Commit 839467f4 authored by David Barker's avatar David Barker Committed by Debargha Mukherjee

Make ext-inter use new rectangular intra predictor

Now that https://aomedia-review.googlesource.com/#/c/6729/
has been merged, build_intra_predictors_for_interintra() is
now redundant, so replace it by a direct call to
av1_predict_intra_block() and remove the old function.

Reset rect_interintra back to 1.

To do this, we need to make the intra predictor take a
BLOCK_SIZE instead of a TX_SIZE. This is because we need to
be able to predict 32x64 and 64x32 blocks, but there is no
TX_32X64 or TX_64X32.

No effect on output or performance.

Change-Id: I8c185a211c97a85012cc54ec293c785a693608ed
parent a93e65e5
......@@ -40,7 +40,7 @@ extern "C" {
#if CONFIG_EXT_INTER
// Should we try rectangular interintra predictions?
#define USE_RECT_INTERINTRA 0
#define USE_RECT_INTERINTRA 1
#if CONFIG_COMPOUND_SEGMENT
......
......@@ -2588,113 +2588,18 @@ static void combine_interintra_highbd(
}
#endif // CONFIG_AOM_HIGHBITDEPTH
// TODO(urvang/davidbarker): Refactor with av1_predict_intra_block().
static void build_intra_predictors_for_interintra(MACROBLOCKD *xd, uint8_t *ref,
int ref_stride, uint8_t *dst,
int dst_stride,
PREDICTION_MODE mode,
BLOCK_SIZE bsize, int plane) {
struct macroblockd_plane *const pd = &xd->plane[plane];
BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, &xd->plane[plane]);
const int bwl = block_size_wide[plane_bsize];
const int bhl = block_size_high[plane_bsize];
TX_SIZE max_tx_size = max_txsize_lookup[plane_bsize];
#if USE_RECT_INTERINTRA
const int pxbw = block_size_wide[plane_bsize];
const int pxbh = block_size_high[plane_bsize];
#if CONFIG_AOM_HIGHBITDEPTH
uint16_t tmp16[MAX_SB_SIZE];
#endif
uint8_t tmp[MAX_SB_SIZE];
#endif
if (bwl == bhl) {
av1_predict_intra_block(xd, pd->width, pd->height, max_tx_size, mode, ref,
ref_stride, dst, dst_stride, 0, 0, plane);
#if !USE_RECT_INTERINTRA
} else {
assert(0);
}
#else
} else if (bwl < bhl) {
uint8_t *src_2 = ref + pxbw * ref_stride;
uint8_t *dst_2 = dst + pxbw * dst_stride;
av1_predict_intra_block(xd, pd->width, pd->height, max_tx_size, mode, ref,
ref_stride, dst, dst_stride, 0, 0, plane);
#if CONFIG_AOM_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
uint16_t *src_216 = CONVERT_TO_SHORTPTR(src_2);
uint16_t *dst_216 = CONVERT_TO_SHORTPTR(dst_2);
memcpy(tmp16, src_216 - ref_stride, sizeof(*src_216) * pxbw);
memcpy(src_216 - ref_stride, dst_216 - dst_stride,
sizeof(*src_216) * pxbw);
} else {
#endif // CONFIG_AOM_HIGHBITDEPTH
memcpy(tmp, src_2 - ref_stride, sizeof(*src_2) * pxbw);
memcpy(src_2 - ref_stride, dst_2 - dst_stride, sizeof(*src_2) * pxbw);
#if CONFIG_AOM_HIGHBITDEPTH
}
#endif
av1_predict_intra_block(xd, pd->width, pd->height, max_tx_size, mode, src_2,
ref_stride, dst_2, dst_stride, 0,
mi_size_wide[plane_bsize], plane);
#if CONFIG_AOM_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
uint16_t *src_216 = CONVERT_TO_SHORTPTR(src_2);
memcpy(src_216 - ref_stride, tmp16, sizeof(*src_216) * pxbw);
} else {
#endif // CONFIG_AOM_HIGHBITDEPTH
memcpy(src_2 - ref_stride, tmp, sizeof(*src_2) * pxbw);
#if CONFIG_AOM_HIGHBITDEPTH
}
#endif
} else { // bwl > bhl
int i;
uint8_t *src_2 = ref + pxbh;
uint8_t *dst_2 = dst + pxbh;
av1_predict_intra_block(xd, pd->width, pd->height, max_tx_size, mode, ref,
ref_stride, dst, dst_stride, 0, 0, plane);
#if CONFIG_AOM_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
uint16_t *src_216 = CONVERT_TO_SHORTPTR(src_2);
uint16_t *dst_216 = CONVERT_TO_SHORTPTR(dst_2);
for (i = 0; i < pxbh; ++i) {
tmp16[i] = src_216[i * ref_stride - 1];
src_216[i * ref_stride - 1] = dst_216[i * dst_stride - 1];
}
} else {
#endif // CONFIG_AOM_HIGHBITDEPTH
for (i = 0; i < pxbh; ++i) {
tmp[i] = src_2[i * ref_stride - 1];
src_2[i * ref_stride - 1] = dst_2[i * dst_stride - 1];
}
#if CONFIG_AOM_HIGHBITDEPTH
}
#endif
av1_predict_intra_block(xd, pd->width, pd->height, max_tx_size, mode, src_2,
ref_stride, dst_2, dst_stride,
mi_size_high[plane_bsize], 0, plane);
#if CONFIG_AOM_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
uint16_t *src_216 = CONVERT_TO_SHORTPTR(src_2);
for (i = 0; i < pxbh; ++i) src_216[i * ref_stride - 1] = tmp16[i];
} else {
#endif // CONFIG_AOM_HIGHBITDEPTH
for (i = 0; i < pxbh; ++i) src_2[i * ref_stride - 1] = tmp[i];
#if CONFIG_AOM_HIGHBITDEPTH
}
#endif
}
#endif
}
void av1_build_intra_predictors_for_interintra(MACROBLOCKD *xd,
BLOCK_SIZE bsize, int plane,
BUFFER_SET *ctx, uint8_t *dst,
int dst_stride) {
build_intra_predictors_for_interintra(
xd, ctx->plane[plane], ctx->stride[plane], dst, dst_stride,
interintra_to_intra_mode[xd->mi[0]->mbmi.interintra_mode], bsize, plane);
struct macroblockd_plane *const pd = &xd->plane[plane];
BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, &xd->plane[plane]);
PREDICTION_MODE mode =
interintra_to_intra_mode[xd->mi[0]->mbmi.interintra_mode];
av1_predict_intra_block(xd, pd->width, pd->height, plane_bsize, mode,
ctx->plane[plane], ctx->stride[plane], dst,
dst_stride, 0, 0, plane);
}
void av1_combine_interintra(MACROBLOCKD *xd, BLOCK_SIZE bsize, int plane,
......
......@@ -1977,40 +1977,41 @@ static void predict_square_intra_block(const MACROBLOCKD *xd, int wpx, int hpx,
}
void av1_predict_intra_block(const MACROBLOCKD *xd, int wpx, int hpx,
TX_SIZE tx_size, PREDICTION_MODE mode,
BLOCK_SIZE bsize, 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 int tx_width = tx_size_wide[tx_size];
const int tx_height = tx_size_high[tx_size];
if (tx_width == tx_height) {
const int block_width = block_size_wide[bsize];
const int block_height = block_size_high[bsize];
TX_SIZE tx_size = max_txsize_lookup[bsize];
assert(tx_size < TX_SIZES);
if (block_width == block_height) {
predict_square_intra_block(xd, wpx, hpx, tx_size, mode, ref, ref_stride,
dst, dst_stride, col_off, row_off, plane);
} else {
#if (CONFIG_VAR_TX || CONFIG_RECT_TX)
#if (CONFIG_VAR_TX || CONFIG_RECT_TX) || \
(CONFIG_EXT_INTER && USE_RECT_INTERINTRA)
#if CONFIG_AOM_HIGHBITDEPTH
uint16_t tmp16[MAX_SB_SIZE];
#endif
uint8_t tmp[MAX_SB_SIZE];
const TX_SIZE sub_tx_size = txsize_sqr_map[tx_size];
assert(sub_tx_size < TX_SIZES);
assert((tx_width == wpx && tx_height == hpx) ||
(tx_width == (wpx >> 1) && tx_height == hpx) ||
(tx_width == wpx && tx_height == (hpx >> 1)));
if (tx_width < tx_height) {
assert(tx_height == (tx_width << 1));
assert((block_width == wpx && block_height == hpx) ||
(block_width == (wpx >> 1) && block_height == hpx) ||
(block_width == wpx && block_height == (hpx >> 1)));
if (block_width < block_height) {
assert(block_height == (block_width << 1));
// Predict the top square sub-block.
predict_square_intra_block(xd, wpx, hpx, sub_tx_size, mode, ref,
ref_stride, dst, dst_stride, col_off, row_off,
plane);
predict_square_intra_block(xd, wpx, hpx, tx_size, mode, ref, ref_stride,
dst, dst_stride, col_off, row_off, plane);
{
const int half_tx_height = tx_height >> 1;
const int half_txh_unit = tx_size_high_unit[tx_size] >> 1;
const int half_block_height = block_height >> 1;
const int half_block_height_unit =
half_block_height >> tx_size_wide_log2[0];
// Cast away const to modify 'ref' temporarily; will be restored later.
uint8_t *src_2 = (uint8_t *)ref + half_tx_height * ref_stride;
uint8_t *dst_2 = dst + half_tx_height * dst_stride;
const int row_off_2 = row_off + half_txh_unit;
uint8_t *src_2 = (uint8_t *)ref + half_block_height * ref_stride;
uint8_t *dst_2 = dst + half_block_height * dst_stride;
const int row_off_2 = row_off + half_block_height_unit;
// Save the last row of top square sub-block as 'above' row for bottom
// square sub-block.
if (src_2 != dst_2 || ref_stride != dst_stride) {
......@@ -2018,20 +2019,21 @@ void av1_predict_intra_block(const MACROBLOCKD *xd, int wpx, int hpx,
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
uint16_t *src_2_16 = CONVERT_TO_SHORTPTR(src_2);
uint16_t *dst_2_16 = CONVERT_TO_SHORTPTR(dst_2);
memcpy(tmp16, src_2_16 - ref_stride, tx_width * sizeof(*src_2_16));
memcpy(tmp16, src_2_16 - ref_stride,
block_width * sizeof(*src_2_16));
memcpy(src_2_16 - ref_stride, dst_2_16 - dst_stride,
tx_width * sizeof(*src_2_16));
block_width * sizeof(*src_2_16));
} else {
#endif // CONFIG_AOM_HIGHBITDEPTH
memcpy(tmp, src_2 - ref_stride, tx_width * sizeof(*src_2));
memcpy(tmp, src_2 - ref_stride, block_width * sizeof(*src_2));
memcpy(src_2 - ref_stride, dst_2 - dst_stride,
tx_width * sizeof(*src_2));
block_width * sizeof(*src_2));
#if CONFIG_AOM_HIGHBITDEPTH
}
#endif // CONFIG_AOM_HIGHBITDEPTH
}
// Predict the bottom square sub-block.
predict_square_intra_block(xd, wpx, hpx, sub_tx_size, mode, src_2,
predict_square_intra_block(xd, wpx, hpx, tx_size, mode, src_2,
ref_stride, dst_2, dst_stride, col_off,
row_off_2, plane);
// Restore the last row of top square sub-block.
......@@ -2039,29 +2041,30 @@ void av1_predict_intra_block(const MACROBLOCKD *xd, int wpx, int hpx,
#if CONFIG_AOM_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
uint16_t *src_2_16 = CONVERT_TO_SHORTPTR(src_2);
memcpy(src_2_16 - ref_stride, tmp16, tx_width * sizeof(*src_2_16));
memcpy(src_2_16 - ref_stride, tmp16,
block_width * sizeof(*src_2_16));
} else {
#endif // CONFIG_AOM_HIGHBITDEPTH
memcpy(src_2 - ref_stride, tmp, tx_width * sizeof(*src_2));
memcpy(src_2 - ref_stride, tmp, block_width * sizeof(*src_2));
#if CONFIG_AOM_HIGHBITDEPTH
}
#endif // CONFIG_AOM_HIGHBITDEPTH
}
}
} else { // tx_width > tx_height
assert(tx_width == (tx_height << 1));
} else { // block_width > block_height
assert(block_width == (block_height << 1));
// Predict the left square sub-block
predict_square_intra_block(xd, wpx, hpx, sub_tx_size, mode, ref,
ref_stride, dst, dst_stride, col_off, row_off,
plane);
predict_square_intra_block(xd, wpx, hpx, tx_size, mode, ref, ref_stride,
dst, dst_stride, col_off, row_off, plane);
{
int i;
const int half_tx_width = tx_width >> 1;
const int half_txw_unit = tx_size_wide_unit[tx_size] >> 1;
const int half_block_width = block_width >> 1;
const int half_block_width_unit =
half_block_width >> tx_size_wide_log2[0];
// Cast away const to modify 'ref' temporarily; will be restored later.
uint8_t *src_2 = (uint8_t *)ref + half_tx_width;
uint8_t *dst_2 = dst + half_tx_width;
const int col_off_2 = col_off + half_txw_unit;
uint8_t *src_2 = (uint8_t *)ref + half_block_width;
uint8_t *dst_2 = dst + half_block_width;
const int col_off_2 = col_off + half_block_width_unit;
// Save the last column of left square sub-block as 'left' column for
// right square sub-block.
if (src_2 != dst_2 || ref_stride != dst_stride) {
......@@ -2069,13 +2072,13 @@ void av1_predict_intra_block(const MACROBLOCKD *xd, int wpx, int hpx,
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
uint16_t *src_2_16 = CONVERT_TO_SHORTPTR(src_2);
uint16_t *dst_2_16 = CONVERT_TO_SHORTPTR(dst_2);
for (i = 0; i < tx_height; ++i) {
for (i = 0; i < block_height; ++i) {
tmp16[i] = src_2_16[i * ref_stride - 1];
src_2_16[i * ref_stride - 1] = dst_2_16[i * dst_stride - 1];
}
} else {
#endif // CONFIG_AOM_HIGHBITDEPTH
for (i = 0; i < tx_height; ++i) {
for (i = 0; i < block_height; ++i) {
tmp[i] = src_2[i * ref_stride - 1];
src_2[i * ref_stride - 1] = dst_2[i * dst_stride - 1];
}
......@@ -2084,7 +2087,7 @@ void av1_predict_intra_block(const MACROBLOCKD *xd, int wpx, int hpx,
#endif // CONFIG_AOM_HIGHBITDEPTH
}
// Predict the right square sub-block.
predict_square_intra_block(xd, wpx, hpx, sub_tx_size, mode, src_2,
predict_square_intra_block(xd, wpx, hpx, tx_size, mode, src_2,
ref_stride, dst_2, dst_stride, col_off_2,
row_off, plane);
// Restore the last column of left square sub-block.
......@@ -2092,12 +2095,12 @@ void av1_predict_intra_block(const MACROBLOCKD *xd, int wpx, int hpx,
#if CONFIG_AOM_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
uint16_t *src_2_16 = CONVERT_TO_SHORTPTR(src_2);
for (i = 0; i < tx_height; ++i) {
for (i = 0; i < block_height; ++i) {
src_2_16[i * ref_stride - 1] = tmp16[i];
}
} else {
#endif // CONFIG_AOM_HIGHBITDEPTH
for (i = 0; i < tx_height; ++i) {
for (i = 0; i < block_height; ++i) {
src_2[i * ref_stride - 1] = tmp[i];
}
#if CONFIG_AOM_HIGHBITDEPTH
......
......@@ -22,7 +22,7 @@ extern "C" {
void av1_init_intra_predictors(void);
void av1_predict_intra_block(const MACROBLOCKD *xd, int bw, int bh,
TX_SIZE tx_size, PREDICTION_MODE mode,
BLOCK_SIZE bsize, PREDICTION_MODE mode,
const uint8_t *ref, int ref_stride, uint8_t *dst,
int dst_stride, int aoff, int loff, int plane);
......
......@@ -495,8 +495,9 @@ static void predict_and_reconstruct_intra_block(AV1_COMMON *cm,
if (plane == 0) mode = xd->mi[0]->bmi[block_idx].as_mode;
#endif
av1_predict_intra_block(xd, pd->width, pd->height, tx_size, mode, dst,
pd->dst.stride, dst, pd->dst.stride, col, row, plane);
av1_predict_intra_block(xd, pd->width, pd->height, txsize_to_bsize[tx_size],
mode, dst, pd->dst.stride, dst, pd->dst.stride, col,
row, plane);
if (!mbmi->skip) {
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
......
......@@ -973,8 +973,9 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
src_diff =
&p->src_diff[(blk_row * diff_stride + blk_col) << tx_size_wide_log2[0]];
mode = (plane == 0) ? get_y_mode(xd->mi[0], block_raster_idx) : mbmi->uv_mode;
av1_predict_intra_block(xd, pd->width, pd->height, tx_size, mode, dst,
dst_stride, dst, dst_stride, blk_col, blk_row, plane);
av1_predict_intra_block(xd, pd->width, pd->height, txsize_to_bsize[tx_size],
mode, dst, dst_stride, dst, dst_stride, blk_col,
blk_row, plane);
if (check_subtract_block_size(tx1d_width, tx1d_height)) {
#if CONFIG_AOM_HIGHBITDEPTH
......
......@@ -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, 16, 16, TX_16X16, mode, x->plane[0].src.buf,
av1_predict_intra_block(xd, 16, 16, BLOCK_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,
......
......@@ -2237,9 +2237,9 @@ static int64_t intra_model_yrd(const AV1_COMP *const cpi, MACROBLOCK *const x,
struct macroblockd_plane *const pd = &xd->plane[0];
uint8_t *dst =
&pd->dst.buf[(row * pd->dst.stride + col) << tx_size_wide_log2[0]];
av1_predict_intra_block(xd, pd->width, pd->height, tx_size, mbmi->mode,
dst, pd->dst.stride, dst, pd->dst.stride, col,
row, 0);
av1_predict_intra_block(xd, pd->width, pd->height,
txsize_to_bsize[tx_size], mbmi->mode, dst,
pd->dst.stride, dst, pd->dst.stride, col, row, 0);
}
}
// RD estimation.
......@@ -2558,9 +2558,9 @@ static int64_t rd_pick_intra_sub_8x8_y_subblock_mode(
assert(IMPLIES(tx_size == TX_4X8 || tx_size == TX_8X4,
block == 0 || block == 2));
xd->mi[0]->bmi[block_raster_idx].as_mode = mode;
av1_predict_intra_block(xd, pd->width, pd->height, tx_size, mode, dst,
dst_stride, dst, dst_stride, col + idx,
row + idy, 0);
av1_predict_intra_block(
xd, pd->width, pd->height, txsize_to_bsize[tx_size], mode, dst,
dst_stride, dst, dst_stride, col + idx, row + idy, 0);
aom_highbd_subtract_block(tx_height, tx_width, src_diff, 8, src,
src_stride, dst, dst_stride, xd->bd);
if (is_lossless) {
......@@ -2717,8 +2717,9 @@ static int64_t rd_pick_intra_sub_8x8_y_subblock_mode(
assert(IMPLIES(tx_size == TX_4X8 || tx_size == TX_8X4,
block == 0 || block == 2));
xd->mi[0]->bmi[block_raster_idx].as_mode = mode;
av1_predict_intra_block(xd, pd->width, pd->height, tx_size, mode, dst,
dst_stride, dst, dst_stride,
av1_predict_intra_block(xd, pd->width, pd->height,
txsize_to_bsize[tx_size], mode, dst, dst_stride,
dst, dst_stride,
#if CONFIG_CB4X4
2 * (col + idx), 2 * (row + idy),
#else
......
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