shithub: libvpx

Download patch

ref: 3117830af31452ab85590770f2b75cc48a60041a
parent: 9ffbc31367668034538c1af707f430e463f022a1
parent: d78dbff09a1b3166fdd5be07b5227179e6e2dfcb
author: Deb Mukherjee <[email protected]>
date: Thu Oct 9 07:14:51 EDT 2014

Merge "Subpel search cleanups and enhancements"

--- a/vp9/encoder/vp9_encoder.h
+++ b/vp9/encoder/vp9_encoder.h
@@ -529,8 +529,8 @@
   return frame_index & 0x1;
 }
 
-static INLINE int *cond_sad_list(const struct VP9_COMP *cpi, int *sad_list) {
-  return cpi->sf.mv.subpel_search_method != SUBPEL_TREE ? sad_list : NULL;
+static INLINE int *cond_cost_list(const struct VP9_COMP *cpi, int *cost_list) {
+  return cpi->sf.mv.subpel_search_method != SUBPEL_TREE ? cost_list : NULL;
 }
 
 #ifdef __cplusplus
--- a/vp9/encoder/vp9_mbgraph.c
+++ b/vp9/encoder/vp9_mbgraph.c
@@ -34,7 +34,7 @@
   const int tmp_row_min = x->mv_row_min;
   const int tmp_row_max = x->mv_row_max;
   MV ref_full;
-  int sad_list[5];
+  int cost_list[5];
 
   // Further step/diamond searches as necessary
   int step_param = mv_sf->reduce_first_step_size;
@@ -47,7 +47,7 @@
 
   /*cpi->sf.search_method == HEX*/
   vp9_hex_search(x, &ref_full, step_param, x->errorperbit, 0,
-                 cond_sad_list(cpi, sad_list),
+                 cond_cost_list(cpi, cost_list),
                  &v_fn_ptr, 0, ref_mv, dst_mv);
 
   // Try sub-pixel MC
@@ -58,7 +58,7 @@
     cpi->find_fractional_mv_step(
         x, dst_mv, ref_mv, cpi->common.allow_high_precision_mv, x->errorperbit,
         &v_fn_ptr, 0, mv_sf->subpel_iters_per_step,
-        cond_sad_list(cpi, sad_list),
+        cond_cost_list(cpi, cost_list),
         NULL, NULL,
         &distortion, &sse, NULL, 0, 0);
   }
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -327,11 +327,11 @@
   return ((n < 0) ^ (d < 0)) ? ((n - d / 2) / d) : ((n + d / 2) / d);
 }
 
