[x265] [PATCH] cabac: cleanup unused code

Min Chen chenm003 at 163.com
Sun Oct 13 05:50:24 CEST 2013


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1381636216 -28800
# Node ID 9cf433a526f4e0b48a5e4fce9d1553b2240b7e12
# Parent  40c806406d719e3c3253538c089df99228b9f2d6
cabac: cleanup unused code

diff -r 40c806406d71 -r 9cf433a526f4 source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Sun Oct 13 11:06:05 2013 +0800
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Sun Oct 13 11:50:16 2013 +0800
@@ -237,7 +237,6 @@
     m_totalCost        = MAX_INT64;
     m_totalDistortion  = 0;
     m_totalBits        = 0;
-    m_totalBins        = 0;
     m_numPartitions    = pic->getNumPartInCU();
 
     // CHECK_ME: why partStartIdx always negative
@@ -392,7 +391,6 @@
     m_totalCost        = MAX_INT64;
     m_totalDistortion  = 0;
     m_totalBits        = 0;
-    m_totalBins        = 0;
 
     UChar width  = g_maxCUWidth  >> depth;
     UChar height = g_maxCUHeight >> depth;
@@ -462,7 +460,6 @@
     m_totalCost        = MAX_INT64;
     m_totalDistortion  = 0;
     m_totalBits        = 0;
-    m_totalBins        = 0;
     m_numPartitions    = cu->getTotalNumPart() >> 2;
 
     int iSizeInUchar = sizeof(UChar) * m_numPartitions;
@@ -724,7 +721,6 @@
     memcpy(m_trCoeffCr + uiTmp2, cu->getCoeffCr(), sizeof(TCoeff) * uiTmp);
     memcpy(m_iPCMSampleCb + uiTmp2, cu->getPCMSampleCb(), sizeof(Pel) * uiTmp);
     memcpy(m_iPCMSampleCr + uiTmp2, cu->getPCMSampleCr(), sizeof(Pel) * uiTmp);
-    m_totalBins += cu->m_totalBins;
 }
 
 // Copy current predicted part to a CU in picture.
@@ -788,7 +784,6 @@
     memcpy(rpcCU->getCoeffCr() + tmp2, m_trCoeffCr, sizeof(TCoeff) * tmp);
     memcpy(rpcCU->getPCMSampleCb() + tmp2, m_iPCMSampleCb, sizeof(Pel) * tmp);
     memcpy(rpcCU->getPCMSampleCr() + tmp2, m_iPCMSampleCr, sizeof(Pel) * tmp);
-    rpcCU->m_totalBins = m_totalBins;
 }
 
 void TComDataCU::copyToPic(UChar depth, UInt partIdx, UInt partDepth)
@@ -850,7 +845,6 @@
     memcpy(cu->getCoeffCr() + tmp2, m_trCoeffCr, sizeof(TCoeff) * tmp);
     memcpy(cu->getPCMSampleCb() + tmp2, m_iPCMSampleCb, sizeof(Pel) * tmp);
     memcpy(cu->getPCMSampleCr() + tmp2, m_iPCMSampleCr, sizeof(Pel) * tmp);
-    cu->m_totalBins = m_totalBins;
 }
 
 // --------------------------------------------------------------------------------------------------------------------
diff -r 40c806406d71 -r 9cf433a526f4 source/Lib/TLibCommon/TComDataCU.h
--- a/source/Lib/TLibCommon/TComDataCU.h	Sun Oct 13 11:06:05 2013 +0800
+++ b/source/Lib/TLibCommon/TComDataCU.h	Sun Oct 13 11:50:16 2013 +0800
@@ -178,7 +178,6 @@
     UInt64        m_totalCost;       ///< sum of partition RD costs
     UInt          m_totalDistortion; ///< sum of partition distortion
     UInt          m_totalBits;       ///< sum of partition signal bits
-    UInt          m_totalBins;       ///< sum of partition bins
     
     // -------------------------------------------------------------------------------------------------------------------
     // create / destroy / initialize / copy
