Void TEncCu::init( TEncTop* pcEncTop )
{
m_pcEncCfg = pcEncTop;
m_pcPredSearch = pcEncTop->getPredSearch();
m_pcTrQuant = pcEncTop->getTrQuant();
m_pcRdCost = pcEncTop->getRdCost();
m_pcEntropyCoder = pcEncTop->getEntropyCoder();
m_pcBinCABAC = pcEncTop->getBinCABAC();
m_pppcRDSbacCoder = pcEncTop->getRDSbacCoder();
m_pcRDGoOnSbacCoder = pcEncTop->getRDGoOnSbacCoder();
m_pcRateCtrl = pcEncTop->getRateCtrl();
}
// ====================================================================================================================
// Public member functions
// ====================================================================================================================
/**
\param pCtu pointer of CU data class
*/
Void TEncCu::compressCtu( TComDataCU* pCtu )
{
// initialize CU data
m_ppcBestCU[0]->initCtu( pCtu->getPic(), pCtu->getCtuRsAddr() );
m_ppcTempCU[0]->initCtu( pCtu->getPic(), pCtu->getCtuRsAddr() );
// analysis of CU
DEBUG_STRING_NEW(sDebug)
统计图片CU的划分情况
// TComPic* pcPic = pCtu->getPic();
// const TComSPS &sps = pcPic->getPicSym()->getSPS();
// const UInt maxCuWidth = sps.getMaxCUWidth();
// xCompressCU( m_ppcBestCU[0], m_ppcTempCU[0], 0 DEBUG_STRING_PASS_INTO(sDebug) );
// DEBUG_STRING_OUTPUT(std::cout, sDebug)
printf("\n---------------CTU Address(Raster Scan): %d-----------------\n", pCtu->getDepth());//这里改了一点,原来为pcCU->getAddr()
// printf("\n---------------CU starts--------------\n");
// int iCount = 0;
// int iWidthInPart = maxCuWidth >> 2;
// for (int i = 0; i < pCtu->getTotalNumPart(); i++)
// {
// if ((iCount & (iWidthInPart - 1)) == 0)
// printf("\n");
// printf("%d ", pCtu->getDepth(g_auiRasterToZscan[i]));
// iCount++;
// }
// printf("\n---------------CU ends--------------\n");
// printf("\n---------------TU starts--------------\n");
// iCount = 0;
// for (int i = 0; i < pCtu->getTotalNumPart(); i++)
// {
// if ((iCount & (iWidthInPart - 1)) == 0)
// printf("\n");
// printf("%d ",pCtu->getTransformIdx(g_auiRasterToZscan[i]) + pCtu->getDepth(g_auiRasterToZscan[i]));
// iCount++;
// }
// printf("\n---------------TU ends--------------\n");
//*************下面代码是我加入的,用于matlab显示CU划分情况********************
//Add the code from here
//ofstream DepthInfo;
//TComDataCU* DepthCU = m_ppcBestCU[0];
//DepthInfo.open("BestDepth.txt", ios::app);
//for (UInt iPartitionNum = 0; iPartitionNum < DepthCU->getTotalNumPart(); iPartitionNum++)
//{
// DepthInfo << DepthCU->getDepth()[iPartitionNum];
//}
//DepthInfo.close();
*************上面代码是我加入的,用于显示CU划分情况********************
#if ADAPTIVE_QP_SELECTION
if( m_pcEncCfg->getUseAdaptQpSelect() )
{
if(pCtu->getSlice()->getSliceType()!=I_SLICE) //IIII
{
xCtuCollectARLStats( pCtu );
}
}
#endif
}
/** \param pCtu pointer of CU data class
*/
Void TEncCu::encodeCtu ( TComDataCU* pCtu )
{
if ( pCtu->getSlice()->getPPS()->getUseDQP() )
{
setdQPFlag(true);
}
if ( pCtu->getSlice()->getUseChromaQpAdj() )
{
setCodeChromaQpAdjFlag(true);
}
// Encode CU data
xEncodeCU( pCtu, 0, 0 );
}
// ====================================================================================================================
// Protected member functions
// ====================================================================================================================
//! Derive small set of test modes for AMP encoder speed-up
#if AMP_ENC_SPEEDUP
#if AMP_MRG
Void TEncCu::deriveTestModeAMP (TComDataCU *pcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver, Bool &bTestMergeAMP_Hor, Bool &bTestMergeAMP_Ver)
#else
Void TEncCu::deriveTestModeAMP (TComDataCU *pcBestCU, PartSize eParentPartSize, Bool &bTestAMP_Hor, Bool &bTestAMP_Ver)
#endif
{
if ( pcBestCU->getPartitionSize(0) == SIZE_2NxN )
{
bTestAMP_Hor = true;
}
else if ( pcBestCU->getPartitionSize(0) == SIZE_Nx2N )
{
bTestAMP_Ver = true;
}
else if ( pcBestCU->getPartitionSize(0) == SIZE_2Nx2N && pcBestCU->getMergeFlag(0) == false && pcBestCU->isSkipped(0) == false )
{
bTestAMP_Hor = true;
bTestAMP_Ver = true;
}
#if AMP_MRG
//! Utilizing the partition size of parent PU
if ( eParentPartSize >= SIZE_2NxnU && eParentPartSize <= SIZE_nRx2N )
{
bTestMergeAMP_Hor = true;
bTestMergeAMP_Ver = true;
}
if ( eParentPartSize == NUMBER_OF_PART_SIZES ) //! if parent is intra
{
if ( pcBestCU->getPartitionSize(0) == SIZE_2NxN )
{
bTestMergeAMP_Hor = true;
}
else if ( pcBestCU->getPartitionSize(0) == SIZE_Nx2N )
{
bTestMergeAMP_Ver = true;
}
}
if ( pcBestCU->getPartitionSize(0) == SIZE_2Nx2N && pcBestCU->isSkipped(0) == false )
{
bTestMergeAMP_Hor = true;
bTestMergeAMP_Ver = true;
}
if ( pcBestCU->getWidth(0) == 64 )
{
bTestAMP_Hor = false;
bTestAMP_Ver = false;
}
#else
//! Utilizing the partition size of parent PU
if ( eParentPartSize >= SIZE_2NxnU && eParentPartSize <= SIZE_nRx2N )
{
bTestAMP_Hor = true;
bTestAMP_Ver = true;
}
if ( eParentPartSize == SIZE_2Nx2N )
{
bTestAMP_Hor = false;
bTestAMP_Ver = false;
}
#endif
}
#endif
(我把加的代码给注释掉了)以上是参考以前大神的笔记自己实现,得到的结果比较多,可以自己设置生成一个文件,方便自己统计