[x265] [PATCH] remove getNumPartInCU() and replace it with macro

santhoshini at multicorewareinc.com santhoshini at multicorewareinc.com
Thu Sep 25 12:05:21 CEST 2014


# HG changeset patch
# User Santhoshini Sekar <santhoshini at multicorewareinc.com>
# Date 1411638856 -19800
#      Thu Sep 25 15:24:16 2014 +0530
# Node ID e26ef0404b0042d9f46c18002197fdbce6b19601
# Parent  cb114b17a30e8dc12eb9a14ce5ae7d155398e1c5
remove getNumPartInCU() and replace it with macro

diff -r cb114b17a30e -r e26ef0404b00 source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Thu Sep 25 13:52:58 2014 +0530
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Thu Sep 25 15:24:16 2014 +0530
@@ -320,7 +320,7 @@
     m_totalBits        = 0;
     m_mvBits           = 0;
     m_coeffBits        = 0;
-    m_numPartitions    = pic->getNumPartInCU();
+    m_numPartitions    = NUM_CU_PARTITIONS;
     char* qp           = pic->getCU(getAddr())->getQP();
     m_baseQp           = pic->getCU(getAddr())->m_baseQp;
     for (int i = 0; i < 4; i++)
@@ -771,7 +771,7 @@
     if (planarAtLCUBoundary)
         return NULL;
 
-    aPartUnitIdx = g_rasterToZscan[absPartIdx + m_pic->getNumPartInCU() - numPartInCUSize];
+    aPartUnitIdx = g_rasterToZscan[absPartIdx + NUM_CU_PARTITIONS - numPartInCUSize];
     return m_cuAbove;
 }
 
@@ -796,7 +796,7 @@
                 return this;
             }
         }
-        alPartUnitIdx = g_rasterToZscan[absPartIdx + m_pic->getNumPartInCU() - numPartInCUSize - 1];
+        alPartUnitIdx = g_rasterToZscan[absPartIdx + NUM_CU_PARTITIONS - numPartInCUSize - 1];
         return m_cuAbove;
     }
 
@@ -806,7 +806,7 @@
         return m_cuLeft;
     }
 
-    alPartUnitIdx = g_rasterToZscan[m_pic->getNumPartInCU() - 1];
+    alPartUnitIdx = g_rasterToZscan[NUM_CU_PARTITIONS - 1];
     return m_cuAboveLeft;
 }
 
@@ -838,7 +838,7 @@
             }
             return NULL;
         }
-        arPartUnitIdx = g_rasterToZscan[absPartIdxRT + m_pic->getNumPartInCU() - numPartInCUSize + 1];
+        arPartUnitIdx = g_rasterToZscan[absPartIdxRT + NUM_CU_PARTITIONS - numPartInCUSize + 1];
         return m_cuAbove;
     }
 
@@ -847,7 +847,7 @@
         return NULL;
     }
 
-    arPartUnitIdx = g_rasterToZscan[m_pic->getNumPartInCU() - numPartInCUSize];
+    arPartUnitIdx = g_rasterToZscan[NUM_CU_PARTITIONS - numPartInCUSize];
     return m_cuAboveRight;
 }
 
@@ -959,7 +959,7 @@
             }
             return NULL;
         }
-        arPartUnitIdx = g_rasterToZscan[absPartIdxRT + m_pic->getNumPartInCU() - numPartInCUSize + partUnitOffset];
+        arPartUnitIdx = g_rasterToZscan[absPartIdxRT + NUM_CU_PARTITIONS - numPartInCUSize + partUnitOffset];
         if (m_cuAbove == NULL || m_cuAbove->m_slice == NULL)
         {
             return NULL;
@@ -972,7 +972,7 @@
         return NULL;
     }
 
