[x265] [PATCH] entropy: removed g_puOffset table

ashok at multicorewareinc.com ashok at multicorewareinc.com
Tue Jun 23 17:18:39 CEST 2015


# HG changeset patch
# User Ashok Kumar Mishra<ashok at multicorewareinc.com>
# Date 1435071938 -19800
#      Tue Jun 23 20:35:38 2015 +0530
# Node ID 34a1674bd5ba9896904288f9b6452bae38153210
# Parent  cc243b161a2c2868be52e7d2077a77de5d1ef351
entropy: removed g_puOffset table

diff -r cc243b161a2c -r 34a1674bd5ba source/common/cudata.h
--- a/source/common/cudata.h	Tue Jun 23 20:35:34 2015 +0530
+++ b/source/common/cudata.h	Tue Jun 23 20:35:38 2015 +0530
@@ -258,7 +258,7 @@
                                                               (((m_interDir[subPartIdx] >> 1) & 1) << (m_refIdx[1][subPartIdx] + 16)); }
     uint32_t getPUOffset(uint32_t puIdx, uint32_t absPartIdx) const { return (partAddrTable[(int)m_partSize[absPartIdx]][puIdx] << (g_unitSizeDepth - m_cuDepth[absPartIdx]) * 2) >> 4; }
 
-    uint32_t getNumPartInter() const              { return nbPartsTable[(int)m_partSize[0]]; }
+    uint32_t getNumPartInter(uint32_t absPartIdx) const              { return nbPartsTable[(int)m_partSize[absPartIdx]]; }
     bool     isIntra(uint32_t absPartIdx) const   { return m_predMode[absPartIdx] == MODE_INTRA; }
     bool     isInter(uint32_t absPartIdx) const   { return !!(m_predMode[absPartIdx] & MODE_INTER); }
     bool     isSkipped(uint32_t absPartIdx) const { return m_predMode[absPartIdx] == MODE_SKIP; }
