[x264-devel] commit: Make the ABR buffer consider the distance to the end of the video ( Jason Garrett-Glaser )

git version control git at videolan.org
Mon Feb 15 10:20:26 CET 2010


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Sat Feb 13 00:52:31 2010 -0800| [aa2626c567083432f56368bee9c9d43d7c8e1fef] | committer: Jason Garrett-Glaser 

Make the ABR buffer consider the distance to the end of the video
Should improve bitrate accuracy in 2-pass mode.
May also slightly improve quality by allowing more variation earlier-on in a file.

Also fix abr_buffer with 1-pass: it does something very different than what it does for 2-pass.
Thus, the earlier change that increased it based on threads caused 1-pass ABR to be somewhat less accurate.

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

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

diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c
index 0c946ba..8c61582 100644
--- a/encoder/ratecontrol.c
+++ b/encoder/ratecontrol.c
@@ -1784,13 +1784,15 @@ static float rate_estimate_qscale( x264_t *h )
     }
     else
     {
-        double abr_buffer = 2 * rcc->rate_tolerance * rcc->bitrate * h->i_thread_frames;
+        double abr_buffer = 2 * rcc->rate_tolerance * rcc->bitrate;
 
         if( rcc->b_2pass )
         {
-            //FIXME adjust abr_buffer based on distance to the end of the video
             int64_t diff;
             int64_t predicted_bits = total_bits;
+            /* Adjust ABR buffer based on distance to the end of the video. */
+            if( rcc->num_entries > h->fenc->i_frame )
+                abr_buffer *= 0.5 * sqrt( rcc->num_entries - h->fenc->i_frame );
 
             if( rcc->b_vbv )
             {



More information about the x264-devel mailing list