xCompressCU函数会进行递归调用,其中的xCheckModeSplit函数会调用xCompressCU试着把当前cu进行更进一步的划分。
tempCS用来存储当前compress区域的各种模式下处理得到的数据,如果tempCS的cost小于bestCS,那么swap给bestCS;如果差于bestCS,那么丢弃tempCS中数据。
bestCS在xCompressCU函数中的任何位置,都用来存储到目前为止所得到的最优划分和最优模式数据。
//传入的tempLUT和bestLUT表示编码当前块之前所维护的HMVP列表信息
void EncCu::xCompressCU( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &partitioner
#if JVET_L0266_HMVP
, LutMotionCand *&tempMotCandLUTs
, LutMotionCand *&bestMotCandLUTs
#endif
)
{
Slice& slice = *tempCS->slice;
const PPS &pps = *tempCS->pps;
const SPS &sps = *tempCS->sps;
const uint32_t uiLPelX = tempCS->area.Y().lumaPos().x;
const uint32_t uiTPelY = tempCS->area.Y().lumaPos().y;
const unsigned wIdx = gp_sizeIdxInfo->idxFrom( partitioner.currArea().lwidth() );
//当前compress的cu的区域
const UnitArea currCsArea = clipArea( CS::getArea( *bestCS, bestCS->area, partitioner.chType ), *tempCS->picture );
if( m_pImvTempCS && !slice.isIntra() )
{
const unsigned maxMEPart = tempCS->pcv->only2Nx2N ? 1 : NUMBER_OF_PART_SIZES;
for( unsigned p = 0; p < maxMEPart; p++ )
{
tempCS->initSubStructure( *m_pImvTempCS[wIdx][p], partitioner.chType, partitioner.currArea(), false );
}
}
#if JVET_L0293_CPR
tempCS->chType = partitioner.chType;
bestCS->chType = partitioner.chType;
#endif
m_modeCtrl->initCULevel( partitioner, *tempCS ); //该函数对m_modeCtrl进行初始化,对需要test的各种模式进行压栈等操作
m_CurrCtx->start = m_CABACEstimator->getCtx();
m_cuChromaQpOffsetIdxPlus1 = 0;
if( slice.getUseChromaQpAdj()