Fix out of bound tpl mv access

Resolve an enc/dec mismatch issue when mv-compress is on.

BUG=aomedia:746

Change-Id: Iaa79129076e6bd7215cb0448c4933a58c6241eaf
diff --git a/av1/common/mvref_common.c b/av1/common/mvref_common.c
index 0699903..39ea9fa 100644
--- a/av1/common/mvref_common.c
+++ b/av1/common/mvref_common.c
@@ -345,9 +345,6 @@
                           MV_REFERENCE_FRAME ref_frame, int blk_row,
                           int blk_col, uint8_t *refmv_count,
                           CANDIDATE_MV *ref_mv_stack, int16_t *mode_context) {
-  const TPL_MV_REF *prev_frame_mvs = cm->cur_frame->tpl_mvs +
-                                     (mi_row + blk_row) * cm->mi_stride +
-                                     (mi_col + blk_col);
   (void)prev_frame_mvs_base;
   POSITION mi_pos;
   int idx;
@@ -365,6 +362,10 @@
   if (!is_inside(&xd->tile, mi_col, mi_row, cm->mi_rows, cm, &mi_pos))
     return coll_blk_count;
 
+  const TPL_MV_REF *prev_frame_mvs = cm->cur_frame->tpl_mvs +
+                                     (mi_row + mi_pos.row) * cm->mi_stride +
+                                     (mi_col + mi_pos.col);
+
   MV_REFERENCE_FRAME rf[2];
   av1_set_ref_frame(rf, ref_frame);