HEVC学习(九) —— 帧内预测系列之六

来源:互联网 发布:妮维雅舒安系列 知乎 编辑:程序博客网 时间:2024/06/07 10:52

这篇博客写得不错,觉得对我对大家刚开始学习时会有帮助,于是转载之。

原文地址:http://blog.csdn.net/hevc_cjl/article/details/8242448


上次留下两个帧内预测中最为重要的两个函数xPredIntraPlanar和xPredIntraAng,本文先介绍第一个函数。先看代码及相应的注释:

[cpp] view plaincopy
  1. /** Function for deriving planar intra prediction. 
  2.  * \param pSrc pointer to reconstructed sample array 
  3.  * \param srcStride the stride of the reconstructed sample array 
  4.  * \param rpDst reference to pointer for the prediction sample array 
  5.  * \param dstStride the stride of the prediction sample array 
  6.  * \param width the width of the block 
  7.  * \param height the height of the block 
  8.  * 
  9.  * This function derives the prediction samples for planar mode (intra coding). 
  10.  */  
  11. Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height )  
  12. {  
  13.   assert(width == height);  
  14.   
  15.   Int k, l, bottomLeft, topRight;  
  16.   Int horPred;  
  17.   Int leftColumn[MAX_CU_SIZE], topRow[MAX_CU_SIZE], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE];  
  18.   UInt blkSize = width;  
  19.   UInt offset2D = width;  
  20.   UInt shift1D = g_aucConvertToBit[ width ] + 2;  //!< 加2才是得到实际的宽度取Log2的结果   
  21.   UInt shift2D = shift1D + 1;  
  22.   
  23.   // Get left and above reference column and row  
  24.   for(k=0;k<blkSize+1;k++)  
  25.   {  
  26.     topRow[k] = pSrc[k-srcStride];   //!< p[x][-1], x = 0, 1, 2, ..., nT,即上边界  
  27.     leftColumn[k] = pSrc[k*srcStride-1]; //!< p[-1][y], y = -1, 0, 1, 2, ..., nT,即左边界  
  28.   }  
  29.   
  30.   // Prepare intermediate variables used in interpolation  
  31.   bottomLeft = leftColumn[blkSize]; //!< 左下边界  
  32.   topRight   = topRow[blkSize]; //!< 右上边界  
  33.   for (k=0;k<blkSize;k++)  
  34.   {  
  35.     bottomRow[k]   = bottomLeft - topRow[k];  
  36.     rightColumn[k] = topRight   - leftColumn[k];  
  37.     topRow[k]      <<= shift1D;  
  38.     leftColumn[k]  <<= shift1D;  
  39.   }  
  40. <span style="color:#000000;"//! 上边那个循环过程参考下图</span>  

[cpp] view plaincopy
  1.  //! planar预测模式分析:首先,获取待预测CU的上邻块的最后一行topRow以及右上点topRight,  
  2.  //!  待预测CU的左邻块的最右一列leftColumn以及左下点bottomLeft,  
  3.  //!  接着,根据以上获得的样点值计算用于求预测样点值的中间变量---待预测CU的右邻列和下邻行,  
  4.  //!  右邻列对应点的计算方法为前面获得的右上点topRight减去leftColumn对应点(右上-左),  
  5.  //!  下邻行对应点的计算方法为前面获得的左下点bottomLeft减去topRow对应点(左下-上),  
  6.  //!  接下来,对于待预测CU中的每一个样点值(x, y),它的预测值由(x, -1), (x, nT), (-1, y), (nT, y)  
  7.  //!  四个点取平均值获得(其实不是直接地取平均,表达起来比较麻烦,姑且这么说吧)  
  8.   
  9.  //! 对照着下面代码参考下图  
  10.   // Generate prediction signal  
  11.   for (k=0;k<blkSize;k++)  
  12.   {  
  13.     horPred = leftColumn[k] + offset2D; //!< leftColumn[k] * uiWidth + uiWidth,最后加上uiWidth应该是为了取平均时进行四舍五入  
  14.     for (l=0;l<blkSize;l++)  
  15.     {  
  16.       horPred += rightColumn[k];  
  17.       topRow[l] += bottomRow[l]; //!< topRow[l] * uiWidth  
  18.       rpDst[k*dstStride+l] = ( (horPred + topRow[l]) >> shift2D );  // draft 8.4.4.2.4,公式(8-33)  
  19.     }  
  20.   }  
  21. }  

 

至此,还剩下最后一个函数尚未介绍,留待下一篇文章。

 

(转载请注明出处。)

 


阅读全文
0 0
原创粉丝点击