[x265-commits] [x265] search: make some helper methods const
Steve Borho
steve at borho.org
Thu Oct 2 08:30:38 CEST 2014
details: http://hg.videolan.org/x265/rev/b17293bb0f19
branches:
changeset: 8200:b17293bb0f19
user: Steve Borho <steve at borho.org>
date: Thu Oct 02 00:25:46 2014 -0500
description:
search: make some helper methods const
Subject: [x265] search: use sad cost directly to pick MVP
details: http://hg.videolan.org/x265/rev/bd6e2cdd5938
branches:
changeset: 8201:bd6e2cdd5938
user: Steve Borho <steve at borho.org>
date: Thu Oct 02 00:26:45 2014 -0500
description:
search: use sad cost directly to pick MVP
there's no point in use SAD RD cost if all the candidates have the same
estimated bit cost.
Subject: [x265] search: remove redundant calls to prepMotionCompensation()
details: http://hg.videolan.org/x265/rev/50490cd35e57
branches:
changeset: 8202:50490cd35e57
user: Steve Borho <steve at borho.org>
date: Thu Oct 02 01:12:32 2014 -0500
description:
search: remove redundant calls to prepMotionCompensation()
diffstat:
source/encoder/rdcost.h | 14 +++++++-------
source/encoder/search.cpp | 12 ++++++------
source/encoder/search.h | 6 +++---
3 files changed, 16 insertions(+), 16 deletions(-)
diffs (142 lines):
diff -r 898a2546aff1 -r 50490cd35e57 source/encoder/rdcost.h
--- a/source/encoder/rdcost.h Wed Oct 01 23:26:28 2014 -0500
+++ b/source/encoder/rdcost.h Thu Oct 02 01:12:32 2014 -0500
@@ -69,7 +69,7 @@ public:
m_lambda = (uint64_t)floor(256.0 * lambda);
}
- inline uint64_t calcRdCost(uint32_t distortion, uint32_t bits)
+ inline uint64_t calcRdCost(uint32_t distortion, uint32_t bits) const
{
X265_CHECK(bits <= (UINT64_MAX - 128) / m_lambda2,
"calcRdCost wrap detected dist: %d, bits %d, lambda: %d\n", distortion, bits, (int)m_lambda2);
@@ -77,39 +77,39 @@ public:
}
/* return the difference in energy between the source block and the recon block */
- inline int psyCost(int size, pixel *source, intptr_t sstride, pixel *recon, intptr_t rstride)
+ inline int psyCost(int size, pixel *source, intptr_t sstride, pixel *recon, intptr_t rstride) const
{
return primitives.psy_cost[size](source, sstride, recon, rstride);
}
/* return the RD cost of this prediction, including the effect of psy-rd */
- inline uint64_t calcPsyRdCost(uint32_t distortion, uint32_t bits, uint32_t psycost)
+ inline uint64_t calcPsyRdCost(uint32_t distortion, uint32_t bits, uint32_t psycost) const
{
return distortion + ((m_lambda * m_psyRd * psycost) >> 16) + ((bits * m_lambda2) >> 8);
}
- inline uint64_t calcRdSADCost(uint32_t sadCost, uint32_t bits)
+ inline uint64_t calcRdSADCost(uint32_t sadCost, uint32_t bits) const
{
X265_CHECK(bits <= (UINT64_MAX - 128) / m_lambda,
"calcRdSADCost wrap detected dist: %d, bits %d, lambda: "X265_LL"\n", sadCost, bits, m_lambda);
return sadCost + ((bits * m_lambda + 128) >> 8);
}
- inline uint32_t scaleChromaDistCb(uint32_t dist)
+ inline uint32_t scaleChromaDistCb(uint32_t dist) const
{
X265_CHECK(dist <= (UINT64_MAX - 128) / m_cbDistortionWeight,
"scaleChromaDistCb wrap detected dist: %d, lambda: "X265_LL"\n", dist, m_cbDistortionWeight);
return (uint32_t)(((dist * m_cbDistortionWeight) + 128) >> 8);
}
- inline uint32_t scaleChromaDistCr(uint32_t dist)
+ inline uint32_t scaleChromaDistCr(uint32_t dist) const
{
X265_CHECK(dist <= (UINT64_MAX - 128) / m_crDistortionWeight,
"scaleChromaDistCr wrap detected dist: %d, lambda: "X265_LL"\n", dist, m_crDistortionWeight);
return (uint32_t)(((dist * m_crDistortionWeight) + 128) >> 8);
}
- inline uint32_t getCost(uint32_t bits)
+ inline uint32_t getCost(uint32_t bits) const
{
return (uint32_t)((bits * m_lambda + 128) >> 8);
}
diff -r 898a2546aff1 -r 50490cd35e57 source/encoder/search.cpp
--- a/source/encoder/search.cpp Wed Oct 01 23:26:28 2014 -0500
+++ b/source/encoder/search.cpp Thu Oct 02 01:12:32 2014 -0500
@@ -1693,6 +1693,8 @@ bool Search::predInterSearch(TComDataCU*
int roiWidth, roiHeight;
cu->getPartIndexAndSize(partIdx, partAddr, roiWidth, roiHeight);
+ prepMotionCompensation(cu, cuData, partIdx);
+
pixel* pu = fenc->getLumaAddr(cu->getAddr(), cuData->encodeIdx + partAddr);
m_me.setSourcePU(pu - fenc->getLumaAddr(), roiWidth, roiHeight);
@@ -1764,10 +1766,8 @@ bool Search::predInterSearch(TComDataCU*
cu->clipMv(mvCand);
- prepMotionCompensation(cu, cuData, partIdx);
predInterLumaBlk(slice->m_refPicList[l][ref]->getPicYuvRec(), &m_predTempYuv, &mvCand);
uint32_t cost = m_me.bufSAD(m_predTempYuv.getLumaAddr(partAddr), m_predTempYuv.getStride());
- cost = (uint32_t)m_rdCost.calcRdSADCost(cost, MVP_IDX_BITS);
if (bestCost > cost)
{
@@ -1812,7 +1812,6 @@ bool Search::predInterSearch(TComDataCU*
TComPicYuv *refPic0 = slice->m_refPicList[0][list[0].ref]->getPicYuvRec();
TComPicYuv *refPic1 = slice->m_refPicList[1][list[1].ref]->getPicYuvRec();
- prepMotionCompensation(cu, cuData, partIdx);
predInterLumaBlk(refPic0, &m_bidirPredYuv[0], &list[0].mv);
predInterLumaBlk(refPic1, &m_bidirPredYuv[1], &list[1].mv);
@@ -1938,6 +1937,7 @@ bool Search::predInterSearch(TComDataCU*
totalmebits += list[1].bits;
}
+
prepMotionCompensation(cu, cuData, partIdx);
motionCompensation(predYuv, true, bChroma);
}
@@ -1947,7 +1947,7 @@ bool Search::predInterSearch(TComDataCU*
return true;
}
-void Search::getBlkBits(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]) const
{
if (cuMode == SIZE_2Nx2N)
{
@@ -2000,7 +2000,7 @@ void Search::getBlkBits(PartSize cuMode,
}
/* Check if using an alternative MVP would result in a smaller MVD + signal bits */
-void Search::checkBestMVP(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) const
{
X265_CHECK(amvpCand[outMvpIdx] == mvPred, "checkBestMVP: unexpected mvPred\n");
@@ -2017,7 +2017,7 @@ void Search::checkBestMVP(MV* amvpCand,
}
}
-void Search::setSearchRange(TComDataCU* cu, MV mvp, int merange, MV& mvmin, MV& mvmax)
+void Search::setSearchRange(TComDataCU* cu, MV mvp, int merange, MV& mvmin, MV& mvmax) const
{
cu->clipMv(mvp);
diff -r 898a2546aff1 -r 50490cd35e57 source/encoder/search.h
--- a/source/encoder/search.h Wed Oct 01 23:26:28 2014 -0500
+++ b/source/encoder/search.h Thu Oct 02 01:12:32 2014 -0500
@@ -171,11 +171,11 @@ protected:
};
/* inter/ME helper functions */
- 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]);
+ void checkBestMVP(MV* amvpCand, MV cMv, MV& mvPred, int& mvpIdx, uint32_t& outBits, uint32_t& outCost) const;
+ void getBlkBits(PartSize cuMode, bool bPSlice, int partIdx, uint32_t lastMode, uint32_t blockBit[3]) const;
+ void setSearchRange(TComDataCU* cu, MV mvp, int merange, MV& mvmin, MV& mvmax) const;
uint32_t getInterSymbolBits(TComDataCU* cu, uint32_t depthRange[2]);
uint32_t mergeEstimation(TComDataCU* cu, CU* cuData, int partIdx, MergeData& m);
- void setSearchRange(TComDataCU* cu, MV mvp, int merange, MV& mvmin, MV& mvmax);
/* intra helper functions */
enum { MAX_RD_INTRA_MODES = 16 };
More information about the x265-commits
mailing list