[x264-devel] Fix VBV bug with MinCR limit

Anton Mitrofanov git at videolan.org
Wed Jun 15 04:54:15 CEST 2011


x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Mon May 30 02:36:31 2011 +0400| [8ca923ed018d1c46d737a62395fc75d63da5c0d0] | committer: Jason Garrett-Glaser

Fix VBV bug with MinCR limit

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=8ca923ed018d1c46d737a62395fc75d63da5c0d0
---

 encoder/ratecontrol.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c
index 1bc6fc1..af15d1f 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;
     }



More information about the x264-devel mailing list