[x265] [PATCH 1 of 4] cu, search: remove redundant m_rdGoOnSbacCoder pointer

Steve Borho steve at borho.org
Fri Jul 11 02:30:29 CEST 2014


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1405031594 18000
#      Thu Jul 10 17:33:14 2014 -0500
# Node ID d6c423c66e4d5a06dc4dccbd9eade7a21f9c8adf
# Parent  57a4c1c2274ec6b40f4a138523c6b67ffa853e09
cu, search: remove redundant m_rdGoOnSbacCoder pointer

m_rdGoOnSbacCoder was always either pointing to the same SBac as m_sbacCoder
(for calls to compressCU()) or it was supposed to be unused (for calls to
encodeCU)

diff -r 57a4c1c2274e -r d6c423c66e4d source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp	Thu Jul 10 14:13:30 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncCu.cpp	Thu Jul 10 17:33:14 2014 -0500
@@ -75,7 +75,6 @@
     m_rdCost          = NULL;
     m_sbacCoder       = NULL;
     m_rdSbacCoders    = NULL;
-    m_rdGoOnSbacCoder = NULL;
     m_bBitCounting    = false;
 }
 
@@ -1348,7 +1347,7 @@
     // Encode Coefficients
     bool bEncodeDQP = m_bEncodeDQP;
     m_sbacCoder->codeCoeff(outTempCU, 0, depth, outTempCU->getCUSize(0), bEncodeDQP);
-    m_rdGoOnSbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
+    m_sbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
     outTempCU->m_totalBits = m_sbacCoder->getNumberOfWrittenBits();
     outTempCU->m_coeffBits = outTempCU->m_totalBits - outTempCU->m_mvBits;
 
@@ -1397,7 +1396,7 @@
     // Encode Coefficients
     bool bCodeDQP = m_bEncodeDQP;
     m_sbacCoder->codeCoeff(outTempCU, 0, depth, outTempCU->getCUSize(0), bCodeDQP);
-    m_rdGoOnSbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
+    m_sbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
     outTempCU->m_totalBits = m_sbacCoder->getNumberOfWrittenBits();
     outTempCU->m_coeffBits = outTempCU->m_totalBits - outTempCU->m_mvBits;
 
diff -r 57a4c1c2274e -r d6c423c66e4d source/Lib/TLibEncoder/TEncCu.h
--- a/source/Lib/TLibEncoder/TEncCu.h	Thu Jul 10 14:13:30 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncCu.h	Thu Jul 10 17:33:14 2014 -0500
@@ -124,7 +124,6 @@
 
     // RD SBac pointers
     SBac       (*m_rdSbacCoders)[CI_NUM];
-    SBac*        m_rdGoOnSbacCoder;
 
     uint8_t      m_totalDepth;
 
diff -r 57a4c1c2274e -r d6c423c66e4d source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp	Thu Jul 10 14:13:30 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Thu Jul 10 17:33:14 2014 -0500
@@ -68,7 +68,6 @@
     m_trQuant = NULL;
     m_sbacCoder = NULL;
     m_rdSbacCoders = NULL;
-    m_rdGoOnSbacCoder = NULL;
     m_numLayers = 0;
 }
 
