[x265] cleanup MPM related

Satoshi Nakagawa nakagawa424 at oki.com
Sun Feb 9 08:58:41 CET 2014


# HG changeset patch
# User Satoshi Nakagawa <nakagawa424 at oki.com>
# Date 1391932597 -32400
#      Sun Feb 09 16:56:37 2014 +0900
# Node ID ccca4e4fcbcc3ac929810d197cf3fda0c0a43efb
# Parent  fa9f7b56d4d870f5ebef47bb1007995c2d71ce1a
cleanup MPM related

diff -r fa9f7b56d4d8 -r ccca4e4fcbcc source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Fri Feb 07 21:37:17 2014 +0530
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Sun Feb 09 16:56:37 2014 +0900
@@ -1162,7 +1162,7 @@
 *\param   piMode          it is set with MPM mode in case both MPM are equal. It is used to restrict RD search at encode side.
 *\returns Number of MPM
 */
-void TComDataCU::getIntraDirLumaPredictor(uint32_t absPartIdx, int32_t* intraDirPred, int32_t* modes)
+int TComDataCU::getIntraDirLumaPredictor(uint32_t absPartIdx, int32_t* intraDirPred)
 {
     TComDataCU* tempCU;
     uint32_t        tempPartIdx;
@@ -1171,25 +1171,20 @@
     // Get intra direction of left PU
     tempCU = getPULeft(tempPartIdx, m_absIdxInLCU + absPartIdx);
 
-    leftIntraDir  = tempCU ? (tempCU->isIntra(tempPartIdx) ? tempCU->getLumaIntraDir(tempPartIdx) : DC_IDX) : DC_IDX;
+    leftIntraDir  = (tempCU && tempCU->isIntra(tempPartIdx)) ? tempCU->getLumaIntraDir(tempPartIdx) : DC_IDX;
 
     // Get intra direction of above PU
     tempCU = getPUAbove(tempPartIdx, m_absIdxInLCU + absPartIdx, true, true);
 
-    aboveIntraDir = tempCU ? (tempCU->isIntra(tempPartIdx) ? tempCU->getLumaIntraDir(tempPartIdx) : DC_IDX) : DC_IDX;
+    aboveIntraDir = (tempCU && tempCU->isIntra(tempPartIdx)) ? tempCU->getLumaIntraDir(tempPartIdx) : DC_IDX;
 
     if (leftIntraDir == aboveIntraDir)
     {
-        if (modes)
-        {
-            *modes = 1;
-        }
-
-        if (leftIntraDir > 1) // angular modes
+        if (leftIntraDir >= 2) // angular modes
         {
             intraDirPred[0] = leftIntraDir;
-            intraDirPred[1] = ((leftIntraDir + 29) % 32) + 2;
-            intraDirPred[2] = ((leftIntraDir - 1) % 32) + 2;
+            intraDirPred[1] = ((leftIntraDir - 2 + 31) & 31) + 2;
+            intraDirPred[2] = ((leftIntraDir - 2 +  1) & 31) + 2;
         }
         else //non-angular
         {
@@ -1197,13 +1192,10 @@
             intraDirPred[1] = DC_IDX;
             intraDirPred[2] = VER_IDX;
         }
+        return 1;
     }
     else
     {
-        if (modes)
-        {
-            *modes = 2;
-        }
         intraDirPred[0] = leftIntraDir;
         intraDirPred[1] = aboveIntraDir;
 
@@ -1215,6 +1207,7 @@
         {
             intraDirPred[2] =  (leftIntraDir + aboveIntraDir) < 2 ? VER_IDX : DC_IDX;
         }
+        return 2;
     }
 }
 
diff -r fa9f7b56d4d8 -r ccca4e4fcbcc source/Lib/TLibCommon/TComDataCU.h
--- a/source/Lib/TLibCommon/TComDataCU.h	Fri Feb 07 21:37:17 2014 +0530
+++ b/source/Lib/TLibCommon/TComDataCU.h	Sun Feb 09 16:56:37 2014 +0900
@@ -455,7 +455,7 @@
     uint32_t      getIntraSizeIdx(uint32_t absPartIdx);
 
     void          getAllowedChromaDir(uint32_t absPartIdx, uint32_t* modeList);
