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