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