add --enable-mv-compress to reduce the storage of temporal mv candidate

Change-Id: I5a2469d10f7295f1b8a6bea64e36b8325c8dca22
diff --git a/av1/common/mvref_common.c b/av1/common/mvref_common.c
index b9f191d..b84f9e5 100644
--- a/av1/common/mvref_common.c
+++ b/av1/common/mvref_common.c
@@ -361,8 +361,13 @@
   int coll_blk_count = 0;
   const int weight_unit = mi_size_wide[BLOCK_8X8];
 
+#if CONFIG_MV_COMPRESS
+  mi_pos.row = (mi_row & 0x01) ? blk_row : blk_row + 1;
+  mi_pos.col = (mi_col & 0x01) ? blk_col : blk_col + 1;
+#else
   mi_pos.row = blk_row;
   mi_pos.col = blk_col;
+#endif
 
 #if CONFIG_DEPENDENT_HORZTILES
   if (!is_inside(&xd->tile, mi_col, mi_row, cm->mi_rows,
@@ -410,10 +415,18 @@
   CANDIDATE_MV tmp_mv;
   int len, nr_len;
 
+#if CONFIG_MV_COMPRESS
+  const MV_REF *const prev_frame_mvs_base =
+      cm->use_prev_frame_mvs
+          ? cm->prev_frame->mvs + (((mi_row >> 1) << 1) + 1) * cm->mi_cols +
+                ((mi_col >> 1) << 1) + 1
+          : NULL;
+#else
   const MV_REF *const prev_frame_mvs_base =
       cm->use_prev_frame_mvs
           ? cm->prev_frame->mvs + mi_row * cm->mi_cols + mi_col
           : NULL;
+#endif
 
   const int bs = AOMMAX(xd->n8_w, xd->n8_h);
   const int has_tr = has_top_right(xd, mi_row, mi_col, bs);
@@ -592,10 +605,25 @@
 #endif
   int different_ref_found = 0;
   int context_counter = 0;
+#if CONFIG_MV_COMPRESS
+  const TileInfo *const tile_ = &xd->tile;
+  int mi_row_end = tile_->mi_row_end;
+  int mi_col_end = tile_->mi_col_end;
+  const MV_REF *const prev_frame_mvs =
+      cm->use_prev_frame_mvs
+          ? cm->prev_frame->mvs +
+                AOMMIN(((mi_row >> 1) << 1) + 1 + (((xd->n8_h - 1) >> 1) << 1),
+                       mi_row_end - 1) *
+                    cm->mi_cols +
+                AOMMIN(((mi_col >> 1) << 1) + 1 + (((xd->n8_w - 1) >> 1) << 1),
+                       mi_col_end - 1)
+          : NULL;
+#else
   const MV_REF *const prev_frame_mvs =
       cm->use_prev_frame_mvs
           ? cm->prev_frame->mvs + mi_row * cm->mi_cols + mi_col
           : NULL;
+#endif
   const TileInfo *const tile = &xd->tile;
   const BLOCK_SIZE bsize = mi->mbmi.sb_type;
   const int bw = block_size_wide[AOMMAX(bsize, BLOCK_8X8)];
diff --git a/configure b/configure
index 8ee3ae8..799900c 100755
--- a/configure
+++ b/configure
@@ -311,6 +311,7 @@
     palette_throughput
     ref_adapt
     lv_map
+    mv_compress
 "
 CONFIG_LIST="
     dependency_tracking