Commit 002b63c3f7 for aom

commit 002b63c3f72097473f68e90310766b5ee61a6043
Author: Samuthirika <samuthirika.s@ittiam.com>
Date:   Wed Nov 18 10:36:46 2026 +0000

    Make subpel_search_method configurable per search site

    Previously, the subpel_search_method speed feature was
    configured globally for all sub-pel searches. This CL adds a
    framework to allow configuring sub-pel search methods
    independently across different caller sites.

    The enum SUBPEL_SEARCH_CASE is introduced to differentiate
    search stages, and subpel_search_method and
    find_fractional_mv_step are converted into arrays indexed by
    search case. The helper function set_subpel_search_methods() is
    used to initialize all cases to preserve existing behavior
    across speed presets.

    This is a bit-exact change.

    Change-Id: I44d4e94cf54120058ecd93e27dfb097c60f009b8

diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 23d6c9f83c..01c5b835f1 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -2173,15 +2173,7 @@ typedef struct {
    * In MV unit test: av1_return_max_sub_pixel_mv
    *                  av1_return_min_sub_pixel_mv
    */
-  fractional_mv_step_fp *find_fractional_mv_step;
-  /*!
-   * Pointer to sub-pixel search function for TPL motion search.
-   */
-  fractional_mv_step_fp *find_fractional_mv_step_tpl;
-  /*!
-   * Pointer to sub-pixel search function for temporal filtering motion search.
-   */
-  fractional_mv_step_fp *find_fractional_mv_step_tf;
+  fractional_mv_step_fp *find_fractional_mv_step[SUBPEL_SEARCH_CASES];
   /*!
    * Search site configuration for full-pel MV search.
    * search_site_cfg[SS_CFG_SRC]: Used in tpl, rd/non-rd inter mode loop, simple
@@ -4288,15 +4280,21 @@ static inline int get_chessboard_index(int frame_index) {
 }

 static inline const int *cond_cost_list_const(const struct AV1_COMP *cpi,
-                                              const int *cost_list) {
-  const int use_cost_list = cpi->sf.mv_sf.subpel_search_method != SUBPEL_TREE &&
-                            cpi->sf.mv_sf.use_fullpel_costlist;
+                                              const int *cost_list,
+                                              SUBPEL_SEARCH_CASE search_case) {
+  assert(search_case < SUBPEL_SEARCH_CASES);
+  const int use_cost_list =
+      cpi->sf.mv_sf.subpel_search_method[search_case] != SUBPEL_TREE &&
+      cpi->sf.mv_sf.use_fullpel_costlist;
   return use_cost_list ? cost_list : NULL;
 }

-static inline int *cond_cost_list(const struct AV1_COMP *cpi, int *cost_list) {
-  const int use_cost_list = cpi->sf.mv_sf.subpel_search_method != SUBPEL_TREE &&
-                            cpi->sf.mv_sf.use_fullpel_costlist;
+static inline int *cond_cost_list(const struct AV1_COMP *cpi, int *cost_list,
+                                  SUBPEL_SEARCH_CASE search_case) {
+  assert(search_case < SUBPEL_SEARCH_CASES);
+  const int use_cost_list =
+      cpi->sf.mv_sf.subpel_search_method[search_case] != SUBPEL_TREE &&
+      cpi->sf.mv_sf.use_fullpel_costlist;
   return use_cost_list ? cost_list : NULL;
 }

diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c
index ad875dab62..52b26127a4 100644
--- a/av1/encoder/mcomp.c
+++ b/av1/encoder/mcomp.c
@@ -184,13 +184,14 @@ void av1_set_ms_to_intra_mode(FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
 void av1_make_default_subpel_ms_params(SUBPEL_MOTION_SEARCH_PARAMS *ms_params,
                                        const struct AV1_COMP *cpi,
                                        const MACROBLOCK *x, BLOCK_SIZE bsize,
-                                       const MV *ref_mv, const int *cost_list) {
+                                       const MV *ref_mv, const int *cost_list,
+                                       SUBPEL_SEARCH_CASE search_case) {
   const AV1_COMMON *cm = &cpi->common;
   // High level params
   ms_params->allow_hp = cm->features.allow_high_precision_mv;
   ms_params->forced_stop = cpi->sf.mv_sf.subpel_force_stop;
   ms_params->iters_per_step = cpi->sf.mv_sf.subpel_iters_per_step;
-  ms_params->cost_list = cond_cost_list_const(cpi, cost_list);
+  ms_params->cost_list = cond_cost_list_const(cpi, cost_list, search_case);

   av1_set_subpel_mv_search_range(&ms_params->mv_limits, &x->mv_limits, ref_mv);

diff --git a/av1/encoder/mcomp.h b/av1/encoder/mcomp.h
index 53f1aae44d..21be593e55 100644
--- a/av1/encoder/mcomp.h
+++ b/av1/encoder/mcomp.h
@@ -273,6 +273,24 @@ static inline int av1_is_fullmv_in_range(const FullMvLimits *mv_limits,
 // =============================================================================
 //  Subpixel Motion Search
 // =============================================================================
+enum {
+  // Default sub-pel search used in non-RD pickmode.
+  SUBPEL_SEARCH_DEFAULT,
+  // Sub-pel search in TPL.
+  SUBPEL_SEARCH_TPL,
+  // Sub-pel search in temporal filter.
+  SUBPEL_SEARCH_TF,
+  // Sub-pel search in single motion search.
+  SUBPEL_SEARCH_SINGLE,
+  // Sub-pel search in joint motion search and
+  // compound single motion search.
+  SUBPEL_SEARCH_COMPOUND,
+  // Sub-pel search in simple motion search of partition decision.
+  SUBPEL_SEARCH_SMS,
+  // All sub-pel search cases.
+  SUBPEL_SEARCH_CASES
+} UENUM1BYTE(SUBPEL_SEARCH_CASE);
+
 enum {
   EIGHTH_PEL,
   QUARTER_PEL,
@@ -308,7 +326,8 @@ typedef struct {
 void av1_make_default_subpel_ms_params(SUBPEL_MOTION_SEARCH_PARAMS *ms_params,
                                        const struct AV1_COMP *cpi,
                                        const MACROBLOCK *x, BLOCK_SIZE bsize,
-                                       const MV *ref_mv, const int *cost_list);
+                                       const MV *ref_mv, const int *cost_list,
+                                       SUBPEL_SEARCH_CASE search_case);

 typedef int(fractional_mv_step_fp)(MACROBLOCKD *xd, const AV1_COMMON *const cm,
                                    const SUBPEL_MOTION_SEARCH_PARAMS *ms_params,
diff --git a/av1/encoder/motion_search_facade.c b/av1/encoder/motion_search_facade.c
index 0c2f56bf80..c501cdefab 100644
--- a/av1/encoder/motion_search_facade.c
+++ b/av1/encoder/motion_search_facade.c
@@ -335,8 +335,8 @@ void av1_single_motion_search(const AV1_COMP *const cpi, MACROBLOCK *x,
         }
         const int thissme = av1_full_pixel_search(
             smv.as_fullmv, &full_ms_params, pme_step_param,
-            cond_cost_list(cpi, cost_list), &this_best_mv, &this_mv_stats,
-            &this_second_best_mv);
+            cond_cost_list(cpi, cost_list, SUBPEL_SEARCH_SINGLE), &this_best_mv,
+            &this_mv_stats, &this_second_best_mv);

         if (thissme < bestsme) {
           bestsme = thissme;
@@ -432,7 +432,7 @@ void av1_single_motion_search(const AV1_COMP *const cpi, MACROBLOCK *x,

     SUBPEL_MOTION_SEARCH_PARAMS ms_params;
     av1_make_default_subpel_ms_params(&ms_params, cpi, x, bsize, &ref_mv,
-                                      cost_list);
+                                      cost_list, SUBPEL_SEARCH_SINGLE);
     MV subpel_start_mv = get_mv_from_fullmv(&best_mv->as_fullmv);
     assert(av1_is_subpelmv_in_range(&ms_params.mv_limits, subpel_start_mv));

@@ -442,9 +442,10 @@ void av1_single_motion_search(const AV1_COMP *const cpi, MACROBLOCK *x,
           const int try_second = second_best_mv.as_int != INVALID_MV &&
                                  second_best_mv.as_int != best_mv->as_int &&
                                  (mv_sf->disable_second_mv <= 1);
-          const int best_mv_var = mv_search_params->find_fractional_mv_step(
-              xd, cm, &ms_params, subpel_start_mv, &best_mv_stats,
-              &best_mv->as_mv, &dis, &x->pred_sse[ref], fractional_ms_list);
+          const int best_mv_var =
+              mv_search_params->find_fractional_mv_step[SUBPEL_SEARCH_SINGLE](
+                  xd, cm, &ms_params, subpel_start_mv, &best_mv_stats,
+                  &best_mv->as_mv, &dis, &x->pred_sse[ref], fractional_ms_list);

           if (try_second) {
             struct macroblockd_plane *p = xd->plane;
@@ -458,9 +459,11 @@ void av1_single_motion_search(const AV1_COMP *const cpi, MACROBLOCK *x,
             if (av1_is_subpelmv_in_range(&ms_params.mv_limits,
                                          subpel_start_mv)) {
               unsigned int sse;
-              const int this_var = mv_search_params->find_fractional_mv_step(
-                  xd, cm, &ms_params, subpel_start_mv, NULL, &this_best_mv,
-                  &dis, &sse, fractional_ms_list);
+              const int this_var =
+                  mv_search_params
+                      ->find_fractional_mv_step[SUBPEL_SEARCH_SINGLE](
+                          xd, cm, &ms_params, subpel_start_mv, NULL,
+                          &this_best_mv, &dis, &sse, fractional_ms_list);

               // If cpi->sf.mv_sf.disable_second_mv is 0 and both MVs are valid,
               // use actual rd cost to choose the better MV.
@@ -509,7 +512,7 @@ void av1_single_motion_search(const AV1_COMP *const cpi, MACROBLOCK *x,
             }
           }
         } else {
-          mv_search_params->find_fractional_mv_step(
+          mv_search_params->find_fractional_mv_step[SUBPEL_SEARCH_SINGLE](
               xd, cm, &ms_params, subpel_start_mv, &best_mv_stats,
               &best_mv->as_mv, &dis, &x->pred_sse[ref], NULL);
         }
@@ -771,7 +774,8 @@ int av1_joint_motion_search(const AV1_COMP *cpi, MACROBLOCK *x,
       unsigned int sse;
       SUBPEL_MOTION_SEARCH_PARAMS ms_params;
       av1_make_default_subpel_ms_params(&ms_params, cpi, x, bsize,
-                                        &ref_mv[id].as_mv, NULL);
+                                        &ref_mv[id].as_mv, NULL,
+                                        SUBPEL_SEARCH_COMPOUND);
       av1_set_ms_compound_refs(&ms_params.var_params.ms_buffers, second_pred,
                                mask, mask_stride, id);
       ms_params.forced_stop = EIGHTH_PEL;
@@ -780,16 +784,20 @@ int av1_joint_motion_search(const AV1_COMP *cpi, MACROBLOCK *x,
       }
       MV start_mv = get_mv_from_fullmv(&best_mv.as_fullmv);
       assert(av1_is_subpelmv_in_range(&ms_params.mv_limits, start_mv));
-      bestsme = cpi->mv_search_params.find_fractional_mv_step(
-          xd, cm, &ms_params, start_mv, NULL, &best_mv.as_mv, &dis, &sse, NULL);
+      bestsme =
+          cpi->mv_search_params.find_fractional_mv_step[SUBPEL_SEARCH_COMPOUND](
+              xd, cm, &ms_params, start_mv, NULL, &best_mv.as_mv, &dis, &sse,
+              NULL);

       if (try_second) {
         MV this_best_mv;
         MV subpel_start_mv = get_mv_from_fullmv(&second_best_mv.as_fullmv);
         if (av1_is_subpelmv_in_range(&ms_params.mv_limits, subpel_start_mv)) {
-          const int thissme = cpi->mv_search_params.find_fractional_mv_step(
-              xd, cm, &ms_params, subpel_start_mv, NULL, &this_best_mv, &dis,
-              &sse, NULL);
+          const int thissme =
+              cpi->mv_search_params
+                  .find_fractional_mv_step[SUBPEL_SEARCH_COMPOUND](
+                      xd, cm, &ms_params, subpel_start_mv, NULL, &this_best_mv,
+                      &dis, &sse, NULL);
           if (thissme < bestsme) {
             best_mv.as_mv = this_best_mv;
             bestsme = thissme;
@@ -917,15 +925,16 @@ int av1_compound_single_motion_search(const AV1_COMP *cpi, MACROBLOCK *x,
     unsigned int sse;
     SUBPEL_MOTION_SEARCH_PARAMS ms_params;
     av1_make_default_subpel_ms_params(&ms_params, cpi, x, bsize, &ref_mv.as_mv,
-                                      NULL);
+                                      NULL, SUBPEL_SEARCH_COMPOUND);
     av1_set_ms_compound_refs(&ms_params.var_params.ms_buffers, second_pred,
                              mask, mask_stride, ref_idx);
     ms_params.forced_stop = EIGHTH_PEL;
     MV start_mv = get_mv_from_fullmv(&best_mv.as_fullmv);
     assert(av1_is_subpelmv_in_range(&ms_params.mv_limits, start_mv));
-    bestsme = cpi->mv_search_params.find_fractional_mv_step(
-        xd, cm, &ms_params, start_mv, &best_mv_stats, &best_mv.as_mv, &dis,
-        &sse, NULL);
+    bestsme =
+        cpi->mv_search_params.find_fractional_mv_step[SUBPEL_SEARCH_COMPOUND](
+            xd, cm, &ms_params, start_mv, &best_mv_stats, &best_mv.as_mv, &dis,
+            &sse, NULL);
   }

   // Restore the pointer to the first unscaled prediction buffer.
@@ -1139,9 +1148,10 @@ int_mv av1_simple_motion_search_sse_var(AV1_COMP *const cpi, MACROBLOCK *x,
                                      start_mv, src_search_sites, search_method,
                                      fine_search_interval);

-  bestsme = av1_full_pixel_search(start_mv, &full_ms_params, step_param,
-                                  cond_cost_list(cpi, cost_list),
-                                  &best_mv.as_fullmv, &best_mv_stats, NULL);
+  bestsme =
+      av1_full_pixel_search(start_mv, &full_ms_params, step_param,
+                            cond_cost_list(cpi, cost_list, SUBPEL_SEARCH_SMS),
+                            &best_mv.as_fullmv, &best_mv_stats, NULL);

   const int use_subpel_search =
       bestsme < INT_MAX && !cpi->common.features.cur_frame_force_integer_mv &&
@@ -1155,14 +1165,14 @@ int_mv av1_simple_motion_search_sse_var(AV1_COMP *const cpi, MACROBLOCK *x,

     SUBPEL_MOTION_SEARCH_PARAMS ms_params;
     av1_make_default_subpel_ms_params(&ms_params, cpi, x, bsize, &ref_mv,
-                                      cost_list);
+                                      cost_list, SUBPEL_SEARCH_SMS);
     // TODO(yunqing): integrate this into av1_make_default_subpel_ms_params().
     ms_params.forced_stop = mv_sf->simple_motion_subpel_force_stop;

     MV subpel_start_mv = get_mv_from_fullmv(&best_mv.as_fullmv);
     assert(av1_is_subpelmv_in_range(&ms_params.mv_limits, subpel_start_mv));

-    cpi->mv_search_params.find_fractional_mv_step(
+    cpi->mv_search_params.find_fractional_mv_step[SUBPEL_SEARCH_SMS](
         xd, cm, &ms_params, subpel_start_mv, &best_mv_stats, &best_mv.as_mv,
         &not_used, &x->pred_sse[ref], NULL);

diff --git a/av1/encoder/nonrd_pickmode.c b/av1/encoder/nonrd_pickmode.c
index 66da8268b9..9267a6a178 100644
--- a/av1/encoder/nonrd_pickmode.c
+++ b/av1/encoder/nonrd_pickmode.c
@@ -236,8 +236,9 @@ static int combined_motion_search(AV1_COMP *cpi, MACROBLOCK *x,
                                      /*fine_search_interval=*/0);

   const int full_var_rd = av1_full_pixel_search(
-      start_mv, &full_ms_params, step_param, cond_cost_list(cpi, cost_list),
-      &tmp_mv->as_fullmv, &best_mv_stats, NULL);
+      start_mv, &full_ms_params, step_param,
+      cond_cost_list(cpi, cost_list, SUBPEL_SEARCH_DEFAULT), &tmp_mv->as_fullmv,
+      &best_mv_stats, NULL);

   // calculate the bit cost on motion vector
   MV mvp_full = get_mv_from_fullmv(&tmp_mv->as_fullmv);
