[x265] [PATCH] TEncCU and TEncEntrophy: Clean Up

gopu at multicorewareinc.com gopu at multicorewareinc.com
Mon Jul 15 11:28:30 CEST 2013


# HG changeset patch
# User ggopu
# Date 1373880498 -19800
# Node ID 19157b40110a41b94f6f7cefa5855b624e3a154b
# Parent  9e689682ffb144709c5351ca3b2828c507b19b26
TEncCU and TEncEntrophy: Clean Up

diff -r 9e689682ffb1 -r 19157b40110a source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp	Fri Jul 12 23:22:40 2013 -0500
+++ b/source/Lib/TLibEncoder/TEncCu.cpp	Mon Jul 15 14:58:18 2013 +0530
@@ -73,9 +73,9 @@
  \param    uiMaxWidth    largest CU width
  \param    uiMaxHeight   largest CU height
  */
-Void TEncCu::create(UChar uhTotalDepth, UInt uiMaxWidth, UInt uiMaxHeight)
+Void TEncCu::create(UChar totalDepth, UInt maxWidth)
 {
-    m_totalDepth   = uhTotalDepth + 1;
+    m_totalDepth   = totalDepth + 1;
     m_interCU_2Nx2N  = new TComDataCU*[m_totalDepth - 1];
     m_interCU_2NxN   = new TComDataCU*[m_totalDepth - 1];
     m_interCU_Nx2N   = new TComDataCU*[m_totalDepth - 1];
@@ -101,32 +101,32 @@
     m_tmpRecoYuv = new TComYuv*[m_totalDepth - 1];
 
     m_bestMergeRecoYuv = new TComYuv*[m_totalDepth - 1];
-    
+
     m_origYuv = new TComYuv*[m_totalDepth - 1];
 
     for (Int i = 0; i < m_totalDepth - 1; i++)
     {
-        UInt uiNumPartitions = 1 << ((m_totalDepth - i - 1) << 1);
-        UInt width  = uiMaxWidth  >> i;
-        UInt height = uiMaxHeight >> i;
+        UInt numPartitions = 1 << ((m_totalDepth - i - 1) << 1);
+        UInt width  = maxWidth  >> i;
+        UInt height = maxWidth >> i;
 
         m_bestCU[i] = new TComDataCU;
-        m_bestCU[i]->create(uiNumPartitions, width, height, false, uiMaxWidth >> (m_totalDepth - 1));
+        m_bestCU[i]->create(numPartitions, width, height, false, maxWidth >> (m_totalDepth - 1));
         m_tempCU[i] = new TComDataCU;
-        m_tempCU[i]->create(uiNumPartitions, width, height, false, uiMaxWidth >> (m_totalDepth - 1));
+        m_tempCU[i]->create(numPartitions, width, height, false, maxWidth >> (m_totalDepth - 1));
 
         m_interCU_2Nx2N[i] = new TComDataCU;
-        m_interCU_2Nx2N[i]->create(uiNumPartitions, width, height, false, uiMaxWidth >> (m_totalDepth - 1));
+        m_interCU_2Nx2N[i]->create(numPartitions, width, height, false, maxWidth >> (m_totalDepth - 1));
         m_interCU_2NxN[i] = new TComDataCU;
-        m_interCU_2NxN[i]->create(uiNumPartitions, width, height, false, uiMaxWidth >> (m_totalDepth - 1));
+        m_interCU_2NxN[i]->create(numPartitions, width, height, false, maxWidth >> (m_totalDepth - 1));
         m_interCU_Nx2N[i] = new TComDataCU;
-        m_interCU_Nx2N[i]->create(uiNumPartitions, width, height, false, uiMaxWidth >> (m_totalDepth - 1));
+        m_interCU_Nx2N[i]->create(numPartitions, width, height, false, maxWidth >> (m_totalDepth - 1));
         m_intraInInterCU[i] = new TComDataCU;
-        m_intraInInterCU[i]->create(uiNumPartitions, width, height, false, uiMaxWidth >> (m_totalDepth - 1));
+        m_intraInInterCU[i]->create(numPartitions, width, height, false, maxWidth >> (m_totalDepth - 1));
         m_mergeCU[i] = new TComDataCU;
-        m_mergeCU[i]->create(uiNumPartitions, width, height, false, uiMaxWidth >> (m_totalDepth - 1));
+        m_mergeCU[i]->create(numPartitions, width, height, false, maxWidth >> (m_totalDepth - 1));
         m_bestMergeCU[i] = new TComDataCU;
-        m_bestMergeCU[i]->create(uiNumPartitions, width, height, false, uiMaxWidth >> (m_totalDepth - 1));
+        m_bestMergeCU[i]->create(numPartitions, width, height, false, maxWidth >> (m_totalDepth - 1));
         m_bestPredYuv[i] = new TComYuv;
         m_bestPredYuv[i]->create(width, height);
         m_bestResiYuv[i] = new TShortYUV;
@@ -148,10 +148,10 @@
 
         m_tmpRecoYuv[i] = new TComYuv;
         m_tmpRecoYuv[i]->create(width, height);
-                
+
         m_bestMergeRecoYuv[i] = new TComYuv;
         m_bestMergeRecoYuv[i]->create(width, height);
-        
+
         m_origYuv[i] = new TComYuv;
         m_origYuv[i]->create(width, height);
     }
@@ -330,7 +330,7 @@
     }
     if (m_bestMergeRecoYuv)
     {
-        delete []m_bestMergeRecoYuv;
+        delete [] m_bestMergeRecoYuv;
         m_bestMergeRecoYuv = NULL;
     }
     if (m_tmpPredYuv)
