intra-prediction(2)

I_4x4的9种模式

pixel布局

7种模式的方向
enum {
  VERT_PRED            = 0,
  HOR_PRED             = 1,
  DC_PRED              = 2,
  DIAG_DOWN_LEFT_PRED  = 3,
  DIAG_DOWN_RIGHT_PRED = 4,
  VERT_RIGHT_PRED      = 5,
  HOR_DOWN_PRED        = 6,
  VERT_LEFT_PRED       = 7,
  HOR_UP_PRED          = 8
} I4x4PredModes;

0.vertical

vertical方向

只需要用到ABCD,且有
a=e=i=m = A
b=f=j=n = B
c=g=k=o = C
d=h=i=p = D

1.horizontal

horizontal方向

只需要用到IJKL,且有
a=b=c=d = I
e=f=g=h = J
i=j=k=l = K
m=n=o=p = L

static inline void get_i4x4_horizontal(imgpel **cur_pred, imgpel *PredPel)
{
  int i;

  for (i=0; i < BLOCK_SIZE; i++)
  {
    cur_pred[i][0]  =
    cur_pred[i][1]  =
    cur_pred[i][2]  =
    cur_pred[i][3]  = (imgpel) (&P_I)[i];
  }
}

2.DC

DC布局
  • 左边和上边都可用
    mean = sum(A+B+C+D+I+J+K+L+4)>> 3
  • 只有左边可用
    mean = sum(I+J+K+L+2) >>2
  • 只有上边可用
    mean = sum(A+B+C+D+2) >>2
  • 都不可用
    mean = 128
#define BLOCK_SHIFT            2
static inline void get_i4x4_dc(imgpel **cur_pred, imgpel *PredPel, int left_available, int up_available)
{
  int i, j, s0 = 0;
  if (up_available && left_available)
  {
    // no edge
    s0 = (P_A + P_B + P_C + P_D + P_I + P_J + P_K + P_L + 4) >> (BLOCK_SHIFT + 1);
  }
  else if (!up_available && left_available)
  {
    // upper edge
    s0 = (P_I + P_J + P_K + P_L + 2) >> BLOCK_SHIFT;
  }
  else if (up_available && !left_available)
  {
    // left edge
    s0 = (P_A + P_B + P_C + P_D + 2) >> BLOCK_SHIFT;
  }
  else //if (!up_available && !left_available)
  {
    // top left corner, nothing to predict from
    s0 = P_A; // P_A already set to p_Vid->dc_pred_value;
  }

  for (j=0; j < BLOCK_SIZE; j++)
  {
    for (i=0; i < BLOCK_SIZE; i++)
      cur_pred[j][i] = (imgpel) s0;
  }
}

3.Diagonal down left

down left方向

要用到ABCDEFGH,当EFDH不可用时,令E=F=G=H = D

if (block_available_up_right)
  {
    memcpy(&PredPel[5], &img_enc[pix_c.pos_y][pix_c.pos_x], BLOCK_SIZE * sizeof(imgpel));
  }
  else  //EFGH arenot available
  {
    P_E = P_F = P_G = P_H = P_D;
  }

a=
b=e=
c=f=i=
d=g=j=m=
h=n=k=
i=o=
p=

static inline void get_i4x4_downleft(imgpel **cur_pred, imgpel *PredPel)
{
  cur_pred[0][0] = (imgpel) ((P_A + P_C + ((P_B) << 1) + 2) >> 2);
  cur_pred[0][1] =
  cur_pred[1][0] = (imgpel) ((P_B + P_D + ((P_C) << 1) + 2) >> 2);
  cur_pred[0][2] =
  cur_pred[1][1] =
  cur_pred[2][0] = (imgpel) ((P_C + P_E + ((P_D) << 1) + 2) >> 2);
  cur_pred[0][3] =
  cur_pred[1][2] =
  cur_pred[2][1] =
  cur_pred[3][0] = (imgpel) ((P_D + P_F + ((P_E) << 1) + 2) >> 2);
  cur_pred[1][3] =
  cur_pred[2][2] =
  cur_pred[3][1] = (imgpel) ((P_E + P_G + ((P_F)<<1) + 2) >> 2);
  cur_pred[2][3] =
  cur_pred[3][2] = (imgpel) ((P_F + P_H + ((P_G)<<1) + 2) >> 2);
  cur_pred[3][3] = (imgpel) ((P_G + 3*(P_H) + 2) >> 2);
}

