Mercurial > libavcodec.hg
comparison mpegvideo.h @ 456:c006ee838856 libavcodec
single coefficient elimination
prequantization
more readable malloc & check if NULL
error concealment / error resilience
b_quant_offset (unfinished, should be 0 for now)
data partitioning
author | michaelni |
---|---|
date | Sun, 02 Jun 2002 12:20:39 +0000 |
parents | 000aeeac27a2 |
children | 1ca0876f99bc |
comparison
equal
deleted
inserted
replaced
455:7f2d2be2aee9 | 456:c006ee838856 |
---|---|
35 | 35 |
36 #define MAX_FCODE 7 | 36 #define MAX_FCODE 7 |
37 #define MAX_MV 2048 | 37 #define MAX_MV 2048 |
38 #define REORDER_BUFFER_SIZE (FF_MAX_B_FRAMES+2) | 38 #define REORDER_BUFFER_SIZE (FF_MAX_B_FRAMES+2) |
39 | 39 |
40 #define ME_MAP_SIZE 64 | |
41 #define ME_MAP_SHIFT 3 | |
42 #define ME_MAP_MV_BITS 11 | |
43 | |
40 typedef struct Predictor{ | 44 typedef struct Predictor{ |
41 double coeff; | 45 double coeff; |
42 double count; | 46 double count; |
43 double decay; | 47 double decay; |
44 } Predictor; | 48 } Predictor; |
98 int encoding; /* true if we are encoding (vs decoding) */ | 102 int encoding; /* true if we are encoding (vs decoding) */ |
99 int flags; /* AVCodecContext.flags (HQ, MV4, ...) */ | 103 int flags; /* AVCodecContext.flags (HQ, MV4, ...) */ |
100 int force_input_type;/* 0= no force, otherwise I_TYPE, P_TYPE, ... */ | 104 int force_input_type;/* 0= no force, otherwise I_TYPE, P_TYPE, ... */ |
101 int max_b_frames; /* max number of b-frames for encoding */ | 105 int max_b_frames; /* max number of b-frames for encoding */ |
102 float b_quant_factor;/* qscale factor between ips and b frames */ | 106 float b_quant_factor;/* qscale factor between ips and b frames */ |
107 float b_quant_offset;/* qscale offset between ips and b frames */ | |
103 int rc_strategy; | 108 int rc_strategy; |
104 int b_frame_strategy; | 109 int b_frame_strategy; |
110 int luma_elim_threshold; | |
111 int chroma_elim_threshold; | |
112 int strict_std_compliance; /* strictly follow the std (MPEG4, ...) */ | |
105 int workaround_bugs; /* workaround bugs in encoders which cannot be detected automatically */ | 113 int workaround_bugs; /* workaround bugs in encoders which cannot be detected automatically */ |
106 /* the following fields are managed internally by the encoder */ | 114 /* the following fields are managed internally by the encoder */ |
107 | 115 |
108 /* bit output */ | 116 /* bit output */ |
109 PutBitContext pb; | 117 PutBitContext pb; |
140 int ac_pred; | 148 int ac_pred; |
141 int mb_skiped; /* MUST BE SET only during DECODING */ | 149 int mb_skiped; /* MUST BE SET only during DECODING */ |
142 UINT8 *mbskip_table; /* used to avoid copy if macroblock skipped (for black regions for example) | 150 UINT8 *mbskip_table; /* used to avoid copy if macroblock skipped (for black regions for example) |
143 and used for b-frame encoding & decoding (contains skip table of next P Frame) */ | 151 and used for b-frame encoding & decoding (contains skip table of next P Frame) */ |
144 UINT8 *mbintra_table; /* used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding */ | 152 UINT8 *mbintra_table; /* used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding */ |
153 UINT8 *cbp_table; /* used to store cbp, ac_pred for partitioned decoding */ | |
154 UINT8 *pred_dir_table; /* used to store pred_dir for partitioned decoding */ | |
155 INT8 *qscale_table; /* used to store qscale for partitioned decoding (& postprocessing FIXME export) */ | |
145 | 156 |
146 int input_qscale; /* qscale prior to reordering of frames */ | 157 int input_qscale; /* qscale prior to reordering of frames */ |
147 int input_pict_type; /* pict_type prior to reordering of frames */ | 158 int input_pict_type; /* pict_type prior to reordering of frames */ |
148 int force_type; /* 0= no force, otherwise I_TYPE, P_TYPE, ... */ | 159 int force_type; /* 0= no force, otherwise I_TYPE, P_TYPE, ... */ |
149 int qscale; /* QP */ | 160 int qscale; /* QP */ |
157 | 168 |
158 int f_code; /* forward MV resolution */ | 169 int f_code; /* forward MV resolution */ |
159 int b_code; /* backward MV resolution for B Frames (mpeg4) */ | 170 int b_code; /* backward MV resolution for B Frames (mpeg4) */ |
160 INT16 (*motion_val)[2]; /* used for MV prediction (4MV per MB) */ | 171 INT16 (*motion_val)[2]; /* used for MV prediction (4MV per MB) */ |
161 INT16 (*p_mv_table)[2]; /* MV table (1MV per MB) p-frame encoding */ | 172 INT16 (*p_mv_table)[2]; /* MV table (1MV per MB) p-frame encoding */ |
162 INT16 (*last_p_mv_table)[2]; /* MV table (1MV per MB) p-frame encoding */ | |
163 INT16 (*b_forw_mv_table)[2]; /* MV table (1MV per MB) forward mode b-frame encoding */ | 173 INT16 (*b_forw_mv_table)[2]; /* MV table (1MV per MB) forward mode b-frame encoding */ |
164 INT16 (*b_back_mv_table)[2]; /* MV table (1MV per MB) backward mode b-frame encoding */ | 174 INT16 (*b_back_mv_table)[2]; /* MV table (1MV per MB) backward mode b-frame encoding */ |
165 INT16 (*b_bidir_forw_mv_table)[2]; /* MV table (1MV per MB) bidir mode b-frame encoding */ | 175 INT16 (*b_bidir_forw_mv_table)[2]; /* MV table (1MV per MB) bidir mode b-frame encoding */ |
166 INT16 (*b_bidir_back_mv_table)[2]; /* MV table (1MV per MB) bidir mode b-frame encoding */ | 176 INT16 (*b_bidir_back_mv_table)[2]; /* MV table (1MV per MB) bidir mode b-frame encoding */ |
167 INT16 (*b_direct_forw_mv_table)[2];/* MV table (1MV per MB) direct mode b-frame encoding */ | 177 INT16 (*b_direct_forw_mv_table)[2];/* MV table (1MV per MB) direct mode b-frame encoding */ |
168 INT16 (*b_direct_back_mv_table)[2];/* MV table (1MV per MB) direct mode b-frame encoding */ | 178 INT16 (*b_direct_back_mv_table)[2];/* MV table (1MV per MB) direct mode b-frame encoding */ |
169 INT16 (*b_direct_mv_table)[2]; /* MV table (1MV per MB) direct mode b-frame encoding */ | 179 INT16 (*b_direct_mv_table)[2]; /* MV table (1MV per MB) direct mode b-frame encoding */ |
170 int me_method; /* ME algorithm */ | 180 int me_method; /* ME algorithm */ |
171 uint8_t *me_scratchpad; /* data area for the me algo, so that the ME doesnt need to malloc/free */ | 181 uint8_t *me_scratchpad; /* data area for the me algo, so that the ME doesnt need to malloc/free */ |
182 uint32_t *me_map; /* map to avoid duplicate evaluations */ | |
183 uint16_t *me_score_map; /* map to store the SADs */ | |
184 int me_map_generation; | |
185 int skip_me; /* set if ME is skiped for the current MB */ | |
172 int mv_dir; | 186 int mv_dir; |
173 #define MV_DIR_BACKWARD 1 | 187 #define MV_DIR_BACKWARD 1 |
174 #define MV_DIR_FORWARD 2 | 188 #define MV_DIR_FORWARD 2 |
175 #define MV_DIRECT 4 // bidirectional mode where the difference equals the MV of the last P/S/I-Frame (mpeg4) | 189 #define MV_DIRECT 4 // bidirectional mode where the difference equals the MV of the last P/S/I-Frame (mpeg4) |
176 int mv_type; | 190 int mv_type; |
199 | 213 |
200 /* macroblock layer */ | 214 /* macroblock layer */ |
201 int mb_x, mb_y; | 215 int mb_x, mb_y; |
202 int mb_incr; | 216 int mb_incr; |
203 int mb_intra; | 217 int mb_intra; |
204 UINT16 *mb_var; /* Table for MB variances */ | 218 UINT16 *mb_var; /* Table for MB variances */ |
205 UINT8 *mb_type; /* Table for MB type */ | 219 UINT16 *mc_mb_var; /* Table for motion compensated MB variances */ |
220 UINT8 *mb_type; /* Table for MB type */ | |
206 #define MB_TYPE_INTRA 0x01 | 221 #define MB_TYPE_INTRA 0x01 |
207 #define MB_TYPE_INTER 0x02 | 222 #define MB_TYPE_INTER 0x02 |
208 #define MB_TYPE_INTER4V 0x04 | 223 #define MB_TYPE_INTER4V 0x04 |
209 #define MB_TYPE_SKIPED 0x08 | 224 #define MB_TYPE_SKIPED 0x08 |
225 #define MB_TYPE_GMC 0x10 | |
226 | |
210 #define MB_TYPE_DIRECT 0x10 | 227 #define MB_TYPE_DIRECT 0x10 |
211 #define MB_TYPE_FORWARD 0x20 | 228 #define MB_TYPE_FORWARD 0x20 |
212 #define MB_TYPE_BACKWARD 0x40 | 229 #define MB_TYPE_BACKWARD 0x40 |
213 #define MB_TYPE_BIDIR 0x80 | 230 #define MB_TYPE_BIDIR 0x80 |
214 | 231 |
237 | 254 |
238 void *opaque; /* private data for the user */ | 255 void *opaque; /* private data for the user */ |
239 | 256 |
240 /* bit rate control */ | 257 /* bit rate control */ |
241 int I_frame_bits; //FIXME used in mpeg12 ... | 258 int I_frame_bits; //FIXME used in mpeg12 ... |
242 int avg_mb_var; /* average MB variance for current frame */ | 259 int mb_var_sum; /* sum of MB variance for current frame */ |
243 int mc_mb_var; /* motion compensated MB variance for current frame */ | 260 int mc_mb_var_sum; /* motion compensated MB variance for current frame */ |
244 int last_non_b_mc_mb_var;/* motion compensated MB variance for last non b frame */ | 261 int last_non_b_mc_mb_var;/* motion compensated MB variance for last non b frame */ |
245 INT64 wanted_bits; | 262 INT64 wanted_bits; |
246 INT64 total_bits; | 263 INT64 total_bits; |
247 int frame_bits; /* bits used for the current frame */ | 264 int frame_bits; /* bits used for the current frame */ |
248 int pb_frame_bits; /* bits of the last b...bp group */ | 265 int pb_frame_bits; /* bits of the last b...bp group */ |
262 int i_count; | 279 int i_count; |
263 int p_count; | 280 int p_count; |
264 int skip_count; | 281 int skip_count; |
265 int misc_bits; // cbp, mb_type | 282 int misc_bits; // cbp, mb_type |
266 int last_bits; //temp var used for calculating the above vars | 283 int last_bits; //temp var used for calculating the above vars |
284 | |
285 /* error concealment / resync */ | |
286 int resync_mb_x; /* x position of last resync marker */ | |
287 int resync_mb_y; /* y position of last resync marker */ | |
288 int mb_num_left; /* number of MBs left in this video packet */ | |
289 GetBitContext next_resync_gb; /* starts at the next resync marker */ | |
290 int next_resync_qscale; /* qscale of next resync marker */ | |
291 int next_resync_pos; /* bitstream position of next resync marker */ | |
292 #define DECODING_AC_LOST -1 | |
293 #define DECODING_ACDC_LOST -2 | |
294 #define DECODING_DESYNC -3 | |
295 int decoding_error; | |
296 int next_p_frame_damaged; /* set if the next p frame is damaged, to avoid showing trashed b frames */ | |
297 int error_resilience; | |
267 | 298 |
268 /* H.263 specific */ | 299 /* H.263 specific */ |
269 int gob_number; | 300 int gob_number; |
270 int gob_index; | 301 int gob_index; |
271 int first_gob_line; | |
272 | 302 |
273 /* H.263+ specific */ | 303 /* H.263+ specific */ |
274 int umvplus; | 304 int umvplus; |
275 int umvplus_dec; | 305 int umvplus_dec; |
276 int h263_aic; /* Advanded INTRA Coding (AIC) */ | 306 int h263_aic; /* Advanded INTRA Coding (AIC) */ |
304 int new_pred; | 334 int new_pred; |
305 int reduced_res_vop; | 335 int reduced_res_vop; |
306 int aspect_ratio_info; | 336 int aspect_ratio_info; |
307 int sprite_warping_accuracy; | 337 int sprite_warping_accuracy; |
308 int low_latency_sprite; | 338 int low_latency_sprite; |
309 int data_partioning; | 339 int data_partitioning; |
310 int resync_marker; | 340 int rvlc; /* reversible vlc */ |
311 int resync_x_pos; | 341 int resync_marker; /* could this stream contain resync markers*/ |
312 int low_delay; /* no reordering needed / has no b-frames */ | 342 int low_delay; /* no reordering needed / has no b-frames */ |
313 int vo_type; | 343 int vo_type; |
314 int vol_control_parameters; /* does the stream contain the low_delay flag, used to workaround buggy encoders */ | 344 int vol_control_parameters; /* does the stream contain the low_delay flag, used to workaround buggy encoders */ |
345 PutBitContext tex_pb; /* used for data partitioned VOPs */ | |
346 PutBitContext pb2; /* used for data partitioned VOPs */ | |
347 #define PB_BUFFER_SIZE 1024*256 | |
348 uint8_t *tex_pb_buffer; | |
349 uint8_t *pb2_buffer; | |
315 | 350 |
316 /* divx specific, used to workaround (many) bugs in divx5 */ | 351 /* divx specific, used to workaround (many) bugs in divx5 */ |
317 int divx_version; | 352 int divx_version; |
318 int divx_build; | 353 int divx_build; |
319 #define BITSTREAM_BUFFER_SIZE 1024*256 | 354 #define BITSTREAM_BUFFER_SIZE 1024*256 |
339 int dc_table_index; | 374 int dc_table_index; |
340 int use_skip_mb_code; | 375 int use_skip_mb_code; |
341 int slice_height; /* in macroblocks */ | 376 int slice_height; /* in macroblocks */ |
342 int first_slice_line; /* used in mpeg4 too to handle resync markers */ | 377 int first_slice_line; /* used in mpeg4 too to handle resync markers */ |
343 int flipflop_rounding; | 378 int flipflop_rounding; |
344 int bitrate; | |
345 int msmpeg4_version; /* 0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 */ | 379 int msmpeg4_version; /* 0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 */ |
346 /* decompression specific */ | 380 /* decompression specific */ |
347 GetBitContext gb; | 381 GetBitContext gb; |
348 | 382 |
349 /* MPEG2 specific - I wish I had not to support this mess. */ | 383 /* MPEG2 specific - I wish I had not to support this mess. */ |
400 #ifdef HAVE_MMX | 434 #ifdef HAVE_MMX |
401 void MPV_common_init_mmx(MpegEncContext *s); | 435 void MPV_common_init_mmx(MpegEncContext *s); |
402 #endif | 436 #endif |
403 int (*dct_quantize)(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow); | 437 int (*dct_quantize)(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow); |
404 void (*draw_edges)(UINT8 *buf, int wrap, int width, int height, int w); | 438 void (*draw_edges)(UINT8 *buf, int wrap, int width, int height, int w); |
439 void ff_conceal_past_errors(MpegEncContext *s, int conceal_all); | |
440 void ff_copy_bits(PutBitContext *pb, UINT8 *src, int length); | |
441 void ff_clean_intra_table_entries(MpegEncContext *s); | |
405 | 442 |
406 /* motion_est.c */ | 443 /* motion_est.c */ |
407 void ff_estimate_p_frame_motion(MpegEncContext * s, | 444 void ff_estimate_p_frame_motion(MpegEncContext * s, |
408 int mb_x, int mb_y); | 445 int mb_x, int mb_y); |
409 void ff_estimate_b_frame_motion(MpegEncContext * s, | 446 void ff_estimate_b_frame_motion(MpegEncContext * s, |
477 int mpeg4_decode_picture_header(MpegEncContext * s); | 514 int mpeg4_decode_picture_header(MpegEncContext * s); |
478 int intel_h263_decode_picture_header(MpegEncContext *s); | 515 int intel_h263_decode_picture_header(MpegEncContext *s); |
479 int h263_decode_mb(MpegEncContext *s, | 516 int h263_decode_mb(MpegEncContext *s, |
480 DCTELEM block[6][64]); | 517 DCTELEM block[6][64]); |
481 int h263_get_picture_format(int width, int height); | 518 int h263_get_picture_format(int width, int height); |
519 int ff_mpeg4_decode_video_packet_header(MpegEncContext *s); | |
520 int ff_mpeg4_resync(MpegEncContext *s); | |
521 void ff_mpeg4_encode_video_packet_header(MpegEncContext *s); | |
522 void ff_mpeg4_clean_buffers(MpegEncContext *s); | |
523 void ff_mpeg4_stuffing(PutBitContext * pbc); | |
524 void ff_mpeg4_init_partitions(MpegEncContext *s); | |
525 void ff_mpeg4_merge_partitions(MpegEncContext *s); | |
482 | 526 |
483 /* rv10.c */ | 527 /* rv10.c */ |
484 void rv10_encode_picture_header(MpegEncContext *s, int picture_number); | 528 void rv10_encode_picture_header(MpegEncContext *s, int picture_number); |
485 int rv_decode_dc(MpegEncContext *s, int n); | 529 int rv_decode_dc(MpegEncContext *s, int n); |
486 | 530 |