@@ -636,7 +635,7 @@
         if (checkTransformSkip || checkTQbypass)
         {
             //----- store original entropy coding status -----
-            m_rdGoOnSbacCoder->store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+            m_sbacCoder->store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 
             uint32_t  singleDistYTmp = 0;
             uint32_t  singlePsyEnergyYTmp = 0;
@@ -694,10 +693,10 @@
                     bestTQbypass = singleTQbypass;
                     bestModeId   = modeId;
                     if (bestModeId == firstCheckId)
-                        m_rdGoOnSbacCoder->store(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
+                        m_sbacCoder->store(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
                 }
                 if (modeId == firstCheckId)
-                    m_rdGoOnSbacCoder->load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+                    m_sbacCoder->load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
             }
 
             cu->setTransformSkipSubParts(checkTransformSkip ? bestModeId : 0, TEXT_LUMA, absPartIdx, fullDepth);
@@ -708,7 +707,7 @@
             {
                 xLoadIntraResultQT(cu, absPartIdx, log2TrSize, reconQt, reconQtStride);
                 cu->setCbfSubParts(singleCbfY << trDepth, TEXT_LUMA, absPartIdx, fullDepth);
-                m_rdGoOnSbacCoder->load(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
+                m_sbacCoder->load(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
             }
             else
             {
@@ -719,7 +718,7 @@
         }
         else
         {
-            m_rdGoOnSbacCoder->store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+            m_sbacCoder->store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 
             //----- code luma block with given intra prediction mode and store Cbf-----
             cu->setTransformSkipSubParts(0, TEXT_LUMA, absPartIdx, fullDepth);
@@ -748,11 +747,11 @@
         //----- store full entropy coding status, load original entropy coding status -----
         if (bCheckFull)
         {
-            m_rdGoOnSbacCoder->store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_TEST]);
-            m_rdGoOnSbacCoder->load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+            m_sbacCoder->store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_TEST]);
+            m_sbacCoder->load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
         }
         else
-            m_rdGoOnSbacCoder->store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+            m_sbacCoder->store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 
         //----- code splitted block -----
         uint64_t splitCost     = 0;
@@ -776,7 +775,7 @@
             cu->getCbf(TEXT_LUMA)[absPartIdx + offs] |= (splitCbfY << trDepth);
 
         //----- restore context states -----
-        m_rdGoOnSbacCoder->load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+        m_sbacCoder->load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 
         //----- determine rate and r-d cost -----
         uint32_t splitBits = xGetIntraBitsQTLuma(cu, trDepth, absPartIdx);
@@ -798,7 +797,7 @@
             cu->m_psyEnergy = singlePsyEnergyY;
 
         //----- set entropy coding status -----
-        m_rdGoOnSbacCoder->load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_TEST]);
+        m_sbacCoder->load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_TEST]);
 
         //--- set transform index and Cbf values ---
         cu->setTrIdxSubParts(trDepth, absPartIdx, fullDepth);
