intra-prediction(2)
2018-11-18 本文已影响0人
阿King_
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所有,不得以任何理由任何形式转载