ref: 48f3e66e160d85648493d0a5e340a8577ce46c77
parent: 138ec38cab4e8093d459600cd744720b036f2d50
author: John Koleszar <[email protected]>
date: Tue Apr 23 10:38:52 EDT 2013
Remove coeff from BLOCK Lookup the data per-plane from the MACROBLOCK struct. Change-Id: I9253c4d3cf886aa9ab4aeab23a2156bfcf994ede
--- a/vp9/encoder/vp9_block.h
+++ b/vp9/encoder/vp9_block.h
@@ -25,9 +25,6 @@
typedef struct block {
// 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries
- int16_t *coeff;
-
- // 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries
int16_t *quant;
int16_t *quant_fast; // fast quant deprecated for now
uint8_t *quant_shift;
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -1248,8 +1248,6 @@
vp9_setup_block_dptrs(&x->e_mbd);
- vp9_setup_block_ptrs(x);
-
xd->mode_info_context->mbmi.mode = DC_PRED;
xd->mode_info_context->mbmi.uv_mode = DC_PRED;
@@ -1731,17 +1729,6 @@
encode_frame_internal(cpi);
}
-}
-
-void vp9_setup_block_ptrs(MACROBLOCK *x) {
- int i;
-
- for (i = 0; i < 16; i++)
- x->block[i].coeff = x->plane[0].coeff + i * 16;
- for (i = 16; i < 20; i++)
- x->block[i].coeff = x->plane[1].coeff + (i - 16) * 16;
- for (i = 20; i < 24; i++)
- x->block[i].coeff = x->plane[2].coeff + (i - 20) * 16;
}
void vp9_build_block_offsets(MACROBLOCK *x) {
--- a/vp9/encoder/vp9_encodeframe.h
+++ b/vp9/encoder/vp9_encodeframe.h
@@ -16,6 +16,4 @@
void vp9_build_block_offsets(struct macroblock *x);
-void vp9_setup_block_ptrs(struct macroblock *x);
-
#endif // VP9_ENCODER_VP9_ENCODEFRAME_H_
--- a/vp9/encoder/vp9_encodeintra.c
+++ b/vp9/encoder/vp9_encodeintra.c
@@ -48,6 +48,7 @@
int16_t* const src_diff =
raster_block_offset_int16(xd, BLOCK_SIZE_MB16X16, 0, ib,
x->plane[0].src_diff);
+ int16_t* const coeff = BLOCK_OFFSET(x->plane[0].coeff, ib, 16);
assert(ib < 16);
@@ -63,12 +64,12 @@
tx_type = get_tx_type_4x4(&x->e_mbd, ib);
if (tx_type != DCT_DCT) {
- vp9_short_fht4x4(src_diff, be->coeff, 16, tx_type);
+ vp9_short_fht4x4(src_diff, coeff, 16, tx_type);
vp9_ht_quantize_b_4x4(x, ib, tx_type);
vp9_short_iht4x4(BLOCK_OFFSET(xd->plane[0].dqcoeff, ib, 16),
b->diff, 16, tx_type);
} else {
- x->fwd_txm4x4(src_diff, be->coeff, 32);
+ x->fwd_txm4x4(src_diff, coeff, 32);
x->quantize_b_4x4(x, ib, 16);
vp9_inverse_transform_b_4x4(&x->e_mbd, xd->plane[0].eobs[ib],
BLOCK_OFFSET(xd->plane[0].dqcoeff, ib, 16),
@@ -167,17 +168,18 @@
if (xd->mode_info_context->mbmi.txfm_size == TX_8X8) {
int idx = (ib & 0x02) ? (ib + 2) : ib;
- int16_t * const dqcoeff = BLOCK_OFFSET(xd->plane[0].dqcoeff, idx, 16);
+ int16_t* const dqcoeff = BLOCK_OFFSET(xd->plane[0].dqcoeff, idx, 16);
+ int16_t* const coeff = BLOCK_OFFSET(x->plane[0].coeff, idx, 16);
assert(idx < 16);
tx_type = get_tx_type_8x8(xd, ib);
if (tx_type != DCT_DCT) {
- vp9_short_fht8x8(src_diff, (x->block + idx)->coeff, 16, tx_type);
+ vp9_short_fht8x8(src_diff, coeff, 16, tx_type);
x->quantize_b_8x8(x, idx, tx_type, 16);
vp9_short_iht8x8(dqcoeff, xd->block[ib].diff,
16, tx_type);
} else {
- x->fwd_txm8x8(src_diff, (x->block + idx)->coeff, 32);
+ x->fwd_txm8x8(src_diff, coeff, 32);
x->quantize_b_8x8(x, idx, DCT_DCT, 16);
vp9_short_idct8x8(dqcoeff, xd->block[ib].diff, 32);
}
@@ -184,7 +186,8 @@
} else {
for (i = 0; i < 4; i++) {
int idx = ib + iblock[i];
- int16_t * const dqcoeff = BLOCK_OFFSET(xd->plane[0].dqcoeff, idx, 16);
+ int16_t* const dqcoeff = BLOCK_OFFSET(xd->plane[0].dqcoeff, idx, 16);
+ int16_t* const coeff = BLOCK_OFFSET(x->plane[0].coeff, idx, 16);
int16_t* const src_diff =
raster_block_offset_int16(xd, BLOCK_SIZE_MB16X16, 0, idx,
x->plane[0].src_diff);
@@ -194,12 +197,12 @@
be = &x->block[ib + iblock[i]];
tx_type = get_tx_type_4x4(xd, ib + iblock[i]);
if (tx_type != DCT_DCT) {
- vp9_short_fht4x4(src_diff, be->coeff, 16, tx_type);
+ vp9_short_fht4x4(src_diff, coeff, 16, tx_type);
vp9_ht_quantize_b_4x4(x, ib + iblock[i], tx_type);
vp9_short_iht4x4(dqcoeff, b->diff, 16, tx_type);
} else if (!(i & 1) &&
get_tx_type_4x4(xd, ib + iblock[i] + 1) == DCT_DCT) {
- x->fwd_txm8x4(src_diff, be->coeff, 32);
+ x->fwd_txm8x4(src_diff, coeff, 32);
x->quantize_b_4x4_pair(x, ib + iblock[i], ib + iblock[i] + 1, 16);
vp9_inverse_transform_b_4x4(xd, xd->plane[0].eobs[ib + iblock[i]],
dqcoeff, b->diff, 32);
@@ -207,7 +210,7 @@
dqcoeff + 16, (b + 1)->diff, 32);
i++;
} else {
- x->fwd_txm4x4(src_diff, be->coeff, 32);
+ x->fwd_txm4x4(src_diff, coeff, 32);
x->quantize_b_4x4(x, ib + iblock[i], 16);
vp9_inverse_transform_b_4x4(xd, xd->plane[0].eobs[ib + iblock[i]],
dqcoeff, b->diff, 32);
@@ -235,6 +238,7 @@
BLOCKD *b = &x->e_mbd.block[ib];
BLOCK *be = &x->block[ib];
int16_t * const dqcoeff = MB_SUBBLOCK_FIELD(xd, dqcoeff, ib);
+ int16_t* const coeff = MB_SUBBLOCK_FIELD(x, coeff, ib);
const int plane = ib < 20 ? 1 : 2;
const int block = ib < 20 ? ib - 16 : ib - 20;
int16_t* const src_diff =
@@ -250,7 +254,7 @@
*(be->base_src) + be->src, be->src_stride,
*(b->base_dst) + b->dst, b->dst_stride);
- x->fwd_txm4x4(src_diff, be->coeff, 16);
+ x->fwd_txm4x4(src_diff, coeff, 16);
x->quantize_b_4x4(x, ib, 16);
vp9_inverse_transform_b_4x4(&x->e_mbd, xd->plane[plane].eobs[block],
dqcoeff, b->diff, 16);
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -496,8 +496,6 @@
vp9_setup_block_dptrs(&x->e_mbd);
- vp9_setup_block_ptrs(x);
-
// set up frame new frame for intra coded blocks
vp9_setup_intra_recon(new_yv12);
vp9_frame_init_quantizer(cpi);
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -873,6 +873,7 @@
int16_t* const src_diff =
raster_block_offset_int16(xd, BLOCK_SIZE_MB16X16, 0, ib,
x->plane[0].src_diff);
+ int16_t* const coeff = BLOCK_OFFSET(x->plane[0].coeff, ib, 16);
ENTROPY_CONTEXT ta = *a, tempa = *a;
ENTROPY_CONTEXT tl = *l, templ = *l;
TX_TYPE tx_type = DCT_DCT;
@@ -919,10 +920,10 @@
b->bmi.as_mode.first = mode;
tx_type = get_tx_type_4x4(xd, be - x->block);
if (tx_type != DCT_DCT) {
- vp9_short_fht4x4(src_diff, be->coeff, 16, tx_type);
+ vp9_short_fht4x4(src_diff, coeff, 16, tx_type);
vp9_ht_quantize_b_4x4(x, be - x->block, tx_type);
} else {
- x->fwd_txm4x4(src_diff, be->coeff, 32);
+ x->fwd_txm4x4(src_diff, coeff, 32);
x->quantize_b_4x4(x, be - x->block, 16);
}
@@ -932,7 +933,7 @@
ratey = cost_coeffs(cm, x, b - xd->block,
PLANE_TYPE_Y_WITH_DC, &tempa, &templ, TX_4X4, 16);
rate += ratey;
- distortion = vp9_block_error(be->coeff,
+ distortion = vp9_block_error(coeff,
BLOCK_OFFSET(xd->plane[0].dqcoeff, ib, 16),
16) >> 2;
@@ -1110,6 +1111,7 @@
int16_t* const src_diff =
raster_block_offset_int16(xd, BLOCK_SIZE_MB16X16, 0, ib,
x->plane[0].src_diff);
+ int16_t* const coeff = BLOCK_OFFSET(x->plane[0].coeff, idx, 16);
assert(ib < 16);
for (mode = DC_PRED; mode <= TM_PRED; mode++) {
@@ -1129,13 +1131,13 @@
if (xd->mode_info_context->mbmi.txfm_size == TX_8X8) {
TX_TYPE tx_type = get_tx_type_8x8(xd, ib);
if (tx_type != DCT_DCT)
- vp9_short_fht8x8(src_diff, (x->block + idx)->coeff, 16, tx_type);
+ vp9_short_fht8x8(src_diff, coeff, 16, tx_type);
else
- x->fwd_txm8x8(src_diff, (x->block + idx)->coeff, 32);
+ x->fwd_txm8x8(src_diff, coeff, 32);
x->quantize_b_8x8(x, idx, tx_type, 16);
// compute quantization mse of 8x8 block
- distortion = vp9_block_error_c((x->block + idx)->coeff,
+ distortion = vp9_block_error_c(coeff,
BLOCK_OFFSET(xd->plane[0].dqcoeff, idx, 16), 64);
vpx_memcpy(&ta, a, sizeof(ENTROPY_CONTEXT_PLANES));
@@ -1167,23 +1169,25 @@
raster_block_offset_int16(xd, BLOCK_SIZE_MB16X16,
0, ib + iblock[i],
x->plane[0].src_diff);
+ int16_t* const coeff = BLOCK_OFFSET(x->plane[0].coeff,
+ ib + iblock[i], 16);
int do_two = 0;
b = &xd->block[ib + iblock[i]];
be = &x->block[ib + iblock[i]];
tx_type = get_tx_type_4x4(xd, ib + iblock[i]);
if (tx_type != DCT_DCT) {
- vp9_short_fht4x4(src_diff, be->coeff, 16, tx_type);
+ vp9_short_fht4x4(src_diff, coeff, 16, tx_type);
vp9_ht_quantize_b_4x4(x, ib + iblock[i], tx_type);
} else if (!(i & 1) &&
get_tx_type_4x4(xd, ib + iblock[i] + 1) == DCT_DCT) {
- x->fwd_txm8x4(src_diff, be->coeff, 32);
+ x->fwd_txm8x4(src_diff, coeff, 32);
x->quantize_b_4x4_pair(x, ib + iblock[i], ib + iblock[i] + 1, 16);
do_two = 1;
} else {
- x->fwd_txm4x4(src_diff, be->coeff, 32);
+ x->fwd_txm4x4(src_diff, coeff, 32);
x->quantize_b_4x4(x, ib + iblock[i], 16);
}
- distortion += vp9_block_error_c(be->coeff,
+ distortion += vp9_block_error_c(coeff,
BLOCK_OFFSET(xd->plane[0].dqcoeff, ib + iblock[i], 16),
16 << do_two);
rate_t += cost_coeffs(cm, x, ib + iblock[i], PLANE_TYPE_Y_WITH_DC,
@@ -1726,6 +1730,7 @@
int16_t* const src_diff =
raster_block_offset_int16(xd, BLOCK_SIZE_MB16X16, 0, i,
x->plane[0].src_diff);
+ int16_t* const coeff = BLOCK_OFFSET(x->plane[0].coeff, 16, i);
int thisdistortion;
vp9_build_inter_predictor(*(bd->base_pre) + bd->pre,
@@ -1751,9 +1756,9 @@
vp9_subtract_block(4, 4, src_diff, 16,
*(be->base_src) + be->src, be->src_stride,
*(bd->base_dst) + bd->dst, bd->dst_stride);
- x->fwd_txm4x4(src_diff, be->coeff, 32);
+ x->fwd_txm4x4(src_diff, coeff, 32);
x->quantize_b_4x4(x, i, 16);
- thisdistortion = vp9_block_error(be->coeff,
+ thisdistortion = vp9_block_error(coeff,
BLOCK_OFFSET(xd->plane[0].dqcoeff, i, 16), 16);
*distortion += thisdistortion;
*labelyrate += cost_coeffs(cm, x, i, PLANE_TYPE_Y_WITH_DC,
@@ -1798,10 +1803,11 @@
int which_mv;
const int idx = (ib & 8) + ((ib & 2) << 1);
BLOCKD *bd = &xd->block[ib];
- BLOCK *be = &x->block[ib], *be2 = &x->block[idx];
+ BLOCK *be = &x->block[ib];
int16_t* const src_diff =
raster_block_offset_int16(xd, BLOCK_SIZE_MB16X16, 0, ib,
x->plane[0].src_diff);
+ int16_t* const coeff = BLOCK_OFFSET(x->plane[0].coeff, idx, 16);
int thisdistortion;
assert(idx < 16);
@@ -1825,9 +1831,9 @@
if (xd->mode_info_context->mbmi.txfm_size == TX_4X4) {
if (otherrd) {
- x->fwd_txm8x8(src_diff, be2->coeff, 32);
+ x->fwd_txm8x8(src_diff, coeff, 32);
x->quantize_b_8x8(x, idx, DCT_DCT, 16);
- thisdistortion = vp9_block_error_c(be2->coeff,
+ thisdistortion = vp9_block_error_c(coeff,
BLOCK_OFFSET(xd->plane[0].dqcoeff, idx, 16), 64);
otherdist += thisdistortion;
xd->mode_info_context->mbmi.txfm_size = TX_8X8;
@@ -1842,11 +1848,13 @@
raster_block_offset_int16(xd, BLOCK_SIZE_MB16X16,
0, ib + iblock[j],
x->plane[0].src_diff);
+ int16_t* const coeff = BLOCK_OFFSET(x->plane[0].coeff,
+ ib + iblock[j], 16);
bd = &xd->block[ib + iblock[j]];
be = &x->block[ib + iblock[j]];
- x->fwd_txm8x4(src_diff, be->coeff, 32);
+ x->fwd_txm8x4(src_diff, coeff, 32);
x->quantize_b_4x4_pair(x, ib + iblock[j], ib + iblock[j] + 1, 16);
- thisdistortion = vp9_block_error_c(be->coeff,
+ thisdistortion = vp9_block_error_c(coeff,
BLOCK_OFFSET(xd->plane[0].dqcoeff, ib + iblock[j], 16), 32);
*distortion += thisdistortion;
*labelyrate +=
@@ -1864,14 +1872,15 @@
} else /* 8x8 */ {
if (otherrd) {
for (j = 0; j < 4; j += 2) {
- BLOCK *be = &x->block[ib + iblock[j]];
int16_t* const src_diff =
raster_block_offset_int16(xd, BLOCK_SIZE_MB16X16,
0, ib + iblock[j],
x->plane[0].src_diff);
- x->fwd_txm8x4(src_diff, be->coeff, 32);
+ int16_t* const coeff = BLOCK_OFFSET(x->plane[0].coeff,
+ ib + iblock[j], 16);
+ x->fwd_txm8x4(src_diff, coeff, 32);
x->quantize_b_4x4_pair(x, ib + iblock[j], ib + iblock[j] + 1, 16);
- thisdistortion = vp9_block_error_c(be->coeff,
+ thisdistortion = vp9_block_error_c(coeff,
BLOCK_OFFSET(xd->plane[0].dqcoeff, ib + iblock[j], 16), 32);
otherdist += thisdistortion;
xd->mode_info_context->mbmi.txfm_size = TX_4X4;
@@ -1889,9 +1898,9 @@
xd->mode_info_context->mbmi.txfm_size = TX_8X8;
}
}
- x->fwd_txm8x8(src_diff, be2->coeff, 32);
+ x->fwd_txm8x8(src_diff, coeff, 32);
x->quantize_b_8x8(x, idx, DCT_DCT, 16);
- thisdistortion = vp9_block_error_c(be2->coeff,
+ thisdistortion = vp9_block_error_c(coeff,
BLOCK_OFFSET(xd->plane[0].dqcoeff, idx, 16), 64);
*distortion += thisdistortion;
*labelyrate += cost_coeffs(cm, x, idx, PLANE_TYPE_Y_WITH_DC,