-static INLINE int is_sad_list_wellbehaved(int *sad_list) {
-  return sad_list[0] >= sad_list[1] &&
-         sad_list[0] >= sad_list[2] &&
-         sad_list[0] >= sad_list[3] &&
-         sad_list[0] >= sad_list[4];
+static INLINE int is_cost_list_wellbehaved(int *cost_list) {
+  return cost_list[0] < cost_list[1] &&
+         cost_list[0] < cost_list[2] &&
+         cost_list[0] < cost_list[3] &&
+         cost_list[0] < cost_list[4];
 }
 
 // Returns surface minima estimate at given precision in 1/2^n bits.
@@ -342,27 +342,28 @@
 // x0 = 1/2 (S1 - S3)/(S1 + S3 - 2*S0),
 // y0 = 1/2 (S4 - S2)/(S4 + S2 - 2*S0).
 // The code below is an integerized version of that.
-static void get_cost_surf_min(int *sad_list, int *ir, int *ic,
+static void get_cost_surf_min(int *cost_list, int *ir, int *ic,
                               int bits) {
-  *ic = divide_and_round((sad_list[1] - sad_list[3]) * (1 << (bits - 1)),
-                         (sad_list[1] - 2 * sad_list[0] + sad_list[3]));
-  *ir = divide_and_round((sad_list[4] - sad_list[2]) * (1 << (bits - 1)),
-                         (sad_list[4] - 2 * sad_list[0] + sad_list[2]));
+  *ic = divide_and_round((cost_list[1] - cost_list[3]) * (1 << (bits - 1)),
+                         (cost_list[1] - 2 * cost_list[0] + cost_list[3]));
+  *ir = divide_and_round((cost_list[4] - cost_list[2]) * (1 << (bits - 1)),
+                         (cost_list[4] - 2 * cost_list[0] + cost_list[2]));
 }
 
-int vp9_find_best_sub_pixel_surface_fit(const MACROBLOCK *x,
-                                        MV *bestmv, const MV *ref_mv,
-                                        int allow_hp,
-                                        int error_per_bit,
-                                        const vp9_variance_fn_ptr_t *vfp,
-                                        int forced_stop,
-                                        int iters_per_step,
-                                        int *sad_list,
-                                        int *mvjcost, int *mvcost[2],
-                                        int *distortion,
-                                        unsigned int *sse1,
-                                        const uint8_t *second_pred,
-                                        int w, int h) {
+int vp9_find_best_sub_pixel_tree_pruned_evenmore(
+    const MACROBLOCK *x,
+    MV *bestmv, const MV *ref_mv,
+    int allow_hp,
+    int error_per_bit,
+    const vp9_variance_fn_ptr_t *vfp,
+    int forced_stop,
+    int iters_per_step,
+    int *cost_list,
+    int *mvjcost, int *mvcost[2],
+    int *distortion,
+    unsigned int *sse1,
+    const uint8_t *second_pred,
+    int w, int h) {
   SETUP_SUBPEL_SEARCH;
   SETUP_CENTER_ERROR;
   (void) halfiters;
@@ -373,19 +374,49 @@
   (void) forced_stop;
   (void) hstep;
 
-  if (sad_list &&
-      sad_list[0] != INT_MAX && sad_list[1] != INT_MAX &&
-      sad_list[2] != INT_MAX && sad_list[3] != INT_MAX &&
-      sad_list[4] != INT_MAX &&
-      is_sad_list_wellbehaved(sad_list)) {
+  if (cost_list &&
+      cost_list[0] != INT_MAX && cost_list[1] != INT_MAX &&
+      cost_list[2] != INT_MAX && cost_list[3] != INT_MAX &&
+      cost_list[4] != INT_MAX &&
+      is_cost_list_wellbehaved(cost_list)) {
     int ir, ic;
     unsigned int minpt;
-    get_cost_surf_min(sad_list, &ir, &ic, 3);
+    get_cost_surf_min(cost_list, &ir, &ic, 2);
     if (ir != 0 || ic != 0) {
-      CHECK_BETTER(minpt, tr + ir, tc + ic);
+      CHECK_BETTER(minpt, tr + 2 * ir, tc + 2 * ic);
     }
+  } else {
+    FIRST_LEVEL_CHECKS;
+    if (halfiters > 1) {
+      SECOND_LEVEL_CHECKS;
+    }
+
+    tr = br;
+    tc = bc;
+
+    // Each subsequent iteration checks at least one point in common with
+    // the last iteration could be 2 ( if diag selected) 1/4 pel
+    // Note forced_stop: 0 - full, 1 - qtr only, 2 - half only
+    if (forced_stop != 2) {
+      hstep >>= 1;
+      FIRST_LEVEL_CHECKS;
+      if (quarteriters > 1) {
+        SECOND_LEVEL_CHECKS;
+      }
+    }
   }
 
+  tr = br;
+  tc = bc;
+
+  if (allow_hp && vp9_use_mv_hp(ref_mv) && forced_stop == 0) {
+    hstep >>= 1;
+    FIRST_LEVEL_CHECKS;
+    if (eighthiters > 1) {
+      SECOND_LEVEL_CHECKS;
+    }
+  }
+
   bestmv->row = br;
   bestmv->col = bc;
 
@@ -403,7 +434,7 @@
                                              const vp9_variance_fn_ptr_t *vfp,
                                              int forced_stop,
                                              int iters_per_step,
-                                             int *sad_list,
+                                             int *cost_list,
                                              int *mvjcost, int *mvcost[2],
                                              int *distortion,
                                              unsigned int *sse1,
@@ -411,14 +442,14 @@
                                              int w, int h) {
   SETUP_SUBPEL_SEARCH;
   SETUP_CENTER_ERROR;
-  if (sad_list &&
-      sad_list[0] != INT_MAX && sad_list[1] != INT_MAX &&
-      sad_list[2] != INT_MAX && sad_list[3] != INT_MAX &&
-      sad_list[4] != INT_MAX &&
-      is_sad_list_wellbehaved(sad_list)) {
+  if (cost_list &&
+      cost_list[0] != INT_MAX && cost_list[1] != INT_MAX &&
+      cost_list[2] != INT_MAX && cost_list[3] != INT_MAX &&
+      cost_list[4] != INT_MAX &&
+      is_cost_list_wellbehaved(cost_list)) {
     unsigned int minpt;
     int ir, ic;
-    get_cost_surf_min(sad_list, &ir, &ic, 1);
+    get_cost_surf_min(cost_list, &ir, &ic, 1);
     if (ir != 0 || ic != 0) {
       CHECK_BETTER(minpt, tr + ir * hstep, tc + ic * hstep);
     }
@@ -429,31 +460,28 @@
     }
   }
 
-  tr = br;
-  tc = bc;
-
   // Each subsequent iteration checks at least one point in common with
   // the last iteration could be 2 ( if diag selected) 1/4 pel
 
   // Note forced_stop: 0 - full, 1 - qtr only, 2 - half only
   if (forced_stop != 2) {
+    tr = br;
+    tc = bc;
     hstep >>= 1;
     FIRST_LEVEL_CHECKS;
     if (quarteriters > 1) {
       SECOND_LEVEL_CHECKS;
     }
-    tr = br;
-    tc = bc;
   }
 
   if (allow_hp && vp9_use_mv_hp(ref_mv) && forced_stop == 0) {
+    tr = br;
+    tc = bc;
     hstep >>= 1;
     FIRST_LEVEL_CHECKS;
     if (eighthiters > 1) {
       SECOND_LEVEL_CHECKS;
     }
-    tr = br;
-    tc = bc;
   }
   // These lines insure static analysis doesn't warn that
   // tr and tc aren't used after the above point.
@@ -477,7 +505,7 @@
                                         const vp9_variance_fn_ptr_t *vfp,
                                         int forced_stop,
                                         int iters_per_step,
-                                        int *sad_list,
+                                        int *cost_list,
                                         int *mvjcost, int *mvcost[2],
                                         int *distortion,
                                         unsigned int *sse1,
@@ -485,13 +513,13 @@
                                         int w, int h) {
   SETUP_SUBPEL_SEARCH;
   SETUP_CENTER_ERROR;
-  if (sad_list &&
-      sad_list[0] != INT_MAX && sad_list[1] != INT_MAX &&
-      sad_list[2] != INT_MAX && sad_list[3] != INT_MAX &&
-      sad_list[4] != INT_MAX) {
+  if (cost_list &&
+      cost_list[0] != INT_MAX && cost_list[1] != INT_MAX &&
+      cost_list[2] != INT_MAX && cost_list[3] != INT_MAX &&
+      cost_list[4] != INT_MAX) {
     unsigned int left, right, up, down, diag;
-    whichdir = (sad_list[1] < sad_list[3] ? 0 : 1) +
-               (sad_list[2] < sad_list[4] ? 0 : 2);
+    whichdir = (cost_list[1] < cost_list[3] ? 0 : 1) +
+               (cost_list[2] < cost_list[4] ? 0 : 2);
     switch (whichdir) {
       case 0:
         CHECK_BETTER(left, tr, tc - hstep);
@@ -569,7 +597,7 @@
                                  const vp9_variance_fn_ptr_t *vfp,
                                  int forced_stop,
                                  int iters_per_step,
-                                 int *sad_list,
+                                 int *cost_list,
                                  int *mvjcost, int *mvcost[2],
                                  int *distortion,
                                  unsigned int *sse1,
@@ -577,7 +605,7 @@
                                  int w, int h) {
   SETUP_SUBPEL_SEARCH;
   SETUP_CENTER_ERROR;
-  (void) sad_list;  // to silence compiler warning
+  (void) cost_list;  // to silence compiler warning
 
   // Each subsequent iteration checks at least one point in
   // common with the last iteration could be 2 ( if diag selected)
@@ -661,12 +689,12 @@
 #define PATTERN_CANDIDATES_REF      3  // number of refinement candidates
 
 // Calculate and return a sad+mvcost list around an integer best pel.
-static INLINE void calc_int_sad_cost_list(MACROBLOCK *x,
-                                          const MV *ref_mv,
-                                          int sadpb,
-                                          const vp9_variance_fn_ptr_t *fn_ptr,
-                                          const MV *best_mv,
-                                          int *cost_list) {
+static INLINE void calc_int_cost_list(const MACROBLOCK *x,
+                                      const MV *ref_mv,
+                                      int sadpb,
+                                      const vp9_variance_fn_ptr_t *fn_ptr,
+                                      const MV *best_mv,
+                                      int *cost_list) {
   static const MV neighbors[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}};
   const struct buf_2d *const what = &x->plane[0].src;
   const struct buf_2d *const in_what = &x->e_mbd.plane[0].pre[0];
@@ -675,21 +703,24 @@
   int bc = best_mv->col;
   MV this_mv;
   int i;
+  unsigned int sse;
 
   this_mv.row = br;
   this_mv.col = bc;
-  cost_list[0] = fn_ptr->sdf(what->buf, what->stride,
-                             get_buf_from_mv(in_what, &this_mv),
-                             in_what->stride) +
+  cost_list[0] = fn_ptr->vf(what->buf, what->stride,
+                            get_buf_from_mv(in_what, &this_mv),
+                            in_what->stride, &sse) +
       mvsad_err_cost(x, &this_mv, &fcenter_mv, sadpb);
   if (check_bounds(x, br, bc, 1)) {
     for (i = 0; i < 4; i++) {
       const MV this_mv = {br + neighbors[i].row,
         bc + neighbors[i].col};
-      cost_list[i + 1] = fn_ptr->sdf(what->buf, what->stride,
-                                     get_buf_from_mv(in_what, &this_mv),
-                                     in_what->stride) +
-          mvsad_err_cost(x, &this_mv, &fcenter_mv, sadpb);
+      cost_list[i + 1] = fn_ptr->vf(what->buf, what->stride,
+                                    get_buf_from_mv(in_what, &this_mv),
+                                    in_what->stride, &sse) +
+          // mvsad_err_cost(x, &this_mv, &fcenter_mv, sadpb);
+          mv_err_cost(&this_mv, &fcenter_mv, x->nmvjointcost, x->mvcost,
+                      x->errorperbit);
     }
   } else {
     for (i = 0; i < 4; i++) {
@@ -698,10 +729,12 @@
       if (!is_mv_in(x, &this_mv))
         cost_list[i + 1] = INT_MAX;
       else
-        cost_list[i + 1] = fn_ptr->sdf(what->buf, what->stride,
-                                       get_buf_from_mv(in_what, &this_mv),
-                                       in_what->stride) +
-            mvsad_err_cost(x, &this_mv, &fcenter_mv, sadpb);
+        cost_list[i + 1] = fn_ptr->vf(what->buf, what->stride,
+                                      get_buf_from_mv(in_what, &this_mv),
+                                      in_what->stride, &sse) +
+            // mvsad_err_cost(x, &this_mv, &fcenter_mv, sadpb);
+            mv_err_cost(&this_mv, &fcenter_mv, x->nmvjointcost, x->mvcost,
+                        x->errorperbit);
     }
   }
 }
@@ -716,7 +749,7 @@
                               int search_param,
                               int sad_per_bit,
                               int do_init_search,
-                              int *sad_list,
+                              int *cost_list,
                               const vp9_variance_fn_ptr_t *vfp,
                               int use_mvcost,
                               const MV *center_mv,
@@ -868,40 +901,14 @@
   }
 
   // Returns the one-away integer pel sad values around the best as follows:
-  // sad_list[0]: sad at the best integer pel
-  // sad_list[1]: sad at delta {0, -1} (left)   from the best integer pel
-  // sad_list[2]: sad at delta { 1, 0} (bottom) from the best integer pel
-  // sad_list[3]: sad at delta { 0, 1} (right)  from the best integer pel
-  // sad_list[4]: sad at delta {-1, 0} (top)    from the best integer pel
-  if (sad_list) {
-    static const MV neighbors[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}};
-    sad_list[0] = bestsad;
-    if (check_bounds(x, br, bc, 1)) {
-      for (i = 0; i < 4; i++) {
-        const MV this_mv = {br + neighbors[i].row,
-                            bc + neighbors[i].col};
-        sad_list[i + 1] = vfp->sdf(what->buf, what->stride,
-                                   get_buf_from_mv(in_what, &this_mv),
-                                   in_what->stride) +
-            (use_mvcost ?
-             mvsad_err_cost(x, &this_mv, &fcenter_mv, sad_per_bit) :
-             0);
-      }
-    } else {
-      for (i = 0; i < 4; i++) {
-        const MV this_mv = {br + neighbors[i].row,
-                            bc + neighbors[i].col};
-        if (!is_mv_in(x, &this_mv))
-          sad_list[i + 1] = INT_MAX;
-        else
-          sad_list[i + 1] = vfp->sdf(what->buf, what->stride,
-                                     get_buf_from_mv(in_what, &this_mv),
-                                     in_what->stride) +
-              (use_mvcost ?
-               mvsad_err_cost(x, &this_mv, &fcenter_mv, sad_per_bit) :
-               0);
-      }
-    }
+  // cost_list[0]: cost at the best integer pel
+  // cost_list[1]: cost at delta {0, -1} (left)   from the best integer pel
+  // cost_list[2]: cost at delta { 1, 0} (bottom) from the best integer pel
+  // cost_list[3]: cost at delta { 0, 1} (right)  from the best integer pel
+  // cost_list[4]: cost at delta {-1, 0} (top)    from the best integer pel
+  if (cost_list) {
+    const MV best_mv = { br, bc };
+    calc_int_cost_list(x, &fcenter_mv, sad_per_bit, vfp, &best_mv, cost_list);
   }
   best_mv->row = br;
   best_mv->col = bc;
@@ -909,7 +916,7 @@
 }
 
 // A specialized function where the smallest scale search candidates
-// are 4 1-away neighbors, and sad_list is non-null
+// are 4 1-away neighbors, and cost_list is non-null
 // TODO(debargha): Merge this function with the one above. Also remove
 // use_mvcost option since it is always 1, to save unnecessary branches.
 static int vp9_pattern_search_sad(const MACROBLOCK *x,
@@ -917,7 +924,7 @@
                                   int search_param,
                                   int sad_per_bit,
                                   int do_init_search,
-                                  int *sad_list,
+                                  int *cost_list,
                                   const vp9_variance_fn_ptr_t *vfp,
                                   int use_mvcost,
                                   const MV *center_mv,
@@ -942,8 +949,8 @@
   clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
   br = ref_mv->row;
   bc = ref_mv->col;
-  if (sad_list != NULL) {
-    sad_list[0] = sad_list[1] = sad_list[2] = sad_list[3] = sad_list[4] =
+  if (cost_list != NULL) {
+    cost_list[0] = cost_list[1] = cost_list[2] = cost_list[3] = cost_list[4] =
         INT_MAX;
   }
 
@@ -997,7 +1004,7 @@
   // If the center point is still the best, just skip this and move to
   // the refinement step.
   if (best_init_s != -1) {
-    int do_sad = (num_candidates[0] == 4 && sad_list != NULL);
+    int do_sad = (num_candidates[0] == 4 && cost_list != NULL);
     int best_site = -1;
     s = best_init_s;
 
@@ -1071,15 +1078,15 @@
       } while (best_site != -1);
     }
 
-    // Note: If we enter the if below, then sad_list must be non-NULL.
+    // Note: If we enter the if below, then cost_list must be non-NULL.
     if (s == 0) {
-      sad_list[0] = bestsad;
+      cost_list[0] = bestsad;
       if (!do_init_search || s != best_init_s) {
         if (check_bounds(x, br, bc, 1 << s)) {
           for (i = 0; i < num_candidates[s]; i++) {
             const MV this_mv = {br + candidates[s][i].row,
                                 bc + candidates[s][i].col};
-            sad_list[i + 1] =
+            cost_list[i + 1] =
             thissad = vfp->sdf(what->buf, what->stride,
                                get_buf_from_mv(in_what, &this_mv),
                                in_what->stride);
@@ -1091,7 +1098,7 @@
                                 bc + candidates[s][i].col};
             if (!is_mv_in(x, &this_mv))
               continue;
-            sad_list[i + 1] =
+            cost_list[i + 1] =
             thissad = vfp->sdf(what->buf, what->stride,
                                get_buf_from_mv(in_what, &this_mv),
                                in_what->stride);
@@ -1111,15 +1118,15 @@
         next_chkpts_indices[0] = (k == 0) ? num_candidates[s] - 1 : k - 1;
         next_chkpts_indices[1] = k;
         next_chkpts_indices[2] = (k == num_candidates[s] - 1) ? 0 : k + 1;
-        sad_list[1] = sad_list[2] = sad_list[3] = sad_list[4] = INT_MAX;
-        sad_list[((k + 2) % 4) + 1] = sad_list[0];
-        sad_list[0] = bestsad;
+        cost_list[1] = cost_list[2] = cost_list[3] = cost_list[4] = INT_MAX;
+        cost_list[((k + 2) % 4) + 1] = cost_list[0];
+        cost_list[0] = bestsad;
 
         if (check_bounds(x, br, bc, 1 << s)) {
           for (i = 0; i < PATTERN_CANDIDATES_REF; i++) {
             const MV this_mv = {br + candidates[s][next_chkpts_indices[i]].row,
                                 bc + candidates[s][next_chkpts_indices[i]].col};
-            sad_list[next_chkpts_indices[i] + 1] =
+            cost_list[next_chkpts_indices[i] + 1] =
             thissad = vfp->sdf(what->buf, what->stride,
                                get_buf_from_mv(in_what, &this_mv),
                                in_what->stride);
@@ -1130,10 +1137,10 @@
             const MV this_mv = {br + candidates[s][next_chkpts_indices[i]].row,
                                 bc + candidates[s][next_chkpts_indices[i]].col};
             if (!is_mv_in(x, &this_mv)) {
-              sad_list[next_chkpts_indices[i] + 1] = INT_MAX;
+              cost_list[next_chkpts_indices[i] + 1] = INT_MAX;
               continue;
             }
-            sad_list[next_chkpts_indices[i] + 1] =
+            cost_list[next_chkpts_indices[i] + 1] =
             thissad = vfp->sdf(what->buf, what->stride,
                                get_buf_from_mv(in_what, &this_mv),
                                in_what->stride);
@@ -1151,20 +1158,20 @@
   }
 
   // Returns the one-away integer pel sad values around the best as follows:
-  // sad_list[0]: sad at the best integer pel
-  // sad_list[1]: sad at delta {0, -1} (left)   from the best integer pel
-  // sad_list[2]: sad at delta { 1, 0} (bottom) from the best integer pel
-  // sad_list[3]: sad at delta { 0, 1} (right)  from the best integer pel
-  // sad_list[4]: sad at delta {-1, 0} (top)    from the best integer pel
-  if (sad_list) {
+  // cost_list[0]: sad at the best integer pel
+  // cost_list[1]: sad at delta {0, -1} (left)   from the best integer pel
+  // cost_list[2]: sad at delta { 1, 0} (bottom) from the best integer pel
+  // cost_list[3]: sad at delta { 0, 1} (right)  from the best integer pel
+  // cost_list[4]: sad at delta {-1, 0} (top)    from the best integer pel
+  if (cost_list) {
     static const MV neighbors[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}};
-    if (sad_list[0] == INT_MAX) {
-      sad_list[0] = bestsad;
+    if (cost_list[0] == INT_MAX) {
+      cost_list[0] = bestsad;
       if (check_bounds(x, br, bc, 1)) {
         for (i = 0; i < 4; i++) {
-          const MV this_mv = {br + neighbors[i].row,
-            bc + neighbors[i].col};
-          sad_list[i + 1] = vfp->sdf(what->buf, what->stride,
+          const MV this_mv = { br + neighbors[i].row,
+                               bc + neighbors[i].col };
+          cost_list[i + 1] = vfp->sdf(what->buf, what->stride,
                                      get_buf_from_mv(in_what, &this_mv),
                                      in_what->stride);
         }
@@ -1173,9 +1180,9 @@
           const MV this_mv = {br + neighbors[i].row,
             bc + neighbors[i].col};
           if (!is_mv_in(x, &this_mv))
-            sad_list[i + 1] = INT_MAX;
+            cost_list[i + 1] = INT_MAX;
           else
-            sad_list[i + 1] = vfp->sdf(what->buf, what->stride,
+            cost_list[i + 1] = vfp->sdf(what->buf, what->stride,
                                        get_buf_from_mv(in_what, &this_mv),
                                        in_what->stride);
         }
@@ -1185,8 +1192,8 @@
         for (i = 0; i < 4; i++) {
           const MV this_mv = {br + neighbors[i].row,
             bc + neighbors[i].col};
-          if (sad_list[i + 1] != INT_MAX) {
-            sad_list[i + 1] +=
+          if (cost_list[i + 1] != INT_MAX) {
+            cost_list[i + 1] +=
                 mvsad_err_cost(x, &this_mv, &fcenter_mv, sad_per_bit);
           }
         }
@@ -1236,7 +1243,7 @@
                    int search_param,
                    int sad_per_bit,
                    int do_init_search,
-                   int *sad_list,
+                   int *cost_list,
                    const vp9_variance_fn_ptr_t *vfp,
                    int use_mvcost,
                    const MV *center_mv, MV *best_mv) {
@@ -1261,7 +1268,7 @@
       { -1024, 0}},
   };
   return vp9_pattern_search(x, ref_mv, search_param, sad_per_bit,
-                            do_init_search, sad_list, vfp, use_mvcost,
+                            do_init_search, cost_list, vfp, use_mvcost,
                             center_mv, best_mv,
                             hex_num_candidates, hex_candidates);
 }
@@ -1271,7 +1278,7 @@
                       int search_param,
                       int sad_per_bit,
                       int do_init_search,
-                      int *sad_list,
+                      int *cost_list,
                       const vp9_variance_fn_ptr_t *vfp,
                       int use_mvcost,
                       const MV *center_mv,
@@ -1303,7 +1310,7 @@
       {-512, 512}, {-1024, 0}},
   };
   return vp9_pattern_search_sad(x, ref_mv, search_param, sad_per_bit,
-                                do_init_search, sad_list, vfp, use_mvcost,
+                                do_init_search, cost_list, vfp, use_mvcost,
                                 center_mv, best_mv,
                                 bigdia_num_candidates, bigdia_candidates);
 }
@@ -1313,7 +1320,7 @@
                       int search_param,
                       int sad_per_bit,
                       int do_init_search,
-                      int *sad_list,
+                      int *cost_list,
                       const vp9_variance_fn_ptr_t *vfp,
                       int use_mvcost,
                       const MV *center_mv,
@@ -1345,7 +1352,7 @@
       {0, 1024}, {-1024, 1024}, {-1024, 0}},
   };
   return vp9_pattern_search(x, ref_mv, search_param, sad_per_bit,
-                            do_init_search, sad_list, vfp, use_mvcost,
+                            do_init_search, cost_list, vfp, use_mvcost,
                             center_mv, best_mv,
                             square_num_candidates, square_candidates);
 }
@@ -1355,13 +1362,13 @@
                         int search_param,
                         int sad_per_bit,
                         int do_init_search,  // must be zero for fast_hex
-                        int *sad_list,
+                        int *cost_list,
                         const vp9_variance_fn_ptr_t *vfp,
                         int use_mvcost,
                         const MV *center_mv,
                         MV *best_mv) {
   return vp9_hex_search(x, ref_mv, MAX(MAX_MVSEARCH_STEPS - 2, search_param),
-                        sad_per_bit, do_init_search, sad_list, vfp, use_mvcost,
+                        sad_per_bit, do_init_search, cost_list, vfp, use_mvcost,
                         center_mv, best_mv);
 }
 
@@ -1370,13 +1377,13 @@
                         int search_param,
                         int sad_per_bit,
                         int do_init_search,
-                        int *sad_list,
+                        int *cost_list,
                         const vp9_variance_fn_ptr_t *vfp,
                         int use_mvcost,
                         const MV *center_mv,
                         MV *best_mv) {
   return vp9_bigdia_search(x, ref_mv, MAX(MAX_MVSEARCH_STEPS - 2, search_param),
-                           sad_per_bit, do_init_search, sad_list, vfp,
+                           sad_per_bit, do_init_search, cost_list, vfp,
                            use_mvcost, center_mv, best_mv);
 }
 
@@ -1659,7 +1666,7 @@
 
   // Return cost list.
   if (cost_list) {
-    calc_int_sad_cost_list(x, ref_mv, sadpb, fn_ptr, dst_mv, cost_list);
+    calc_int_cost_list(x, ref_mv, sadpb, fn_ptr, dst_mv, cost_list);
   }
   return bestsme;
 }
@@ -1980,7 +1987,7 @@
 int vp9_full_pixel_search(VP9_COMP *cpi, MACROBLOCK *x,
                           BLOCK_SIZE bsize, MV *mvp_full,
                           int step_param, int error_per_bit,
-                          int *sad_list,
+                          int *cost_list,
                           const MV *ref_mv, MV *tmp_mv,
                           int var_max, int rd) {
   const SPEED_FEATURES *const sf = &cpi->sf;
@@ -1987,39 +1994,39 @@
   const SEARCH_METHODS method = sf->mv.search_method;
   vp9_variance_fn_ptr_t *fn_ptr = &cpi->fn_ptr[bsize];
   int var = 0;
-  if (sad_list) {
-    sad_list[0] = INT_MAX;
-    sad_list[1] = INT_MAX;
-    sad_list[2] = INT_MAX;
-    sad_list[3] = INT_MAX;
-    sad_list[4] = INT_MAX;
+  if (cost_list) {
+    cost_list[0] = INT_MAX;
+    cost_list[1] = INT_MAX;
+    cost_list[2] = INT_MAX;
+    cost_list[3] = INT_MAX;
+    cost_list[4] = INT_MAX;
   }
 
   switch (method) {
     case FAST_DIAMOND:
       var = vp9_fast_dia_search(x, mvp_full, step_param, error_per_bit, 0,
-                                sad_list, fn_ptr, 1, ref_mv, tmp_mv);
+                                cost_list, fn_ptr, 1, ref_mv, tmp_mv);
       break;
     case FAST_HEX:
       var = vp9_fast_hex_search(x, mvp_full, step_param, error_per_bit, 0,
-                                sad_list, fn_ptr, 1, ref_mv, tmp_mv);
+                                cost_list, fn_ptr, 1, ref_mv, tmp_mv);
       break;
     case HEX:
       var = vp9_hex_search(x, mvp_full, step_param, error_per_bit, 1,
-                           sad_list, fn_ptr, 1, ref_mv, tmp_mv);
+                           cost_list, fn_ptr, 1, ref_mv, tmp_mv);
       break;
     case SQUARE:
       var = vp9_square_search(x, mvp_full, step_param, error_per_bit, 1,
-                              sad_list, fn_ptr, 1, ref_mv, tmp_mv);
+                              cost_list, fn_ptr, 1, ref_mv, tmp_mv);
       break;
     case BIGDIA:
       var = vp9_bigdia_search(x, mvp_full, step_param, error_per_bit, 1,
-                              sad_list, fn_ptr, 1, ref_mv, tmp_mv);
+                              cost_list, fn_ptr, 1, ref_mv, tmp_mv);
       break;
     case NSTEP:
       var = vp9_full_pixel_diamond(cpi, x, mvp_full, step_param, error_per_bit,
                                    MAX_MVSEARCH_STEPS - 1 - step_param,
-                                   1, sad_list, fn_ptr, ref_mv, tmp_mv);
+                                   1, cost_list, fn_ptr, ref_mv, tmp_mv);
       break;
     default:
       assert(!"Invalid search method.");
--- a/vp9/encoder/vp9_mcomp.h
+++ b/vp9/encoder/vp9_mcomp.h
@@ -80,7 +80,7 @@
     int search_param,
     int error_per_bit,
     int do_init_search,
-    int *sad_list,
+    int *cost_list,
     const vp9_variance_fn_ptr_t *vf,
     int use_mvcost,
     const MV *center_mv,
@@ -100,7 +100,7 @@
     const vp9_variance_fn_ptr_t *vfp,
     int forced_stop,  // 0 - full, 1 - qtr only, 2 - half only
     int iters_per_step,
-    int *sad_list,
+    int *cost_list,
     int *mvjcost, int *mvcost[2],
     int *distortion, unsigned int *sse1,
     const uint8_t *second_pred,
@@ -109,7 +109,7 @@
 extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree;
 extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree_pruned;
 extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree_pruned_more;
-extern fractional_mv_step_fp vp9_find_best_sub_pixel_surface_fit;
+extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree_pruned_evenmore;
 
 typedef int (*vp9_full_search_fn_t)(const MACROBLOCK *x,
                                     const MV *ref_mv, int sad_per_bit,
@@ -142,7 +142,7 @@
 int vp9_full_pixel_search(struct VP9_COMP *cpi, MACROBLOCK *x,
                           BLOCK_SIZE bsize, MV *mvp_full,
                           int step_param, int error_per_bit,
-                          int *sad_list,
+                          int *cost_list,
                           const MV *ref_mv, MV *tmp_mv,
                           int var_max, int rd);
 
--- a/vp9/encoder/vp9_pickmode.c
+++ b/vp9/encoder/vp9_pickmode.c
@@ -132,7 +132,7 @@
   const int tmp_row_min = x->mv_row_min;
   const int tmp_row_max = x->mv_row_max;
   int rv = 0;
-  int sad_list[5];
+  int cost_list[5];
   const YV12_BUFFER_CONFIG *scaled_ref_frame = vp9_get_scaled_ref_frame(cpi,
                                                                         ref);
   if (cpi->common.show_frame &&
@@ -160,7 +160,7 @@
   mvp_full.row >>= 3;
 
   vp9_full_pixel_search(cpi, x, bsize, &mvp_full, step_param, sadpb,
-                        cond_sad_list(cpi, sad_list),
+                        cond_cost_list(cpi, cost_list),
                         &ref_mv, &tmp_mv->as_mv, INT_MAX, 0);
 
   x->mv_col_min = tmp_col_min;
@@ -187,7 +187,7 @@
                                  &cpi->fn_ptr[bsize],
                                  cpi->sf.mv.subpel_force_stop,
                                  cpi->sf.mv.subpel_iters_per_step,
-                                 cond_sad_list(cpi, sad_list),
+                                 cond_cost_list(cpi, cost_list),
                                  x->nmvjointcost, x->mvcost,
                                  &dis, &x->pred_sse[ref], NULL, 0, 0);
     x->pred_mv[ref] = tmp_mv->as_mv;
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -1628,7 +1628,7 @@
           int sadpb = x->sadperbit4;
           MV mvp_full;
           int max_mv;
-          int sad_list[5];
+          int cost_list[5];
 
           /* Is the best so far sufficiently good that we cant justify doing
            * and new motion search. */
@@ -1674,7 +1674,7 @@
 
           bestsme = vp9_full_pixel_search(
               cpi, x, bsize, &mvp_full, step_param, sadpb,
-              cpi->sf.mv.subpel_search_method != SUBPEL_TREE ? sad_list : NULL,
+              cpi->sf.mv.subpel_search_method != SUBPEL_TREE ? cost_list : NULL,
               &bsi->ref_mv[0]->as_mv, new_mv,
               INT_MAX, 1);
 
@@ -1688,7 +1688,7 @@
                                            sadpb, 16, &cpi->fn_ptr[bsize],
                                            &bsi->ref_mv[0]->as_mv,
                                            &best_mv->as_mv);
-            sad_list[1] = sad_list[2] = sad_list[3] = sad_list[4] = INT_MAX;
+            cost_list[1] = cost_list[2] = cost_list[3] = cost_list[4] = INT_MAX;
             if (thissme < bestsme) {
               bestsme = thissme;
               *new_mv = best_mv->as_mv;
@@ -1709,7 +1709,7 @@
                 x->errorperbit, &cpi->fn_ptr[bsize],
                 cpi->sf.mv.subpel_force_stop,
                 cpi->sf.mv.subpel_iters_per_step,
-                cond_sad_list(cpi, sad_list),
+                cond_cost_list(cpi, cost_list),
                 x->nmvjointcost, x->mvcost,
                 &distortion,
                 &x->pred_sse[mbmi->ref_frame[0]],
@@ -2043,7 +2043,7 @@
   int tmp_col_max = x->mv_col_max;
   int tmp_row_min = x->mv_row_min;
   int tmp_row_max = x->mv_row_max;
-  int sad_list[5];
+  int cost_list[5];
 
   const YV12_BUFFER_CONFIG *scaled_ref_frame = vp9_get_scaled_ref_frame(cpi,
                                                                         ref);
@@ -2115,7 +2115,7 @@
   mvp_full.row >>= 3;
 
   bestsme = vp9_full_pixel_search(cpi, x, bsize, &mvp_full, step_param, sadpb,
-                                  cond_sad_list(cpi, sad_list),
+                                  cond_cost_list(cpi, cost_list),
                                   &ref_mv, &tmp_mv->as_mv, INT_MAX, 1);
 
   x->mv_col_min = tmp_col_min;
@@ -2131,7 +2131,7 @@
                                  &cpi->fn_ptr[bsize],
                                  cpi->sf.mv.subpel_force_stop,
                                  cpi->sf.mv.subpel_iters_per_step,
-                                 cond_sad_list(cpi, sad_list),
+                                 cond_cost_list(cpi, cost_list),
                                  x->nmvjointcost, x->mvcost,
                                  &dis, &x->pred_sse[ref], NULL, 0, 0);
   }
--- a/vp9/encoder/vp9_speed_features.c
+++ b/vp9/encoder/vp9_speed_features.c
@@ -124,7 +124,7 @@
     sf->tx_size_search_method = USE_LARGESTALL;
     sf->disable_split_mask = DISABLE_ALL_SPLIT;
     sf->mv.search_method = BIGDIA;
-    sf->mv.subpel_search_method = SUBPEL_TREE_PRUNED;
+    sf->mv.subpel_search_method = SUBPEL_TREE_PRUNED_MORE;
     sf->adaptive_rd_thresh = 4;
     sf->mode_search_skip_flags |= FLAG_EARLY_TERMINATE;
     sf->disable_filter_search_var_thresh = 200;
@@ -430,8 +430,8 @@
     cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_tree_pruned;
   } else if (sf->mv.subpel_search_method == SUBPEL_TREE_PRUNED_MORE) {
     cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_tree_pruned_more;
-  } else if (sf->mv.subpel_search_method == SUBPEL_SURFACE_FIT) {
-    cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_surface_fit;
+  } else if (sf->mv.subpel_search_method == SUBPEL_TREE_PRUNED_EVENMORE) {
+    cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_tree_pruned_evenmore;
   }
 
   cpi->mb.optimize = sf->optimize_coefficients == 1 && oxcf->pass != 1;
