From b66f7016c1eed780545efa2518a7f33ae401ee35 Mon Sep 17 00:00:00 2001 From: Jingning Han Date: Tue, 7 Oct 2014 12:30:33 -0700 Subject: [PATCH] Take out repeated block width/height lookup functions The functions b_width_log2 and b_height_log2 only do direct table fetch. This commit unifies such use cases by using the table directly and removes these functions. Change-Id: I3103fc6ba959c1182886a2799d21b8b77c8a7b6b --- vp9/common/vp9_blockd.h | 9 +-------- vp9/common/vp9_onyxc_int.h | 2 +- vp9/decoder/vp9_decodeframe.c | 2 +- vp9/encoder/vp9_bitstream.c | 2 +- vp9/encoder/vp9_encodeframe.c | 18 +++++++++--------- vp9/encoder/vp9_encodemb.c | 2 +- vp9/encoder/vp9_pickmode.c | 4 ++-- vp9/encoder/vp9_rdopt.c | 14 +++++++------- 8 files changed, 23 insertions(+), 30 deletions(-) diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h index 702efe07b..01de4aa65 100644 --- a/vp9/common/vp9_blockd.h +++ b/vp9/common/vp9_blockd.h @@ -111,13 +111,6 @@ typedef enum { MAX_REF_FRAMES = 4 } MV_REFERENCE_FRAME; -static INLINE int b_width_log2(BLOCK_SIZE sb_type) { - return b_width_log2_lookup[sb_type]; -} -static INLINE int b_height_log2(BLOCK_SIZE sb_type) { - return b_height_log2_lookup[sb_type]; -} - static INLINE int mi_width_log2(BLOCK_SIZE sb_type) { return mi_width_log2_lookup[sb_type]; } @@ -312,7 +305,7 @@ void vp9_foreach_transformed_block( static INLINE void txfrm_block_to_raster_xy(BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int block, int *x, int *y) { - const int bwl = b_width_log2(plane_bsize); + const int bwl = b_width_log2_lookup[plane_bsize]; const int tx_cols_log2 = bwl - tx_size; const int tx_cols = 1 << tx_cols_log2; const int raster_mb = block >> (tx_size << 1); diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index 3954c459b..eeaff7fb9 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -333,7 +333,7 @@ static INLINE int partition_plane_context(const MACROBLOCKD *xd, const int bs = 1 << bsl; int above = 0, left = 0, i; - assert(b_width_log2(bsize) == b_height_log2(bsize)); + assert(b_width_log2_lookup[bsize] == b_height_log2_lookup[bsize]); assert(bsl >= 0); for (i = 0; i < bs; i++) { diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c index c78e97dfd..c54611fba 100644 --- a/vp9/decoder/vp9_decodeframe.c +++ b/vp9/decoder/vp9_decodeframe.c @@ -318,7 +318,7 @@ static void predict_and_reconstruct_intra_block(int plane, int block, dst = &pd->dst.buf[4 * y * pd->dst.stride + 4 * x]; vp9_predict_intra_block(xd, block >> (tx_size << 1), - b_width_log2(plane_bsize), tx_size, mode, + b_width_log2_lookup[plane_bsize], tx_size, mode, dst, pd->dst.stride, dst, pd->dst.stride, x, y, plane); diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index 5114fc55f..694cac76f 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -431,7 +431,7 @@ static void write_modes_sb(VP9_COMP *cpi, const VP9_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &cpi->mb.e_mbd; - const int bsl = b_width_log2(bsize); + const int bsl = b_width_log2_lookup[bsize]; const int bs = (1 << bsl) / 4; PARTITION_TYPE partition; BLOCK_SIZE subsize; diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 81d5d592f..6183f1fe2 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -1012,7 +1012,7 @@ static void encode_sb(VP9_COMP *cpi, const TileInfo *const tile, MACROBLOCK *const x = &cpi->mb; MACROBLOCKD *const xd = &x->e_mbd; - const int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4; + const int bsl = b_width_log2_lookup[bsize], hbs = (1 << bsl) / 4; int ctx; PARTITION_TYPE partition; BLOCK_SIZE subsize = bsize; @@ -1441,7 +1441,7 @@ static void encode_sb_rt(VP9_COMP *cpi, const TileInfo *const tile, MACROBLOCK *const x = &cpi->mb; MACROBLOCKD *const xd = &x->e_mbd; - const int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4; + const int bsl = b_width_log2_lookup[bsize], hbs = (1 << bsl) / 4; int ctx; PARTITION_TYPE partition; BLOCK_SIZE subsize; @@ -1514,7 +1514,7 @@ static void rd_use_partition(VP9_COMP *cpi, MACROBLOCK *const x = &cpi->mb; MACROBLOCKD *const xd = &x->e_mbd; const int mis = cm->mi_stride; - const int bsl = b_width_log2(bsize); + const int bsl = b_width_log2_lookup[bsize]; const int mi_step = num_4x4_blocks_wide_lookup[bsize] / 2; const int bss = (1 << bsl) / 4; int i, pl; @@ -2270,8 +2270,8 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, pc_tree->partitioning = PARTITION_NONE; // Adjust dist breakout threshold according to the partition size. - dist_breakout_thr >>= 8 - (b_width_log2(bsize) + - b_height_log2(bsize)); + dist_breakout_thr >>= 8 - (b_width_log2_lookup[bsize] + + b_height_log2_lookup[bsize]); rate_breakout_thr *= num_pels_log2_lookup[bsize]; @@ -2727,7 +2727,7 @@ static void fill_mode_info_sb(VP9_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize, BLOCK_SIZE subsize, PC_TREE *pc_tree) { MACROBLOCKD *xd = &x->e_mbd; - int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4; + int bsl = b_width_log2_lookup[bsize], hbs = (1 << bsl) / 4; PARTITION_TYPE partition = pc_tree->partitioning; assert(bsize >= BLOCK_8X8); @@ -2856,8 +2856,8 @@ static void nonrd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, pc_tree->partitioning = PARTITION_NONE; // Adjust threshold according to partition size. - stop_thresh >>= 8 - (b_width_log2(bsize) + - b_height_log2(bsize)); + stop_thresh >>= 8 - (b_width_log2_lookup[bsize] + + b_height_log2_lookup[bsize]); stop_thresh_rd = RDCOST(x->rdmult, x->rddiv, 0, stop_thresh); // If obtained distortion is very small, choose current partition @@ -3049,7 +3049,7 @@ static void nonrd_use_partition(VP9_COMP *cpi, VP9_COMMON *const cm = &cpi->common; MACROBLOCK *const x = &cpi->mb; MACROBLOCKD *const xd = &x->e_mbd; - const int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4; + const int bsl = b_width_log2_lookup[bsize], hbs = (1 << bsl) / 4; const int mis = cm->mi_stride; PARTITION_TYPE partition; BLOCK_SIZE subsize; diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c index 3b456b972..594dfb9e3 100644 --- a/vp9/encoder/vp9_encodemb.c +++ b/vp9/encoder/vp9_encodemb.c @@ -814,7 +814,7 @@ static void encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, const scan_order *scan_order; TX_TYPE tx_type; PREDICTION_MODE mode; - const int bwl = b_width_log2(plane_bsize); + const int bwl = b_width_log2_lookup[plane_bsize]; const int diff_stride = 4 * (1 << bwl); uint8_t *src, *dst; int16_t *src_diff; diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c index 428767a44..9abc9d1fb 100644 --- a/vp9/encoder/vp9_pickmode.c +++ b/vp9/encoder/vp9_pickmode.c @@ -339,7 +339,7 @@ static void encode_breakout_test(VP9_COMP *cpi, MACROBLOCK *x, // Adjust ac threshold according to partition size. thresh_ac >>= - 8 - (b_width_log2(bsize) + b_height_log2(bsize)); + 8 - (b_width_log2_lookup[bsize] + b_height_log2_lookup[bsize]); thresh_dc = (xd->plane[0].dequant[0] * xd->plane[0].dequant[0] >> 6); #if CONFIG_VP9_HIGHBITDEPTH @@ -433,7 +433,7 @@ static void estimate_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, pd->dst.buf = &dst_buf_base[4 * (j * dst_stride + i)]; // Use source buffer as an approximation for the fully reconstructed buffer. vp9_predict_intra_block(xd, block >> (2 * tx_size), - b_width_log2(plane_bsize), + b_width_log2_lookup[plane_bsize], tx_size, args->mode, p->src.buf, src_stride, pd->dst.buf, dst_stride, diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index f793269ee..b3dfbb058 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -131,7 +131,7 @@ static const REF_DEFINITION vp9_ref_order[MAX_REFS] = { static int raster_block_offset(BLOCK_SIZE plane_bsize, int raster_block, int stride) { - const int bw = b_width_log2(plane_bsize); + const int bw = b_width_log2_lookup[plane_bsize]; const int y = 4 * (raster_block >> bw); const int x = 4 * (raster_block & ((1 << bw) - 1)); return y * stride + x; @@ -2072,14 +2072,14 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x, } if (cpi->sf.adaptive_motion_search && bsize < BLOCK_64X64) { - int boffset = 2 * (b_width_log2(BLOCK_64X64) - MIN(b_height_log2(bsize), - b_width_log2(bsize))); + int boffset = 2 * (b_width_log2_lookup[BLOCK_64X64] - + MIN(b_height_log2_lookup[bsize], b_width_log2_lookup[bsize])); step_param = MAX(step_param, boffset); } if (cpi->sf.adaptive_motion_search) { - int bwl = b_width_log2(bsize); - int bhl = b_height_log2(bsize); + int bwl = b_width_log2_lookup[bsize]; + int bhl = b_height_log2_lookup[bsize]; int i; int tlevel = x->pred_mv_sad[ref] >> (bwl + bhl + 4); @@ -2374,8 +2374,8 @@ static void rd_encode_breakout_test(VP9_COMP *cpi, MACROBLOCK *x, thresh_ac = clamp(thresh_ac, min_thresh, max_thresh); // Adjust threshold according to partition size. - thresh_ac >>= 8 - (b_width_log2(bsize) + - b_height_log2(bsize)); + thresh_ac >>= 8 - (b_width_log2_lookup[bsize] + + b_height_log2_lookup[bsize]); thresh_dc = (xd->plane[0].dequant[0] * xd->plane[0].dequant[0] >> 6); #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { -- 2.40.0