xRecurIntraCodingLumaQT是lumaIntra预测模式中最后进行RDO选最优模式的主要函数,xRecurIntraCodingLumaQT函数的作用就是计算一个具体的lumaIntra模式时的cost。
由于函数中涉及到很多的tu块变换方面的知识,没有太懂,以后对VTM变换量化方面看懂之后补充
本函数和VTM1中没有太大区别:
VTM1.0代码阅读:xRecurIntraCodingLumaQT函数
void IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &partitioner )
{
const UnitArea &currArea = partitioner.currArea(); //当前处理区域
const CodingUnit &cu = *cs.getCU(currArea.lumaPos(), partitioner.chType);
uint32_t currDepth = partitioner.currTrDepth; //当前tu的划分深度
const PPS &pps = *cs.pps;
const bool keepResi = pps.getPpsRangeExtension().getCrossComponentPredictionEnabledFlag() || KEEP_PRED_AND_RESI_SIGNALS;
bool bCheckFull = true; //是否需要进行tu划分
bool bCheckSplit = false;
bCheckFull = cs.pcv->noRQT && !partitioner.canSplit( TU_MAX_TR_SPLIT, cs );
bCheckSplit = cs.pcv->noRQT && partitioner.canSplit( TU_MAX_TR_SPLIT, cs );
uint32_t numSig = 0;
if( !cs.pcv->noRQT )
{
}
bool checkInitTrDepth = false, checkInitTrDepthTransformSkipWinner = false;
double dSingleCost = MAX_DOUBLE; //记录最优变换模式的cost等
Distortion uiSingleDistLuma = 0;
uint64_t singleFracBits = 0;
bool checkTransformSkip = pps.getUseTransformSkip(); //是否用TS模式
int bestModeId[MAX_NUM_COMPONENT] = {
0, 0, 0}; //Y/Cb/Cr三个通道的最优变换模式
uint8_t nNumTransformCands = cu.emtFlag ? 4 : 1; //4 is the number of transforms of emt
bool isAllIntra = m_pcEncCfg->getIntraPeriod() == 1;
uint8_t numTransformIndexCands = nNumTransformCands;
const TempCtx ctxStart ( m_CtxCache, m_CABACEstimator->getCtx() );
TempCtx ctxBest ( m_CtxCache );
CodingStructure *csSplit = nullptr;
CodingStructure *csFull = nullptr;
if( bCheckSplit )
{
csSplit = &cs;
}
else if( bCheckFull )
{
csFull = &cs;
}
if( bCheckFull ) //不进行tu的划分
{
csFull->cost = 0.0;
TransformUnit &tu = csFull->addTU( CS::getArea( *csFull, currArea, partitioner.chType ), partitioner.chType );
tu.depth = currDepth;
checkTransformSkip &= TU::hasTransformSkipFlag