这个函数主要是用来计算镇内预测的一个PU单元的DC值
//psrc为预测单元的第一个像素,isrcstride为政府图片的宽度,pDcVal为返回的DC值
Pel TComPrediction::predIntraGetPredValDC( const Pel* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, ChannelType channelType, ChromaFormat format, Bool bAbove, Bool bLeft )
{assert(iWidth > 0 && iHeight > 0);
Int iInd, iSum = 0;
Pel pDcVal;
//计算预测单元above的像素值总和
if (bAbove)
{
for (iInd = 0;iInd < iWidth;iInd++)
{
iSum += pSrc[iInd-iSrcStride];
}
}
//计算预测单元左半部分的值总和
if (bLeft){
for (iInd = 0;iInd < iHeight;iInd++)
{
iSum += pSrc[iInd*iSrcStride-1];
}
}
//算这些值的平均值
if (bAbove && bLeft)
{
pDcVal = (iSum + iWidth) / (iWidth + iHeight);
}
else if (bAbove)
{
pDcVal = (iSum + iWidth/2) / iWidth;
}
else if (bLeft)
{
pDcVal = (iSum + iHeight/2) / iHeight;
}
else
{
pDcVal = pSrc[-1]; // Default DC value already calculated and placed in the prediction array if no neighbors are available
}
return pDcVal;
}