diff -r cc243b161a2c -r 34a1674bd5ba source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp	Tue Jun 23 20:35:34 2015 +0530
+++ b/source/encoder/analysis.cpp	Tue Jun 23 20:35:38 2015 +0530
@@ -583,7 +583,8 @@
                 /* RD selection between merge, inter, bidir and intra */
                 if (!m_bChromaSa8d) /* When m_bChromaSa8d is enabled, chroma MC has already been done */
                 {
-                    for (uint32_t puIdx = 0; puIdx < bestInter->cu.getNumPartInter(); puIdx++)
+                    uint32_t numPU = bestInter->cu.getNumPartInter(0);
+                    for (uint32_t puIdx = 0; puIdx < numPU; puIdx++)
                     {
                         PredictionUnit pu(bestInter->cu, cuGeom, puIdx);
                         motionCompensation(bestInter->cu, pu, bestInter->predYuv, false, true);
@@ -619,7 +620,8 @@
                 else if (!md.bestMode->cu.m_mergeFlag[0])
                 {
                     /* finally code the best mode selected from SA8D costs */
-                    for (uint32_t puIdx = 0; puIdx < md.bestMode->cu.getNumPartInter(); puIdx++)
+                    uint32_t numPU = md.bestMode->cu.getNumPartInter(0);
+                    for (uint32_t puIdx = 0; puIdx < numPU; puIdx++)
                     {
                         PredictionUnit pu(md.bestMode->cu, cuGeom, puIdx);
                         motionCompensation(md.bestMode->cu, pu, md.bestMode->predYuv, false, true);
@@ -934,7 +936,8 @@
                 /* Calculate RD cost of best inter option */
                 if (!m_bChromaSa8d) /* When m_bChromaSa8d is enabled, chroma MC has already been done */
                 {
-                    for (uint32_t puIdx = 0; puIdx < bestInter->cu.getNumPartInter(); puIdx++)
+                    uint32_t numPU = bestInter->cu.getNumPartInter(0);
+                    for (uint32_t puIdx = 0; puIdx < numPU; puIdx++)
                     {
                         PredictionUnit pu(bestInter->cu, cuGeom, puIdx);
                         motionCompensation(bestInter->cu, pu, bestInter->predYuv, false, true);
@@ -1005,7 +1008,8 @@
                 }
                 else if (md.bestMode->cu.isInter(0))
                 {
-                    for (uint32_t puIdx = 0; puIdx < md.bestMode->cu.getNumPartInter(); puIdx++)
+                    uint32_t numPU = md.bestMode->cu.getNumPartInter(0);
+                    for (uint32_t puIdx = 0; puIdx < numPU; puIdx++)
                     {
                         PredictionUnit pu(md.bestMode->cu, cuGeom, puIdx);
                         motionCompensation(md.bestMode->cu, pu, md.bestMode->predYuv, false, true);
@@ -1083,7 +1087,7 @@
     {
         /* use best merge/inter mode, in case of intra use 2Nx2N inter references */
         CUData& cu = md.bestMode->cu.isIntra(0) ? md.pred[PRED_2Nx2N].cu : md.bestMode->cu;
-        uint32_t numPU = cu.getNumPartInter();
+        uint32_t numPU = cu.getNumPartInter(0);
         refMask = 0;
         for (uint32_t puIdx = 0, subPartIdx = 0; puIdx < numPU; puIdx++, subPartIdx += cu.getPUOffset(puIdx, 0))
             refMask |= cu.getBestRefIdx(subPartIdx);
@@ -1355,7 +1359,7 @@
     {
         /* use best merge/inter mode, in case of intra use 2Nx2N inter references */
         CUData& cu = md.bestMode->cu.isIntra(0) ? md.pred[PRED_2Nx2N].cu : md.bestMode->cu;
-        uint32_t numPU = cu.getNumPartInter();
+        uint32_t numPU = cu.getNumPartInter(0);
         refMask = 0;
         for (uint32_t puIdx = 0, subPartIdx = 0; puIdx < numPU; puIdx++, subPartIdx += cu.getPUOffset(puIdx, 0))
             refMask |= cu.getBestRefIdx(subPartIdx);
@@ -1618,7 +1622,8 @@
 
     if (m_param->analysisMode == X265_ANALYSIS_LOAD && m_reuseInterDataCTU)
     {
-        for (uint32_t part = 0; part < interMode.cu.getNumPartInter(); part++)
+        uint32_t numPU = interMode.cu.getNumPartInter(0);
+        for (uint32_t part = 0; part < numPU; part++)
         {
             MotionData* bestME = interMode.bestME[part];
             for (int32_t i = 0; i < numPredDir; i++)
@@ -1645,7 +1650,8 @@
 
     if (m_param->analysisMode == X265_ANALYSIS_SAVE && m_reuseInterDataCTU)
     {
-        for (uint32_t puIdx = 0; puIdx < interMode.cu.getNumPartInter(); puIdx++)
+        uint32_t numPU = interMode.cu.getNumPartInter(0);
+        for (uint32_t puIdx = 0; puIdx < numPU; puIdx++)
         {
             MotionData* bestME = interMode.bestME[puIdx];
             for (int32_t i = 0; i < numPredDir; i++)
@@ -1666,7 +1672,8 @@
 
     if (m_param->analysisMode == X265_ANALYSIS_LOAD && m_reuseInterDataCTU)
     {
-        for (uint32_t puIdx = 0; puIdx < interMode.cu.getNumPartInter(); puIdx++)
+        uint32_t numPU = interMode.cu.getNumPartInter(0);
+        for (uint32_t puIdx = 0; puIdx < numPU; puIdx++)
         {
             MotionData* bestME = interMode.bestME[puIdx];
             for (int32_t i = 0; i < numPredDir; i++)
@@ -1684,7 +1691,8 @@
 
     if (m_param->analysisMode == X265_ANALYSIS_SAVE && m_reuseInterDataCTU)
     {
-        for (uint32_t puIdx = 0; puIdx < interMode.cu.getNumPartInter(); puIdx++)
+        uint32_t numPU = interMode.cu.getNumPartInter(0);
+        for (uint32_t puIdx = 0; puIdx < numPU; puIdx++)
         {
             MotionData* bestME = interMode.bestME[puIdx];
             for (int32_t i = 0; i < numPredDir; i++)
diff -r cc243b161a2c -r 34a1674bd5ba source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp	Tue Jun 23 20:35:34 2015 +0530
+++ b/source/encoder/entropy.cpp	Tue Jun 23 20:35:38 2015 +0530
@@ -860,12 +860,9 @@
 void Entropy::codePUWise(const CUData& cu, uint32_t absPartIdx)
 {
     X265_CHECK(!cu.isIntra(absPartIdx), "intra block not expected\n");
-    PartSize partSize = (PartSize)cu.m_partSize[absPartIdx];
-    uint32_t numPU = (partSize == SIZE_2Nx2N ? 1 : (partSize == SIZE_NxN ? 4 : 2));
-    uint32_t depth = cu.m_cuDepth[absPartIdx];
-    uint32_t puOffset = (g_puOffset[uint32_t(partSize)] << (g_unitSizeDepth - depth) * 2) >> 4;
+    uint32_t numPU = cu.getNumPartInter(absPartIdx);
 
-    for (uint32_t puIdx = 0, subPartIdx = absPartIdx; puIdx < numPU; puIdx++, subPartIdx += puOffset)
+    for (uint32_t puIdx = 0, subPartIdx = absPartIdx; puIdx < numPU; puIdx++, subPartIdx += cu.getPUOffset(puIdx, absPartIdx))
     {
         codeMergeFlag(cu, subPartIdx);
         if (cu.m_mergeFlag[subPartIdx])
diff -r cc243b161a2c -r 34a1674bd5ba source/encoder/entropy.h
--- a/source/encoder/entropy.h	Tue Jun 23 20:35:34 2015 +0530
+++ b/source/encoder/entropy.h	Tue Jun 23 20:35:38 2015 +0530
@@ -38,8 +38,6 @@
 struct EstBitsSbac;
 class ScalingList;
 
-static const uint32_t g_puOffset[8] = { 0, 8, 4, 4, 2, 10, 1, 5 };
-
 enum SplitType
 {
     DONT_SPLIT            = 0,
diff -r cc243b161a2c -r 34a1674bd5ba source/encoder/search.cpp
--- a/source/encoder/search.cpp	Tue Jun 23 20:35:34 2015 +0530
+++ b/source/encoder/search.cpp	Tue Jun 23 20:35:38 2015 +0530
@@ -2022,7 +2022,7 @@
     MV mvc[(MD_ABOVE_LEFT + 1) * 2 + 2];
 
     const Slice *slice = m_slice;
-    int numPart     = cu.getNumPartInter();
+    int numPart     = cu.getNumPartInter(0);
     int numPredDir  = slice->isInterP() ? 1 : 2;
     const int* numRefIdx = slice->m_numRefIdx;
     uint32_t lastMode = 0;


More information about the x265-devel mailing list