@@ -346,6 +346,7 @@
             m_modePredYuv[i] = NULL;
         }
     }
+
     if (m_tmpResiYuv)
     {
         delete [] m_tmpResiYuv;
@@ -717,9 +718,9 @@
     }
 #endif
     outBestCU->copyToPic(depth); // Copy Best data to Picture for next partition prediction.
-    
+
     // Copy Yuv data to picture Yuv
-    xCopyYuv2Pic(outBestCU->getPic(), outBestCU->getAddr(), outBestCU->getZorderIdxInCU(), depth, depth, outBestCU, lpelx, tpelx); 
+    xCopyYuv2Pic(outBestCU->getPic(), outBestCU->getAddr(), outBestCU->getZorderIdxInCU(), depth, depth, outBestCU, lpelx, tpelx);
 
     if (bBoundary || (bSliceEnd && bInsidePicture)) return;
 
@@ -768,7 +769,7 @@
     Bool bSliceEnd = (slice->getSliceCurEndCUAddr() > outTempCU->getSCUAddr() &&
                       slice->getSliceCurEndCUAddr() < outTempCU->getSCUAddr() + outTempCU->getTotalNumPart());
     Bool bInsidePicture = (rpelx < outBestCU->getSlice()->getSPS()->getPicWidthInLumaSamples()) &&
-                          (bpely < outBestCU->getSlice()->getSPS()->getPicHeightInLumaSamples());
+        (bpely < outBestCU->getSlice()->getSPS()->getPicHeightInLumaSamples());
 
     // We need to split, so don't try these modes.
     if (!bSliceEnd && bInsidePicture)
@@ -1483,7 +1484,7 @@
                         yuv = outBestPredYuv;
                         outBestPredYuv = m_tmpPredYuv[depth];
                         m_tmpPredYuv[depth] = yuv;
-                        
+
                         yuv = rpcYuvReconBest;
                         rpcYuvReconBest = m_tmpRecoYuv[depth];
                         m_tmpRecoYuv[depth] = yuv;
