From: John Koleszar Date: Tue, 23 Apr 2013 21:38:52 +0000 (-0700) Subject: Remove coeff from BLOCK X-Git-Tag: v1.3.0~1106^2~163^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=48f3e66e160d85648493d0a5e340a8577ce46c77;p=libvpx Remove coeff from BLOCK Lookup the data per-plane from the MACROBLOCK struct. Change-Id: I9253c4d3cf886aa9ab4aeab23a2156bfcf994ede --- diff --git a/vp9/encoder/vp9_block.h b/vp9/encoder/vp9_block.h index 7b5b158da..206ddff1a 100644 --- a/vp9/encoder/vp9_block.h +++ b/vp9/encoder/vp9_block.h @@ -24,9 +24,6 @@ typedef struct { } search_site; 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 diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 27d386108..c410d3fd7 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -1248,8 +1248,6 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) { 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; @@ -1733,17 +1731,6 @@ void vp9_encode_frame(VP9_COMP *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) { int block = 0; int br, bc; diff --git a/vp9/encoder/vp9_encodeframe.h b/vp9/encoder/vp9_encodeframe.h index 9f13edcec..4ace46807 100644 --- a/vp9/encoder/vp9_encodeframe.h +++ b/vp9/encoder/vp9_encodeframe.h @@ -16,6 +16,4 @@ struct macroblock; void vp9_build_block_offsets(struct macroblock *x); -void vp9_setup_block_ptrs(struct macroblock *x); - #endif // VP9_ENCODER_VP9_ENCODEFRAME_H_ diff --git a/vp9/encoder/vp9_encodeintra.c b/vp9/encoder/vp9_encodeintra.c index 32a92b8e7..66d62d99b 100644 --- a/vp9/encoder/vp9_encodeintra.c +++ b/vp9/encoder/vp9_encodeintra.c @@ -48,6 +48,7 @@ static void encode_intra4x4block(MACROBLOCK *x, int 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, ib, 16); assert(ib < 16); @@ -63,12 +64,12 @@ static void encode_intra4x4block(MACROBLOCK *x, int ib) { 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,24 +168,26 @@ void vp9_encode_intra8x8(MACROBLOCK *x, int ib) { 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); } } 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 @@ void vp9_encode_intra8x8(MACROBLOCK *x, int ib) { 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 @@ void vp9_encode_intra8x8(MACROBLOCK *x, int ib) { 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 @@ static void encode_intra_uv4x4(MACROBLOCK *x, int ib, int mode) { 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 @@ static void encode_intra_uv4x4(MACROBLOCK *x, int ib, int mode) { *(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); diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index b18dce4be..e441107e7 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -496,8 +496,6 @@ void vp9_first_pass(VP9_COMP *cpi) { 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); diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 693da6119..1ecae0b5e 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -873,6 +873,7 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int 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, ib, 16); ENTROPY_CONTEXT ta = *a, tempa = *a; ENTROPY_CONTEXT tl = *l, templ = *l; TX_TYPE tx_type = DCT_DCT; @@ -919,10 +920,10 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib, 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 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib, 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 @@ static int64_t rd_pick_intra8x8block(VP9_COMP *cpi, MACROBLOCK *x, int 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); assert(ib < 16); for (mode = DC_PRED; mode <= TM_PRED; mode++) { @@ -1129,13 +1131,13 @@ static int64_t rd_pick_intra8x8block(VP9_COMP *cpi, MACROBLOCK *x, int ib, 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 @@ static int64_t rd_pick_intra8x8block(VP9_COMP *cpi, MACROBLOCK *x, int ib, 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 @@ static int64_t encode_inter_mb_segment(VP9_COMMON *const cm, 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 @@ static int64_t encode_inter_mb_segment(VP9_COMMON *const cm, 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 @@ static int64_t encode_inter_mb_segment_8x8(VP9_COMMON *const cm, 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 @@ static int64_t encode_inter_mb_segment_8x8(VP9_COMMON *const cm, 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 @@ static int64_t encode_inter_mb_segment_8x8(VP9_COMMON *const cm, 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 @@ static int64_t encode_inter_mb_segment_8x8(VP9_COMMON *const cm, } 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 @@ static int64_t encode_inter_mb_segment_8x8(VP9_COMMON *const cm, 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,