Revert "Allow a large motion search range"

This reverts commit 6471e8bd7ed006bf3a84253e4057414638efd988.

Change-Id: I4278faf5816d56cf6a6c82c34dfa408e713a63e5
diff --git a/av1/encoder/firstpass.c b/av1/encoder/firstpass.c
index e3ca2cc..5eaf204 100644
--- a/av1/encoder/firstpass.c
+++ b/av1/encoder/firstpass.c
@@ -364,7 +364,7 @@
   aom_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[bsize];
   const int new_mv_mode_penalty = NEW_MV_MODE_PENALTY;
 
-  int step_param = 4;
+  int step_param = 3;
   int further_steps = (MAX_MVSEARCH_STEPS - 1) - step_param;
   const int sr = get_search_range(cpi);
   step_param += sr;
diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c
index ca77500..c3190e6 100644
--- a/av1/encoder/mcomp.c
+++ b/av1/encoder/mcomp.c
@@ -1009,7 +1009,7 @@
     }                                                                     \
   }
 
-#define MAX_PATTERN_SCALES 12
+#define MAX_PATTERN_SCALES 11
 #define MAX_PATTERN_CANDIDATES 8  // max number of canddiates per scale
 #define PATTERN_CANDIDATES_REF 3  // number of refinement candidates
 
@@ -1115,7 +1115,7 @@
     const MV candidates[MAX_PATTERN_SCALES][MAX_PATTERN_CANDIDATES]) {
   const MACROBLOCKD *const xd = &x->e_mbd;
   static const int search_param_to_steps[MAX_MVSEARCH_STEPS] = {
-    11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
+    10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
   };
   int i, s, t;
   const struct buf_2d *const what = &x->plane[0].src;
@@ -1428,9 +1428,8 @@
                    const MV *center_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, 6, 6, 6, 6, 6, 6
-  };
+  static const int hex_num_candidates[MAX_PATTERN_SCALES] = { 8, 6, 6, 6, 6, 6,
+                                                              6, 6, 6, 6, 6 };
   // Note that the largest candidate step at each scale is 2^scale
   /* clang-format off */
   static const MV hex_candidates[MAX_PATTERN_SCALES][MAX_PATTERN_CANDIDATES] = {
@@ -1452,8 +1451,6 @@
       { -512, 0 } },
     { { -512, -1024 }, { 512, -1024 }, { 1024, 0 }, { 512, 1024 },
       { -512, 1024 }, { -1024, 0 } },
-    { { -1024, -2048 }, { 1024, -2048 }, { 2048, 0 }, { 1024, 2048 },
-      { -1024, 2048 }, { -2048, 0 } },
   };
   /* clang-format on */
   return pattern_search(x, start_mv, search_param, sad_per_bit, do_init_search,
@@ -1468,7 +1465,7 @@
   // 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] = {
-    4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+    4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
   };
   // Note that the largest candidate step at each scale is 2^scale
   /* clang-format off */
@@ -1495,8 +1492,6 @@
           { 0, 512 }, { -256, 256 }, { -512, 0 } },
         { { -512, -512 }, { 0, -1024 }, { 512, -512 }, { 1024, 0 },
           { 512, 512 }, { 0, 1024 }, { -512, 512 }, { -1024, 0 } },
-        { { -1024, -1024 }, { 0, -2048 }, { 1024, -1024 }, { 2048, 0 },
-          { 1024, 1024 }, { 0, 2048 }, { -1024, 1024 }, { -2048, 0 } },
       };
   /* clang-format on */
   return pattern_search(x, start_mv, search_param, sad_per_bit, do_init_search,
@@ -1510,7 +1505,7 @@
                          const MV *center_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, 8,
+    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
   };
   // Note that the largest candidate step at each scale is 2^scale
   /* clang-format off */
@@ -1538,8 +1533,6 @@
           { 0, 512 }, { -512, 512 }, { -512, 0 } },
         { { -1024, -1024 }, { 0, -1024 }, { 1024, -1024 }, { 1024, 0 },
           { 1024, 1024 }, { 0, 1024 }, { -1024, 1024 }, { -1024, 0 } },
-        { { -2048, -2048 }, { 0, -2048 }, { 2048, -2048 }, { 2048, 0 },
-          { 2048, 2048 }, { 0, 2048 }, { -2048, 2048 }, { -2048, 0 } },
       };
   /* clang-format on */
   return pattern_search(x, start_mv, search_param, sad_per_bit, do_init_search,
diff --git a/av1/encoder/mcomp.h b/av1/encoder/mcomp.h
index c3d0cf3..42eca55 100644
--- a/av1/encoder/mcomp.h
+++ b/av1/encoder/mcomp.h
@@ -21,9 +21,9 @@
 
 // The maximum number of steps in a step search given the largest
 // allowed initial step
-#define MAX_MVSEARCH_STEPS 12
+#define MAX_MVSEARCH_STEPS 11
 // Max full pel mv specified in the unit of full pixel
-// Enable the use of motion vector in range [-2047, 2047].
+// Enable the use of motion vector in range [-1023, 1023].
 #define MAX_FULL_PEL_VAL ((1 << (MAX_MVSEARCH_STEPS - 1)) - 1)
 // Maximum size of the first step in full pel units
 #define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS - 1))
@@ -74,6 +74,13 @@
                             const aom_variance_fn_ptr_t *fn_ptr,
                             const struct mv *center_mv);
 
+// Runs sequence of diamond searches in smaller steps for RD.
+int av1_full_pixel_diamond(const struct AV1_COMP *cpi, MACROBLOCK *x,
+                           MV *mvp_full, int step_param, int sadpb,
+                           int further_steps, int do_refine, int *cost_list,
+                           const aom_variance_fn_ptr_t *fn_ptr,
+                           const MV *ref_mv, MV *dst_mv);
+
 // Perform integral projection based motion estimation.
 unsigned int av1_int_pro_motion_estimation(const struct AV1_COMP *cpi,
                                            MACROBLOCK *x, BLOCK_SIZE bsize,