@@ -1103,7 +1102,7 @@
                 if (checkTransformSkip)
                 {
                     // use RDO to decide whether Cr/Cb takes TS
-                    m_rdGoOnSbacCoder->store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+                    m_sbacCoder->store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 
                     uint64_t singleCost     = MAX_INT64;
                     int      bestModeId     = 0;
@@ -1154,17 +1153,17 @@
                             singleCbfC  = singleCbfCTmp;
                             singlePsyEnergy = singlePsyEnergyTmp;
                             if (bestModeId == firstCheckId)
-                                m_rdGoOnSbacCoder->store(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
+                                m_sbacCoder->store(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
                         }
                         if (chromaModeId == firstCheckId)
-                            m_rdGoOnSbacCoder->load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+                            m_sbacCoder->load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
                     }
 
                     if (bestModeId == firstCheckId)
                     {
                         xLoadIntraResultChromaQT(cu, absPartIdxC, log2TrSizeC, chromaId, reconQt, reconQtStride);
                         cu->setCbfPartRange(singleCbfC << trDepth, (TextType)chromaId, absPartIdxC, tuIterator.absPartIdxStep);
-                        m_rdGoOnSbacCoder->load(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
+                        m_sbacCoder->load(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
                     }
                     else
                     {
@@ -1178,7 +1177,7 @@
                     outDist += singleDistC;
 
                     if (chromaId == 1)
-                        m_rdGoOnSbacCoder->store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+                        m_sbacCoder->store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
                 }
                 else
                 {
@@ -1578,7 +1577,7 @@
             cu->setLumaIntraDirSubParts(origMode, partOffset, depth + initTrDepth);
 
             // set context models
-            m_rdGoOnSbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
+            m_sbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
 
             // determine residual for partition
             uint32_t puDistY = 0;
@@ -1607,7 +1606,7 @@
             cu->setLumaIntraDirSubParts(origMode, partOffset, depth + initTrDepth);
 
             // set context models
-            m_rdGoOnSbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
+            m_sbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
 
             // determine residual for partition
             uint32_t puDistY = 0;
@@ -1664,7 +1663,7 @@
     }
 
     //===== reset context models =====
-    m_rdGoOnSbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
+    m_sbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
 
     //===== set distortion (rate and r-d costs are determined later) =====
     cu->m_totalDistortion = overallDistY;
@@ -1764,7 +1763,7 @@
         for (uint32_t mode = minMode; mode < maxMode; mode++)
         {
             //----- restore context models -----
-            m_rdGoOnSbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
+            m_sbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
 
             //----- chroma coding -----
             uint32_t dist = 0;
@@ -1774,7 +1773,7 @@
             xRecurIntraChromaCodingQT(cu, initTrDepth, absPartIdxC, fencYuv, predYuv, resiYuv, dist);
 
             if (cu->getSlice()->getPPS()->getUseTransformSkip())
-                m_rdGoOnSbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
+                m_sbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
 
             uint32_t bits = xGetIntraBitsQTChroma(cu, initTrDepth, absPartIdxC, tuIterator.absPartIdxStep);
             uint64_t cost = 0; 
@@ -1841,7 +1840,7 @@
         }
     }
     //----- restore context models -----
-    m_rdGoOnSbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
+    m_sbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
 }
 
 /** estimation of best merge coding
@@ -2339,7 +2338,7 @@
         distortion += m_rdCost->scaleChromaDistCb(primitives.sse_pp[part](fencYuv->getCbAddr(), fencYuv->getCStride(), outReconYuv->getCbAddr(), outReconYuv->getCStride()));
         distortion += m_rdCost->scaleChromaDistCr(primitives.sse_pp[part](fencYuv->getCrAddr(), fencYuv->getCStride(), outReconYuv->getCrAddr(), outReconYuv->getCStride()));
 
-        m_rdGoOnSbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
+        m_sbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
         m_sbacCoder->resetBits();
         if (cu->getSlice()->getPPS()->getTransquantBypassEnableFlag())
             m_sbacCoder->codeCUTransquantBypassFlag(cu, 0);
@@ -2360,7 +2359,7 @@
         else
             cu->m_totalRDCost = m_rdCost->calcRdCost(cu->m_totalDistortion, cu->m_totalBits);
 
-        m_rdGoOnSbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
+        m_sbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
 
         cu->clearCbf(0, depth);
         cu->setTrIdxSubParts(0, 0, depth);
@@ -2394,7 +2393,7 @@
         bits = 0;
         distortion = 0;
 
-        m_rdGoOnSbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
+        m_sbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
         xEstimateResidualQT(cu, 0, fencYuv, predYuv, outResiYuv, depth, cost, bits, distortion, &zeroDistortion, curUseRDOQ);
 
         m_sbacCoder->resetBits();
@@ -2435,7 +2434,7 @@
         else
             xSetResidualQTData(cu, 0, NULL, depth, false);
 
-        m_rdGoOnSbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
+        m_sbacCoder->load(m_rdSbacCoders[depth][CI_CURR_BEST]);
 
         bits = xSymbolBitsInter(cu);
 
@@ -2451,7 +2450,7 @@
 
             bestBits = bits;
             bestCost = cost;
-            m_rdGoOnSbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
+            m_sbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
         }
 
         X265_CHECK(bestCost != MAX_INT64, "no best cost\n");
@@ -2714,7 +2713,7 @@
 
     uint32_t bestCBF[MAX_NUM_COMPONENT];
     uint32_t bestsubTUCBF[MAX_NUM_COMPONENT][2];
-    m_rdGoOnSbacCoder->store(m_rdSbacCoders[depth][CI_QT_TRAFO_ROOT]);
+    m_sbacCoder->store(m_rdSbacCoders[depth][CI_QT_TRAFO_ROOT]);
 
     uint32_t trSize = 1 << log2TrSize;
     const bool splitIntoSubTUs = (chFmt == CHROMA_422);
@@ -3107,7 +3106,7 @@
             ALIGN_VAR_32(coeff_t, tsCoeffY[MAX_TS_SIZE * MAX_TS_SIZE]);
             ALIGN_VAR_32(int16_t, tsResiY[MAX_TS_SIZE * MAX_TS_SIZE]);
 
-            m_rdGoOnSbacCoder->load(m_rdSbacCoders[depth][CI_QT_TRAFO_ROOT]);
+            m_sbacCoder->load(m_rdSbacCoders[depth][CI_QT_TRAFO_ROOT]);
 
             cu->setTransformSkipSubParts(1, TEXT_LUMA, absPartIdx, depth);
 
@@ -3172,7 +3171,7 @@
             uint64_t singleCostU = MAX_INT64;
             uint64_t singleCostV = MAX_INT64;
 
-            m_rdGoOnSbacCoder->load(m_rdSbacCoders[depth][CI_QT_TRAFO_ROOT]);
+            m_sbacCoder->load(m_rdSbacCoders[depth][CI_QT_TRAFO_ROOT]);
 
             TURecurse tuIterator(splitIntoSubTUs ? VERTICAL_SPLIT : DONT_SPLIT, absPartIdxStep, absPartIdx);
 
@@ -3304,7 +3303,7 @@
             while (tuIterator.isNextSection());
         }
 
-        m_rdGoOnSbacCoder->load(m_rdSbacCoders[depth][CI_QT_TRAFO_ROOT]);
+        m_sbacCoder->load(m_rdSbacCoders[depth][CI_QT_TRAFO_ROOT]);
 
         m_sbacCoder->resetBits();
 
@@ -3388,8 +3387,8 @@
     {
         if (bCheckFull)
         {
-            m_rdGoOnSbacCoder->store(m_rdSbacCoders[depth][CI_QT_TRAFO_TEST]);
-            m_rdGoOnSbacCoder->load(m_rdSbacCoders[depth][CI_QT_TRAFO_ROOT]);
+            m_sbacCoder->store(m_rdSbacCoders[depth][CI_QT_TRAFO_TEST]);
+            m_sbacCoder->load(m_rdSbacCoders[depth][CI_QT_TRAFO_ROOT]);
         }
         uint32_t subdivDist = 0;
         uint32_t subdivBits = 0;
@@ -3435,7 +3434,7 @@
             cu->getCbf(TEXT_CHROMA_V)[absPartIdx + i] |= vcbf << trMode;
         }
 
-        m_rdGoOnSbacCoder->load(m_rdSbacCoders[depth][CI_QT_TRAFO_ROOT]);
+        m_sbacCoder->load(m_rdSbacCoders[depth][CI_QT_TRAFO_ROOT]);
         m_sbacCoder->resetBits();
 
         xEncodeResidualQT(cu, absPartIdx, depth, true,  TEXT_LUMA);
@@ -3479,7 +3478,7 @@
             }
         }
         X265_CHECK(bCheckFull, "check-full must be set\n");
-        m_rdGoOnSbacCoder->load(m_rdSbacCoders[depth][CI_QT_TRAFO_TEST]);
+        m_sbacCoder->load(m_rdSbacCoders[depth][CI_QT_TRAFO_TEST]);
     }
 
     rdCost += singleCost;
@@ -3691,7 +3690,7 @@
 uint32_t TEncSearch::xModeBitsIntra(TComDataCU* cu, uint32_t mode, uint32_t partOffset, uint32_t depth)
 {
     // Reload only contexts required for coding intra mode information
-    m_rdGoOnSbacCoder->loadIntraDirModeLuma(m_rdSbacCoders[depth][CI_CURR_BEST]);
+    m_sbacCoder->loadIntraDirModeLuma(m_rdSbacCoders[depth][CI_CURR_BEST]);
 
     cu->getLumaIntraDir()[partOffset] = (uint8_t)mode;
 
diff -r 57a4c1c2274e -r d6c423c66e4d source/Lib/TLibEncoder/TEncSearch.h
--- a/source/Lib/TLibEncoder/TEncSearch.h	Thu Jul 10 14:13:30 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSearch.h	Thu Jul 10 17:33:14 2014 -0500
@@ -104,8 +104,6 @@
     MotionEstimate   m_me;
     MotionReference (*m_mref)[MAX_NUM_REF + 1];
 
-    SBac          (*m_rdSbacCoders)[CI_NUM];
-    SBac*           m_rdGoOnSbacCoder;
     bool            m_bFrameParallel;
 
     ShortYuv*       m_qtTempShortYuv;
@@ -122,6 +120,8 @@
     SBac*           m_sbacCoder;
     x265_param*     m_param;
 
+    SBac          (*m_rdSbacCoders)[CI_NUM];
+
     bool            m_bEnableRDOQ;
     int             m_numLayers;
 
diff -r 57a4c1c2274e -r d6c423c66e4d source/encoder/compress.cpp
--- a/source/encoder/compress.cpp	Thu Jul 10 14:13:30 2014 -0500
+++ b/source/encoder/compress.cpp	Thu Jul 10 17:33:14 2014 -0500
@@ -42,7 +42,7 @@
     uint32_t initTrDepth = cu->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1;
 
     // set context models
-    m_search->m_rdGoOnSbacCoder->load(m_search->m_rdSbacCoders[depth][CI_CURR_BEST]);
+    m_sbacCoder->load(m_search->m_rdSbacCoders[depth][CI_CURR_BEST]);
 
     m_search->xRecurIntraCodingQT(cu, initTrDepth, 0, fencYuv, predYuv, outResiYuv, puDistY, false, puCost);
     m_search->xSetIntraResultQT(cu, initTrDepth, 0, outReconYuv);
@@ -71,7 +71,7 @@
     // Encode Coefficients
     bool bCodeDQP = m_bEncodeDQP;
     m_sbacCoder->codeCoeff(cu, 0, depth, cu->getCUSize(0), bCodeDQP);
-    m_rdGoOnSbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
+    m_sbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
 
     cu->m_totalBits = m_sbacCoder->getNumberOfWrittenBits();
     cu->m_coeffBits = cu->m_totalBits - cu->m_mvBits;
diff -r 57a4c1c2274e -r d6c423c66e4d source/encoder/cturow.cpp
--- a/source/encoder/cturow.cpp	Thu Jul 10 14:13:30 2014 -0500
+++ b/source/encoder/cturow.cpp	Thu Jul 10 17:33:14 2014 -0500
@@ -69,10 +69,8 @@
     // setup thread local data structures to use this row's CABAC state
     tld.m_search.m_sbacCoder = &m_rdGoOnSbacCoder;
     tld.m_search.m_rdSbacCoders = m_rdSbacCoders;
-    tld.m_search.m_rdGoOnSbacCoder = &m_rdGoOnSbacCoder;
     tld.m_cuCoder.m_sbacCoder = &m_rdGoOnSbacCoder;
     tld.m_cuCoder.m_rdSbacCoders = m_rdSbacCoders;
-    tld.m_cuCoder.m_rdGoOnSbacCoder = &m_rdGoOnSbacCoder;
 
     BitCounter bc;
     m_rdGoOnSbacCoder.setBitstream(&bc);


More information about the x265-devel mailing list