]> git.sesse.net Git - x264/commitdiff
Fix VBV bug with MinCR limit
authorAnton Mitrofanov <BugMaster@narod.ru>
Sun, 29 May 2011 22:36:31 +0000 (02:36 +0400)
committerFiona Glaser <fiona@x264.com>
Mon, 13 Jun 2011 02:48:43 +0000 (19:48 -0700)
encoder/ratecontrol.c

index 9e4d76499376ba1dc27a7a35454bda642746cabf..5fff35688fb373bbcca2e77546735bf9f073cbec 100644 (file)
@@ -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;
     }