[x265] [PATCH] vbv:bug fix - down shifting of satdcost for 10 bit depth

aarthi at multicorewareinc.com aarthi at multicorewareinc.com
Tue Mar 11 14:08:16 CET 2014


# HG changeset patch
# User Aarthi Thirumalai
# Date 1394543191 -19800
#      Tue Mar 11 18:36:31 2014 +0530
# Node ID 0fa2952dec254d67f5ea1b1707cd181aae50b37a
# Parent  3b1353f3e0929ecbb5dbfc7b101341492ee22330
vbv:bug fix - down shifting of satdcost for 10 bit depth.

diff -r 3b1353f3e092 -r 0fa2952dec25 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Tue Mar 11 01:52:38 2014 +0530
+++ b/source/encoder/ratecontrol.cpp	Tue Mar 11 18:36:31 2014 +0530
@@ -670,7 +670,7 @@
                     totalDuration += frameDuration;
                     bufferFillCur += vbvMaxRate * frameDuration;
                     int type = pic->m_lowres.plannedType[j];
-                    int64_t satd = pic->m_lowres.plannedSatd[j];
+                    int64_t satd = pic->m_lowres.plannedSatd[j] >> (X265_DEPTH - 8);
                     if (type == X265_TYPE_AUTO)
                         break;
                     type = IS_X265_TYPE_I(type) ? I_SLICE : IS_X265_TYPE_B(type) ? B_SLICE : P_SLICE;
@@ -774,6 +774,7 @@
         encodedBitsSoFar += pic->m_rowEncodedBits[row];
         rowSatdCostSoFar = pic->m_rowDiagSatd[row];
         uint32_t satdCostForPendingCus = pic->m_rowSatdForVbv[row] - rowSatdCostSoFar;
+        satdCostForPendingCus >>= X265_DEPTH - 8;
         if (satdCostForPendingCus  > 0)
         {
             double pred_s = predictSize(rce->rowPred[0], qScale, satdCostForPendingCus);
@@ -789,6 +790,7 @@
                     refRowBits += refPic->getCU(cuAddr)->m_totalBits;
                     intraCost += pic->m_intraCuCostsForVbv[cuAddr];
                 }
+                refRowSatdCost >>= X265_DEPTH - 8;
                 refQScale = refPic->m_rowDiagQScale[row];
             }
             if (picType == I_SLICE || qScale >= refQScale)
@@ -824,23 +826,26 @@
 int RateControl::rowDiagonalVbvRateControl(TComPic* pic, uint32_t row, RateControlEntry* rce, double& qpVbv)
 {
     double qScaleVbv = x265_qp2qScale(qpVbv);
-    double rowSatdCost = pic->m_rowDiagSatd[row];
+    uint64_t rowSatdCost = pic->m_rowDiagSatd[row];
     double encodedBits = pic->m_rowEncodedBits[row];
     if (row == 1)
     {
         rowSatdCost += pic->m_rowDiagSatd[0];
         encodedBits += pic->m_rowEncodedBits[0];
     }
-    updatePredictor(rce->rowPred[0], qScaleVbv, rowSatdCost, encodedBits);
+    rowSatdCost >>= X265_DEPTH - 8;
+    updatePredictor(rce->rowPred[0], qScaleVbv, (double)rowSatdCost, encodedBits);
     if (pic->getSlice()->getSliceType() == P_SLICE)
     {
         TComPic* refSlice = pic->getSlice()->getRefPic(REF_PIC_LIST_0, 0);
         if (qpVbv < refSlice->m_rowDiagQp[row])
         {
+            uint64_t intraRowSatdCost = pic->m_rowDiagIntraSatd[row];
             if (row == 1)
-                updatePredictor(rce->rowPred[1], qScaleVbv, pic->m_rowDiagIntraSatd[row] + pic->m_rowDiagIntraSatd[0], pic->m_rowEncodedBits[row] + pic->m_rowEncodedBits[0]);
-            else
-                updatePredictor(rce->rowPred[1], qScaleVbv, pic->m_rowDiagIntraSatd[row], pic->m_rowEncodedBits[row]);
+            {
+                intraRowSatdCost += pic->m_rowDiagIntraSatd[0];
+            }
+            updatePredictor(rce->rowPred[1], qScaleVbv, (double)intraRowSatdCost, encodedBits);
         }
     }
 


More information about the x265-devel mailing list