以下分析TComDataCU.cpp。这个cpp是很重要的,要分几次分析完,这是分析TComDataCU.cpp(一)。
Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH)
{
UInt col = m_uiCUPelX;
UInt row = m_uiCUPelY;
switch ( m_pePartSize[0] )
{
case SIZE_2NxN:
nPSW = getWidth(0);
nPSH = getHeight(0) >> 1;
xP = col;
yP = (partIdx ==0)? row: row + nPSH;
break;
case SIZE_Nx2N:
nPSW = getWidth(0) >> 1;
nPSH = getHeight(0);
xP = (partIdx ==0)? col: col + nPSW;
yP = row;
break;
case SIZE_NxN:
nPSW = getWidth(0) >> 1;
nPSH = getHeight(0) >> 1;
xP = col + (partIdx&0x1)*nPSW;
yP = row + (partIdx>>1)*nPSH;
break;
case SIZE_2NxnU:
nPSW = getWidth(0);
nPSH = ( partIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 );
xP = col;
yP = (partIdx ==0)? row: row + getHeight(0) - nPSH;
break;
case SIZE_2NxnD:
nPSW = getWidth(0);
nPSH = ( partIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2;
xP = col;
yP = (partIdx ==0)? row: row + getHeight(0) - nPSH;
break;
case SIZE_nLx2N:
nPSW = ( partIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 );
nPSH = getHeight(0);
xP = (partIdx ==0)? col: col + getWidth(0) - nPSW;
yP = row;
break;
case SIZE_nRx2N:
nPSW = ( partIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2;
nPSH = getHeight(0);
xP = (partIdx ==0)? col: col + getWidth(0) - nPSW;
yP = row;
break;
default:
assert ( m_pePartSize[0] == SIZE_2Nx2N );
nPSW = getWidth(0);
nPSH = getHeight(0);
xP = col ;
yP = row ;
break;
}
}
在 2N*N, 2N*nU,2N*nD 中,上面部分的partIdx 为0,下面部分为1;
在N*2N,nL*2N,nR*2N中, 左边部分的partIdx为0,右边部分为1;
在N*N中, 按四叉树的结构,partIdx 分别为0,1,2,3;
在2N*2N中, partIdx只能为0;
xP,yP的值是CU块左上角的绝对位置值,nPSW,nPSH是当前CU块的宽度和高度,记住,CU是可以嵌套的,CU包含CU,所以有xP,yP,nPSW,nPSH就能够唯一的确定CU块,
限于时间关系,今天先分析至此。