diff -r 40c806406d71 -r 9cf433a526f4 source/Lib/TLibEncoder/TEncBinCoder.h
--- a/source/Lib/TLibEncoder/TEncBinCoder.h	Sun Oct 13 11:06:05 2013 +0800
+++ b/source/Lib/TLibEncoder/TEncBinCoder.h	Sun Oct 13 11:50:16 2013 +0800
@@ -73,8 +73,6 @@
     virtual void  encodeBinsEP(UInt bins, int numBins) = 0;
     virtual void  encodeBinTrm(UInt bin) = 0;
 
-    virtual TEncBinCABAC*   getTEncBinCABAC()  { return 0; }
-
     virtual ~TEncBinIf() {}
 };
 }
diff -r 40c806406d71 -r 9cf433a526f4 source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp
--- a/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp	Sun Oct 13 11:06:05 2013 +0800
+++ b/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp	Sun Oct 13 11:50:16 2013 +0800
@@ -45,7 +45,6 @@
 
 TEncBinCABAC::TEncBinCABAC(bool isCounter)
     : m_pcTComBitIf(0)
-    , m_binCountIncrement(0)
     , m_fracBits(0)
     , bIsCounter(isCounter)
 {}
@@ -150,7 +149,7 @@
 
 void TEncBinCABAC::copyState(TEncBinIf* pcTEncBinIf)
 {
-    TEncBinCABAC* pcTEncBinCABAC = pcTEncBinIf->getTEncBinCABAC();
+    TEncBinCABAC* pcTEncBinCABAC = (TEncBinCABAC*)pcTEncBinIf;
 
     m_uiLow           = pcTEncBinCABAC->m_uiLow;
     m_uiRange         = pcTEncBinCABAC->m_uiRange;
@@ -166,11 +165,7 @@
     m_bitsLeft         = 23;
     m_numBufferedBytes = 0;
     m_bufferedByte     = 0xff;
-    if (m_binCountIncrement)
-    {
-        m_uiBinsCoded = 0;
-    }
-    m_fracBits &= 32767;
+    m_fracBits        &= 32767;
 }
 
 UInt TEncBinCABAC::getNumWrittenBits()
@@ -197,7 +192,6 @@
         DTRACE_CABAC_V(binValue)
         DTRACE_CABAC_T("\n")
     }
-    m_uiBinsCoded += m_binCountIncrement;
     if (bIsCounter)
     {
         m_fracBits += rcCtxModel.getEntropyBits(binValue);
@@ -247,7 +241,6 @@
         DTRACE_CABAC_V(binValue)
         DTRACE_CABAC_T("\n")
     }
