From: Anton Mitrofanov Date: Sun, 29 May 2011 22:36:31 +0000 (+0400) Subject: Fix VBV bug with MinCR limit X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=8ca923ed018d1c46d737a62395fc75d63da5c0d0;p=x264.git Fix VBV bug with MinCR limit --- diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c index 1bc6fc1e..af15d1f4 100644 --- a/encoder/ratecontrol.c +++ b/encoder/ratecontrol.c @@ -2129,6 +2129,9 @@ static float rate_estimate_qscale( x264_t *h ) rcc->frame_size_planned = qscale2bits( &rce, qp2qscale( q ) ); else rcc->frame_size_planned = predict_size( rcc->pred_b_from_p, qp2qscale( q ), h->fref[1][h->i_ref[1]-1]->i_satd ); + /* Limit planned size by MinCR */ + if( rcc->b_vbv ) + rcc->frame_size_planned = X264_MIN( rcc->frame_size_planned, rcc->frame_size_maximum ); h->rc->frame_size_estimated = rcc->frame_size_planned; /* For row SATDs */ @@ -2320,6 +2323,9 @@ static float rate_estimate_qscale( x264_t *h ) /* Always use up the whole VBV in this case. */ if( rcc->single_frame_vbv ) rcc->frame_size_planned = rcc->buffer_rate; + /* Limit planned size by MinCR */ + if( rcc->b_vbv ) + rcc->frame_size_planned = X264_MIN( rcc->frame_size_planned, rcc->frame_size_maximum ); h->rc->frame_size_estimated = rcc->frame_size_planned; return q; }