📄 transform8x8.c
字号:
cur_pred[0][1] =
cur_pred[2][2] =
cur_pred[4][3] =
cur_pred[6][4] = (imgpel) ((P_A + P_B + 1) >> 1);
cur_pred[0][2] =
cur_pred[2][3] =
cur_pred[4][4] =
cur_pred[6][5] = (imgpel) ((P_B + P_C + 1) >> 1);
cur_pred[0][3] =
cur_pred[2][4] =
cur_pred[4][5] =
cur_pred[6][6] = (imgpel) ((P_C + P_D + 1) >> 1);
cur_pred[0][4] =
cur_pred[2][5] =
cur_pred[4][6] =
cur_pred[6][7] = (imgpel) ((P_D + P_E + 1) >> 1);
cur_pred[0][5] =
cur_pred[2][6] =
cur_pred[4][7] = (imgpel) ((P_E + P_F + 1) >> 1);
cur_pred[0][6] =
cur_pred[2][7] = (imgpel) ((P_F + P_G + 1) >> 1);
cur_pred[0][7] = (imgpel) ((P_G + P_H + 1) >> 1);
cur_pred[1][0] =
cur_pred[3][1] =
cur_pred[5][2] =
cur_pred[7][3] = (imgpel) ((P_Q + P_A + (P_Z << 1) + 2) >> 2);
cur_pred[1][1] =
cur_pred[3][2] =
cur_pred[5][3] =
cur_pred[7][4] = (imgpel) ((P_Z + P_B + (P_A << 1) + 2) >> 2);
cur_pred[1][2] =
cur_pred[3][3] =
cur_pred[5][4] =
cur_pred[7][5] = (imgpel) ((P_A + P_C + (P_B << 1) + 2) >> 2);
cur_pred[1][3] =
cur_pred[3][4] =
cur_pred[5][5] =
cur_pred[7][6] = (imgpel) ((P_B + P_D + (P_C << 1) + 2) >> 2);
cur_pred[1][4] =
cur_pred[3][5] =
cur_pred[5][6] =
cur_pred[7][7] = (imgpel) ((P_C + P_E + (P_D << 1) + 2) >> 2);
cur_pred[1][5] =
cur_pred[3][6] =
cur_pred[5][7] = (imgpel) ((P_D + P_F + (P_E << 1) + 2) >> 2);
cur_pred[1][6] =
cur_pred[3][7] = (imgpel) ((P_E + P_G + (P_F << 1) + 2) >> 2);
cur_pred[1][7] = (imgpel) ((P_F + P_H + (P_G << 1) + 2) >> 2);
cur_pred[2][0] =
cur_pred[4][1] =
cur_pred[6][2] = (imgpel) ((P_R + P_Z + (P_Q << 1) + 2) >> 2);
cur_pred[3][0] =
cur_pred[5][1] =
cur_pred[7][2] = (imgpel) ((P_S + P_Q + (P_R << 1) + 2) >> 2);
cur_pred[4][0] =
cur_pred[6][1] = (imgpel) ((P_T + P_R + (P_S << 1) + 2) >> 2);
cur_pred[5][0] =
cur_pred[7][1] = (imgpel) ((P_U + P_S + (P_T << 1) + 2) >> 2);
cur_pred[6][0] = (imgpel) ((P_V + P_T + (P_U << 1) + 2) >> 2);
cur_pred[7][0] = (imgpel) ((P_W + P_U + (P_V << 1) + 2) >> 2);
}
static inline void get_hor_down(imgpel **cur_pred, imgpel *PredPel)
{
cur_pred[0][0] =
cur_pred[1][2] =
cur_pred[2][4] =
cur_pred[3][6] = (imgpel) ((P_Q + P_Z + 1) >> 1);
cur_pred[1][0] =
cur_pred[2][2] =
cur_pred[3][4] =
cur_pred[4][6] = (imgpel) ((P_R + P_Q + 1) >> 1);
cur_pred[2][0] =
cur_pred[3][2] =
cur_pred[4][4] =
cur_pred[5][6] = (imgpel) ((P_S + P_R + 1) >> 1);
cur_pred[3][0] =
cur_pred[4][2] =
cur_pred[5][4] =
cur_pred[6][6] = (imgpel) ((P_T + P_S + 1) >> 1);
cur_pred[4][0] =
cur_pred[5][2] =
cur_pred[6][4] =
cur_pred[7][6] = (imgpel) ((P_U + P_T + 1) >> 1);
cur_pred[5][0] =
cur_pred[6][2] =
cur_pred[7][4] = (imgpel) ((P_V + P_U + 1) >> 1);
cur_pred[6][0] =
cur_pred[7][2] = (imgpel) ((P_W + P_V + 1) >> 1);
cur_pred[7][0] = (imgpel) ((P_X + P_W + 1) >> 1);
cur_pred[0][1] =
cur_pred[1][3] =
cur_pred[2][5] =
cur_pred[3][7] = (imgpel) ((P_Q + P_A + (P_Z << 1) + 2) >> 2);
cur_pred[1][1] =
cur_pred[2][3] =
cur_pred[3][5] =
cur_pred[4][7] = (imgpel) ((P_Z + P_R + (P_Q << 1) + 2) >> 2);
cur_pred[2][1] =
cur_pred[3][3] =
cur_pred[4][5] =
cur_pred[5][7] = (imgpel) ((P_Q + P_S + (P_R << 1) + 2) >> 2);
cur_pred[3][1] =
cur_pred[4][3] =
cur_pred[5][5] =
cur_pred[6][7] = (imgpel) ((P_R + P_T + (P_S << 1) + 2) >> 2);
cur_pred[4][1] =
cur_pred[5][3] =
cur_pred[6][5] =
cur_pred[7][7] = (imgpel) ((P_S + P_U + (P_T << 1) + 2) >> 2);
cur_pred[5][1] =
cur_pred[6][3] =
cur_pred[7][5] = (imgpel) ((P_T + P_V + (P_U << 1) + 2) >> 2);
cur_pred[6][1] =
cur_pred[7][3] = (imgpel) ((P_U + P_W + (P_V << 1) + 2) >> 2);
cur_pred[7][1] = (imgpel) ((P_V + P_X + (P_W << 1) + 2) >> 2);
cur_pred[0][2] =
cur_pred[1][4] =
cur_pred[2][6] = (imgpel) ((P_Z + P_B + (P_A << 1) + 2) >> 2);
cur_pred[0][3] =
cur_pred[1][5] =
cur_pred[2][7] = (imgpel) ((P_A + P_C + (P_B << 1) + 2) >> 2);
cur_pred[0][4] =
cur_pred[1][6] = (imgpel) ((P_B + P_D + (P_C << 1) + 2) >> 2);
cur_pred[0][5] =
cur_pred[1][7] = (imgpel) ((P_C + P_E + (P_D << 1) + 2) >> 2);
cur_pred[0][6] = (imgpel) ((P_D + P_F + (P_E << 1) + 2) >> 2);
cur_pred[0][7] = (imgpel) ((P_E + P_G + (P_F << 1) + 2) >> 2);
}
static inline void get_hor_up(imgpel **cur_pred, imgpel *PredPel)
{
cur_pred[0][0] = (imgpel) ((P_Q + P_R + 1) >> 1);
cur_pred[1][0] =
cur_pred[0][2] = (imgpel) ((P_R + P_S + 1) >> 1);
cur_pred[2][0] =
cur_pred[1][2] =
cur_pred[0][4] = (imgpel) ((P_S + P_T + 1) >> 1);
cur_pred[3][0] =
cur_pred[2][2] =
cur_pred[1][4] =
cur_pred[0][6] = (imgpel) ((P_T + P_U + 1) >> 1);
cur_pred[4][0] =
cur_pred[3][2] =
cur_pred[2][4] =
cur_pred[1][6] = (imgpel) ((P_U + P_V + 1) >> 1);
cur_pred[5][0] =
cur_pred[4][2] =
cur_pred[3][4] =
cur_pred[2][6] = (imgpel) ((P_V + P_W + 1) >> 1);
cur_pred[6][0] =
cur_pred[5][2] =
cur_pred[4][4] =
cur_pred[3][6] = (imgpel) ((P_W + P_X + 1) >> 1);
cur_pred[4][6] =
cur_pred[4][7] =
cur_pred[5][4] =
cur_pred[5][5] =
cur_pred[5][6] =
cur_pred[5][7] =
cur_pred[6][2] =
cur_pred[6][3] =
cur_pred[6][4] =
cur_pred[6][5] =
cur_pred[6][6] =
cur_pred[6][7] =
cur_pred[7][0] =
cur_pred[7][1] =
cur_pred[7][2] =
cur_pred[7][3] =
cur_pred[7][4] =
cur_pred[7][5] =
cur_pred[7][6] =
cur_pred[7][7] = (imgpel) P_X;
cur_pred[6][1] =
cur_pred[5][3] =
cur_pred[4][5] =
cur_pred[3][7] = (imgpel) ((P_W + P_X + (P_X << 1) + 2) >> 2);
cur_pred[5][1] =
cur_pred[4][3] =
cur_pred[3][5] =
cur_pred[2][7] = (imgpel) ((P_X + P_V + (P_W << 1) + 2) >> 2);
cur_pred[4][1] =
cur_pred[3][3] =
cur_pred[2][5] =
cur_pred[1][7] = (imgpel) ((P_W + P_U + (P_V << 1) + 2) >> 2);
cur_pred[3][1] =
cur_pred[2][3] =
cur_pred[1][5] =
cur_pred[0][7] = (imgpel) ((P_V + P_T + (P_U << 1) + 2) >> 2);
cur_pred[2][1] =
cur_pred[1][3] =
cur_pred[0][5] = (imgpel) ((P_U + P_S + (P_T << 1) + 2) >> 2);
cur_pred[1][1] =
cur_pred[0][3] = (imgpel) ((P_T + P_R + (P_S << 1) + 2) >> 2);
cur_pred[0][1] = (imgpel) ((P_S + P_Q + (P_R << 1) + 2) >> 2);
}
/*!
************************************************************************
* \brief
* Make intra 8x8 prediction according to all 9 prediction modes.
* The routine uses left and upper neighbouring points from
* previous coded blocks to do this (if available). Notice that
* inaccessible neighbouring points are signalled with a negative
* value in the predmode array .
*
* \par Input:
* Starting point of current 8x8 block image posision
*
* \par Output:
* none
************************************************************************
*/
void intrapred_8x8(Macroblock *currMB, ColorPlane pl, int img_x,int img_y, int *left_available, int *up_available, int *all_available)
{
int i,j;
int s0;
static imgpel PredPel[25]; // array of predictor pels
imgpel **img_enc = enc_picture->p_curr_img;
imgpel *img_pel;
static imgpel **cur_pred;
imgpel ***curr_mpr_8x8 = img->mpr_8x8[pl];
unsigned int dc_pred_value = img->dc_pred_value;
int *mb_size = img->mb_size[IS_LUMA];
int ioff = (img_x & 15);
int joff = (img_y & 15);
PixelPos pix_a[8];
PixelPos pix_b, pix_c, pix_d;
int block_available_up;
int block_available_left;
int block_available_up_left;
int block_available_up_right;
for (i=0;i<8;i++)
{
getNeighbour(currMB, ioff - 1, joff + i , mb_size, &pix_a[i]);
}
getNeighbour(currMB, ioff , joff - 1, mb_size, &pix_b);
getNeighbour(currMB, ioff + 8, joff - 1, mb_size, &pix_c);
getNeighbour(currMB, ioff - 1, joff - 1, mb_size, &pix_d);
pix_c.available = pix_c.available &&!(ioff == 8 && joff == 8);
if (params->UseConstrainedIntraPred)
{
for (i=0, block_available_left=1; i<8;i++)
block_available_left &= pix_a[i].available ? img->intra_block[pix_a[i].mb_addr]: 0;
block_available_up = pix_b.available ? img->intra_block [pix_b.mb_addr] : 0;
block_available_up_right = pix_c.available ? img->intra_block [pix_c.mb_addr] : 0;
block_available_up_left = pix_d.available ? img->intra_block [pix_d.mb_addr] : 0;
}
else
{
block_available_left = pix_a[0].available;
block_available_up = pix_b.available;
block_available_up_right = pix_c.available;
block_available_up_left = pix_d.available;
}
*left_available = block_available_left;
*up_available = block_available_up;
*all_available = block_available_up && block_available_left && block_available_up_left;
// form predictor pels
if (block_available_up)
{
img_pel = &img_enc[pix_b.pos_y][pix_b.pos_x];
P_A = *(img_pel++);
P_B = *(img_pel++);
P_C = *(img_pel++);
P_D = *(img_pel++);
P_E = *(img_pel++);
P_F = *(img_pel++);
P_G = *(img_pel++);
P_H = *(img_pel);
}
else
{
P_A = P_B = P_C = P_D = P_E = P_F = P_G = P_H = dc_pred_value;
}
if (block_available_up_right)
{
img_pel = &img_enc[pix_c.pos_y][pix_c.pos_x];
P_I = *(img_pel++);
P_J = *(img_pel++);
P_K = *(img_pel++);
P_L = *(img_pel++);
P_M = *(img_pel++);
P_N = *(img_pel++);
P_O = *(img_pel++);
P_P = *(img_pel);
}
else
{
P_I = P_J = P_K = P_L = P_M = P_N = P_O = P_P = P_H;
}
if (block_available_left)
{
P_Q = img_enc[pix_a[0].pos_y][pix_a[0].pos_x];
P_R = img_enc[pix_a[1].pos_y][pix_a[1].pos_x];
P_S = img_enc[pix_a[2].pos_y][pix_a[2].pos_x];
P_T = img_enc[pix_a[3].pos_y][pix_a[3].pos_x];
P_U = img_enc[pix_a[4].pos_y][pix_a[4].pos_x];
P_V = img_enc[pix_a[5].pos_y][pix_a[5].pos_x];
P_W = img_enc[pix_a[6].pos_y][pix_a[6].pos_x];
P_X = img_enc[pix_a[7].pos_y][pix_a[7].pos_x];
}
else
{
P_Q = P_R = P_S = P_T = P_U = P_V = P_W = P_X = dc_pred_value;
}
if (block_available_up_left)
{
P_Z = img_enc[pix_d.pos_y][pix_d.pos_x];
}
else
{
P_Z = dc_pred_value;
}
for(i=0;i<9;i++)
curr_mpr_8x8[i][0][0]=-1;
LowPassForIntra8x8Pred(&(P_Z), block_available_up_left, block_available_up, block_available_left);
///////////////////////////////
// make DC prediction
///////////////////////////////
s0 = 0;
if (block_available_up && block_available_left)
{
// no edge
s0 = rshift_rnd_sf((P_A + P_B + P_C + P_D + P_E + P_F + P_G + P_H + P_Q + P_R + P_S + P_T + P_U + P_V + P_W + P_X), 4);
}
else if (!block_available_up && block_available_left)
{
// upper edge
s0 = rshift_rnd_sf((P_Q + P_R + P_S + P_T + P_U + P_V + P_W + P_X), 3);
}
else if (block_available_up && !block_available_left)
{
// left edge
s0 = rshift_rnd_sf((P_A + P_B + P_C + P_D + P_E + P_F + P_G + P_H), 3);
}
else //if (!block_available_up && !block_available_left)
{
// top left corner, nothing to predict from
s0 = dc_pred_value;
}
// store DC prediction
cur_pred = curr_mpr_8x8[DC_PRED];
// First line
for (i=0; i < BLOCK_SIZE_8x8; i++)
{
cur_pred[0][i] = (imgpel) s0;
}
// remaining lines
for (j=0; j < BLOCK_SIZE_8x8 - 1; j++)
{
memcpy (cur_pred[j + 1], cur_pred[j], BLOCK_SIZE_8x8 * sizeof(imgpel));
}
///////////////////////////////
// make horiz and vert prediction
///////////////////////////////
if(block_available_up)
{
cur_pred = curr_mpr_8x8[VERT_PRED];
for (j=0; j < BLOCK_SIZE_8x8; j++)
memcpy(cur_pred[j], &P_A, BLOCK_SIZE_8x8 * sizeof(imgpel));
}
if(block_available_left)
{
cur_pred = curr_mpr_8x8[HOR_PRED];
for (i=0; i < BLOCK_SIZE_8x8; i++)
{
cur_pred[i][0] =
cur_pred[i][1] =
cur_pred[i][2] =
cur_pred[i][3] =
cur_pred[i][4] =
cur_pred[i][5] =
cur_pred[i][6] =
cur_pred[i][7] = (imgpel) (&P_Q)[i];
}
}
///////////////////////////////////
// make diagonal down left prediction
///////////////////////////////////
if (block_available_up)
{
// Mode DIAG_DOWN_LEFT_PRED
get_diag_down_left(curr_mpr_8x8[DIAG_DOWN_LEFT_PRED], PredPel);
///////////////////////////////////
// make vertical left prediction
///////////////////////////////////
get_vert_left(curr_mpr_8x8[VERT_LEFT_PRED], PredPel);
}
///////////////////////////////////
// make diagonal down right prediction
///////////////////////////////////
if (block_available_up && block_available_left && block_available_up_left)
{
// Mode DIAG_DOWN_RIGHT_PRED
get_diag_down_right(curr_mpr_8x8[DIAG_DOWN_RIGHT_PRED], PredPel);
///////////////////////////////////
// make vertical right prediction
///////////////////////////////////
get_vert_right(curr_mpr_8x8[VERT_RIGHT_PRED], PredPel);
///////////////////////////////////
// make horizontal down prediction
///////////////////////////////////
get_hor_down(curr_mpr_8x8[HOR_DOWN_PRED], PredPel);
}
///////////////////////////////////
// make horizontal up prediction
///////////////////////////////////
if (block_available_left)
{
get_hor_up(curr_mpr_8x8[HOR_UP_PRED], PredPel);
}
}
/*!
*************************************************************************************
* \brief
* Prefiltering for Intra8x8 prediction
*************************************************************************************
*/
void LowPassForIntra8x8Pred(imgpel *PredPel, int block_up_left, int block_up, int block_left)
{
int i;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -