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