@@ -1672,7 +1673,7 @@
 Void TEncCu::xCheckIntraPCM(TComDataCU*& outBestCU, TComDataCU*& outTempCU)
 {
     //PPAScopeEvent(TEncCU_xCheckIntraPCM);
-    
+
     UInt depth = outTempCU->getDepth(0);
 
     outTempCU->setSkipFlagSubParts(false, 0, depth);
@@ -1762,7 +1763,7 @@
     UInt bpely = tpely + (g_maxCUHeight >> depth) - 1;
     TComSlice* slice = cu->getPic()->getSlice();
     Bool bSliceEnd = slice->getSliceCurEndCUAddr() > (cu->getAddr()) * cu->getPic()->getNumPartInCU() + absPartIdx &&
-                     slice->getSliceCurEndCUAddr() < (cu->getAddr()) * cu->getPic()->getNumPartInCU() + absPartIdx + (cu->getPic()->getNumPartInCU() >> (depth << 1));
+        slice->getSliceCurEndCUAddr() < (cu->getAddr()) * cu->getPic()->getNumPartInCU() + absPartIdx + (cu->getPic()->getNumPartInCU() >> (depth << 1));
 
     if (!bSliceEnd && (rpelx < slice->getSPS()->getPicWidthInLumaSamples()) && (bpely < slice->getSPS()->getPicHeightInLumaSamples()))
     {
diff -r 9e689682ffb1 -r 19157b40110a source/Lib/TLibEncoder/TEncCu.h
--- a/source/Lib/TLibEncoder/TEncCu.h	Fri Jul 12 23:22:40 2013 -0500
+++ b/source/Lib/TLibEncoder/TEncCu.h	Mon Jul 15 14:58:18 2013 +0530
@@ -114,7 +114,7 @@
     TEncCu();
 
     Void init(TEncTop* top);
-    Void create(UChar totalDepth, UInt maxWidth, UInt maxHeight);
+    Void create(UChar totalDepth, UInt maxWidth);
     Void destroy();
     Void compressCU(TComDataCU* cu);
     Void encodeCU(TComDataCU* cu);
diff -r 9e689682ffb1 -r 19157b40110a source/Lib/TLibEncoder/TEncEntropy.cpp
--- a/source/Lib/TLibEncoder/TEncEntropy.cpp	Fri Jul 12 23:22:40 2013 -0500
+++ b/source/Lib/TLibEncoder/TEncEntropy.cpp	Mon Jul 15 14:58:18 2013 +0530
@@ -213,8 +213,8 @@
 
 Void TEncEntropy::xEncodeTransform(TComDataCU* cu, UInt offsetLuma, UInt offsetChroma, UInt absPartIdx, UInt depth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP)
 {
-    const UInt uiSubdiv = cu->getTransformIdx(absPartIdx) + cu->getDepth(absPartIdx) > depth;
-    const UInt uiLog2TrafoSize = g_convertToBit[cu->getSlice()->getSPS()->getMaxCUWidth()] + 2 - depth;
+    const UInt subdiv = cu->getTransformIdx(absPartIdx) + cu->getDepth(absPartIdx) > depth;
+    const UInt log2TrafoSize = g_convertToBit[cu->getSlice()->getSPS()->getMaxCUWidth()] + 2 - depth;
     UInt cbfY = cu->getCbf(absPartIdx, TEXT_LUMA, uiTrIdx);
     UInt cbfU = cu->getCbf(absPartIdx, TEXT_CHROMA_U, uiTrIdx);
     UInt cbfV = cu->getCbf(absPartIdx, TEXT_CHROMA_V, uiTrIdx);
@@ -223,7 +223,7 @@
     {
         m_bakAbsPartIdxCU = absPartIdx;
     }
-    if (uiLog2TrafoSize == 2)
+    if (log2TrafoSize == 2)
     {
         UInt partNum = cu->getPic()->getNumPartInCU() >> ((depth - 1) << 1);
         if ((absPartIdx % partNum) == 0)
@@ -240,40 +240,40 @@
 
     if (cu->getPredictionMode(absPartIdx) == MODE_INTRA && cu->getPartitionSize(absPartIdx) == SIZE_NxN && depth == cu->getDepth(absPartIdx))
     {
-        assert(uiSubdiv);
+        assert(subdiv);
     }
     else if (cu->getPredictionMode(absPartIdx) == MODE_INTER && (cu->getPartitionSize(absPartIdx) != SIZE_2Nx2N) && depth == cu->getDepth(absPartIdx) &&  (cu->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1))
     {
-        if (uiLog2TrafoSize > cu->getQuadtreeTULog2MinSizeInCU(absPartIdx))
+        if (log2TrafoSize > cu->getQuadtreeTULog2MinSizeInCU(absPartIdx))
         {
-            assert(uiSubdiv);
+            assert(subdiv);
         }
         else
         {
-            assert(!uiSubdiv);
+            assert(!subdiv);
         }
     }
-    else if (uiLog2TrafoSize > cu->getSlice()->getSPS()->getQuadtreeTULog2MaxSize())
+    else if (log2TrafoSize > cu->getSlice()->getSPS()->getQuadtreeTULog2MaxSize())
     {
-        assert(uiSubdiv);
+        assert(subdiv);
     }
-    else if (uiLog2TrafoSize == cu->getSlice()->getSPS()->getQuadtreeTULog2MinSize())
+    else if (log2TrafoSize == cu->getSlice()->getSPS()->getQuadtreeTULog2MinSize())
     {
-        assert(!uiSubdiv);
+        assert(!subdiv);
     }
-    else if (uiLog2TrafoSize == cu->getQuadtreeTULog2MinSizeInCU(absPartIdx))
+    else if (log2TrafoSize == cu->getQuadtreeTULog2MinSizeInCU(absPartIdx))
     {
-        assert(!uiSubdiv);
+        assert(!subdiv);
     }
     else
     {
-        assert(uiLog2TrafoSize > cu->getQuadtreeTULog2MinSizeInCU(absPartIdx));
-        m_pcEntropyCoderIf->codeTransformSubdivFlag(uiSubdiv, 5 - uiLog2TrafoSize);
+        assert(log2TrafoSize > cu->getQuadtreeTULog2MinSizeInCU(absPartIdx));
+        m_pcEntropyCoderIf->codeTransformSubdivFlag(subdiv, 5 - log2TrafoSize);
     }
 
     const UInt trDepthCurr = depth - cu->getDepth(absPartIdx);
     const Bool bFirstCbfOfCU = trDepthCurr == 0;
-    if (bFirstCbfOfCU || uiLog2TrafoSize > 2)
+    if (bFirstCbfOfCU || log2TrafoSize > 2)
     {
         if (bFirstCbfOfCU || cu->getCbf(absPartIdx, TEXT_CHROMA_U, trDepthCurr - 1))
         {
@@ -284,13 +284,13 @@
             m_pcEntropyCoderIf->codeQtCbf(cu, absPartIdx, TEXT_CHROMA_V, trDepthCurr);
         }
     }
-    else if (uiLog2TrafoSize == 2)
+    else if (log2TrafoSize == 2)
     {
         assert(cu->getCbf(absPartIdx, TEXT_CHROMA_U, trDepthCurr) == cu->getCbf(absPartIdx, TEXT_CHROMA_U, trDepthCurr - 1));
         assert(cu->getCbf(absPartIdx, TEXT_CHROMA_V, trDepthCurr) == cu->getCbf(absPartIdx, TEXT_CHROMA_V, trDepthCurr - 1));
     }
 
-    if (uiSubdiv)
+    if (subdiv)
     {
         UInt size;
         width  >>= 1;
@@ -354,11 +354,9 @@
         }
         if (cbfY)
         {
-            Int trWidth = width;
-            Int trHeight = height;
-            m_pcEntropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffY() + offsetLuma), absPartIdx, trWidth, trHeight, depth, TEXT_LUMA);
+            m_pcEntropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffY() + offsetLuma), absPartIdx, width, height, depth, TEXT_LUMA);
         }
