[x265-commits] [x265] search: rename some helper functions without x prefixes

Steve Borho steve at borho.org
Tue Sep 9 23:09:17 CEST 2014


details:   http://hg.videolan.org/x265/rev/719284d910b6
branches:  
changeset: 8032:719284d910b6
user:      Steve Borho <steve at borho.org>
date:      Tue Sep 09 21:07:18 2014 +0200
description:
search: rename some helper functions without x prefixes
Subject: [x265] search: !a ? b : c; -> a ? c : b;

details:   http://hg.videolan.org/x265/rev/f45f3ed38951
branches:  
changeset: 8033:f45f3ed38951
user:      Steve Borho <steve at borho.org>
date:      Tue Sep 09 21:20:15 2014 +0200
description:
search: !a ? b : c; -> a ? c : b;
Subject: [x265] search: reverse meaning of bCheckFirst to bAllowRQTSplit

details:   http://hg.videolan.org/x265/rev/408e2e6f0f70
branches:  
changeset: 8034:408e2e6f0f70
user:      Steve Borho <steve at borho.org>
date:      Tue Sep 09 22:23:26 2014 +0200
description:
search: reverse meaning of bCheckFirst to bAllowRQTSplit

I find this much more readable

diffstat:

 source/encoder/analysis.cpp |   8 +++---
 source/encoder/search.cpp   |  48 +++++++++++++++++++++++---------------------
 source/encoder/search.h     |  24 +++++++++++-----------
 3 files changed, 41 insertions(+), 39 deletions(-)

diffs (294 lines):

