[x265] [PATCH] analysis: removed switch-case to read the best ref index

ashok at multicorewareinc.com ashok at multicorewareinc.com
Mon May 25 17:03:50 CEST 2015


# HG changeset patch
# User Ashok Kumar Mishra<ashok at multicorewareinc.com>
# Date 1432566054 -19800
#      Mon May 25 20:30:54 2015 +0530
# Node ID 44f4024a71b921acc99d21a4e342ebe791d8128b
# Parent  1335a2788c60d97c68d25250f847fe6a76fb0de6
analysis: removed switch-case to read the best ref index

diff -r 1335a2788c60 -r 44f4024a71b9 source/common/cudata.h
--- a/source/common/cudata.h	Mon May 25 20:30:54 2015 +0530
+++ b/source/common/cudata.h	Mon May 25 20:30:54 2015 +0530
@@ -222,6 +222,8 @@
     void     getNeighbourMV(uint32_t puIdx, uint32_t absPartIdx, InterNeighbourMV* neighbours) const;
     void     getIntraTUQtDepthRange(uint32_t tuDepthRange[2], uint32_t absPartIdx) const;
     void     getInterTUQtDepthRange(uint32_t tuDepthRange[2], uint32_t absPartIdx) const;
+    uint32_t getBestRefIdx(uint32_t subPartIdx) const { return ((m_interDir[subPartIdx] & 1) << m_refIdx[0][subPartIdx]) |
+                                                              (((m_interDir[subPartIdx] >> 1) & 1) << (m_refIdx[1][subPartIdx] + 16)); }
 
     uint32_t getNumPartInter() const              { return nbPartsTable[(int)m_partSize[0]]; }
     bool     isIntra(uint32_t absPartIdx) const   { return m_predMode[absPartIdx] == MODE_INTRA; }
diff -r 1335a2788c60 -r 44f4024a71b9 source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp	Mon May 25 20:30:54 2015 +0530
+++ b/source/encoder/analysis.cpp	Mon May 25 20:30:54 2015 +0530
@@ -853,20 +853,7 @@
             if (m_param->limitReferences & X265_REF_LIMIT_CU)
             {
                 CUData& cu = md.pred[PRED_2Nx2N].cu;
-                int refMask;
-                switch (cu.m_interDir[0])
-                {
-                case 1:
-                    refMask = 1 << cu.m_refIdx[0][0];
-                    break;
-                case 2:
-                    refMask = 1 << (cu.m_refIdx[1][0] + 16);
-                    break;
-                case 3:
-                    refMask = 1 << cu.m_refIdx[0][0];
-                    refMask |= 1 << (cu.m_refIdx[1][0] + 16);
-                    break;
-                }
+                uint32_t refMask = cu.getBestRefIdx(0);
                 allSplitRefs = splitRefs[0] = splitRefs[1] = splitRefs[2] = splitRefs[3] = refMask;
             }
 
@@ -1101,22 +1088,7 @@
         uint32_t puOffset = (g_puOffset[uint32_t(partSize)] << (g_unitSizeDepth - cu.m_cuDepth[0]) * 2) >> 4;
         refMask = 0;
         for (uint32_t puIdx = 0, subPartIdx = 0; puIdx < numPU; puIdx++, subPartIdx += puOffset)
-        {
-            uint32_t interDir = cu.m_interDir[subPartIdx];
-            switch (interDir)
-            {
-            case 1:
-                refMask |= 1 << cu.m_refIdx[0][subPartIdx];
-                break;
-            case 2:
-                refMask |= 1 << (cu.m_refIdx[1][subPartIdx] + 16);
-                break;
-            case 3:
-                refMask |= 1 << cu.m_refIdx[0][subPartIdx];
-                refMask |= 1 << (cu.m_refIdx[1][subPartIdx] + 16);
-                break;
-            }
-        }
+            refMask |= cu.getBestRefIdx(subPartIdx);
     }
     
     if (mightNotSplit)
@@ -1254,20 +1226,7 @@
             if (m_param->limitReferences & X265_REF_LIMIT_CU)
             {
                 CUData& cu = md.pred[PRED_2Nx2N].cu;
-                int refMask;
-                switch (cu.m_interDir[0])
-                {
-                case 1:
-                    refMask = 1 << cu.m_refIdx[0][0];
-                    break;
-                case 2:
-                    refMask = 1 << (cu.m_refIdx[1][0] + 16);
-                    break;
-                case 3:
-                    refMask = 1 << cu.m_refIdx[0][0];
-                    refMask |= 1 << (cu.m_refIdx[1][0] + 16);
-                    break;
-                }
+                uint32_t refMask = cu.getBestRefIdx(0);
                 allSplitRefs = splitRefs[0] = splitRefs[1] = splitRefs[2] = splitRefs[3] = refMask;
             }
 
@@ -1390,22 +1349,7 @@
         uint32_t puOffset = (g_puOffset[uint32_t(partSize)] << (g_unitSizeDepth - cu.m_cuDepth[0]) * 2) >> 4;
         refMask = 0;
         for (uint32_t puIdx = 0, subPartIdx = 0; puIdx < numPU; puIdx++, subPartIdx += puOffset)
-        {
-            uint32_t interDir = cu.m_interDir[subPartIdx];
-            switch (interDir)
-            {
-            case 1:
-                refMask |= 1 << cu.m_refIdx[0][subPartIdx];
-                break;
-            case 2:
-                refMask |= 1 << (cu.m_refIdx[1][subPartIdx] + 16);
-                break;
-            case 3:
-                refMask |= 1 << cu.m_refIdx[0][subPartIdx];
-                refMask |= 1 << (cu.m_refIdx[1][subPartIdx] + 16);
-                break;
-            }
-        }
+            refMask |= cu.getBestRefIdx(subPartIdx);
     }
 
     /* Copy best data to encData CTU and recon */


More information about the x265-devel mailing list