[x265] reduce set*SubParts()

Satoshi Nakagawa nakagawa424 at oki.com
Sun Feb 23 06:42:00 CET 2014


# HG changeset patch
# User Satoshi Nakagawa <nakagawa424 at oki.com>
# Date 1393133917 -32400
#      Sun Feb 23 14:38:37 2014 +0900
# Node ID 2f62117d39440c1d7d0360205fbdf14d6c892d9d
# Parent  734f106295df911edb41b5c54e795decdcdb4f04
reduce set*SubParts()

diff -r 734f106295df -r 2f62117d3944 source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Sat Feb 22 15:59:39 2014 -0600
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Sun Feb 23 14:38:37 2014 +0900
@@ -345,8 +345,6 @@
 
     for (uint32_t i = 0; i < m_numPartitions; i++)
     {
-        m_mvpIdx[0][i] = -1;
-        m_mvpIdx[1][i] = -1;
         m_depth[i] = depth;
         m_width[i] = width;
         m_height[i] = height;
@@ -361,7 +359,6 @@
         m_iPCMFlags[i] = 0;
         m_qp[i] = qp;
         m_bMergeFlags[i] = 0;
-        m_mergeIndex[i] = 0;
         m_lumaIntraDir[i] = DC_IDX;
         m_chromaIntraDir[i] = 0;
         m_interDir[i] = 0;
@@ -408,7 +405,6 @@
     memset(m_qp, qp, sizeInChar);
 
     memset(m_bMergeFlags,     0, iSizeInBool);
-    memset(m_mergeIndex,      0, iSizeInUchar);
     memset(m_lumaIntraDir,    DC_IDX, iSizeInUchar);
     memset(m_chromaIntraDir,  0, iSizeInUchar);
     memset(m_interDir,        0, iSizeInUchar);
@@ -432,8 +428,6 @@
         m_partSizes[i] = SIZE_NONE;
         m_predModes[i] = MODE_NONE;
         m_cuTransquantBypass[i] = false;
-        m_mvpIdx[0][i] = -1;
-        m_mvpIdx[1][i] = -1;
     }
 
     m_cuMvField[0].clearMvField();
@@ -1492,16 +1486,6 @@
     }
 }
 
-void TComDataCU::setMergeFlagSubParts(bool bMergeFlag, uint32_t absPartIdx, uint32_t partIdx, uint32_t depth)
-{
-    setSubPart(bMergeFlag, m_bMergeFlags, absPartIdx, depth, partIdx);
-}
-
-void TComDataCU::setMergeIndexSubParts(uint32_t mergeIndex, uint32_t absPartIdx, uint32_t partIdx, uint32_t depth)
-{
-    setSubPart<UChar>(mergeIndex, m_mergeIndex, absPartIdx, depth, partIdx);
-}
-
 void TComDataCU::setChromIntraDirSubParts(uint32_t dir, uint32_t absPartIdx, uint32_t depth)
 {
     uint32_t curPartNum = m_pic->getNumPartInCU() >> (depth << 1);
@@ -1514,11 +1498,6 @@
     setSubPart<UChar>(dir, m_interDir, absPartIdx, depth, partIdx);
 }
 
-void TComDataCU::setMVPIdxSubParts(int mvpIdx, int picList, uint32_t absPartIdx, uint32_t partIdx, uint32_t depth)
-{
-    setSubPart<char>(mvpIdx, m_mvpIdx[picList], absPartIdx, depth, partIdx);
-}
-
 void TComDataCU::setTrIdxSubParts(uint32_t trIdx, uint32_t absPartIdx, uint32_t depth)
 {
     uint32_t curPartNum = m_pic->getNumPartInCU() >> (depth << 1);
diff -r 734f106295df -r 2f62117d3944 source/Lib/TLibCommon/TComDataCU.h
--- a/source/Lib/TLibCommon/TComDataCU.h	Sat Feb 22 15:59:39 2014 -0600
+++ b/source/Lib/TLibCommon/TComDataCU.h	Sun Feb 23 14:38:37 2014 +0900
@@ -326,13 +326,14 @@
 
     bool          getMergeFlag(uint32_t idx)            { return m_bMergeFlags[idx]; }
 
-    void          setMergeFlagSubParts(bool bMergeFlag, uint32_t absPartIdx, uint32_t partIdx, uint32_t depth);
+    void          setMergeFlag(uint32_t idx, bool bMergeFlag) { m_bMergeFlags[idx] = bMergeFlag; }
 
     UChar*        getMergeIndex()                   { return m_mergeIndex; }
 
     UChar         getMergeIndex(uint32_t idx)           { return m_mergeIndex[idx]; }
 
-    void          setMergeIndexSubParts(uint32_t mergeIndex, uint32_t absPartIdx, uint32_t partIdx, uint32_t depth);
+    void          setMergeIndex(uint32_t idx, uint32_t mergeIndex) { m_mergeIndex[idx] = (UChar)mergeIndex; }
+
     template<typename T>
     void          setSubPart(T bParameter, T* pbBaseLCU, uint32_t cuAddr, uint32_t cuDepth, uint32_t puIdx);
 
@@ -384,8 +385,6 @@
 
     char*         getMVPIdx(int picList)                       { return m_mvpIdx[picList]; }
 
-    void          setMVPIdxSubParts(int mvpIdx, int picList, uint32_t absPartIdx, uint32_t partIdx, uint32_t depth);
-
     void          clipMv(MV& outMV);
 
     void          getMvPredLeft(MV& mvPred)       { mvPred = m_mvFieldA.mv; }
diff -r 734f106295df -r 2f62117d3944 source/Lib/TLibCommon/TComMotionInfo.cpp
--- a/source/Lib/TLibCommon/TComMotionInfo.cpp	Sat Feb 22 15:59:39 2014 -0600
+++ b/source/Lib/TLibCommon/TComMotionInfo.cpp	Sun Feb 23 14:38:37 2014 +0900
@@ -310,11 +310,6 @@
     setAll(m_mv, mv, cuMode, partAddr, depth, partIdx);
 }
 
