xCheckModeSplit函数在xCompressCU中被调用,用于进行QT,BT,TT的划分模式处理,encTestMode可以获取具体需要test的划分模式。
xCheckModeSplit在依据划分模式,将当前tempCS区域划分为相应的多个子cu区域之后,对每个子cu分别调用xCompressCU函数进行处理;
获取各个子cu的最优划分和最优模式,递归返回之后将bestSubCS的最优数据copy给tempCS,然后进行下一个子cu的递归处理,获取最优模式;
再将bestSubCS的最优数据copy给tempCS,直至xCompressCU处理完所有子cu之后,tempCS就包含encTestMode划分模式的最优数据;
最后xCheckBestMode比较tempCS和bestCS的cost,最优模式存入bestCS。
void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &partitioner, const EncTestMode& encTestMode
#if JVET_L0266_HMVP
, LutMotionCand* &tempMotCandLUTs
, LutMotionCand* &bestMotCandLUTs
, UnitArea parArea
#endif
)
{
const int qp = encTestMode.qp;
const PPS &pps = *tempCS->pps;
const Slice &slice = *tempCS->slice;
const bool bIsLosslessMode = false; // False at this level. Next level down may set it to true.
const int oldPrevQp = tempCS->prevQP[partitioner.chType];
const uint32_t currDepth = partitioner.currDepth;
#if JVET_L0266_HMVP
const unsigned wParIdx = gp_sizeIdxInfo->idxFrom(parArea.lwidth());
const unsigned hParIdx = gp_sizeIdxInfo->idxFrom(parArea.lheight());
#if JVET_L0293_CPR
if (tempCS->chType == CHANNEL_TYPE_LUMA)
#endif //将tempLUT首先转存入splitTempLUT,函数最后又存回tempLUT。这样可以使tempCS的这些数据始终不发生变化,而只让bestCS(bestLUT)的数据产生变化,存储最优数据
tempCS->slice->copyMotionLUTs(tempMotCandLUTs, m_pSplitTempMotLUTs[wParIdx][hParIdx]);
#endif
const PartSplit split = getPartSplit( encTestMode ); //获取划分模式
CHECK( split == CU_DONT_SPLIT, "No proper split provided!" );
tempCS->initStructData( qp, bIsLosslessMode ); //tempCS中的数据进行清空初始化
m_CABACEstimator->getCtx() = m_CurrCtx->start;
if( tempCS->sps->getSpsNext().getUseQTBT() ) //QTBT时,提前判断能否划分
{
const TempCtx ctxStartSP( m_CtxCache, SubCtx( Ctx::SplitFlag, m_CABACEstimator->getCtx() ) );
const TempCtx ctxStartBT( m_CtxCache, SubCtx( Ctx::BTSplitFlag, m_CABACEstimator->getCtx() ) );
m_CABACEstimator->resetBits();
if( partitioner.getImplicitSplit( *tempCS ) != CU_QUAD_SPLIT )
{
if( partitioner.canSplit( CU_QUAD_SPLIT, *tempCS ) )