-    arPartUnitIdx = g_rasterToZscan[m_pic->getNumPartInCU() - numPartInCUSize + partUnitOffset - 1];
+    arPartUnitIdx = g_rasterToZscan[NUM_CU_PARTITIONS - numPartInCUSize + partUnitOffset - 1];
     if ((m_cuAboveRight == NULL || m_cuAboveRight->m_slice == NULL ||
          (m_cuAboveRight->getAddr()) > getAddr()))
     {
@@ -1073,7 +1073,7 @@
         else if (getAddr() > 0 && !(m_slice->m_pps->bEntropyCodingSyncEnabled &&
                                     getAddr() % m_pic->getFrameWidthInCU() == 0))
         {
-            return m_pic->getCU(getAddr() - 1)->getLastCodedQP(m_pic->getNumPartInCU());
+            return m_pic->getCU(getAddr() - 1)->getLastCodedQP(NUM_CU_PARTITIONS);
         }
         else
         {
@@ -1213,7 +1213,7 @@
 
 void TComDataCU::clearCbf(uint32_t absPartIdx, uint32_t depth)
 {
-    uint32_t curPartNum = m_pic->getNumPartInCU() >> (depth << 1);
+    uint32_t curPartNum = NUM_CU_PARTITIONS >> (depth << 1);
 
     memset(m_cbf[0] + absPartIdx, 0, sizeof(uint8_t) * curPartNum);
     memset(m_cbf[1] + absPartIdx, 0, sizeof(uint8_t) * curPartNum);
@@ -1222,7 +1222,7 @@
 
 void TComDataCU::setCbfSubParts(uint32_t cbf, TextType ttype, uint32_t absPartIdx, uint32_t depth)
 {
-    uint32_t curPartNum = m_pic->getNumPartInCU() >> (depth << 1);
+    uint32_t curPartNum = NUM_CU_PARTITIONS >> (depth << 1);
 
     memset(m_cbf[ttype] + absPartIdx, cbf, sizeof(uint8_t) * curPartNum);
 }
@@ -1235,14 +1235,14 @@
 void TComDataCU::setDepthSubParts(uint32_t depth)
 {
     /*All 4x4 partitions in current CU have the CU depth saved*/
-    uint32_t curPartNum = m_pic->getNumPartInCU() >> (depth << 1);
+    uint32_t curPartNum = NUM_CU_PARTITIONS >> (depth << 1);
 
     memset(m_depth, depth, sizeof(uint8_t) * curPartNum);
 }
 
 bool TComDataCU::isFirstAbsZorderIdxInDepth(uint32_t absPartIdx, uint32_t depth)
 {
-    uint32_t curPartNum = m_pic->getNumPartInCU() >> (depth << 1);
+    uint32_t curPartNum = NUM_CU_PARTITIONS >> (depth << 1);
 
     return ((m_absIdxInLCU + absPartIdx) & (curPartNum - 1)) == 0;
 }
@@ -1250,29 +1250,29 @@
 void TComDataCU::setPartSizeSubParts(PartSize mode, uint32_t absPartIdx, uint32_t depth)
 {
     X265_CHECK(sizeof(*m_partSizes) == 1, "size check failure\n");
-    memset(m_partSizes + absPartIdx, mode, m_pic->getNumPartInCU() >> (depth << 1));
+    memset(m_partSizes + absPartIdx, mode, NUM_CU_PARTITIONS >> (depth << 1));
 }
 
 void TComDataCU::setCUTransquantBypassSubParts(bool flag, uint32_t absPartIdx, uint32_t depth)
 {
-    memset(m_cuTransquantBypass + absPartIdx, flag, m_pic->getNumPartInCU() >> (depth << 1));
+    memset(m_cuTransquantBypass + absPartIdx, flag, NUM_CU_PARTITIONS >> (depth << 1));
 }
 
 void TComDataCU::setSkipFlagSubParts(bool skip, uint32_t absPartIdx, uint32_t depth)
 {
     X265_CHECK(sizeof(*m_skipFlag) == 1, "size check failure\n");
-    memset(m_skipFlag + absPartIdx, skip, m_pic->getNumPartInCU() >> (depth << 1));
+    memset(m_skipFlag + absPartIdx, skip, NUM_CU_PARTITIONS >> (depth << 1));
 }
 
 void TComDataCU::setPredModeSubParts(PredMode eMode, uint32_t absPartIdx, uint32_t depth)
 {
     X265_CHECK(sizeof(*m_predModes) == 1, "size check failure\n");
-    memset(m_predModes + absPartIdx, eMode, m_pic->getNumPartInCU() >> (depth << 1));
+    memset(m_predModes + absPartIdx, eMode, NUM_CU_PARTITIONS >> (depth << 1));
 }
 
 void TComDataCU::setQPSubCUs(int qp, TComDataCU* cu, uint32_t absPartIdx, uint32_t depth, bool &foundNonZeroCbf)
 {
-    uint32_t curPartNumb = m_pic->getNumPartInCU() >> (depth << 1);
+    uint32_t curPartNumb = NUM_CU_PARTITIONS >> (depth << 1);
     uint32_t curPartNumQ = curPartNumb >> 2;
 
     if (!foundNonZeroCbf)
@@ -1300,7 +1300,7 @@
 
 void TComDataCU::setQPSubParts(int qp, uint32_t absPartIdx, uint32_t depth)
 {
-    uint32_t curPartNum = m_pic->getNumPartInCU() >> (depth << 1);
+    uint32_t curPartNum = NUM_CU_PARTITIONS >> (depth << 1);
 
     for (uint32_t scuIdx = absPartIdx; scuIdx < absPartIdx + curPartNum; scuIdx++)
     {
@@ -1310,7 +1310,7 @@
 
 void TComDataCU::setLumaIntraDirSubParts(uint32_t dir, uint32_t absPartIdx, uint32_t depth)
 {
-    uint32_t curPartNum = m_pic->getNumPartInCU() >> (depth << 1);
+    uint32_t curPartNum = NUM_CU_PARTITIONS >> (depth << 1);
 
     memset(m_lumaIntraDir + absPartIdx, dir, sizeof(uint8_t) * curPartNum);
 }
@@ -1320,7 +1320,7 @@
 {
     X265_CHECK(sizeof(T) == 1, "size check failure\n"); // Using memset() works only for types of size 1
 
-    uint32_t curPartNumQ = (m_pic->getNumPartInCU() >> (2 * cuDepth)) >> 2;
+    uint32_t curPartNumQ = (NUM_CU_PARTITIONS >> (2 * cuDepth)) >> 2;
     switch (m_partSizes[cuAddr])
     {
     case SIZE_2Nx2N:
@@ -1415,7 +1415,7 @@
 
 void TComDataCU::setChromIntraDirSubParts(uint32_t dir, uint32_t absPartIdx, uint32_t depth)
 {
-    uint32_t curPartNum = m_pic->getNumPartInCU() >> (depth << 1);
+    uint32_t curPartNum = NUM_CU_PARTITIONS >> (depth << 1);
 
     memset(m_chromaIntraDir + absPartIdx, dir, sizeof(uint8_t) * curPartNum);
 }
@@ -1427,14 +1427,14 @@
 
 void TComDataCU::setTrIdxSubParts(uint32_t trIdx, uint32_t absPartIdx, uint32_t depth)
 {
-    uint32_t curPartNum = m_pic->getNumPartInCU() >> (depth << 1);
+    uint32_t curPartNum = NUM_CU_PARTITIONS >> (depth << 1);
 
     memset(m_trIdx + absPartIdx, trIdx, sizeof(uint8_t) * curPartNum);
 }
 
 void TComDataCU::setTransformSkipSubParts(uint32_t useTransformSkipY, uint32_t useTransformSkipU, uint32_t useTransformSkipV, uint32_t absPartIdx, uint32_t depth)
 {
-    uint32_t curPartNum = m_pic->getNumPartInCU() >> (depth << 1);
+    uint32_t curPartNum = NUM_CU_PARTITIONS >> (depth << 1);
 
     memset(m_transformSkip[0] + absPartIdx, useTransformSkipY, sizeof(uint8_t) * curPartNum);
     memset(m_transformSkip[1] + absPartIdx, useTransformSkipU, sizeof(uint8_t) * curPartNum);
@@ -1443,7 +1443,7 @@
 
 void TComDataCU::setTransformSkipSubParts(uint32_t useTransformSkip, TextType ttype, uint32_t absPartIdx, uint32_t depth)
 {
-    uint32_t curPartNum = m_pic->getNumPartInCU() >> (depth << 1);
+    uint32_t curPartNum = NUM_CU_PARTITIONS >> (depth << 1);
 
     memset(m_transformSkip[ttype] + absPartIdx, useTransformSkip, sizeof(uint8_t) * curPartNum);
 }
diff -r cb114b17a30e -r e26ef0404b00 source/common/deblock.cpp
--- a/source/common/deblock.cpp	Thu Sep 25 13:52:58 2014 +0530
+++ b/source/common/deblock.cpp	Thu Sep 25 15:24:16 2014 +0530
@@ -48,7 +48,7 @@
         return;
 
     Frame* pic = cu->m_pic;
-    uint32_t curNumParts = pic->getNumPartInCU() >> (depth << 1);
+    uint32_t curNumParts = NUM_CU_PARTITIONS >> (depth << 1);
 
     if (cu->getDepth(absZOrderIdx) > depth)
     {
@@ -119,7 +119,7 @@
 {
     if (cu->getTransformIdx(absZOrderIdx) + cu->getDepth(absZOrderIdx) > (uint8_t)depth)
     {
-        const uint32_t curNumParts = cu->m_pic->getNumPartInCU() >> (depth << 1);
+        const uint32_t curNumParts = NUM_CU_PARTITIONS >> (depth << 1);
         const uint32_t qNumParts   = curNumParts >> 2;
 
         for (uint32_t partIdx = 0; partIdx < 4; partIdx++, absZOrderIdx += qNumParts)
diff -r cb114b17a30e -r e26ef0404b00 source/common/frame.h
--- a/source/common/frame.h	Thu Sep 25 13:52:58 2014 +0530
+++ b/source/common/frame.h	Thu Sep 25 15:24:16 2014 +0530
@@ -23,6 +23,7 @@
 
 #ifndef X265_FRAME_H
 #define X265_FRAME_H
+#define NUM_CU_PARTITIONS uint32_t(1 << (g_maxFullDepth << 1))
 
 #include "common.h"
 #include "TLibCommon/TComPicSym.h"
@@ -117,8 +118,6 @@
 
     uint32_t    getNumPartInCUSize() const { return m_picSym->getNumPartInCUSize(); }
 
-    uint32_t    getNumPartInCU() const     { return m_picSym->getNumPartition(); }
-
     uint32_t    getFrameWidthInCU() const  { return m_picSym->getFrameWidthInCU(); }
 
     uint32_t    getFrameHeightInCU() const { return m_picSym->getFrameHeightInCU(); }
diff -r cb114b17a30e -r e26ef0404b00 source/common/slice.cpp
--- a/source/common/slice.cpp	Thu Sep 25 13:52:58 2014 +0530
+++ b/source/common/slice.cpp	Thu Sep 25 15:24:16 2014 +0530
@@ -182,8 +182,8 @@
 uint32_t Slice::realEndAddress(uint32_t endCUAddr)
 {
     // Calculate end address
-    uint32_t internalAddress = (endCUAddr - 1) % m_pic->getNumPartInCU();
-    uint32_t externalAddress = (endCUAddr - 1) / m_pic->getNumPartInCU();
+    uint32_t internalAddress = (endCUAddr - 1) % NUM_CU_PARTITIONS;
+    uint32_t externalAddress = (endCUAddr - 1) / NUM_CU_PARTITIONS;
     uint32_t xmax = m_sps->picWidthInLumaSamples  - (externalAddress % m_pic->getFrameWidthInCU()) * g_maxCUSize;
     uint32_t ymax = m_sps->picHeightInLumaSamples - (externalAddress / m_pic->getFrameWidthInCU()) * g_maxCUSize;
 
@@ -191,13 +191,13 @@
         internalAddress--;
 
     internalAddress++;
-    if (internalAddress == m_pic->getNumPartInCU())
+    if (internalAddress == NUM_CU_PARTITIONS)
     {
         internalAddress = 0;
         externalAddress++;
     }
 
-    return externalAddress * m_pic->getNumPartInCU() + internalAddress;
+    return externalAddress * NUM_CU_PARTITIONS + internalAddress;
 }
 
 
diff -r cb114b17a30e -r e26ef0404b00 source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp	Thu Sep 25 13:52:58 2014 +0530
+++ b/source/encoder/analysis.cpp	Thu Sep 25 15:24:16 2014 +0530
@@ -2069,7 +2069,7 @@
         Slice* slice = cu->m_slice;
         uint32_t nextDepth = depth + 1;
         TComDataCU* subTempPartCU = m_tempCU[nextDepth];
-        uint32_t qNumParts = (pic->getNumPartInCU() >> (depth << 1)) >> 2;
+        uint32_t qNumParts = (NUM_CU_PARTITIONS >> (depth << 1)) >> 2;
         uint32_t xmax = slice->m_sps->picWidthInLumaSamples  - lcu->getCUPelX();
         uint32_t ymax = slice->m_sps->picHeightInLumaSamples - lcu->getCUPelY();        for (uint32_t partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++, absPartIdx += qNumParts)
         {
diff -r cb114b17a30e -r e26ef0404b00 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Thu Sep 25 13:52:58 2014 +0530
+++ b/source/encoder/encoder.cpp	Thu Sep 25 15:24:16 2014 +0530
@@ -454,7 +454,7 @@
             slice->m_sps = &m_sps;
             slice->m_pps = &m_pps;
             slice->m_maxNumMergeCand = m_param->maxNumMergeCand;
-            slice->m_endCUAddr = slice->realEndAddress(fenc->getNumCUsInFrame() * fenc->getNumPartInCU());
+            slice->m_endCUAddr = slice->realEndAddress(fenc->getNumCUsInFrame() * NUM_CU_PARTITIONS);
         }
         curEncoder->m_rce.encodeOrder = m_encodedFrameNum++;
         if (m_bframeDelay)
diff -r cb114b17a30e -r e26ef0404b00 source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp	Thu Sep 25 13:52:58 2014 +0530
+++ b/source/encoder/entropy.cpp	Thu Sep 25 15:24:16 2014 +0530
@@ -490,7 +490,6 @@
 /* encode a CU block recursively */
 void Entropy::encodeCU(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth, bool& bEncodeDQP, CU* cuData)
 {
-    Frame* pic = cu->m_pic;
     Slice* slice = cu->m_slice;
 
     if (depth <= slice->m_pps->maxCuDQPDepth && slice->m_pps->bUseDQP)
@@ -501,7 +500,7 @@
 
     if (!cuUnsplitFlag)
     {
-        uint32_t qNumParts = (pic->getNumPartInCU() >> (depth << 1)) >> 2;
+        uint32_t qNumParts = (NUM_CU_PARTITIONS >> (depth << 1)) >> 2;
         for (uint32_t partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++, absPartIdx += qNumParts)
         {
             CU *childCU = cu->m_CULocalData + cuData->childIdx + partUnitIdx;
@@ -518,7 +517,7 @@
 
     if (depth < cu->getDepth(absPartIdx) && depth < g_maxCUDepth)
     {
-        uint32_t qNumParts = (pic->getNumPartInCU() >> (depth << 1)) >> 2;
+        uint32_t qNumParts = (NUM_CU_PARTITIONS >> (depth << 1)) >> 2;
 
         for (uint32_t partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++, absPartIdx += qNumParts)
         {
@@ -580,7 +579,7 @@
     {
         // Encode slice finish
         bool bTerminateSlice = false;
-        if (cuAddr + (cu->m_pic->getNumPartInCU() >> (depth << 1)) == realEndAddress)
+        if (cuAddr + (NUM_CU_PARTITIONS >> (depth << 1)) == realEndAddress)
             bTerminateSlice = true;
 
         // The 1-terminating bit is added to all streams, so don't add it here when it's 1.
@@ -607,7 +606,7 @@
 
     if ((log2TrSize == 2) && !(cu->getChromaFormat() == X265_CSP_I444))
     {
-        uint32_t partNum = cu->m_pic->getNumPartInCU() >> ((depth - 1) << 1);
+        uint32_t partNum = NUM_CU_PARTITIONS >> ((depth - 1) << 1);
         if ((absPartIdx & (partNum - 1)) == 0)
         {
             state.bakAbsPartIdx   = absPartIdx;
@@ -684,7 +683,7 @@
         trIdx++;
         ++depth;
         absPartIdxStep >>= 2;
-        const uint32_t partNum = cu->m_pic->getNumPartInCU() >> (depth << 1);
+        const uint32_t partNum = NUM_CU_PARTITIONS >> (depth << 1);
 
         encodeTransform(cu, state, offsetLuma, offsetChroma, absPartIdx, absPartIdxStep, depth, log2TrSize, trIdx, bCodeDQP, depthRange);
 
@@ -730,13 +729,13 @@
         int chFmt = cu->getChromaFormat();
         if ((log2TrSize == 2) && !(chFmt == X265_CSP_I444))
         {
-            uint32_t partNum = cu->m_pic->getNumPartInCU() >> ((depth - 1) << 1);
+            uint32_t partNum = NUM_CU_PARTITIONS >> ((depth - 1) << 1);
             if ((absPartIdx & (partNum - 1)) == (partNum - 1))
             {
                 const uint32_t log2TrSizeC = 2;
                 const bool splitIntoSubTUs = (chFmt == X265_CSP_I422);
 
-                uint32_t curPartNum = cu->m_pic->getNumPartInCU() >> ((depth - 1) << 1);
+                uint32_t curPartNum = NUM_CU_PARTITIONS >> ((depth - 1) << 1);
 
                 for (uint32_t chromaId = TEXT_CHROMA_U; chromaId <= TEXT_CHROMA_V; chromaId++)
                 {
@@ -759,7 +758,7 @@
         {
             uint32_t log2TrSizeC = log2TrSize - hChromaShift;
             const bool splitIntoSubTUs = (chFmt == X265_CSP_I422);
-            uint32_t curPartNum = cu->m_pic->getNumPartInCU() >> (depth << 1);
+            uint32_t curPartNum = NUM_CU_PARTITIONS >> (depth << 1);
             for (uint32_t chromaId = TEXT_CHROMA_U; chromaId <= TEXT_CHROMA_V; chromaId++)
             {
                 TURecurse tuIterator(splitIntoSubTUs ? VERTICAL_SPLIT : DONT_SPLIT, curPartNum, absPartIdx);
@@ -791,7 +790,7 @@
 
             if ((chFmt == X265_CSP_I444) && (cu->getPartitionSize(absPartIdx) == SIZE_NxN))
             {
-                uint32_t partOffset = (cu->m_pic->getNumPartInCU() >> (cu->getDepth(absPartIdx) << 1)) >> 2;
+                uint32_t partOffset = (NUM_CU_PARTITIONS >> (cu->getDepth(absPartIdx) << 1)) >> 2;
                 codeIntraDirChroma(cu, absPartIdx + partOffset);
                 codeIntraDirChroma(cu, absPartIdx + partOffset * 2);
                 codeIntraDirChroma(cu, absPartIdx + partOffset * 3);
@@ -860,7 +859,7 @@
     uint32_t log2CUSize   = cu->getLog2CUSize(absPartIdx);
     uint32_t lumaOffset   = absPartIdx << (LOG2_UNIT_SIZE * 2);
     uint32_t chromaOffset = lumaOffset >> (cu->getHorzChromaShift() + cu->getVertChromaShift());
-    uint32_t absPartIdxStep = cu->m_pic->getNumPartInCU() >> (depth << 1);
+    uint32_t absPartIdxStep = NUM_CU_PARTITIONS >> (depth << 1);
     CoeffCodeState state;
     encodeTransform(cu, state, lumaOffset, chromaOffset, absPartIdx, absPartIdxStep, depth, log2CUSize, 0, bCodeDQP, depthRange);
 }
@@ -1291,7 +1290,7 @@
     int predIdx[4];
     PartSize mode = cu->getPartitionSize(absPartIdx);
     uint32_t partNum = isMultiple ? (mode == SIZE_NxN ? 4 : 1) : 1;
-    uint32_t partOffset = (cu->m_pic->getNumPartInCU() >> (cu->getDepth(absPartIdx) << 1)) >> 2;
+    uint32_t partOffset = (NUM_CU_PARTITIONS >> (cu->getDepth(absPartIdx) << 1)) >> 2;
 
     for (j = 0; j < partNum; j++)
     {
diff -r cb114b17a30e -r e26ef0404b00 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Thu Sep 25 13:52:58 2014 +0530
+++ b/source/encoder/frameencoder.cpp	Thu Sep 25 15:24:16 2014 +0530
@@ -419,7 +419,7 @@
 {
     Slice* slice = m_frame->m_picSym->m_slice;
     const uint32_t widthInLCUs = m_frame->getPicSym()->getFrameWidthInCU();
-    const uint32_t lastCUAddr = (slice->m_endCUAddr + m_frame->getNumPartInCU() - 1) / m_frame->getNumPartInCU();
+    const uint32_t lastCUAddr = (slice->m_endCUAddr + NUM_CU_PARTITIONS - 1) / NUM_CU_PARTITIONS;
     const int numSubstreams = m_param->bEnableWavefront ? m_frame->getPicSym()->getFrameHeightInCU() : 1;
 
     SAOParam *saoParam = slice->m_pic->getPicSym()->m_saoParam;
diff -r cb114b17a30e -r e26ef0404b00 source/encoder/sao.cpp
--- a/source/encoder/sao.cpp	Thu Sep 25 13:52:58 2014 +0530
+++ b/source/encoder/sao.cpp	Thu Sep 25 15:24:16 2014 +0530
@@ -2457,8 +2457,7 @@
     // go to sub-CU
     if (cu->getDepth(absZOrderIdx) > depth)
     {
-        Frame* pic = cu->m_pic;
-        uint32_t curNumParts = pic->getNumPartInCU() >> (depth << 1);
+        uint32_t curNumParts = NUM_CU_PARTITIONS >> (depth << 1);
         uint32_t qNumParts   = curNumParts >> 2;
         uint32_t xmax = cu->m_slice->m_sps->picWidthInLumaSamples  - cu->getCUPelX();
         uint32_t ymax = cu->m_slice->m_sps->picHeightInLumaSamples - cu->getCUPelY();
diff -r cb114b17a30e -r e26ef0404b00 source/encoder/search.cpp
--- a/source/encoder/search.cpp	Thu Sep 25 13:52:58 2014 +0530
+++ b/source/encoder/search.cpp	Thu Sep 25 15:24:16 2014 +0530
@@ -136,7 +136,7 @@
         width  >>= 1;
         height >>= 1;
 
-        uint32_t qtPartNum = cu->m_pic->getNumPartInCU() >> ((fullDepth + 1) << 1);
+        uint32_t qtPartNum = NUM_CU_PARTITIONS >> ((fullDepth + 1) << 1);
         for (uint32_t part = 0; part < 4; part++)
             xEncSubdivCbfQTChroma(cu, trDepth + 1, absPartIdx + part * qtPartNum, absPartIdxStep, width, height);
     }
@@ -152,7 +152,7 @@
 
     if (trMode > trDepth)
     {
-        uint32_t qtPartNum = cu->m_pic->getNumPartInCU() >> ((fullDepth + 1) << 1);
+        uint32_t qtPartNum = NUM_CU_PARTITIONS >> ((fullDepth + 1) << 1);
         for (uint32_t part = 0; part < 4; part++)
             xEncCoeffQTChroma(cu, trDepth + 1, absPartIdx + part * qtPartNum, ttype);
 
@@ -170,7 +170,7 @@
         X265_CHECK(trDepth > 0, "transform size too small\n");
         trDepthC--;
         log2TrSizeC++;
-        uint32_t qpdiv = cu->m_pic->getNumPartInCU() >> ((cu->getDepth(0) + trDepthC) << 1);
+        uint32_t qpdiv = NUM_CU_PARTITIONS >> ((cu->getDepth(0) + trDepthC) << 1);
         bool bFirstQ = ((absPartIdx & (qpdiv - 1)) == 0);
         if (!bFirstQ)
             return;
@@ -190,7 +190,7 @@
         uint32_t coeffOffset = absPartIdx << (LOG2_UNIT_SIZE * 2 - 1);
         coeff_t* coeff = m_qtTempCoeff[ttype][qtLayer] + coeffOffset;
         uint32_t subTUSize = 1 << (log2TrSizeC * 2);
-        uint32_t partIdxesPerSubTU  = cu->m_pic->getNumPartInCU() >> (((cu->getDepth(absPartIdx) + trDepthC) << 1) + 1);
+        uint32_t partIdxesPerSubTU  = NUM_CU_PARTITIONS >> (((cu->getDepth(absPartIdx) + trDepthC) << 1) + 1);
         if (cu->getCbf(absPartIdx, ttype, trDepth + 1))
             m_entropyCoder->codeCoeffNxN(cu, coeff, absPartIdx, log2TrSizeC, ttype);
         if (cu->getCbf(absPartIdx + partIdxesPerSubTU, ttype, trDepth + 1))
@@ -591,7 +591,7 @@
         uint64_t splitCost     = 0;
         uint32_t splitDistY    = 0;
         uint32_t splitPsyEnergyY = 0;
-        uint32_t qPartsDiv     = cu->m_pic->getNumPartInCU() >> ((fullDepth + 1) << 1);
+        uint32_t qPartsDiv     = NUM_CU_PARTITIONS >> ((fullDepth + 1) << 1);
         uint32_t absPartIdxSub = absPartIdx;
         uint32_t splitCbfY     = 0;
         uint32_t splitBits     = 0;
@@ -735,7 +735,7 @@
     {
         // code splitted block
 
-        uint32_t qPartsDiv     = cu->m_pic->getNumPartInCU() >> ((fullDepth + 1) << 1);
+        uint32_t qPartsDiv     = NUM_CU_PARTITIONS >> ((fullDepth + 1) << 1);
         uint32_t absPartIdxSub = absPartIdx;
         uint32_t splitCbfY     = 0;
 
@@ -771,7 +771,7 @@
     }
     else
     {
-        uint32_t numQPart = cu->m_pic->getNumPartInCU() >> ((fullDepth + 1) << 1);
+        uint32_t numQPart = NUM_CU_PARTITIONS >> ((fullDepth + 1) << 1);
         for (uint32_t part = 0; part < 4; part++)
             xSetIntraResultQT(cu, trDepth + 1, absPartIdx + part * numQPart, reconYuv);
     }
@@ -813,7 +813,7 @@
         trDepthC--;
     }
 
-    uint32_t partIdxesPerSubTU = (cu->m_pic->getNumPartInCU() >> ((depth + trDepthC) << 1)) >> 1;
+    uint32_t partIdxesPerSubTU = (NUM_CU_PARTITIONS >> ((depth + trDepthC) << 1)) >> 1;
 
     // move the CBFs down a level and set the parent CBF
     uint8_t subTUCBF[2];
@@ -857,7 +857,7 @@
             X265_CHECK(trDepth > 0, "invalid trDepth\n");
             trDepthC--;
             log2TrSizeC++;
-            uint32_t qpdiv = cu->m_pic->getNumPartInCU() >> ((cu->getDepth(0) + trDepthC) << 1);
+            uint32_t qpdiv = NUM_CU_PARTITIONS >> ((cu->getDepth(0) + trDepthC) << 1);
             bool bFirstQ = ((absPartIdx & (qpdiv - 1)) == 0);
             if (!bFirstQ)
                 return outDist;
@@ -887,7 +887,7 @@
         uint32_t singlePsyEnergy = 0;
         for (uint32_t chromaId = TEXT_CHROMA_U; chromaId <= TEXT_CHROMA_V; chromaId++)
         {
-            uint32_t curPartNum = cu->m_pic->getNumPartInCU() >> ((cu->getDepth(0) + trDepthC) << 1);
+            uint32_t curPartNum = NUM_CU_PARTITIONS >> ((cu->getDepth(0) + trDepthC) << 1);
             TURecurse tuIterator(splitIntoSubTUs ? VERTICAL_SPLIT : DONT_SPLIT, curPartNum, absPartIdx);
 
             do
@@ -1020,7 +1020,7 @@
         uint32_t splitCbfU     = 0;
         uint32_t splitCbfV     = 0;
         uint32_t splitPsyEnergy = 0;
-        uint32_t qPartsDiv     = cu->m_pic->getNumPartInCU() >> ((fullDepth + 1) << 1);
+        uint32_t qPartsDiv     = NUM_CU_PARTITIONS >> ((fullDepth + 1) << 1);
         uint32_t absPartIdxSub = absPartIdx;
         for (uint32_t part = 0; part < 4; part++, absPartIdxSub += qPartsDiv)
         {
@@ -1059,7 +1059,7 @@
             X265_CHECK(trDepth > 0, "invalid trDepth\n");
             trDepth--;
             log2TrSizeC++;
-            uint32_t qpdiv = cu->m_pic->getNumPartInCU() >> ((cu->getDepth(0) + trDepth) << 1);
+            uint32_t qpdiv = NUM_CU_PARTITIONS >> ((cu->getDepth(0) + trDepth) << 1);
             if (absPartIdx & (qpdiv - 1))
                 return;
         }
@@ -1082,7 +1082,7 @@
     }
     else
     {
-        uint32_t numQPart = cu->m_pic->getNumPartInCU() >> ((fullDepth + 1) << 1);
+        uint32_t numQPart = NUM_CU_PARTITIONS >> ((fullDepth + 1) << 1);
         for (uint32_t part = 0; part < 4; part++)
             xSetIntraResultChromaQT(cu, trDepth + 1, absPartIdx + part * numQPart, reconYuv);
     }
@@ -1106,7 +1106,7 @@
             X265_CHECK(trDepth > 0, "invalid trDepth\n");
             trDepthC--;
             log2TrSizeC++;
-            uint32_t qpdiv = cu->m_pic->getNumPartInCU() >> ((cu->getDepth(0) + trDepthC) << 1);
+            uint32_t qpdiv = NUM_CU_PARTITIONS >> ((cu->getDepth(0) + trDepthC) << 1);
             bool bFirstQ = ((absPartIdx & (qpdiv - 1)) == 0);
             if (!bFirstQ)
                 return;
@@ -1119,7 +1119,7 @@
 
         for (uint32_t chromaId = TEXT_CHROMA_U; chromaId <= TEXT_CHROMA_V; chromaId++)
         {
-            uint32_t curPartNum = cu->m_pic->getNumPartInCU() >> ((cu->getDepth(0) + trDepthC) << 1);
+            uint32_t curPartNum = NUM_CU_PARTITIONS >> ((cu->getDepth(0) + trDepthC) << 1);
             TURecurse tuIterator(splitIntoSubTUs ? VERTICAL_SPLIT : DONT_SPLIT, curPartNum, absPartIdx);
 
             do
@@ -1191,7 +1191,7 @@
     {
         uint32_t splitCbfU     = 0;
         uint32_t splitCbfV     = 0;
-        uint32_t qPartsDiv     = cu->m_pic->getNumPartInCU() >> ((fullDepth + 1) << 1);
+        uint32_t qPartsDiv     = NUM_CU_PARTITIONS >> ((fullDepth + 1) << 1);
         uint32_t absPartIdxSub = absPartIdx;
         for (uint32_t part = 0; part < 4; part++, absPartIdxSub += qPartsDiv)
         {
@@ -1500,7 +1500,7 @@
     uint32_t depth       = cu->getDepth(0);
     uint32_t initTrDepth = (cu->getPartitionSize(0) != SIZE_2Nx2N) && (cu->getChromaFormat() == X265_CSP_I444 ? 1 : 0);
     uint32_t log2TrSize  = cu->getLog2CUSize(0) - initTrDepth;
-    uint32_t absPartIdx  = (cu->m_pic->getNumPartInCU() >> (depth << 1));
+    uint32_t absPartIdx  = (NUM_CU_PARTITIONS >> (depth << 1));
 
     int part = partitionFromLog2Size(log2TrSize);
 
@@ -2162,7 +2162,7 @@
             distortion = zeroDistortion;
             cu->m_psyEnergy = zeroPsyEnergyY;
 
-            const uint32_t qpartnum = cu->m_pic->getNumPartInCU() >> (depth << 1);
+            const uint32_t qpartnum = NUM_CU_PARTITIONS >> (depth << 1);
             ::memset(cu->getTransformIdx(), 0, qpartnum * sizeof(uint8_t));
             ::memset(cu->getCbf(TEXT_LUMA), 0, qpartnum * sizeof(uint8_t));
             ::memset(cu->getCbf(TEXT_CHROMA_U), 0, qpartnum * sizeof(uint8_t));
@@ -2299,12 +2299,12 @@
         {
             log2TrSizeC++;
             trModeC--;
-            uint32_t qpdiv = cu->m_pic->getNumPartInCU() >> ((depth - 1) << 1);
+            uint32_t qpdiv = NUM_CU_PARTITIONS >> ((depth - 1) << 1);
             bCodeChroma = ((absPartIdx & (qpdiv - 1)) == 0);
         }
 
         const bool splitIntoSubTUs = (m_csp == X265_CSP_I422);
-        uint32_t absPartIdxStep = cu->m_pic->getNumPartInCU() >> ((cu->getDepth(0) +  trModeC) << 1);
+        uint32_t absPartIdxStep = NUM_CU_PARTITIONS >> ((cu->getDepth(0) +  trModeC) << 1);
 
         uint32_t coeffOffsetY = absPartIdx << (LOG2_UNIT_SIZE * 2);
         uint32_t coeffOffsetC = coeffOffsetY >> (hChromaShift + vChromaShift);
@@ -2379,7 +2379,7 @@
     // code sub-blocks
     if (bCheckSplit && !bCheckFull)
     {
-        const uint32_t qPartNumSubdiv = cu->m_pic->getNumPartInCU() >> ((depth + 1) << 1);
+        const uint32_t qPartNumSubdiv = NUM_CU_PARTITIONS >> ((depth + 1) << 1);
         for (uint32_t i = 0; i < 4; ++i)
         {
             residualTransformQuantInter(cu, absPartIdx + i * qPartNumSubdiv, fencYuv, resiYuv, depth + 1, depthRange, cuData);
@@ -2433,7 +2433,7 @@
     {
         log2TrSizeC++;
         trModeC--;
-        uint32_t qpdiv = cu->m_pic->getNumPartInCU() >> ((depth - 1) << 1);
+        uint32_t qpdiv = NUM_CU_PARTITIONS >> ((depth - 1) << 1);
         bCodeChroma = ((absPartIdx & (qpdiv - 1)) == 0);
     }
 
@@ -2455,7 +2455,7 @@
 
     uint32_t trSize = 1 << log2TrSize;
     const bool splitIntoSubTUs = (m_csp == X265_CSP_I422);
-    uint32_t absPartIdxStep = cu->m_pic->getNumPartInCU() >> ((cu->getDepth(0) +  trModeC) << 1);
+    uint32_t absPartIdxStep = NUM_CU_PARTITIONS >> ((cu->getDepth(0) +  trModeC) << 1);
 
     // code full block
     if (bCheckFull)
@@ -3127,7 +3127,7 @@
             }
         }
 
-        const uint32_t qPartNumSubdiv = cu->m_pic->getNumPartInCU() >> ((depth + 1) << 1);
+        const uint32_t qPartNumSubdiv = NUM_CU_PARTITIONS >> ((depth + 1) << 1);
         for (uint32_t i = 0; i < 4; ++i)
         {
             cu->m_psyEnergy = 0;
@@ -3264,7 +3264,7 @@
         const bool bFirstCbfOfCU = curTrMode == 0;
         if (bFirstCbfOfCU || mCodeAll)
         {
-            uint32_t absPartIdxStep = cu->m_pic->getNumPartInCU() >> ((cu->getDepth(0) +  curTrMode) << 1);
+            uint32_t absPartIdxStep = NUM_CU_PARTITIONS >> ((cu->getDepth(0) +  curTrMode) << 1);
             if (bFirstCbfOfCU || cu->getCbf(absPartIdx, TEXT_CHROMA_U, curTrMode - 1))
                 m_entropyCoder->codeQtCbf(cu, absPartIdx, absPartIdxStep, trWidthC, trHeightC, TEXT_CHROMA_U, curTrMode, !bSubdiv);
             if (bFirstCbfOfCU || cu->getCbf(absPartIdx, TEXT_CHROMA_V, curTrMode - 1))
@@ -3291,7 +3291,7 @@
         {
             log2TrSizeC++;
             trModeC--;
-            uint32_t qpdiv = cu->m_pic->getNumPartInCU() >> ((depth - 1) << 1);
+            uint32_t qpdiv = NUM_CU_PARTITIONS >> ((depth - 1) << 1);
             bCodeChroma = ((absPartIdx & (qpdiv - 1)) == 0);
         }
 
@@ -3317,7 +3317,7 @@
                 }
                 else
                 {
-                    uint32_t partIdxesPerSubTU  = cu->m_pic->getNumPartInCU() >> (((cu->getDepth(absPartIdx) + trModeC) << 1) + 1);
+                    uint32_t partIdxesPerSubTU  = NUM_CU_PARTITIONS >> (((cu->getDepth(absPartIdx) + trModeC) << 1) + 1);
                     uint32_t subTUSize = 1 << (log2TrSizeC * 2);
                     if (ttype == TEXT_CHROMA_U && cu->getCbf(absPartIdx, TEXT_CHROMA_U, trMode))
                     {
@@ -3341,7 +3341,7 @@
     {
         if (bSubdivAndCbf || cu->getCbf(absPartIdx, ttype, curTrMode))
         {
-            const uint32_t qpartNumSubdiv = cu->m_pic->getNumPartInCU() >> ((depth + 1) << 1);
+            const uint32_t qpartNumSubdiv = NUM_CU_PARTITIONS >> ((depth + 1) << 1);
             for (uint32_t i = 0; i < 4; ++i)
                 xEncodeResidualQT(cu, absPartIdx + i * qpartNumSubdiv, depth + 1, bSubdivAndCbf, ttype, depthRange);
         }
@@ -3369,7 +3369,7 @@
         {
             log2TrSizeC++;
             trModeC--;
-            uint32_t qpdiv = cu->m_pic->getNumPartInCU() >> ((cu->getDepth(0) + trModeC) << 1);
+            uint32_t qpdiv = NUM_CU_PARTITIONS >> ((cu->getDepth(0) + trModeC) << 1);
             bCodeChroma = ((absPartIdx & (qpdiv - 1)) == 0);
         }
 
@@ -3402,7 +3402,7 @@
     }
     else
     {
-        const uint32_t qPartNumSubdiv = cu->m_pic->getNumPartInCU() >> ((depth + 1) << 1);
+        const uint32_t qPartNumSubdiv =  NUM_CU_PARTITIONS >> ((depth + 1) << 1);
         for (uint32_t i = 0; i < 4; ++i)
             xSetResidualQTData(cu, absPartIdx + i * qPartNumSubdiv, resiYuv, depth + 1, bSpatial);
     }


More information about the x265-devel mailing list