[x265] [PATCH 1 of 2] vbv: use row wise IntraSatdCost to predict vbv intra frame bits

aarthi at multicorewareinc.com aarthi at multicorewareinc.com
Mon Mar 10 20:36:35 CET 2014


# HG changeset patch
# User Aarthi Thirumalai
# Date 1394477273 -19800
#      Tue Mar 11 00:17:53 2014 +0530
# Node ID 489ec5db168c83c61836b77503eb9280fd5b5164
# Parent  f76a92a2b00beed83fa61810f57c366b8a2bcef1
vbv: use row wise IntraSatdCost to predict vbv intra frame bits.

If P/B slice is predominatly inntra coded, use intra SatdCost to predict the row bits in vbv.

diff -r f76a92a2b00b -r 489ec5db168c source/Lib/TLibCommon/TComPic.cpp
--- a/source/Lib/TLibCommon/TComPic.cpp	Mon Mar 10 12:16:50 2014 -0500
+++ b/source/Lib/TLibCommon/TComPic.cpp	Tue Mar 11 00:17:53 2014 +0530
@@ -59,10 +59,12 @@
     , m_rowDiagQp(NULL)
     , m_rowDiagQScale(NULL)
     , m_rowDiagSatd(NULL)
+    , m_rowDiagIntraSatd(NULL)
     , m_rowEncodedBits(NULL)
     , m_numEncodedCusPerRow(NULL)
     , m_rowSatdForVbv(NULL)
     , m_cuCostsForVbv(NULL)
+    , m_intraCuCostsForVbv(NULL)
 {
     m_reconRowCount = 0;
     m_countRefEncoders = 0;
@@ -119,10 +121,12 @@
             CHECKED_MALLOC(m_rowDiagQp, double, numRows);
             CHECKED_MALLOC(m_rowDiagQScale, double, numRows);
             CHECKED_MALLOC(m_rowDiagSatd, uint32_t, numRows);
+            CHECKED_MALLOC(m_rowDiagIntraSatd, uint32_t, numRows);
             CHECKED_MALLOC(m_rowEncodedBits, uint32_t, numRows);
             CHECKED_MALLOC(m_numEncodedCusPerRow, uint32_t, numRows);
             CHECKED_MALLOC(m_rowSatdForVbv, uint32_t, numRows);
             CHECKED_MALLOC(m_cuCostsForVbv, uint32_t, numRows * numCols);
+            CHECKED_MALLOC(m_intraCuCostsForVbv, uint32_t, numRows * numCols);
             CHECKED_MALLOC(m_qpaRc, double, numRows);
         }
         reInit(cfg);
@@ -144,10 +148,12 @@
         memset(m_rowDiagQp, 0, numRows * sizeof(double));
         memset(m_rowDiagQScale, 0, numRows * sizeof(double));
         memset(m_rowDiagSatd, 0, numRows * sizeof(uint32_t));
+        memset(m_rowDiagIntraSatd, 0, numRows * sizeof(uint32_t));
         memset(m_rowEncodedBits, 0, numRows * sizeof(uint32_t));
         memset(m_numEncodedCusPerRow, 0, numRows * sizeof(uint32_t));
         memset(m_rowSatdForVbv, 0, numRows * sizeof(uint32_t));
         memset(m_cuCostsForVbv, 0,  numRows * numCols * sizeof(uint32_t));
+        memset(m_intraCuCostsForVbv, 0, numRows * numCols * sizeof(uint32_t));
         memset(m_qpaRc, 0, numRows * sizeof(double));
     }
     if (cfg->param->rc.aqMode)
@@ -181,10 +187,12 @@
     X265_FREE(m_rowDiagQp);
     X265_FREE(m_rowDiagQScale);
     X265_FREE(m_rowDiagSatd);
+    X265_FREE(m_rowDiagIntraSatd);
     X265_FREE(m_rowEncodedBits);
     X265_FREE(m_numEncodedCusPerRow);
     X265_FREE(m_rowSatdForVbv);
     X265_FREE(m_cuCostsForVbv);
+    X265_FREE(m_intraCuCostsForVbv);
     X265_FREE(m_qpaAq);
     X265_FREE(m_qpaRc);
 }
diff -r f76a92a2b00b -r 489ec5db168c source/Lib/TLibCommon/TComPic.h
--- a/source/Lib/TLibCommon/TComPic.h	Mon Mar 10 12:16:50 2014 -0500
+++ b/source/Lib/TLibCommon/TComPic.h	Tue Mar 11 00:17:53 2014 +0530
@@ -106,10 +106,12 @@
     double*               m_rowDiagQp;
     double*               m_rowDiagQScale;
     uint32_t*             m_rowDiagSatd;
+    uint32_t*             m_rowDiagIntraSatd;
     uint32_t*             m_rowEncodedBits;
     uint32_t*             m_numEncodedCusPerRow;
     uint32_t*             m_rowSatdForVbv;
     uint32_t*             m_cuCostsForVbv;
+    uint32_t*             m_intraCuCostsForVbv;
     double*               m_qpaAq;
     double*               m_qpaRc;
     double                m_avgQpRc; //avg QP as decided by ratecontrol
diff -r f76a92a2b00b -r 489ec5db168c source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Mon Mar 10 12:16:50 2014 -0500
+++ b/source/encoder/ratecontrol.cpp	Tue Mar 11 00:17:53 2014 +0530
@@ -782,7 +782,7 @@
         if (satdCostForPendingCus  > 0)
         {
             double pred_s = predictSize(rowPred[0], qScale, satdCostForPendingCus);
-            uint32_t refRowSatdCost = 0, refRowBits = 0;
+            uint32_t refRowSatdCost = 0, refRowBits = 0, intraCost = 0;
             double refQScale = 0;
 
             if (picType != I_SLICE)
@@ -792,6 +792,7 @@
                 {
                     refRowSatdCost += refPic->m_cuCostsForVbv[cuAddr];
                     refRowBits += refPic->getCU(cuAddr)->m_totalBits;
+                    intraCost += pic->m_intraCuCostsForVbv[cuAddr];
                 }
 
                 refQScale = row == maxRows - 1 ? refPic->m_rowDiagQScale[row] : refPic->m_rowDiagQScale[row + 1];
@@ -817,7 +818,7 @@
             else
             {
                 /* Our QP is lower than the reference! */
-                double pred_intra = predictSize(rowPred[1], qScale, satdCostForPendingCus);
+                double pred_intra = predictSize(rowPred[1], qScale, intraCost);
                 /* Sum: better to overestimate than underestimate by using only one of the two predictors. */
                 totalSatdBits += int32_t(pred_intra + pred_s);
             }
@@ -847,9 +848,9 @@
         if (qpVbv < refSlice->m_rowDiagQp[row])
         {
             if (row == 1)
-                updatePredictor(rowPred[1], qScaleVbv, refSlice->m_rowDiagSatd[row] + refSlice->m_rowDiagSatd[0], refSlice->m_rowEncodedBits[row] + refSlice->m_rowEncodedBits[0]);
+                updatePredictor(rowPred[1], qScaleVbv, pic->m_rowDiagIntraSatd[row] + pic->m_rowDiagIntraSatd[0], pic->m_rowEncodedBits[row] + pic->m_rowEncodedBits[0]);
             else
-                updatePredictor(rowPred[1], qScaleVbv, refSlice->m_rowDiagSatd[row], refSlice->m_rowEncodedBits[row]);
+                updatePredictor(rowPred[1], qScaleVbv, pic->m_rowDiagIntraSatd[row], pic->m_rowEncodedBits[row]);
         }
     }
 


More information about the x265-devel mailing list