-        if (uiLog2TrafoSize > 2)
+        if (log2TrafoSize > 2)
         {
             Int trWidth = width >> 1;
             Int trHeight = height >> 1;
@@ -376,15 +374,13 @@
             UInt partNum = cu->getPic()->getNumPartInCU() >> ((depth - 1) << 1);
             if ((absPartIdx % partNum) == (partNum - 1))
             {
-                Int trWidth = width;
-                Int trHeight = height;
                 if (cbfU)
                 {
-                    m_pcEntropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffCb() + m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, depth, TEXT_CHROMA_U);
+                    m_pcEntropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffCb() + m_uiBakChromaOffset), m_uiBakAbsPartIdx, width, height, depth, TEXT_CHROMA_U);
                 }
                 if (cbfV)
                 {
-                    m_pcEntropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffCr() + m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, depth, TEXT_CHROMA_V);
+                    m_pcEntropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffCr() + m_uiBakChromaOffset), m_uiBakAbsPartIdx, width, height, depth, TEXT_CHROMA_V);
                 }
             }
         }
@@ -439,27 +435,27 @@
     }
 
     PartSize partSize = cu->getPartitionSize(absPartIdx);
-    UInt uiNumPU = (partSize == SIZE_2Nx2N ? 1 : (partSize == SIZE_NxN ? 4 : 2));
+    UInt numPU = (partSize == SIZE_2Nx2N ? 1 : (partSize == SIZE_NxN ? 4 : 2));
     UInt depth = cu->getDepth(absPartIdx);
