Commit 891a8774 authored by Debargha Mukherjee's avatar Debargha Mukherjee

Add option to disable split partitions for chroma

When the flag DISABLE_VARTX_FOR_CHROMA is on chroma is
constrained to always use the largest transform size
for the prediction unit size.
This is meant to simnplify the logic for transform size
selection for chroma with hopefully no loss.

Results:
lowres 30 frames, speed 1: -0.038% (a slight improvement).
lowres 30 frames, speed 0: 0.000% (noise level difference).

Change-Id: I14dd5b1983d908bd98e59b7d252e11f5755c97e6
parent 3aa28111
......@@ -39,6 +39,9 @@ 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
// SEG_MASK_TYPES should not surpass 1 << MAX_SEG_MASK_BITS
typedef enum {
#if COMPOUND_SEGMENT_TYPE == 0
......@@ -1213,10 +1216,12 @@ static INLINE int is_interintra_pred(const MB_MODE_INFO *mbmi) {
return (mbmi->ref_frame[1] == INTRA_FRAME) && is_interintra_allowed(mbmi);
}
static INLINE int get_vartx_max_txsize(const MB_MODE_INFO *const mbmi,
BLOCK_SIZE bsize, int subsampled) {
(void)mbmi;
TX_SIZE max_txsize = get_max_rect_tx_size(bsize, is_inter_block(mbmi));
static INLINE int get_vartx_max_txsize(const MACROBLOCKD *xd, BLOCK_SIZE bsize,
int subsampled) {
TX_SIZE max_txsize =
xd->lossless[xd->mi[0]->mbmi.segment_id]
? TX_4X4
: get_max_rect_tx_size(bsize, is_inter_block(&xd->mi[0]->mbmi));
#if CONFIG_EXT_PARTITION && CONFIG_TX64X64
// The decoder is designed so that it can process 64x64 luma pixels at a
......
......@@ -247,7 +247,11 @@ 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 (tx_size == plane_tx_size
#if DISABLE_VARTX_FOR_CHROMA
|| pd->subsampling_x || pd->subsampling_y
#endif // DISABLE_VARTX_FOR_CHROMA
) {
PLANE_TYPE plane_type = get_plane_type(plane);
#if TXCOEFF_TIMER
struct aom_usec_timer timer;
......@@ -260,15 +264,15 @@ static void decode_reconstruct_tx(AV1_COMMON *cm, MACROBLOCKD *const xd,
pd->dqcoeff, tx_size, &max_scan_line, &eob);
// tx_type will be read out in av1_read_coeffs_txb_facade
const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, plane_tx_size);
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
#else // CONFIG_LV_MAP
const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, plane_tx_size);
const SCAN_ORDER *sc = get_scan(cm, plane_tx_size, tx_type, mbmi);
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
const SCAN_ORDER *sc = get_scan(cm, tx_size, tx_type, mbmi);
int16_t max_scan_line = 0;
const int eob = av1_decode_block_tokens(
cm, xd, plane, sc, blk_col, blk_row, plane_tx_size, tx_type,
&max_scan_line, r, mbmi->segment_id);
const int eob =
av1_decode_block_tokens(cm, xd, plane, sc, blk_col, blk_row, tx_size,
tx_type, &max_scan_line, r, mbmi->segment_id);
#endif // CONFIG_LV_MAP
#if TXCOEFF_TIMER
......@@ -279,7 +283,7 @@ static void decode_reconstruct_tx(AV1_COMMON *cm, MACROBLOCKD *const xd,
#endif
inverse_transform_block(
xd, plane, tx_type, plane_tx_size,
xd, plane, tx_type, tx_size,
&pd->dst
.buf[(blk_row * pd->dst.stride + blk_col) << tx_size_wide_log2[0]],
pd->dst.stride, max_scan_line, eob, cm->reduced_tx_set_used);
......@@ -532,7 +536,7 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi,
mu_blocks_high = AOMMIN(max_blocks_high, mu_blocks_high);
const TX_SIZE max_tx_size = get_vartx_max_txsize(
mbmi, plane_bsize, pd->subsampling_x || pd->subsampling_y);
xd, plane_bsize, pd->subsampling_x || pd->subsampling_y);
const int bh_var_tx = tx_size_high_unit[max_tx_size];
const int bw_var_tx = tx_size_wide_unit[max_tx_size];
int block = 0;
......
......@@ -512,7 +512,11 @@ static void pack_txb_tokens(aom_writer *w, AV1_COMMON *cm, MACROBLOCK *const x,
plane ? uv_txsize_lookup[bsize][mbmi->inter_tx_size[tx_row][tx_col]][0][0]
: mbmi->inter_tx_size[tx_row][tx_col];
if (tx_size == plane_tx_size) {
if (tx_size == plane_tx_size
#if DISABLE_VARTX_FOR_CHROMA
|| pd->subsampling_x || pd->subsampling_y
#endif // DISABLE_VARTX_FOR_CHROMA
) {
TOKEN_STATS tmp_token_stats;
init_token_stats(&tmp_token_stats);
......@@ -574,7 +578,11 @@ static void pack_txb_tokens(aom_writer *w, const TOKENEXTRA **tp,
plane ? uv_txsize_lookup[bsize][mbmi->inter_tx_size[tx_row][tx_col]][0][0]
: mbmi->inter_tx_size[tx_row][tx_col];
if (tx_size == plane_tx_size) {
if (tx_size == plane_tx_size
#if DISABLE_VARTX_FOR_CHROMA
|| pd->subsampling_x || pd->subsampling_y
#endif // DISABLE_VARTX_FOR_CHROMA
) {
TOKEN_STATS tmp_token_stats;
init_token_stats(&tmp_token_stats);
pack_mb_tokens(w, tp, tok_end, bit_depth, tx_size,
......@@ -1291,7 +1299,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
if (cm->tx_mode == TX_MODE_SELECT && block_signals_txsize(bsize) &&
!(is_inter && skip) && !xd->lossless[segment_id]) {
if (is_inter) { // This implies skip flag is 0.
const TX_SIZE max_tx_size = get_vartx_max_txsize(mbmi, bsize, 0);
const TX_SIZE max_tx_size = get_vartx_max_txsize(xd, bsize, 0);
const int bh = tx_size_high_unit[max_tx_size];
const int bw = tx_size_wide_unit[max_tx_size];
const int width = block_size_wide[bsize] >> tx_size_wide_log2[0];
......@@ -1466,7 +1474,7 @@ static void write_intrabc_info(AV1_COMMON *cm, MACROBLOCKD *xd,
assert(mbmi->uv_mode == UV_DC_PRED);
if ((enable_tx_size && !mbmi->skip)) {
const BLOCK_SIZE bsize = mbmi->sb_type;
const TX_SIZE max_tx_size = get_vartx_max_txsize(mbmi, bsize, 0);
const TX_SIZE max_tx_size = get_vartx_max_txsize(xd, bsize, 0);
const int bh = tx_size_high_unit[max_tx_size];
const int bw = tx_size_wide_unit[max_tx_size];
const int width = block_size_wide[bsize] >> tx_size_wide_log2[0];
......@@ -1782,7 +1790,7 @@ static void write_inter_txb_coeff(AV1_COMMON *const cm, MACROBLOCK *const x,
AOMMAX(BLOCK_4X4, get_plane_block_size(mbmi->sb_type, pd));
const TX_SIZE max_tx_size = get_vartx_max_txsize(
mbmi, plane_bsize, pd->subsampling_x || pd->subsampling_y);
xd, plane_bsize, pd->subsampling_x || pd->subsampling_y);
const int step =
tx_size_wide_unit[max_tx_size] * tx_size_high_unit[max_tx_size];
const int bkw = tx_size_wide_unit[max_tx_size];
......
......@@ -4682,7 +4682,7 @@ static void tx_partition_count_update(const AV1_COMMON *const cm, MACROBLOCK *x,
MACROBLOCKD *xd = &x->e_mbd;
const int mi_width = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
const int mi_height = block_size_high[plane_bsize] >> tx_size_wide_log2[0];
TX_SIZE max_tx_size = get_vartx_max_txsize(&xd->mi[0]->mbmi, plane_bsize, 0);
TX_SIZE max_tx_size = get_vartx_max_txsize(xd, plane_bsize, 0);
const int bh = tx_size_high_unit[max_tx_size];
const int bw = tx_size_wide_unit[max_tx_size];
int idx, idy;
......@@ -4741,7 +4741,7 @@ static void tx_partition_set_contexts(const AV1_COMMON *const cm,
int mi_row, int mi_col) {
const int mi_width = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
const int mi_height = block_size_high[plane_bsize] >> tx_size_high_log2[0];
TX_SIZE max_tx_size = get_vartx_max_txsize(&xd->mi[0]->mbmi, plane_bsize, 0);
TX_SIZE max_tx_size = get_vartx_max_txsize(xd, plane_bsize, 0);
const int bh = tx_size_high_unit[max_tx_size];
const int bw = tx_size_wide_unit[max_tx_size];
int idx, idy;
......
......@@ -714,7 +714,11 @@ static void encode_block_inter(int plane, int block, int blk_row, int blk_col,
plane ? uv_txsize_lookup[bsize][mbmi->inter_tx_size[tx_row][tx_col]][0][0]
: mbmi->inter_tx_size[tx_row][tx_col];
if (tx_size == plane_tx_size) {
if (tx_size == plane_tx_size
#if DISABLE_VARTX_FOR_CHROMA
|| pd->subsampling_x || pd->subsampling_y
#endif // DISABLE_VARTX_FOR_CHROMA
) {
encode_block(plane, block, blk_row, blk_col, plane_bsize, tx_size, arg);
} else {
assert(tx_size < TX_SIZES_ALL);
......@@ -830,7 +834,7 @@ void av1_encode_sb(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize, int mi_row,
const int mi_width = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
const int mi_height = block_size_high[plane_bsize] >> tx_size_wide_log2[0];
const TX_SIZE max_tx_size = get_vartx_max_txsize(
mbmi, plane_bsize, pd->subsampling_x || pd->subsampling_y);
xd, plane_bsize, pd->subsampling_x || pd->subsampling_y);
const BLOCK_SIZE txb_size = txsize_to_bsize[max_tx_size];
const int bw = block_size_wide[txb_size] >> tx_size_wide_log2[0];
const int bh = block_size_high[txb_size] >> tx_size_wide_log2[0];
......
......@@ -4344,7 +4344,11 @@ static void tx_block_yrd(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
mbmi->sb_type, tx_size);
av1_init_rd_stats(rd_stats);
if (tx_size == plane_tx_size) {
if (tx_size == plane_tx_size
#if DISABLE_VARTX_FOR_CHROMA
|| pd->subsampling_x || pd->subsampling_y
#endif // DISABLE_VARTX_FOR_CHROMA
) {
ENTROPY_CONTEXT *ta = above_ctx + blk_col;
ENTROPY_CONTEXT *tl = left_ctx + blk_row;
#if CONFIG_LV_MAP
......@@ -4437,7 +4441,8 @@ int inter_block_yrd(const AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *rd_stats,
const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
const int mi_width = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
const int mi_height = block_size_high[plane_bsize] >> tx_size_high_log2[0];
const TX_SIZE max_tx_size = max_txsize_rect_lookup[plane_bsize];
const TX_SIZE max_tx_size = get_vartx_max_txsize(
xd, plane_bsize, pd->subsampling_x || pd->subsampling_y);
const int bh = tx_size_high_unit[max_tx_size];
const int bw = tx_size_wide_unit[max_tx_size];
const int init_depth = get_search_init_depth(mi_width, mi_height, &cpi->sf);
......@@ -4448,7 +4453,6 @@ int inter_block_yrd(const AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *rd_stats,
ENTROPY_CONTEXT ctxl[2 * MAX_MIB_SIZE];
TXFM_CONTEXT tx_above[MAX_MIB_SIZE * 2];
TXFM_CONTEXT tx_left[MAX_MIB_SIZE * 2];
RD_STATS pn_rd_stats;
av1_get_entropy_contexts(bsize, 0, pd, ctxa, ctxl);
......@@ -4966,7 +4970,11 @@ static void tx_block_rd(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
plane ? uv_txsize_lookup[bsize][mbmi->inter_tx_size[tx_row][tx_col]][0][0]
: mbmi->inter_tx_size[tx_row][tx_col];
if (tx_size == plane_tx_size) {
if (tx_size == plane_tx_size
#if DISABLE_VARTX_FOR_CHROMA
|| pd->subsampling_x || pd->subsampling_y
#endif // DISABLE_VARTX_FOR_CHROMA
) {
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,
......@@ -5029,8 +5037,8 @@ int inter_block_uvrd(const AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *rd_stats,
const int mi_width = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
const int mi_height =
block_size_high[plane_bsize] >> tx_size_high_log2[0];
const TX_SIZE max_tx_size =
get_max_rect_tx_size(plane_bsize, is_inter_block(mbmi));
const TX_SIZE max_tx_size = get_vartx_max_txsize(
xd, plane_bsize, pd->subsampling_x || pd->subsampling_y);
const int bh = tx_size_high_unit[max_tx_size];
const int bw = tx_size_wide_unit[max_tx_size];
int idx, idy;
......
......@@ -565,7 +565,11 @@ void tokenize_vartx(ThreadData *td, TOKENEXTRA **t, RUN_TYPE dry_run,
plane ? uv_txsize_lookup[bsize][mbmi->inter_tx_size[tx_row][tx_col]][0][0]
: mbmi->inter_tx_size[tx_row][tx_col];
if (tx_size == plane_tx_size) {
if (tx_size == plane_tx_size
#if DISABLE_VARTX_FOR_CHROMA
|| pd->subsampling_x || pd->subsampling_y
#endif // DISABLE_VARTX_FOR_CHROMA
) {
plane_bsize = get_plane_block_size(mbmi->sb_type, pd);
#if CONFIG_LV_MAP
if (!dry_run) {
......@@ -660,7 +664,7 @@ void av1_tokenize_sb_vartx(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t,
const int mi_width = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
const int mi_height = block_size_high[plane_bsize] >> tx_size_wide_log2[0];
const TX_SIZE max_tx_size = get_vartx_max_txsize(
mbmi, plane_bsize, pd->subsampling_x || pd->subsampling_y);
xd, plane_bsize, pd->subsampling_x || pd->subsampling_y);
const BLOCK_SIZE txb_size = txsize_to_bsize[max_tx_size];
int bw = block_size_wide[txb_size] >> tx_size_wide_log2[0];
int bh = block_size_high[txb_size] >> tx_size_wide_log2[0];
......
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