Pass start_mv by value instead of by const ptr

Since FULLPEL_MV's size is only 32-bit, this should not degrade
performance. This also prevents accidental pointer aliasing when best_mv
is same as start_mv.

BUG=aomedia:2594

Change-Id: I596e9d7c710fa93ffe9f37e821b9bc49c91b38f9
diff --git a/av1/encoder/firstpass.c b/av1/encoder/firstpass.c
index d8b6a3c..3fefe2e 100644
--- a/av1/encoder/firstpass.c
+++ b/av1/encoder/firstpass.c
@@ -233,7 +233,7 @@
   int cost_list[5];
 
   tmp_err = av1_full_pixel_search(
-      cpi, x, bsize, &start_mv, step_param, NSTEP, 0, x->sadperbit16,
+      cpi, x, bsize, start_mv, step_param, NSTEP, 0, x->sadperbit16,
       cond_cost_list(cpi, cost_list), ref_mv, INT_MAX, 0,
       (MI_SIZE * xd->mi_col), (MI_SIZE * xd->mi_row), 0,
       &cpi->ss_cfg[SS_CFG_FPF], 0);
diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c
index 41e24ef..48b399f 100644
--- a/av1/encoder/mcomp.c
+++ b/av1/encoder/mcomp.c
@@ -480,7 +480,7 @@
 // candidates as indicated in the num_candidates and candidates arrays
 // passed into this function
 static int pattern_search(
-    MACROBLOCK *x, FULLPEL_MV *start_mv, int search_param, int sad_per_bit,
+    MACROBLOCK *x, FULLPEL_MV start_mv, int search_param, int sad_per_bit,
     int do_init_search, int *cost_list, const aom_variance_fn_ptr_t *vfp,
     const MV *ref_mv, const int num_candidates[MAX_PATTERN_SCALES],
     const MV candidates[MAX_PATTERN_SCALES][MAX_PATTERN_CANDIDATES]) {
@@ -501,9 +501,9 @@
   assert(search_param < MAX_MVSEARCH_STEPS);
   int best_init_s = search_param_to_steps[search_param];
   // adjust ref_mv to make sure it is within MV range
-  clamp_fullmv(start_mv, &x->mv_limits);
-  br = start_mv->row;
-  bc = start_mv->col;
+  clamp_fullmv(&start_mv, &x->mv_limits);
+  br = start_mv.row;
+  bc = start_mv.col;
   if (cost_list != NULL) {
     cost_list[0] = cost_list[1] = cost_list[2] = cost_list[3] = cost_list[4] =
         INT_MAX;
@@ -512,9 +512,9 @@
 
   // Work out the start point for the search
   raw_bestsad = vfp->sdf(what->buf, what->stride,
-                         get_buf_from_mv(in_what, start_mv), in_what->stride);
+                         get_buf_from_mv(in_what, &start_mv), in_what->stride);
   bestsad =
-      raw_bestsad + mvsad_err_cost(x, start_mv, &full_ref_mv, sad_per_bit);
+      raw_bestsad + mvsad_err_cost(x, &start_mv, &full_ref_mv, sad_per_bit);
 
   // Search all possible scales up to the search param around the center point
   // pick the scale of the point that is best as the starting scale of
@@ -754,9 +754,10 @@
 // vfp: a function pointer to the simd function so we can compute the cost
 //   efficiently
 // ref_mv: the reference mv used to compute the mv cost
-int av1_hex_search(MACROBLOCK *x, FULLPEL_MV *start_mv, int search_param,
-                   int sad_per_bit, int do_init_search, int *cost_list,
-                   const aom_variance_fn_ptr_t *vfp, const MV *ref_mv) {
+static int hex_search(MACROBLOCK *x, const FULLPEL_MV start_mv,
+                      int search_param, int sad_per_bit, int do_init_search,
+                      int *cost_list, const aom_variance_fn_ptr_t *vfp,
+                      const MV *ref_mv) {
   // First scale has 8-closest points, the rest have 6 points in hex shape
   // at increasing scales
   static const int hex_num_candidates[MAX_PATTERN_SCALES] = { 8, 6, 6, 6, 6, 6,
@@ -789,9 +790,10 @@
                         hex_candidates);
 }
 
-static int bigdia_search(MACROBLOCK *x, FULLPEL_MV *start_mv, int search_param,
-                         int sad_per_bit, int do_init_search, int *cost_list,
-                         const aom_variance_fn_ptr_t *vfp, const MV *ref_mv) {
+static int bigdia_search(MACROBLOCK *x, const FULLPEL_MV start_mv,
+                         int search_param, int sad_per_bit, int do_init_search,
+                         int *cost_list, const aom_variance_fn_ptr_t *vfp,
+                         const MV *ref_mv) {
   // First scale has 4-closest points, the rest have 8 points in diamond
   // shape at increasing scales
   static const int bigdia_num_candidates[MAX_PATTERN_SCALES] = {
@@ -829,9 +831,10 @@
                         bigdia_candidates);
 }
 
-static int square_search(MACROBLOCK *x, FULLPEL_MV *start_mv, int search_param,
-                         int sad_per_bit, int do_init_search, int *cost_list,
-                         const aom_variance_fn_ptr_t *vfp, const MV *ref_mv) {
+static int square_search(MACROBLOCK *x, const FULLPEL_MV start_mv,
+                         int search_param, int sad_per_bit, int do_init_search,
+                         int *cost_list, const aom_variance_fn_ptr_t *vfp,
+                         const MV *ref_mv) {
   // 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,
@@ -869,17 +872,16 @@
                         square_candidates);
 }
 
-static int fast_hex_search(MACROBLOCK *x, FULLPEL_MV *start_mv,
+static int fast_hex_search(MACROBLOCK *x, const FULLPEL_MV start_mv,
                            int search_param, int sad_per_bit,
                            int do_init_search,  // must be zero for fast_hex
                            int *cost_list, const aom_variance_fn_ptr_t *vfp,
                            const MV *ref_mv) {
-  return av1_hex_search(x, start_mv,
-                        AOMMAX(MAX_MVSEARCH_STEPS - 2, search_param),
-                        sad_per_bit, do_init_search, cost_list, vfp, ref_mv);
+  return hex_search(x, start_mv, AOMMAX(MAX_MVSEARCH_STEPS - 2, search_param),
+                    sad_per_bit, do_init_search, cost_list, vfp, ref_mv);
 }
 
-static int fast_dia_search(MACROBLOCK *x, FULLPEL_MV *start_mv,
+static int fast_dia_search(MACROBLOCK *x, const FULLPEL_MV start_mv,
                            int search_param, int sad_per_bit,
                            int do_init_search, int *cost_list,
                            const aom_variance_fn_ptr_t *vfp, const MV *ref_mv) {
@@ -894,11 +896,10 @@
                                   FULLPEL_MV *best_mv, int range, int step,
                                   int sad_per_bit,
                                   const aom_variance_fn_ptr_t *fn_ptr,
-                                  const FULLPEL_MV *start_mv) {
+                                  FULLPEL_MV start_mv) {
   const MACROBLOCKD *const xd = &x->e_mbd;
   const struct buf_2d *const what = &x->plane[0].src;
   const struct buf_2d *const in_what = &xd->plane[0].pre[0];
-  FULLPEL_MV start_mv_ = *start_mv;
   unsigned int best_sad = INT_MAX;
   int r, c, i;
   int start_col, end_col, start_row, end_row;
@@ -906,22 +907,21 @@
 
   assert(step >= 1);
 
-  clamp_fullmv(&start_mv_, &x->mv_limits);
-  *best_mv = start_mv_;
-  best_sad =
-      fn_ptr->sdf(what->buf, what->stride, get_buf_from_mv(in_what, &start_mv_),
-                  in_what->stride) +
-      mvsad_err_cost(x, &start_mv_, ref_mv, sad_per_bit);
-  start_row = AOMMAX(-range, x->mv_limits.row_min - start_mv_.row);
-  start_col = AOMMAX(-range, x->mv_limits.col_min - start_mv_.col);
-  end_row = AOMMIN(range, x->mv_limits.row_max - start_mv_.row);
-  end_col = AOMMIN(range, x->mv_limits.col_max - start_mv_.col);
+  clamp_fullmv(&start_mv, &x->mv_limits);
+  *best_mv = start_mv;
+  best_sad = fn_ptr->sdf(what->buf, what->stride,
+                         get_buf_from_mv(in_what, &start_mv), in_what->stride) +
+             mvsad_err_cost(x, &start_mv, ref_mv, sad_per_bit);
+  start_row = AOMMAX(-range, x->mv_limits.row_min - start_mv.row);
+  start_col = AOMMAX(-range, x->mv_limits.col_min - start_mv.col);
+  end_row = AOMMIN(range, x->mv_limits.row_max - start_mv.row);
+  end_col = AOMMIN(range, x->mv_limits.col_max - start_mv.col);
 
   for (r = start_row; r <= end_row; r += step) {
     for (c = start_col; c <= end_col; c += col_step) {
       // Step > 1 means we are not checking every location in this pass.
       if (step > 1) {
-        const FULLPEL_MV mv = { start_mv_.row + r, start_mv_.col + c };
+        const FULLPEL_MV mv = { start_mv.row + r, start_mv.col + c };
         unsigned int sad =
             fn_ptr->sdf(what->buf, what->stride, get_buf_from_mv(in_what, &mv),
                         in_what->stride);
@@ -939,15 +939,14 @@
           unsigned int sads[4];
           const uint8_t *addrs[4];
           for (i = 0; i < 4; ++i) {
-            const FULLPEL_MV mv = { start_mv_.row + r, start_mv_.col + c + i };
+            const FULLPEL_MV mv = { start_mv.row + r, start_mv.col + c + i };
             addrs[i] = get_buf_from_mv(in_what, &mv);
           }
           fn_ptr->sdx4df(what->buf, what->stride, addrs, in_what->stride, sads);
 
           for (i = 0; i < 4; ++i) {
             if (sads[i] < best_sad) {
-              const FULLPEL_MV mv = { start_mv_.row + r,
-                                      start_mv_.col + c + i };
+              const FULLPEL_MV mv = { start_mv.row + r, start_mv.col + c + i };
               const unsigned int sad =
                   sads[i] + mvsad_err_cost(x, &mv, ref_mv, sad_per_bit);
               if (sad < best_sad) {
@@ -959,7 +958,7 @@
           }
         } else {
           for (i = 0; i < end_col - c; ++i) {
-            const FULLPEL_MV mv = { start_mv_.row + r, start_mv_.col + c + i };
+            const FULLPEL_MV mv = { start_mv.row + r, start_mv.col + c + i };
             unsigned int sad =
                 fn_ptr->sdf(what->buf, what->stride,
                             get_buf_from_mv(in_what, &mv), in_what->stride);
@@ -980,12 +979,12 @@
   return best_sad;
 }
 
-int av1_diamond_search_sad_c(MACROBLOCK *x, const search_site_config *cfg,
-                             FULLPEL_MV *start_mv, FULLPEL_MV *best_mv,
-                             int search_param, int sad_per_bit, int *num00,
-                             const aom_variance_fn_ptr_t *fn_ptr,
-                             const MV *ref_mv, uint8_t *second_pred,
-                             uint8_t *mask, int mask_stride, int inv_mask) {
+static int diamond_search_sad(MACROBLOCK *x, const search_site_config *cfg,
+                              FULLPEL_MV start_mv, FULLPEL_MV *best_mv,
+                              int search_param, int sad_per_bit, int *num00,
+                              const aom_variance_fn_ptr_t *fn_ptr,
+                              const MV *ref_mv, uint8_t *second_pred,
+                              uint8_t *mask, int mask_stride, int inv_mask) {
   const MACROBLOCKD *const xd = &x->e_mbd;
   uint8_t *what = x->plane[0].src.buf;
   const int what_stride = x->plane[0].src.stride;
@@ -997,18 +996,18 @@
   int best_site = 0;
   int is_off_center = 0;
 
+  clamp_fullmv(&start_mv, &x->mv_limits);
+
   // search_param determines the length of the initial step and hence the number
   // of iterations.
   const int tot_steps = cfg->ss_count - search_param;
 
   const FULLPEL_MV full_ref_mv = get_fullmv_from_mv(ref_mv);
-  clamp_fullmv(start_mv, &x->mv_limits);
   *num00 = 0;
-  best_mv->row = start_mv->row;
-  best_mv->col = start_mv->col;
+  *best_mv = start_mv;
 
   // Work out the start point for the search
-  in_what = get_buf_from_mv(&xd->plane[0].pre[0], start_mv);
+  in_what = get_buf_from_mv(&xd->plane[0].pre[0], &start_mv);
   best_address = in_what;
 
   // Check the starting position
@@ -1118,7 +1117,7 @@
 /* do_refine: If last step (1-away) of n-step search doesn't pick the center
               point as the best match, we will do a final 1-away diamond
               refining search  */
-static int full_pixel_diamond(MACROBLOCK *x, FULLPEL_MV *start_mv,
+static int full_pixel_diamond(MACROBLOCK *x, const FULLPEL_MV start_mv,
                               int step_param, int sadpb, int *cost_list,
                               const aom_variance_fn_ptr_t *fn_ptr,
                               const MV *ref_mv, const search_site_config *cfg,
@@ -1126,9 +1125,9 @@
                               int mask_stride, int inv_mask) {
   FULLPEL_MV best_mv;
   int thissme, n, num00 = 0;
-  int bestsme = av1_diamond_search_sad_c(x, cfg, start_mv, &best_mv, step_param,
-                                         sadpb, &n, fn_ptr, ref_mv, second_pred,
-                                         mask, mask_stride, inv_mask);
+  int bestsme = diamond_search_sad(x, cfg, start_mv, &best_mv, step_param,
+                                   sadpb, &n, fn_ptr, ref_mv, second_pred, mask,
+                                   mask_stride, inv_mask);
 
   if (bestsme < INT_MAX) {
     if (mask)
@@ -1154,9 +1153,9 @@
     if (num00) {
       num00--;
     } else {
-      thissme = av1_diamond_search_sad_c(
-          x, cfg, start_mv, &best_mv, step_param + n, sadpb, &num00, fn_ptr,
-          ref_mv, second_pred, mask, mask_stride, inv_mask);
+      thissme = diamond_search_sad(x, cfg, start_mv, &best_mv, step_param + n,
+                                   sadpb, &num00, fn_ptr, ref_mv, second_pred,
+                                   mask, mask_stride, inv_mask);
 
       if (thissme < INT_MAX) {
         if (mask)
@@ -1197,7 +1196,7 @@
 // Runs an limited range exhaustive mesh search using a pattern set
 // according to the encode speed profile.
 static int full_pixel_exhaustive(
-    MACROBLOCK *x, const FULLPEL_MV *start_mv, int sadpb, int *cost_list,
+    MACROBLOCK *x, const FULLPEL_MV start_mv, int sadpb, int *cost_list,
     const aom_variance_fn_ptr_t *fn_ptr, const MV *ref_mv, FULLPEL_MV *best_mv,
     const struct MESH_PATTERN *const mesh_patterns) {
   FULLPEL_MV full_ref_mv = get_fullmv_from_mv(ref_mv);
@@ -1207,7 +1206,7 @@
   int range = mesh_patterns[0].range;
   int baseline_interval_divisor;
 
-  *best_mv = *start_mv;
+  *best_mv = start_mv;
 
   // Trap illegal values for interval and range for this function.
   if ((range < MIN_RANGE) || (range > MAX_RANGE) || (interval < MIN_INTERVAL) ||
@@ -1224,7 +1223,7 @@
 
   // initial search
   bestsme = exhuastive_mesh_search(x, &full_ref_mv, best_mv, range, interval,
-                                   sadpb, fn_ptr, best_mv);
+                                   sadpb, fn_ptr, *best_mv);
 
   if ((interval > MIN_INTERVAL) && (range > MIN_RANGE)) {
     // Progressive searches with range and step size decreasing each time
@@ -1233,7 +1232,7 @@
       // First pass with coarser step and longer range
       bestsme = exhuastive_mesh_search(
           x, &full_ref_mv, best_mv, mesh_patterns[i].range,
-          mesh_patterns[i].interval, sadpb, fn_ptr, best_mv);
+          mesh_patterns[i].interval, sadpb, fn_ptr, *best_mv);
 
       if (mesh_patterns[i].interval == 1) break;
     }
@@ -1345,7 +1344,7 @@
 }
 
 int av1_full_pixel_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
-                          FULLPEL_MV *start_mv, int step_param, int method,
+                          const FULLPEL_MV start_mv, int step_param, int method,
                           int run_mesh_search, int error_per_bit,
                           int *cost_list, const MV *ref_mv, int var_max, int rd,
                           int x_pos, int y_pos, int intra,
@@ -1373,8 +1372,8 @@
                             cost_list, fn_ptr, ref_mv);
       break;
     case HEX:
-      var = av1_hex_search(x, start_mv, step_param, error_per_bit, 1, cost_list,
-                           fn_ptr, ref_mv);
+      var = hex_search(x, start_mv, step_param, error_per_bit, 1, cost_list,
+                       fn_ptr, ref_mv);
       break;
     case SQUARE:
       var = square_search(x, start_mv, step_param, error_per_bit, 1, cost_list,
@@ -1406,8 +1405,8 @@
   // filtering. Can extend it to intrabc.
   if (!use_intrabc_mesh_pattern && sf->mv_sf.prune_mesh_search) {
     const int full_pel_mv_diff =
-        AOMMAX(abs(start_mv->row - x->best_mv.as_fullmv.row),
-               abs(start_mv->col - x->best_mv.as_fullmv.col));
+        AOMMAX(abs(start_mv.row - x->best_mv.as_fullmv.row),
+               abs(start_mv.col - x->best_mv.as_fullmv.col));
     if (full_pel_mv_diff <= 4) {
       run_mesh_search = 0;
     }
@@ -1421,9 +1420,9 @@
     const MESH_PATTERN *const mesh_patterns =
         use_intrabc_mesh_pattern ? sf->mv_sf.intrabc_mesh_patterns
                                  : sf->mv_sf.mesh_patterns;
-    var_ex = full_pixel_exhaustive(x, &x->best_mv.as_fullmv, error_per_bit,
-                                   cost_list, fn_ptr, ref_mv, &tmp_mv_ex,
-                                   mesh_patterns);
+    var_ex =
+        full_pixel_exhaustive(x, x->best_mv.as_fullmv, error_per_bit, cost_list,
+                              fn_ptr, ref_mv, &tmp_mv_ex, mesh_patterns);
     if (var_ex < var) {
       var = var_ex;
       x->best_mv.as_fullmv = tmp_mv_ex;
@@ -1522,7 +1521,7 @@
 }
 
 static int obmc_refining_search_sad(const MACROBLOCK *x, const int32_t *wsrc,
-                                    const int32_t *mask, FULLPEL_MV *start_mv,
+                                    const int32_t *mask, FULLPEL_MV *best_mv,
                                     int error_per_bit, int search_range,
                                     const aom_variance_fn_ptr_t *fn_ptr,
                                     const MV *ref_mv) {
@@ -1531,17 +1530,17 @@
   const struct buf_2d *const in_what = xd->plane[0].pre;
   const FULLPEL_MV full_ref_mv = get_fullmv_from_mv(ref_mv);
   unsigned int best_sad =
-      fn_ptr->osdf(get_buf_from_mv(in_what, start_mv), in_what->stride, wsrc,
+      fn_ptr->osdf(get_buf_from_mv(in_what, best_mv), in_what->stride, wsrc,
                    mask) +
-      mvsad_err_cost(x, start_mv, &full_ref_mv, error_per_bit);
+      mvsad_err_cost(x, best_mv, &full_ref_mv, error_per_bit);
   int i, j;
 
   for (i = 0; i < search_range; i++) {
     int best_site = -1;
 
     for (j = 0; j < 4; j++) {
-      const FULLPEL_MV mv = { start_mv->row + neighbors[j].row,
-                              start_mv->col + neighbors[j].col };
+      const FULLPEL_MV mv = { best_mv->row + neighbors[j].row,
+                              best_mv->col + neighbors[j].col };
       if (av1_is_fullmv_in_range(&x->mv_limits, mv)) {
         unsigned int sad = fn_ptr->osdf(get_buf_from_mv(in_what, &mv),
                                         in_what->stride, wsrc, mask);
@@ -1558,8 +1557,8 @@
     if (best_site == -1) {
       break;
     } else {
-      start_mv->row += neighbors[best_site].row;
-      start_mv->col += neighbors[best_site].col;
+      best_mv->row += neighbors[best_site].row;
+      best_mv->col += neighbors[best_site].col;
     }
   }
   return best_sad;
@@ -1567,7 +1566,7 @@
 
 static int obmc_diamond_search_sad(
     const MACROBLOCK *x, const search_site_config *cfg, const int32_t *wsrc,
-    const int32_t *mask, FULLPEL_MV *start_mv, FULLPEL_MV *best_mv,
+    const int32_t *mask, FULLPEL_MV start_mv, FULLPEL_MV *best_mv,
     int search_param, int sad_per_bit, int *num00,
     const aom_variance_fn_ptr_t *fn_ptr, const MV *ref_mv) {
   const MACROBLOCKD *const xd = &x->e_mbd;
@@ -1584,11 +1583,11 @@
   int best_site = 0;
   int step;
 
-  clamp_fullmv(start_mv, &x->mv_limits);
-  in_what_ref = get_buf_from_mv(in_what, start_mv);
+  clamp_fullmv(&start_mv, &x->mv_limits);
+  in_what_ref = get_buf_from_mv(in_what, &start_mv);
   best_address = in_what_ref;
   *num00 = 0;
-  *best_mv = *start_mv;
+  *best_mv = start_mv;
 
   // Check the starting position
   best_sad = fn_ptr->osdf(best_address, in_what->stride, wsrc, mask) +
@@ -1625,7 +1624,7 @@
 }
 
 static int obmc_full_pixel_diamond(const AV1_COMP *cpi, MACROBLOCK *x,
-                                   FULLPEL_MV *start_mv, int step_param,
+                                   const FULLPEL_MV start_mv, int step_param,
                                    int sadpb, int further_steps, int do_refine,
                                    const aom_variance_fn_ptr_t *fn_ptr,
                                    const MV *ref_mv, FULLPEL_MV *best_mv,
@@ -1684,8 +1683,8 @@
 }
 
 int av1_obmc_full_pixel_search(const AV1_COMP *cpi, MACROBLOCK *x,
-                               FULLPEL_MV *start_mv, int step_param, int sadpb,
-                               int further_steps, int do_refine,
+                               const FULLPEL_MV start_mv, int step_param,
+                               int sadpb, int further_steps, int do_refine,
                                const aom_variance_fn_ptr_t *fn_ptr,
                                const MV *ref_mv, FULLPEL_MV *best_mv,
                                const search_site_config *cfg) {
@@ -1698,7 +1697,7 @@
     const int32_t *wsrc = x->wsrc_buf;
     const int32_t *mask = x->mask_buf;
     const int search_range = 8;
-    *best_mv = *start_mv;
+    *best_mv = start_mv;
     clamp_fullmv(best_mv, &x->mv_limits);
     int thissme = obmc_refining_search_sad(x, wsrc, mask, best_mv, sadpb,
                                            search_range, fn_ptr, ref_mv);
diff --git a/av1/encoder/mcomp.h b/av1/encoder/mcomp.h
index efca00d..acf984f 100644
--- a/av1/encoder/mcomp.h
+++ b/av1/encoder/mcomp.h
@@ -124,10 +124,6 @@
                                            MACROBLOCK *x, BLOCK_SIZE bsize,
                                            int mi_row, int mi_col,
                                            const MV *ref_mv);
-// Runs sequence of diamond searches in smaller steps for RD.
-int av1_hex_search(MACROBLOCK *x, FULLPEL_MV *start_mv, int search_param,
-                   int sad_per_bit, int do_init_search, int *cost_list,
-                   const aom_variance_fn_ptr_t *vfp, const MV *ref_mv);
 
 int av1_refining_search_8p_c(MACROBLOCK *x, int error_per_bit, int search_range,
                              const aom_variance_fn_ptr_t *fn_ptr,
@@ -137,15 +133,8 @@
                              const struct buf_2d *src,
                              const struct buf_2d *pre);
 
-int av1_diamond_search_sad_c(MACROBLOCK *x, const search_site_config *cfg,
-                             FULLPEL_MV *start_mv, FULLPEL_MV *best_mv,
-                             int search_param, int sad_per_bit, int *num00,
-                             const aom_variance_fn_ptr_t *fn_ptr,
-                             const MV *ref_mv, uint8_t *second_pred,
-                             uint8_t *mask, int mask_stride, int inv_mask);
-
 int av1_full_pixel_search(const struct AV1_COMP *cpi, MACROBLOCK *x,
-                          BLOCK_SIZE bsize, FULLPEL_MV *start_mv,
+                          BLOCK_SIZE bsize, const FULLPEL_MV start_mv,
                           int step_param, int method, int run_mesh_search,
                           int error_per_bit, int *cost_list, const MV *ref_mv,
                           int var_max, int rd, int x_pos, int y_pos, int intra,
@@ -153,8 +142,8 @@
                           int use_intrabc_mesh_pattern);
 
 int av1_obmc_full_pixel_search(const struct AV1_COMP *cpi, MACROBLOCK *x,
-                               FULLPEL_MV *start_mv, int step_param, int sadpb,
-                               int further_steps, int do_refine,
+                               const FULLPEL_MV start_mv, int step_param,
+                               int sadpb, int further_steps, int do_refine,
                                const aom_variance_fn_ptr_t *fn_ptr,
                                const MV *ref_mv, FULLPEL_MV *dst_mv,
                                const search_site_config *cfg);
diff --git a/av1/encoder/motion_search_facade.c b/av1/encoder/motion_search_facade.c
index ba4ce6f..9fd1c60 100644
--- a/av1/encoder/motion_search_facade.c
+++ b/av1/encoder/motion_search_facade.c
@@ -129,14 +129,14 @@
   switch (mbmi->motion_mode) {
     case SIMPLE_TRANSLATION:
       bestsme = av1_full_pixel_search(
-          cpi, x, bsize, &start_mv, step_param, cpi->sf.mv_sf.search_method, 0,
+          cpi, x, bsize, start_mv, step_param, cpi->sf.mv_sf.search_method, 0,
           sadpb, cond_cost_list(cpi, cost_list), &ref_mv, INT_MAX, 1,
           (MI_SIZE * mi_col), (MI_SIZE * mi_row), 0, &cpi->ss_cfg[SS_CFG_SRC],
           0);
       break;
     case OBMC_CAUSAL:
       bestsme = av1_obmc_full_pixel_search(
-          cpi, x, &start_mv, step_param, sadpb,
+          cpi, x, start_mv, step_param, sadpb,
           MAX_MVSEARCH_STEPS - 1 - step_param, 1, &cpi->fn_ptr[bsize], &ref_mv,
           &(x->best_mv.as_fullmv), &cpi->ss_cfg[SS_CFG_SRC]);
       break;
@@ -667,7 +667,7 @@
   // This overwrites the mv_limits so we will need to restore it later.
   av1_set_mv_search_range(&x->mv_limits, &ref_mv);
   var = av1_full_pixel_search(
-      cpi, x, bsize, &start_mv, step_param, search_methods, do_mesh_search,
+      cpi, x, bsize, start_mv, step_param, search_methods, do_mesh_search,
       sadpb, cond_cost_list(cpi, cost_list), &ref_mv, INT_MAX, 1,
       mi_col * MI_SIZE, mi_row * MI_SIZE, 0, &cpi->ss_cfg[SS_CFG_SRC], 0);
   // Restore
diff --git a/av1/encoder/nonrd_pickmode.c b/av1/encoder/nonrd_pickmode.c
index 01afe0a..aa43320 100644
--- a/av1/encoder/nonrd_pickmode.c
+++ b/av1/encoder/nonrd_pickmode.c
@@ -153,7 +153,7 @@
     center_mv = tmp_mv->as_mv;
 
   av1_full_pixel_search(
-      cpi, x, bsize, &start_mv, step_param, cpi->sf.mv_sf.search_method, 0,
+      cpi, x, bsize, start_mv, step_param, cpi->sf.mv_sf.search_method, 0,
       sadpb, cond_cost_list(cpi, cost_list), &center_mv, INT_MAX, 0,
       (MI_SIZE * mi_col), (MI_SIZE * mi_row), 0, &cpi->ss_cfg[SS_CFG_SRC], 0);
 
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index b23d27a3..9967ba6 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -2556,7 +2556,7 @@
     const int sadpb = x->sadperbit16;
     int cost_list[5];
     const int bestsme = av1_full_pixel_search(
-        cpi, x, bsize, &start_mv, step_param, cpi->sf.mv_sf.search_method, 0,
+        cpi, x, bsize, start_mv, step_param, cpi->sf.mv_sf.search_method, 0,
         sadpb, cond_cost_list(cpi, cost_list), &dv_ref.as_mv, INT_MAX, 1,
         (MI_SIZE * mi_col), (MI_SIZE * mi_row), 1,
         &cpi->ss_cfg[SS_CFG_LOOKAHEAD], 1);
diff --git a/av1/encoder/temporal_filter.c b/av1/encoder/temporal_filter.c
index 212f830..4995cb8 100644
--- a/av1/encoder/temporal_filter.c
+++ b/av1/encoder/temporal_filter.c
@@ -124,7 +124,7 @@
   // searched result will be stored in `mb->best_mv`.
   int block_error = INT_MAX;
   mb->mv_cost_type = mv_cost_type;
-  av1_full_pixel_search(cpi, mb, block_size, &start_mv, step_param,
+  av1_full_pixel_search(cpi, mb, block_size, start_mv, step_param,
                         full_search_method, 1, sadperbit16,
                         cond_cost_list(cpi, cost_list), &baseline_mv, 0, 0,
                         mb_x, mb_y, 0, &ss_cfg, 0);
@@ -166,7 +166,7 @@
         mbd->plane[0].pre[0].buf = ref_frame->y_buffer + y_offset + offset;
         av1_set_mv_search_range(&mb->mv_limits, &baseline_mv);
         mb->mv_cost_type = mv_cost_type;
-        av1_full_pixel_search(cpi, mb, subblock_size, &start_mv, step_param,
+        av1_full_pixel_search(cpi, mb, subblock_size, start_mv, step_param,
                               full_search_method, 1, sadperbit16,
                               cond_cost_list(cpi, cost_list), &baseline_mv, 0,
                               0, mb_x, mb_y, 0, &ss_cfg, 0);
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index e5096f0..352d380 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -153,7 +153,7 @@
 
   assert(ss_cfg->stride == stride_ref);
 
-  av1_full_pixel_search(cpi, x, bsize, &start_mv, step_param, search_method, 0,
+  av1_full_pixel_search(cpi, x, bsize, start_mv, step_param, search_method, 0,
                         sadpb, cond_cost_list(cpi, cost_list), &center_mv,
                         INT_MAX, 0, (MI_SIZE * mi_col), (MI_SIZE * mi_row), 0,
                         ss_cfg, 0);