Commit 89aa4e87 authored by Fiona Glaser's avatar Fiona Glaser

Fix one bug, one corner case in VBV

qp_novbv wasn't set correctly for B-frames.
Disable ABR code for frames with zero complexity.
Disable ABR code for CBR mode; it is completely unnecessary and can have negative consequences.
parent daa1342e
......@@ -1808,6 +1808,7 @@ static float rate_estimate_qscale( x264_t *h )
/* For row SATDs */
if( rcc->b_vbv )
rcc->last_satd = x264_rc_analyse_slice( h );
rcc->qp_novbv = q;
return qp2qscale(q);
}
else
......@@ -1921,13 +1922,18 @@ static float rate_estimate_qscale( x264_t *h )
q = get_qscale( h, &rce, rcc->wanted_bits_window / rcc->cplxr_sum, h->fenc->i_frame );
// FIXME is it simpler to keep track of wanted_bits in ratecontrol_end?
wanted_bits = i_frame_done * rcc->bitrate / rcc->fps;
if( wanted_bits > 0 )
/* ABR code can potentially be counterproductive in CBR, so just don't bother.
* Don't run it if the frame complexity is zero either. */
if( !rcc->b_vbv_min_rate && rcc->last_satd )
{
abr_buffer *= X264_MAX( 1, sqrt(i_frame_done/25) );
overflow = x264_clip3f( 1.0 + (total_bits - wanted_bits) / abr_buffer, .5, 2 );
q *= overflow;
// FIXME is it simpler to keep track of wanted_bits in ratecontrol_end?
wanted_bits = i_frame_done * rcc->bitrate / rcc->fps;
if( wanted_bits > 0 )
{
abr_buffer *= X264_MAX( 1, sqrt(i_frame_done/25) );
overflow = x264_clip3f( 1.0 + (total_bits - wanted_bits) / abr_buffer, .5, 2 );
q *= overflow;
}
}
}
......
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