-void TComCUMvField::setAllMvd(const MV& mvd, PartSize cuMode, int partAddr, uint32_t depth, int partIdx)
-{
-    setAll(m_mvd, mvd, cuMode, partAddr, depth, partIdx);
-}
-
 void TComCUMvField::setAllRefIdx(int refIdx, PartSize cuMode, int partAddr, uint32_t depth, int partIdx)
 {
     setAll(m_refIdx, static_cast<char>(refIdx), cuMode, partAddr, depth, partIdx);
diff -r 734f106295df -r 2f62117d3944 source/Lib/TLibCommon/TComMotionInfo.h
--- a/source/Lib/TLibCommon/TComMotionInfo.h	Sat Feb 22 15:59:39 2014 -0600
+++ b/source/Lib/TLibCommon/TComMotionInfo.h	Sun Feb 23 14:38:37 2014 +0900
@@ -130,9 +130,9 @@
     // ------------------------------------------------------------------------------------------------------------------
 
     void    setAllMv(const MV& mv,              PartSize cuMode, int partAddr, uint32_t depth, int partIdx = 0);
-    void    setAllMvd(const MV& mvd,            PartSize cuMode, int partAddr, uint32_t depth, int partIdx = 0);
     void    setAllRefIdx(int refIdx,                  PartSize mbMode, int partAddr, uint32_t depth, int partIdx = 0);
     void    setAllMvField(const TComMvField& mvField, PartSize mbMode, int partAddr, uint32_t depth, int partIdx = 0);
+    void    setMvd(int idx, const MV& mvd) { m_mvd[idx] = mvd; }
 
     void setNumPartition(int numPart)
     {
diff -r 734f106295df -r 2f62117d3944 source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp	Sat Feb 22 15:59:39 2014 -0600
+++ b/source/Lib/TLibEncoder/TEncCu.cpp	Sun Feb 23 14:38:37 2014 +0900
@@ -1253,8 +1253,8 @@
                     outTempCU->setPredModeSubParts(MODE_INTER, 0, depth); // interprets depth relative to LCU level
                     outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(),     0, depth);
                     outTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth); // interprets depth relative to LCU level
-                    outTempCU->setMergeFlagSubParts(true, 0, 0, depth); // interprets depth relative to LCU level
-                    outTempCU->setMergeIndexSubParts(mergeCand, 0, 0, depth); // interprets depth relative to LCU level
+                    outTempCU->setMergeFlag(0, true);
+                    outTempCU->setMergeIndex(0, mergeCand);
                     outTempCU->setInterDirSubParts(interDirNeighbours[mergeCand], 0, 0, depth); // interprets depth relative to LCU level
                     outTempCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField(mvFieldNeighbours[0 + 2 * mergeCand], SIZE_2Nx2N, 0, 0); // interprets depth relative to outTempCU level
                     outTempCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField(mvFieldNeighbours[1 + 2 * mergeCand], SIZE_2Nx2N, 0, 0); // interprets depth relative to outTempCU level
diff -r 734f106295df -r 2f62117d3944 source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp	Sat Feb 22 15:59:39 2014 -0600
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Sun Feb 23 14:38:37 2014 +0900
@@ -2736,11 +2736,6 @@
         //  Clear Motion Field
         cu->getCUMvField(REF_PIC_LIST_0)->setAllMvField(TComMvField(), partSize, partAddr, 0, partIdx);
         cu->getCUMvField(REF_PIC_LIST_1)->setAllMvField(TComMvField(), partSize, partAddr, 0, partIdx);
