[x265] [PATCH 2 of 3] rc: use actual bits to update vbv buffer

aarthi at multicorewareinc.com aarthi at multicorewareinc.com
Wed Jun 4 15:49:58 CEST 2014


# HG changeset patch
# User Aarthi Thirumalai
# Date 1401889659 -19800
#      Wed Jun 04 19:17:39 2014 +0530
# Node ID 4ecd1bfebb7294d70b288ea77eba570c850f769c
# Parent  6c5fda5ef3e24b887f4d21ef47b68f9069a5cc26
rc: use actual bits to update vbv buffer

diff -r 6c5fda5ef3e2 -r 4ecd1bfebb72 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Wed Jun 04 19:17:06 2014 +0530
+++ b/source/encoder/ratecontrol.cpp	Wed Jun 04 19:17:39 2014 +0530
@@ -1151,6 +1151,7 @@
 /* After encoding one frame, update rate control state */
 int RateControl::rateControlEnd(TComPic* pic, int64_t bits, RateControlEntry* rce)
 {
+    double actualBits = bits;
     if (isAbr)
     {
         if (param->rc.rateControlMode == X265_RC_ABR)
@@ -1235,7 +1236,7 @@
     {
         if (rce->sliceType == B_SLICE)
         {
-            bframeBits += (int)bits;
+            bframeBits += (int)actualBits;
             if (rce->bLastMiniGopBFrame)
             {
                 if (rce->bframes != 0)
@@ -1243,7 +1244,7 @@
                 bframeBits = 0;
             }
         }
-        updateVbv(bits, rce);
+        updateVbv(actualBits, rce);
 
         if (param->bEmitHRDSEI)
         {
@@ -1272,7 +1273,7 @@
             }
 
             uint32_t cpbsizeUnscale = (hrd->getCpbSizeValueMinus1(0, 0, 0) + 1) << (hrd->getCpbSizeScale() + CPB_SHIFT);
-            pic->m_hrdTiming.cpbFinalAT = prevCpbFinalAT = pic->m_hrdTiming.cpbInitialAT + bits / cpbsizeUnscale;
+            pic->m_hrdTiming.cpbFinalAT = prevCpbFinalAT = pic->m_hrdTiming.cpbInitialAT + actualBits / cpbsizeUnscale;
             pic->m_hrdTiming.dpbOutputTime = (double)pic->m_sei.m_picDpbOutputDelay * time->getNumUnitsInTick() / time->getTimeScale() + pic->m_hrdTiming.cpbRemovalTime;
         }
     }


More information about the x265-devel mailing list