HM编码器代码阅读(13)——帧间预测之一inter模式

入口函数xCheckRDCostInter。
主要流程如下:
(1)得到当前的深度。
(2)调用predInterSearch,进行ME(运动估计)和MC(运动补偿)。
(3)调用encodeResAndCalcRdInterCU,根据预测值,求出残差,然后进行TU的划分,然后进行变换、量化等操作以及RD代价的计算。
(4)调用xCheckBestMode选择最好的模式。
#if AMP_MRG
Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bUseMRG)
#else
Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize )
#endif
{
	// 深度
	UChar uhDepth = rpcTempCU->getDepth( 0 );

	rpcTempCU->setDepthSubParts( uhDepth, 0 );

	rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );

	rpcTempCU->setPartSizeSubParts  ( ePartSize,  0, uhDepth );
	rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );

    // 对于帧间预测,需要在参考帧选择一个最合适的位置给它,进行预测编码
    // 并计算出了残差以及其他信息
#if AMP_MRG
	rpcTempCU->setMergeAMP (true);
	m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], false, bUseMRG );
#else  
	m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] );
#endif

#if AMP_MRG
	if ( !rpcTempCU->getMergeAMP() )
	{
		return;
	}
#endif

    // 下一步的计算
	m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false );
	rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );

	xCheckDQP( rpcTempCU );
	xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
}


你可能感兴趣的:(C++,编码,h.265,HEVC)