-    m_uiBinsCoded += m_binCountIncrement;
     if (bIsCounter)
     {
         m_fracBits += 32768;
@@ -271,7 +264,6 @@
  */
 void TEncBinCABAC::encodeBinsEP(UInt binValues, int numBins)
 {
-    m_uiBinsCoded += numBins & - m_binCountIncrement;
     if (bIsCounter)
     {
         m_fracBits += 32768 * numBins;
@@ -312,7 +304,6 @@
  */
 void TEncBinCABAC::encodeBinTrm(UInt binValue)
 {
-    m_uiBinsCoded += m_binCountIncrement;
     if (bIsCounter)
     {
         m_fracBits += ContextModel::getEntropyBitsTrm(binValue);
diff -r 40c806406d71 -r 9cf433a526f4 source/Lib/TLibEncoder/TEncBinCoderCABAC.h
--- a/source/Lib/TLibEncoder/TEncBinCoderCABAC.h	Sun Oct 13 11:06:05 2013 +0800
+++ b/source/Lib/TLibEncoder/TEncBinCoderCABAC.h	Sun Oct 13 11:50:16 2013 +0800
@@ -73,16 +73,6 @@
     void  encodeBinsEP(UInt binValues, int numBins);
     void  encodeBinTrm(UInt binValue);
 
-    TEncBinCABAC* getTEncBinCABAC() { return this; }
-
-    void  setBinsCoded(UInt val) { m_uiBinsCoded = val; }
-
-    UInt  getBinsCoded() { return m_uiBinsCoded; }
-
-    void  setBinCountingEnableFlag(bool bFlag) { m_binCountIncrement = bFlag ? 1 : 0; }
-
-    bool  getBinCountingEnableFlag() { return m_binCountIncrement != 0; }
-
 protected:
 
     void testAndWriteOut();
@@ -95,8 +85,6 @@
     UInt                m_bufferedByte;
     int                 m_numBufferedBytes;
     int                 m_bitsLeft;
-    UInt                m_uiBinsCoded;
-    int                 m_binCountIncrement;
     UInt64              m_fracBits;
     bool                bIsCounter;
 };
diff -r 40c806406d71 -r 9cf433a526f4 source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp	Sun Oct 13 11:06:05 2013 +0800
+++ b/source/Lib/TLibEncoder/TEncCu.cpp	Sun Oct 13 11:50:16 2013 +0800
@@ -585,7 +585,6 @@
         m_entropyCoder->resetBits();
         m_entropyCoder->encodeSplitFlag(outBestCU, 0, depth, true);
         outBestCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits
-        outBestCU->m_totalBins += ((TEncBinCABAC*)((TEncSbac*)m_entropyCoder->m_entropyCoderIf)->getEncBinIf())->getBinsCoded();
         outBestCU->m_totalCost  = m_rdCost->calcRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits);
 
         // Early CU determination
@@ -662,7 +661,6 @@
             m_entropyCoder->encodeSplitFlag(outTempCU, 0, depth, true);
 
             outTempCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits
-            outTempCU->m_totalBins += ((TEncBinCABAC*)((TEncSbac*)m_entropyCoder->m_entropyCoderIf)->getEncBinIf())->getBinsCoded();
         }
         outTempCU->m_totalCost = m_rdCost->calcRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);
 
@@ -983,7 +981,6 @@
         m_entropyCoder->resetBits();
         m_entropyCoder->encodeSplitFlag(outBestCU, 0, depth, true);
         outBestCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits
-        outBestCU->m_totalBins += ((TEncBinCABAC*)((TEncSbac*)m_entropyCoder->m_entropyCoderIf)->getEncBinIf())->getBinsCoded();
         outBestCU->m_totalCost  = m_rdCost->calcRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits);
 
         // Early CU determination
@@ -1064,7 +1061,6 @@
             m_entropyCoder->encodeSplitFlag(outTempCU, 0, depth, true);
 
             outTempCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits
-            outTempCU->m_totalBins += ((TEncBinCABAC*)((TEncSbac*)m_entropyCoder->m_entropyCoderIf)->getEncBinIf())->getBinsCoded();
         }
         outTempCU->m_totalCost = m_rdCost->calcRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);
 
@@ -1566,7 +1562,6 @@
     m_rdGoOnSbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
 
     outTempCU->m_totalBits = m_entropyCoder->getNumberOfWrittenBits();
-    outTempCU->m_totalBins = ((TEncBinCABAC*)((TEncSbac*)m_entropyCoder->m_entropyCoderIf)->getEncBinIf())->getBinsCoded();
     outTempCU->m_totalCost = m_rdCost->calcRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);
 
     xCheckDQP(outTempCU);
@@ -1616,7 +1611,6 @@
     m_rdGoOnSbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
 
     outTempCU->m_totalBits = m_entropyCoder->getNumberOfWrittenBits();
-    outTempCU->m_totalBins = ((TEncBinCABAC*)((TEncSbac*)m_entropyCoder->m_entropyCoderIf)->getEncBinIf())->getBinsCoded();
     if (!m_cfg->param.bEnableRDO)
     {
         UInt partEnum = PartitionFromSizes(outTempCU->getWidth(0), outTempCU->getHeight(0));
@@ -1669,7 +1663,6 @@
     m_rdGoOnSbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
 
     outTempCU->m_totalBits = m_entropyCoder->getNumberOfWrittenBits();
-    outTempCU->m_totalBins = ((TEncBinCABAC*)((TEncSbac*)m_entropyCoder->m_entropyCoderIf)->getEncBinIf())->getBinsCoded();
     outTempCU->m_totalCost = m_rdCost->calcRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);
 
     xCheckDQP(outTempCU);