diff -r 491e74c58e51 -r 408e2e6f0f70 source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp	Tue Sep 09 18:55:48 2014 +0200
+++ b/source/encoder/analysis.cpp	Tue Sep 09 22:23:26 2014 +0200
@@ -1684,13 +1684,13 @@ void Analysis::checkIntraInInter_rd0_4(T
     cu->getIntraDirLumaPredictor(partOffset, preds);
 
     uint64_t mpms;
-    uint32_t rbits = xModeBitsRemIntra(cu, partOffset, depth, preds, mpms);
+    uint32_t rbits = getIntraRemModeBits(cu, partOffset, depth, preds, mpms);
 
     // DC
     primitives.intra_pred[sizeIdx][DC_IDX](tmp, scaleStride, left, above, 0, (scaleTuSize <= 16));
     bsad = sa8d(fenc, scaleStride, tmp, scaleStride) << costShift;
     bmode = mode = DC_IDX;
-    bbits = !(mpms & ((uint64_t)1 << mode)) ? rbits : xModeBitsIntra(cu, mode, partOffset, depth);
+    bbits = (mpms & ((uint64_t)1 << mode)) ? getIntraModeBits(cu, mode, partOffset, depth) : rbits;
     bcost = m_rdCost.calcRdSADCost(bsad, bbits);
 
     pixel *abovePlanar   = above;
@@ -1706,7 +1706,7 @@ void Analysis::checkIntraInInter_rd0_4(T
     primitives.intra_pred[sizeIdx][PLANAR_IDX](tmp, scaleStride, leftPlanar, abovePlanar, 0, 0);
     sad = sa8d(fenc, scaleStride, tmp, scaleStride) << costShift;
     mode = PLANAR_IDX;
-    bits = !(mpms & ((uint64_t)1 << mode)) ? rbits : xModeBitsIntra(cu, mode, partOffset, depth);
+    bits = (mpms & ((uint64_t)1 << mode)) ? getIntraModeBits(cu, mode, partOffset, depth) : rbits;
     cost = m_rdCost.calcRdSADCost(sad, bits);
     COPY4_IF_LT(bcost, cost, bmode, mode, bsad, sad, bbits, bits);
 
@@ -1724,7 +1724,7 @@ void Analysis::checkIntraInInter_rd0_4(T
     cmp = modeHor ? buf_trans : fenc; \
     srcStride = modeHor ? scaleTuSize : scaleStride; \
     sad = sa8d(cmp, srcStride, &tmp[(angle - 2) * predsize], scaleTuSize) << costShift; \
-    bits = (mpms & ((uint64_t)1 << angle)) ? xModeBitsIntra(cu, angle, partOffset, depth) : rbits; \
+    bits = (mpms & ((uint64_t)1 << angle)) ? getIntraModeBits(cu, angle, partOffset, depth) : rbits; \
     cost = m_rdCost.calcRdSADCost(sad, bits)
 
     if (m_param->bEnableFastIntra)
diff -r 491e74c58e51 -r 408e2e6f0f70 source/encoder/search.cpp
--- a/source/encoder/search.cpp	Tue Sep 09 18:55:48 2014 +0200
+++ b/source/encoder/search.cpp	Tue Sep 09 22:23:26 2014 +0200
@@ -111,7 +111,7 @@ fail:
     return false;
 }
 
-void Search::xEncSubdivCbfQTLuma(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, uint32_t* depthRange)
+void Search::xEncSubdivCbfQTLuma(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, uint32_t depthRange[2])
 {
     uint32_t fullDepth  = cu->getDepth(0) + trDepth;
     uint32_t trMode     = cu->getTransformIdx(absPartIdx);
@@ -316,7 +316,7 @@ void Search::xEncIntraHeaderChroma(TComD
     }
 }
 
-uint32_t Search::xGetIntraBitsQTLuma(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, uint32_t* depthRange)
+uint32_t Search::xGetIntraBitsQTLuma(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, uint32_t depthRange[2])
 {
     m_entropyCoder->resetBits();
     xEncIntraHeaderLuma(cu, trDepth, absPartIdx);
@@ -336,7 +336,7 @@ uint32_t Search::xGetIntraBitsQTChroma(T
     return m_entropyCoder->getNumberOfWrittenBits();
 }
 
-uint32_t Search::xGetIntraBitsLuma(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, uint32_t log2TrSize, coeff_t* coeff, uint32_t* depthRange)
+uint32_t Search::xGetIntraBitsLuma(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, uint32_t log2TrSize, coeff_t* coeff, uint32_t depthRange[2])
 {
     m_entropyCoder->resetBits();
     xEncIntraHeaderLuma(cu, trDepth, absPartIdx);
@@ -463,7 +463,7 @@ uint32_t Search::xIntraCodingChromaBlk(T
 
 /* returns distortion. TODO reorder params */
 uint32_t Search::xRecurIntraCodingQT(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, TComYuv* fencYuv, TComYuv* predYuv,
-                                     ShortYuv* resiYuv, bool bCheckFirst, uint64_t& rdCost, uint32_t depthRange[2])
+                                     ShortYuv* resiYuv, bool bAllowRQTSplit, uint64_t& rdCost, uint32_t depthRange[2])
 {
     uint32_t fullDepth   = cu->getDepth(0) + trDepth;
     uint32_t log2TrSize  = g_maxLog2CUSize - fullDepth;
@@ -487,7 +487,7 @@ uint32_t Search::xRecurIntraCodingQT(TCo
             // if maximum RD-penalty don't check TU size 32x32
             bCheckFull = (log2TrSize <= (uint32_t)X265_MIN(maxTuSize, 4));
     }
-    if (bCheckFirst && noSplitIntraMaxTuSize)
+    if (!bAllowRQTSplit && noSplitIntraMaxTuSize)
         bCheckSplit = false;
 
     uint64_t singleCost   = MAX_INT64;
@@ -667,7 +667,7 @@ uint32_t Search::xRecurIntraCodingQT(TCo
         for (uint32_t part = 0; part < 4; part++, absPartIdxSub += qPartsDiv)
         {
             cu->m_psyEnergy = 0;
-            splitDistY += xRecurIntraCodingQT(cu, trDepth + 1, absPartIdxSub, fencYuv, predYuv, resiYuv, bCheckFirst, splitCost, depthRange);
+            splitDistY += xRecurIntraCodingQT(cu, trDepth + 1, absPartIdxSub, fencYuv, predYuv, resiYuv, bAllowRQTSplit, splitCost, depthRange);
             splitPsyEnergyY += cu->m_psyEnergy;
             splitCbfY |= cu->getCbf(absPartIdxSub, TEXT_LUMA, trDepth + 1);
         }
@@ -1389,13 +1389,13 @@ void Search::estIntraPredQT(TComDataCU* 
         int numCand = cu->getIntraDirLumaPredictor(partOffset, preds);
         
         uint64_t mpms;
-        uint32_t rbits = xModeBitsRemIntra(cu, partOffset, depth, preds, mpms);
+        uint32_t rbits = getIntraRemModeBits(cu, partOffset, depth, preds, mpms);
 
         // Find N least cost modes. N = numModesForFullRD
         for (int mode = 0; mode < numModesAvailable; mode++)
         {
             uint32_t sad = modeCosts[mode];
-            uint32_t bits = !(mpms & ((uint64_t)1 << mode)) ? rbits : xModeBitsIntra(cu, mode, partOffset, depth);
+            uint32_t bits = (mpms & ((uint64_t)1 << mode)) ? getIntraModeBits(cu, mode, partOffset, depth) : rbits;
             uint64_t cost = m_rdCost.calcRdSADCost(sad, bits);
             candNum += xUpdateCandList(mode, cost, numModesForFullRD, rdModeList, candCostList);
         }
@@ -1436,7 +1436,7 @@ void Search::estIntraPredQT(TComDataCU* 
 
             // determine residual for partition
             puCost = 0;
-            puDistY = xRecurIntraCodingQT(cu, initTrDepth, partOffset, fencYuv, predYuv, resiYuv, true, puCost, depthRange);
+            puDistY = xRecurIntraCodingQT(cu, initTrDepth, partOffset, fencYuv, predYuv, resiYuv, false, puCost, depthRange);
 
             // check r-d cost
             if (puCost < bestPUCost)
@@ -1455,7 +1455,7 @@ void Search::estIntraPredQT(TComDataCU* 
 
         // determine residual for partition
         puCost = 0;
-        puDistY = xRecurIntraCodingQT(cu, initTrDepth, partOffset, fencYuv, predYuv, resiYuv, false, puCost, depthRange);
+        puDistY = xRecurIntraCodingQT(cu, initTrDepth, partOffset, fencYuv, predYuv, resiYuv, true, puCost, depthRange);
 
         overallDistY += (puCost >= bestPUCost) ? bestPUDistY : puDistY;
 
@@ -1790,7 +1790,7 @@ bool Search::predInterSearch(TComDataCU*
         list[0].cost = MAX_UINT;
         list[1].cost = MAX_UINT;
 
-        xGetBlkBits(partSize, slice->isInterP(), partIdx, lastMode, listSelBits);
+        getBlkBits(partSize, slice->isInterP(), partIdx, lastMode, listSelBits);
 
         // Uni-directional prediction
         for (int l = 0; l < numPredDir; l++)
@@ -1839,7 +1839,7 @@ bool Search::predInterSearch(TComDataCU*
                 uint32_t cost = (satdCost - m_me.mvcost(outmv)) + m_rdCost.getCost(bits);
 
                 /* Refine MVP selection, updates: mvp, mvpIdx, bits, cost */
-                xCheckBestMVP(amvpCand[l][ref], outmv, mvp, mvpIdx, bits, cost);
+                checkBestMVP(amvpCand[l][ref], outmv, mvp, mvpIdx, bits, cost);
 
                 if (cost < list[l].cost)
                 {
@@ -1916,8 +1916,8 @@ bool Search::predInterSearch(TComDataCU*
                 uint32_t cost = satdCost + m_rdCost.getCost(bits0) + m_rdCost.getCost(bits1);
 
                 /* refine MVP selection for zero mv, updates: mvp, mvpidx, bits, cost */
-                xCheckBestMVP(amvpCand[0][list[0].ref], mvzero, mvp0, mvpIdx0, bits0, cost);
-                xCheckBestMVP(amvpCand[1][list[1].ref], mvzero, mvp1, mvpIdx1, bits1, cost);
+                checkBestMVP(amvpCand[0][list[0].ref], mvzero, mvp0, mvpIdx0, bits0, cost);
+                checkBestMVP(amvpCand[1][list[1].ref], mvzero, mvp1, mvpIdx1, bits1, cost);
 
                 if (cost < bidirCost)
                 {
@@ -2003,7 +2003,7 @@ bool Search::predInterSearch(TComDataCU*
     return true;
 }
 
-void Search::xGetBlkBits(PartSize cuMode, bool bPSlice, int partIdx, uint32_t lastMode, uint32_t blockBit[3])
+void Search::getBlkBits(PartSize cuMode, bool bPSlice, int partIdx, uint32_t lastMode, uint32_t blockBit[3])
 {
     if (cuMode == SIZE_2Nx2N)
     {
@@ -2051,14 +2051,14 @@ void Search::xGetBlkBits(PartSize cuMode
     }
     else
     {
-        X265_CHECK(0, "xGetBlkBits: unknown cuMode\n");
+        X265_CHECK(0, "getBlkBits: unknown cuMode\n");
     }
 }
 
 /* Check if using an alternative MVP would result in a smaller MVD + signal bits */
-void Search::xCheckBestMVP(MV* amvpCand, MV mv, MV& mvPred, int& outMvpIdx, uint32_t& outBits, uint32_t& outCost)
+void Search::checkBestMVP(MV* amvpCand, MV mv, MV& mvPred, int& outMvpIdx, uint32_t& outBits, uint32_t& outCost)
 {
-    X265_CHECK(amvpCand[outMvpIdx] == mvPred, "xCheckBestMVP: unexpected mvPred\n");
+    X265_CHECK(amvpCand[outMvpIdx] == mvPred, "checkBestMVP: unexpected mvPred\n");
 
     int mvpIdx = !outMvpIdx;
     MV mvp = amvpCand[mvpIdx];
@@ -2238,7 +2238,7 @@ void Search::encodeResAndCalcRdInterCU(T
 
         m_entropyCoder->load(m_rdEntropyCoders[depth][CI_CURR_BEST]);
 
-        bits = xSymbolBitsInter(cu, tuDepthRange);
+        bits = getInterSymbolBits(cu, tuDepthRange);
 
         if (m_rdCost.m_psyRd)
             cost = m_rdCost.calcPsyRdCost(distortion, bits, cu->m_psyEnergy);
@@ -3465,7 +3465,7 @@ void Search::xSetResidualQTData(TComData
     }
 }
 
-uint32_t Search::xModeBitsIntra(TComDataCU* cu, uint32_t mode, uint32_t partOffset, uint32_t depth)
+uint32_t Search::getIntraModeBits(TComDataCU* cu, uint32_t mode, uint32_t partOffset, uint32_t depth)
 {
     // Reload only contexts required for coding intra mode information
     m_entropyCoder->loadIntraDirModeLuma(m_rdEntropyCoders[depth][CI_CURR_BEST]);
@@ -3478,7 +3478,9 @@ uint32_t Search::xModeBitsIntra(TComData
     return m_entropyCoder->getNumberOfWrittenBits();
 }
 
-uint32_t Search::xModeBitsRemIntra(TComDataCU* cu, uint32_t partOffset, uint32_t depth, uint32_t preds[3], uint64_t& mpms)
+/* returns the number of bits required to signal a non-most-probable mode.
+ * on return mpm contains bitmap of most probable modes */
+uint32_t Search::getIntraRemModeBits(TComDataCU* cu, uint32_t partOffset, uint32_t depth, uint32_t preds[3], uint64_t& mpms)
 {
     mpms = 0;
     for (int i = 0; i < 3; ++i)
@@ -3488,7 +3490,7 @@ uint32_t Search::xModeBitsRemIntra(TComD
     while (mpms & ((uint64_t)1 << mode))
         --mode;
 
-    return xModeBitsIntra(cu, mode, partOffset, depth);
+    return getIntraModeBits(cu, mode, partOffset, depth);
 }
 
 uint32_t Search::xUpdateCandList(uint32_t mode, uint64_t cost, uint32_t fastCandNum, uint32_t* CandModeList, uint64_t* CandCostList)
@@ -3516,7 +3518,7 @@ uint32_t Search::xUpdateCandList(uint32_
 }
 
 /* add inter-prediction syntax elements for a CU block */
-uint32_t Search::xSymbolBitsInter(TComDataCU* cu, uint32_t* depthRange)
+uint32_t Search::getInterSymbolBits(TComDataCU* cu, uint32_t depthRange[2])
 {
     if (cu->getMergeFlag(0) && cu->getPartitionSize(0) == SIZE_2Nx2N && !cu->getQtRootCbf(0))
     {
diff -r 491e74c58e51 -r 408e2e6f0f70 source/encoder/search.h
--- a/source/encoder/search.h	Tue Sep 09 18:55:48 2014 +0200
+++ b/source/encoder/search.h	Tue Sep 09 22:23:26 2014 +0200
@@ -111,8 +111,6 @@ public:
     bool initSearch(Encoder& top);
 
     void estIntraPredQT(TComDataCU* cu, TComYuv* fencYuv, TComYuv* predYuv, ShortYuv* resiYuv, TComYuv* reconYuv, uint32_t depthRange[2]);
-
-    void getBestIntraModeChroma(TComDataCU* cu, TComYuv* fencYuv, TComYuv* predYuv);
     void estIntraPredChromaQT(TComDataCU* cu, TComYuv* fencYuv, TComYuv* predYuv, ShortYuv* resiYuv, TComYuv* reconYuv);
 
     // estimation inter prediction (non-skip)
@@ -124,7 +122,9 @@ public:
 
     void generateCoeffRecon(TComDataCU* cu, TComYuv* fencYuv, TComYuv* predYuv, ShortYuv* resiYuv, TComYuv* reconYuv);
     void residualTransformQuantInter(TComDataCU* cu, uint32_t absPartIdx, TComYuv* fencYuv, ShortYuv* resiYuv, uint32_t depth, uint32_t depthRange[2]);
-    void offsetSubTUCBFs(TComDataCU* cu, TextType ttype, uint32_t trDepth, uint32_t absPartIdx);
+
+    uint32_t getIntraModeBits(TComDataCU* cu, uint32_t mode, uint32_t partOffset, uint32_t depth);
+    uint32_t getIntraRemModeBits(TComDataCU * cu, uint32_t partOffset, uint32_t depth, uint32_t preds[3], uint64_t & mpms);
 
 protected:
 
@@ -149,7 +149,7 @@ protected:
                                  uint64_t &rdCost, uint32_t &outBits, uint32_t *zeroDist, uint32_t tuDepthRange[2]);
 
     uint32_t xRecurIntraCodingQT(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, TComYuv* fencYuv, TComYuv* predYuv,
-                                 ShortYuv* resiYuv, bool bCheckFirst, uint64_t& dRDCost, uint32_t depthRange[2]);
+                                 ShortYuv* resiYuv, bool bAllowRQTSplit, uint64_t& dRDCost, uint32_t depthRange[2]);
 
     uint32_t xRecurIntraChromaCodingQT(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, TComYuv* fencYuv, TComYuv* predYuv, ShortYuv* resiYuv);
 
@@ -162,22 +162,22 @@ protected:
     void residualQTIntraChroma(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, TComYuv* fencYuv,
                                TComYuv* predYuv, ShortYuv* resiYuv, TComYuv* reconYuv);
 
+    void xEncodeResidualQT(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth, bool bSubdivAndCbf, TextType ttype, uint32_t depthRange[2]);
     void xSetIntraResultChromaQT(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, TComYuv* reconYuv);
 
     void xLoadIntraResultQT(TComDataCU* cu, uint32_t absPartIdx, uint32_t log2TrSize, int16_t* reconQt, uint32_t reconQtStride);
     void xLoadIntraResultChromaQT(TComDataCU* cu, uint32_t absPartIdx, uint32_t log2TrSizeC, uint32_t chromaId, int16_t* reconQt, uint32_t reconQtStride);
 
-    void     xCheckBestMVP(MV* amvpCand, MV cMv, MV& mvPred, int& mvpIdx, uint32_t& outBits, uint32_t& outCost);
-    void     xGetBlkBits(PartSize cuMode, bool bPSlice, int partIdx, uint32_t lastMode, uint32_t blockBit[3]);
-    uint32_t xSymbolBitsInter(TComDataCU* cu, uint32_t depthRange[2]);
-    uint32_t xModeBitsIntra(TComDataCU* cu, uint32_t mode, uint32_t partOffset, uint32_t depth);
-    uint32_t xModeBitsRemIntra(TComDataCU * cu, uint32_t partOffset, uint32_t depth, uint32_t preds[3], uint64_t & mpms);
+    void     getBestIntraModeChroma(TComDataCU* cu, TComYuv* fencYuv, TComYuv* predYuv);
+    void     offsetSubTUCBFs(TComDataCU* cu, TextType ttype, uint32_t trDepth, uint32_t absPartIdx);
+
+    void     checkBestMVP(MV* amvpCand, MV cMv, MV& mvPred, int& mvpIdx, uint32_t& outBits, uint32_t& outCost);
+    void     getBlkBits(PartSize cuMode, bool bPSlice, int partIdx, uint32_t lastMode, uint32_t blockBit[3]);
+    uint32_t getInterSymbolBits(TComDataCU* cu, uint32_t depthRange[2]);
     uint32_t xUpdateCandList(uint32_t mode, uint64_t cost, uint32_t fastCandNum, uint32_t* CandModeList, uint64_t* CandCostList);
 
     uint32_t xMergeEstimation(TComDataCU* cu, int partIdx, MergeData& m);
-    void xSetSearchRange(TComDataCU* cu, MV mvp, int merange, MV& mvmin, MV& mvmax);
-
-    void xEncodeResidualQT(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth, bool bSubdivAndCbf, TextType ttype, uint32_t depthRange[2]);
+    void     xSetSearchRange(TComDataCU* cu, MV mvp, int merange, MV& mvmin, MV& mvmax);
 };
 }
 


More information about the x265-commits mailing list