[x264-devel] commit: Fix a case in which VBV underflows can occur (Gabriel Bouvigne )

git version control git at videolan.org
Tue Sep 16 10:54:36 CEST 2008


x264 | branch: master | Gabriel Bouvigne <bouvigne at mp3-tech.org> | Tue Sep 16 01:53:02 2008 -0700| [7eaff1792dd1064ff607fec47d0d7d91fdc62641] | committer: Jason Garrett-Glaser 

Fix a case in which VBV underflows can occur
Fix a potential case where a frame might be initially allocated too low a QP, which would then have to be raised a low during row-based ratecontrol.
In some cases, this could even produce VBV underflows in 2pass mode.

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

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

diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c
index 3251f4f..1559c72 100644
--- a/encoder/ratecontrol.c
+++ b/encoder/ratecontrol.c
@@ -1418,10 +1418,12 @@ static float rate_estimate_qscale( x264_t *h )
                 double expected_fullness =  rce.expected_vbv / rcc->buffer_size;
                 double qmax = q*(2 - expected_fullness);
                 double size_constraint = 1 + expected_fullness;
+                qmax = X264_MAX(qmax, rce.new_qscale);
                 if (expected_fullness < .05)
                     qmax = lmax;
                 qmax = X264_MIN(qmax, lmax);
-                while( (expected_vbv < rce.expected_vbv/size_constraint) && (q < qmax) )
+                while( ((expected_vbv < rce.expected_vbv/size_constraint) && (q < qmax)) ||
+                        ((expected_vbv < 0) && (q < lmax)))
                 {
                     q *= 1.05;
                     expected_size = qscale2bits(&rce, q);



More information about the x264-devel mailing list