Code cleanup inside vp9_reconintra4x4.c file.
Using ROUND_POWER_OF_TWO macro, using array initialization syntax for less code. Change-Id: I661453a6b29a9046fcff0a3f18fccb452b5eb39d
This commit is contained in:
parent
757e138a3b
commit
64de375e1f
@ -195,12 +195,7 @@ void vp9_intra4x4_predict(MACROBLOCKD *xd,
|
|||||||
|
|
||||||
if (have_top) {
|
if (have_top) {
|
||||||
uint8_t *above_ptr = *(x->base_dst) + x->dst - x->dst_stride;
|
uint8_t *above_ptr = *(x->base_dst) + x->dst - x->dst_stride;
|
||||||
|
top_left = have_left ? above_ptr[-1] : 127;
|
||||||
if (have_left) {
|
|
||||||
top_left = above_ptr[-1];
|
|
||||||
} else {
|
|
||||||
top_left = 127;
|
|
||||||
}
|
|
||||||
|
|
||||||
above[0] = above_ptr[0];
|
above[0] = above_ptr[0];
|
||||||
above[1] = above_ptr[1];
|
above[1] = above_ptr[1];
|
||||||
@ -270,13 +265,11 @@ void vp9_intra4x4_predict(MACROBLOCKD *xd,
|
|||||||
expected_dc += left[i];
|
expected_dc += left[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
expected_dc = (expected_dc + 4) >> 3;
|
expected_dc = ROUND_POWER_OF_TWO(expected_dc, 3);
|
||||||
|
|
||||||
for (r = 0; r < 4; r++) {
|
for (r = 0; r < 4; r++) {
|
||||||
for (c = 0; c < 4; c++) {
|
for (c = 0; c < 4; c++)
|
||||||
predictor[c] = expected_dc;
|
predictor[c] = expected_dc;
|
||||||
}
|
|
||||||
|
|
||||||
predictor += ps;
|
predictor += ps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,210 +277,160 @@ void vp9_intra4x4_predict(MACROBLOCKD *xd,
|
|||||||
case B_TM_PRED: {
|
case B_TM_PRED: {
|
||||||
/* prediction similar to true_motion prediction */
|
/* prediction similar to true_motion prediction */
|
||||||
for (r = 0; r < 4; r++) {
|
for (r = 0; r < 4; r++) {
|
||||||
for (c = 0; c < 4; c++) {
|
for (c = 0; c < 4; c++)
|
||||||
predictor[c] = clip_pixel(above[c] - top_left + left[r]);
|
predictor[c] = clip_pixel(above[c] - top_left + left[r]);
|
||||||
}
|
|
||||||
|
|
||||||
predictor += ps;
|
predictor += ps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case B_V_PRED:
|
||||||
case B_V_PRED: {
|
|
||||||
unsigned int ap[4];
|
|
||||||
|
|
||||||
ap[0] = above[0];
|
|
||||||
ap[1] = above[1];
|
|
||||||
ap[2] = above[2];
|
|
||||||
ap[3] = above[3];
|
|
||||||
|
|
||||||
for (r = 0; r < 4; r++) {
|
for (r = 0; r < 4; r++) {
|
||||||
for (c = 0; c < 4; c++) {
|
for (c = 0; c < 4; c++)
|
||||||
predictor[c] = ap[c];
|
predictor[c] = above[c];
|
||||||
}
|
|
||||||
|
|
||||||
predictor += ps;
|
predictor += ps;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
case B_H_PRED:
|
||||||
case B_H_PRED: {
|
|
||||||
unsigned int lp[4];
|
|
||||||
|
|
||||||
lp[0] = left[0];
|
|
||||||
lp[1] = left[1];
|
|
||||||
lp[2] = left[2];
|
|
||||||
lp[3] = left[3];
|
|
||||||
|
|
||||||
for (r = 0; r < 4; r++) {
|
for (r = 0; r < 4; r++) {
|
||||||
for (c = 0; c < 4; c++) {
|
for (c = 0; c < 4; c++)
|
||||||
predictor[c] = lp[r];
|
predictor[c] = left[r];
|
||||||
}
|
|
||||||
|
|
||||||
predictor += ps;
|
predictor += ps;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case B_D45_PRED: {
|
case B_D45_PRED: {
|
||||||
uint8_t *ptr = above;
|
uint8_t *p = above;
|
||||||
|
|
||||||
predictor[0 * ps + 0] = (ptr[0] + ptr[1] * 2 + ptr[2] + 2) >> 2;
|
predictor[0 * ps + 0] = ROUND_POWER_OF_TWO(p[0] + p[1] * 2 + p[2], 2);
|
||||||
predictor[0 * ps + 1] =
|
predictor[0 * ps + 1] =
|
||||||
predictor[1 * ps + 0] = (ptr[1] + ptr[2] * 2 + ptr[3] + 2) >> 2;
|
predictor[1 * ps + 0] = ROUND_POWER_OF_TWO(p[1] + p[2] * 2 + p[3], 2);
|
||||||
predictor[0 * ps + 2] =
|
predictor[0 * ps + 2] =
|
||||||
predictor[1 * ps + 1] =
|
predictor[1 * ps + 1] =
|
||||||
predictor[2 * ps + 0] = (ptr[2] + ptr[3] * 2 + ptr[4] + 2) >> 2;
|
predictor[2 * ps + 0] = ROUND_POWER_OF_TWO(p[2] + p[3] * 2 + p[4], 2);
|
||||||
predictor[0 * ps + 3] =
|
predictor[0 * ps + 3] =
|
||||||
predictor[1 * ps + 2] =
|
predictor[1 * ps + 2] =
|
||||||
predictor[2 * ps + 1] =
|
predictor[2 * ps + 1] =
|
||||||
predictor[3 * ps + 0] = (ptr[3] + ptr[4] * 2 + ptr[5] + 2) >> 2;
|
predictor[3 * ps + 0] =
|
||||||
|
ROUND_POWER_OF_TWO(p[3] + p[4] * 2 + p[5], 2);
|
||||||
predictor[1 * ps + 3] =
|
predictor[1 * ps + 3] =
|
||||||
predictor[2 * ps + 2] =
|
predictor[2 * ps + 2] =
|
||||||
predictor[3 * ps + 1] = (ptr[4] + ptr[5] * 2 + ptr[6] + 2) >> 2;
|
predictor[3 * ps + 1] = ROUND_POWER_OF_TWO(p[4] + p[5] * 2 + p[6], 2);
|
||||||
predictor[2 * ps + 3] =
|
predictor[2 * ps + 3] =
|
||||||
predictor[3 * ps + 2] = (ptr[5] + ptr[6] * 2 + ptr[7] + 2) >> 2;
|
predictor[3 * ps + 2] = ROUND_POWER_OF_TWO(p[5] + p[6] * 2 + p[7], 2);
|
||||||
predictor[3 * ps + 3] = (ptr[6] + ptr[7] * 2 + ptr[7] + 2) >> 2;
|
predictor[3 * ps + 3] = ROUND_POWER_OF_TWO(p[6] + p[7] * 2 + p[7], 2);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case B_D135_PRED: {
|
case B_D135_PRED: {
|
||||||
uint8_t pp[9];
|
uint8_t p[9] = { left[3], left[2], left[1], left[0],
|
||||||
|
top_left,
|
||||||
|
above[0], above[1], above[2], above[3] };
|
||||||
|
|
||||||
pp[0] = left[3];
|
predictor[3 * ps + 0] = ROUND_POWER_OF_TWO(p[0] + p[1] * 2 + p[2], 2);
|
||||||
pp[1] = left[2];
|
|
||||||
pp[2] = left[1];
|
|
||||||
pp[3] = left[0];
|
|
||||||
pp[4] = top_left;
|
|
||||||
pp[5] = above[0];
|
|
||||||
pp[6] = above[1];
|
|
||||||
pp[7] = above[2];
|
|
||||||
pp[8] = above[3];
|
|
||||||
|
|
||||||
predictor[3 * ps + 0] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
|
|
||||||
predictor[3 * ps + 1] =
|
predictor[3 * ps + 1] =
|
||||||
predictor[2 * ps + 0] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
|
predictor[2 * ps + 0] = ROUND_POWER_OF_TWO(p[1] + p[2] * 2 + p[3], 2);
|
||||||
predictor[3 * ps + 2] =
|
predictor[3 * ps + 2] =
|
||||||
predictor[2 * ps + 1] =
|
predictor[2 * ps + 1] =
|
||||||
predictor[1 * ps + 0] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
|
predictor[1 * ps + 0] = ROUND_POWER_OF_TWO(p[2] + p[3] * 2 + p[4], 2);
|
||||||
predictor[3 * ps + 3] =
|
predictor[3 * ps + 3] =
|
||||||
predictor[2 * ps + 2] =
|
predictor[2 * ps + 2] =
|
||||||
predictor[1 * ps + 1] =
|
predictor[1 * ps + 1] =
|
||||||
predictor[0 * ps + 0] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
|
predictor[0 * ps + 0] =
|
||||||
|
ROUND_POWER_OF_TWO(p[3] + p[4] * 2 + p[5], 2);
|
||||||
predictor[2 * ps + 3] =
|
predictor[2 * ps + 3] =
|
||||||
predictor[1 * ps + 2] =
|
predictor[1 * ps + 2] =
|
||||||
predictor[0 * ps + 1] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
|
predictor[0 * ps + 1] = ROUND_POWER_OF_TWO(p[4] + p[5] * 2 + p[6], 2);
|
||||||
predictor[1 * ps + 3] =
|
predictor[1 * ps + 3] =
|
||||||
predictor[0 * ps + 2] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
|
predictor[0 * ps + 2] = ROUND_POWER_OF_TWO(p[5] + p[6] * 2 + p[7], 2);
|
||||||
predictor[0 * ps + 3] = (pp[6] + pp[7] * 2 + pp[8] + 2) >> 2;
|
predictor[0 * ps + 3] = ROUND_POWER_OF_TWO(p[6] + p[7] * 2 + p[8], 2);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case B_D117_PRED: {
|
case B_D117_PRED: {
|
||||||
uint8_t pp[9];
|
uint8_t p[9] = { left[3], left[2], left[1], left[0],
|
||||||
|
top_left,
|
||||||
|
above[0], above[1], above[2], above[3] };
|
||||||
|
|
||||||
pp[0] = left[3];
|
predictor[3 * ps + 0] = ROUND_POWER_OF_TWO(p[1] + p[2] * 2 + p[3], 2);
|
||||||
pp[1] = left[2];
|
predictor[2 * ps + 0] = ROUND_POWER_OF_TWO(p[2] + p[3] * 2 + p[4], 2);
|
||||||
pp[2] = left[1];
|
|
||||||
pp[3] = left[0];
|
|
||||||
pp[4] = top_left;
|
|
||||||
pp[5] = above[0];
|
|
||||||
pp[6] = above[1];
|
|
||||||
pp[7] = above[2];
|
|
||||||
pp[8] = above[3];
|
|
||||||
|
|
||||||
predictor[3 * ps + 0] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
|
|
||||||
predictor[2 * ps + 0] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
|
|
||||||
predictor[3 * ps + 1] =
|
predictor[3 * ps + 1] =
|
||||||
predictor[1 * ps + 0] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
|
predictor[1 * ps + 0] = ROUND_POWER_OF_TWO(p[3] + p[4] * 2 + p[5], 2);
|
||||||
predictor[2 * ps + 1] =
|
predictor[2 * ps + 1] =
|
||||||
predictor[0 * ps + 0] = (pp[4] + pp[5] + 1) >> 1;
|
predictor[0 * ps + 0] = ROUND_POWER_OF_TWO(p[4] + p[5], 1);
|
||||||
predictor[3 * ps + 2] =
|
predictor[3 * ps + 2] =
|
||||||
predictor[1 * ps + 1] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
|
predictor[1 * ps + 1] = ROUND_POWER_OF_TWO(p[4] + p[5] * 2 + p[6], 2);
|
||||||
predictor[2 * ps + 2] =
|
predictor[2 * ps + 2] =
|
||||||
predictor[0 * ps + 1] = (pp[5] + pp[6] + 1) >> 1;
|
predictor[0 * ps + 1] = ROUND_POWER_OF_TWO(p[5] + p[6], 1);
|
||||||
predictor[3 * ps + 3] =
|
predictor[3 * ps + 3] =
|
||||||
predictor[1 * ps + 2] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
|
predictor[1 * ps + 2] = ROUND_POWER_OF_TWO(p[5] + p[6] * 2 + p[7], 2);
|
||||||
predictor[2 * ps + 3] =
|
predictor[2 * ps + 3] =
|
||||||
predictor[0 * ps + 2] = (pp[6] + pp[7] + 1) >> 1;
|
predictor[0 * ps + 2] = ROUND_POWER_OF_TWO(p[6] + p[7], 1);
|
||||||
predictor[1 * ps + 3] = (pp[6] + pp[7] * 2 + pp[8] + 2) >> 2;
|
predictor[1 * ps + 3] = ROUND_POWER_OF_TWO(p[6] + p[7] * 2 + p[8], 2);
|
||||||
predictor[0 * ps + 3] = (pp[7] + pp[8] + 1) >> 1;
|
predictor[0 * ps + 3] = ROUND_POWER_OF_TWO(p[7] + p[8], 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case B_D63_PRED: {
|
case B_D63_PRED: {
|
||||||
uint8_t *pp = above;
|
uint8_t *p = above;
|
||||||
|
|
||||||
predictor[0 * ps + 0] = (pp[0] + pp[1] + 1) >> 1;
|
predictor[0 * ps + 0] = ROUND_POWER_OF_TWO(p[0] + p[1], 1);
|
||||||
predictor[1 * ps + 0] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
|
predictor[1 * ps + 0] = ROUND_POWER_OF_TWO(p[0] + p[1] * 2 + p[2], 2);
|
||||||
predictor[2 * ps + 0] =
|
predictor[2 * ps + 0] =
|
||||||
predictor[0 * ps + 1] = (pp[1] + pp[2] + 1) >> 1;
|
predictor[0 * ps + 1] = ROUND_POWER_OF_TWO(p[1] + p[2], 1);
|
||||||
predictor[1 * ps + 1] =
|
predictor[1 * ps + 1] =
|
||||||
predictor[3 * ps + 0] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
|
predictor[3 * ps + 0] = ROUND_POWER_OF_TWO(p[1] + p[2] * 2 + p[3], 2);
|
||||||
predictor[2 * ps + 1] =
|
predictor[2 * ps + 1] =
|
||||||
predictor[0 * ps + 2] = (pp[2] + pp[3] + 1) >> 1;
|
predictor[0 * ps + 2] = ROUND_POWER_OF_TWO(p[2] + p[3], 1);
|
||||||
predictor[3 * ps + 1] =
|
predictor[3 * ps + 1] =
|
||||||
predictor[1 * ps + 2] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
|
predictor[1 * ps + 2] = ROUND_POWER_OF_TWO(p[2] + p[3] * 2 + p[4], 2);
|
||||||
predictor[0 * ps + 3] =
|
predictor[0 * ps + 3] =
|
||||||
predictor[2 * ps + 2] = (pp[3] + pp[4] + 1) >> 1;
|
predictor[2 * ps + 2] = ROUND_POWER_OF_TWO(p[3] + p[4], 1);
|
||||||
predictor[1 * ps + 3] =
|
predictor[1 * ps + 3] =
|
||||||
predictor[3 * ps + 2] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
|
predictor[3 * ps + 2] = ROUND_POWER_OF_TWO(p[3] + p[4] * 2 + p[5], 2);
|
||||||
predictor[2 * ps + 3] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
|
predictor[2 * ps + 3] = ROUND_POWER_OF_TWO(p[4] + p[5] * 2 + p[6], 2);
|
||||||
predictor[3 * ps + 3] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
|
predictor[3 * ps + 3] = ROUND_POWER_OF_TWO(p[5] + p[6] * 2 + p[7], 2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_D153_PRED: {
|
case B_D153_PRED: {
|
||||||
uint8_t pp[9];
|
uint8_t p[9] = { left[3], left[2], left[1], left[0],
|
||||||
|
top_left,
|
||||||
|
above[0], above[1], above[2], above[3] };
|
||||||
|
|
||||||
pp[0] = left[3];
|
predictor[3 * ps + 0] = ROUND_POWER_OF_TWO(p[0] + p[1], 1);
|
||||||
pp[1] = left[2];
|
predictor[3 * ps + 1] = ROUND_POWER_OF_TWO(p[0] + p[1] * 2 + p[2], 2);
|
||||||
pp[2] = left[1];
|
|
||||||
pp[3] = left[0];
|
|
||||||
pp[4] = top_left;
|
|
||||||
pp[5] = above[0];
|
|
||||||
pp[6] = above[1];
|
|
||||||
pp[7] = above[2];
|
|
||||||
pp[8] = above[3];
|
|
||||||
|
|
||||||
|
|
||||||
predictor[3 * ps + 0] = (pp[0] + pp[1] + 1) >> 1;
|
|
||||||
predictor[3 * ps + 1] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
|
|
||||||
predictor[2 * ps + 0] =
|
predictor[2 * ps + 0] =
|
||||||
predictor[3 * ps + 2] = (pp[1] + pp[2] + 1) >> 1;
|
predictor[3 * ps + 2] = ROUND_POWER_OF_TWO(p[1] + p[2], 1);
|
||||||
predictor[2 * ps + 1] =
|
predictor[2 * ps + 1] =
|
||||||
predictor[3 * ps + 3] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
|
predictor[3 * ps + 3] = ROUND_POWER_OF_TWO(p[1] + p[2] * 2 + p[3], 2);
|
||||||
predictor[2 * ps + 2] =
|
predictor[2 * ps + 2] =
|
||||||
predictor[1 * ps + 0] = (pp[2] + pp[3] + 1) >> 1;
|
predictor[1 * ps + 0] = ROUND_POWER_OF_TWO(p[2] + p[3], 1);
|
||||||
predictor[2 * ps + 3] =
|
predictor[2 * ps + 3] =
|
||||||
predictor[1 * ps + 1] = (pp[2] + pp[3] * 2 + pp[4] + 2) >> 2;
|
predictor[1 * ps + 1] = ROUND_POWER_OF_TWO(p[2] + p[3] * 2 + p[4], 2);
|
||||||
predictor[1 * ps + 2] =
|
predictor[1 * ps + 2] =
|
||||||
predictor[0 * ps + 0] = (pp[3] + pp[4] + 1) >> 1;
|
predictor[0 * ps + 0] = ROUND_POWER_OF_TWO(p[3] + p[4], 1);
|
||||||
predictor[1 * ps + 3] =
|
predictor[1 * ps + 3] =
|
||||||
predictor[0 * ps + 1] = (pp[3] + pp[4] * 2 + pp[5] + 2) >> 2;
|
predictor[0 * ps + 1] = ROUND_POWER_OF_TWO(p[3] + p[4] * 2 + p[5], 2);
|
||||||
predictor[0 * ps + 2] = (pp[4] + pp[5] * 2 + pp[6] + 2) >> 2;
|
predictor[0 * ps + 2] = ROUND_POWER_OF_TWO(p[4] + p[5] * 2 + p[6], 2);
|
||||||
predictor[0 * ps + 3] = (pp[5] + pp[6] * 2 + pp[7] + 2) >> 2;
|
predictor[0 * ps + 3] = ROUND_POWER_OF_TWO(p[5] + p[6] * 2 + p[7], 2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case B_D27_PRED: {
|
case B_D27_PRED: {
|
||||||
uint8_t *pp = left;
|
uint8_t *p = left;
|
||||||
predictor[0 * ps + 0] = (pp[0] + pp[1] + 1) >> 1;
|
predictor[0 * ps + 0] = ROUND_POWER_OF_TWO(p[0] + p[1], 1);
|
||||||
predictor[0 * ps + 1] = (pp[0] + pp[1] * 2 + pp[2] + 2) >> 2;
|
predictor[0 * ps + 1] = ROUND_POWER_OF_TWO(p[0] + p[1] * 2 + p[2], 2);
|
||||||
predictor[0 * ps + 2] =
|
predictor[0 * ps + 2] =
|
||||||
predictor[1 * ps + 0] = (pp[1] + pp[2] + 1) >> 1;
|
predictor[1 * ps + 0] = ROUND_POWER_OF_TWO(p[1] + p[2], 1);
|
||||||
predictor[0 * ps + 3] =
|
predictor[0 * ps + 3] =
|
||||||
predictor[1 * ps + 1] = (pp[1] + pp[2] * 2 + pp[3] + 2) >> 2;
|
predictor[1 * ps + 1] = ROUND_POWER_OF_TWO(p[1] + p[2] * 2 + p[3], 2);
|
||||||
predictor[1 * ps + 2] =
|
predictor[1 * ps + 2] =
|
||||||
predictor[2 * ps + 0] = (pp[2] + pp[3] + 1) >> 1;
|
predictor[2 * ps + 0] = ROUND_POWER_OF_TWO(p[2] + p[3], 1);
|
||||||
predictor[1 * ps + 3] =
|
predictor[1 * ps + 3] =
|
||||||
predictor[2 * ps + 1] = (pp[2] + pp[3] * 2 + pp[3] + 2) >> 2;
|
predictor[2 * ps + 1] = ROUND_POWER_OF_TWO(p[2] + p[3] * 2 + p[3], 2);
|
||||||
predictor[2 * ps + 2] =
|
predictor[2 * ps + 2] =
|
||||||
predictor[2 * ps + 3] =
|
predictor[2 * ps + 3] =
|
||||||
predictor[3 * ps + 0] =
|
predictor[3 * ps + 0] =
|
||||||
predictor[3 * ps + 1] =
|
predictor[3 * ps + 1] =
|
||||||
predictor[3 * ps + 2] =
|
predictor[3 * ps + 2] =
|
||||||
predictor[3 * ps + 3] = pp[3];
|
predictor[3 * ps + 3] = p[3];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user