如上图所示,以亮度信号为例,解释了内存中扩展图像和原始图像之间的存储关系,以及计算关系,图像存储一份,色度信号与之类似。
Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth )
{
m_iPicWidth = iPicWidth;
m_iPicHeight = iPicHeight;
// --> After config finished!
m_iCuWidth = uiMaxCUWidth;
m_iCuHeight = uiMaxCUHeight;
Int numCuInWidth = m_iPicWidth / m_iCuWidth + (m_iPicWidth % m_iCuWidth != 0);
Int numCuInHeight = m_iPicHeight / m_iCuHeight + (m_iPicHeight % m_iCuHeight != 0);
m_iLumaMarginX = g_uiMaxCUWidth + 16; // for 16-byte alignment
m_iLumaMarginY = g_uiMaxCUHeight + 16; // margin for 8-tap filter and infinite padding
m_iChromaMarginX = m_iLumaMarginX>>1;
m_iChromaMarginY = m_iLumaMarginY>>1;
m_apiPicBufY = (Pel*)xMalloc( Pel, ( m_iPicWidth + (m_iLumaMarginX <<1)) * ( m_iPicHeight + (m_iLumaMarginY <<1)));
m_apiPicBufU = (Pel*)xMalloc( Pel, ((m_iPicWidth >> 1) + (m_iChromaMarginX<<1)) * ((m_iPicHeight >> 1) + (m_iChromaMarginY<<1)));
m_apiPicBufV = (Pel*)xMalloc( Pel, ((m_iPicWidth >> 1) + (m_iChromaMarginX<<1)) * ((m_iPicHeight >> 1) + (m_iChromaMarginY<<1)));
m_piPicOrgY = m_apiPicBufY + m_iLumaMarginY * getStride() + m_iLumaMarginX;
m_piPicOrgU = m_apiPicBufU + m_iChromaMarginY * getCStride() + m_iChromaMarginX;
m_piPicOrgV = m_apiPicBufV + m_iChromaMarginY * getCStride() + m_iChromaMarginX;
m_bIsBorderExtended = false;
m_cuOffsetY = new Int[numCuInWidth * numCuInHeight];
m_cuOffsetC = new Int[numCuInWidth * numCuInHeight];
for (Int cuRow = 0; cuRow < numCuInHeight; cuRow++)
{
for (Int cuCol = 0; cuCol < numCuInWidth; cuCol++)
{
m_cuOffsetY[cuRow * numCuInWidth + cuCol] = getStride() * cuRow * m_iCuHeight + cuCol * m_iCuWidth;
m_cuOffsetC[cuRow * numCuInWidth + cuCol] = getCStride() * cuRow * (m_iCuHeight / 2) + cuCol * (m_iCuWidth / 2);
}
}
m_buOffsetY = new Int[(size_t)1 << (2 * uiMaxCUDepth)];
m_buOffsetC = new Int[(size_t)1 << (2 * uiMaxCUDepth)];
for (Int buRow = 0; buRow < (1 << uiMaxCUDepth); buRow++)
{
for (Int buCol = 0; buCol < (1 << uiMaxCUDepth); buCol++)
{
m_buOffsetY[(buRow << uiMaxCUDepth) + buCol] = getStride() * buRow * (uiMaxCUHeight >> uiMaxCUDepth) + buCol * (uiMaxCUWidth >> uiMaxCUDepth);
m_buOffsetC[(buRow << uiMaxCUDepth) + buCol] = getCStride() * buRow * (uiMaxCUHeight / 2 >> uiMaxCUDepth) + buCol * (uiMaxCUWidth / 2 >> uiMaxCUDepth);
}
}
return;
}