[x265-commits] [x265] cleanup unused arg
Satoshi Nakagawa
nakagawa424 at oki.com
Mon May 19 09:18:53 CEST 2014
details: http://hg.videolan.org/x265/rev/f9f132b3e36e
branches:
changeset: 6877:f9f132b3e36e
user: Satoshi Nakagawa <nakagawa424 at oki.com>
date: Fri May 16 13:04:45 2014 +0900
description:
cleanup unused arg
Subject: [x265] encodeCoeffNxN(): call only if non-zero coeff exists
details: http://hg.videolan.org/x265/rev/ba2a9f61ea06
branches:
changeset: 6878:ba2a9f61ea06
user: Satoshi Nakagawa <nakagawa424 at oki.com>
date: Fri May 16 19:20:46 2014 +0900
description:
encodeCoeffNxN(): call only if non-zero coeff exists
diffstat:
source/Lib/TLibCommon/TComDataCU.cpp | 21 +----
source/Lib/TLibCommon/TComDataCU.h | 3 +-
source/Lib/TLibEncoder/TEncCu.cpp | 6 +-
source/Lib/TLibEncoder/TEncEntropy.cpp | 79 ++++++++--------------
source/Lib/TLibEncoder/TEncEntropy.h | 8 +-
source/Lib/TLibEncoder/TEncSbac.cpp | 6 +-
source/Lib/TLibEncoder/TEncSbac.h | 2 +-
source/Lib/TLibEncoder/TEncSearch.cpp | 114 +++++++++++++++++++++++++-------
source/encoder/compress.cpp | 2 +-
9 files changed, 134 insertions(+), 107 deletions(-)
diffs (truncated from 603 to 300 lines):
diff -r c78bed701db4 -r ba2a9f61ea06 source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp Mon May 19 00:56:18 2014 -0500
+++ b/source/Lib/TLibCommon/TComDataCU.cpp Fri May 16 19:20:46 2014 +0900
@@ -1304,13 +1304,13 @@ uint32_t TComDataCU::getCtxInterDir(uint
return getDepth(absPartIdx);
}
-void TComDataCU::setCbfSubParts(uint32_t cbfY, uint32_t cbfU, uint32_t cbfV, uint32_t absPartIdx, uint32_t depth)
+void TComDataCU::clearCbf(uint32_t absPartIdx, uint32_t depth)
{
uint32_t curPartNum = m_pic->getNumPartInCU() >> (depth << 1);
- memset(m_cbf[0] + absPartIdx, cbfY, sizeof(uint8_t) * curPartNum);
- memset(m_cbf[1] + absPartIdx, cbfU, sizeof(uint8_t) * curPartNum);
- memset(m_cbf[2] + absPartIdx, cbfV, sizeof(uint8_t) * curPartNum);
+ memset(m_cbf[0] + absPartIdx, 0, sizeof(uint8_t) * curPartNum);
+ memset(m_cbf[1] + absPartIdx, 0, sizeof(uint8_t) * curPartNum);
+ memset(m_cbf[2] + absPartIdx, 0, sizeof(uint8_t) * curPartNum);
}
void TComDataCU::setCbfSubParts(uint32_t cbf, TextType ttype, uint32_t absPartIdx, uint32_t depth)
@@ -1320,19 +1320,6 @@ void TComDataCU::setCbfSubParts(uint32_t
memset(m_cbf[ttype] + absPartIdx, cbf, sizeof(uint8_t) * curPartNum);
}
-/** Sets a coded block flag for all sub-partitions of a partition
- * \param uiCbf The value of the coded block flag to be set
- * \param ttype
- * \param absPartIdx
- * \param partIdx
- * \param depth
- * \returns void
- */
-void TComDataCU::setCbfSubParts(uint32_t uiCbf, TextType ttype, uint32_t absPartIdx, uint32_t partIdx, uint32_t depth)
-{
- setSubPart<uint8_t>(uiCbf, m_cbf[ttype], absPartIdx, depth, partIdx);
-}
-
void TComDataCU::setCbfPartRange(uint32_t cbf, TextType ttype, uint32_t absPartIdx, uint32_t coveredPartIdxes)
{
memset(m_cbf[ttype] + absPartIdx, cbf, sizeof(uint8_t) * coveredPartIdxes);
diff -r c78bed701db4 -r ba2a9f61ea06 source/Lib/TLibCommon/TComDataCU.h
--- a/source/Lib/TLibCommon/TComDataCU.h Mon May 19 00:56:18 2014 -0500
+++ b/source/Lib/TLibCommon/TComDataCU.h Fri May 16 19:20:46 2014 +0900
@@ -300,9 +300,8 @@ public:
uint8_t getQtRootCbf(uint32_t idx) { return getCbf(idx, TEXT_LUMA) || getCbf(idx, TEXT_CHROMA_U) || getCbf(idx, TEXT_CHROMA_V); }
- void setCbfSubParts(uint32_t cbfY, uint32_t cbfU, uint32_t cbfV, uint32_t absPartIdx, uint32_t depth);
+ void clearCbf(uint32_t absPartIdx, uint32_t depth);
void setCbfSubParts(uint32_t cbf, TextType ttype, uint32_t absPartIdx, uint32_t depth);
- void setCbfSubParts(uint32_t cbf, TextType ttype, uint32_t absPartIdx, uint32_t partIdx, uint32_t depth);
void setCbfPartRange(uint32_t cbf, TextType ttype, uint32_t absPartIdx, uint32_t coveredPartIdxes);
void setTransformSkipPartRange(uint32_t useTransformSkip, TextType ttype, uint32_t absPartIdx, uint32_t coveredPartIdxes);
diff -r c78bed701db4 -r ba2a9f61ea06 source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp Mon May 19 00:56:18 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncCu.cpp Fri May 16 19:20:46 2014 +0900
@@ -1193,7 +1193,7 @@ void TEncCu::xEncodeCU(TComDataCU* cu, u
// Encode Coefficients
bool bCodeDQP = getdQPFlag();
- m_entropyCoder->encodeCoeff(cu, absPartIdx, depth, cu->getCUSize(absPartIdx), cu->getCUSize(absPartIdx), bCodeDQP);
+ m_entropyCoder->encodeCoeff(cu, absPartIdx, depth, cu->getCUSize(absPartIdx), bCodeDQP);
setdQPFlag(bCodeDQP);
// --- write terminating bit ---
@@ -1385,7 +1385,7 @@ void TEncCu::xCheckRDCostIntra(TComDataC
// Encode Coefficients
bool bCodeDQP = getdQPFlag();
- m_entropyCoder->encodeCoeff(outTempCU, 0, depth, outTempCU->getCUSize(0), outTempCU->getCUSize(0), bCodeDQP);
+ m_entropyCoder->encodeCoeff(outTempCU, 0, depth, outTempCU->getCUSize(0), bCodeDQP);
m_rdGoOnSbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
outTempCU->m_totalBits = m_entropyCoder->getNumberOfWrittenBits();
@@ -1432,7 +1432,7 @@ void TEncCu::xCheckRDCostIntraInInter(TC
// Encode Coefficients
bool bCodeDQP = getdQPFlag();
- m_entropyCoder->encodeCoeff(outTempCU, 0, depth, outTempCU->getCUSize(0), outTempCU->getCUSize(0), bCodeDQP);
+ m_entropyCoder->encodeCoeff(outTempCU, 0, depth, outTempCU->getCUSize(0), bCodeDQP);
m_rdGoOnSbacCoder->store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
outTempCU->m_totalBits = m_entropyCoder->getNumberOfWrittenBits();
diff -r c78bed701db4 -r ba2a9f61ea06 source/Lib/TLibEncoder/TEncEntropy.cpp
--- a/source/Lib/TLibEncoder/TEncEntropy.cpp Mon May 19 00:56:18 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncEntropy.cpp Fri May 16 19:20:46 2014 +0900
@@ -209,7 +209,7 @@ void TEncEntropy::initTUEntropySection(T
tuIterator->m_absPartIdxStep = absPartIdxStep >> partIdxStepShift[splitMode];
}
-void TEncEntropy::xEncodeTransform(TComDataCU* cu, uint32_t offsetLuma, uint32_t offsetChroma, uint32_t absPartIdx, uint32_t absPartIdxStep, uint32_t depth, uint32_t width, uint32_t height, uint32_t trIdx, bool& bCodeDQP)
+void TEncEntropy::xEncodeTransform(TComDataCU* cu, uint32_t offsetLuma, uint32_t offsetChroma, uint32_t absPartIdx, uint32_t absPartIdxStep, uint32_t depth, uint32_t tuSize, uint32_t trIdx, bool& bCodeDQP)
{
const uint32_t subdiv = cu->getTransformIdx(absPartIdx) + cu->getDepth(absPartIdx) > depth;
const uint32_t log2TrafoSize = g_convertToBit[cu->getSlice()->getSPS()->getMaxCUSize()] + 2 - depth;
@@ -276,7 +276,7 @@ void TEncEntropy::xEncodeTransform(TComD
const bool bFirstCbfOfCU = trDepthCurr == 0;
bool mCodeAll = true;
- const uint32_t numPels = (width >> hChromaShift) * (height >> vChromaShift);
+ const uint32_t numPels = (tuSize * tuSize) >> (hChromaShift + vChromaShift);
if (numPels < (MIN_TU_SIZE * MIN_TU_SIZE))
{
mCodeAll = false;
@@ -286,11 +286,11 @@ void TEncEntropy::xEncodeTransform(TComD
{
if (bFirstCbfOfCU || cu->getCbf(absPartIdx, TEXT_CHROMA_U, trDepthCurr - 1))
{
- m_entropyCoderIf->codeQtCbf(cu, absPartIdx, TEXT_CHROMA_U, trDepthCurr, absPartIdxStep, (width >> hChromaShift), (height >> vChromaShift), (subdiv == 0));
+ m_entropyCoderIf->codeQtCbf(cu, absPartIdx, TEXT_CHROMA_U, trDepthCurr, absPartIdxStep, (tuSize >> hChromaShift), (tuSize >> vChromaShift), (subdiv == 0));
}
if (bFirstCbfOfCU || cu->getCbf(absPartIdx, TEXT_CHROMA_V, trDepthCurr - 1))
{
- m_entropyCoderIf->codeQtCbf(cu, absPartIdx, TEXT_CHROMA_V, trDepthCurr, absPartIdxStep, (width >> hChromaShift), (height >> vChromaShift), (subdiv == 0));
+ m_entropyCoderIf->codeQtCbf(cu, absPartIdx, TEXT_CHROMA_V, trDepthCurr, absPartIdxStep, (tuSize >> hChromaShift), (tuSize >> vChromaShift), (subdiv == 0));
}
}
else
@@ -301,31 +301,30 @@ void TEncEntropy::xEncodeTransform(TComD
if (subdiv)
{
- uint32_t size;
- width >>= 1;
- height >>= 1;
- size = width * height;
+ tuSize >>= 1;
+ uint32_t numCoeff = tuSize * tuSize;
+ uint32_t numCoeffC = (numCoeff >> (hChromaShift + vChromaShift));
trIdx++;
++depth;
- absPartIdxStep = absPartIdxStep >> partIdxStepShift[QUAD_SPLIT];
+ absPartIdxStep >>= 2;
const uint32_t partNum = cu->getPic()->getNumPartInCU() >> (depth << 1);
- xEncodeTransform(cu, offsetLuma, offsetChroma, absPartIdx, absPartIdxStep, depth, width, height, trIdx, bCodeDQP);
+ xEncodeTransform(cu, offsetLuma, offsetChroma, absPartIdx, absPartIdxStep, depth, tuSize, trIdx, bCodeDQP);
absPartIdx += partNum;
- offsetLuma += size;
- offsetChroma += (size >> (hChromaShift + vChromaShift));
- xEncodeTransform(cu, offsetLuma, offsetChroma, absPartIdx, absPartIdxStep, depth, width, height, trIdx, bCodeDQP);
+ offsetLuma += numCoeff;
+ offsetChroma += numCoeffC;
+ xEncodeTransform(cu, offsetLuma, offsetChroma, absPartIdx, absPartIdxStep, depth, tuSize, trIdx, bCodeDQP);
absPartIdx += partNum;
- offsetLuma += size;
- offsetChroma += (size >> (hChromaShift + vChromaShift));
- xEncodeTransform(cu, offsetLuma, offsetChroma, absPartIdx, absPartIdxStep, depth, width, height, trIdx, bCodeDQP);
+ offsetLuma += numCoeff;
+ offsetChroma += numCoeffC;
+ xEncodeTransform(cu, offsetLuma, offsetChroma, absPartIdx, absPartIdxStep, depth, tuSize, trIdx, bCodeDQP);
absPartIdx += partNum;
- offsetLuma += size;
- offsetChroma += (size >> (hChromaShift + vChromaShift));
- xEncodeTransform(cu, offsetLuma, offsetChroma, absPartIdx, absPartIdxStep, depth, width, height, trIdx, bCodeDQP);
+ offsetLuma += numCoeff;
+ offsetChroma += numCoeffC;
+ xEncodeTransform(cu, offsetLuma, offsetChroma, absPartIdx, absPartIdxStep, depth, tuSize, trIdx, bCodeDQP);
}
else
{
@@ -346,7 +345,7 @@ void TEncEntropy::xEncodeTransform(TComD
}
else
{
- m_entropyCoderIf->codeQtCbf(cu, absPartIdx, TEXT_LUMA, cu->getTransformIdx(absPartIdx), absPartIdxStep, width, height, (subdiv == 0));
+ m_entropyCoderIf->codeQtCbf(cu, absPartIdx, TEXT_LUMA, cu->getTransformIdx(absPartIdx), absPartIdxStep, tuSize, tuSize, (subdiv == 0));
}
if (cbfY || cbfU || cbfV)
@@ -363,7 +362,7 @@ void TEncEntropy::xEncodeTransform(TComD
}
if (cbfY)
{
- m_entropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffY() + offsetLuma), absPartIdx, width, depth, TEXT_LUMA);
+ m_entropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffY() + offsetLuma), absPartIdx, tuSize, TEXT_LUMA);
}
int chFmt = cu->getChromaFormat();
@@ -384,11 +383,11 @@ void TEncEntropy::xEncodeTransform(TComD
coeff_t* coeffChroma = (chromaId == 1) ? cu->getCoeffCb() : cu->getCoeffCr();
do
{
- uint32_t cbf = cu->getCbf(tuIterator.m_absPartIdxTURelCU, (TextType)chromaId, trIdx);
+ uint32_t cbf = cu->getCbf(tuIterator.m_absPartIdxTURelCU, (TextType)chromaId, trIdx + splitIntoSubTUs);
uint32_t subTUIndex = tuIterator.m_section * trWidthC * trWidthC;
if (cbf)
{
- m_entropyCoderIf->codeCoeffNxN(cu, (coeffChroma + m_bakChromaOffset + subTUIndex), tuIterator.m_absPartIdxTURelCU, trWidthC, depth, (TextType)chromaId);
+ m_entropyCoderIf->codeCoeffNxN(cu, (coeffChroma + m_bakChromaOffset + subTUIndex), tuIterator.m_absPartIdxTURelCU, trWidthC, (TextType)chromaId);
}
}
while (isNextTUSection(&tuIterator));
@@ -397,8 +396,8 @@ void TEncEntropy::xEncodeTransform(TComD
}
else
{
- uint32_t trWidthC = width >> hChromaShift;
- uint32_t trHeightC = height >> vChromaShift;
+ uint32_t trWidthC = tuSize >> hChromaShift;
+ uint32_t trHeightC = tuSize >> vChromaShift;
const bool splitIntoSubTUs = (chFmt == CHROMA_422);
trHeightC = splitIntoSubTUs ? trHeightC >> 1 : trHeightC;
uint32_t curPartNum = cu->getPic()->getNumPartInCU() >> (depth << 1);
@@ -409,11 +408,11 @@ void TEncEntropy::xEncodeTransform(TComD
coeff_t* coeffChroma = (chromaId == 1) ? cu->getCoeffCb() : cu->getCoeffCr();
do
{
- uint32_t cbf = cu->getCbf(tuIterator.m_absPartIdxTURelCU, (TextType)chromaId, trIdx);
+ uint32_t cbf = cu->getCbf(tuIterator.m_absPartIdxTURelCU, (TextType)chromaId, trIdx + splitIntoSubTUs);
uint32_t subTUIndex = tuIterator.m_section * trWidthC * trHeightC;
if (cbf)
{
- m_entropyCoderIf->codeCoeffNxN(cu, (coeffChroma + offsetChroma + subTUIndex), tuIterator.m_absPartIdxTURelCU, trWidthC, depth, (TextType)chromaId);
+ m_entropyCoderIf->codeCoeffNxN(cu, (coeffChroma + offsetChroma + subTUIndex), tuIterator.m_absPartIdxTURelCU, trWidthC, (TextType)chromaId);
}
}
while (isNextTUSection(&tuIterator));
@@ -588,7 +587,7 @@ void TEncEntropy::encodeQP(TComDataCU* c
* \param width
* \param height
*/
-void TEncEntropy::encodeCoeff(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth, uint32_t width, uint32_t height, bool& bCodeDQP)
+void TEncEntropy::encodeCoeff(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth, uint32_t cuSize, bool& bCodeDQP)
{
uint32_t lumaOffset = absPartIdx << cu->getPic()->getLog2UnitSize() * 2;
uint32_t chromaOffset = lumaOffset >> (cu->getHorzChromaShift() + cu->getVertChromaShift());
@@ -613,30 +612,12 @@ void TEncEntropy::encodeCoeff(TComDataCU
}
uint32_t absPartIdxStep = cu->getPic()->getNumPartInCU() >> (depth << 1);
- xEncodeTransform(cu, lumaOffset, chromaOffset, absPartIdx, absPartIdxStep, depth, width, height, 0, bCodeDQP);
+ xEncodeTransform(cu, lumaOffset, chromaOffset, absPartIdx, absPartIdxStep, depth, cuSize, 0, bCodeDQP);
}
-void TEncEntropy::encodeCoeffNxN(TComDataCU* cu, coeff_t* coeff, uint32_t absPartIdx, uint32_t trWidth, uint32_t trHeight, uint32_t depth, TextType ttype)
+void TEncEntropy::encodeCoeffNxN(TComDataCU* cu, coeff_t* coeff, uint32_t absPartIdx, uint32_t trSize, TextType ttype)
{
- // This is for Transform unit processing. This may be used at mode selection stage for Inter.
- if (trWidth != trHeight)
- {
- uint32_t curPartNum = cu->getPic()->getNumPartInCU() >> (depth << 1);
- TComTURecurse tuIterator;
- initTUEntropySection(&tuIterator, VERTICAL_SPLIT, curPartNum, absPartIdx);
- trHeight >>= 1;
- uint32_t subTUSize = trWidth * trHeight;
-
- do
- {
- m_entropyCoderIf->codeCoeffNxN(cu, coeff + tuIterator.m_section * subTUSize, tuIterator.m_absPartIdxTURelCU, trWidth, depth, ttype);
- }
- while (isNextTUSection(&tuIterator));
- }
- else
- {
- m_entropyCoderIf->codeCoeffNxN(cu, coeff, absPartIdx, trWidth, depth, ttype);
- }
+ m_entropyCoderIf->codeCoeffNxN(cu, coeff, absPartIdx, trSize, ttype);
}
void TEncEntropy::estimateBit(estBitsSbacStruct* estBitsSBac, int trSize, TextType ttype)
diff -r c78bed701db4 -r ba2a9f61ea06 source/Lib/TLibEncoder/TEncEntropy.h
--- a/source/Lib/TLibEncoder/TEncEntropy.h Mon May 19 00:56:18 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncEntropy.h Fri May 16 19:20:46 2014 +0900
@@ -123,7 +123,7 @@ public:
virtual void codeRefFrmIdx(TComDataCU* cu, uint32_t absPartIdx, int eRefList) = 0;
virtual void codeMvd(TComDataCU* cu, uint32_t absPartIdx, int eRefList) = 0;
virtual void codeDeltaQP(TComDataCU* cu, uint32_t absPartIdx) = 0;
- virtual void codeCoeffNxN(TComDataCU* cu, coeff_t* pcCoef, uint32_t absPartIdx, uint32_t trSize, uint32_t depth, TextType ttype) = 0;
+ virtual void codeCoeffNxN(TComDataCU* cu, coeff_t* pcCoef, uint32_t absPartIdx, uint32_t trSize, TextType ttype) = 0;
virtual void codeSAOSign(uint32_t code) = 0;
virtual void codeSaoMaxUvlc(uint32_t code, uint32_t maxSymbol) = 0;
virtual void codeSaoMerge(uint32_t code) = 0;
@@ -198,13 +198,13 @@ public:
private:
- void xEncodeTransform(TComDataCU* cu, uint32_t offsetLumaOffset, uint32_t offsetChroma, uint32_t absPartIdx, uint32_t absPartIdxStep, uint32_t depth, uint32_t width, uint32_t height, uint32_t uiTrIdx, bool& bCodeDQP);
+ void xEncodeTransform(TComDataCU* cu, uint32_t offsetLumaOffset, uint32_t offsetChroma, uint32_t absPartIdx, uint32_t absPartIdxStep, uint32_t depth, uint32_t tuSize, uint32_t uiTrIdx, bool& bCodeDQP);
public:
- void encodeCoeff(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth, uint32_t width, uint32_t height, bool& bCodeDQP);
+ void encodeCoeff(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth, uint32_t cuSize, bool& bCodeDQP);
- void encodeCoeffNxN(TComDataCU* cu, coeff_t* pcCoeff, uint32_t absPartIdx, uint32_t trWidth, uint32_t trHeight, uint32_t depth, TextType ttype);
+ void encodeCoeffNxN(TComDataCU* cu, coeff_t* pcCoeff, uint32_t absPartIdx, uint32_t trSize, TextType ttype);
void estimateBit(estBitsSbacStruct* estBitsSbac, int trSize, TextType ttype);
void encodeSaoOffset(SaoLcuParam* saoLcuParam, uint32_t compIdx);
diff -r c78bed701db4 -r ba2a9f61ea06 source/Lib/TLibEncoder/TEncSbac.cpp
--- a/source/Lib/TLibEncoder/TEncSbac.cpp Mon May 19 00:56:18 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSbac.cpp Fri May 16 19:20:46 2014 +0900
@@ -2089,7 +2089,7 @@ void TEncSbac::codeLastSignificantXY(uin
}
More information about the x265-commits
mailing list