HEVC的帧内预测(2)

来源:互联网 发布:淘宝淘盘有手机版app吗 编辑:程序博客网 时间:2024/04/30 13:59

接着上一篇文章HEVC的帧内预测(1)继续讨论。


相邻参考值的获取


帧内预测用到的相邻参考值(neighbouringsamples,p[ x ][ y ]),其几何位置如下图所示。( xTbCmp, yTbCmp )表示当前变换块相对于图像左上角的坐标。


当前tb(current transform block)的尺寸为TbS,neigbour samples数量为2*TbS(上边1行),左边1列(2*TbS),左上角1个像素。数量为nTbS * 4 + 1。


对于每一个参考值p[x][y]来说,其可获得性(available)有以下伪代码:


if((availableN == FALSE)||\( (CuPredMode[ xNbY ][ yNbY ]!=MODE_INTRA)&&\(constrained_intra_pred_flag==1))){   sample p[ x ][ y ] is marked as "not available for intra prediction"}else{   sample p[ x ][ y ] is marked as "available for intra prediction";}

其中,availableN在HEVC的帧内预测(1)中有详细介绍。

然后,对于每一个参考值p[x][y],(x = −1, y = −1..nTbS * 2 −1 and x = 0..nTbS * 2−1,  y = −1),根据条件做出以下修改:

if(all samples p[ x ][ y ] are marked as "not available for intra prediction"){   p[ x ][ y ] = 1 << ( bitDepth −1 )  //for all samples p[ x ][ y ]}else if(at least one but not all samples p[ x ][ y ] are marked as "not available for intra prediction"){   if(p[-1][nTbS*2-1] is marked as "not available for intra prediction")   {      search from x = −1, y = nTbS * 2 −1 to x = −1, y = −1, then from x = 0, y = −1 to x = nTbS * 2 −1, y = −1;      {           if(p[ x ][ y ] marked as "available for intra prediction")               p[ −1 ][ nTbS * 2 −1 ]= p[ x ][ y ],search end      }      search from x = −1, y = nTbS * 2 −2 to x = −1, y = −1      {           if(p[x][y] is marked as "not available for intra prediction")           p[x][y+1]=p[x][y]      }      for(x = 0..nTbS * 2 −1, y = −1)      {         if(p[ x ][ y ] is marked as "not available for intra prediction")             p[x-1][y]=p[x][y]       }}



参考值滤波

参数filterFlag,由以下伪代码得到其值。

if((predModeIntra == INTRA_DC)||(nTbS == 4)){   filterFlag = 0;}else{   minDistVerHor=Min( Abs( predModeIntra −26 ), Abs( predModeIntra −10 ) )   intraHorVerDistThres[ nTbS ] is specified in Table A   if(minDistVerHor>intraHorVerDistThres[ nTbS ])      filterFlag = 1    else      filterFlag = 0}
其中,table A如下:



当filterFlag为1时,引入变量biIntFlag。有以下伪代码。

if((strong_intra_smoothing_enabled_flag == 1)&&(nTbS == 32)&&\(Abs(p[−1][−1]+p[nTbS*2−1][−1]–2*p[nTbS−1][−1])<(1<<(BitDepthY −5)))&&\(Abs(p[−1][−1]+p[−1][nTbS*2−1]–2*p[−1][nTbS−1]) < (1 << (BitDepthY −5))){   biIntFlag = 1}
对参考值进行滤波:

if(biIntFlag == 1){   pF[−1][ −1 ] = p[ −1 ][ −1 ]    pF[−1][y] = ((63 −y) * p[−1][−1] + (y + 1) * p[ −1 ][ 63 ] + 32 ) >> 6 for y = 0..62    pF[ −1 ][ 63 ] = p[ −1 ][ 63 ]    pF[x][−1] = ((63 −x) * p[−1][−1] + (x + 1) * p[ 63 ][ −1 ] + 32 ) >> 6 for x = 0..62   pF[ 63 ][ −1 ] = p[ 63 ][ −1 ]}else{   pF[−1 ][−1 ] = ( p[ −1 ][ 0 ] + 2 * p[ −1 ][ −1 ] + p[ 0 ][ −1 ] + 2 ) >> 2   pF[−1][y] = (p[−1][y + 1]+2*p[−1][y] + p[−1][y −1]+ 2)>>2 for y = 0..nTbS*2 −2    pF[ −1 ][ nTbS * 2 −1 ] = p[ −1 ][ nTbS * 2 −1 ] }

其中,p[x][y]为4.2中得到的参考值,pF[x][y]为滤波后的参考值。

而当filterFlag为0时,则不进行滤波操作。


各种模式的预测值的计算


INTRA_PLANAR模式


预测值predSamples[ x ][ y ]的计算如下:

predSamples[x][y] = ((nTbS −1 −x ) * p[−1][ y] + ( x + 1 ) * p[nTbS][−1] + (nTbS−1−y)*p[x][−1]+(y+1)*p[−1][nTbS]+nTbS )>> (Log2(nTbS)+1)

INTRA_DC模式


预测值predSamples[ x ][ y ]的计算,引入变量dcVal。
                    

if((cIdx==0)&&(nTbS<32)){   predSamples[ 0 ][ 0 ] = ( p[ −1 ][ 0 ] + 2 * dcVal + p[ 0 ][ −1 ] + 2 ) >> 2     predSamples[ x ][ 0 ] = ( p[ x ][ −1 ] + 3 * dcVal + 2 ) >> 2, with x = 1..nTbS −1   predSamples[ 0 ][ y ] = ( p[ −1 ][ y ] + 3 * dcVal + 2 ) >> 2, with y = 1..nTbS −1   predSamples[ x ][ y ] = dcVal, with x, y = 1..nTbS −1}else{   predSamples[ x ][ y ] = dcVal, with x, y = 0..nTbS −1}


intra_angular2...intra_angular34模式


各种预测模式(2~34)的角度见下图。




引入变量intraPredAngle和invAngle。根据下表和predModeIntra(帧内预测模式)可以得到他们的值。




引入数组ref[x](参考值序列),有以下伪代码:

if(predModeIntra>=18){   ref[x] = p[ −1 + x ][ −1 ], with x = 0..nTbS}if(intraPredAngle < 0){   if((( nTbS * intraPredAngle ) >> 5) < −1)      ref[x]= p[ −1 ][ −1 + ( ( x * invAngle + 128 ) >> 8 ) ]        with x = −1..( nTbS * intraPredAngle ) >> 5   else      ref[ x ] = p[ −1 + x ][ −1 ], with x = nTbS + 1..2 * nTbS}

引入变量iIdx和iFact,有以下的伪代码:


iIdx = ( ( x + 1 ) * intraPredAngle ) >> 5iFact = ( ( x + 1 ) * intraPredAngle ) & 31if(iFact != 0)   predSamples[x][y]=((32−iFact)*ref[y+iIdx+1] + iFact*ref[y + iIdx + 2] + 16 >>5 else   predSamples[ x ][ y ] = ref[ y + iIdx + 1 ]if(predModeIntra == 10){   predSamples[x][y] =Clip1Y( p[ −1 ][ y ] + ((p[ x ][ −1 ] −p[ −1 ][ −1 ] ) >>1))}


至此,所有帧内预测模式的预测值predSamples[x][y]都计算完成了。


0 0
原创粉丝点击