所有LCU都是通过调用xCompressCU来实现其CU/PU划分. 然后通过其结果再调用 TEncCu::xencodeCU 函数来实现对所有CUs进行压缩编码.
xCompressCU大体可分为一下三块.
- 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来比较是否选用分割!