H.266/VVC代码学习:DC模式和Planar模式
Planar模式和DC模式时两种特殊的角度模式,分别对应于模式号0和1。
一、DC模式
DC模式适用于大面积平坦区域,其预测值是通过计算左边和(或)上边参考像素的平均值获得的。
1.1、计算
DC模式预测值的计算和块的形状有关:
- 当宽等于高时,用左侧参考像素和上边参考像素的平均值作为预测值填充整个块
- 当宽大于高时,用上边参考像素的平均值作为预测值填充整个块
- 当宽小于高时,用左侧参考像素的平均值作为预测值填充整个块
1.2、代码
xPredIntraDc函数是DC模式的入口函数,主要功能是调用xGetPredValDc函数生成DC值,然后将DC值填充整个块
void IntraPrediction::xPredIntraDc( const CPelBuf &pSrc, PelBuf &pDst, const ChannelType channelType, const bool enableBoundaryFilter )
{//DC模式适用于大面积平坦区域,其预测值由其左侧和(或)上侧参考像素值得到。const Pel dcval = xGetPredValDc( pSrc, pDst );//生成DC值pDst.fill( dcval );//填充
}
xGetPredValDc函数用来生成DC值
// Function for calculating DC value of the reference samples used in Intra prediction
//NOTE: Bit-Limit - 25-bit source
Pel IntraPrediction::xGetPredValDc( const CPelBuf &pSrc, const Size &dstSize )
{CHECK( dstSize.width == 0 || dstSize.height == 0, "Empty area provided" );int idx, sum = 0;Pel dcVal;const int width = dstSize.width;const int height = dstSize.height;const auto denom = (width == height) ? (width << 1) : std::max(width,height);const auto divShift = floorLog2(denom);const auto divOffset = (denom >> 1);if ( width >= height )//宽大于高时,只用预测像素宽的平均值{for( idx = 0; idx < width; idx++ ){sum += pSrc.at(m_ipaParam.multiRefIndex + 1 + idx, 0);}}if ( width <= height )//宽小于高时,只用预测像素高的平均值{for( idx = 0; idx < height; idx++ ){sum += pSrc.at(m_ipaParam.multiRefIndex + 1 + idx, 1);}}dcVal = (sum + divOffset) >> divShift;//四舍五入求平均值return dcVal;
}
二、Planar模式
Planar模式适用于像素渐变的情况,即适用于像素值缓慢变换的区域。
2.1、计算
计算方法:根据a,b,c,d求加权平均,权重与距离有关;
具体计算公式如下:
横向预测值为 pred_h(x,y) = (width-x-1)*b + (x+1)*a
纵向预测值为 pred_v(x,y) = (height-y-1)*d + (y+1)*c
最终预测值为 pred(x,y) = (pred_h(x,y) + pred_v(x,y) + offset) >> shift
其中,x=0,1···width-1;y=0,1···height-1
2.2、代码
/** Function for deriving planar intra prediction. This function derives the prediction samples for planar mode (intra coding).*///NOTE: Bit-Limit - 24-bit source
void IntraPrediction::xPredIntraPlanar( const CPelBuf &pSrc, PelBuf &pDst )
{const uint32_t width = pDst.width;const uint32_t height = pDst.height;#if JVET_P0329_PLANAR_SIMPLIFICATIONconst uint32_t log2W = floorLog2( width );const uint32_t log2H = floorLog2( height );
#elseconst uint32_t log2W = floorLog2(width < 2 ? 2 : width);const uint32_t log2H = floorLog2(height < 2 ? 2 : height);
#endifint leftColumn[MAX_CU_SIZE + 1], topRow[MAX_CU_SIZE + 1], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE];const uint32_t offset = 1 << (log2W + log2H);//后面用于四舍五入// Get left and above reference column and row// 获得参考像素for( int k = 0; k < width + 1; k++ ){topRow[k] = pSrc.at( k + 1, 0 );//获取上一行的像素值}for( int k = 0; k < height + 1; k++ ){leftColumn[k] = pSrc.at(k + 1, 1);//获取左一列的像素值}/*** Planar模式横向的预测值为 pred_h(x,y) = (width-x-1)*leftcolumn(y) + (x+1)*topRight* Planar模式纵向的预测值为 pred_v(x,y) = (height-y-1)*topRow(x) + (y+1)*bottomLeft* 最终预测值为:pred(x,y) = (pred_h + pred_v + offset) >> shift** 代码里将上式调整为:pred_h(x,y) = width*leftcolumn(y) + (x+1)*[topRight-leftcolumn(y)]* pred_v(x,y) = height*topRow(x) + (y+1)*[bottomLeft-topRow(x)]**/// Prepare intermediate variables used in interpolation// 准备用于插值的中间变量int bottomLeft = leftColumn[height];//左边界下一个int topRight = topRow[width];//上边界右一位//填充四个边缘的值for( int k = 0; k < width; k++ ){bottomRow[k] = bottomLeft - topRow[k];topRow[k] = topRow[k] << log2H;//实现height*topRow(x) }for( int k = 0; k < height; k++ ){rightColumn[k] = topRight - leftColumn[k];leftColumn[k] = leftColumn[k] << log2W;//实现width*leftcolumn(y)}//填充Planar模式CU内部的像素值const uint32_t finalShift = 1 + log2W + log2H;const uint32_t stride = pDst.stride;Pel* pred = pDst.buf;//预测像素的首地址for( int y = 0; y < height; y++, pred += stride ){int horPred = leftColumn[y];//水平方向预测值for( int x = 0; x < width; x++ ){horPred += rightColumn[y];//累加,通过循环实现(x+1)*[topRight-leftcolumn(y)]topRow[x] += bottomRow[x];//累加,通过循环实现(y+1)*[bottomLeft-topRow(x)]int vertPred = topRow[x];//垂直方向预测值//水平方向预测像素的权重和高度有关,垂直方向的预测像素的权重和宽度有关pred[x] = ( ( horPred << log2H ) + ( vertPred << log2W ) + offset ) >> finalShift;//加权后求平均值,获得最终预测像素}}
}
H.266/VVC代码学习:DC模式和Planar模式相关推荐
- H.266/VVC代码学习20:角度预测入口 / 特殊模式的PDPC技术(predIntraAng)
1.predIntraAng函数 predIntraAng是帧内0~66这67种预测的入口.其中可细分为: 模式0:PLANAR模式 模式1:DC模式 模式2~66:角度模式 此函数在亮度预测和色度预 ...
- H.266/VVC代码学习21:帧内角度预测的实现 / 近对角模式的PDPC(xPredIntraAng)
xPredIntraAng函数的作用是对任意大小的块和任意模式,如何将参考像素的值根据其模式的角度填充进每一个像素. 下图是basketball drill的一个16*16的块,其预测模式为10(偏斜 ...
- H.266/VVC-VTM代码学习-帧内预测05-Angular模式下计算预测像素值xPredIntraAng
H.266/VVC专栏传送 上一篇:H.266/VVC-VTM代码学习-帧内预测04-Planar模式下计算预测像素值xPredIntraPlanar 下一篇:H.266/VVC-VTM代码学习-帧内 ...
- H.266/VVC代码学习17:帧内亮度预测的编解码(intra_luma_pred_modes)
引--亮度预测:H.266/VVC代码学习5:VTM4.0帧内亮度预测代码(estIntraPredLumaQT) 一.结论: 亮度编解码根据MPM列表的值分为两个阶段: 1 亮度模式在MPM列表中: ...
- H.266/VVC代码学习:帧内预测之角度预测函数(predIntraAng、xPredIntraAng)
predIntraAng函数 VTM中,帧内预测的角度预测的入口函数为predIntraAng函数,该函数主要是用于进行传统的帧内预测(Planar.DC.角度预测),然后对Planar和DC模式使用 ...
- H.266/VVC代码学习:xCompressCU函数
xCompressCU函数是用来进行CU划分(递归调用自身)以及模式选择. 首先调用m_modeCtrl->initCULevel函数初始化模式选择列表,由堆栈控制,将当前CU可以划分的模式(四 ...
- H.266/VVC代码学习32:VTM5.0解码端最上层函数
解码部分的研究不像编码端那样需要精雕细琢,但如果想研究一个内容划分或选择模式等的最终结果是怎样,那么应该从解码端入手.下面让我们来学习解码端的框架及最上层的三个函数. 文章目录 1 main() 2 ...
- H.266/VVC代码学习:MIP技术相关代码之initIntraMip函数
initIntraMip函数主要是对参考像素进行下采样并为MIP矩阵乘法准备输入数据,函数结构如下: MIP根据块尺寸可以分为以下三种情况: 块尺寸 下采样后的边界长度 m_reducedBdry ...
- H.266/VVC技术学习之帧内模式编码
在HEVC中,支持33种角度模式.DC模式和Planar模式,为了减少编码比特,使用长度为3的最可能模式列表.在VVC中,引入了ISP模式.MRL模式.MIP模式等,帧内模式编码时需要先对这些模式的f ...
最新文章
- 市值破万亿美金的苹果 近年在AI上搞了些新动作
- MVC进阶学习--HtmlHelper控件解析(一)
- apache+tomcat 子目录映射成子域名
- tms570 can 接收大量数据_超全!嵌入式必懂的CAN总线一文讲通了
- boost::gil::packed_channel_value用法的测试程序
- autoconf常用宏
- 多线程编程 RW_LOCK 读写锁
- 1042: 筛法求素数
- LeetCode第一题两数之和---JavaScript
- Atiitt 关于不可替代性的思索 目录 1.1. 不可替代性与 这份工作谁都能干无关	1 1.2. 不可替代性未必很好,因为其岗位可能很累或者收入很低	1 1.3. 不可替代性与报酬无关	1 2
- 人体姿态估计综述 2020最全
- wp文件转shp_【转载】将E00文件转换成shp文件
- 基础-07-八大疑问词
- Axure RP 9 for Mac 中文版 专业产品原型设计工具
- 淘宝评论数据抓取简记
- 信用社pb通用记账_信用社会计记账采用的是()。A、收付实现制B、权责发生制C、借贷记账法D、单式记账法...
- bcdedit添加linux引导,用BCDEdit编辑启动菜单
- 使用visio创建跨职能流程图
- 前端架构设计第六课工程化构建、编译、运行
- 使用python预测基金_使用python先知3 1创建预测