All LCUs implement CU/PU division by calling xCompressCU, and then calling the TEncCu: xencodeCU function through the result to compress and encode all CUs.
XCompressCU can be divided into three parts.
[Cpp] view plaincopyprint?
Void TEncCu: xCompressCU ()
{
// The first block 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 );
}
// The second block 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 );
Block 3 // 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 whether split is used
XCheckBestMode (rpcBestCU, rpcTempCU, uiDepth );
}
The first two enable RDcost calculation for the LCU mode of the current layer. The last one implements the lower layer split calculation. Finally, xCheckBestMode is used to compare whether segmentation is selected!