HEVC代码阅读- - xPredIntraPlanar函数
var code = "708fbcd6-392d-4e1e-be86-072ebed56ce5"
xPredIntraPlanar函数
实现功能:Planar模式的预测
对应的公式:
Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height )
{
assert(width == height);
// k,l表示行和列
// bottomLeft和topRight表示左下、右上像素值
Int k, l, bottomLeft, topRight;
Int horPred;
Int leftColumn[MAX_CU_SIZE], topRow[MAX_CU_SIZE], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE];
UInt blkSize = width;
UInt offset2D = width;
// shift1D 表示 width对应的位数
// g_aucConvertToBit(x) 函数:log2(x)-2
UInt shift1D = g_aucConvertToBit[ width ] + 2;
UInt shift2D = shift1D + 1;
// 获取左侧列和上方行的参考数组
for(k=0;k<blkSize+1;k++)
{
// srcStride 表示 pSrc数组的跨度
topRow[k] = pSrc[k-srcStride];
leftColumn[k] = pSrc[k*srcStride-1];
}
// 准备插值所用的中间变量
bottomLeft = leftColumn[blkSize];
topRight = topRow[blkSize];
for (k=0;k<blkSize;k++)
{
bottomRow[k] = bottomLeft - topRow[k];
rightColumn[k] = topRight - leftColumn[k];
topRow[k] <<= shift1D;
leftColumn[k] <<= shift1D;
}
// 生成预测信号
for (k=0;k<blkSize;k++)
{
horPred = leftColumn[k] + offset2D;
for (l=0;l<blkSize;l++)
{
horPred += rightColumn[k];
topRow[l] += bottomRow[l];
// rpDst[k*dstStride+l]表示 (k,l)处的预测信号值
// 此数组为一维数组,使用dstStride(跨度)来间接的表示二维
rpDst[k*dstStride+l] = ( (horPred + topRow[l]) >> shift2D );
}
}
}