在使用HEVC的过程中,我们使用的视频的尺寸经常不是LCU的整数倍,HM中对LCU的数目又是怎么统计的呢?这个涉及到TComPicSym类下的成员函数create函数,具体贴代码如下:
Void TComPicSym::create ( Int iPicWidth, Int iPicHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth )
{
UInt i;
m_uhTotalDepth = uiMaxDepth;//最大深度
m_uiNumPartitions = 1<<(m_uhTotalDepth<<1);//划分小CU的数目,小CU为4x4
m_uiMaxCUWidth = uiMaxWidth;//最大CU宽度
m_uiMaxCUHeight = uiMaxHeight;//最大CU高度
m_uiMinCUWidth = uiMaxWidth >> m_uhTotalDepth;//最小CU宽度
m_uiMinCUHeight = uiMaxHeight >> m_uhTotalDepth;//最小CU高度
m_uiNumPartInWidth = m_uiMaxCUWidth / m_uiMinCUWidth;//
m_uiNumPartInHeight = m_uiMaxCUHeight / m_uiMinCUHeight;//
//图像宽度模运算最大CU宽度,根据结果,得到在宽度上CU的个数统计(1)
m_uiWidthInCU = ( iPicWidth %m_uiMaxCUWidth ) ? iPicWidth /m_uiMaxCUWidth + 1 : iPicWidth /m_uiMaxCUWidth;
//图像高度模运算最大CU高度,根据结果,得到在高度上CU的个数统计(2)
m_uiHeightInCU = ( iPicHeight%m_uiMaxCUHeight ) ? iPicHeight/m_uiMaxCUHeight + 1 : iPicHeight/m_uiMaxCUHeight;
m_uiNumCUsInFrame = m_uiWidthInCU * m_uiHeightInCU;//(1)和(2)结果相乘就是LCU的个数统计
m_apcTComDataCU = new TComDataCU*[m_uiNumCUsInFrame];
if (m_uiNumAllocatedSlice>0)
{
for ( i=0; i<m_uiNumAllocatedSlice ; i++ )
{
delete m_apcTComSlice[i];
}
delete [] m_apcTComSlice;
}
m_apcTComSlice = new TComSlice*[m_uiNumCUsInFrame*m_uiNumPartitions];
m_apcTComSlice[0] = new TComSlice;
m_uiNumAllocatedSlice = 1;
for ( i=0; i<m_uiNumCUsInFrame ; i++ )//
{
m_apcTComDataCU[i] = new TComDataCU;
m_apcTComDataCU[i]->create( m_uiNumPartitions, m_uiMaxCUWidth, m_uiMaxCUHeight, false, m_uiMaxCUWidth >> m_uhTotalDepth
#if ADAPTIVE_QP_SELECTION
, true
#endif
);
}
m_puiCUOrderMap = new UInt[m_uiNumCUsInFrame+1];
m_puiTileIdxMap = new UInt[m_uiNumCUsInFrame];
m_puiInverseCUOrderMap = new UInt[m_uiNumCUsInFrame+1];
for( i=0; i<m_uiNumCUsInFrame; i++ )
{
m_puiCUOrderMap[i] = i;
m_puiInverseCUOrderMap[i] = i;
}
m_saoParam = NULL;
}