From c4c99da9259b07b72b8d44330badb7e339f505de Mon Sep 17 00:00:00 2001 From: Jingning Han Date: Mon, 24 Oct 2016 10:27:28 -0700 Subject: [PATCH] Refactor av1_predict_intra_block tx_size interface Simplify the input arguments. Make direct use of the block size in the unit of pixels. Change-Id: Ifec9d90b4b4fa9605f93b4f93b8242f76f898b5f --- av1/common/onyxc_int.h | 6 ++---- av1/common/reconintra.c | 12 ++++-------- av1/common/reconintra.h | 2 +- av1/decoder/decodeframe.c | 2 +- av1/encoder/encodemb.c | 6 ++---- av1/encoder/firstpass.c | 3 +++ av1/encoder/mbgraph.c | 2 +- av1/encoder/rdopt.c | 10 ++++++---- 8 files changed, 20 insertions(+), 23 deletions(-) diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h index bd810d430..6ec5c67d4 100644 --- a/av1/common/onyxc_int.h +++ b/av1/common/onyxc_int.h @@ -524,14 +524,12 @@ static INLINE void set_plane_n4(MACROBLOCKD *const xd, int bw, int bh, int bwl, int bhl) { int i; for (i = 0; i < MAX_MB_PLANE; i++) { - xd->plane[i].width = - block_size_wide[xd->mi[0]->mbmi.sb_type] >> xd->plane[i].subsampling_x; - xd->plane[i].height = - block_size_high[xd->mi[0]->mbmi.sb_type] >> xd->plane[i].subsampling_y; xd->plane[i].n4_w = (bw << 1) >> xd->plane[i].subsampling_x; xd->plane[i].n4_h = (bh << 1) >> xd->plane[i].subsampling_y; xd->plane[i].n4_wl = bwl - xd->plane[i].subsampling_x; xd->plane[i].n4_hl = bhl - xd->plane[i].subsampling_y; + xd->plane[i].width = xd->plane[i].n4_w * 4; + xd->plane[i].height = xd->plane[i].n4_h * 4; } } diff --git a/av1/common/reconintra.c b/av1/common/reconintra.c index 96ffb083b..70d10f08e 100644 --- a/av1/common/reconintra.c +++ b/av1/common/reconintra.c @@ -1509,25 +1509,21 @@ static void build_intra_predictors(const MACROBLOCKD *xd, const uint8_t *ref, } } -void av1_predict_intra_block(const MACROBLOCKD *xd, int bwl_in, int bhl_in, +void av1_predict_intra_block(const MACROBLOCKD *xd, int wpx, int hpx, TX_SIZE tx_size, PREDICTION_MODE mode, const uint8_t *ref, int ref_stride, uint8_t *dst, int dst_stride, int col_off, int row_off, int plane) { const BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type; const struct macroblockd_plane *const pd = &xd->plane[plane]; - const int txw = num_4x4_blocks_wide_txsize_lookup[tx_size]; - const int txh = num_4x4_blocks_high_txsize_lookup[tx_size]; + const int txw = tx_size_wide_unit[tx_size]; + const int txh = tx_size_high_unit[tx_size]; const int have_top = row_off || xd->up_available; const int have_left = col_off || xd->left_available; const int x = col_off * 4; const int y = row_off * 4; - const int bw = pd->subsampling_x ? 1 << bwl_in : AOMMAX(2, 1 << bwl_in); - const int bh = pd->subsampling_y ? 1 << bhl_in : AOMMAX(2, 1 << bhl_in); const int mi_row = -xd->mb_to_top_edge >> (3 + MI_SIZE_LOG2); const int mi_col = -xd->mb_to_left_edge >> (3 + MI_SIZE_LOG2); - const int wpx = 4 * bw; - const int hpx = 4 * bh; const int txwpx = 4 * txw; const int txhpx = 4 * txh; // Distance between the right edge of this prediction block to @@ -1556,7 +1552,7 @@ void av1_predict_intra_block(const MACROBLOCKD *xd, int bwl_in, int bhl_in, #if CONFIG_PALETTE if (xd->mi[0]->mbmi.palette_mode_info.palette_size[plane != 0] > 0) { const int bs = 4 * num_4x4_blocks_wide_txsize_lookup[tx_size]; - const int stride = 4 * (1 << bwl_in); + const int stride = wpx; int r, c; uint8_t *map = NULL; #if CONFIG_AOM_HIGHBITDEPTH diff --git a/av1/common/reconintra.h b/av1/common/reconintra.h index 7778874c2..23bad1cf2 100644 --- a/av1/common/reconintra.h +++ b/av1/common/reconintra.h @@ -21,7 +21,7 @@ extern "C" { void av1_init_intra_predictors(void); -void av1_predict_intra_block(const MACROBLOCKD *xd, int bwl_in, int bhl_in, +void av1_predict_intra_block(const MACROBLOCKD *xd, int bw, int bh, TX_SIZE tx_size, PREDICTION_MODE mode, const uint8_t *ref, int ref_stride, uint8_t *dst, int dst_stride, int aoff, int loff, int plane); diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c index 4cb7d8233..edbf46384 100644 --- a/av1/decoder/decodeframe.c +++ b/av1/decoder/decodeframe.c @@ -274,7 +274,7 @@ static void predict_and_reconstruct_intra_block(AV1_COMMON *cm, if (mbmi->sb_type < BLOCK_8X8) if (plane == 0) mode = xd->mi[0]->bmi[(row << 1) + col].as_mode; - av1_predict_intra_block(xd, pd->n4_wl, pd->n4_hl, tx_size, mode, dst, + av1_predict_intra_block(xd, pd->width, pd->height, tx_size, mode, dst, pd->dst.stride, dst, pd->dst.stride, col, row, plane); if (!mbmi->skip) { diff --git a/av1/encoder/encodemb.c b/av1/encoder/encodemb.c index 8914ba5c2..018fd5df5 100644 --- a/av1/encoder/encodemb.c +++ b/av1/encoder/encodemb.c @@ -1078,7 +1078,6 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col, const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size); PREDICTION_MODE mode; const int bwl = b_width_log2_lookup[plane_bsize]; - const int bhl = b_height_log2_lookup[plane_bsize]; const int diff_stride = 4 * (1 << bwl); uint8_t *src, *dst; int16_t *src_diff; @@ -1097,10 +1096,9 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col, dst = &pd->dst.buf[4 * (blk_row * dst_stride + blk_col)]; src = &p->src.buf[4 * (blk_row * src_stride + blk_col)]; src_diff = &p->src_diff[4 * (blk_row * diff_stride + blk_col)]; - mode = plane == 0 ? get_y_mode(xd->mi[0], block) : mbmi->uv_mode; - av1_predict_intra_block(xd, bwl, bhl, tx_size, mode, dst, dst_stride, dst, - dst_stride, blk_col, blk_row, plane); + av1_predict_intra_block(xd, pd->width, pd->height, tx_size, mode, dst, + dst_stride, dst, dst_stride, blk_col, blk_row, plane); #if CONFIG_AOM_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { aom_highbd_subtract_block(tx1d_height, tx1d_width, src_diff, diff_stride, diff --git a/av1/encoder/firstpass.c b/av1/encoder/firstpass.c index 466cb9c77..4d74246ed 100644 --- a/av1/encoder/firstpass.c +++ b/av1/encoder/firstpass.c @@ -579,6 +579,9 @@ void av1_first_pass(AV1_COMP *cpi, const struct lookahead_entry *source) { set_mi_row_col(xd, &tile, mb_row << 1, num_8x8_blocks_high_lookup[bsize], mb_col << 1, num_8x8_blocks_wide_lookup[bsize], cm->mi_rows, cm->mi_cols); + set_plane_n4(xd, num_8x8_blocks_wide_lookup[bsize], + num_8x8_blocks_high_lookup[bsize], + mi_width_log2_lookup[bsize], mi_height_log2_lookup[bsize]); // Do intra 16x16 prediction. xd->mi[0]->mbmi.segment_id = 0; diff --git a/av1/encoder/mbgraph.c b/av1/encoder/mbgraph.c index 9bbed2b48..1fd1682ca 100644 --- a/av1/encoder/mbgraph.c +++ b/av1/encoder/mbgraph.c @@ -149,7 +149,7 @@ static int find_best_16x16_intra(AV1_COMP *cpi, PREDICTION_MODE *pbest_mode) { unsigned int err; xd->mi[0]->mbmi.mode = mode; - av1_predict_intra_block(xd, 2, 2, TX_16X16, mode, x->plane[0].src.buf, + av1_predict_intra_block(xd, 16, 16, TX_16X16, mode, x->plane[0].src.buf, x->plane[0].src.stride, xd->plane[0].dst.buf, xd->plane[0].dst.stride, 0, 0, 0); err = aom_sad16x16(x->plane[0].src.buf, x->plane[0].src.stride, diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c index 627352b51..82716fecc 100644 --- a/av1/encoder/rdopt.c +++ b/av1/encoder/rdopt.c @@ -1944,8 +1944,9 @@ static int64_t rd_pick_intra4x4block( int16_t *const src_diff = av1_raster_block_offset_int16(BLOCK_8X8, block, p->src_diff); xd->mi[0]->bmi[block].as_mode = mode; - av1_predict_intra_block(xd, 1, 1, TX_4X4, mode, dst, dst_stride, dst, - dst_stride, col + idx, row + idy, 0); + av1_predict_intra_block(xd, pd->width, pd->height, TX_4X4, mode, dst, + dst_stride, dst, dst_stride, col + idx, + row + idy, 0); aom_highbd_subtract_block(4, 4, src_diff, 8, src, src_stride, dst, dst_stride, xd->bd); if (xd->lossless[xd->mi[0]->mbmi.segment_id]) { @@ -2064,8 +2065,9 @@ static int64_t rd_pick_intra4x4block( int16_t *const src_diff = av1_raster_block_offset_int16(BLOCK_8X8, block, p->src_diff); xd->mi[0]->bmi[block].as_mode = mode; - av1_predict_intra_block(xd, 1, 1, TX_4X4, mode, dst, dst_stride, dst, - dst_stride, col + idx, row + idy, 0); + av1_predict_intra_block(xd, pd->width, pd->height, TX_4X4, mode, dst, + dst_stride, dst, dst_stride, col + idx, + row + idy, 0); aom_subtract_block(4, 4, src_diff, 8, src, src_stride, dst, dst_stride); if (xd->lossless[xd->mi[0]->mbmi.segment_id]) {