diff -r 40c806406d71 -r 9cf433a526f4 source/encoder/compress.cpp
--- a/source/encoder/compress.cpp	Sun Oct 13 11:06:05 2013 +0800
+++ b/source/encoder/compress.cpp	Sun Oct 13 11:50:16 2013 +0800
@@ -79,7 +79,6 @@
     m_rdGoOnSbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
 
     cu->m_totalBits = m_entropyCoder->getNumberOfWrittenBits();
-    cu->m_totalBins = ((TEncBinCABAC*)((TEncSbac*)m_entropyCoder->m_entropyCoderIf)->getEncBinIf())->getBinsCoded();
     cu->m_totalCost = m_rdCost->calcRdCost(cu->m_totalDistortion, cu->m_totalBits);
 }
 
@@ -539,7 +538,6 @@
         m_entropyCoder->resetBits();
         m_entropyCoder->encodeSplitFlag(outBestCU, 0, depth, true);
         outBestCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits
-        outBestCU->m_totalBins += ((TEncBinCABAC*)((TEncSbac*)m_entropyCoder->m_entropyCoderIf)->getEncBinIf())->getBinsCoded();
         outBestCU->m_totalCost  = m_rdCost->calcRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits);
     }
     else if (!(bSliceEnd && bInsidePicture))
@@ -609,7 +607,6 @@
                 m_entropyCoder->resetBits();
                 m_entropyCoder->encodeSplitFlag(outBestCU, 0, depth, true);
                 outBestCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits();        // split bits
-                outBestCU->m_totalBins += ((TEncBinCABAC*)((TEncSbac*)m_entropyCoder->m_entropyCoderIf)->getEncBinIf())->getBinsCoded();
                 outBestCU->m_totalCost  = m_rdCost->calcRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits);
                 /* Copy Best data to Picture for next partition prediction. */
                 outBestCU->copyToPic((UChar)depth);
@@ -659,7 +656,6 @@
             m_entropyCoder->encodeSplitFlag(outTempCU, 0, depth, true);
 
             outTempCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits
-            outTempCU->m_totalBins += ((TEncBinCABAC*)((TEncSbac*)m_entropyCoder->m_entropyCoderIf)->getEncBinIf())->getBinsCoded();
         }
 
         outTempCU->m_totalCost = m_rdCost->calcRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);
diff -r 40c806406d71 -r 9cf433a526f4 source/encoder/cturow.cpp
--- a/source/encoder/cturow.cpp	Sun Oct 13 11:06:05 2013 +0800
+++ b/source/encoder/cturow.cpp	Sun Oct 13 11:50:16 2013 +0800
@@ -68,11 +68,6 @@
 
 void CTURow::processCU(TComDataCU *cu, TComSlice *slice, TEncSbac *bufferSbac, bool bSaveSBac)
 {
-    TEncBinCABAC* rdSbacCoder = (TEncBinCABAC*)m_rdSbacCoders[0][CI_CURR_BEST]->getEncBinIf();
-
-    rdSbacCoder->setBinCountingEnableFlag(false);
-    rdSbacCoder->setBinsCoded(0);
-
     if (bufferSbac)
     {
         // Load SBAC coder context from previous row.
@@ -81,7 +76,6 @@
 
     m_entropyCoder.setEntropyCoder(&m_rdGoOnSbacCoder, slice);
     m_entropyCoder.setBitstream(&m_bitCounter);
-    ((TEncBinCABAC*)m_rdGoOnSbacCoder.getEncBinIf())->setBinCountingEnableFlag(true);
     m_cuCoder.setRDGoOnSbacCoder(&m_rdGoOnSbacCoder);
 
     m_cuCoder.compressCU(cu); // Does all the CU analysis
@@ -90,14 +84,10 @@
     m_entropyCoder.setEntropyCoder(m_rdSbacCoders[0][CI_CURR_BEST], slice);
     m_entropyCoder.setBitstream(&m_bitCounter);
     m_cuCoder.setBitCounter(&m_bitCounter);
-    rdSbacCoder->setBinCountingEnableFlag(true);
     m_bitCounter.resetBits();
-    rdSbacCoder->setBinsCoded(0);
 
     m_cuCoder.encodeCU(cu);  // Count bits
 
-    rdSbacCoder->setBinCountingEnableFlag(false);
-
     if (bSaveSBac)
     {
         // Save CABAC state for next row



More information about the x265-devel mailing list