Commit c51d00b7 authored by Fiona Glaser's avatar Fiona Glaser

Improve VBV, fix bug in 2-pass VBV introduced in MB-tree

Bug caused AQ'd row/frame costs to not be calculated (and thus caused underflows).
Also make VBV more aggressive with more threads in 2-pass mode.
Finally, --ratetol now affects VBV aggressiveness (higher is less aggressive).
parent 1a1b9c6f
......@@ -294,7 +294,11 @@ int x264_macroblock_tree_read( x264_t *h, x264_frame_t *frame )
goto fail;
for( i = 0; i < h->mb.i_mb_count; i++ )
{
frame->f_qp_offset[i] = ((float)(int16_t)endian_fix16( rc->qp_buffer[i] )) * (1/256.0);
if( h->frames.b_have_lowres )
frame->i_inv_qscale_factor[i] = x264_exp2fix8(frame->f_qp_offset[i]);
}
}
else
x264_adaptive_quant_frame( h, frame );
......@@ -1131,8 +1135,10 @@ void x264_ratecontrol_mb( x264_t *h, int bits )
/* More threads means we have to be more cautious in letting ratecontrol use up extra bits.
* In 2-pass mode we can be more trusting of the planned frame sizes, since they were decided
* by actual encoding instead of SATD prediction. */
float rc_tol = h->param.rc.b_stat_read ? (buffer_left_planned / rc->buffer_size) * rc->frame_size_planned
: (buffer_left_planned / h->param.i_threads);
float rc_tol = buffer_left_planned / h->param.i_threads * rc->rate_tolerance;
if( h->param.rc.b_stat_read )
rc_tol *= rc->frame_size_planned / rc->buffer_size;
/* Don't modify the row QPs until a sufficent amount of the bits of the frame have been processed, in case a flat */
/* area at the top of the frame was measured inaccurately. */
if( row_bits_so_far(h,y) < 0.05 * rc->frame_size_planned )
......
......@@ -233,7 +233,7 @@ static void Help( x264_param_t *defaults, int longhelp )
H2( " --qpmin <integer> Set min QP [%d]\n", defaults->rc.i_qp_min );
H2( " --qpmax <integer> Set max QP [%d]\n", defaults->rc.i_qp_max );
H2( " --qpstep <integer> Set max QP step [%d]\n", defaults->rc.i_qp_step );
H2( " --ratetol <float> Allowed variance of average bitrate [%.1f]\n", defaults->rc.f_rate_tolerance );
H2( " --ratetol <float> Tolerance of ABR ratecontrol and VBV [%.1f]\n", defaults->rc.f_rate_tolerance );
H2( " --ipratio <float> QP factor between I and P [%.2f]\n", defaults->rc.f_ip_factor );
H2( " --pbratio <float> QP factor between P and B [%.2f]\n", defaults->rc.f_pb_factor );
H2( " --chroma-qp-offset <integer> QP difference between chroma and luma [%d]\n", defaults->analyse.i_chroma_qp_offset );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment