00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00028 #ifndef AVCODEC_MPEGVIDEO_H
00029 #define AVCODEC_MPEGVIDEO_H
00030
00031 #include "dsputil.h"
00032 #include "get_bits.h"
00033 #include "put_bits.h"
00034 #include "ratecontrol.h"
00035 #include "parser.h"
00036 #include "mpeg12data.h"
00037 #include "rl.h"
00038
00039 #define FRAME_SKIPPED 100
00040
00041 enum OutputFormat {
00042 FMT_MPEG1,
00043 FMT_H261,
00044 FMT_H263,
00045 FMT_MJPEG,
00046 FMT_H264,
00047 };
00048
00049 #define MPEG_BUF_SIZE (16 * 1024)
00050
00051 #define QMAT_SHIFT_MMX 16
00052 #define QMAT_SHIFT 22
00053
00054 #define MAX_FCODE 7
00055 #define MAX_MV 2048
00056
00057 #define MAX_THREADS 16
00058
00059 #define MAX_PICTURE_COUNT 32
00060
00061 #define ME_MAP_SIZE 64
00062 #define ME_MAP_SHIFT 3
00063 #define ME_MAP_MV_BITS 11
00064
00065 #define MAX_MB_BYTES (30*16*16*3/8 + 120)
00066
00067 #define INPLACE_OFFSET 16
00068
00069
00070 #define SEQ_END_CODE 0x000001b7
00071 #define SEQ_START_CODE 0x000001b3
00072 #define GOP_START_CODE 0x000001b8
00073 #define PICTURE_START_CODE 0x00000100
00074 #define SLICE_MIN_START_CODE 0x00000101
00075 #define SLICE_MAX_START_CODE 0x000001af
00076 #define EXT_START_CODE 0x000001b5
00077 #define USER_START_CODE 0x000001b2
00078
00082 typedef struct Picture{
00083 FF_COMMON_FRAME
00084
00088 uint8_t *interpolated[3];
00089 int8_t *qscale_table_base;
00090 int16_t (*motion_val_base[2])[2];
00091 uint32_t *mb_type_base;
00092 #define MB_TYPE_INTRA MB_TYPE_INTRA4x4 //default mb_type if there is just one type
00093 #define IS_INTRA4x4(a) ((a)&MB_TYPE_INTRA4x4)
00094 #define IS_INTRA16x16(a) ((a)&MB_TYPE_INTRA16x16)
00095 #define IS_PCM(a) ((a)&MB_TYPE_INTRA_PCM)
00096 #define IS_INTRA(a) ((a)&7)
00097 #define IS_INTER(a) ((a)&(MB_TYPE_16x16|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8))
00098 #define IS_SKIP(a) ((a)&MB_TYPE_SKIP)
00099 #define IS_INTRA_PCM(a) ((a)&MB_TYPE_INTRA_PCM)
00100 #define IS_INTERLACED(a) ((a)&MB_TYPE_INTERLACED)
00101 #define IS_DIRECT(a) ((a)&MB_TYPE_DIRECT2)
00102 #define IS_GMC(a) ((a)&MB_TYPE_GMC)
00103 #define IS_16X16(a) ((a)&MB_TYPE_16x16)
00104 #define IS_16X8(a) ((a)&MB_TYPE_16x8)
00105 #define IS_8X16(a) ((a)&MB_TYPE_8x16)
00106 #define IS_8X8(a) ((a)&MB_TYPE_8x8)
00107 #define IS_SUB_8X8(a) ((a)&MB_TYPE_16x16) //note reused
00108 #define IS_SUB_8X4(a) ((a)&MB_TYPE_16x8) //note reused
00109 #define IS_SUB_4X8(a) ((a)&MB_TYPE_8x16) //note reused
00110 #define IS_SUB_4X4(a) ((a)&MB_TYPE_8x8) //note reused
00111 #define IS_ACPRED(a) ((a)&MB_TYPE_ACPRED)
00112 #define IS_QUANT(a) ((a)&MB_TYPE_QUANT)
00113 #define IS_DIR(a, part, list) ((a) & (MB_TYPE_P0L0<<((part)+2*(list))))
00114 #define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0|MB_TYPE_P1L0)<<(2*(list))))
00115 #define HAS_CBP(a) ((a)&MB_TYPE_CBP)
00116
00117 int field_poc[2];
00118 int poc;
00119 int frame_num;
00120 int mmco_reset;
00121 int pic_id;
00123 int long_ref;
00124 int ref_poc[2][2][16];
00125 int ref_count[2][2];
00126 int mbaff;
00127
00128 int mb_var_sum;
00129 int mc_mb_var_sum;
00130 uint16_t *mb_var;
00131 uint16_t *mc_mb_var;
00132 uint8_t *mb_mean;
00133 int32_t *mb_cmp_score;
00134 int b_frame_score;
00135 } Picture;
00136
00137 struct MpegEncContext;
00138
00142 typedef struct MotionEstContext{
00143 AVCodecContext *avctx;
00144 int skip;
00145 int co_located_mv[4][2];
00146 int direct_basis_mv[4][2];
00147 uint8_t *scratchpad;
00148 uint8_t *best_mb;
00149 uint8_t *temp_mb[2];
00150 uint8_t *temp;
00151 int best_bits;
00152 uint32_t *map;
00153 uint32_t *score_map;
00154 int map_generation;
00155 int pre_penalty_factor;
00156 int penalty_factor;
00161 int sub_penalty_factor;
00162 int mb_penalty_factor;
00163 int flags;
00164 int sub_flags;
00165 int mb_flags;
00166 int pre_pass;
00167 int dia_size;
00168 int xmin;
00169 int xmax;
00170 int ymin;
00171 int ymax;
00172 int pred_x;
00173 int pred_y;
00174 uint8_t *src[4][4];
00175 uint8_t *ref[4][4];
00176 int stride;
00177 int uvstride;
00178
00179 int mc_mb_var_sum_temp;
00180 int mb_var_sum_temp;
00181 int scene_change_score;
00182
00183 op_pixels_func (*hpel_put)[4];
00184 op_pixels_func (*hpel_avg)[4];
00185 qpel_mc_func (*qpel_put)[16];
00186 qpel_mc_func (*qpel_avg)[16];
00187 uint8_t (*mv_penalty)[MAX_MV*2+1];
00188 uint8_t *current_mv_penalty;
00189 int (*sub_motion_search)(struct MpegEncContext * s,
00190 int *mx_ptr, int *my_ptr, int dmin,
00191 int src_index, int ref_index,
00192 int size, int h);
00193 }MotionEstContext;
00194
00198 typedef struct MpegEncContext {
00199 struct AVCodecContext *avctx;
00200
00201 int width, height;
00202 int gop_size;
00203 int intra_only;
00204 int bit_rate;
00205 enum OutputFormat out_format;
00206 int h263_pred;
00207 int pb_frame;
00208
00209
00210 int h263_plus;
00211 int h263_msmpeg4;
00212 int h263_flv;
00213
00214 enum CodecID codec_id;
00215 int fixed_qscale;
00216 int encoding;
00217 int flags;
00218 int flags2;
00219 int max_b_frames;
00220 int luma_elim_threshold;
00221 int chroma_elim_threshold;
00222 int strict_std_compliance;
00223 int workaround_bugs;
00224 int codec_tag;
00225 int stream_codec_tag;
00226
00227
00229 PutBitContext pb;
00230
00231
00232 int context_initialized;
00233 int input_picture_number;
00234 int coded_picture_number;
00235 int picture_number;
00236 int picture_in_gop_number;
00237 int b_frames_since_non_b;
00238 int64_t user_specified_pts;
00239 int mb_width, mb_height;
00240 int mb_stride;
00241 int b8_stride;
00242 int b4_stride;
00243 int h_edge_pos, v_edge_pos;
00244 int mb_num;
00245 int linesize;
00246 int uvlinesize;
00247 Picture *picture;
00248 Picture **input_picture;
00249 Picture **reordered_input_picture;
00250
00251 int start_mb_y;
00252 int end_mb_y;
00253 struct MpegEncContext *thread_context[MAX_THREADS];
00254
00259 Picture last_picture;
00260
00265 Picture next_picture;
00266
00271 Picture new_picture;
00272
00277 Picture current_picture;
00278
00279 Picture *last_picture_ptr;
00280 Picture *next_picture_ptr;
00281 Picture *current_picture_ptr;
00282 uint8_t *visualization_buffer[3];
00283 int last_dc[3];
00284 int16_t *dc_val_base;
00285 int16_t *dc_val[3];
00286 int16_t dc_cache[4*5];
00287 int y_dc_scale, c_dc_scale;
00288 const uint8_t *y_dc_scale_table;
00289 const uint8_t *c_dc_scale_table;
00290 const uint8_t *chroma_qscale_table;
00291 uint8_t *coded_block_base;
00292 uint8_t *coded_block;
00293 int16_t (*ac_val_base)[16];
00294 int16_t (*ac_val[3])[16];
00295 int ac_pred;
00296 uint8_t *prev_pict_types;
00297 #define PREV_PICT_TYPES_BUFFER_SIZE 256
00298 int mb_skipped;
00299 uint8_t *mbskip_table;
00301 uint8_t *mbintra_table;
00302 uint8_t *cbp_table;
00303 uint8_t *pred_dir_table;
00304 uint8_t *allocated_edge_emu_buffer;
00305 uint8_t *edge_emu_buffer;
00306 uint8_t *rd_scratchpad;
00307 uint8_t *obmc_scratchpad;
00308 uint8_t *b_scratchpad;
00309
00310 int qscale;
00311 int chroma_qscale;
00312 unsigned int lambda;
00313 unsigned int lambda2;
00314 int *lambda_table;
00315 int adaptive_quant;
00316 int dquant;
00317 int closed_gop;
00318 int pict_type;
00319 int last_pict_type;
00320 int last_non_b_pict_type;
00321 int dropable;
00322 int frame_rate_index;
00323 int last_lambda_for[5];
00324 int skipdct;
00325
00326
00327 int unrestricted_mv;
00328 int h263_long_vectors;
00329 int decode;
00330
00331 DSPContext dsp;
00332 int f_code;
00333 int b_code;
00334 int16_t (*p_mv_table_base)[2];
00335 int16_t (*b_forw_mv_table_base)[2];
00336 int16_t (*b_back_mv_table_base)[2];
00337 int16_t (*b_bidir_forw_mv_table_base)[2];
00338 int16_t (*b_bidir_back_mv_table_base)[2];
00339 int16_t (*b_direct_mv_table_base)[2];
00340 int16_t (*p_field_mv_table_base[2][2])[2];
00341 int16_t (*b_field_mv_table_base[2][2][2])[2];
00342 int16_t (*p_mv_table)[2];
00343 int16_t (*b_forw_mv_table)[2];
00344 int16_t (*b_back_mv_table)[2];
00345 int16_t (*b_bidir_forw_mv_table)[2];
00346 int16_t (*b_bidir_back_mv_table)[2];
00347 int16_t (*b_direct_mv_table)[2];
00348 int16_t (*p_field_mv_table[2][2])[2];
00349 int16_t (*b_field_mv_table[2][2][2])[2];
00350 uint8_t (*p_field_select_table[2]);
00351 uint8_t (*b_field_select_table[2][2]);
00352 int me_method;
00353 int mv_dir;
00354 #define MV_DIR_FORWARD 1
00355 #define MV_DIR_BACKWARD 2
00356 #define MV_DIRECT 4
00357 int mv_type;
00358 #define MV_TYPE_16X16 0
00359 #define MV_TYPE_8X8 1
00360 #define MV_TYPE_16X8 2
00361 #define MV_TYPE_FIELD 3
00362 #define MV_TYPE_DMV 4
00363
00368 int mv[2][4][2];
00369 int field_select[2][2];
00370 int last_mv[2][2][2];
00371 uint8_t *fcode_tab;
00372 int16_t direct_scale_mv[2][64];
00373
00374 MotionEstContext me;
00375
00376 int no_rounding;
00379 int hurry_up;
00382
00383 int mb_x, mb_y;
00384 int mb_skip_run;
00385 int mb_intra;
00386 uint16_t *mb_type;
00387 #define CANDIDATE_MB_TYPE_INTRA 0x01
00388 #define CANDIDATE_MB_TYPE_INTER 0x02
00389 #define CANDIDATE_MB_TYPE_INTER4V 0x04
00390 #define CANDIDATE_MB_TYPE_SKIPPED 0x08
00391
00392
00393 #define CANDIDATE_MB_TYPE_DIRECT 0x10
00394 #define CANDIDATE_MB_TYPE_FORWARD 0x20
00395 #define CANDIDATE_MB_TYPE_BACKWARD 0x40
00396 #define CANDIDATE_MB_TYPE_BIDIR 0x80
00397
00398 #define CANDIDATE_MB_TYPE_INTER_I 0x100
00399 #define CANDIDATE_MB_TYPE_FORWARD_I 0x200
00400 #define CANDIDATE_MB_TYPE_BACKWARD_I 0x400
00401 #define CANDIDATE_MB_TYPE_BIDIR_I 0x800
00402
00403 #define CANDIDATE_MB_TYPE_DIRECT0 0x1000
00404
00405 int block_index[6];
00406 int block_wrap[6];
00407 uint8_t *dest[3];
00408
00409 int *mb_index2xy;
00410
00412 uint16_t intra_matrix[64];
00413 uint16_t chroma_intra_matrix[64];
00414 uint16_t inter_matrix[64];
00415 uint16_t chroma_inter_matrix[64];
00416 #define QUANT_BIAS_SHIFT 8
00417 int intra_quant_bias;
00418 int inter_quant_bias;
00419 int min_qcoeff;
00420 int max_qcoeff;
00421 int ac_esc_length;
00422 uint8_t *intra_ac_vlc_length;
00423 uint8_t *intra_ac_vlc_last_length;
00424 uint8_t *inter_ac_vlc_length;
00425 uint8_t *inter_ac_vlc_last_length;
00426 uint8_t *luma_dc_vlc_length;
00427 uint8_t *chroma_dc_vlc_length;
00428 #define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level))
00429
00430 int coded_score[8];
00431
00433 int (*q_intra_matrix)[64];
00434 int (*q_inter_matrix)[64];
00436 uint16_t (*q_intra_matrix16)[2][64];
00437 uint16_t (*q_inter_matrix16)[2][64];
00438 int block_last_index[12];
00439
00440 ScanTable intra_scantable;
00441 ScanTable intra_h_scantable;
00442 ScanTable intra_v_scantable;
00443 ScanTable inter_scantable;
00444
00445
00446 int (*dct_error_sum)[64];
00447 int dct_count[2];
00448 uint16_t (*dct_offset)[64];
00449
00450 void *opaque;
00451
00452
00453 int64_t wanted_bits;
00454 int64_t total_bits;
00455 int frame_bits;
00456 int next_lambda;
00457 RateControlContext rc_context;
00458
00459
00460 int mv_bits;
00461 int header_bits;
00462 int i_tex_bits;
00463 int p_tex_bits;
00464 int i_count;
00465 int f_count;
00466 int b_count;
00467 int skip_count;
00468 int misc_bits;
00469 int last_bits;
00470
00471
00472 int error_count;
00473 uint8_t *error_status_table;
00474 #define VP_START 1
00475 #define AC_ERROR 2
00476 #define DC_ERROR 4
00477 #define MV_ERROR 8
00478 #define AC_END 16
00479 #define DC_END 32
00480 #define MV_END 64
00481
00482
00483 int resync_mb_x;
00484 int resync_mb_y;
00485 GetBitContext last_resync_gb;
00486 int mb_num_left;
00487 int next_p_frame_damaged;
00488 int error_recognition;
00489
00490 ParseContext parse_context;
00491
00492
00493 int gob_index;
00494 int obmc;
00495 int showed_packed_warning;
00496
00497
00498 int umvplus;
00499 int h263_aic;
00500 int h263_aic_dir;
00501 int h263_slice_structured;
00502 int alt_inter_vlc;
00503 int modified_quant;
00504 int loop_filter;
00505 int custom_pcf;
00506
00507
00508 int time_increment_bits;
00509 int last_time_base;
00510 int time_base;
00511 int64_t time;
00512 int64_t last_non_b_time;
00513 uint16_t pp_time;
00514 uint16_t pb_time;
00515 uint16_t pp_field_time;
00516 uint16_t pb_field_time;
00517 int shape;
00518 int vol_sprite_usage;
00519 int sprite_width;
00520 int sprite_height;
00521 int sprite_left;
00522 int sprite_top;
00523 int sprite_brightness_change;
00524 int num_sprite_warping_points;
00525 int real_sprite_warping_points;
00526 uint16_t sprite_traj[4][2];
00527 int sprite_offset[2][2];
00528 int sprite_delta[2][2];
00529 int sprite_shift[2];
00530 int mcsel;
00531 int quant_precision;
00532 int quarter_sample;
00533 int scalability;
00534 int hierachy_type;
00535 int enhancement_type;
00536 int new_pred;
00537 int reduced_res_vop;
00538 int aspect_ratio_info;
00539 int sprite_warping_accuracy;
00540 int low_latency_sprite;
00541 int data_partitioning;
00542 int partitioned_frame;
00543 int rvlc;
00544 int resync_marker;
00545 int low_delay;
00546 int vo_type;
00547 int vol_control_parameters;
00548 int intra_dc_threshold;
00549 int use_intra_dc_vlc;
00550 PutBitContext tex_pb;
00551 PutBitContext pb2;
00552 int mpeg_quant;
00553 int t_frame;
00554 int padding_bug_score;
00555 int cplx_estimation_trash_i;
00556 int cplx_estimation_trash_p;
00557 int cplx_estimation_trash_b;
00558
00559
00560 int divx_version;
00561 int divx_build;
00562 int divx_packed;
00563 uint8_t *bitstream_buffer;
00564 int bitstream_buffer_size;
00565 unsigned int allocated_bitstream_buffer_size;
00566
00567 int xvid_build;
00568
00569
00570 int lavc_build;
00571
00572
00573 int rv10_version;
00574 int rv10_first_dc_coded[3];
00575 int orig_width, orig_height;
00576
00577
00578 struct MJpegContext *mjpeg_ctx;
00579 int mjpeg_vsample[3];
00580 int mjpeg_hsample[3];
00581
00582
00583 int mv_table_index;
00584 int rl_table_index;
00585 int rl_chroma_table_index;
00586 int dc_table_index;
00587 int use_skip_mb_code;
00588 int slice_height;
00589 int first_slice_line;
00590 int flipflop_rounding;
00591 int msmpeg4_version;
00592 int per_mb_rl_table;
00593 int esc3_level_length;
00594 int esc3_run_length;
00596 int (*ac_stats)[2][MAX_LEVEL+1][MAX_RUN+1][2];
00597 int inter_intra_pred;
00598 int mspel;
00599
00600
00601 GetBitContext gb;
00602
00603
00604 int gop_picture_number;
00605 int last_mv_dir;
00606 int broken_link;
00607 uint8_t *vbv_delay_ptr;
00608
00609
00610 int progressive_sequence;
00611 int mpeg_f_code[2][2];
00612 int picture_structure;
00613
00614 #define PICT_TOP_FIELD 1
00615 #define PICT_BOTTOM_FIELD 2
00616 #define PICT_FRAME 3
00617
00618 int intra_dc_precision;
00619 int frame_pred_frame_dct;
00620 int top_field_first;
00621 int concealment_motion_vectors;
00622 int q_scale_type;
00623 int intra_vlc_format;
00624 int alternate_scan;
00625 int repeat_first_field;
00626 int chroma_420_type;
00627 int chroma_format;
00628 #define CHROMA_420 1
00629 #define CHROMA_422 2
00630 #define CHROMA_444 3
00631 int chroma_x_shift;
00632 int chroma_y_shift;
00633
00634 int progressive_frame;
00635 int full_pel[2];
00636 int interlaced_dct;
00637 int first_slice;
00638 int first_field;
00639
00640
00641 int rtp_mode;
00642
00643 uint8_t *ptr_lastgob;
00644 int swap_uv;
00645 DCTELEM (*pblocks[12])[64];
00646
00647 DCTELEM (*block)[64];
00648 DCTELEM (*blocks)[8][64];
00649 int (*decode_mb)(struct MpegEncContext *s, DCTELEM block[6][64]);
00650 #define SLICE_OK 0
00651 #define SLICE_ERROR -1
00652 #define SLICE_END -2
00653 #define SLICE_NOEND -3
00654
00655 void (*dct_unquantize_mpeg1_intra)(struct MpegEncContext *s,
00656 DCTELEM *block, int n, int qscale);
00657 void (*dct_unquantize_mpeg1_inter)(struct MpegEncContext *s,
00658 DCTELEM *block, int n, int qscale);
00659 void (*dct_unquantize_mpeg2_intra)(struct MpegEncContext *s,
00660 DCTELEM *block, int n, int qscale);
00661 void (*dct_unquantize_mpeg2_inter)(struct MpegEncContext *s,
00662 DCTELEM *block, int n, int qscale);
00663 void (*dct_unquantize_h263_intra)(struct MpegEncContext *s,
00664 DCTELEM *block, int n, int qscale);
00665 void (*dct_unquantize_h263_inter)(struct MpegEncContext *s,
00666 DCTELEM *block, int n, int qscale);
00667 void (*dct_unquantize_h261_intra)(struct MpegEncContext *s,
00668 DCTELEM *block, int n, int qscale);
00669 void (*dct_unquantize_h261_inter)(struct MpegEncContext *s,
00670 DCTELEM *block, int n, int qscale);
00671 void (*dct_unquantize_intra)(struct MpegEncContext *s,
00672 DCTELEM *block, int n, int qscale);
00673 void (*dct_unquantize_inter)(struct MpegEncContext *s,
00674 DCTELEM *block, int n, int qscale);
00675 int (*dct_quantize)(struct MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
00676 int (*fast_dct_quantize)(struct MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
00677 void (*denoise_dct)(struct MpegEncContext *s, DCTELEM *block);
00678 } MpegEncContext;
00679
00680
00681 void MPV_decode_defaults(MpegEncContext *s);
00682 int MPV_common_init(MpegEncContext *s);
00683 void MPV_common_end(MpegEncContext *s);
00684 void MPV_decode_mb(MpegEncContext *s, DCTELEM block[12][64]);
00685 int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx);
00686 void MPV_frame_end(MpegEncContext *s);
00687 int MPV_encode_init(AVCodecContext *avctx);
00688 int MPV_encode_end(AVCodecContext *avctx);
00689 int MPV_encode_picture(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data);
00690 void MPV_common_init_mmx(MpegEncContext *s);
00691 void MPV_common_init_axp(MpegEncContext *s);
00692 void MPV_common_init_mlib(MpegEncContext *s);
00693 void MPV_common_init_mmi(MpegEncContext *s);
00694 void MPV_common_init_arm(MpegEncContext *s);
00695 void MPV_common_init_altivec(MpegEncContext *s);
00696 void MPV_common_init_bfin(MpegEncContext *s);
00697 void ff_clean_intra_table_entries(MpegEncContext *s);
00698 void ff_draw_horiz_band(MpegEncContext *s, int y, int h);
00699 void ff_mpeg_flush(AVCodecContext *avctx);
00700 void ff_print_debug_info(MpegEncContext *s, AVFrame *pict);
00701 void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix);
00702 int ff_find_unused_picture(MpegEncContext *s, int shared);
00703 void ff_denoise_dct(MpegEncContext *s, DCTELEM *block);
00704 void ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src);
00705 const uint8_t *ff_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state);
00706 void ff_set_qscale(MpegEncContext * s, int qscale);
00707
00708 void ff_er_frame_start(MpegEncContext *s);
00709 void ff_er_frame_end(MpegEncContext *s);
00710 void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int endy, int status);
00711
00712 int ff_dct_common_init(MpegEncContext *s);
00713 void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][64],
00714 const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra);
00715
00716 void ff_init_block_index(MpegEncContext *s);
00717 void ff_copy_picture(Picture *dst, Picture *src);
00718
00723 int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared);
00724
00725 extern const enum PixelFormat ff_pixfmt_list_420[];
00726 extern const enum PixelFormat ff_hwaccel_pixfmt_list_420[];
00727
00728 static inline void ff_update_block_index(MpegEncContext *s){
00729 const int block_size= 8>>s->avctx->lowres;
00730
00731 s->block_index[0]+=2;
00732 s->block_index[1]+=2;
00733 s->block_index[2]+=2;
00734 s->block_index[3]+=2;
00735 s->block_index[4]++;
00736 s->block_index[5]++;
00737 s->dest[0]+= 2*block_size;
00738 s->dest[1]+= block_size;
00739 s->dest[2]+= block_size;
00740 }
00741
00742 static inline int get_bits_diff(MpegEncContext *s){
00743 const int bits= put_bits_count(&s->pb);
00744 const int last= s->last_bits;
00745
00746 s->last_bits = bits;
00747
00748 return bits - last;
00749 }
00750
00751 static inline int ff_h263_round_chroma(int x){
00752 static const uint8_t h263_chroma_roundtab[16] = {
00753
00754 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1,
00755 };
00756 return h263_chroma_roundtab[x & 0xf] + (x >> 3);
00757 }
00758
00759
00760 void ff_estimate_p_frame_motion(MpegEncContext * s,
00761 int mb_x, int mb_y);
00762 void ff_estimate_b_frame_motion(MpegEncContext * s,
00763 int mb_x, int mb_y);
00764 int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type);
00765 void ff_fix_long_p_mvs(MpegEncContext * s);
00766 void ff_fix_long_mvs(MpegEncContext * s, uint8_t *field_select_table, int field_select,
00767 int16_t (*mv_table)[2], int f_code, int type, int truncate);
00768 int ff_init_me(MpegEncContext *s);
00769 int ff_pre_estimate_p_frame_motion(MpegEncContext * s, int mb_x, int mb_y);
00770 int ff_epzs_motion_search(MpegEncContext * s, int *mx_ptr, int *my_ptr,
00771 int P[10][2], int src_index, int ref_index, int16_t (*last_mv)[2],
00772 int ref_mv_scale, int size, int h);
00773 int ff_get_mb_score(MpegEncContext * s, int mx, int my, int src_index,
00774 int ref_index, int size, int h, int add_rate);
00775
00776
00777 extern const uint8_t ff_mpeg1_dc_scale_table[128];
00778 extern const uint8_t * const ff_mpeg2_dc_scale_table[4];
00779
00780 void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number);
00781 void mpeg1_encode_mb(MpegEncContext *s,
00782 DCTELEM block[6][64],
00783 int motion_x, int motion_y);
00784 void ff_mpeg1_encode_init(MpegEncContext *s);
00785 void ff_mpeg1_encode_slice_header(MpegEncContext *s);
00786 void ff_mpeg1_clean_buffers(MpegEncContext *s);
00787 int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, AVCodecParserContext *s);
00788
00789 extern const uint8_t ff_aic_dc_scale_table[32];
00790 extern const uint8_t ff_h263_chroma_qscale_table[32];
00791 extern const uint8_t ff_h263_loop_filter_strength[32];
00792
00793
00794 void ff_h261_loop_filter(MpegEncContext *s);
00795 void ff_h261_reorder_mb_index(MpegEncContext* s);
00796 void ff_h261_encode_mb(MpegEncContext *s,
00797 DCTELEM block[6][64],
00798 int motion_x, int motion_y);
00799 void ff_h261_encode_picture_header(MpegEncContext * s, int picture_number);
00800 void ff_h261_encode_init(MpegEncContext *s);
00801 int ff_h261_get_picture_format(int width, int height);
00802
00803
00804
00805 void rv10_encode_picture_header(MpegEncContext *s, int picture_number);
00806 int rv_decode_dc(MpegEncContext *s, int n);
00807 void rv20_encode_picture_header(MpegEncContext *s, int picture_number);
00808
00809
00810
00811 void msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number);
00812 void msmpeg4_encode_ext_header(MpegEncContext * s);
00813 void msmpeg4_encode_mb(MpegEncContext * s,
00814 DCTELEM block[6][64],
00815 int motion_x, int motion_y);
00816 int msmpeg4_decode_picture_header(MpegEncContext * s);
00817 int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size);
00818 int ff_msmpeg4_decode_init(AVCodecContext *avctx);
00819 void ff_msmpeg4_encode_init(MpegEncContext *s);
00820 int ff_wmv2_decode_picture_header(MpegEncContext * s);
00821 int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s);
00822 void ff_wmv2_add_mb(MpegEncContext *s, DCTELEM block[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr);
00823 void ff_mspel_motion(MpegEncContext *s,
00824 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
00825 uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
00826 int motion_x, int motion_y, int h);
00827 int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number);
00828 void ff_wmv2_encode_mb(MpegEncContext * s,
00829 DCTELEM block[6][64],
00830 int motion_x, int motion_y);
00831
00832 #endif
00833