Commit 29e0f9faea for aom

commit 29e0f9faea1f24377b9e0f4ec99f06f1d0545745
Author: Bhaskarabhatla V S K S Yaswanth Sastry <yaswanth.sastry@ittiam.com>
Date:   Thu Jan 29 15:33:20 2026 +0530

    Enable SGR filter at speed 5,6

    This patch enables the SGR filter for speed 5 and 6 and
    introduces a new level 2 for the 'enable_sgr_ep_pruning'sf
    where only 4 SGR projection parameters are searched.

    Performance results averaged over all resolutions are as
    follows:

             Instruction
          Count Reduction(%)          BD-Rate Loss(%)
     cpu  Encoder  Decoder    avg.psnr   ssim     vmaf   vmaf_neg
      5   -1.89    -4.88      -1.2041  -1.9123  -0.3232  -0.4700
      6   -2.58    -4.81      -1.2586  -2.0265  -0.4120  -0.5395

    STATS_CHANGED for speed = 5,6.

    Change-Id:If4814eafac8ce1415e68788307be836b6846a02e

diff --git a/av1/encoder/pickrst.c b/av1/encoder/pickrst.c
index 3913d58351..cd79ed9248 100644
--- a/av1/encoder/pickrst.c
+++ b/av1/encoder/pickrst.c
@@ -848,25 +848,27 @@ static SgrprojInfo search_selfguided_restoration(
                           flt0, flt1, flt_stride, exqd, &err, error_info);
       get_best_error(&besterr, err, exqd, bestxqd, &bestep, ep);
     }
-    // evaluate left and right ep of winner in seed ep
-    int bestep_ref = bestep;
-    for (ep = bestep_ref - 1; ep < bestep_ref + 2; ep += 2) {
-      if (ep < SGRPROJ_EP_GRP1_START_IDX || ep > SGRPROJ_EP_GRP1_END_IDX)
-        continue;
-      int64_t err;
-      compute_sgrproj_err(dat8, width, height, dat_stride, src8, src_stride,
-                          use_highbitdepth, bit_depth, pu_width, pu_height, ep,
-                          flt0, flt1, flt_stride, exqd, &err, error_info);
-      get_best_error(&besterr, err, exqd, bestxqd, &bestep, ep);
-    }
-    // evaluate last two group
-    for (idx = 0; idx < SGRPROJ_EP_GRP2_3_SEARCH_COUNT; idx++) {
-      ep = sgproj_ep_grp2_3[idx][bestep];
-      int64_t err;
-      compute_sgrproj_err(dat8, width, height, dat_stride, src8, src_stride,
-                          use_highbitdepth, bit_depth, pu_width, pu_height, ep,
-                          flt0, flt1, flt_stride, exqd, &err, error_info);
-      get_best_error(&besterr, err, exqd, bestxqd, &bestep, ep);
+    if (enable_sgr_ep_pruning < 2) {
+      // evaluate left and right ep of winner in seed ep
+      int bestep_ref = bestep;
+      for (ep = bestep_ref - 1; ep < bestep_ref + 2; ep += 2) {
+        if (ep < SGRPROJ_EP_GRP1_START_IDX || ep > SGRPROJ_EP_GRP1_END_IDX)
+          continue;
+        int64_t err;
+        compute_sgrproj_err(dat8, width, height, dat_stride, src8, src_stride,
+                            use_highbitdepth, bit_depth, pu_width, pu_height,
+                            ep, flt0, flt1, flt_stride, exqd, &err, error_info);
+        get_best_error(&besterr, err, exqd, bestxqd, &bestep, ep);
+      }
+      // evaluate last two group
+      for (idx = 0; idx < SGRPROJ_EP_GRP2_3_SEARCH_COUNT; idx++) {
+        ep = sgproj_ep_grp2_3[idx][bestep];
+        int64_t err;
+        compute_sgrproj_err(dat8, width, height, dat_stride, src8, src_stride,
+                            use_highbitdepth, bit_depth, pu_width, pu_height,
+                            ep, flt0, flt1, flt_stride, exqd, &err, error_info);
+        get_best_error(&besterr, err, exqd, bestxqd, &bestep, ep);
+      }
     }
   }

diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index 0ba18c8296..e2b04cad07 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -1426,7 +1426,7 @@ static void set_good_speed_features_framesize_independent(
                                           : MULTI_WINNER_MODE_OFF;

     // Disable Self-guided Loop restoration filter.
-    sf->lpf_sf.disable_sgr_filter = true;
+    sf->lpf_sf.enable_sgr_ep_pruning = 2;
     sf->lpf_sf.disable_wiener_coeff_refine_search = true;

     sf->tpl_sf.prune_starting_mv = 3;
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index 54e64aeefc..ad7f7e4fb7 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -1598,7 +1598,14 @@ typedef struct LOOP_FILTER_SPEED_FEATURES {
   // search_switchable()
   int switchable_lr_with_bias_level;

-  // prune sgr ep using binary search like mechanism
+  // Enable fast search in self guided restoration
+  // 0 : Search over all 16 SGR projection parameters listed
+  //     in av1_sgr_params[SGRPROJ_PARAMS].
+  // 1 : Approximate search using binary search like mechanism,
+  //     a total of 8 SGR projection parameters are searched.
+  // 2 : Search only 'ep' values in
+  //     sgproj_ep_grp1_seed[SGRPROJ_EP_GRP1_SEARCH_COUNT],
+  //     a total of 4 SGR projection parameters are searched.
   int enable_sgr_ep_pruning;

   // Disable loop restoration for Chroma plane