--- a/vp9/encoder/vp9_speed_features.h
+++ b/vp9/encoder/vp9_speed_features.h
@@ -81,9 +81,9 @@
 
 typedef enum {
   SUBPEL_TREE = 0,
-  SUBPEL_TREE_PRUNED = 1,
-  SUBPEL_TREE_PRUNED_MORE = 2,
-  SUBPEL_SURFACE_FIT = 3,
+  SUBPEL_TREE_PRUNED = 1,           // Prunes 1/2-pel searches
+  SUBPEL_TREE_PRUNED_MORE = 2,      // Prunes 1/2-pel searches more aggressively
+  SUBPEL_TREE_PRUNED_EVENMORE = 3,  // Prunes 1/2- and 1/4-pel searches
   // Other methods to come
 } SUBPEL_SEARCH_METHODS;
 
--- a/vp9/encoder/vp9_temporal_filter.c
+++ b/vp9/encoder/vp9_temporal_filter.c
@@ -221,7 +221,7 @@
   int bestsme = INT_MAX;
   int distortion;
   unsigned int sse;
-  int sad_list[5];
+  int cost_list[5];
 
   MV best_ref_mv1 = {0, 0};
   MV best_ref_mv1_full; /* full-pixel value of best_ref_mv1 */
@@ -245,7 +245,7 @@
 
   // Ignore mv costing by sending NULL pointer instead of cost arrays
   vp9_hex_search(x, &best_ref_mv1_full, step_param, sadpb, 1,
-                 cond_sad_list(cpi, sad_list),
+                 cond_cost_list(cpi, cost_list),
                  &cpi->fn_ptr[BLOCK_16X16], 0, &best_ref_mv1, ref_mv);
 
   // Ignore mv costing by sending NULL pointer instead of cost array
@@ -255,7 +255,7 @@
                                          x->errorperbit,
                                          &cpi->fn_ptr[BLOCK_16X16],
                                          0, mv_sf->subpel_iters_per_step,
-                                         cond_sad_list(cpi, sad_list),
+                                         cond_cost_list(cpi, cost_list),
                                          NULL, NULL,
                                          &distortion, &sse, NULL, 0, 0);