Remove experimental flag of EXT_TX
This experiment has been adopted, we can simplify the code
by dropping the associated preprocessor conditionals.
Change-Id: I02ed47186bbc32400ee9bfadda17659d859c0ef7
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index a0ddd66..ba16d06 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -58,9 +58,7 @@
#include "av1/encoder/rd.h"
#include "av1/encoder/rdopt.h"
#include "av1/encoder/tokenize.h"
-#if CONFIG_EXT_TX
#include "av1/encoder/tx_prune_model_weights.h"
-#endif // CONFIG_EXT_TX
#if CONFIG_DUAL_FILTER
#define DUAL_FILTER_SET_SIZE (SWITCHABLE_FILTERS * SWITCHABLE_FILTERS)
@@ -1039,7 +1037,6 @@
return prune_bitmask;
}
-#if CONFIG_EXT_TX
static void get_horver_correlation(const int16_t *diff, int stride, int w,
int h, double *hcorr, double *vcorr) {
// Returns hor/ver correlation coefficient
@@ -1123,7 +1120,6 @@
return prune;
}
-#endif // CONFIG_EXT_TX
// Performance drop: 0.3%, Speed improvement: 5%
static int prune_one_for_sby(const AV1_COMP *cpi, BLOCK_SIZE bsize,
@@ -1134,7 +1130,6 @@
pd->dst.stride);
}
-#if CONFIG_EXT_TX
// 1D Transforms used in inter set, this needs to be changed if
// ext_tx_used_inter is changed
static const int ext_tx_used_inter_1D[EXT_TX_SETS_INTER][TX_TYPES_1D] = {
@@ -1384,18 +1379,12 @@
return prune_bitmask;
}
-#endif // CONFIG_EXT_TX
static int prune_tx_types(const AV1_COMP *cpi, BLOCK_SIZE bsize, MACROBLOCK *x,
const MACROBLOCKD *const xd, int tx_set_type) {
-#if CONFIG_EXT_TX
int tx_set = ext_tx_set_index[1][tx_set_type];
assert(tx_set >= 0);
const int *tx_set_1D = ext_tx_used_inter_1D[tx_set];
-#else
- const int tx_set_1D[TX_TYPES_1D] = { 0 };
- (void)tx_set_type;
-#endif // CONFIG_EXT_TX
switch (cpi->sf.tx_type_search.prune_mode) {
case NO_PRUNE: return 0; break;
@@ -1403,7 +1392,6 @@
if (!(tx_set_1D[FLIPADST_1D] & tx_set_1D[ADST_1D])) return 0;
return prune_one_for_sby(cpi, bsize, x, xd);
break;
-#if CONFIG_EXT_TX
case PRUNE_TWO:
if (!(tx_set_1D[FLIPADST_1D] & tx_set_1D[ADST_1D])) {
if (!(tx_set_1D[DCT_1D] & tx_set_1D[IDTX_1D])) return 0;
@@ -1429,7 +1417,6 @@
else
return 0;
break;
-#endif // CONFIG_EXT_TX
}
assert(0);
return 0;
@@ -1437,23 +1424,13 @@
static int do_tx_type_search(TX_TYPE tx_type, int prune,
TX_TYPE_PRUNE_MODE mode) {
-// TODO(sarahparker) implement for non ext tx
-#if CONFIG_EXT_TX
+ // TODO(sarahparker) implement for non ext tx
if (mode >= PRUNE_2D_ACCURATE) {
return !((prune >> tx_type) & 1);
} else {
return !(((prune >> vtx_tab[tx_type]) & 1) |
((prune >> (htx_tab[tx_type] + 8)) & 1));
}
-#else
- // temporary to avoid compiler warnings
- (void)vtx_tab;
- (void)htx_tab;
- (void)tx_type;
- (void)prune;
- (void)mode;
- return 1;
-#endif // CONFIG_EXT_TX
}
static void model_rd_from_sse(const AV1_COMP *const cpi,
@@ -1976,10 +1953,8 @@
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
mrc_mask,
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
-#if CONFIG_EXT_TX
- plane,
-#endif // CONFIG_EXT_TX
- tx_type, tx_size, recon, MAX_TX_SIZE, eob);
+ plane, tx_type, tx_size, recon, MAX_TX_SIZE,
+ eob);
#if CONFIG_DIST_8X8
if (x->using_dist_8x8 && plane == 0 && (bsw < 8 || bsh < 8)) {
@@ -2349,7 +2324,6 @@
const MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
const int is_inter = is_inter_block(mbmi);
-#if CONFIG_EXT_TX
if (get_ext_tx_types(tx_size, bsize, is_inter, cm->reduced_tx_set_used) > 1 &&
!xd->lossless[xd->mi[0]->mbmi.segment_id]) {
const int ext_tx_set =
@@ -2376,20 +2350,6 @@
}
}
}
-#else
- (void)bsize;
- (void)cm;
- if (tx_size < TX_32X32 && !xd->lossless[xd->mi[0]->mbmi.segment_id] &&
- !FIXED_TX_TYPE) {
- if (is_inter) {
- return x->inter_tx_type_costs[tx_size][tx_type];
- } else {
- return x->intra_tx_type_costs[tx_size]
- [intra_mode_to_tx_type_context[mbmi->mode]]
- [tx_type];
- }
- }
-#endif // CONFIG_EXT_TX
return 0;
}
static int64_t txfm_yrd(const AV1_COMP *const cpi, MACROBLOCK *x,
@@ -2407,9 +2367,7 @@
const int r_tx_size = tx_size_cost(cm, x, bs, tx_size);
-#if CONFIG_EXT_TX
assert(IMPLIES(is_rect_tx(tx_size), is_rect_tx_allowed_bsize(bs)));
-#endif // CONFIG_EXT_TX
s0 = x->skip_cost[skip_ctx][0];
s1 = x->skip_cost[skip_ctx][1];
@@ -2480,7 +2438,6 @@
tx_type != get_default_tx_type(0, xd, 0, tx_size))
return 1;
if (max_tx_size >= TX_32X32 && tx_size == TX_4X4) return 1;
-#if CONFIG_EXT_TX
const AV1_COMMON *const cm = &cpi->common;
const TxSetType tx_set_type =
get_ext_tx_set_type(tx_size, bs, is_inter, cm->reduced_tx_set_used);
@@ -2495,12 +2452,6 @@
if (tx_type != intra_mode_to_tx_type_context[mbmi->mode]) return 1;
}
}
-#else // CONFIG_EXT_TX
- if (tx_size >= TX_32X32 && tx_type != DCT_DCT) return 1;
- if (is_inter && cpi->sf.tx_type_search.prune_mode > NO_PRUNE &&
- !do_tx_type_search(tx_type, prune, cpi->sf.tx_type_search.prune_mode))
- return 1;
-#endif // CONFIG_EXT_TX
return 0;
}
@@ -2543,20 +2494,13 @@
mbmi->tx_size = tx_size_from_tx_mode(bs, cm->tx_mode, is_inter);
mbmi->min_tx_size = get_min_tx_size(mbmi->tx_size);
-#if CONFIG_EXT_TX
const TxSetType tx_set_type =
get_ext_tx_set_type(mbmi->tx_size, bs, is_inter, cm->reduced_tx_set_used);
-#endif // CONFIG_EXT_TX
if (is_inter && cpi->sf.tx_type_search.prune_mode > NO_PRUNE &&
!x->use_default_inter_tx_type) {
-#if CONFIG_EXT_TX
prune = prune_tx_types(cpi, bs, x, xd, tx_set_type);
-#else
- prune = prune_tx_types(cpi, bs, x, xd, 0);
-#endif // CONFIG_EXT_TX
}
-#if CONFIG_EXT_TX
if (get_ext_tx_types(mbmi->tx_size, bs, is_inter, cm->reduced_tx_set_used) >
1 &&
!xd->lossless[mbmi->segment_id]) {
@@ -2637,48 +2581,6 @@
txfm_rd_in_plane(x, cpi, rd_stats, ref_best_rd, 0, bs, mbmi->tx_size,
cpi->sf.use_fast_coef_costing);
}
-#else // CONFIG_EXT_TX
- if (mbmi->tx_size < TX_32X32 && !xd->lossless[mbmi->segment_id]) {
- for (tx_type = 0; tx_type < TX_TYPES; ++tx_type) {
- RD_STATS this_rd_stats;
- if (!is_inter && x->use_default_intra_tx_type &&
- tx_type != get_default_tx_type(0, xd, 0, mbmi->tx_size))
- continue;
- if (is_inter && x->use_default_inter_tx_type &&
- tx_type != get_default_tx_type(0, xd, 0, mbmi->tx_size))
- continue;
- mbmi->tx_type = tx_type;
- txfm_rd_in_plane(x, cpi, &this_rd_stats, ref_best_rd, 0, bs,
- mbmi->tx_size, cpi->sf.use_fast_coef_costing);
- if (this_rd_stats.rate == INT_MAX) continue;
-
- av1_tx_type_cost(cm, x, xd, bs, plane, mbmi->tx_size, tx_type);
- if (is_inter) {
- if (cpi->sf.tx_type_search.prune_mode > NO_PRUNE &&
- !do_tx_type_search(tx_type, prune,
- cpi->sf.tx_type_search.prune_mode))
- continue;
- }
- if (this_rd_stats.skip)
- this_rd = RDCOST(x->rdmult, s1, this_rd_stats.sse);
- else
- this_rd =
- RDCOST(x->rdmult, this_rd_stats.rate + s0, this_rd_stats.dist);
- if (is_inter && !xd->lossless[mbmi->segment_id] && !this_rd_stats.skip)
- this_rd = AOMMIN(this_rd, RDCOST(x->rdmult, s1, this_rd_stats.sse));
-
- if (this_rd < best_rd) {
- best_rd = this_rd;
- best_tx_type = mbmi->tx_type;
- *rd_stats = this_rd_stats;
- }
- }
- } else {
- mbmi->tx_type = DCT_DCT;
- txfm_rd_in_plane(x, cpi, rd_stats, ref_best_rd, 0, bs, mbmi->tx_size,
- cpi->sf.use_fast_coef_costing);
- }
-#endif // CONFIG_EXT_TX
mbmi->tx_type = best_tx_type;
#if CONFIG_LGT_FROM_PRED
mbmi->use_lgt = is_lgt_best;
@@ -2730,7 +2632,6 @@
av1_invalid_rd_stats(rd_stats);
-#if CONFIG_EXT_TX
int evaluate_rect_tx = 0;
if (tx_select) {
evaluate_rect_tx = is_rect_tx_allowed(xd, mbmi);
@@ -2857,7 +2758,6 @@
#endif // CONFIG_LGT_FROM_PRED
}
#endif // CONFIG_RECT_TX_EXT
-#endif // CONFIG_EXT_TX
if (tx_select) {
start_tx = max_tx_size;
@@ -2872,18 +2772,12 @@
int prune = 0;
if (is_inter && cpi->sf.tx_type_search.prune_mode > NO_PRUNE &&
!x->use_default_inter_tx_type) {
-#if CONFIG_EXT_TX
prune = prune_tx_types(cpi, bs, x, xd, EXT_TX_SET_ALL16);
-#else
- prune = prune_tx_types(cpi, bs, x, xd, 0);
-#endif // CONFIG_EXT_TX
}
last_rd = INT64_MAX;
for (n = start_tx; n >= end_tx; --n) {
-#if CONFIG_EXT_TX
if (is_rect_tx(n)) break;
-#endif // CONFIG_EXT_TX
TX_TYPE tx_start = DCT_DCT;
TX_TYPE tx_end = TX_TYPES;
#if CONFIG_TXK_SEL
@@ -2954,10 +2848,6 @@
#endif
mbmi->min_tx_size = get_min_tx_size(mbmi->tx_size);
-
-#if !CONFIG_EXT_TX
- if (mbmi->tx_size >= TX_32X32) assert(mbmi->tx_type == DCT_DCT);
-#endif // !CONFIG_EXT_TX
}
static void super_block_yrd(const AV1_COMP *const cpi, MACROBLOCK *x,
@@ -4009,10 +3899,8 @@
#if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
mrc_mask,
#endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK
-#if CONFIG_EXT_TX
- plane,
-#endif // CONFIG_EXT_TX
- tx_type, tx_size, rec_buffer, MAX_TX_SIZE, eob);
+ plane, tx_type, tx_size, rec_buffer, MAX_TX_SIZE,
+ eob);
if (eob > 0) {
#if CONFIG_DIST_8X8
if (x->using_dist_8x8 && plane == 0 && (bw < 8 && bh < 8)) {
@@ -4606,7 +4494,6 @@
}
#if !CONFIG_TXK_SEL
-#if CONFIG_EXT_TX
if (get_ext_tx_types(mbmi->min_tx_size, bsize, is_inter,
cm->reduced_tx_set_used) > 1 &&
!xd->lossless[xd->mi[0]->mbmi.segment_id]) {
@@ -4652,10 +4539,6 @@
#if CONFIG_LGT_FROM_PRED
}
#endif
-#else
- if (mbmi->min_tx_size < TX_32X32 && !xd->lossless[xd->mi[0]->mbmi.segment_id])
- rd_stats->rate += x->inter_tx_type_costs[mbmi->min_tx_size][mbmi->tx_type];
-#endif // CONFIG_EXT_TX
#endif // CONFIG_TXK_SEL
if (rd_stats->skip)
@@ -4908,7 +4791,6 @@
param.tx_size = max_txsize_rect_lookup[bsize];
param.bd = 8;
param.lossless = 0;
-#if CONFIG_EXT_TX
const MACROBLOCKD *xd = &x->e_mbd;
const struct macroblockd_plane *const pd = &xd->plane[0];
const BLOCK_SIZE plane_bsize =
@@ -4918,7 +4800,6 @@
// within this function.
param.tx_set_type = get_ext_tx_set_type(param.tx_size, plane_bsize,
is_inter_block(&xd->mi[0]->mbmi), 0);
-#endif // CONFIG_EXT_TX
#if CONFIG_TXMG
av1_highbd_fwd_txfm(p->src_diff, DCT_coefs, bw, ¶m);
@@ -4969,7 +4850,6 @@
rate += x->txfm_partition_cost[ctx][0];
}
#if !CONFIG_TXK_SEL
-#if CONFIG_EXT_TX
const AV1_COMMON *cm = &cpi->common;
const int ext_tx_set = get_ext_tx_set(max_txsize_lookup[bsize], bsize, 1,
cm->reduced_tx_set_used);
@@ -4981,10 +4861,6 @@
x->inter_tx_type_costs[ext_tx_set][txsize_sqr_map[mbmi->min_tx_size]]
[mbmi->tx_type];
}
-#else
- if (mbmi->min_tx_size < TX_32X32 && !xd->lossless[xd->mi[0]->mbmi.segment_id])
- rd_stats->rate += x->inter_tx_type_costs[mbmi->min_tx_size][mbmi->tx_type];
-#endif // CONFIG_EXT_TX
#endif // CONFIG_TXK_SEL
rd_stats->rate = rate;
@@ -5022,26 +4898,24 @@
const int n4 = bsize_to_num_blk(bsize);
int idx, idy;
int prune = 0;
-#if CONFIG_EXT_TX
const TX_SIZE sqr_up_tx_size =
txsize_sqr_up_map[max_txsize_rect_lookup[bsize]];
// Get the tx_size 1 level down
TX_SIZE min_tx_size = sub_tx_size_map[sqr_up_tx_size];
const TxSetType tx_set_type = get_ext_tx_set_type(
min_tx_size, bsize, is_inter, cm->reduced_tx_set_used);
-#endif // CONFIG_EXT_TX
int within_border = (mi_row + mi_size_high[bsize] <= cm->mi_rows) &&
(mi_col + mi_size_wide[bsize] <= cm->mi_cols);
av1_invalid_rd_stats(rd_stats);
-#if CONFIG_EXT_TX && CONFIG_LGT_FROM_PRED
+#if CONFIG_LGT_FROM_PRED
mbmi->use_lgt = 0;
int search_lgt = is_inter
? LGT_FROM_PRED_INTER &&
(!cpi->sf.tx_type_search.prune_mode > NO_PRUNE)
: LGT_FROM_PRED_INTRA && ALLOW_INTRA_EXT_TX;
-#endif // CONFIG_EXT_TX && CONFIG_LGT_FROM_PRED
+#endif // CONFIG_LGT_FROM_PRED
const uint32_t hash = get_block_residue_hash(x, bsize);
TX_RD_RECORD *tx_rd_record = &x->tx_rd_record;
@@ -5074,11 +4948,7 @@
if (is_inter && cpi->sf.tx_type_search.prune_mode > NO_PRUNE &&
!x->use_default_inter_tx_type && !xd->lossless[mbmi->segment_id]) {
-#if CONFIG_EXT_TX
prune = prune_tx_types(cpi, bsize, x, xd, tx_set_type);
-#else
- prune = prune_tx_types(cpi, bsize, x, xd, 0);
-#endif // CONFIG_EXT_TX
}
int found = 0;
@@ -5086,38 +4956,32 @@
for (tx_type = txk_start; tx_type < txk_end; ++tx_type) {
RD_STATS this_rd_stats;
av1_init_rd_stats(&this_rd_stats);
-#if CONFIG_EXT_TX && CONFIG_MRC_TX
+#if CONFIG_MRC_TX
// MRC_DCT only implemented for TX_32X32 so only include this tx in
// the search for TX_32X32
if (tx_type == MRC_DCT &&
(max_tx_size != TX_32X32 || (is_inter && !USE_MRC_INTER) ||
(!is_inter && !USE_MRC_INTRA)))
continue;
-#endif // CONFIG_EXT_TX && CONFIG_MRC_TX
-#if CONFIG_EXT_TX
+#endif // CONFIG_MRC_TX
if (!av1_ext_tx_used[tx_set_type][tx_type]) continue;
(void)prune;
-// TODO(sarahparker) This speed feature has been temporarily disabled
-// with ext-tx because it is not compatible with the current
-// search method. It will be fixed in a followup.
-/*
- if (is_inter) {
- if (cpi->sf.tx_type_search.prune_mode > NO_PRUNE) {
- if (!do_tx_type_search(tx_type, prune,
- cpi->sf.tx_type_search.prune_mode))
- continue;
- }
- } else {
- if (!ALLOW_INTRA_EXT_TX && bsize >= BLOCK_8X8) {
- if (tx_type != intra_mode_to_tx_type_context[mbmi->mode]) continue;
- }
- }
-*/
-#else // CONFIG_EXT_TX
- if (is_inter && cpi->sf.tx_type_search.prune_mode > NO_PRUNE &&
- !do_tx_type_search(tx_type, prune, cpi->sf.tx_type_search.prune_mode))
- continue;
-#endif // CONFIG_EXT_TX
+ // TODO(sarahparker) This speed feature has been temporarily disabled
+ // with ext-tx because it is not compatible with the current
+ // search method. It will be fixed in a followup.
+ /*
+ if (is_inter) {
+ if (cpi->sf.tx_type_search.prune_mode > NO_PRUNE) {
+ if (!do_tx_type_search(tx_type, prune,
+ cpi->sf.tx_type_search.prune_mode))
+ continue;
+ }
+ } else {
+ if (!ALLOW_INTRA_EXT_TX && bsize >= BLOCK_8X8) {
+ if (tx_type != intra_mode_to_tx_type_context[mbmi->mode]) continue;
+ }
+ }
+ */
if (is_inter && x->use_default_inter_tx_type &&
tx_type != get_default_tx_type(0, xd, 0, max_tx_size))
continue;
@@ -5127,14 +4991,12 @@
rd = select_tx_size_fix_type(cpi, x, &this_rd_stats, bsize, mi_row, mi_col,
ref_best_rd, tx_type);
-#if CONFIG_EXT_TX
// If the current tx_type is not included in the tx_set for the smallest
// tx size found, then all vartx partitions were actually transformed with
// DCT_DCT and we should avoid picking it.
const TxSetType min_tx_set_type = get_ext_tx_set_type(
mbmi->min_tx_size, bsize, is_inter, cm->reduced_tx_set_used);
if (!av1_ext_tx_used[min_tx_set_type][tx_type]) continue;
-#endif // CONFIG_EXT_TX
ref_best_rd = AOMMIN(rd, ref_best_rd);
if (rd < best_rd) {
@@ -5157,7 +5019,7 @@
assert(IMPLIES(!found, ref_best_rd != INT64_MAX));
if (!found) return;
-#if CONFIG_EXT_TX && CONFIG_LGT_FROM_PRED
+#if CONFIG_LGT_FROM_PRED
if (search_lgt && is_lgt_allowed(mbmi->mode, max_tx_size) &&
!cm->reduced_tx_set_used) {
RD_STATS this_rd_stats;
@@ -5177,7 +5039,7 @@
mbmi->use_lgt = 0;
}
}
-#endif // CONFIG_EXT_TX && CONFIG_LGT_FROM_PRED
+#endif // CONFIG_LGT_FROM_PRED
// We found a candidate transform to use. Copy our results from the "best"
// array into mbmi.
mbmi->tx_type = best_tx_type;