[x264-devel] commit: Fix one bug, one corner case in VBV (Jason Garrett-Glaser )

git version control git at videolan.org
Sat Feb 27 01:16:53 CET 2010


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Wed Feb 24 03:49:32 2010 -0800| [479a9e8e4e39409b24b0517a1c155a767af63454] | committer: Jason Garrett-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.

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

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

diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c
index 8b47e29..300dc88 100644
--- a/encoder/ratecontrol.c
+++ b/encoder/ratecontrol.c
@@ -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;
+                    }
                 }
             }
 



More information about the x264-devel mailing list