Commit c4c99da9 authored by Jingning Han's avatar Jingning Han

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
parent c47fe6c6
......@@ -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;
}
}
......
......@@ -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
......
......@@ -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);
......
......@@ -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) {
......
......@@ -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,
......
......@@ -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;
......
......@@ -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,
......
......@@ -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]) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment