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
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index bd810d4..6ec5c67 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -524,14 +524,12 @@
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 96ffb08..70d10f0 100644
--- a/av1/common/reconintra.c
+++ b/av1/common/reconintra.c
@@ -1509,25 +1509,21 @@
}
}
-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 @@
#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 7778874..23bad1c 100644
--- a/av1/common/reconintra.h
+++ b/av1/common/reconintra.h
@@ -21,7 +21,7 @@
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 4cb7d82..edbf463 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -274,7 +274,7 @@
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 8914ba5..018fd5d 100644
--- a/av1/encoder/encodemb.c
+++ b/av1/encoder/encodemb.c
@@ -1078,7 +1078,6 @@
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 @@
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 466cb9c..4d74246 100644
--- a/av1/encoder/firstpass.c
+++ b/av1/encoder/firstpass.c
@@ -579,6 +579,9 @@
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 9bbed2b..1fd1682 100644
--- a/av1/encoder/mbgraph.c
+++ b/av1/encoder/mbgraph.c
@@ -149,7 +149,7 @@
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 627352b..82716fe 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -1944,8 +1944,9 @@
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 @@
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]) {