Change number of winner modes in winner mode processing
This CL limits the number of winner modes to 2 on speed 5, and
disables multi-winner processing on speed 6.
Performance:
SPEED SET | TESTSET | AVG_PSNR | OVR_PSNR | SSIM | SPD
-----------+---------+----------+----------+---------+-------
| LOWRES | +0.106% | +0.096% | +0.144% | +1.8%
5 | MIDRES | +0.110% | +0.097% | +0.069% | +1.2%
| HDRES | +0.026% | +0.018% | +0.041% | +1.1%
-----------+---------+----------+----------+---------+-------
| LOWRES | +0.517% | +0.496% | +0.664% | +5.4%
6 | MIDRES | +0.551% | +0.532% | +0.548% | +3.6%
| HDRES | +0.357% | +0.349% | +0.398% | +2.8%
STATS_CHANGED
BUG=aomedia:2694
Change-Id: Ide7990a142fd8d6cc51601003c417c628e22f079
diff --git a/av1/encoder/intra_mode_search.c b/av1/encoder/intra_mode_search.c
index c3563b8..de15b67 100644
--- a/av1/encoder/intra_mode_search.c
+++ b/av1/encoder/intra_mode_search.c
@@ -131,8 +131,7 @@
const int txfm_search_done = 1;
store_winner_mode_stats(
&cpi->common, x, mbmi, NULL, NULL, NULL, 0, NULL, bsize, this_rd,
- cpi->sf.winner_mode_sf.enable_multiwinner_mode_process,
- txfm_search_done);
+ cpi->sf.winner_mode_sf.multi_winner_mode_type, txfm_search_done);
if (this_rd < *best_rd) {
*best_rd = this_rd;
best_tx_size = mbmi->tx_size;
@@ -1113,8 +1112,7 @@
const int txfm_search_done = 1;
store_winner_mode_stats(
&cpi->common, x, mbmi, NULL, NULL, NULL, 0, NULL, bsize, this_rd,
- cpi->sf.winner_mode_sf.enable_multiwinner_mode_process,
- txfm_search_done);
+ cpi->sf.winner_mode_sf.multi_winner_mode_type, txfm_search_done);
if (this_rd < best_rd) {
best_mbmi = *mbmi;
best_rd = this_rd;
@@ -1156,7 +1154,7 @@
// In multi-winner mode processing, perform tx search for few best modes
// identified during mode evaluation. Winner mode processing uses best tx
// configuration for tx search.
- if (cpi->sf.winner_mode_sf.enable_multiwinner_mode_process) {
+ if (cpi->sf.winner_mode_sf.multi_winner_mode_type) {
int best_mode_idx = 0;
int block_width, block_height;
uint8_t *color_map_dst = xd->plane[PLANE_TYPE_Y].color_index_map;
diff --git a/av1/encoder/palette.c b/av1/encoder/palette.c
index b91b50d..dd54a8a 100644
--- a/av1/encoder/palette.c
+++ b/av1/encoder/palette.c
@@ -268,8 +268,7 @@
const int txfm_search_done = 1;
store_winner_mode_stats(
&cpi->common, x, mbmi, NULL, NULL, NULL, THR_DC, color_map, bsize,
- this_rd, cpi->sf.winner_mode_sf.enable_multiwinner_mode_process,
- txfm_search_done);
+ this_rd, cpi->sf.winner_mode_sf.multi_winner_mode_type, txfm_search_done);
if (this_rd < *best_rd) {
*best_rd = this_rd;
// Setting beat_best_rd flag because current mode rd is better than best_rd.
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index a87a67d..a6f2e64 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -2421,7 +2421,7 @@
store_winner_mode_stats(
&cpi->common, x, best_mbmi, best_rd_stats, best_rd_stats_y,
best_rd_stats_uv, mode_enum, NULL, bsize, *best_rd,
- cpi->sf.winner_mode_sf.enable_multiwinner_mode_process, do_tx_search);
+ cpi->sf.winner_mode_sf.multi_winner_mode_type, do_tx_search);
args->modelled_rd[this_mode][ref_mv_idx][refs[0]] =
args->modelled_rd[this_mode][i][refs[0]];
args->simple_rd[this_mode][ref_mv_idx][refs[0]] =
@@ -2927,10 +2927,10 @@
const THR_MODES mode_enum = get_prediction_mode_idx(
mbmi->mode, mbmi->ref_frame[0], mbmi->ref_frame[1]);
// Collect mode stats for multiwinner mode processing
- store_winner_mode_stats(
- &cpi->common, x, mbmi, rd_stats, rd_stats_y, rd_stats_uv, mode_enum,
- NULL, bsize, tmp_rd,
- cpi->sf.winner_mode_sf.enable_multiwinner_mode_process, do_tx_search);
+ store_winner_mode_stats(&cpi->common, x, mbmi, rd_stats, rd_stats_y,
+ rd_stats_uv, mode_enum, NULL, bsize, tmp_rd,
+ cpi->sf.winner_mode_sf.multi_winner_mode_type,
+ do_tx_search);
if (tmp_rd < best_rd) {
// Update the best rd stats if we found the best mode so far
best_rd_stats = *rd_stats;
@@ -3415,10 +3415,10 @@
MACROBLOCK *x, MB_MODE_INFO *best_mbmode, RD_STATS *best_rd_cost,
int best_rate_y, int best_rate_uv, THR_MODES *best_mode_index,
RD_STATS **winner_rd_cost, int *winner_rate_y, int *winner_rate_uv,
- THR_MODES *winner_mode_index, int enable_multiwinner_mode_process,
+ THR_MODES *winner_mode_index, MULTI_WINNER_MODE_TYPE multi_winner_mode_type,
int mode_idx) {
MB_MODE_INFO *winner_mbmi;
- if (enable_multiwinner_mode_process) {
+ if (multi_winner_mode_type) {
assert(mode_idx >= 0 && mode_idx < x->winner_mode_count);
WinnerModeStats *winner_mode_stat = &x->winner_mode_stats[mode_idx];
winner_mbmi = &winner_mode_stat->mbmi;
@@ -3475,7 +3475,7 @@
MB_MODE_INFO *winner_mbmi = get_winner_mode_stats(
x, best_mbmode, rd_cost, best_rate_y, best_rate_uv, best_mode_index,
&winner_rd_stats, &winner_rate_y, &winner_rate_uv, &winner_mode_index,
- cpi->sf.winner_mode_sf.enable_multiwinner_mode_process, mode_idx);
+ cpi->sf.winner_mode_sf.multi_winner_mode_type, mode_idx);
if (xd->lossless[winner_mbmi->segment_id] == 0 &&
winner_mode_index != THR_INVALID &&
@@ -4631,7 +4631,7 @@
store_winner_mode_stats(
&cpi->common, x, mbmi, &rd_stats, &rd_stats_y, &rd_stats_uv,
mode_enum, NULL, bsize, rd_stats.rdcost,
- cpi->sf.winner_mode_sf.enable_multiwinner_mode_process, do_tx_search);
+ cpi->sf.winner_mode_sf.multi_winner_mode_type, do_tx_search);
if (rd_stats.rdcost < search_state->best_rd) {
update_search_state(search_state, rd_cost, ctx, &rd_stats, &rd_stats_y,
&rd_stats_uv, mode_enum, x, do_tx_search);
@@ -4814,10 +4814,9 @@
search_state->best_mode_index = THR_INVALID;
// Initialize best mode stats for winner mode processing
x->winner_mode_count = 0;
- store_winner_mode_stats(
- &cpi->common, x, mbmi, NULL, NULL, NULL, THR_INVALID, NULL, bsize,
- best_rd_so_far, cpi->sf.winner_mode_sf.enable_multiwinner_mode_process,
- 0);
+ store_winner_mode_stats(&cpi->common, x, mbmi, NULL, NULL, NULL, THR_INVALID,
+ NULL, bsize, best_rd_so_far,
+ cpi->sf.winner_mode_sf.multi_winner_mode_type, 0);
inter_modes_info->num =
inter_modes_info->num < cpi->sf.rt_sf.num_inter_modes_for_tx_search
? inter_modes_info->num
@@ -4887,8 +4886,7 @@
store_winner_mode_stats(
&cpi->common, x, mbmi, &rd_stats, &rd_stats_y, &rd_stats_uv, mode_enum,
NULL, bsize, rd_stats.rdcost,
- cpi->sf.winner_mode_sf.enable_multiwinner_mode_process,
- txfm_search_done);
+ cpi->sf.winner_mode_sf.multi_winner_mode_type, txfm_search_done);
if (rd_stats.rdcost < search_state->best_rd) {
update_search_state(search_state, rd_cost, ctx, &rd_stats, &rd_stats_y,
@@ -5119,10 +5117,9 @@
// Initialize best mode stats for winner mode processing
av1_zero(x->winner_mode_stats);
x->winner_mode_count = 0;
- store_winner_mode_stats(
- &cpi->common, x, mbmi, NULL, NULL, NULL, THR_INVALID, NULL, bsize,
- best_rd_so_far, cpi->sf.winner_mode_sf.enable_multiwinner_mode_process,
- 0);
+ store_winner_mode_stats(&cpi->common, x, mbmi, NULL, NULL, NULL, THR_INVALID,
+ NULL, bsize, best_rd_so_far,
+ cpi->sf.winner_mode_sf.multi_winner_mode_type, 0);
int mode_thresh_mul_fact = (1 << MODE_THRESH_QBITS);
if (sf->inter_sf.prune_inter_modes_if_skippable) {
@@ -5356,8 +5353,7 @@
store_winner_mode_stats(
&cpi->common, x, mbmi, &intra_rd_stats, &intra_rd_stats_y,
&intra_rd_stats_uv, mode_enum, NULL, bsize, intra_rd_stats.rdcost,
- cpi->sf.winner_mode_sf.enable_multiwinner_mode_process,
- txfm_search_done);
+ cpi->sf.winner_mode_sf.multi_winner_mode_type, txfm_search_done);
if (intra_rd_stats.rdcost < search_state.best_rd) {
update_search_state(&search_state, rd_cost, ctx, &intra_rd_stats,
&intra_rd_stats_y, &intra_rd_stats_uv, mode_enum, x,
@@ -5368,9 +5364,8 @@
end_timing(cpi, handle_intra_mode_time);
#endif
- int winner_mode_count = cpi->sf.winner_mode_sf.enable_multiwinner_mode_process
- ? x->winner_mode_count
- : 1;
+ int winner_mode_count =
+ cpi->sf.winner_mode_sf.multi_winner_mode_type ? x->winner_mode_count : 1;
// In effect only when fast tx search speed features are enabled.
refine_winner_mode_tx(
cpi, x, rd_cost, bsize, ctx, &search_state.best_mode_index,
diff --git a/av1/encoder/rdopt_utils.h b/av1/encoder/rdopt_utils.h
index 73f1496..cc14163 100644
--- a/av1/encoder/rdopt_utils.h
+++ b/av1/encoder/rdopt_utils.h
@@ -595,21 +595,24 @@
const AV1_COMMON *const cm, MACROBLOCK *x, const MB_MODE_INFO *mbmi,
RD_STATS *rd_cost, RD_STATS *rd_cost_y, RD_STATS *rd_cost_uv,
THR_MODES mode_index, uint8_t *color_map, BLOCK_SIZE bsize, int64_t this_rd,
- int enable_multiwinner_mode_process, int txfm_search_done) {
+ int multi_winner_mode_type, int txfm_search_done) {
WinnerModeStats *winner_mode_stats = x->winner_mode_stats;
int mode_idx = 0;
int is_palette_mode = mbmi->palette_mode_info.palette_size[PLANE_TYPE_Y] > 0;
// Mode stat is not required when multiwinner mode processing is disabled
- if (!enable_multiwinner_mode_process) return;
+ if (multi_winner_mode_type == MULTI_WINNER_MODE_OFF) return;
// Ignore mode with maximum rd
if (this_rd == INT64_MAX) return;
// TODO(any): Winner mode processing is currently not applicable for palette
// mode in Inter frames. Clean-up the following code, once support is added
if (!frame_is_intra_only(cm) && is_palette_mode) return;
- const int max_winner_mode_count = frame_is_intra_only(cm)
- ? MAX_WINNER_MODE_COUNT_INTRA
- : MAX_WINNER_MODE_COUNT_INTER;
+ int max_winner_mode_count = frame_is_intra_only(cm)
+ ? MAX_WINNER_MODE_COUNT_INTRA
+ : MAX_WINNER_MODE_COUNT_INTER;
+ max_winner_mode_count = (multi_winner_mode_type == MULTI_WINNER_MODE_FAST)
+ ? AOMMIN(max_winner_mode_count, 2)
+ : max_winner_mode_count;
assert(x->winner_mode_count >= 0 &&
x->winner_mode_count <= max_winner_mode_count);
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index 7a57140..a998e9d 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -577,8 +577,9 @@
sf->rd_sf.tx_domain_dist_thres_level = 2;
// TODO(any): Extend multi-winner mode processing support for inter frames
- sf->winner_mode_sf.enable_multiwinner_mode_process =
- frame_is_intra_only(&cpi->common) ? 1 : 0;
+ sf->winner_mode_sf.multi_winner_mode_type =
+ frame_is_intra_only(&cpi->common) ? MULTI_WINNER_MODE_DEFAULT
+ : MULTI_WINNER_MODE_OFF;
sf->winner_mode_sf.enable_winner_mode_for_tx_size_srch = 1;
sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL2;
@@ -615,6 +616,11 @@
sf->inter_sf.txfm_rd_gate_level = boosted ? 0 : 4;
sf->inter_sf.prune_inter_modes_if_skippable = 1;
+ // TODO(any): Extend multi-winner mode processing support for inter frames
+ sf->winner_mode_sf.multi_winner_mode_type =
+ frame_is_intra_only(&cpi->common) ? MULTI_WINNER_MODE_FAST
+ : MULTI_WINNER_MODE_OFF;
+
sf->lpf_sf.lpf_pick = LPF_PICK_FROM_FULL_IMAGE_NON_DUAL;
sf->lpf_sf.disable_lr_filter = 1;
sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL3;
@@ -634,6 +640,8 @@
sf->tpl_sf.disable_filtered_key_tpl = 1;
sf->tx_sf.tx_type_search.prune_tx_type_est_rd = 0;
+
+ sf->winner_mode_sf.multi_winner_mode_type = MULTI_WINNER_MODE_OFF;
}
}
@@ -1144,7 +1152,7 @@
winner_mode_sf->enable_winner_mode_for_coeff_opt = 0;
winner_mode_sf->enable_winner_mode_for_tx_size_srch = 0;
winner_mode_sf->enable_winner_mode_for_use_tx_domain_dist = 0;
- winner_mode_sf->enable_multiwinner_mode_process = 0;
+ winner_mode_sf->multi_winner_mode_type = 0;
}
static AOM_INLINE void init_lpf_sf(LOOP_FILTER_SPEED_FEATURES *lpf_sf) {
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index ef833bc..3d91a40 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -204,6 +204,20 @@
FAST_DETECTION_MAXQ = 1,
} UENUM1BYTE(OVERSHOOT_DETECTION_CBR);
+enum {
+ // Turns off multi-winner mode. So we will do txfm search on either all modes
+ // if winner mode is off, or we will only on txfm search on a single winner
+ // mode.
+ MULTI_WINNER_MODE_OFF = 0,
+
+ // Limits the number of winner modes to at most 2
+ MULTI_WINNER_MODE_FAST = 1,
+
+ // Uses the default number of winner modes, which is 3 for intra mode, and 1
+ // for inter mode.
+ MULTI_WINNER_MODE_DEFAULT = 2,
+} UENUM1BYTE(MULTI_WINNER_MODE_TYPE);
+
typedef struct {
TX_TYPE_PRUNE_MODE prune_2d_txfm_mode;
int fast_intra_tx_type_search;
@@ -852,7 +866,7 @@
int enable_winner_mode_for_use_tx_domain_dist;
// Flag used to enable processing of multiple winner modes
- int enable_multiwinner_mode_process;
+ MULTI_WINNER_MODE_TYPE multi_winner_mode_type;
// Motion mode for winner candidates:
// 0: speed feature OFF