comparison mpegvideo.h @ 268:09ae29b27ed9 libavcodec

hopefully better bitrate controll
author michaelni
date Sun, 17 Mar 2002 16:31:38 +0000
parents 252444e5259b
children 5cb2978e701f
comparison
equal deleted inserted replaced
267:e10840e4f773 268:09ae29b27ed9
32 #define MPEG_BUF_SIZE (16 * 1024) 32 #define MPEG_BUF_SIZE (16 * 1024)
33 33
34 #define QMAT_SHIFT_MMX 19 34 #define QMAT_SHIFT_MMX 19
35 #define QMAT_SHIFT 25 35 #define QMAT_SHIFT 25
36 36
37 typedef struct Predictor{
38 double coeff;
39 double count;
40 double decay;
41 } Predictor;
42
37 typedef struct MpegEncContext { 43 typedef struct MpegEncContext {
38 struct AVCodecContext *avctx; 44 struct AVCodecContext *avctx;
39 /* the following parameters must be initialized before encoding */ 45 /* the following parameters must be initialized before encoding */
40 int width, height; /* picture size. must be a multiple of 16 */ 46 int width, height; /* picture size. must be a multiple of 16 */
41 int gop_size; 47 int gop_size;
42 int frame_rate; /* number of frames per second */ 48 int frame_rate; /* number of frames per second */
43 int intra_only; /* if true, only intra pictures are generated */ 49 int intra_only; /* if true, only intra pictures are generated */
44 int bit_rate; /* wanted bit rate */ 50 int bit_rate; /* wanted bit rate */
51 int bit_rate_tolerance; /* amount of +- bits (>0)*/
45 enum OutputFormat out_format; /* output format */ 52 enum OutputFormat out_format; /* output format */
46 int h263_plus; /* h263 plus headers */ 53 int h263_plus; /* h263 plus headers */
47 int h263_rv10; /* use RV10 variation for H263 */ 54 int h263_rv10; /* use RV10 variation for H263 */
48 int h263_pred; /* use mpeg4/h263 ac/dc predictions */ 55 int h263_pred; /* use mpeg4/h263 ac/dc predictions */
49 int h263_msmpeg4; /* generate MSMPEG4 compatible stream */ 56 int h263_msmpeg4; /* generate MSMPEG4 compatible stream */
50 int h263_intel; /* use I263 intel h263 header */ 57 int h263_intel; /* use I263 intel h263 header */
51 int fixed_qscale; /* fixed qscale if non zero */ 58 int fixed_qscale; /* fixed qscale if non zero */
59 float qcompress; /* amount of qscale change between easy & hard scenes (0.0-1.0) */
60 float qblur; /* amount of qscale smoothing over time (0.0-1.0) */
61 int qmin; /* min qscale */
62 int qmax; /* max qscale */
63 int max_qdiff; /* max qscale difference between frames */
52 int encoding; /* true if we are encoding (vs decoding) */ 64 int encoding; /* true if we are encoding (vs decoding) */
53 /* the following fields are managed internally by the encoder */ 65 /* the following fields are managed internally by the encoder */
54 66
55 /* bit output */ 67 /* bit output */
56 PutBitContext pb; 68 PutBitContext pb;
83 UINT8 *mbintra_table; /* used to kill a few memsets */ 95 UINT8 *mbintra_table; /* used to kill a few memsets */
84 96
85 int qscale; 97 int qscale;
86 int pict_type; 98 int pict_type;
87 int last_non_b_pict_type; /* used for mpeg4 gmc b-frames */ 99 int last_non_b_pict_type; /* used for mpeg4 gmc b-frames */
100 int last_pict_type; /* used for bit rate stuff (needs that to update the right predictor) */
88 int frame_rate_index; 101 int frame_rate_index;
89 /* motion compensation */ 102 /* motion compensation */
90 int unrestricted_mv; 103 int unrestricted_mv;
91 int h263_long_vectors; /* use horrible h263v1 long vector mode */ 104 int h263_long_vectors; /* use horrible h263v1 long vector mode */
92 105
144 157
145 /* bit rate control */ 158 /* bit rate control */
146 int I_frame_bits; /* wanted number of bits per I frame */ 159 int I_frame_bits; /* wanted number of bits per I frame */
147 int P_frame_bits; /* same for P frame */ 160 int P_frame_bits; /* same for P frame */
148 int avg_mb_var; /* average MB variance for current frame */ 161 int avg_mb_var; /* average MB variance for current frame */
162 int mc_mb_var; /* motion compensated MB variance for current frame */
163 int last_mc_mb_var; /* motion compensated MB variance for last frame */
149 INT64 wanted_bits; 164 INT64 wanted_bits;
150 INT64 total_bits; 165 INT64 total_bits;
151 166 int frame_bits; /* bits used for the current frame */
167 int last_frame_bits; /* bits used for the last frame */
168 Predictor i_pred;
169 Predictor p_pred;
170 double qsum; /* sum of qscales */
171 double qcount; /* count of qscales */
172 double short_term_qsum; /* sum of recent qscales */
173 double short_term_qcount; /* count of recent qscales */
174
152 /* H.263 specific */ 175 /* H.263 specific */
153 int gob_number; 176 int gob_number;
154 int gob_index; 177 int gob_index;
155 int first_gob_line; 178 int first_gob_line;
156 179