@@ -251,7 +252,7 @@ static int combined_motion_search(AV1_COMP *cpi, MACROBLOCK *x,
   if (rv && search_subpel) {
     SUBPEL_MOTION_SEARCH_PARAMS ms_params;
     av1_make_default_subpel_ms_params(&ms_params, cpi, x, bsize, &ref_mv,
-                                      cost_list);
+                                      cost_list, SUBPEL_SEARCH_DEFAULT);
     const bool fullpel_performed_well =
         (bsize == BLOCK_64X64 && (int64_t)full_var_rd * 40 < 62267 * 7) ||
         (bsize == BLOCK_32X32 && (int64_t)full_var_rd * 8 < 42380) ||
@@ -270,7 +271,7 @@ static int combined_motion_search(AV1_COMP *cpi, MACROBLOCK *x,
           xd, cm, &ms_params, subpel_start_mv, &best_mv_stats, &tmp_mv->as_mv,
           &dis, &x->pred_sse[ref], NULL);
     else
-      cpi->mv_search_params.find_fractional_mv_step(
+      cpi->mv_search_params.find_fractional_mv_step[SUBPEL_SEARCH_DEFAULT](
           xd, cm, &ms_params, subpel_start_mv, &best_mv_stats, &tmp_mv->as_mv,
           &dis, &x->pred_sse[ref], NULL);
     *rate_mv =
@@ -346,7 +347,8 @@ static int search_new_mv(AV1_COMP *cpi, MACROBLOCK *x,
     this_ref_frm_newmv->as_mv.col >>= 3;

     SUBPEL_MOTION_SEARCH_PARAMS ms_params;
-    av1_make_default_subpel_ms_params(&ms_params, cpi, x, bsize, &ref_mv, NULL);
+    av1_make_default_subpel_ms_params(&ms_params, cpi, x, bsize, &ref_mv, NULL,
+                                      SUBPEL_SEARCH_DEFAULT);
     if (cpi->sf.rt_sf.reduce_mv_pel_precision_highmotion ||
         cpi->sf.rt_sf.reduce_mv_pel_precision_lowcomplex) {
       FULLPEL_MV start_mv = { .row = 0, .col = 0 };
@@ -355,7 +357,7 @@ static int search_new_mv(AV1_COMP *cpi, MACROBLOCK *x,
     }
     MV start_mv = get_mv_from_fullmv(&best_mv.as_fullmv);
     assert(av1_is_subpelmv_in_range(&ms_params.mv_limits, start_mv));
-    cpi->mv_search_params.find_fractional_mv_step(
+    cpi->mv_search_params.find_fractional_mv_step[SUBPEL_SEARCH_DEFAULT](
         xd, cm, &ms_params, start_mv, NULL, &best_mv.as_mv, &dis,
         &x->pred_sse[ref_frame], NULL);
     this_ref_frm_newmv->as_int = best_mv.as_int;
@@ -1432,7 +1434,8 @@ static void search_motion_mode(AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *this_rdc,
           const int_mv ref_mv = av1_get_ref_mv(x, 0);
           SUBPEL_MOTION_SEARCH_PARAMS ms_params;
           av1_make_default_subpel_ms_params(&ms_params, cpi, x, bsize,
-                                            &ref_mv.as_mv, NULL);
+                                            &ref_mv.as_mv, NULL,
+                                            SUBPEL_SEARCH_DEFAULT);

           // Refine MV in a small range.
           av1_refine_warped_mv(xd, cm, &ms_params, bsize, pts0, pts_inref0,
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 80514081c9..233e91cbf6 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -1827,7 +1827,8 @@ static int64_t motion_mode_rd(
           const int_mv ref_mv = av1_get_ref_mv(x, 0);
           SUBPEL_MOTION_SEARCH_PARAMS ms_params;
           av1_make_default_subpel_ms_params(&ms_params, cpi, x, bsize,
-                                            &ref_mv.as_mv, NULL);
+                                            &ref_mv.as_mv, NULL,
+                                            SUBPEL_SEARCH_DEFAULT);

           // Refine MV in a small range.
           dst_y_valid = av1_refine_warped_mv(xd, cm, &ms_params, bsize, pts0,
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index 5aff7167ed..fc7751d3f0 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -163,6 +163,15 @@ static inline void set_txfm_rd_gate_level(
     txfm_rd_gate_level[idx] = level;
 }

+// Set the given sub-pel search method for all the cases.
+static inline void set_subpel_search_methods(
+    SUBPEL_SEARCH_METHOD subpel_search_method[SUBPEL_SEARCH_CASES],
+    SUBPEL_SEARCH_METHOD method) {
+  assert(method < SUBPEL_SEARCH_METHODS);
+  for (int idx = 0; idx < SUBPEL_SEARCH_CASES; ++idx)
+    subpel_search_method[idx] = method;
+}
+
 static void set_allintra_speed_feature_framesize_dependent(
     const AV1_COMP *const cpi, SPEED_FEATURES *const sf, int speed) {
   const AV1_COMMON *const cm = &cpi->common;
@@ -469,7 +478,8 @@ static void set_allintra_speed_features_framesize_independent(
   }

   if (speed >= 4) {
-    sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE;
+    set_subpel_search_methods(sf->mv_sf.subpel_search_method,
+                              SUBPEL_TREE_PRUNED_MORE);

     sf->part_sf.simple_motion_search_prune_agg = SIMPLE_AGG_LVL4;
     sf->part_sf.simple_motion_search_reduce_search_steps = 4;
@@ -1450,7 +1460,6 @@ static void set_good_speed_features_framesize_independent(
     sf->pme_sf.early_exit_thresh = 64 * 64 * 8;
 #endif  // CONFIG_PYRAMID_ME
     sf->hl_sf.weight_calc_level_in_tf = low_q ? 0 : 1;
-    sf->hl_sf.tf_subpel_search_method = SUBPEL_TREE_PRUNED;

     sf->gm_sf.prune_ref_frame_for_gm_search = 1;
     sf->gm_sf.prune_zero_mv_with_sse = (is_lf_frame || low_q) ? 2 : 1;
@@ -1480,8 +1489,15 @@ static void set_good_speed_features_framesize_independent(
       }
     }

-    sf->mv_sf.subpel_search_method =
-        (low_q && is_lf_frame) ? SUBPEL_TREE_PRUNED_MORE : SUBPEL_TREE_PRUNED;
+    if (low_q && is_lf_frame) {
+      set_subpel_search_methods(sf->mv_sf.subpel_search_method,
+                                SUBPEL_TREE_PRUNED_MORE);
+    } else {
+      set_subpel_search_methods(sf->mv_sf.subpel_search_method,
+                                SUBPEL_TREE_PRUNED);
+    }
+    sf->mv_sf.subpel_search_method[SUBPEL_SEARCH_TF] = SUBPEL_TREE_PRUNED;
+    sf->mv_sf.subpel_search_method[SUBPEL_SEARCH_TPL] = SUBPEL_TREE_PRUNED;
     sf->mv_sf.simple_motion_subpel_force_stop =
         (is_deep_lf_frame || (low_q && is_lf_frame)) ? HALF_PEL : QUARTER_PEL;
     sf->mv_sf.search_method = DIAMOND;
@@ -1545,7 +1561,6 @@ static void set_good_speed_features_framesize_independent(
     sf->tpl_sf.prune_intra_modes = 1;
     sf->tpl_sf.reduce_first_step_size = 6;
     sf->tpl_sf.subpel_force_stop = QUARTER_PEL;
-    sf->tpl_sf.subpel_search_method = SUBPEL_TREE_PRUNED;

     sf->tx_sf.adaptive_txb_search_level = boosted ? 2 : 3;
     sf->tx_sf.tx_type_search.use_skip_flag_prediction = 2;
@@ -1592,9 +1607,8 @@ static void set_good_speed_features_framesize_independent(
 #if CONFIG_PYRAMID_ME
     sf->pme_sf.enable_pyramid_me = false;
 #endif  // CONFIG_PYRAMID_ME
-    sf->hl_sf.tf_subpel_search_method = SUBPEL_TREE_PRUNED_MORE;
-    sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE;
-    sf->tpl_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE;
+    set_subpel_search_methods(sf->mv_sf.subpel_search_method,
+                              SUBPEL_TREE_PRUNED_MORE);

     sf->gm_sf.prune_zero_mv_with_sse = 2;
     sf->gm_sf.downsample_level = 1;
@@ -1985,7 +1999,8 @@ static void set_rt_speed_feature_framesize_dependent(const AV1_COMP *const cpi,
          cpi->oxcf.frm_dim_cfg.width * cpi->oxcf.frm_dim_cfg.height <=
              640 * 360)) {
       sf->mv_sf.search_method = NSTEP;
-      sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED;
+      set_subpel_search_methods(sf->mv_sf.subpel_search_method,
+                                SUBPEL_TREE_PRUNED);
       sf->rt_sf.fullpel_search_step_param = 10;
       sf->rt_sf.reduce_mv_pel_precision_highmotion = 0;
       if (cm->width * cm->height <= 352 * 288)
@@ -1998,7 +2013,8 @@ static void set_rt_speed_feature_framesize_dependent(const AV1_COMP *const cpi,
       sf->rt_sf.reduce_mv_pel_precision_highmotion = 3;
       if (rtc_ref->non_reference_frame) {
         sf->rt_sf.nonrd_aggressive_skip = 1;
-        sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE;
+        set_subpel_search_methods(sf->mv_sf.subpel_search_method,
+                                  SUBPEL_TREE_PRUNED_MORE);
       }
     }
     if (speed <= 9 && cpi->svc.number_temporal_layers > 2 &&
@@ -2031,7 +2047,7 @@ static void set_rt_speed_feature_framesize_dependent(const AV1_COMP *const cpi,
     // For single layers RPS: bias/adjustment for recovery frame.
     if (cpi->ppi->rtc_ref.bias_recovery_frame) {
       sf->mv_sf.search_method = NSTEP;
-      sf->mv_sf.subpel_search_method = SUBPEL_TREE;
+      set_subpel_search_methods(sf->mv_sf.subpel_search_method, SUBPEL_TREE);
       sf->rt_sf.fullpel_search_step_param = 8;
       sf->rt_sf.nonrd_aggressive_skip = 0;
     }
@@ -2063,7 +2079,8 @@ static void set_rt_speed_feature_framesize_dependent(const AV1_COMP *const cpi,
       sf->rt_sf.skip_lf_screen = 1;
       sf->rt_sf.nonrd_prune_ref_frame_search = 3;
       sf->rt_sf.var_part_split_threshold_shift = 10;
-      sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE;
+      set_subpel_search_methods(sf->mv_sf.subpel_search_method,
+                                SUBPEL_TREE_PRUNED_MORE);
       sf->rt_sf.reduce_mv_pel_precision_lowcomplex = 1;
       sf->lpf_sf.cdef_pick_method = CDEF_PICK_FROM_Q;
       sf->rt_sf.nonrd_check_partition_merge_mode = 0;
@@ -2138,7 +2155,8 @@ static void set_rt_speed_feature_framesize_dependent(const AV1_COMP *const cpi,
     if (cpi->rc.high_source_sad && cpi->ppi->rtc_ref.non_reference_frame) {
       sf->rt_sf.use_idtx_nonrd = 0;
       sf->rt_sf.prefer_large_partition_blocks = 1;
-      sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE;
+      set_subpel_search_methods(sf->mv_sf.subpel_search_method,
+                                SUBPEL_TREE_PRUNED_MORE);
       sf->rt_sf.fullpel_search_step_param = 10;
     }
     sf->rt_sf.partition_direct_merging = 0;
@@ -2292,7 +2310,7 @@ static void set_rt_speed_features_framesize_independent(AV1_COMP *cpi,
   sf->mv_sf.use_accurate_subpel_search = USE_2_TAPS;
   sf->mv_sf.search_method = FAST_DIAMOND;
   sf->mv_sf.subpel_force_stop = EIGHTH_PEL;
-  sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED;
+  set_subpel_search_methods(sf->mv_sf.subpel_search_method, SUBPEL_TREE_PRUNED);

   for (int i = 0; i < TX_SIZES; ++i) {
     sf->intra_sf.intra_y_mode_mask[i] = INTRA_DC;
@@ -2498,7 +2516,8 @@ static void set_rt_speed_features_framesize_independent(AV1_COMP *cpi,
     sf->rt_sf.sse_early_term_inter_search = EARLY_TERM_IDX_4;
     sf->rt_sf.nonrd_prune_ref_frame_search = 3;
     sf->rt_sf.var_part_split_threshold_shift = 10;
-    sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE;
+    set_subpel_search_methods(sf->mv_sf.subpel_search_method,
+                              SUBPEL_TREE_PRUNED_MORE);
   }
   if (speed >= 11 && !frame_is_intra_only(cm) &&
       cpi->oxcf.tune_cfg.content == AOM_CONTENT_SCREEN) {
@@ -2529,7 +2548,6 @@ static inline void init_hl_sf(HIGH_LEVEL_SPEED_FEATURES *hl_sf) {
   hl_sf->ref_frame_mvs_lvl = 0;
   hl_sf->screen_detection_mode2_fast_detection = 0;
   hl_sf->weighted_chroma_distortion = 0;
-  hl_sf->tf_subpel_search_method = SUBPEL_TREE;
 }

 static inline void init_fp_sf(FIRST_PASS_SPEED_FEATURES *fp_sf) {
@@ -2546,7 +2564,6 @@ static inline void init_tpl_sf(TPL_SPEED_FEATURES *tpl_sf) {
   tpl_sf->reduce_first_step_size = 0;
   tpl_sf->skip_alike_starting_mv = 0;
   tpl_sf->subpel_force_stop = EIGHTH_PEL;
-  tpl_sf->subpel_search_method = SUBPEL_TREE;
   tpl_sf->search_method = NSTEP;
   tpl_sf->prune_ref_frames_in_tpl = 0;
   tpl_sf->allow_compound_pred = 1;
@@ -2679,7 +2696,7 @@ static inline void init_mv_sf(MV_SPEED_FEATURES *mv_sf) {
   mv_sf->simple_motion_subpel_force_stop = EIGHTH_PEL;
   mv_sf->subpel_force_stop = EIGHTH_PEL;
   mv_sf->subpel_iters_per_step = 2;
-  mv_sf->subpel_search_method = SUBPEL_TREE;
+  set_subpel_search_methods(mv_sf->subpel_search_method, SUBPEL_TREE);
   mv_sf->use_accurate_subpel_search = USE_8_TAPS;
   mv_sf->use_bsize_dependent_search_method = 0;
   mv_sf->use_fullpel_costlist = 0;
@@ -2991,15 +3008,14 @@ static fractional_mv_step_fp *get_subpel_search_method(

 // Populate appropriate sub-pel search method based on speed feature and user
 // specified settings
-static void set_subpel_search_method(MotionVectorSearchParams *mv_search_params,
-                                     unsigned int motion_vector_unit_test,
-                                     const SPEED_FEATURES *sf) {
-  mv_search_params->find_fractional_mv_step = get_subpel_search_method(
-      motion_vector_unit_test, sf->mv_sf.subpel_search_method);
-  mv_search_params->find_fractional_mv_step_tpl = get_subpel_search_method(
-      motion_vector_unit_test, sf->tpl_sf.subpel_search_method);
-  mv_search_params->find_fractional_mv_step_tf = get_subpel_search_method(
-      motion_vector_unit_test, sf->hl_sf.tf_subpel_search_method);
+static void set_subpel_search_method(
+    MotionVectorSearchParams *mv_search_params,
+    unsigned int motion_vector_unit_test,
+    const SUBPEL_SEARCH_METHOD subpel_search_method[SUBPEL_SEARCH_CASES]) {
+  for (int idx = 0; idx < SUBPEL_SEARCH_CASES; ++idx) {
+    mv_search_params->find_fractional_mv_step[idx] = get_subpel_search_method(
+        motion_vector_unit_test, subpel_search_method[idx]);
+  }
 }

 void av1_set_speed_features_framesize_dependent(AV1_COMP *cpi, int speed) {
@@ -3026,7 +3042,8 @@ void av1_set_speed_features_framesize_dependent(AV1_COMP *cpi, int speed) {
   }

   set_subpel_search_method(&cpi->mv_search_params,
-                           cpi->oxcf.unit_test_cfg.motion_vector_unit_test, sf);
+                           cpi->oxcf.unit_test_cfg.motion_vector_unit_test,
+                           sf->mv_sf.subpel_search_method);

   // For multi-thread use case with row_mt enabled, cost update for a set of
   // SB rows is not desirable. Hence, the sf mv_cost_upd_level is set to
@@ -3140,7 +3157,8 @@ void av1_set_speed_features_framesize_independent(AV1_COMP *cpi, int speed) {
     sf->hl_sf.recode_loop = DISALLOW_RECODE;

   set_subpel_search_method(&cpi->mv_search_params,
-                           cpi->oxcf.unit_test_cfg.motion_vector_unit_test, sf);
+                           cpi->oxcf.unit_test_cfg.motion_vector_unit_test,
+                           sf->mv_sf.subpel_search_method);

   // assert ensures that tx_domain_dist_level is accessed correctly
   assert(cpi->sf.rd_sf.tx_domain_dist_thres_level >= 0 &&
@@ -3497,7 +3515,8 @@ void av1_set_speed_features_qindex_dependent(AV1_COMP *cpi, int speed) {
   }

   set_subpel_search_method(&cpi->mv_search_params,
-                           cpi->oxcf.unit_test_cfg.motion_vector_unit_test, sf);
+                           cpi->oxcf.unit_test_cfg.motion_vector_unit_test,
+                           sf->mv_sf.subpel_search_method);

   // Apply faster motion search and downsampled SAD for GOOD mode at speed > 2.
   const int is_lf_frame =
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index 102cecb9e5..2380791461 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -493,11 +493,6 @@ typedef struct HIGH_LEVEL_SPEED_FEATURES {
    */
   int allow_sub_blk_me_in_tf;

-  /*!
-   * Sub-pixel search method used in temporal filtering motion estimation.
-   */
-  SUBPEL_SEARCH_METHOD tf_subpel_search_method;
-
   /*!
    * Decide whether to disable temporal mv prediction.
    * 0: Do not disable
@@ -575,9 +570,6 @@ typedef struct TPL_SPEED_FEATURES {
   // When to stop subpel search.
   SUBPEL_FORCE_STOP subpel_force_stop;

-  // Sub-pixel search method used in TPL motion estimation.
-  SUBPEL_SEARCH_METHOD subpel_search_method;
-
   // Which search method to use.
   SEARCH_METHODS search_method;

@@ -992,11 +984,9 @@ typedef struct MV_SPEED_FEATURES {
   // largest motion vector found in the last frame.
   int auto_mv_step_size;

-  // Subpel_search_method can only be subpel_tree which does a subpixel
-  // logarithmic search that keeps stepping at 1/2 pixel units until
-  // you stop getting a gain, and then goes on to 1/4 and repeats
-  // the same process. Along the way it skips many diagonals.
-  SUBPEL_SEARCH_METHOD subpel_search_method;
+  // Subpel_search_method used for logarithmic fractional-pel refinement
+  // across each search stage defined in SUBPEL_SEARCH_CASE.
+  SUBPEL_SEARCH_METHOD subpel_search_method[SUBPEL_SEARCH_CASES];

   // Maximum number of steps in logarithmic subpel search before giving up.
   int subpel_iters_per_step;
diff --git a/av1/encoder/temporal_filter.c b/av1/encoder/temporal_filter.c
index d775b3f1b5..fd9731f6ba 100644
--- a/av1/encoder/temporal_filter.c
+++ b/av1/encoder/temporal_filter.c
@@ -111,11 +111,11 @@ static void subblock_motion_search(
   }

   av1_full_pixel_search(start_mv, full_ms_params, step_param,
-                        cond_cost_list(cpi, cost_list), &best_mv.as_fullmv,
-                        best_mv_stats, NULL);
+                        cond_cost_list(cpi, cost_list, SUBPEL_SEARCH_TF),
+                        &best_mv.as_fullmv, best_mv_stats, NULL);

   av1_make_default_subpel_ms_params(ms_params, cpi, mb, subblock_size, ref_mv,
-                                    cost_list);
+                                    cost_list, SUBPEL_SEARCH_TF);
   ms_params->forced_stop = EIGHTH_PEL;
   ms_params->var_params.subpel_search_type = subpel_ms_type;
   // Since we are merely refining the result from full pixel
@@ -125,7 +125,7 @@ static void subblock_motion_search(

   MV subpel_start_mv = get_mv_from_fullmv(&best_mv.as_fullmv);
   assert(av1_is_subpelmv_in_range(&ms_params->mv_limits, subpel_start_mv));
-  error = cpi->mv_search_params.find_fractional_mv_step_tf(
+  error = cpi->mv_search_params.find_fractional_mv_step[SUBPEL_SEARCH_TF](
       &mb->e_mbd, &cpi->common, ms_params, subpel_start_mv, best_mv_stats,
       &best_mv.as_mv, &distortion, &sse, NULL);

@@ -348,8 +348,8 @@ static void tf_motion_search(AV1_COMP *cpi, MACROBLOCK *mb,
   }

   av1_full_pixel_search(start_mv, &full_ms_params, step_param,
-                        cond_cost_list(cpi, cost_list), &best_mv.as_fullmv,
-                        &best_mv_stats, NULL);
+                        cond_cost_list(cpi, cost_list, SUBPEL_SEARCH_TF),
+                        &best_mv.as_fullmv, &best_mv_stats, NULL);

   if (force_integer_mv == 1) {  // Only do full search on the entire block.
     const int mv_row = best_mv.as_mv.row;
@@ -366,7 +366,8 @@ static void tf_motion_search(AV1_COMP *cpi, MACROBLOCK *mb,
     if (src_var <= 2 * (int64_t)error) *is_low_cntras = 1;
   } else {  // Do fractional search on the entire block and all sub-blocks.
     av1_make_default_subpel_ms_params(&ms_params, cpi, mb, block_size,
-                                      &baseline_mv, cost_list);
+                                      &baseline_mv, cost_list,
+                                      SUBPEL_SEARCH_TF);
     ms_params.forced_stop = EIGHTH_PEL;
     ms_params.var_params.subpel_search_type = subpel_search_type;
     // Since we are merely refining the result from full pixel search, we don't
@@ -376,7 +377,7 @@ static void tf_motion_search(AV1_COMP *cpi, MACROBLOCK *mb,

     MV subpel_start_mv = get_mv_from_fullmv(&best_mv.as_fullmv);
     assert(av1_is_subpelmv_in_range(&ms_params.mv_limits, subpel_start_mv));
-    error = cpi->mv_search_params.find_fractional_mv_step_tf(
+    error = cpi->mv_search_params.find_fractional_mv_step[SUBPEL_SEARCH_TF](
         &mb->e_mbd, &cpi->common, &ms_params, subpel_start_mv, &best_mv_stats,
         &best_mv.as_mv, &distortion, &sse, NULL);
     block_mse = DIVIDE_AND_ROUND(error, mb_pels);
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index 1116271da1..c3715ba55e 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -320,9 +320,10 @@ static uint32_t motion_estimation(AV1_COMP *cpi, MACROBLOCK *x,
                                      tpl_sf->search_method,
                                      /*fine_search_interval=*/0);

-  bestsme = av1_full_pixel_search(start_mv, &full_ms_params, step_param,
-                                  cond_cost_list(cpi, cost_list),
-                                  &best_mv->as_fullmv, &best_mv_stats, NULL);
+  bestsme =
+      av1_full_pixel_search(start_mv, &full_ms_params, step_param,
+                            cond_cost_list(cpi, cost_list, SUBPEL_SEARCH_TPL),
+                            &best_mv->as_fullmv, &best_mv_stats, NULL);

   // When sub-pel motion search is skipped, populate sub-pel precision MV and
   // return.
@@ -333,14 +334,14 @@ static uint32_t motion_estimation(AV1_COMP *cpi, MACROBLOCK *x,

   SUBPEL_MOTION_SEARCH_PARAMS ms_params;
   av1_make_default_subpel_ms_params(&ms_params, cpi, x, bsize, &center_mv,
-                                    cost_list);
+                                    cost_list, SUBPEL_SEARCH_TPL);
   ms_params.forced_stop = tpl_sf->subpel_force_stop;
   ms_params.var_params.subpel_search_type = USE_2_TAPS;
   ms_params.mv_cost_params.mv_cost_type = MV_COST_NONE;
   best_mv_stats.err_cost = 0;
   MV subpel_start_mv = get_mv_from_fullmv(&best_mv->as_fullmv);
   assert(av1_is_subpelmv_in_range(&ms_params.mv_limits, subpel_start_mv));
-  bestsme = cpi->mv_search_params.find_fractional_mv_step_tpl(
+  bestsme = cpi->mv_search_params.find_fractional_mv_step[SUBPEL_SEARCH_TPL](
       xd, cm, &ms_params, subpel_start_mv, &best_mv_stats, &best_mv->as_mv,
       &distortion, &sse, NULL);