[x265] cleanup g_convertTxtTypeToIdx[]

Satoshi Nakagawa nakagawa424 at oki.com
Tue Jan 28 02:47:12 CET 2014


# HG changeset patch
# User Satoshi Nakagawa <nakagawa424 at oki.com>
# Date 1390830789 -32400
#      Mon Jan 27 22:53:09 2014 +0900
# Node ID 704f4ef99927767324e992539e86c520ba45b490
# Parent  b59b1e579f78b4c29c0c1491e6198a63ba1d597f
cleanup g_convertTxtTypeToIdx[]

diff -r b59b1e579f78 -r 704f4ef99927 source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Mon Jan 27 00:10:56 2014 -0600
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Mon Jan 27 22:53:09 2014 +0900
@@ -1315,7 +1315,7 @@
 {
     uint32_t curPartNum = m_pic->getNumPartInCU() >> (depth << 1);
 
-    memset(m_cbf[g_convertTxtTypeToIdx[ttype]] + absPartIdx, cbf, sizeof(UChar) * curPartNum);
+    memset(m_cbf[ttype] + absPartIdx, cbf, sizeof(UChar) * curPartNum);
 }
 
 /** Sets a coded block flag for all sub-partitions of a partition
@@ -1328,7 +1328,7 @@
  */
 void TComDataCU::setCbfSubParts(uint32_t uiCbf, TextType ttype, uint32_t absPartIdx, uint32_t partIdx, uint32_t depth)
 {
-    setSubPart<UChar>(uiCbf, m_cbf[g_convertTxtTypeToIdx[ttype]], absPartIdx, depth, partIdx);
+    setSubPart<UChar>(uiCbf, m_cbf[ttype], absPartIdx, depth, partIdx);
 }
 
 void TComDataCU::setDepthSubParts(uint32_t depth, uint32_t absPartIdx)
@@ -1558,7 +1558,7 @@
 {
     uint32_t curPartNum = m_pic->getNumPartInCU() >> (depth << 1);
 
-    memset(m_transformSkip[g_convertTxtTypeToIdx[ttype]] + absPartIdx, useTransformSkip, sizeof(UChar) * curPartNum);
+    memset(m_transformSkip[ttype] + absPartIdx, useTransformSkip, sizeof(UChar) * curPartNum);
 }
 
 UChar TComDataCU::getNumPartInter()
