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)
{
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 UInt currDepth = partitioner.currDepth;
const PartSplit split = getPartSplit( encTestMode ); //获取划分模式
CHECK( split == CU_DONT_SPLIT, "No proper split provided!" );
tempCS->initStructData( qp, bIsLosslessMode ); //tempCS中的数据进行清空初始化
partitioner.splitCurrArea( split, *tempCS ); //将tempCS表示区域按照encTestMode划分模式进行划分
m_CABACEstimator->getCtx() = m_CurrCtx->start;
m_CurrCtx++;
tempCS->getRecoBuf().fill( 0 );
do
{
const auto &subCUArea = partitioner.currArea(); //获取划分后的子cu区域
if( tempCS->picture->Y().contains( subCUArea.lumaPos(