[x265-commits] [x265] cleanup bReusePred, unify absTUPartIdx to absPartIdx
Satoshi Nakagawa
nakagawa424 at oki.com
Thu May 22 17:29:36 CEST 2014
details: http://hg.videolan.org/x265/rev/b7e6b21a5906
branches:
changeset: 6909:b7e6b21a5906
user: Satoshi Nakagawa <nakagawa424 at oki.com>
date: Mon May 19 18:14:50 2014 +0900
description:
cleanup bReusePred, unify absTUPartIdx to absPartIdx
Subject: [x265] TEncSearch: readability nits
details: http://hg.videolan.org/x265/rev/73e8188a48ca
branches:
changeset: 6910:73e8188a48ca
user: Steve Borho <steve at borho.org>
date: Thu May 22 08:51:36 2014 -0500
description:
TEncSearch: readability nits
diffstat:
source/Lib/TLibCommon/TComRom.h | 4 +-
source/Lib/TLibEncoder/TEncSearch.cpp | 409 ++++++++++++++++-----------------
source/Lib/TLibEncoder/TEncSearch.h | 10 +-
source/encoder/compress.cpp | 2 +-
4 files changed, 210 insertions(+), 215 deletions(-)
diffs (truncated from 1047 to 300 lines):
diff -r 34187fb932d3 -r 73e8188a48ca source/Lib/TLibCommon/TComRom.h
--- a/source/Lib/TLibCommon/TComRom.h Thu May 22 08:08:14 2014 -0500
+++ b/source/Lib/TLibCommon/TComRom.h Thu May 22 08:51:36 2014 -0500
@@ -92,8 +92,8 @@ extern uint32_t g_maxCUSize;
extern uint32_t g_maxCUDepth;
extern uint32_t g_addCUDepth;
-#define MAX_TS_WIDTH 4
-#define MAX_TS_HEIGHT 4
+#define LOG2_MAX_TS_SIZE 2 // TODO: RExt
+#define MAX_TS_SIZE (1 << LOG2_MAX_TS_SIZE)
extern const uint32_t g_puOffset[8];
diff -r 34187fb932d3 -r 73e8188a48ca source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp Thu May 22 08:08:14 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp Thu May 22 08:51:36 2014 -0500
@@ -133,9 +133,9 @@ bool TEncSearch::init(Encoder* cfg, RDCo
m_qtTempTransformSkipFlag[1] = m_qtTempTransformSkipFlag[0] + numPartitions;
m_qtTempTransformSkipFlag[2] = m_qtTempTransformSkipFlag[0] + numPartitions * 2;
- CHECKED_MALLOC(m_qtTempTUCoeffY, coeff_t, MAX_TS_WIDTH * MAX_TS_HEIGHT * 3);
- m_qtTempTUCoeffCb = m_qtTempTUCoeffY + MAX_TS_WIDTH * MAX_TS_HEIGHT;
- m_qtTempTUCoeffCr = m_qtTempTUCoeffY + MAX_TS_WIDTH * MAX_TS_HEIGHT * 2;
+ CHECKED_MALLOC(m_qtTempTUCoeffY, coeff_t, MAX_TS_SIZE * MAX_TS_SIZE * 3);
+ m_qtTempTUCoeffCb = m_qtTempTUCoeffY + MAX_TS_SIZE * MAX_TS_SIZE;
+ m_qtTempTUCoeffCr = m_qtTempTUCoeffY + MAX_TS_SIZE * MAX_TS_SIZE * 2;
return m_qtTempTransformSkipYuv.create(g_maxCUSize, g_maxCUSize, cfg->param->internalCsp);
@@ -410,8 +410,7 @@ void TEncSearch::xIntraCodingLumaBlk(TCo
TComYuv* fencYuv,
TComYuv* predYuv,
ShortYuv* resiYuv,
- uint32_t& outDist,
- bool bReusePred)
+ uint32_t& outDist)
{
uint32_t fullDepth = cu->getDepth(0) + trDepth;
uint32_t tuSize = cu->getCUSize(0) >> trDepth;
@@ -435,15 +434,6 @@ void TEncSearch::xIntraCodingLumaBlk(TCo
uint32_t reconIPredStride = cu->getPic()->getPicYuvRec()->getStride();
bool useTransformSkip = !!cu->getTransformSkip(absPartIdx, TEXT_LUMA);
- if (!bReusePred)
- {
- //===== init availability pattern =====
- uint32_t lumaPredMode = cu->getLumaIntraDir(absPartIdx);
- TComPattern::initAdiPattern(cu, absPartIdx, trDepth, m_predBuf, m_refAbove, m_refLeft, m_refAboveFlt, m_refLeftFlt, lumaPredMode);
- //===== get prediction signal =====
- predIntraLumaAng(lumaPredMode, pred, stride, tuSize);
- }
-
//===== get residual signal =====
X265_CHECK(!((uint32_t)(size_t)fenc & (tuSize - 1)), "fenc alignment check fail\n");
X265_CHECK(!((uint32_t)(size_t)pred & (tuSize - 1)), "pred alignment check fail\n");
@@ -501,8 +491,7 @@ void TEncSearch::xIntraCodingChromaBlk(T
TComYuv* predYuv,
ShortYuv* resiYuv,
uint32_t& outDist,
- uint32_t chromaId,
- bool bReusePred)
+ uint32_t chromaId)
{
uint32_t fullDepth = cu->getDepth(0) + trDepth;
uint32_t trSizeLog2 = g_convertToBit[cu->getSlice()->getSPS()->getMaxCUSize() >> fullDepth] + 2;
@@ -541,24 +530,6 @@ void TEncSearch::xIntraCodingChromaBlk(T
bool useTransformSkipChroma = !!cu->getTransformSkip(absPartIdx, ttype);
int part = partitionFromSizes(tuSize, tuSize);
- if (!bReusePred)
- {
- //===== init availability pattern =====
- TComPattern::initAdiPatternChroma(cu, absPartIdx, trDepth, m_predBuf, chromaId);
- pixel* chromaPred = TComPattern::getAdiChromaBuf(chromaId, tuSize, m_predBuf);
-
- uint32_t chromaPredMode = cu->getChromaIntraDir(absPartIdx);
- //===== update chroma mode =====
- if (chromaPredMode == DM_CHROMA_IDX)
- {
- uint32_t lumaLCUIdx = (chFmt == CHROMA_444) ? absPartIdx : absPartIdx & (~((1 << (2 * g_addCUDepth)) - 1));
- chromaPredMode = cu->getLumaIntraDir(lumaLCUIdx);
- }
- chromaPredMode = (chFmt == CHROMA_422) ? g_chroma422IntraAngleMappingTable[chromaPredMode] : chromaPredMode;
- //===== get prediction signal =====
- predIntraChromaAng(chromaPred, chromaPredMode, pred, stride, tuSize, chFmt);
- }
-
//===== get residual signal =====
X265_CHECK(!((uint32_t)(size_t)fenc & (tuSize - 1)), "fenc alignment check fail\n");
X265_CHECK(!((uint32_t)(size_t)pred & (tuSize - 1)), "pred alignment check fail\n");
@@ -670,38 +641,49 @@ void TEncSearch::xRecurIntraCodingQT(TCo
uint64_t singleCost = MAX_INT64;
uint32_t singleDistY = 0;
uint32_t singleCbfY = 0;
- bool checkTransformSkip = cu->getSlice()->getPPS()->getUseTransformSkip();
- uint32_t widthTransformSkip = cu->getCUSize(0) >> trDepth;
- uint32_t heightTransformSkip = cu->getCUSize(0) >> trDepth;
int bestModeId = 0;
- checkTransformSkip &= (widthTransformSkip == 4 && heightTransformSkip == 4);
- checkTransformSkip &= (!cu->getCUTransquantBypass(0));
- checkTransformSkip &= (!((cu->getQP(0) == 0) && (cu->getSlice()->getSPS()->getUseLossless())));
- if (m_cfg->param->bEnableTSkipFast)
- {
- checkTransformSkip &= (cu->getPartitionSize(absPartIdx) == SIZE_NxN);
- }
-
if (bCheckFull)
{
- if (checkTransformSkip == true)
+ uint32_t tuSize = 1 << trSizeLog2;
+
+ bool checkTransformSkip = (cu->getSlice()->getPPS()->getUseTransformSkip() &&
+ trSizeLog2 <= LOG2_MAX_TS_SIZE &&
+ !cu->getCUTransquantBypass(0));
+ if (checkTransformSkip)
+ {
+ checkTransformSkip &= (!((cu->getQP(0) == 0) && (cu->getSlice()->getSPS()->getUseLossless())));
+ if (m_cfg->param->bEnableTSkipFast)
+ {
+ checkTransformSkip &= (cu->getPartitionSize(absPartIdx) == SIZE_NxN);
+ }
+ }
+
+ uint32_t stride = fencYuv->getStride();
+ pixel* pred = predYuv->getLumaAddr(absPartIdx);
+
+ //===== init availability pattern =====
+ uint32_t lumaPredMode = cu->getLumaIntraDir(absPartIdx);
+ TComPattern::initAdiPattern(cu, absPartIdx, trDepth, m_predBuf, m_refAbove, m_refLeft, m_refAboveFlt, m_refLeftFlt, lumaPredMode);
+ //===== get prediction signal =====
+ predIntraLumaAng(lumaPredMode, pred, stride, tuSize);
+
+ if (checkTransformSkip)
{
//----- store original entropy coding status -----
m_rdGoOnSbacCoder->store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
- uint32_t singleDistYTmp = 0;
- uint32_t singleCbfYTmp = 0;
- uint64_t singleCostTmp = 0;
- const int firstCheckId = 0;
+ uint32_t singleDistYTmp = 0;
+ uint32_t singleCbfYTmp = 0;
+ uint64_t singleCostTmp = 0;
+ const int firstCheckId = 0;
for (int modeId = firstCheckId; modeId < 2; modeId++)
{
singleDistYTmp = 0;
cu->setTransformSkipSubParts(modeId, TEXT_LUMA, absPartIdx, fullDepth);
//----- code luma block with given intra prediction mode and store Cbf-----
- bool bReusePred = modeId != firstCheckId;
- xIntraCodingLumaBlk(cu, trDepth, absPartIdx, fencYuv, predYuv, resiYuv, singleDistYTmp, bReusePred);
+ xIntraCodingLumaBlk(cu, trDepth, absPartIdx, fencYuv, predYuv, resiYuv, singleDistYTmp);
singleCbfYTmp = cu->getCbf(absPartIdx, TEXT_LUMA, trDepth);
//----- determine rate and r-d cost -----
if (modeId == 1 && singleCbfYTmp == 0)
@@ -717,10 +699,10 @@ void TEncSearch::xRecurIntraCodingQT(TCo
if (singleCostTmp < singleCost)
{
- singleCost = singleCostTmp;
+ singleCost = singleCostTmp;
singleDistY = singleDistYTmp;
singleCbfY = singleCbfYTmp;
- bestModeId = modeId;
+ bestModeId = modeId;
if (bestModeId == firstCheckId)
{
xStoreIntraResultQT(cu, trDepth, absPartIdx);
@@ -854,13 +836,10 @@ void TEncSearch::residualTransformQuantI
int maxTuSize = cu->getSlice()->getSPS()->getQuadtreeTULog2MaxSize();
int isIntraSlice = (cu->getSlice()->getSliceType() == I_SLICE);
- if (m_cfg->param->rdPenalty && !isIntraSlice)
+ if (m_cfg->param->rdPenalty == 2 && !isIntraSlice)
{
// if maximum RD-penalty don't check TU size 32x32
- if (m_cfg->param->rdPenalty == 2)
- {
- bCheckFull = (trSizeLog2 <= X265_MIN(maxTuSize, 4));
- }
+ bCheckFull = (trSizeLog2 <= X265_MIN(maxTuSize, 4));
}
if (bCheckFull)
{
@@ -1200,13 +1179,14 @@ void TEncSearch::xRecurIntraChromaCoding
if (trMode == trDepth)
{
int chFmt = cu->getChromaFormat();
- bool checkTransformSkip = cu->getSlice()->getPPS()->getUseTransformSkip();
uint32_t trSizeLog2 = g_convertToBit[cu->getSlice()->getSPS()->getMaxCUSize() >> fullDepth] + 2;
+ uint32_t trSizeCLog2 = trSizeLog2 - m_hChromaShift;
uint32_t actualTrDepth = trDepth;
if ((trSizeLog2 == 2) && !(chFmt == CHROMA_444))
{
X265_CHECK(trDepth > 0, "invalid trDepth\n");
actualTrDepth--;
+ trSizeCLog2++;
uint32_t qpdiv = cu->getPic()->getNumPartInCU() >> ((cu->getDepth(0) + actualTrDepth) << 1);
bool bFirstQ = ((absPartIdx % qpdiv) == 0);
if (!bFirstQ)
@@ -1216,9 +1196,12 @@ void TEncSearch::xRecurIntraChromaCoding
}
uint32_t tuSize = cu->getCUSize(0) >> (actualTrDepth + m_hChromaShift);
+ uint32_t stride = fencYuv->getCStride();
const bool splitIntoSubTUs = (chFmt == CHROMA_422);
- checkTransformSkip &= (tuSize <= 4);
+ bool checkTransformSkip = (cu->getSlice()->getPPS()->getUseTransformSkip() &&
+ trSizeCLog2 <= LOG2_MAX_TS_SIZE &&
+ !cu->getCUTransquantBypass(0));
if (m_cfg->param->bEnableTSkipFast)
{
@@ -1243,6 +1226,24 @@ void TEncSearch::xRecurIntraChromaCoding
do
{
+ uint32_t absPartIdxC = tuIterator.m_absPartIdxTURelCU;
+ pixel* pred = (chromaId == 1) ? predYuv->getCbAddr(absPartIdxC) : predYuv->getCrAddr(absPartIdxC);
+
+ //===== init availability pattern =====
+ TComPattern::initAdiPatternChroma(cu, absPartIdxC, actualTrDepth, m_predBuf, chromaId);
+ pixel* chromaPred = TComPattern::getAdiChromaBuf(chromaId, tuSize, m_predBuf);
+
+ uint32_t chromaPredMode = cu->getChromaIntraDir(absPartIdxC);
+ //===== update chroma mode =====
+ if (chromaPredMode == DM_CHROMA_IDX)
+ {
+ uint32_t lumaLCUIdx = (chFmt == CHROMA_444) ? absPartIdxC : absPartIdxC & (~((1 << (2 * g_addCUDepth)) - 1));
+ chromaPredMode = cu->getLumaIntraDir(lumaLCUIdx);
+ }
+ chromaPredMode = (chFmt == CHROMA_422) ? g_chroma422IntraAngleMappingTable[chromaPredMode] : chromaPredMode;
+ //===== get prediction signal =====
+ predIntraChromaAng(chromaPred, chromaPredMode, pred, stride, tuSize, chFmt);
+
if (checkTransformSkip)
{
// use RDO to decide whether Cr/Cb takes TS
@@ -1260,14 +1261,12 @@ void TEncSearch::xRecurIntraChromaCoding
for (int chromaModeId = firstCheckId; chromaModeId < 2; chromaModeId++)
{
- cu->setTransformSkipPartRange(chromaModeId, (TextType)chromaId, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);
+ cu->setTransformSkipPartRange(chromaModeId, (TextType)chromaId, absPartIdxC, tuIterator.m_absPartIdxStep);
singleDistCTmp = 0;
- bool bReusePred = chromaModeId != firstCheckId;
-
- xIntraCodingChromaBlk(cu, trDepth, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep, fencYuv, predYuv, resiYuv, singleDistCTmp, (TextType)chromaId, bReusePred);
-
- singleCbfCTmp = cu->getCbf(tuIterator.m_absPartIdxTURelCU, (TextType)chromaId, trDepth);
+ xIntraCodingChromaBlk(cu, trDepth, absPartIdxC, tuIterator.m_absPartIdxStep, fencYuv, predYuv, resiYuv, singleDistCTmp, chromaId);
+
+ singleCbfCTmp = cu->getCbf(absPartIdxC, (TextType)chromaId, trDepth);
if (chromaModeId == 1 && singleCbfCTmp == 0)
{
@@ -1276,7 +1275,7 @@ void TEncSearch::xRecurIntraChromaCoding
}
else
{
- uint32_t bitsTmp = xGetIntraBitsQTChroma(cu, trDepth, tuIterator.m_absPartIdxTURelCU, chromaId, splitIntoSubTUs);
+ uint32_t bitsTmp = xGetIntraBitsQTChroma(cu, trDepth, absPartIdxC, chromaId, splitIntoSubTUs);
singleCostTmp = m_rdCost->calcRdCost(singleDistCTmp, bitsTmp);
}
@@ -1289,7 +1288,7 @@ void TEncSearch::xRecurIntraChromaCoding
if (bestModeId == firstCheckId)
{
- xStoreIntraResultChromaQT(cu, trDepth, tuIterator.m_absPartIdxTURelCU, (TextType)chromaId, splitIntoSubTUs);
+ xStoreIntraResultChromaQT(cu, trDepth, absPartIdxC, (TextType)chromaId, splitIntoSubTUs);
m_rdGoOnSbacCoder->store(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
}
}
@@ -1301,13 +1300,13 @@ void TEncSearch::xRecurIntraChromaCoding
if (bestModeId == firstCheckId)
{
- xLoadIntraResultChromaQT(cu, trDepth, tuIterator.m_absPartIdxTURelCU, (TextType)chromaId, splitIntoSubTUs);
- cu->setCbfPartRange(singleCbfC << trDepth, (TextType)chromaId, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);
+ xLoadIntraResultChromaQT(cu, trDepth, absPartIdxC, (TextType)chromaId, splitIntoSubTUs);
+ cu->setCbfPartRange(singleCbfC << trDepth, (TextType)chromaId, absPartIdxC, tuIterator.m_absPartIdxStep);
m_rdGoOnSbacCoder->load(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
}
- cu->setTransformSkipPartRange(bestModeId, (TextType)chromaId, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);
+ cu->setTransformSkipPartRange(bestModeId, (TextType)chromaId, absPartIdxC, tuIterator.m_absPartIdxStep);
outDist += singleDistC;
@@ -1318,8 +1317,8 @@ void TEncSearch::xRecurIntraChromaCoding
}
else
More information about the x265-commits
mailing list