@@ -2572,7 +2572,7 @@
 
 void TComDataCU::clearCbf(uint32_t idx, TextType ttype, uint32_t numParts)
 {
-    ::memset(&m_cbf[g_convertTxtTypeToIdx[ttype]][idx], 0, sizeof(UChar) * numParts);
+    ::memset(&m_cbf[ttype][idx], 0, sizeof(UChar) * numParts);
 }
 
 /** Set a I_PCM flag for all sub-partitions of a partition.
diff -r b59b1e579f78 -r 704f4ef99927 source/Lib/TLibCommon/TComDataCU.h
--- a/source/Lib/TLibCommon/TComDataCU.h	Mon Jan 27 00:10:56 2014 -0600
+++ b/source/Lib/TLibCommon/TComDataCU.h	Mon Jan 27 22:53:09 2014 +0900
@@ -281,9 +281,9 @@
 
     void          setTrIdxSubParts(uint32_t uiTrIdx, uint32_t absPartIdx, uint32_t depth);
 
-    UChar*        getTransformSkip(TextType ttype)     { return m_transformSkip[g_convertTxtTypeToIdx[ttype]]; }
+    UChar*        getTransformSkip(TextType ttype)     { return m_transformSkip[ttype]; }
 
-    UChar         getTransformSkip(uint32_t idx, TextType ttype)    { return m_transformSkip[g_convertTxtTypeToIdx[ttype]][idx]; }
+    UChar         getTransformSkip(uint32_t idx, TextType ttype)    { return m_transformSkip[ttype][idx]; }
 
     void          setTransformSkipSubParts(uint32_t useTransformSkip, TextType ttype, uint32_t absPartIdx, uint32_t depth);
     void          setTransformSkipSubParts(uint32_t useTransformSkipY, uint32_t useTransformSkipU, uint32_t useTransformSkipV, uint32_t absPartIdx, uint32_t depth);
@@ -304,13 +304,13 @@
 
     Pel*&         getPCMSampleCr()            { return m_iPCMSampleCr; }
 
-    UChar         getCbf(uint32_t idx, TextType ttype) { return m_cbf[g_convertTxtTypeToIdx[ttype]][idx]; }
+    UChar         getCbf(uint32_t idx, TextType ttype) { return m_cbf[ttype][idx]; }
 
-    UChar*        getCbf(TextType ttype)           { return m_cbf[g_convertTxtTypeToIdx[ttype]]; }
+    UChar*        getCbf(TextType ttype)           { return m_cbf[ttype]; }
 
     UChar         getCbf(uint32_t idx, TextType ttype, uint32_t trDepth) { return (getCbf(idx, ttype) >> trDepth) & 0x1; }
 
-    void          setCbf(uint32_t idx, TextType ttype, UChar uh)     { m_cbf[g_convertTxtTypeToIdx[ttype]][idx] = uh; }
+    void          setCbf(uint32_t idx, TextType ttype, UChar uh)     { m_cbf[ttype][idx] = uh; }
 
     void          clearCbf(uint32_t idx, TextType ttype, uint32_t numParts);
     UChar         getQtRootCbf(uint32_t idx)           { return getCbf(idx, TEXT_LUMA, 0) || getCbf(idx, TEXT_CHROMA_U, 0) || getCbf(idx, TEXT_CHROMA_V, 0); }
diff -r b59b1e579f78 -r 704f4ef99927 source/Lib/TLibCommon/TComRom.cpp
--- a/source/Lib/TLibCommon/TComRom.cpp	Mon Jan 27 00:10:56 2014 -0600
+++ b/source/Lib/TLibCommon/TComRom.cpp	Mon Jan 27 22:53:09 2014 +0900
@@ -302,10 +302,6 @@
     3 // 128x128
 };
 
-// chroma
-
-const UChar g_convertTxtTypeToIdx[4] = { 0, 1, 1, 2 };
-
 // ====================================================================================================================
 // Misc.
 // ====================================================================================================================
@@ -508,7 +504,6 @@
 uint32_t g_scalingListSize[4] = { 16, 64, 256, 1024 };
 uint32_t g_scalingListSizeX[4] = { 4, 8, 16,  32 };
 uint32_t g_scalingListNum[SCALING_LIST_SIZE_NUM] = { 6, 6, 6, 2 };
-int  g_eTTable[4] = { 0, 3, 1, 2 };
 
 const int g_winUnitX[] = { 1, 2, 2, 1 };
 const int g_winUnitY[] = { 1, 2, 1, 1 };
diff -r b59b1e579f78 -r 704f4ef99927 source/Lib/TLibCommon/TComRom.h
--- a/source/Lib/TLibCommon/TComRom.h	Mon Jan 27 00:10:56 2014 -0600
+++ b/source/Lib/TLibCommon/TComRom.h	Mon Jan 27 22:53:09 2014 +0900
@@ -169,12 +169,6 @@
 inline T Clip3(T minVal, T maxVal, T a) { return std::min<T>(std::max<T>(minVal, a), maxVal); } ///< general min/max clip
 
 // ====================================================================================================================
-// Texture type to integer mapping
-// ====================================================================================================================
-
-extern const UChar g_convertTxtTypeToIdx[4];
-
-// ====================================================================================================================
 // Misc.
 // ====================================================================================================================
 
@@ -288,7 +282,6 @@
 extern uint32_t g_scalingListSize[SCALING_LIST_SIZE_NUM];
 extern uint32_t g_scalingListSizeX[SCALING_LIST_SIZE_NUM];
 extern uint32_t g_scalingListNum[SCALING_LIST_SIZE_NUM];
-extern int  g_eTTable[4];
 //! \}
 
 // Map Luma samples to chroma samples
diff -r b59b1e579f78 -r 704f4ef99927 source/Lib/TLibCommon/TComTrQuant.cpp
--- a/source/Lib/TLibCommon/TComTrQuant.cpp	Mon Jan 27 00:10:56 2014 -0600
+++ b/source/Lib/TLibCommon/TComTrQuant.cpp	Mon Jan 27 22:53:09 2014 +0900
@@ -274,7 +274,7 @@
         int deltaU[32 * 32];
 
         uint32_t log2TrSize = g_convertToBit[width] + 2;
-        int scalingListType = (cu->isIntra(absPartIdx) ? 0 : 3) + g_eTTable[(int)ttype];
+        int scalingListType = (cu->isIntra(absPartIdx) ? 0 : 3) + ttype;
         assert(scalingListType < 6);
         int32_t *quantCoeff = 0;
         quantCoeff = getQuantCoeff(scalingListType, m_qpParam.m_rem, log2TrSize - 2);
@@ -510,7 +510,7 @@
     uint32_t       goRiceParam      = 0;
     double     blockUncodedCost = 0;
     const uint32_t log2BlkSize      = g_convertToBit[width] + 2;
-    int scalingListType = (cu->isIntra(absPartIdx) ? 0 : 3) + g_eTTable[(int)ttype];
+    int scalingListType = (cu->isIntra(absPartIdx) ? 0 : 3) + ttype;
 
     assert(scalingListType < 6);
 
@@ -789,7 +789,7 @@
     else
     {
         ctxCbf    = cu->getCtxQtCbf(ttype, cu->getTransformIdx(absPartIdx));
-        ctxCbf    = (ttype ? TEXT_CHROMA : ttype) * NUM_QT_CBF_CTX + ctxCbf;
+        ctxCbf    = (ttype ? NUM_QT_CBF_CTX : 0) + ctxCbf;
         bestCost  = blockUncodedCost + xGetICost(m_estBitsSbac->blockCbpBits[ctxCbf][0]);
         baseCost += xGetICost(m_estBitsSbac->blockCbpBits[ctxCbf][1]);
     }
diff -r b59b1e579f78 -r 704f4ef99927 source/Lib/TLibCommon/TypeDef.h
--- a/source/Lib/TLibCommon/TypeDef.h	Mon Jan 27 00:10:56 2014 -0600
+++ b/source/Lib/TLibCommon/TypeDef.h	Mon Jan 27 22:53:09 2014 +0900
@@ -107,11 +107,10 @@
 /// texture component type
 enum TextType
 {
-    TEXT_LUMA,          ///< luma
-    TEXT_CHROMA,        ///< chroma (U+V)
-    TEXT_CHROMA_U,      ///< chroma U
-    TEXT_CHROMA_V,      ///< chroma V
-    TEXT_ALL,           ///< Y+U+V
+    TEXT_LUMA     = 0,  ///< luma
+    TEXT_CHROMA   = 1,  ///< chroma (U+V)
+    TEXT_CHROMA_U = 1,  ///< chroma U
+    TEXT_CHROMA_V = 2,  ///< chroma V
 };
 
 /// index for SBAC based RD optimization
diff -r b59b1e579f78 -r 704f4ef99927 source/Lib/TLibEncoder/TEncSbac.cpp
--- a/source/Lib/TLibEncoder/TEncSbac.cpp	Mon Jan 27 00:10:56 2014 -0600
+++ b/source/Lib/TLibEncoder/TEncSbac.cpp	Mon Jan 27 22:53:09 2014 +0900
@@ -1897,7 +1897,7 @@
     uint32_t cbf = cu->getCbf(absPartIdx, ttype, trDepth);
     uint32_t ctx = cu->getCtxQtCbf(ttype, trDepth);
 
-    m_binIf->encodeBin(cbf, m_contextModels[OFF_QT_CBF_CTX + (ttype ? TEXT_CHROMA : 0) * NUM_QT_CBF_CTX + ctx]);
+    m_binIf->encodeBin(cbf, m_contextModels[OFF_QT_CBF_CTX + (ttype ? NUM_QT_CBF_CTX : 0) + ctx]);
     DTRACE_CABAC_VL(g_nSymbolCounter++)
     DTRACE_CABAC_T("\tparseQtCbf()")
     DTRACE_CABAC_T("\tsymbol=")
@@ -1923,7 +1923,7 @@
     }
 
     uint32_t useTransformSkip = cu->getTransformSkip(absPartIdx, ttype);
-    m_binIf->encodeBin(useTransformSkip, m_contextModels[OFF_TRANSFORMSKIP_FLAG_CTX + (ttype ? TEXT_CHROMA : TEXT_LUMA) * NUM_TRANSFORMSKIP_FLAG_CTX]);
+    m_binIf->encodeBin(useTransformSkip, m_contextModels[OFF_TRANSFORMSKIP_FLAG_CTX + (ttype ? NUM_TRANSFORMSKIP_FLAG_CTX : 0)]);
     DTRACE_CABAC_VL(g_nSymbolCounter++)
     DTRACE_CABAC_T("\tparseTransformSkip()");
     DTRACE_CABAC_T("\tsymbol=")
@@ -2042,7 +2042,7 @@
     uint32_t cbf = 0;
     uint32_t ctx = cu->getCtxQtCbf(ttype, trDepth);
 
-    m_binIf->encodeBin(cbf, m_contextModels[OFF_QT_CBF_CTX + (ttype ? TEXT_CHROMA : 0) * NUM_QT_CBF_CTX + ctx]);
+    m_binIf->encodeBin(cbf, m_contextModels[OFF_QT_CBF_CTX + (ttype ? NUM_QT_CBF_CTX : 0) + ctx]);
 }
 
 void TEncSbac::codeQtRootCbfZero(TComDataCU*)
diff -r b59b1e579f78 -r 704f4ef99927 source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp	Mon Jan 27 00:10:56 2014 -0600
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Mon Jan 27 22:53:09 2014 +0900
@@ -486,7 +486,7 @@
     int size = g_convertToBit[width];
     if (absSum)
     {
-        int scalingListType = 0 + g_eTTable[(int)TEXT_LUMA];
+        int scalingListType = 0 + TEXT_LUMA;
         assert(scalingListType < 6);
         m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), cu->getLumaIntraDir(absPartIdx), residual, stride, coeff, width, height, scalingListType, useTransformSkip, lastPos);
     }
@@ -621,7 +621,7 @@
         //--- inverse transform ---
         if (absSum)
         {
-            int scalingListType = 0 + g_eTTable[(int)ttype];
+            int scalingListType = 0 + ttype;
             assert(scalingListType < 6);
             m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), REG_DCT, residual, stride, coeff, width, height, scalingListType, useTransformSkipChroma, lastPos);
         }
@@ -1056,7 +1056,7 @@
         int size = g_convertToBit[width];
         if (absSum)
         {
-            int scalingListType = 0 + g_eTTable[(int)TEXT_LUMA];
+            int scalingListType = 0 + TEXT_LUMA;
             assert(scalingListType < 6);
             m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), cu->getLumaIntraDir(absPartIdx), residual, stride, coeff, width, height, scalingListType, useTransformSkip, lastPos);
         }
@@ -1683,7 +1683,7 @@
             //--- inverse transform ---
             if (absSum)
             {
-                int scalingListType = 0 + g_eTTable[(int)ttype];
+                int scalingListType = 0 + ttype;
                 assert(scalingListType < 6);
                 m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), REG_DCT, residual, stride, coeff, width, height, scalingListType, useTransformSkipChroma, lastPos);
             }
@@ -3306,7 +3306,7 @@
 
             m_trQuant->setQPforQuant(cu->getQP(0), TEXT_LUMA, cu->getSlice()->getSPS()->getQpBDOffsetY(), 0);
 
-            int scalingListType = 3 + g_eTTable[(int)TEXT_LUMA];
+            int scalingListType = 3 + TEXT_LUMA;
             assert(scalingListType < 6);
             m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), REG_DCT, curResiY, resiYuv->m_width,  coeffCurY, trWidth, trHeight, scalingListType, false, lastPosY); //this is for inter mode only
         }
@@ -3326,7 +3326,7 @@
                 int curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCbQpOffset() + cu->getSlice()->getSliceQpDeltaCb();
                 m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset);
 
-                int scalingListType = 3 + g_eTTable[(int)TEXT_CHROMA_U];
+                int scalingListType = 3 + TEXT_CHROMA_U;
                 assert(scalingListType < 6);
                 m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), REG_DCT, pcResiCurrU, resiYuv->m_cwidth, coeffCurU, trWidthC, trHeightC, scalingListType, false, lastPosU);
             }
@@ -3342,7 +3342,7 @@
                 int curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCrQpOffset() + cu->getSlice()->getSliceQpDeltaCr();
                 m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset);
 
-                int scalingListType = 3 + g_eTTable[(int)TEXT_CHROMA_V];
+                int scalingListType = 3 + TEXT_CHROMA_V;
                 assert(scalingListType < 6);
                 m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), REG_DCT, curResiV, resiYuv->m_cwidth, coeffCurV, trWidthC, trHeightC, scalingListType, false, lastPosV);
             }
@@ -3550,7 +3550,7 @@
 
             m_trQuant->setQPforQuant(cu->getQP(0), TEXT_LUMA, cu->getSlice()->getSPS()->getQpBDOffsetY(), 0);
 
-            int scalingListType = 3 + g_eTTable[(int)TEXT_LUMA];
+            int scalingListType = 3 + TEXT_LUMA;
             assert(scalingListType < 6);
             assert(m_qtTempTComYuv[qtlayer].m_width == MAX_CU_SIZE);
             m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), REG_DCT, curResiY, MAX_CU_SIZE,  coeffCurY, trWidth, trHeight, scalingListType, false, lastPosY); //this is for inter mode only
@@ -3622,7 +3622,7 @@
                 int curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCbQpOffset() + cu->getSlice()->getSliceQpDeltaCb();
                 m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset);
 
-                int scalingListType = 3 + g_eTTable[(int)TEXT_CHROMA_U];
+                int scalingListType = 3 + TEXT_CHROMA_U;
                 assert(scalingListType < 6);
                 assert(m_qtTempTComYuv[qtlayer].m_cwidth == MAX_CU_SIZE / 2);
                 m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), REG_DCT, pcResiCurrU, MAX_CU_SIZE / 2, coeffCurU, trWidthC, trHeightC, scalingListType, false, lastPosU);
@@ -3689,7 +3689,7 @@
                 int curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCrQpOffset() + cu->getSlice()->getSliceQpDeltaCr();
                 m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset);
 
-                int scalingListType = 3 + g_eTTable[(int)TEXT_CHROMA_V];
+                int scalingListType = 3 + TEXT_CHROMA_V;
                 assert(scalingListType < 6);
                 assert(m_qtTempTComYuv[qtlayer].m_cwidth == MAX_CU_SIZE / 2);
                 m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), REG_DCT, curResiV, MAX_CU_SIZE / 2, coeffCurV, trWidthC, trHeightC, scalingListType, false, lastPosV);
@@ -3795,7 +3795,7 @@
 
                 m_trQuant->setQPforQuant(cu->getQP(0), TEXT_LUMA, cu->getSlice()->getSPS()->getQpBDOffsetY(), 0);
 
-                int scalingListType = 3 + g_eTTable[(int)TEXT_LUMA];
+                int scalingListType = 3 + TEXT_LUMA;
                 assert(scalingListType < 6);
                 assert(m_qtTempTComYuv[qtlayer].m_width == MAX_CU_SIZE);
 
@@ -3886,7 +3886,7 @@
                 curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCbQpOffset() + cu->getSlice()->getSliceQpDeltaCb();
                 m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset);
 
-                int scalingListType = 3 + g_eTTable[(int)TEXT_CHROMA_U];
+                int scalingListType = 3 + TEXT_CHROMA_U;
                 assert(scalingListType < 6);
                 assert(m_qtTempTComYuv[qtlayer].m_cwidth == MAX_CU_SIZE / 2);
 
@@ -3925,7 +3925,7 @@
                 curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCrQpOffset() + cu->getSlice()->getSliceQpDeltaCr();
                 m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset);
 
-                int scalingListType = 3 + g_eTTable[(int)TEXT_CHROMA_V];
+                int scalingListType = 3 + TEXT_CHROMA_V;
                 assert(scalingListType < 6);
                 assert(m_qtTempTComYuv[qtlayer].m_cwidth == MAX_CU_SIZE / 2);
 


More information about the x265-devel mailing list