-    UInt uiPUOffset = (g_auiPUOffset[UInt(partSize)] << ((cu->getSlice()->getSPS()->getMaxCUDepth() - depth) << 1)) >> 4;
+    UInt puOffset = (g_auiPUOffset[UInt(partSize)] << ((cu->getSlice()->getSPS()->getMaxCUDepth() - depth) << 1)) >> 4;
 
-    for (UInt partIdx = 0, uiSubPartIdx = absPartIdx; partIdx < uiNumPU; partIdx++, uiSubPartIdx += uiPUOffset)
+    for (UInt partIdx = 0, subPartIdx = absPartIdx; partIdx < numPU; partIdx++, subPartIdx += puOffset)
     {
-        encodeMergeFlag(cu, uiSubPartIdx);
-        if (cu->getMergeFlag(uiSubPartIdx))
+        encodeMergeFlag(cu, subPartIdx);
+        if (cu->getMergeFlag(subPartIdx))
         {
-            encodeMergeIndex(cu, uiSubPartIdx);
+            encodeMergeIndex(cu, subPartIdx);
         }
         else
         {
-            encodeInterDirPU(cu, uiSubPartIdx);
+            encodeInterDirPU(cu, subPartIdx);
             for (UInt refListIdx = 0; refListIdx < 2; refListIdx++)
             {
                 if (cu->getSlice()->getNumRefIdx(RefPicList(refListIdx)) > 0)
                 {
-                    encodeRefFrmIdxPU(cu, uiSubPartIdx, RefPicList(refListIdx));
-                    encodeMvdPU(cu, uiSubPartIdx, RefPicList(refListIdx));
-                    encodeMVPIdxPU(cu, uiSubPartIdx, RefPicList(refListIdx));
+                    encodeRefFrmIdxPU(cu, subPartIdx, RefPicList(refListIdx));
+                    encodeMvdPU(cu, subPartIdx, RefPicList(refListIdx));
+                    encodeMVPIdxPU(cu, subPartIdx, RefPicList(refListIdx));
                 }
             }
         }
@@ -527,9 +523,9 @@
     m_pcEntropyCoderIf->codeQtCbf(cu, absPartIdx, ttype, trDepth);
 }
 
-Void TEncEntropy::encodeTransformSubdivFlag(UInt uiSymbol, UInt uiCtx)
+Void TEncEntropy::encodeTransformSubdivFlag(UInt symbol, UInt ctx)
 {
-    m_pcEntropyCoderIf->codeTransformSubdivFlag(uiSymbol, uiCtx);
+    m_pcEntropyCoderIf->codeTransformSubdivFlag(symbol, ctx);
 }
 
 Void TEncEntropy::encodeQtRootCbf(TComDataCU* cu, UInt absPartIdx)
