From f1559bdeaf5d5d25d7d13e5f435a43f15c76b215 Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Fri, 9 Aug 2013 16:40:05 -0700 Subject: [PATCH] Inlining 16 as a stride for BLOCK_OFFSET macro. Change-Id: I7f23d174eb089e5500f268a10db09648634c1b82 --- vp9/common/vp9_blockd.h | 2 +- vp9/decoder/vp9_decodframe.c | 2 +- vp9/decoder/vp9_detokenize.c | 2 +- vp9/encoder/vp9_encodemb.c | 21 ++++++++++----------- vp9/encoder/vp9_quantize.c | 6 +++--- vp9/encoder/vp9_rdopt.c | 21 ++++++++++----------- vp9/encoder/vp9_tokenize.c | 2 +- 7 files changed, 27 insertions(+), 29 deletions(-) diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h index 0f4d3aa19..703821dfd 100644 --- a/vp9/common/vp9_blockd.h +++ b/vp9/common/vp9_blockd.h @@ -197,7 +197,7 @@ struct macroblockd_plane { ENTROPY_CONTEXT *left_context; }; -#define BLOCK_OFFSET(x, i, n) ((x) + (i) * (n)) +#define BLOCK_OFFSET(x, i) ((x) + (i) * 16) typedef struct macroblockd { struct macroblockd_plane plane[MAX_MB_PLANE]; diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index 66ca50770..b80ba48e3 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -91,7 +91,7 @@ static void decode_block(int plane, int block, BLOCK_SIZE_TYPE bsize, int ss_txfrm_size, void *arg) { MACROBLOCKD* const xd = arg; struct macroblockd_plane *pd = &xd->plane[plane]; - int16_t* const qcoeff = BLOCK_OFFSET(pd->qcoeff, block, 16); + int16_t* const qcoeff = BLOCK_OFFSET(pd->qcoeff, block); const int stride = pd->dst.stride; const int eob = pd->eobs[block]; const int raster_block = txfrm_block_to_raster_block(xd, bsize, plane, diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c index 916b7210e..021eb11e3 100644 --- a/vp9/decoder/vp9_detokenize.c +++ b/vp9/decoder/vp9_detokenize.c @@ -271,7 +271,7 @@ static void decode_block(int plane, int block, ENTROPY_CONTEXT *L = pd->left_context + loff; const int eob = decode_coefs(&arg->pbi->common, xd, arg->r, block, pd->plane_type, seg_eob, - BLOCK_OFFSET(pd->qcoeff, block, 16), + BLOCK_OFFSET(pd->qcoeff, block), ss_tx_size, pd->dequant, A, L); if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) { diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c index a43c35733..80b0cb573 100644 --- a/vp9/encoder/vp9_encodemb.c +++ b/vp9/encoder/vp9_encodemb.c @@ -149,8 +149,7 @@ static void optimize_b(MACROBLOCK *mb, const int ref = is_inter_block(&xd->mode_info_context->mbmi); vp9_token_state tokens[1025][2]; unsigned best_index[1025][2]; - const int16_t *coeff_ptr = BLOCK_OFFSET(mb->plane[plane].coeff, - block, 16); + const int16_t *coeff_ptr = BLOCK_OFFSET(mb->plane[plane].coeff, block); int16_t *qcoeff_ptr; int16_t *dqcoeff_ptr; int eob = xd->plane[plane].eobs[block], final_eob, sz = 0; @@ -171,8 +170,8 @@ static void optimize_b(MACROBLOCK *mb, const uint8_t * band_translate; assert((!type && !plane) || (type && plane)); - dqcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].dqcoeff, block, 16); - qcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].qcoeff, block, 16); + dqcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].dqcoeff, block); + qcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].qcoeff, block); switch (tx_size) { default: case TX_4X4: @@ -456,9 +455,9 @@ void xform_quant(int plane, int block, BLOCK_SIZE_TYPE bsize, MACROBLOCKD* const xd = &x->e_mbd; struct macroblock_plane *const p = &x->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane]; - int16_t *coeff = BLOCK_OFFSET(p->coeff, block, 16); - int16_t *qcoeff = BLOCK_OFFSET(pd->qcoeff, block, 16); - int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block, 16); + int16_t *coeff = BLOCK_OFFSET(p->coeff, block); + int16_t *qcoeff = BLOCK_OFFSET(pd->qcoeff, block); + int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); const int16_t *scan, *iscan; uint16_t *eob = &pd->eobs[block]; const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size / 2); @@ -531,7 +530,7 @@ static void encode_block(int plane, int block, BLOCK_SIZE_TYPE bsize, const int raster_block = txfrm_block_to_raster_block(xd, bsize, plane, block, ss_txfrm_size); struct macroblockd_plane *const pd = &xd->plane[plane]; - int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block, 16); + int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); uint8_t *const dst = raster_block_offset_uint8(xd, bsize, plane, raster_block, pd->dst.buf, pd->dst.stride); @@ -634,9 +633,9 @@ void encode_block_intra(int plane, int block, BLOCK_SIZE_TYPE bsize, const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size / 2); struct macroblock_plane *const p = &x->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane]; - int16_t *coeff = BLOCK_OFFSET(p->coeff, block, 16); - int16_t *qcoeff = BLOCK_OFFSET(pd->qcoeff, block, 16); - int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block, 16); + int16_t *coeff = BLOCK_OFFSET(p->coeff, block); + int16_t *qcoeff = BLOCK_OFFSET(pd->qcoeff, block); + int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); const int16_t *scan, *iscan; TX_TYPE tx_type; MB_PREDICTION_MODE mode; diff --git a/vp9/encoder/vp9_quantize.c b/vp9/encoder/vp9_quantize.c index 525f4da79..5a04a4b50 100644 --- a/vp9/encoder/vp9_quantize.c +++ b/vp9/encoder/vp9_quantize.c @@ -159,14 +159,14 @@ void vp9_regular_quantize_b_4x4(MACROBLOCK *mb, int b_idx, TX_TYPE tx_type, const int16_t *scan = get_scan_4x4(tx_type); const int16_t *iscan = get_iscan_4x4(tx_type); - vp9_quantize_b(BLOCK_OFFSET(mb->plane[pb_idx.plane].coeff, pb_idx.block, 16), + vp9_quantize_b(BLOCK_OFFSET(mb->plane[pb_idx.plane].coeff, pb_idx.block), 16, mb->skip_block, mb->plane[pb_idx.plane].zbin, mb->plane[pb_idx.plane].round, mb->plane[pb_idx.plane].quant, mb->plane[pb_idx.plane].quant_shift, - BLOCK_OFFSET(xd->plane[pb_idx.plane].qcoeff, pb_idx.block, 16), - BLOCK_OFFSET(xd->plane[pb_idx.plane].dqcoeff, pb_idx.block, 16), + BLOCK_OFFSET(xd->plane[pb_idx.plane].qcoeff, pb_idx.block), + BLOCK_OFFSET(xd->plane[pb_idx.plane].dqcoeff, pb_idx.block), xd->plane[pb_idx.plane].dequant, mb->plane[pb_idx.plane].zbin_extra, &xd->plane[pb_idx.plane].eobs[pb_idx.block], diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 9e4ce711b..6a9006a6c 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -495,7 +495,7 @@ static INLINE int cost_coeffs(MACROBLOCK *mb, int pt, c, cost; const int16_t *band_count = &band_counts[tx_size][1]; const int eob = xd->plane[plane].eobs[block]; - const int16_t *qcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].qcoeff, block, 16); + const int16_t *qcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].qcoeff, block); const int ref = mbmi->ref_frame[0] != INTRA_FRAME; unsigned int (*token_costs)[2][PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = mb->token_costs[tx_size][type][ref]; @@ -581,8 +581,8 @@ static void dist_block(int plane, int block, BLOCK_SIZE_TYPE bsize, struct macroblockd_plane *const pd = &xd->plane[0]; int64_t this_sse; int shift = args->tx_size == TX_32X32 ? 0 : 2; - int16_t *const coeff = BLOCK_OFFSET(p->coeff, block, 16); - int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block, 16); + int16_t *const coeff = BLOCK_OFFSET(p->coeff, block); + int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); args->dist += vp9_block_error(coeff, dqcoeff, 16 << ss_txfrm_size, &this_sse) >> shift; args->sse += this_sse >> shift; @@ -1188,7 +1188,7 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib, xd->mode_info_context->bmi[block].as_mode = mode; src_diff = raster_block_offset_int16(xd, BLOCK_8X8, 0, block, p->src_diff); - coeff = BLOCK_OFFSET(x->plane[0].coeff, block, 16); + coeff = BLOCK_OFFSET(x->plane[0].coeff, block); vp9_predict_intra_block(xd, block, 1, TX_4X4, mode, x->skip_encode ? src : dst, @@ -1211,17 +1211,16 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib, ratey += cost_coeffs(x, 0, block, PLANE_TYPE_Y_WITH_DC, tempa + idx, templ + idy, TX_4X4, scan, vp9_get_coef_neighbors_handle(scan)); - distortion += vp9_block_error(coeff, BLOCK_OFFSET(pd->dqcoeff, - block, 16), + distortion += vp9_block_error(coeff, BLOCK_OFFSET(pd->dqcoeff, block), 16, &ssz) >> 2; if (RDCOST(x->rdmult, x->rddiv, ratey, distortion) >= best_rd) goto next; if (tx_type != DCT_DCT) - vp9_short_iht4x4_add(BLOCK_OFFSET(pd->dqcoeff, block, 16), + vp9_short_iht4x4_add(BLOCK_OFFSET(pd->dqcoeff, block), dst, pd->dst.stride, tx_type); else - xd->inv_txm4x4_add(BLOCK_OFFSET(pd->dqcoeff, block, 16), + xd->inv_txm4x4_add(BLOCK_OFFSET(pd->dqcoeff, block), dst, pd->dst.stride); } } @@ -1628,7 +1627,7 @@ static int64_t encode_inter_mb_segment(VP9_COMP *cpi, src_stride); int16_t* src_diff = raster_block_offset_int16(xd, BLOCK_8X8, 0, i, x->plane[0].src_diff); - int16_t* coeff = BLOCK_OFFSET(x->plane[0].coeff, 16, i); + int16_t* coeff = BLOCK_OFFSET(x->plane[0].coeff, i); uint8_t* const pre = raster_block_offset_uint8(xd, BLOCK_8X8, 0, i, pd->pre[0].buf, pd->pre[0].stride); @@ -1666,10 +1665,10 @@ static int64_t encode_inter_mb_segment(VP9_COMP *cpi, k += (idy * 2 + idx); src_diff = raster_block_offset_int16(xd, BLOCK_8X8, 0, k, x->plane[0].src_diff); - coeff = BLOCK_OFFSET(x->plane[0].coeff, 16, k); + coeff = BLOCK_OFFSET(x->plane[0].coeff, k); x->fwd_txm4x4(src_diff, coeff, 16); x->quantize_b_4x4(x, k, DCT_DCT, 16); - thisdistortion += vp9_block_error(coeff, BLOCK_OFFSET(pd->dqcoeff, k, 16), + thisdistortion += vp9_block_error(coeff, BLOCK_OFFSET(pd->dqcoeff, k), 16, &ssz); thissse += ssz; thisrate += cost_coeffs(x, 0, k, PLANE_TYPE_Y_WITH_DC, diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c index caa89b218..d52f9b2bb 100644 --- a/vp9/encoder/vp9_tokenize.c +++ b/vp9/encoder/vp9_tokenize.c @@ -135,7 +135,7 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize, TOKENEXTRA *t = *tp; /* store tokens starting here */ const int eob = xd->plane[plane].eobs[block]; const PLANE_TYPE type = xd->plane[plane].plane_type; - const int16_t *qcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].qcoeff, block, 16); + const int16_t *qcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].qcoeff, block); const int bwl = b_width_log2(bsize); const int off = block >> (2 * tx_size); const int mod = bwl - tx_size - xd->plane[plane].subsampling_x;