Commit 136511836e for aom

commit 136511836e54093f24d23f02cf93943ff5fc97a2
Author: Yunqing Wang <yunqingwang@google.com>
Date:   Fri Apr 24 16:19:21 2026 -0700

    Remove unused square motion search method

    Change-Id: I321eb27314508c7ef816bc73ca2b291e21cb0287

diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c
index 9ccb2da051..480eb55047 100644
--- a/av1/encoder/mcomp.c
+++ b/av1/encoder/mcomp.c
@@ -576,60 +576,6 @@ static void init_motion_compensation_bigdia(search_site_config *cfg, int stride,
   cfg->num_search_steps = MAX_PATTERN_SCALES;
 }

-// Search site initialization for SQUARE search method.
-static void init_motion_compensation_square(search_site_config *cfg, int stride,
-                                            int level) {
-  (void)level;
-  cfg->stride = stride;
-  // All scales have 8 closest points in square shape.
-  static const int square_num_candidates[MAX_PATTERN_SCALES] = {
-    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-  };
-
-  // Square search method candidates.
-  // Note that the largest candidate step at each scale is 2^scale.
-  /* clang-format off */
-    static const FULLPEL_MV
-        square_candidates[MAX_PATTERN_SCALES][MAX_PATTERN_CANDIDATES] = {
-             { { -1, -1 }, { 0, -1 }, { 1, -1 }, { 1, 0 }, { 1, 1 }, { 0, 1 },
-               { -1, 1 }, { -1, 0 } },
-             { { -2, -2 }, { 0, -2 }, { 2, -2 }, { 2, 0 }, { 2, 2 }, { 0, 2 },
-               { -2, 2 }, { -2, 0 } },
-             { { -4, -4 }, { 0, -4 }, { 4, -4 }, { 4, 0 }, { 4, 4 }, { 0, 4 },
-               { -4, 4 }, { -4, 0 } },
-             { { -8, -8 }, { 0, -8 }, { 8, -8 }, { 8, 0 }, { 8, 8 }, { 0, 8 },
-               { -8, 8 }, { -8, 0 } },
-             { { -16, -16 }, { 0, -16 }, { 16, -16 }, { 16, 0 }, { 16, 16 },
-               { 0, 16 }, { -16, 16 }, { -16, 0 } },
-             { { -32, -32 }, { 0, -32 }, { 32, -32 }, { 32, 0 }, { 32, 32 },
-               { 0, 32 }, { -32, 32 }, { -32, 0 } },
-             { { -64, -64 }, { 0, -64 }, { 64, -64 }, { 64, 0 }, { 64, 64 },
-               { 0, 64 }, { -64, 64 }, { -64, 0 } },
-             { { -128, -128 }, { 0, -128 }, { 128, -128 }, { 128, 0 },
-               { 128, 128 }, { 0, 128 }, { -128, 128 }, { -128, 0 } },
-             { { -256, -256 }, { 0, -256 }, { 256, -256 }, { 256, 0 },
-               { 256, 256 }, { 0, 256 }, { -256, 256 }, { -256, 0 } },
-             { { -512, -512 }, { 0, -512 }, { 512, -512 }, { 512, 0 },
-               { 512, 512 }, { 0, 512 }, { -512, 512 }, { -512, 0 } },
-             { { -1024, -1024 }, { 0, -1024 }, { 1024, -1024 }, { 1024, 0 },
-               { 1024, 1024 }, { 0, 1024 }, { -1024, 1024 }, { -1024, 0 } },
-    };
-
-  /* clang-format on */
-  int radius = 1;
-  for (int i = 0; i < MAX_PATTERN_SCALES; ++i) {
-    cfg->searches_per_step[i] = square_num_candidates[i];
-    cfg->radius[i] = radius;
-    for (int j = 0; j < MAX_PATTERN_CANDIDATES; ++j) {
-      search_site *const site = &cfg->site[i][j];
-      site->mv = square_candidates[i][j];
-      site->offset = get_offset_from_fullmv(&site->mv, stride);
-    }
-    radius *= 2;
-  }
-  cfg->num_search_steps = MAX_PATTERN_SCALES;
-}
-
 // Search site initialization for HEX / FAST_HEX search methods.
 static void init_motion_compensation_hex(search_site_config *cfg, int stride,
                                          int level) {
@@ -683,8 +629,7 @@ const av1_init_search_site_config
     av1_init_motion_compensation[NUM_DISTINCT_SEARCH_METHODS] = {
       init_dsmotion_compensation,     init_motion_compensation_nstep,
       init_motion_compensation_nstep, init_dsmotion_compensation,
-      init_motion_compensation_hex,   init_motion_compensation_bigdia,
-      init_motion_compensation_square
+      init_motion_compensation_hex,   init_motion_compensation_bigdia
     };

 // Checks whether the mv is within range of the mv_limits
@@ -1317,15 +1262,6 @@ static int bigdia_search(const FULLPEL_MV start_mv,
                         cost_list, best_mv, best_mv_stats);
 }