@@ -572,9 +568,9 @@
  */
 Void TEncEntropy::encodeCoeff(TComDataCU* cu, UInt absPartIdx, UInt depth, UInt width, UInt height, Bool& bCodeDQP)
 {
-    UInt uiMinCoeffSize = cu->getPic()->getMinCUWidth() * cu->getPic()->getMinCUHeight();
-    UInt uiLumaOffset   = uiMinCoeffSize * absPartIdx;
-    UInt uiChromaOffset = uiLumaOffset >> 2;
+    UInt minCoeffSize = cu->getPic()->getMinCUWidth() * cu->getPic()->getMinCUHeight();
+    UInt lumaOffset   = minCoeffSize * absPartIdx;
+    UInt chromaOffset = lumaOffset >> 2;
 
     if (cu->isIntra(absPartIdx))
     {
@@ -595,7 +591,7 @@
         }
     }
 
-    xEncodeTransform(cu, uiLumaOffset, uiChromaOffset, absPartIdx, depth, width, height, 0, bCodeDQP);
+    xEncodeTransform(cu, lumaOffset, chromaOffset, absPartIdx, depth, width, height, 0, bCodeDQP);
 }
 
 Void TEncEntropy::encodeCoeffNxN(TComDataCU* cu, TCoeff* pcCoeff, UInt absPartIdx, UInt uiTrWidth, UInt uiTrHeight, UInt depth, TextType ttype)
@@ -616,15 +612,15 @@
  */
 Void TEncEntropy::encodeSaoOffset(SaoLcuParam* saoLcuParam, UInt compIdx)
 {
-    UInt uiSymbol;
+    UInt symbol;
     Int i;
 
-    uiSymbol = saoLcuParam->typeIdx + 1;
+    symbol = saoLcuParam->typeIdx + 1;
     if (compIdx != 2)
     {
-        m_pcEntropyCoderIf->codeSaoTypeIdx(uiSymbol);
+        m_pcEntropyCoderIf->codeSaoTypeIdx(symbol);
     }
-    if (uiSymbol)
+    if (symbol)
     {
         if (saoLcuParam->typeIdx < 4 && compIdx != 2)
         {
@@ -649,8 +645,8 @@
                 }
             }
 
-            uiSymbol = (UInt)(saoLcuParam->subTypeIdx);
-            m_pcEntropyCoderIf->codeSaoUflc(5, uiSymbol);
+            symbol = (UInt)(saoLcuParam->subTypeIdx);
+            m_pcEntropyCoderIf->codeSaoUflc(5, symbol);
         }
         else if (saoLcuParam->typeIdx < 4)
         {
@@ -660,8 +656,8 @@
             m_pcEntropyCoderIf->codeSaoMaxUvlc(-saoLcuParam->offset[3], offsetTh - 1);
             if (compIdx != 2)
             {
-                uiSymbol = (UInt)(saoLcuParam->subTypeIdx);
-                m_pcEntropyCoderIf->codeSaoUflc(2, uiSymbol);
+                symbol = (UInt)(saoLcuParam->subTypeIdx);
+                m_pcEntropyCoderIf->codeSaoUflc(2, symbol);
             }
         }
     }
@@ -706,11 +702,11 @@
     }
 }
 
-Int TEncEntropy::countNonZeroCoeffs(TCoeff* pcCoef, UInt uiSize)
+Int TEncEntropy::countNonZeroCoeffs(TCoeff* pcCoef, UInt size)
 {
     Int count = 0;
 
-    for (Int i = 0; i < uiSize; i++)
+    for (Int i = 0; i < size; i++)
     {
         count += pcCoef[i] != 0;
     }
diff -r 9e689682ffb1 -r 19157b40110a source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Fri Jul 12 23:22:40 2013 -0500
+++ b/source/encoder/frameencoder.cpp	Mon Jul 15 14:58:18 2013 +0530
@@ -62,7 +62,7 @@
     m_search.setEntropyCoder(&m_entropyCoder);
     m_search.setRDGoOnSbacCoder(&m_rdGoOnSbacCoder);
 
-    m_cuCoder.create((UChar)g_maxCUDepth, g_maxCUWidth, g_maxCUHeight);
+    m_cuCoder.create((UChar)g_maxCUDepth, g_maxCUWidth);
     m_cuCoder.init(top);
     m_cuCoder.setRdCost(&m_rdCost);
     m_cuCoder.setRDSbacCoder(m_rdSbacCoders);


More information about the x265-devel mailing list