-        cu->getCUMvField(REF_PIC_LIST_0)->setAllMvd(mvzero, partSize, partAddr, 0, partIdx);
-        cu->getCUMvField(REF_PIC_LIST_1)->setAllMvd(mvzero, partSize, partAddr, 0, partIdx);
-
-        cu->setMVPIdxSubParts(-1, REF_PIC_LIST_0, partAddr, partIdx, cu->getDepth(partAddr));
-        cu->setMVPIdxSubParts(-1, REF_PIC_LIST_1, partAddr, partIdx, cu->getDepth(partAddr));
 
         uint32_t mebits = 0;
         // Set Motion Field_
@@ -2762,17 +2757,17 @@
                 }
                 {
                     MV mvtmp = mvBidir[0] - mvPredBi[0][refIdxBidir[0]];
-                    cu->getCUMvField(REF_PIC_LIST_0)->setAllMvd(mvtmp, partSize, partAddr, 0, partIdx);
+                    cu->getCUMvField(REF_PIC_LIST_0)->setMvd(partAddr, mvtmp);
                 }
                 {
                     MV mvtmp = mvBidir[1] - mvPredBi[1][refIdxBidir[1]];
-                    cu->getCUMvField(REF_PIC_LIST_1)->setAllMvd(mvtmp, partSize, partAddr, 0, partIdx);
+                    cu->getCUMvField(REF_PIC_LIST_1)->setMvd(partAddr, mvtmp);
                 }
 
                 cu->setInterDirSubParts(3, partAddr, partIdx, cu->getDepth(0));
 
-                cu->setMVPIdxSubParts(mvpIdxBi[0][refIdxBidir[0]], REF_PIC_LIST_0, partAddr, partIdx, cu->getDepth(partAddr));
-                cu->setMVPIdxSubParts(mvpIdxBi[1][refIdxBidir[1]], REF_PIC_LIST_1, partAddr, partIdx, cu->getDepth(partAddr));
+                cu->setMVPIdx(REF_PIC_LIST_0, partAddr, mvpIdxBi[0][refIdxBidir[0]]);
+                cu->setMVPIdx(REF_PIC_LIST_1, partAddr, mvpIdxBi[1][refIdxBidir[1]]);
 
                 mebits = bits[2];
             }
@@ -2783,11 +2778,11 @@
                 cu->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx(refIdx[0], partSize, partAddr, 0, partIdx);
                 {
                     MV mvtmp = mv[0] - mvPred[0][refIdx[0]];
-                    cu->getCUMvField(REF_PIC_LIST_0)->setAllMvd(mvtmp, partSize, partAddr, 0, partIdx);
+                    cu->getCUMvField(REF_PIC_LIST_0)->setMvd(partAddr, mvtmp);
                 }
                 cu->setInterDirSubParts(1, partAddr, partIdx, cu->getDepth(0));
 
-                cu->setMVPIdxSubParts(mvpIdx[0][refIdx[0]], REF_PIC_LIST_0, partAddr, partIdx, cu->getDepth(partAddr));
+                cu->setMVPIdx(REF_PIC_LIST_0, partAddr, mvpIdx[0][refIdx[0]]);
 
                 mebits = bits[0];
             }
@@ -2798,11 +2793,11 @@
                 cu->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx(refIdx[1], partSize, partAddr, 0, partIdx);
                 {
                     MV mvtmp = mv[1] - mvPred[1][refIdx[1]];
-                    cu->getCUMvField(REF_PIC_LIST_1)->setAllMvd(mvtmp, partSize, partAddr, 0, partIdx);
+                    cu->getCUMvField(REF_PIC_LIST_1)->setMvd(partAddr, mvtmp);
                 }
                 cu->setInterDirSubParts(2, partAddr, partIdx, cu->getDepth(0));
 
-                cu->setMVPIdxSubParts(mvpIdx[1][refIdx[1]], REF_PIC_LIST_1, partAddr, partIdx, cu->getDepth(partAddr));
+                cu->setMVPIdx(REF_PIC_LIST_1, partAddr, mvpIdx[1][refIdx[1]]);
 
                 mebits = bits[1];
             }
