comparison mpegvideo.h @ 903:22ee74da2cd3 libavcodec

cleanup adding AVVideoFrame moving quality, pict_type, key_frame, qscale_table, ... to AVVideoFrame removing obsolete variables in AVCodecContext skiping of MBs in b frames correctly initalizing AVCodecContext picture buffer cleanup
author michaelni
date Wed, 04 Dec 2002 10:04:03 +0000
parents 2c350f59233a
children 8ae1e4c24e91
comparison
equal deleted inserted replaced
902:6acc8394960d 903:22ee74da2cd3
26 FMT_MPEG1, 26 FMT_MPEG1,
27 FMT_H263, 27 FMT_H263,
28 FMT_MJPEG, 28 FMT_MJPEG,
29 }; 29 };
30 30
31 #define EDGE_WIDTH 16
32
31 #define MPEG_BUF_SIZE (16 * 1024) 33 #define MPEG_BUF_SIZE (16 * 1024)
32 34
33 #define QMAT_SHIFT_MMX 16 35 #define QMAT_SHIFT_MMX 16
34 #define QMAT_SHIFT 22 36 #define QMAT_SHIFT 22
35 37
36 #define MAX_FCODE 7 38 #define MAX_FCODE 7
37 #define MAX_MV 2048 39 #define MAX_MV 2048
38 #define REORDER_BUFFER_SIZE (FF_MAX_B_FRAMES+2) 40
41 #define MAX_PICTURE_COUNT 7
39 42
40 #define ME_MAP_SIZE 64 43 #define ME_MAP_SIZE 64
41 #define ME_MAP_SHIFT 3 44 #define ME_MAP_SHIFT 3
42 #define ME_MAP_MV_BITS 11 45 #define ME_MAP_MV_BITS 11
43 46
88 UINT64 qscale_sum[5]; 91 UINT64 qscale_sum[5];
89 int frame_count[5]; 92 int frame_count[5];
90 int last_non_b_pict_type; 93 int last_non_b_pict_type;
91 }RateControlContext; 94 }RateControlContext;
92 95
93 typedef struct ReorderBuffer{
94 UINT8 *picture[3];
95 int pict_type;
96 int qscale;
97 int force_type;
98 int picture_number;
99 int picture_in_gop_number;
100 } ReorderBuffer;
101 96
102 typedef struct ScanTable{ 97 typedef struct ScanTable{
103 const UINT8 *scantable; 98 const UINT8 *scantable;
104 UINT8 permutated[64]; 99 UINT8 permutated[64];
105 UINT8 raster_end[64]; 100 UINT8 raster_end[64];
106 #ifdef ARCH_POWERPC 101 #ifdef ARCH_POWERPC
107 /* Used by dct_quantise_alitvec to find last-non-zero */ 102 /* Used by dct_quantise_alitvec to find last-non-zero */
108 UINT8 __align8 inverse[64]; 103 UINT8 __align8 inverse[64];
109 #endif 104 #endif
110 } ScanTable; 105 } ScanTable;
106
107 typedef struct Picture{
108 FF_COMMON_PICTURE
109
110 int mb_var_sum; /* sum of MB variance for current frame */
111 int mc_mb_var_sum; /* motion compensated MB variance for current frame */
112 uint16_t *mb_var; /* Table for MB variances */
113 uint16_t *mc_mb_var; /* Table for motion compensated MB variances */
114 uint8_t *mb_mean; /* Table for MB luminance */
115 } Picture;
111 116
112 typedef struct ParseContext{ 117 typedef struct ParseContext{
113 UINT8 *buffer; 118 UINT8 *buffer;
114 int index; 119 int index;
115 int last_index; 120 int last_index;
143 int qmin; /* min qscale */ 148 int qmin; /* min qscale */
144 int qmax; /* max qscale */ 149 int qmax; /* max qscale */
145 int max_qdiff; /* max qscale difference between frames */ 150 int max_qdiff; /* max qscale difference between frames */
146 int encoding; /* true if we are encoding (vs decoding) */ 151 int encoding; /* true if we are encoding (vs decoding) */
147 int flags; /* AVCodecContext.flags (HQ, MV4, ...) */ 152 int flags; /* AVCodecContext.flags (HQ, MV4, ...) */
148 int force_input_type;/* 0= no force, otherwise I_TYPE, P_TYPE, ... */
149 int max_b_frames; /* max number of b-frames for encoding */ 153 int max_b_frames; /* max number of b-frames for encoding */
150 int b_frame_strategy; 154 int b_frame_strategy;
151 int luma_elim_threshold; 155 int luma_elim_threshold;
152 int chroma_elim_threshold; 156 int chroma_elim_threshold;
153 int strict_std_compliance; /* strictly follow the std (MPEG4, ...) */ 157 int strict_std_compliance; /* strictly follow the std (MPEG4, ...) */
158 PutBitContext pb; 162 PutBitContext pb;
159 163
160 /* sequence parameters */ 164 /* sequence parameters */
161 int context_initialized; 165 int context_initialized;
162 int input_picture_number; 166 int input_picture_number;
163 int input_picture_in_gop_number; /* 0-> first pic in gop, ... */
164 int picture_number; 167 int picture_number;
165 int fake_picture_number; /* picture number at the bitstream frame rate */
166 int gop_picture_number; /* index of the first picture of a GOP based on fake_pic_num & mpeg1 specific */
167 int picture_in_gop_number; /* 0-> first pic in gop, ... */ 168 int picture_in_gop_number; /* 0-> first pic in gop, ... */
168 int b_frames_since_non_b; /* used for encoding, relative to not yet reordered input */ 169 int b_frames_since_non_b; /* used for encoding, relative to not yet reordered input */
169 int mb_width, mb_height; /* number of MBs horizontally & vertically */ 170 int mb_width, mb_height; /* number of MBs horizontally & vertically */
170 int h_edge_pos, v_edge_pos;/* horizontal / vertical position of the right/bottom edge (pixel replicateion)*/ 171 int h_edge_pos, v_edge_pos;/* horizontal / vertical position of the right/bottom edge (pixel replicateion)*/
171 int mb_num; /* number of MBs of a picture */ 172 int mb_num; /* number of MBs of a picture */
172 int linesize; /* line size, in bytes, may be different from width */ 173 int linesize; /* line size, in bytes, may be different from width */
173 int uvlinesize; /* line size, for chroma in bytes, may be different from width */ 174 int uvlinesize; /* line size, for chroma in bytes, may be different from width */
174 UINT8 *new_picture[3]; /* picture to be compressed */ 175 Picture picture[MAX_PICTURE_COUNT]; /* main picture buffer */
175 UINT8 *picture_buffer[REORDER_BUFFER_SIZE][3]; /* internal buffers used for reordering of input pictures */ 176 Picture *input_picture[MAX_PICTURE_COUNT]; /* next pictures on display order for encoding*/
176 int picture_buffer_index; 177 Picture *reordered_input_picture[MAX_PICTURE_COUNT]; /* pointer to the next pictures in codedorder for encoding*/
177 ReorderBuffer coded_order[REORDER_BUFFER_SIZE]; 178 Picture last_picture; /* previous picture */
178 UINT8 *last_picture[3]; /* previous picture */ 179 Picture next_picture; /* previous picture (for bidir pred) */
179 UINT8 *last_picture_base[3]; /* real start of the picture */ 180 Picture new_picture; /* source picture for encoding */
180 UINT8 *next_picture[3]; /* previous picture (for bidir pred) */ 181 Picture current_picture; /* buffer to store the decompressed current picture */
181 UINT8 *next_picture_base[3]; /* real start of the picture */
182 UINT8 *aux_picture[3]; /* aux picture (for B frames only) */
183 UINT8 *aux_picture_base[3]; /* real start of the picture */
184 UINT8 *current_picture[3]; /* buffer to store the decompressed current picture */
185 void *last_dr_opaque;
186 void *next_dr_opaque;
187 int ip_buffer_count; /* number of buffers, currently only >2 if dr1 is used */
188 int num_available_buffers; /* is 0 at the start & after seeking, after the first I frame its 1 after next I/P 2 */ 182 int num_available_buffers; /* is 0 at the start & after seeking, after the first I frame its 1 after next I/P 2 */
189 int last_dc[3]; /* last DC values for MPEG1 */ 183 int last_dc[3]; /* last DC values for MPEG1 */
190 INT16 *dc_val[3]; /* used for mpeg4 DC prediction, all 3 arrays must be continuous */ 184 INT16 *dc_val[3]; /* used for mpeg4 DC prediction, all 3 arrays must be continuous */
191 int y_dc_scale, c_dc_scale; 185 int y_dc_scale, c_dc_scale;
192 UINT8 *y_dc_scale_table; /* qscale -> y_dc_scale table */ 186 UINT8 *y_dc_scale_table; /* qscale -> y_dc_scale table */
198 UINT8 *mbskip_table; /* used to avoid copy if macroblock skipped (for black regions for example) 192 UINT8 *mbskip_table; /* used to avoid copy if macroblock skipped (for black regions for example)
199 and used for b-frame encoding & decoding (contains skip table of next P Frame) */ 193 and used for b-frame encoding & decoding (contains skip table of next P Frame) */
200 UINT8 *mbintra_table; /* used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding */ 194 UINT8 *mbintra_table; /* used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding */
201 UINT8 *cbp_table; /* used to store cbp, ac_pred for partitioned decoding */ 195 UINT8 *cbp_table; /* used to store cbp, ac_pred for partitioned decoding */
202 UINT8 *pred_dir_table; /* used to store pred_dir for partitioned decoding */ 196 UINT8 *pred_dir_table; /* used to store pred_dir for partitioned decoding */
203 INT8 *qscale_table; /* used to store qscale */
204 INT8 *aux_qscale_table;
205 INT8 *next_qscale_table;
206 INT8 *last_qscale_table; //FIXME move these into some picture struct (MpegEncContext.aux.qscale_table[])
207 UINT8 *edge_emu_buffer; 197 UINT8 *edge_emu_buffer;
208 198
209 int input_qscale; /* qscale prior to reordering of frames */
210 int input_pict_type; /* pict_type prior to reordering of frames */
211 int force_type; /* 0= no force, otherwise I_TYPE, P_TYPE, ... */
212 int qscale; /* QP */ 199 int qscale; /* QP */
213 float frame_qscale; /* qscale from the frame level rc */ 200 float frame_qscale; /* qscale from the frame level rc FIXME remove*/
214 int adaptive_quant; /* use adaptive quantization */ 201 int adaptive_quant; /* use adaptive quantization */
215 int dquant; /* qscale difference to prev qscale */ 202 int dquant; /* qscale difference to prev qscale */
216 int pict_type; /* I_TYPE, P_TYPE, B_TYPE, ... */ 203 int pict_type; /* I_TYPE, P_TYPE, B_TYPE, ... */
217 int last_pict_type; 204 int last_pict_type;
218 int last_non_b_pict_type; /* used for mpeg4 gmc b-frames & ratecontrol */ 205 int last_non_b_pict_type; /* used for mpeg4 gmc b-frames & ratecontrol */
270 257
271 /* macroblock layer */ 258 /* macroblock layer */
272 int mb_x, mb_y; 259 int mb_x, mb_y;
273 int mb_incr; 260 int mb_incr;
274 int mb_intra; 261 int mb_intra;
275 UINT16 *mb_var; /* Table for MB variances */
276 UINT16 *mc_mb_var; /* Table for motion compensated MB variances */
277 UINT8 *mb_mean; /* Table for MB luminance */
278 UINT8 *mb_type; /* Table for MB type */ 262 UINT8 *mb_type; /* Table for MB type */
279 #define MB_TYPE_INTRA 0x01 263 #define MB_TYPE_INTRA 0x01
280 #define MB_TYPE_INTER 0x02 264 #define MB_TYPE_INTER 0x02
281 #define MB_TYPE_INTER4V 0x04 265 #define MB_TYPE_INTER4V 0x04
282 #define MB_TYPE_SKIPED 0x08 266 #define MB_TYPE_SKIPED 0x08
323 307
324 void *opaque; /* private data for the user */ 308 void *opaque; /* private data for the user */
325 309
326 /* bit rate control */ 310 /* bit rate control */
327 int I_frame_bits; //FIXME used in mpeg12 ... 311 int I_frame_bits; //FIXME used in mpeg12 ...
328 int mb_var_sum; /* sum of MB variance for current frame */
329 int mc_mb_var_sum; /* motion compensated MB variance for current frame */
330 INT64 wanted_bits; 312 INT64 wanted_bits;
331 INT64 total_bits; 313 INT64 total_bits;
332 int frame_bits; /* bits used for the current frame */ 314 int frame_bits; /* bits used for the current frame */
333 RateControlContext rc_context; // contains stuff only accessed in ratecontrol.c 315 RateControlContext rc_context; // contains stuff only accessed in ratecontrol.c
334 316
474 int inter_intra_pred; 456 int inter_intra_pred;
475 457
476 /* decompression specific */ 458 /* decompression specific */
477 GetBitContext gb; 459 GetBitContext gb;
478 460
461 /* Mpeg1 specific */
462 int fake_picture_number; /* picture number at the bitstream frame rate */
463 int gop_picture_number; /* index of the first picture of a GOP based on fake_pic_num & mpeg1 specific */
464
479 /* MPEG2 specific - I wish I had not to support this mess. */ 465 /* MPEG2 specific - I wish I had not to support this mess. */
480 int progressive_sequence; 466 int progressive_sequence;
481 int mpeg_f_code[2][2]; 467 int mpeg_f_code[2][2];
482 int picture_structure; 468 int picture_structure;
483 /* picture type */ 469 /* picture type */
496 int chroma_420_type; 482 int chroma_420_type;
497 int progressive_frame; 483 int progressive_frame;
498 int mpeg2; 484 int mpeg2;
499 int full_pel[2]; 485 int full_pel[2];
500 int interlaced_dct; 486 int interlaced_dct;
501 int last_qscale;
502 int first_slice; 487 int first_slice;
503 488
504 /* RTP specific */ 489 /* RTP specific */
505 /* These are explained on avcodec.h */ 490 /* These are explained on avcodec.h */
506 int rtp_mode; 491 int rtp_mode;