Commit 6396d3ac authored by Debargha Mukherjee's avatar Debargha Mukherjee

Bake in large chroma transforms for inter/intra

Bakes in DISABLE_VARTX_FOR_CHROMA/DISABLE_SMLTX_FOR_CHROMA_INTRA
macros.
Cleans up code and removes the unwieldy uv_txsize_lookup array.

Change-Id: I9aec8bfcfe218791517ab18e427bc645687916c3
parent 94e3fe3b
......@@ -1434,11 +1434,9 @@ static void get_filter_level_and_masks_non420(
(blk_row * mi_size_high[BLOCK_8X8] << TX_UNIT_HIGH_LOG2) >> 1;
const int tx_col_idx =
(blk_col * mi_size_wide[BLOCK_8X8] << TX_UNIT_WIDE_LOG2) >> 1;
const BLOCK_SIZE bsize = get_plane_block_size(mbmi->sb_type, plane);
const TX_SIZE mb_tx_size = mbmi->inter_tx_size[tx_row_idx][tx_col_idx];
tx_size = (plane->plane_type == PLANE_TYPE_UV)
? av1_get_uv_tx_size_vartx(mbmi, plane, bsize, tx_row_idx,
tx_col_idx)
? av1_get_uv_tx_size(mbmi, ss_x, ss_y)
: mb_tx_size;
}
......@@ -2003,12 +2001,10 @@ static const uint32_t av1_transform_masks[NUM_EDGE_DIRS][TX_SIZES_ALL] = {
}
};
static TX_SIZE av1_get_transform_size(const MODE_INFO *const mi,
const EDGE_DIR edge_dir, const int mi_row,
static TX_SIZE av1_get_transform_size(
const MODE_INFO *const mi, const EDGE_DIR edge_dir, const int mi_row,
const int mi_col, const int plane,
const struct macroblockd_plane *plane_ptr,
const uint32_t scale_horz,
const uint32_t scale_vert) {
const struct macroblockd_plane *plane_ptr) {
const MB_MODE_INFO *mbmi = &mi->mbmi;
TX_SIZE tx_size = (plane == AOM_PLANE_Y)
? mbmi->tx_size
......@@ -2034,14 +2030,14 @@ static TX_SIZE av1_get_transform_size(const MODE_INFO *const mi,
(blk_row * mi_size_high[BLOCK_8X8] << TX_UNIT_HIGH_LOG2) >> 1;
const int tx_col_idx =
(blk_col * mi_size_wide[BLOCK_8X8] << TX_UNIT_WIDE_LOG2) >> 1;
const BLOCK_SIZE bsize = ss_size_lookup[sb_type][scale_horz][scale_vert];
const TX_SIZE mb_tx_size = mbmi->inter_tx_size[tx_row_idx][tx_col_idx];
assert(mb_tx_size < TX_SIZES_ALL);
tx_size = (plane == AOM_PLANE_Y) ? mb_tx_size : av1_get_uv_tx_size_vartx(
mbmi, plane_ptr, bsize,
tx_row_idx, tx_col_idx);
tx_size = (plane == AOM_PLANE_Y)
? mb_tx_size
: av1_get_uv_tx_size(mbmi, plane_ptr->subsampling_x,
plane_ptr->subsampling_y);
assert(tx_size < TX_SIZES_ALL);
}
......@@ -2089,9 +2085,8 @@ static void set_lpf_parameters(
const MB_MODE_INFO *mbmi = &mi[0]->mbmi;
{
const TX_SIZE ts =
av1_get_transform_size(mi[0], edge_dir, mi_row, mi_col, plane,
plane_ptr, scale_horz, scale_vert);
const TX_SIZE ts = av1_get_transform_size(mi[0], edge_dir, mi_row, mi_col,
plane, plane_ptr);
#if CONFIG_EXT_DELTA_Q
#if CONFIG_LOOPFILTER_LEVEL
......@@ -2128,9 +2123,8 @@ static void set_lpf_parameters(
(VERT_EDGE == edge_dir) ? (mi_row) : (mi_row - (1 << scale_vert));
const int pv_col =
(VERT_EDGE == edge_dir) ? (mi_col - (1 << scale_horz)) : (mi_col);
const TX_SIZE pv_ts =
av1_get_transform_size(mi_prev, edge_dir, pv_row, pv_col, plane,
plane_ptr, scale_horz, scale_vert);
const TX_SIZE pv_ts = av1_get_transform_size(
mi_prev, edge_dir, pv_row, pv_col, plane, plane_ptr);
#if CONFIG_EXT_DELTA_Q
#if CONFIG_LOOPFILTER_LEVEL
......
......@@ -39,12 +39,6 @@ extern "C" {
#define COMPOUND_SEGMENT_TYPE 1
#define MAX_SEG_MASK_BITS 1
// Disables vartx transform split for chroma
#define DISABLE_VARTX_FOR_CHROMA 1
// Disables small transform split for intra modes.
#define DISABLE_SMLTX_FOR_CHROMA_INTRA 1
// SEG_MASK_TYPES should not surpass 1 << MAX_SEG_MASK_BITS
typedef enum {
#if COMPOUND_SEGMENT_TYPE == 0
......@@ -1151,23 +1145,7 @@ static INLINE TX_SIZE av1_get_max_uv_txsize(BLOCK_SIZE bsize, int is_inter,
static INLINE TX_SIZE av1_get_uv_tx_size(const MB_MODE_INFO *mbmi, int ss_x,
int ss_y) {
if (is_inter_block(mbmi)) {
#if DISABLE_VARTX_FOR_CHROMA
return av1_get_max_uv_txsize(mbmi->sb_type, 1, ss_x, ss_y);
#endif // DISABLE_VARTX_FOR_CHROMA
} else {
#if DISABLE_SMLTX_FOR_CHROMA_INTRA
return av1_get_max_uv_txsize(mbmi->sb_type, 0, ss_x, ss_y);
#endif // DISABLE_SMLTX_FOR_CHROMA_INTRA
#if CONFIG_CFL
if (mbmi->uv_mode == UV_CFL_PRED)
return av1_get_max_uv_txsize(mbmi->sb_type, 0, ss_x, ss_y);
#endif
}
const TX_SIZE uv_txsize =
uv_txsize_lookup[mbmi->sb_type][mbmi->tx_size][ss_x][ss_y];
assert(uv_txsize != TX_INVALID);
return uv_txsize;
return av1_get_max_uv_txsize(mbmi->sb_type, is_inter_block(mbmi), ss_x, ss_y);
}
static INLINE TX_SIZE av1_get_tx_size(int plane, const MACROBLOCKD *xd) {
......@@ -1178,24 +1156,6 @@ static INLINE TX_SIZE av1_get_tx_size(int plane, const MACROBLOCKD *xd) {
return av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y);
}
// Temporary function to facilitate removal of uv_txsize_lookup if we
// decide to go with DISABLE_SMLTX_FOR_CHROMA_INTRA = 1
// TODO(debargha): Clean this up
static INLINE TX_SIZE av1_get_uv_tx_size_vartx(
const MB_MODE_INFO *mbmi, const struct macroblockd_plane *pd,
BLOCK_SIZE bsize, int tx_row, int tx_col) {
#if DISABLE_VARTX_FOR_CHROMA
(void)bsize;
(void)tx_row;
(void)tx_col;
return av1_get_max_uv_txsize(mbmi->sb_type, 1, pd->subsampling_x,
pd->subsampling_y);
#else
(void)pd;
return uv_txsize_lookup[bsize][mbmi->inter_tx_size[tx_row][tx_col]][0][0];
#endif // DISABLE_VARTX_FOR_CHROMA
}
void av1_reset_skip_context(MACROBLOCKD *xd, int mi_row, int mi_col,
BLOCK_SIZE bsize);
......
This diff is collapsed.
......@@ -211,11 +211,10 @@ static void decode_reconstruct_tx(AV1_COMMON *cm, MACROBLOCKD *const xd,
(void)mi_row;
(void)mi_col;
const struct macroblockd_plane *const pd = &xd->plane[plane];
const BLOCK_SIZE bsize = txsize_to_bsize[tx_size];
const int tx_row = blk_row >> (1 - pd->subsampling_y);
const int tx_col = blk_col >> (1 - pd->subsampling_x);
const TX_SIZE plane_tx_size =
plane ? av1_get_uv_tx_size_vartx(mbmi, pd, bsize, tx_row, tx_col)
plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y)
: mbmi->inter_tx_size[tx_row][tx_col];
// Scale to match transform block unit.
const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
......@@ -223,11 +222,7 @@ static void decode_reconstruct_tx(AV1_COMMON *cm, MACROBLOCKD *const xd,
if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
if (tx_size == plane_tx_size
#if DISABLE_VARTX_FOR_CHROMA
|| plane
#endif // DISABLE_VARTX_FOR_CHROMA
) {
if (tx_size == plane_tx_size || plane) {
PLANE_TYPE plane_type = get_plane_type(plane);
#if TXCOEFF_TIMER
struct aom_usec_timer timer;
......
......@@ -482,7 +482,6 @@ static void pack_txb_tokens(aom_writer *w, AV1_COMMON *cm, MACROBLOCK *const x,
int block, int blk_row, int blk_col,
TX_SIZE tx_size, TOKEN_STATS *token_stats) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
const BLOCK_SIZE bsize = txsize_to_bsize[tx_size];
const int tx_row = blk_row >> (1 - pd->subsampling_y);
const int tx_col = blk_col >> (1 - pd->subsampling_x);
const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
......@@ -491,14 +490,10 @@ static void pack_txb_tokens(aom_writer *w, AV1_COMMON *cm, MACROBLOCK *const x,
if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
const TX_SIZE plane_tx_size =
plane ? av1_get_uv_tx_size_vartx(mbmi, pd, bsize, tx_row, tx_col)
plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y)
: mbmi->inter_tx_size[tx_row][tx_col];
if (tx_size == plane_tx_size
#if DISABLE_VARTX_FOR_CHROMA
|| plane
#endif // DISABLE_VARTX_FOR_CHROMA
) {
if (tx_size == plane_tx_size || plane) {
TOKEN_STATS tmp_token_stats;
init_token_stats(&tmp_token_stats);
......@@ -543,7 +538,6 @@ static void pack_txb_tokens(aom_writer *w, const TOKENEXTRA **tp,
int block, int blk_row, int blk_col,
TX_SIZE tx_size, TOKEN_STATS *token_stats) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
const BLOCK_SIZE bsize = txsize_to_bsize[tx_size];
const int tx_row = blk_row >> (1 - pd->subsampling_y);
const int tx_col = blk_col >> (1 - pd->subsampling_x);
const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
......@@ -552,14 +546,10 @@ static void pack_txb_tokens(aom_writer *w, const TOKENEXTRA **tp,
if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
const TX_SIZE plane_tx_size =
plane ? av1_get_uv_tx_size_vartx(mbmi, pd, bsize, tx_row, tx_col)
plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y)
: mbmi->inter_tx_size[tx_row][tx_col];
if (tx_size == plane_tx_size
#if DISABLE_VARTX_FOR_CHROMA
|| plane
#endif // DISABLE_VARTX_FOR_CHROMA
) {
if (tx_size == plane_tx_size || plane) {
TOKEN_STATS tmp_token_stats;
init_token_stats(&tmp_token_stats);
pack_mb_tokens(w, tp, tok_end, bit_depth, tx_size, &tmp_token_stats);
......
......@@ -660,7 +660,6 @@ static void encode_block_inter(int plane, int block, int blk_row, int blk_col,
MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
const BLOCK_SIZE bsize = txsize_to_bsize[tx_size];
const struct macroblockd_plane *const pd = &xd->plane[plane];
const int tx_row = blk_row >> (1 - pd->subsampling_y);
const int tx_col = blk_col >> (1 - pd->subsampling_x);
......@@ -670,14 +669,10 @@ static void encode_block_inter(int plane, int block, int blk_row, int blk_col,
if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
const TX_SIZE plane_tx_size =
plane ? av1_get_uv_tx_size_vartx(mbmi, pd, bsize, tx_row, tx_col)
plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y)
: mbmi->inter_tx_size[tx_row][tx_col];
if (tx_size == plane_tx_size
#if DISABLE_VARTX_FOR_CHROMA
|| plane
#endif // DISABLE_VARTX_FOR_CHROMA
) {
if (tx_size == plane_tx_size || plane) {
encode_block(plane, block, blk_row, blk_col, plane_bsize, tx_size, arg,
mi_row, mi_col, dry_run);
} else {
......
......@@ -4314,7 +4314,6 @@ static void tx_block_yrd(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
struct macroblockd_plane *const pd = &xd->plane[plane];
BLOCK_SIZE bsize = txsize_to_bsize[tx_size];
const int tx_row = blk_row >> (1 - pd->subsampling_y);
const int tx_col = blk_col >> (1 - pd->subsampling_x);
const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
......@@ -4325,18 +4324,14 @@ static void tx_block_yrd(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
const TX_SIZE plane_tx_size =
plane ? av1_get_uv_tx_size_vartx(mbmi, pd, bsize, tx_row, tx_col)
plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y)
: mbmi->inter_tx_size[tx_row][tx_col];
int ctx = txfm_partition_context(tx_above + blk_col, tx_left + blk_row,
mbmi->sb_type, tx_size);
av1_init_rd_stats(rd_stats);
if (tx_size == plane_tx_size
#if DISABLE_VARTX_FOR_CHROMA
|| plane
#endif // DISABLE_VARTX_FOR_CHROMA
) {
if (tx_size == plane_tx_size || plane) {
ENTROPY_CONTEXT *ta = above_ctx + blk_col;
ENTROPY_CONTEXT *tl = left_ctx + blk_row;
#if CONFIG_LV_MAP
......@@ -5019,7 +5014,6 @@ static void tx_block_rd(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
struct macroblockd_plane *const pd = &xd->plane[plane];
BLOCK_SIZE bsize = txsize_to_bsize[tx_size];
const int tx_row = blk_row >> (1 - pd->subsampling_y);
const int tx_col = blk_col >> (1 - pd->subsampling_x);
const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
......@@ -5030,14 +5024,10 @@ static void tx_block_rd(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
const TX_SIZE plane_tx_size =
plane ? av1_get_uv_tx_size_vartx(mbmi, pd, bsize, tx_row, tx_col)
plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y)
: mbmi->inter_tx_size[tx_row][tx_col];
if (tx_size == plane_tx_size
#if DISABLE_VARTX_FOR_CHROMA
|| plane
#endif // DISABLE_VARTX_FOR_CHROMA
) {
if (tx_size == plane_tx_size || plane) {
ENTROPY_CONTEXT *ta = above_ctx + blk_col;
ENTROPY_CONTEXT *tl = left_ctx + blk_row;
av1_tx_block_rd_b(cpi, x, tx_size, blk_row, blk_col, plane, block,
......
......@@ -486,7 +486,6 @@ void tokenize_vartx(ThreadData *td, TOKENEXTRA **t, RUN_TYPE dry_run,
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
const struct macroblockd_plane *const pd = &xd->plane[plane];
const BLOCK_SIZE bsize = txsize_to_bsize[tx_size];
const int tx_row = blk_row >> (1 - pd->subsampling_y);
const int tx_col = blk_col >> (1 - pd->subsampling_x);
const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
......@@ -495,14 +494,10 @@ void tokenize_vartx(ThreadData *td, TOKENEXTRA **t, RUN_TYPE dry_run,
if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
const TX_SIZE plane_tx_size =
plane ? av1_get_uv_tx_size_vartx(mbmi, pd, bsize, tx_row, tx_col)
plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y)
: mbmi->inter_tx_size[tx_row][tx_col];
if (tx_size == plane_tx_size
#if DISABLE_VARTX_FOR_CHROMA
|| plane
#endif // DISABLE_VARTX_FOR_CHROMA
) {
if (tx_size == plane_tx_size || plane) {
plane_bsize = get_plane_block_size(mbmi->sb_type, pd);
#if CONFIG_LV_MAP
if (!dry_run) {
......
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