4.Diagonal down right

down right方向

要用到ABCDIJLKL
m=
i=n=
e=j=o=
a=f=k=p=
b=g=l=
c=h=
d=

static inline void get_i4x4_downright(imgpel **cur_pred, imgpel *PredPel)
{
  cur_pred[3][0] = (imgpel) ((P_L + 2*P_K + P_J + 2) >> 2);
  cur_pred[2][0] =
  cur_pred[3][1] = (imgpel) ((P_K + 2*P_J + P_I + 2) >> 2);
  cur_pred[1][0] =
  cur_pred[2][1] =
  cur_pred[3][2] = (imgpel) ((P_J + 2*P_I + P_X + 2) >> 2);
  cur_pred[0][0] =
  cur_pred[1][1] =
  cur_pred[2][2] =
  cur_pred[3][3] = (imgpel) ((P_I + 2*P_X + P_A + 2) >> 2);
  cur_pred[0][1] =
  cur_pred[1][2] =
  cur_pred[2][3] = (imgpel) ((P_X + 2*P_A + P_B + 2) >> 2);
  cur_pred[0][2] =
  cur_pred[1][3] = (imgpel) ((P_A + 2*P_B + P_C + 2) >> 2);
  cur_pred[0][3] = (imgpel) ((P_B + 2*P_C + P_D + 2) >> 2);
}

5.Vertical right

vertical right方向

要用到ABCDIJKL

static inline void get_i4x4_vertright(imgpel **cur_pred, imgpel *PredPel)
{
  cur_pred[0][0] =
  cur_pred[2][1] = (imgpel) ((P_X + P_A + 1) >> 1);
  cur_pred[0][1] =
  cur_pred[2][2] = (imgpel) ((P_A + P_B + 1) >> 1);
  cur_pred[0][2] =
  cur_pred[2][3] = (imgpel) ((P_B + P_C + 1) >> 1);
  cur_pred[0][3] = (imgpel) ((P_C + P_D + 1) >> 1);  
  cur_pred[1][0] =
  cur_pred[3][1] = (imgpel) ((P_I + 2*P_X + P_A + 2) >> 2);
  cur_pred[1][1] =
  cur_pred[3][2] = (imgpel) ((P_X + 2*P_A + P_B + 2) >> 2);
  cur_pred[1][2] =
  cur_pred[3][3] = (imgpel) ((P_A + 2*P_B + P_C + 2) >> 2);
  cur_pred[1][3] = (imgpel) ((P_B + 2*P_C + P_D + 2) >> 2);
  cur_pred[2][0] = (imgpel) ((P_X + 2*P_I + P_J + 2) >> 2);
  cur_pred[3][0] = (imgpel) ((P_I + 2*P_J + P_K + 2) >> 2);
}

6.Horizontal down

horizontal down方向

要用到ABCDIJKL

static inline void get_i4x4_hordown(imgpel **cur_pred, imgpel *PredPel)
{
  cur_pred[0][0] =
  cur_pred[1][2] = (imgpel) ((P_X + P_I + 1) >> 1);
  cur_pred[0][1] =
  cur_pred[1][3] = (imgpel) ((P_I + 2*P_X + P_A + 2) >> 2);
  cur_pred[0][2] = (imgpel) ((P_X + 2*P_A + P_B + 2) >> 2);
  cur_pred[0][3] = (imgpel) ((P_A + 2*P_B + P_C + 2) >> 2);
  cur_pred[1][0] =
  cur_pred[2][2] = (imgpel) ((P_I + P_J + 1) >> 1);
  cur_pred[1][1] =
  cur_pred[2][3] = (imgpel) ((P_X + 2*P_I + P_J + 2) >> 2);
  cur_pred[2][0] =
  cur_pred[3][2] = (imgpel) ((P_J + P_K + 1) >> 1);
  cur_pred[2][1] =
  cur_pred[3][3] = (imgpel) ((P_I + 2*P_J + P_K + 2) >> 2);
  cur_pred[3][0] = (imgpel) ((P_K + P_L + 1) >> 1);
  cur_pred[3][1] = (imgpel) ((P_J + 2*P_K + P_L + 2) >> 2);
}