-    void          getIntraDirLumaPredictor(uint32_t absPartIdx, int32_t* intraDirPred, int32_t* mode = NULL);
+    int           getIntraDirLumaPredictor(uint32_t absPartIdx, int32_t* intraDirPred);
 
     // -------------------------------------------------------------------------------------------------------------------
     // member functions for SBAC context
diff -r fa9f7b56d4d8 -r ccca4e4fcbcc source/Lib/TLibEncoder/TEncSbac.cpp
--- a/source/Lib/TLibEncoder/TEncSbac.cpp	Fri Feb 07 21:37:17 2014 +0530
+++ b/source/Lib/TLibEncoder/TEncSbac.cpp	Sun Feb 09 16:56:37 2014 +0900
@@ -1686,8 +1686,8 @@
 void TEncSbac::codeIntraDirLumaAng(TComDataCU* cu, uint32_t absPartIdx, bool isMultiple)
 {
     uint32_t dir[4], j;
-    int preds[4][3] = { { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 } };
-    int predIdx[4] = { -1, -1, -1, -1 };
+    int preds[4][3];
+    int predIdx[4];
     PartSize mode = cu->getPartitionSize(absPartIdx);
     uint32_t partNum = isMultiple ? (mode == SIZE_NxN ? 4 : 1) : 1;
     uint32_t partOffset = (cu->getPic()->getNumPartInCU() >> (cu->getDepth(absPartIdx) << 1)) >> 2;
@@ -1696,6 +1696,7 @@
     {
         dir[j] = cu->getLumaIntraDir(absPartIdx + partOffset * j);
         cu->getIntraDirLumaPredictor(absPartIdx + partOffset * j, preds[j]);
+        predIdx[j] = -1;
         for (uint32_t i = 0; i < 3; i++)
         {
             if (dir[j] == preds[j][i])
diff -r fa9f7b56d4d8 -r ccca4e4fcbcc source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp	Fri Feb 07 21:37:17 2014 +0530
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Sun Feb 09 16:56:37 2014 +0900
@@ -1800,7 +1800,7 @@
         cu->getPattern()->initAdiPattern(cu, partOffset, initTrDepth, m_predBuf, m_predBufStride, m_predBufHeight, refAbove, refLeft, refAboveFlt, refLeftFlt);
 
         //===== determine set of modes to be tested (using prediction signal only) =====
-        int numModesAvailable = 35; //total number of Intra modes
+        const int numModesAvailable = 35; //total number of Intra modes
         Pel* fenc   = fencYuv->getLumaAddr(pu, width);
         uint32_t stride = predYuv->getStride();
         uint32_t rdModeList[FAST_UDI_MAX_RDMODE_NUM];
@@ -1901,14 +1901,8 @@
                 candNum += xUpdateCandList(mode, cost, numModesForFullRD, rdModeList, candCostList);
             }
 
-            int preds[3] = { -1, -1, -1 };
-            int mode = -1;
-            int numCand = 3;
-            cu->getIntraDirLumaPredictor(partOffset, preds, &mode);
-            if (mode >= 0)
-            {
-                numCand = mode;
-            }
+            int preds[3];
+            int numCand = cu->getIntraDirLumaPredictor(partOffset, preds);
 
             for (int j = 0; j < numCand; j++)
             {
@@ -1917,7 +1911,11 @@
 
                 for (int i = 0; i < numModesForFullRD; i++)
                 {
-                    mostProbableModeIncluded |= (mostProbableMode == rdModeList[i]);
+                    if (mostProbableMode == rdModeList[i])
+                    {
+                        mostProbableModeIncluded = true;
+                        break;
+                    }
                 }
 
                 if (!mostProbableModeIncluded)


More information about the x265-devel mailing list