@@ -2839,25 +2834,19 @@
             if (mrgCost < meCost)
             {
                 // set Merge result
-                cu->setMergeFlagSubParts(true, partAddr, partIdx, cu->getDepth(partAddr));
-                cu->setMergeIndexSubParts(mrgIndex, partAddr, partIdx, cu->getDepth(partAddr));
+                cu->setMergeFlag(partAddr, true);
+                cu->setMergeIndex(partAddr, mrgIndex);
                 cu->setInterDirSubParts(mrgInterDir, partAddr, partIdx, cu->getDepth(partAddr));
                 {
                     cu->getCUMvField(REF_PIC_LIST_0)->setAllMvField(mrgMvField[0], partSize, partAddr, 0, partIdx);
                     cu->getCUMvField(REF_PIC_LIST_1)->setAllMvField(mrgMvField[1], partSize, partAddr, 0, partIdx);
                 }
-
-                cu->getCUMvField(REF_PIC_LIST_0)->setAllMvd(mvzero, partSize, partAddr, 0, partIdx);
-                cu->getCUMvField(REF_PIC_LIST_1)->setAllMvd(mvzero, partSize, partAddr, 0, partIdx);
-
-                cu->setMVPIdxSubParts(-1, REF_PIC_LIST_0, partAddr, partIdx, cu->getDepth(partAddr));
-                cu->setMVPIdxSubParts(-1, REF_PIC_LIST_1, partAddr, partIdx, cu->getDepth(partAddr));
                 totalmebits += mrgBits;
             }
             else
             {
                 // set ME result
-                cu->setMergeFlagSubParts(false, partAddr, partIdx, cu->getDepth(partAddr));
+                cu->setMergeFlag(partAddr, false);
                 cu->setInterDirSubParts(meInterDir, partAddr, partIdx, cu->getDepth(partAddr));
                 {
                     cu->getCUMvField(REF_PIC_LIST_0)->setAllMvField(meMvField[0], partSize, partAddr, 0, partIdx);
@@ -2912,7 +2901,7 @@
 
     // Setting Best MVP
     mvPred = bestMv;
-    cu->setMVPIdxSubParts(bestIdx, list, partAddr, partIdx, cu->getDepth(partAddr));
+    cu->setMVPIdx(list, partAddr, bestIdx);
 }
 
 void TEncSearch::xGetBlkBits(PartSize cuMode, bool bPSlice, int partIdx, uint32_t lastMode, uint32_t blockBit[3])
diff -r 734f106295df -r 2f62117d3944 source/encoder/compress.cpp
--- a/source/encoder/compress.cpp	Sat Feb 22 15:59:39 2014 -0600
+++ b/source/encoder/compress.cpp	Sun Feb 23 14:38:37 2014 +0900
@@ -227,12 +227,12 @@
     outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
     outTempCU->getInterMergeCandidates(0, 0, mvFieldNeighbours, interDirNeighbours, numValidMergeCand);
     outTempCU->setPredModeSubParts(MODE_INTER, 0, depth);
-    outTempCU->setMergeFlagSubParts(true, 0, 0, depth);
+    outTempCU->setMergeFlag(0, true);
 
     outBestCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth); // interprets depth relative to LCU level
     outBestCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
     outBestCU->setPredModeSubParts(MODE_INTER, 0, depth);
-    outBestCU->setMergeFlagSubParts(true, 0, 0, depth);
+    outBestCU->setMergeFlag(0, true);
 
     int part = g_convertToBit[outTempCU->getWidth(0)];
     int bestMergeCand = -1;
@@ -245,7 +245,7 @@
             && mvFieldNeighbours[1 + 2 * mergeCand].mv.y < (m_cfg->param.searchRange + 1) * 4)
         {
             // set MC parameters, interprets depth relative to LCU level
-            outTempCU->setMergeIndexSubParts(mergeCand, 0, 0, depth);
+            outTempCU->setMergeIndex(0, mergeCand);
             outTempCU->setInterDirSubParts(interDirNeighbours[mergeCand], 0, 0, depth);
             outTempCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField(mvFieldNeighbours[0 + 2 * mergeCand], SIZE_2Nx2N, 0, 0); // interprets depth relative to rpcTempCU level
             outTempCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField(mvFieldNeighbours[1 + 2 * mergeCand], SIZE_2Nx2N, 0, 0); // interprets depth relative to rpcTempCU level
@@ -278,12 +278,12 @@
 
     if (bestMergeCand < 0)
     {
-        outBestCU->setMergeFlagSubParts(false, 0, 0, depth);
+        outBestCU->setMergeFlag(0, false);
         outBestCU->initEstData(depth, outBestCU->getQP(0));
     }
     else
     {
-        outTempCU->setMergeIndexSubParts(bestMergeCand, 0, 0, depth);
+        outTempCU->setMergeIndex(0, bestMergeCand);
         outTempCU->setInterDirSubParts(interDirNeighbours[bestMergeCand], 0, 0, depth);
         outTempCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField(mvFieldNeighbours[0 + 2 * bestMergeCand], SIZE_2Nx2N, 0, 0);
         outTempCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField(mvFieldNeighbours[1 + 2 * bestMergeCand], SIZE_2Nx2N, 0, 0);


More information about the x265-devel mailing list