[x265] [PATCH] vbv: set vbvminrate

santhoshini at multicorewareinc.com santhoshini at multicorewareinc.com
Tue Feb 11 08:44:35 CET 2014


# HG changeset patch
# User Santhoshini Sekar <santhoshini at multicorewareinc.com>
# Date 1392104203 -19800
#      Tue Feb 11 13:06:43 2014 +0530
# Node ID cd078d0dc0278dfca6e13e8f210cb6dda707e306
# Parent  07b5d6b82f5fbcb78ecab12cb8abcf13c78fe552
vbv: set vbvminrate

diff -r 07b5d6b82f5f -r cd078d0dc027 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Mon Feb 10 15:05:04 2014 -0600
+++ b/source/encoder/ratecontrol.cpp	Tue Feb 11 13:06:43 2014 +0530
@@ -284,6 +284,8 @@
     fps = cfg->param.frameRate;
     if (isVbv)
     {
+        /* We don't support changing the ABR bitrate right now,
+           so if the stream starts as CBR, keep it CBR. */
         if (cfg->param.rc.vbvBufferSize < (int)(cfg->param.rc.vbvMaxBitrate / fps))
         {
             cfg->param.rc.vbvBufferSize = (int)(cfg->param.rc.vbvMaxBitrate / fps);
@@ -297,7 +299,13 @@
         vbvMaxRate = vbvMaxBitrate;
         bufferSize = vbvBufferSize;
         singleFrameVbv = bufferRate * 1.1 > bufferSize;
+
+        if (cfg->param.rc.vbvBufferInit > 1.)
+                cfg->param.rc.vbvBufferInit = Clip3( 0.0, 1.0, cfg->param.rc.vbvBufferInit / cfg->param.rc.vbvBufferSize);
+        cfg->param.rc.vbvBufferInit = Clip3(0.0, 1.0, X265_MAX(cfg->param.rc.vbvBufferInit, bufferRate / bufferSize));
         bufferFillFinal = bufferSize * cfg->param.rc.vbvBufferInit;
+        vbvMinRate = /*!rc->b_2pass && */ cfg->param.rc.rateControlMode == X265_RC_ABR
+                   && cfg->param.rc.vbvMaxBitrate <= cfg->param.rc.bitrate;
     }
 
     for (int i = 0; i < 5; i++)
@@ -498,7 +506,7 @@
 
             /* 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 (lastSatd)
+            if (!vbvMinRate && lastSatd)
             {
                 /* use framesDone instead of POC as poc count is not serial with bframes enabled */
                 double timeDone = (double)(framesDone - cfg->param.frameNumThreads + 1) / cfg->param.frameRate;
@@ -670,7 +678,8 @@
             }
             q = X265_MAX(q0 - 5, q);
         }
-        q = X265_MAX(q0, q);
+        if (!vbvMinRate)
+            q = X265_MAX(q0, q);
     }
 
     if (lmin1 == lmax1)
diff -r 07b5d6b82f5f -r cd078d0dc027 source/encoder/ratecontrol.h
--- a/source/encoder/ratecontrol.h	Mon Feb 10 15:05:04 2014 -0600
+++ b/source/encoder/ratecontrol.h	Tue Feb 11 13:06:43 2014 +0530
@@ -89,6 +89,7 @@
     double bufferFill;       /* planned buffer, if all in-progress frames hit their bit budget */
     double bufferRate;       /* # of bits added to buffer_fill after each frame */
     double vbvMaxRate;       /* in kbps */
+    double vbvMinRate;       /* in kbps */
     bool singleFrameVbv;
     bool isVbv;
     double fps;


More information about the x265-devel mailing list