-static int square_search(const FULLPEL_MV start_mv,
-                         const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
-                         const int search_step, const int do_init_search,
-                         int *cost_list, FULLPEL_MV *best_mv,
-                         FULLPEL_MV_STATS *best_mv_stats) {
-  return pattern_search(start_mv, ms_params, search_step, do_init_search,
-                        cost_list, best_mv, best_mv_stats);
-}
-
 static int fast_hex_search(const FULLPEL_MV start_mv,
                            const FULLPEL_MOTION_SEARCH_PARAMS *ms_params,
                            const int search_step, const int do_init_search,
@@ -1887,10 +1823,7 @@ int av1_full_pixel_search(const FULLPEL_MV start_mv,
       var = hex_search(start_mv, ms_params, step_param, 1, cost_list, best_mv,
                        best_mv_stats);
       break;
-    case SQUARE:
-      var = square_search(start_mv, ms_params, step_param, 1, cost_list,
-                          best_mv, best_mv_stats);
-      break;
+
     case BIGDIA:
       var = bigdia_search(start_mv, ms_params, step_param, 1, cost_list,
                           best_mv, best_mv_stats);
diff --git a/av1/encoder/mcomp.h b/av1/encoder/mcomp.h
index eb70c29d0e..5747de0886 100644
--- a/av1/encoder/mcomp.h
+++ b/av1/encoder/mcomp.h
@@ -172,7 +172,6 @@ static const SEARCH_METHODS search_method_lookup[NUM_SEARCH_METHODS] = {
   CLAMPED_DIAMOND,  // CLAMPED_DIAMOND
   HEX,              // HEX
   BIGDIA,           // BIGDIA
-  SQUARE,           // SQUARE
   HEX,              // FAST_HEX
   BIGDIA,           // FAST_DIAMOND
   BIGDIA,           // FAST_BIGDIA
diff --git a/av1/encoder/mcomp_structs.h b/av1/encoder/mcomp_structs.h
index 2fa28174a1..9bb03b05f0 100644
--- a/av1/encoder/mcomp_structs.h
+++ b/av1/encoder/mcomp_structs.h
@@ -72,20 +72,18 @@ enum {
   // up to 11 search stages. First stage consists of 4 search
   // points and the rest with 8 search points each.
   BIGDIA = 5,
-  // Search 8-points in the square grid around center, up to 11 search stages.
-  SQUARE = 6,
   // HEX search with up to 2 stages.
-  FAST_HEX = 7,
+  FAST_HEX = 6,
   // BIGDIA search with up to 2 stages.
-  FAST_DIAMOND = 8,
+  FAST_DIAMOND = 7,
   // BIGDIA search with up to 3 stages.
-  FAST_BIGDIA = 9,
+  FAST_BIGDIA = 8,
   // BIGDIA search with up to 1 stage.
-  VFAST_DIAMOND = 10,
+  VFAST_DIAMOND = 9,
   // Total number of search methods.
   NUM_SEARCH_METHODS,
   // Number of distinct search methods.
-  NUM_DISTINCT_SEARCH_METHODS = SQUARE + 1,
+  NUM_DISTINCT_SEARCH_METHODS = BIGDIA + 1,
 } UENUM1BYTE(SEARCH_METHODS);

 typedef struct warp_search_config {
diff --git a/av1/encoder/motion_search_facade.h b/av1/encoder/motion_search_facade.h
index 5e7f4178e8..87a18cb961 100644
--- a/av1/encoder/motion_search_facade.h
+++ b/av1/encoder/motion_search_facade.h
@@ -98,7 +98,7 @@ static inline SEARCH_METHODS av1_get_faster_search_method(
   // Note on search method's accuracy:
   //  1. NSTEP
   //  2. DIAMOND
-  //  3. BIGDIA \approx SQUARE
+  //  3. BIGDIA
   //  4. HEX.
   //  5. FAST_HEX \approx FAST_DIAMOND
   switch (search_method) {
@@ -107,7 +107,6 @@ static inline SEARCH_METHODS av1_get_faster_search_method(
     case DIAMOND: return BIGDIA;
     case CLAMPED_DIAMOND: return BIGDIA;
     case BIGDIA: return HEX;
-    case SQUARE: return HEX;
     case HEX: return FAST_HEX;
     case FAST_HEX: return FAST_HEX;
     case FAST_DIAMOND: return VFAST_DIAMOND;