diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2002-04-21 21:18:17 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2002-04-21 21:18:17 +0000 |
commit | 8b4c7dbc5507425b0c342948dabf01d714af7068 (patch) | |
tree | 52e929eb4145fe5506cc4624e8f842143b99f7a8 /libavcodec/mpegvideo.h | |
parent | 2c029cd19d7a20aca129a4818212e48e5ce79a76 (diff) | |
download | ffmpeg-8b4c7dbc5507425b0c342948dabf01d714af7068.tar.gz |
fixed ratecontrol & b-frames
2pass ratecontrol
fixed hq with 2pass
inceased build num (a few more vars for the rc stuff)
hopefully no new bugs
Originally committed as revision 408 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpegvideo.h')
-rw-r--r-- | libavcodec/mpegvideo.h | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 24943e5b19..b0aebe8954 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -44,6 +44,24 @@ typedef struct Predictor{ double decay; } Predictor; +typedef struct RateControlEntry{ + int pict_type; + int qscale; + int mv_bits; + int i_tex_bits; + int p_tex_bits; + int misc_bits; + uint64_t expected_bits; + int new_pict_type; + float new_qscale; +}RateControlEntry; + +typedef struct RateControlContext{ + FILE *stats_file; + int num_entries; + RateControlEntry *entry; +}RateControlContext; + typedef struct ReorderBuffer{ UINT8 *picture[3]; int pict_type; @@ -78,6 +96,9 @@ typedef struct MpegEncContext { int flags; /* AVCodecContext.flags (HQ, MV4, ...) */ int force_input_type;/* 0= no force, otherwise I_TYPE, P_TYPE, ... */ int max_b_frames; /* max number of b-frames for encoding */ + float b_quant_factor;/* qscale factor between ips and b frames */ + int rc_strategy; + int b_frame_strategy; /* the following fields are managed internally by the encoder */ /* bit output */ @@ -121,9 +142,9 @@ typedef struct MpegEncContext { int input_pict_type; /* pict_type prior to reordering of frames */ int force_type; /* 0= no force, otherwise I_TYPE, P_TYPE, ... */ int qscale; /* QP */ + int last_non_b_qscale; /* QP of last non b frame used for b frame qscale*/ int pict_type; /* I_TYPE, P_TYPE, B_TYPE, ... */ - int last_non_b_pict_type; /* used for mpeg4 gmc b-frames */ - int last_pict_type; /* used for bit rate stuff (needs that to update the right predictor) */ + int last_non_b_pict_type; /* used for mpeg4 gmc b-frames & ratecontrol */ int frame_rate_index; /* motion compensation */ int unrestricted_mv; @@ -195,7 +216,7 @@ typedef struct MpegEncContext { int q_intra_matrix[64]; int q_non_intra_matrix[64]; /* identical to the above but for MMX & these are not permutated */ - UINT16 __align8 q_intra_matrix16[64] ; + UINT16 __align8 q_intra_matrix16[64]; UINT16 __align8 q_non_intra_matrix16[64]; int block_last_index[6]; /* last non zero coefficient in block */ @@ -204,18 +225,19 @@ typedef struct MpegEncContext { /* bit rate control */ int I_frame_bits; //FIXME used in mpeg12 ... int avg_mb_var; /* average MB variance for current frame */ - int mc_mb_var; /* motion compensated MB variance for current frame */ - int last_mc_mb_var; /* motion compensated MB variance for last frame */ + int mc_mb_var; /* motion compensated MB variance for current frame */ + int last_non_b_mc_mb_var;/* motion compensated MB variance for last non b frame */ INT64 wanted_bits; INT64 total_bits; - int frame_bits; /* bits used for the current frame */ - int last_frame_bits; /* bits used for the last frame */ + int frame_bits; /* bits used for the current frame */ + int pb_frame_bits; /* bits of the last b...bp group */ Predictor i_pred; Predictor p_pred; double qsum; /* sum of qscales */ double qcount; /* count of qscales */ double short_term_qsum; /* sum of recent qscales */ double short_term_qcount; /* count of recent qscales */ + RateControlContext rc_context; /* statistics, used for 2-pass encoding */ int mv_bits; @@ -459,3 +481,14 @@ void mjpeg_encode_mb(MpegEncContext *s, DCTELEM block[6][64]); void mjpeg_picture_header(MpegEncContext *s); void mjpeg_picture_trailer(MpegEncContext *s); + +/* rate control */ +int ff_rate_control_init(MpegEncContext *s); +int ff_rate_estimate_qscale(MpegEncContext *s); +int ff_rate_estimate_qscale_pass2(MpegEncContext *s); +void ff_write_pass1_stats(MpegEncContext *s); +void ff_rate_control_uninit(MpegEncContext *s); + + + + |