Refactor av1_get_mvpred_av_var() interface

Directly pass in the frame buffer pointer, instead of reading through
macroblockd struct.

Change-Id: I055a7ec9a86723042eb1724a79ef1092e5464564
diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c
index 7b80569..b8bcc76 100644
--- a/av1/encoder/mcomp.c
+++ b/av1/encoder/mcomp.c
@@ -1408,10 +1408,11 @@
 
 int av1_get_mvpred_av_var(const MACROBLOCK *x, const MV *best_mv,
                           const MV *center_mv, const uint8_t *second_pred,
-                          const aom_variance_fn_ptr_t *vfp, int use_mvcost) {
-  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 aom_variance_fn_ptr_t *vfp,
+                          const struct buf_2d *src, const struct buf_2d *pre,
+                          int use_mvcost) {
+  const struct buf_2d *const what = src;
+  const struct buf_2d *const in_what = pre;
   const MV mv = { best_mv->row * 8, best_mv->col * 8 };
   unsigned int unused;
 
@@ -1426,10 +1427,10 @@
                             const MV *center_mv, const uint8_t *second_pred,
                             const uint8_t *mask, int mask_stride,
                             int invert_mask, const aom_variance_fn_ptr_t *vfp,
+                            const struct buf_2d *src, const struct buf_2d *pre,
                             int use_mvcost) {
-  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 struct buf_2d *const what = src;
+  const struct buf_2d *const in_what = pre;
   const MV mv = { best_mv->row * 8, best_mv->col * 8 };
   unsigned int unused;
 
diff --git a/av1/encoder/mcomp.h b/av1/encoder/mcomp.h
index 72169c9..e23a61c 100644
--- a/av1/encoder/mcomp.h
+++ b/av1/encoder/mcomp.h
@@ -69,11 +69,14 @@
                        int use_mvcost);
 int av1_get_mvpred_av_var(const MACROBLOCK *x, const MV *best_mv,
                           const MV *center_mv, const uint8_t *second_pred,
-                          const aom_variance_fn_ptr_t *vfp, int use_mvcost);
+                          const aom_variance_fn_ptr_t *vfp,
+                          const struct buf_2d *src, const struct buf_2d *pre,
+                          int use_mvcost);
 int av1_get_mvpred_mask_var(const MACROBLOCK *x, const MV *best_mv,
                             const MV *center_mv, const uint8_t *second_pred,
                             const uint8_t *mask, int mask_stride,
                             int invert_mask, const aom_variance_fn_ptr_t *vfp,
+                            const struct buf_2d *src, const struct buf_2d *pre,
                             int use_mvcost);
 
 struct AV1_COMP;
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 641d261..a83e161 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -7092,12 +7092,13 @@
         &ref_mv[id].as_mv, second_pred, &x->plane[0].src, &ref_yv12[id]);
     if (bestsme < INT_MAX) {
       if (mask)
-        bestsme = av1_get_mvpred_mask_var(x, best_mv, &ref_mv[id].as_mv,
-                                          second_pred, mask, mask_stride, id,
-                                          &cpi->fn_ptr[bsize], 1);
+        bestsme = av1_get_mvpred_mask_var(
+            x, best_mv, &ref_mv[id].as_mv, second_pred, mask, mask_stride, id,
+            &cpi->fn_ptr[bsize], &x->plane[0].src, &ref_yv12[id], 1);
       else
         bestsme = av1_get_mvpred_av_var(x, best_mv, &ref_mv[id].as_mv,
-                                        second_pred, &cpi->fn_ptr[bsize], 1);
+                                        second_pred, &cpi->fn_ptr[bsize],
+                                        &x->plane[0].src, &ref_yv12[id], 1);
     }
 
     x->mv_limits = tmp_mv_limits;
@@ -7687,12 +7688,13 @@
       &ref_mv.as_mv, second_pred, &x->plane[0].src, &ref_yv12);
   if (bestsme < INT_MAX) {
     if (mask)
-      bestsme =
-          av1_get_mvpred_mask_var(x, best_mv, &ref_mv.as_mv, second_pred, mask,
-                                  mask_stride, ref_idx, &cpi->fn_ptr[bsize], 1);
+      bestsme = av1_get_mvpred_mask_var(
+          x, best_mv, &ref_mv.as_mv, second_pred, mask, mask_stride, ref_idx,
+          &cpi->fn_ptr[bsize], &x->plane[0].src, &ref_yv12, 1);
     else
       bestsme = av1_get_mvpred_av_var(x, best_mv, &ref_mv.as_mv, second_pred,
-                                      &cpi->fn_ptr[bsize], 1);
+                                      &cpi->fn_ptr[bsize], &x->plane[0].src,
+                                      &ref_yv12, 1);
   }
 
   x->mv_limits = tmp_mv_limits;