aom: rtc: Adjustments for nonrd keyframe for screen

From 3944d9b3b2accec4cf2b442842f99a9a915f0772 Mon Sep 17 00:00:00 2001
From: Marco Paniconi <[EMAIL REDACTED]>
Date: Wed, 8 May 2024 10:58:55 -0700
Subject: [PATCH] rtc: Adjustments for nonrd keyframe for screen

For speed 11 keyframes in screen mode:
lower the dist_thresh, and include some pruning of
the H/V/SMOOTH modes based on existing speed features.

This brings some quality back with little speed loss.

Change-Id: I94b8a6429c6f9feca9c0e493a336a0b0d594bc7e
---
 av1/encoder/nonrd_pickmode.c | 5 ++---
 av1/encoder/speed_features.c | 3 +++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/av1/encoder/nonrd_pickmode.c b/av1/encoder/nonrd_pickmode.c
index 6a734cbd1..4032d942f 100644
--- a/av1/encoder/nonrd_pickmode.c
+++ b/av1/encoder/nonrd_pickmode.c
@@ -1648,7 +1648,7 @@ void av1_nonrd_pick_intra_mode(AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *rd_cost,
     }
   }
 
-  const int64_t thresh_dist = cpi->sf.rt_sf.prune_palette_nonrd ? 80000 : 20000;
+  const int64_t thresh_dist = cpi->sf.rt_sf.prune_palette_nonrd ? 60000 : 20000;
   const int64_t best_dist_norm = best_rdc.dist >> (b_width_log2_lookup[bsize] +
                                                    b_height_log2_lookup[bsize]);
 
@@ -1665,8 +1665,7 @@ void av1_nonrd_pick_intra_mode(AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *rd_cost,
     av1_search_palette_mode_luma(cpi, x, bsize, intra_ref_frame_cost, ctx,
                                  &this_rdc, best_rdc.rdcost);
     // Update best mode data.
-    if (this_rdc.rdcost < best_rdc.rdcost &&
-        this_rdc.rate < (3 * (best_rdc.rate >> 1))) {
+    if (this_rdc.rdcost < best_rdc.rdcost) {
       best_mode = DC_PRED;
       mi->mv[0].as_int = INVALID_MV;
       mi->mv[1].as_int = INVALID_MV;
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index 25c0b3af4..4ddd4903a 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -1586,6 +1586,9 @@ static void set_rt_speed_feature_framesize_dependent(const AV1_COMP *const cpi,
       sf->rt_sf.part_early_exit_zeromv = 2;
       sf->rt_sf.prune_palette_nonrd = 1;
       sf->rt_sf.increase_color_thresh_palette = 0;
+      sf->rt_sf.prune_h_pred_using_best_mode_so_far = true;
+      sf->rt_sf.enable_intra_mode_pruning_using_neighbors = true;
+      sf->rt_sf.prune_intra_mode_using_best_sad_so_far = true;
     }
     sf->rt_sf.skip_newmv_flat_blocks_screen = 1;
     sf->rt_sf.use_idtx_nonrd = 1;