rtc-screen: Incorporate color into rd cost for IDTX
IDTX mode in nonrd_pickmode is only based on Y channel,
some logic exist to bypass this mode test when color
sensitivity is set, but in some cases, even with color
detected, its still worth entering the mode test.
If color_sensitivity is set for the coding block,
and we enter the IDTX search, add terms from UV channel
into rdcost, using model_rd to avoid slowdown.
bdrate gains on speed 10 rtc screen:
avg/ovr/ssim, IC speedup
-0.493/-1.099/-1.248, 0.286
This reduces color artifacts in sc_web_browsing.
Change-Id: I16695c7647026bb70c437a2f9e8982927ee0df59
diff --git a/av1/encoder/nonrd_pickmode.c b/av1/encoder/nonrd_pickmode.c
index 05bcf1d..57498b1 100644
--- a/av1/encoder/nonrd_pickmode.c
+++ b/av1/encoder/nonrd_pickmode.c
@@ -2905,7 +2905,8 @@
AV1_COMP *cpi, MACROBLOCK *x, InterModeSearchStateNonrd *search_state,
PRED_BUFFER *this_mode_pred, PICK_MODE_CONTEXT *ctx,
PRED_BUFFER *tmp_buffer, struct buf_2d *orig_dst, int skip_idtx_palette,
- int try_palette, BLOCK_SIZE bsize, int reuse_inter_pred) {
+ int try_palette, BLOCK_SIZE bsize, int reuse_inter_pred, int mi_col,
+ int mi_row) {
AV1_COMMON *const cm = &cpi->common;
const REAL_TIME_SPEED_FEATURES *const rt_sf = &cpi->sf.rt_sf;
MACROBLOCKD *const xd = &x->e_mbd;
@@ -2937,12 +2938,29 @@
const PRED_BUFFER *const best_pred = best_pickmode->best_pred;
av1_block_yrd_idtx(x, best_pred->data, best_pred->stride, &idtx_rdc,
&is_skippable, bsize, mi->tx_size);
+ // Incorporate color into rd cost.
+ if ((x->color_sensitivity[COLOR_SENS_IDX(AOM_PLANE_U)] ||
+ x->color_sensitivity[COLOR_SENS_IDX(AOM_PLANE_V)])) {
+ RD_STATS rdc_uv;
+ const BLOCK_SIZE uv_bsize =
+ get_plane_block_size(bsize, xd->plane[AOM_PLANE_U].subsampling_x,
+ xd->plane[AOM_PLANE_U].subsampling_y);
+ if (x->color_sensitivity[COLOR_SENS_IDX(AOM_PLANE_U)]) {
+ av1_enc_build_inter_predictor(cm, xd, mi_row, mi_col, NULL, bsize,
+ AOM_PLANE_U, AOM_PLANE_U);
+ }
+ if (x->color_sensitivity[COLOR_SENS_IDX(AOM_PLANE_V)]) {
+ av1_enc_build_inter_predictor(cm, xd, mi_row, mi_col, NULL, bsize,
+ AOM_PLANE_V, AOM_PLANE_V);
+ }
+ av1_model_rd_for_sb_uv(cpi, uv_bsize, x, xd, &rdc_uv, AOM_PLANE_U,
+ AOM_PLANE_V);
+ idtx_rdc.rate += rdc_uv.rate;
+ idtx_rdc.dist += rdc_uv.dist;
+ idtx_rdc.skip_txfm = idtx_rdc.skip_txfm && rdc_uv.skip_txfm;
+ }
int64_t idx_rdcost = RDCOST(x->rdmult, idtx_rdc.rate, idtx_rdc.dist);
if (idx_rdcost < search_state->best_rdc.rdcost) {
- // Keep the skip_txfm off if the color_sensitivity is set.
- if (x->color_sensitivity[COLOR_SENS_IDX(AOM_PLANE_U)] ||
- x->color_sensitivity[COLOR_SENS_IDX(AOM_PLANE_V)])
- idtx_rdc.skip_txfm = 0;
best_pickmode->tx_type = IDTX;
search_state->best_rdc.rdcost = idx_rdcost;
best_pickmode->best_mode_skip_txfm = idtx_rdc.skip_txfm;
@@ -3303,9 +3321,9 @@
if (rt_sf->prune_palette_nonrd && bsize > BLOCK_16X16) try_palette = 0;
// Perform screen content mode evaluation for non-rd
- handle_screen_content_mode_nonrd(cpi, x, &search_state, this_mode_pred, ctx,
- tmp_buffer, &orig_dst, skip_idtx_palette,
- try_palette, bsize, reuse_inter_pred);
+ handle_screen_content_mode_nonrd(
+ cpi, x, &search_state, this_mode_pred, ctx, tmp_buffer, &orig_dst,
+ skip_idtx_palette, try_palette, bsize, reuse_inter_pred, mi_col, mi_row);
#if COLLECT_NONRD_PICK_MODE_STAT
aom_usec_timer_mark(&x->ms_stat_nonrd.timer1);