7.Vertical left

vertical left方向

要用到ABCDEFG,当EFG不可用时,令E=F=G = D

static inline void get_i4x4_vertleft(imgpel **cur_pred, imgpel *PredPel)
{
  cur_pred[0][0] = (imgpel) ((P_A + P_B + 1) >> 1);
  cur_pred[0][1] =
  cur_pred[2][0] = (imgpel) ((P_B + P_C + 1) >> 1);
  cur_pred[0][2] =
  cur_pred[2][1] = (imgpel) ((P_C + P_D + 1) >> 1);
  cur_pred[0][3] =
  cur_pred[2][2] = (imgpel) ((P_D + P_E + 1) >> 1);
  cur_pred[2][3] = (imgpel) ((P_E + P_F + 1) >> 1);
  cur_pred[1][0] = (imgpel) ((P_A + ((P_B)<<1) + P_C + 2) >> 2);
  cur_pred[1][1] =
  cur_pred[3][0] = (imgpel) ((P_B + ((P_C)<<1) + P_D + 2) >> 2);
  cur_pred[1][2] =
  cur_pred[3][1] = (imgpel) ((P_C + ((P_D)<<1) + P_E + 2) >> 2);
  cur_pred[1][3] =
  cur_pred[3][2] = (imgpel) ((P_D + ((P_E)<<1) + P_F + 2) >> 2);
  cur_pred[3][3] = (imgpel) ((P_E + ((P_F)<<1) + P_G + 2) >> 2);
}

8.Horizontal up

horizontal up方向

要用到IJKL

static inline void get_i4x4_horup(imgpel **cur_pred, imgpel *PredPel)
{
  cur_pred[0][0] = (imgpel) ((P_I + P_J + 1) >> 1);
  cur_pred[0][1] = (imgpel) ((P_I + 2*P_J + P_K + 2) >> 2);
  cur_pred[0][2] =
  cur_pred[1][0] = (imgpel) ((P_J + P_K + 1) >> 1);
  cur_pred[0][3] =
  cur_pred[1][1] = (imgpel) ((P_J + 2*P_K + P_L + 2) >> 2);
  cur_pred[1][2] =
  cur_pred[2][0] = (imgpel) ((P_K + P_L + 1) >> 1);
  cur_pred[1][3] =
  cur_pred[2][1] = (imgpel) ((P_K + 2*P_L + P_L + 2) >> 2);
  cur_pred[3][0] =
  cur_pred[2][2] =
  cur_pred[2][3] =
  cur_pred[3][1] =
  cur_pred[3][2] =
  cur_pred[3][3] = (imgpel) P_L;
}

文章归doc.liang@qq.com所有,不得以任何理由任何形式转载

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • "use strict";function _classCallCheck(e,t){if(!(e instanc...
    久些阅读 2,263评论 0赞 2
  • __ __ |__| _____ __ __ ┌...
    wangchuang2017阅读 7,284评论 2赞 1
  • 上一章目录下一章(待续) 顾谦现在身体还很虚弱,在宴会上坐了一会儿,就开始昏昏欲睡。 幸好永成侯也没有停留到最后,...
    lbgen1阅读 307评论 0赞 0
  • “高考可能是我们青春时代经历过的最有悲壮史诗意味的大事件了。其实对于漫长的人生路来说,它只是一座小土丘。只不过,任...
    沫曦姑娘阅读 512评论 0赞 1
  • 1、 七宝在微博登了一条招亲的消息,说谁能用一句话撩到她,就和谁相亲。七宝是谁?大众女神,长腿照一发,立刻涌来一波...
    巫其格阅读 9,855评论 95赞 244

友情链接更多精彩内容