初学者,如有错误请批评指正。
截取的代码
Pel TComPrediction::predIntraGetPredValDC( const Pel* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight)
{
assert(iWidth > 0 && iHeight > 0);
Int iInd, iSum = 0;
Pel pDcVal;
//获取上面的参考像素
for (iInd = 0;iInd < iWidth;iInd++)
{
iSum += pSrc[iInd-iSrcStride];
}
//获取左侧的参考像素
for (iInd = 0;iInd < iHeight;iInd++)
{
iSum += pSrc[iInd*iSrcStride-1];
}
//不知道为什么iSum要加上iWidth
pDcVal = (iSum + iWidth) / (iWidth + iHeight);
return pDcVal;
}
pSrc这个指针中存放着我们所需要的像素。如果iWidth和iHeight都为4则pSrc指向的是下面的区域,坐标为数字表示坐标。
iSrcStride的值为2N+1。如果width和height为4则iSrcStride为9。最终预测值就为
(pSrc[-9]+pSrc[-8]+pSrc[-7]+pSrc[-6]+pSrc[-1]+pSrc[8]+pSrc[17]+pSrc[26])/iWidth + iHeight