lc-dec: Add sf switchable_lr_with_bias_level

This patch introduces a speed feature that restricts loop restoration
search to RESTORE_SWITCHABLE by skipping RD Cost comparison of
RESTORE_WIENER and RESTORE_SGRPROJ. It also applies a 0.5% penalty with
each level to Wiener and SGR filter selection during switchable
restoration search (search_switchable()).

Performance results of encoder and decoder for the streams
generated with low complexity decode enabled.

     Decode Time              BD-Rate Loss(%)
cpu  Reduction(%)   avg.psnr   ssim     vmaf    vmaf_neg
 1      1.373        0.1069   0.1401   0.1123    0.0916
 2      1.093        0.1058   0.1232   0.3045    0.1850
 3      0.792        0.0701   0.0792   0.3529    0.2326

STATS_CHANGED for low complexity decode

Change-Id: I035f3fc302ffe59b0a0f5d27e2b9e0ef5e1fef21
diff --git a/av1/encoder/pickrst.c b/av1/encoder/pickrst.c
index 4e7030c..3913d58 100644
--- a/av1/encoder/pickrst.c
+++ b/av1/encoder/pickrst.c
@@ -38,6 +38,9 @@
 // Penalty factor for use of dual sgr
 #define DUAL_SGR_PENALTY_MULT 0.01
 
+// Penalty factor to bias against Wiener and SGR filters
+#define WIENER_SGR_PENALTY_MULT 0.005
+
 // Working precision for Wiener filter coefficients
 #define WIENER_TAP_SCALE_FACTOR ((int64_t)1 << 16)
 
@@ -1815,6 +1818,10 @@
         x->rdmult, bits >> 4, sse, rsc->cm->seq_params->bit_depth);
     if (r == RESTORE_SGRPROJ && rusi->sgrproj.ep < 10)
       cost *= (1 + DUAL_SGR_PENALTY_MULT * rsc->lpf_sf->dual_sgr_penalty_level);
+
+    if (r == RESTORE_WIENER || r == RESTORE_SGRPROJ)
+      cost *= (1 + WIENER_SGR_PENALTY_MULT *
+                       rsc->lpf_sf->switchable_lr_with_bias_level);
     if (r == 0 || cost < best_cost) {
       best_cost = cost;
       best_bits = bits;
@@ -2168,6 +2175,12 @@
         // feature 'disable_wiener_filter' and 'disable_sgr_filter'.
         if (disable_lr_filter[r]) continue;
 
+        // Restrict loop restoration search to RESTORE_SWITCHABLE by skipping
+        // WIENER and SGRPROJ.
+        if (lpf_sf->switchable_lr_with_bias_level > 0 &&
+            (r == RESTORE_WIENER || r == RESTORE_SGRPROJ))
+          continue;
+
         double cost_this_plane = RDCOST_DBL_WITH_NATIVE_BD_DIST(
             x->rdmult, rsc.total_bits[r] >> 4, rsc.total_sse[r],
             cm->seq_params->bit_depth);
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index 6bafdab..bfee784 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -619,6 +619,7 @@
     sf->hl_sf.ref_frame_mvs_lvl = 2;
 
     sf->lpf_sf.dual_sgr_penalty_level = boosted ? 1 : 3;
+    sf->lpf_sf.switchable_lr_with_bias_level = 1;
     sf->lpf_sf.skip_loop_filter_using_filt_error =
         (update_type != OVERLAY_UPDATE && update_type != INTNL_OVERLAY_UPDATE &&
          cpi->common.current_frame.pyramid_level > 1)
@@ -641,6 +642,7 @@
     sf->hl_sf.ref_frame_mvs_lvl = 1;
 
     sf->lpf_sf.dual_sgr_penalty_level = boosted ? 1 : 2;
+    sf->lpf_sf.switchable_lr_with_bias_level = 1;
     sf->lpf_sf.skip_loop_filter_using_filt_error =
         (update_type != OVERLAY_UPDATE && update_type != INTNL_OVERLAY_UPDATE &&
          cpi->common.current_frame.pyramid_level > 1)
@@ -2355,6 +2357,7 @@
   lpf_sf->disable_sgr_filter = false;
   lpf_sf->disable_wiener_coeff_refine_search = false;
   lpf_sf->use_downsampled_wiener_stats = 0;
+  lpf_sf->switchable_lr_with_bias_level = 0;
 }
 
 static inline void init_rt_sf(REAL_TIME_SPEED_FEATURES *rt_sf) {
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index a7a46c8..1b455d4 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -1537,6 +1537,15 @@
   // adding a penalty of 1%
   int dual_sgr_penalty_level;
 
+  // Restricts loop restoration to RESTORE_SWITCHABLE by skipping RD cost
+  // comparisons for RESTORE_WIENER and RESTORE_SGRPROJ. Also applies a bias
+  // during switchable restoration search: each level adds a 0.5% penalty to
+  // Wiener and SGR selection.
+  // 0 : No restriction or bias (all restoration types allowed)
+  // 1+: Skip WIENER/SGRPROJ and apply (level x 0.5%) penalty in
+  // search_switchable()
+  int switchable_lr_with_bias_level;
+
   // prune sgr ep using binary search like mechanism
   int enable_sgr_ep_pruning;