Make firstpass use var instead of sse in motion search

This makes the behavior of firstpass consistent with the rest of the
encoder, which enables some minor refactoring to make the code cleaner.

Performance Change on Speed 0:
 TESTSET | AVG_PSNR | OVR_PSNR |  SSIM
  LOWRES |  -0.006% |  -0.008% | +0.031%
  MIDRES |  +0.012% |  +0.005% | +0.052%
   HDRES |  -0.017% |  -0.007% | +0.006%

STATS_CHANGED

Change-Id: I1d2bad6251d21bd27778024f4b14abd7dd38581b
diff --git a/av1/encoder/firstpass.c b/av1/encoder/firstpass.c
index d747bf0..ad1029c 100644
--- a/av1/encoder/firstpass.c
+++ b/av1/encoder/firstpass.c
@@ -232,15 +232,14 @@
   int cost_list[5];
 
   tmp_err = av1_full_pixel_search(
-      cpi, x, bsize, &start_mv, step_param, 0, NSTEP, 0, x->sadperbit16,
+      cpi, x, bsize, &start_mv, step_param, 1, 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);
 
   if (tmp_err < INT_MAX)
-    tmp_err =
-        av1_get_mvpred_var(x, &x->best_mv.as_fullmv, ref_mv, &v_fn_ptr, 0) +
-        new_mv_mode_penalty;
+    tmp_err = av1_get_mvpred_sse(x, &x->best_mv.as_fullmv, ref_mv, &v_fn_ptr) +
+              new_mv_mode_penalty;
 
   if (tmp_err < *best_motion_err) {
     *best_motion_err = tmp_err;
diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c
index 71d5f09..d9e2cd9 100644
--- a/av1/encoder/mcomp.c
+++ b/av1/encoder/mcomp.c
@@ -1535,6 +1535,23 @@
   return bestsad;
 }
 
+int av1_get_mvpred_sse(const MACROBLOCK *x, const FULLPEL_MV *best_mv,
+                       const MV *ref_mv, const aom_variance_fn_ptr_t *vfp) {
+  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];
+  const MV mv = get_mv_from_fullmv(best_mv);
+  const MV_COST_TYPE mv_cost_type = x->mv_cost_type;
+  unsigned int sse, var;
+
+  var = vfp->vf(what->buf, what->stride, get_buf_from_mv(in_what, best_mv),
+                in_what->stride, &sse);
+  (void)var;
+
+  return sse + mv_err_cost(&mv, ref_mv, x->nmv_vec_cost, x->mv_cost_stack,
+                           x->errorperbit, mv_cost_type);
+}
+
 int av1_get_mvpred_var(const MACROBLOCK *x, const FULLPEL_MV *best_mv,
                        const MV *ref_mv, const aom_variance_fn_ptr_t *vfp,
                        int use_var) {
diff --git a/av1/encoder/mcomp.h b/av1/encoder/mcomp.h
index cdd92a7..0ee06f8 100644
--- a/av1/encoder/mcomp.h
+++ b/av1/encoder/mcomp.h
@@ -76,6 +76,8 @@
                     int *mvcost[2], int weight);
 
 // Utility to compute variance + MV rate cost for a given MV
+int av1_get_mvpred_sse(const MACROBLOCK *x, const FULLPEL_MV *best_mv,
+                       const MV *ref_mv, const aom_variance_fn_ptr_t *vfp);
 int av1_get_mvpred_var(const MACROBLOCK *x, const FULLPEL_MV *best_mv,
                        const MV *ref_mv, const aom_variance_fn_ptr_t *vfp,
                        int use_var);