所有LCU都是通過調用xCompressCU來實現其CU/PU劃分. 然後通過其結果再調用 TEncCu::xencodeCU 函數來實現對所有CUs進行壓縮編碼.
xCompressCU大體可分為一下三塊.
[cpp] view plaincopyprint?
Void TEncCu::xCompressCU()
{
//第一塊 for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++)
// do inter modes, SKIP and 2Nx2N
if( rpcBestCU->getSlice()->getSliceType() != I_SLICE )
{
xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode );
}
//第二塊 for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++)
// do inter modes, NxN, 2NxN, and Nx2N
if( rpcBestCU->getSlice()->getSliceType() != I_SLICE )
{
xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN );
xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N );
xCheckRDCostInter ( rpcBestCU, rpcTempCU, SIZE_2NxN );
}
//! Try AMP (SIZE_2NxnU, SIZE_2NxnD, SIZE_nLx2N, SIZE_nRx2N)
// do normal intra modes // speedup for inter frames
{
xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN );
}
// test PCM
xCheckIntraPCM (rpcBestCU, rpcTempCU);
第三塊//for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++)
// further split
for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
{
if ( rpcBestCU->isIntra(0) )
xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth, SIZE_NONE );
else
xCompressCU( pcSubBestPartCU, pcSubTempPartCU, uhNextDepth, rpcBestCU->getPartitionSize(0) );
}
//check是否使用split
xCheckBestMode( rpcBestCU, rpcTempCU, uiDepth);
}
前2塊實現對本層LCU的模式選擇RDcost計算, 最後一塊實現下層分割的計算,最後通過xCheckBestMode來比較是否選用分割!