simp-mv-pred integration with ref-mv

This commit adds simp-mv-pred experiment. The experiment is to work on
top of ref-mv experiment to save memory bandwidth and reduce the size
of line buffer needed in ref-mv experiment.

When compared to ref-mv, this experiment showed:
low-delay BDR gain: 0.03%
High-delay BDR gain: 0.01%
memory/memory bandwidth saving: 40%
local memory/gate count saving: 20%

Change-Id: Ic4006e041fc58ede411da83d0d730c464ebe1749
diff --git a/av1/common/mvref_common.c b/av1/common/mvref_common.c
index 5b0f21d..252c567 100644
--- a/av1/common/mvref_common.c
+++ b/av1/common/mvref_common.c
@@ -350,7 +350,11 @@
 
       if (idx == *refmv_count && *refmv_count < MAX_REF_MV_STACK_SIZE) {
         ref_mv_stack[idx].this_mv.as_int = this_refmv.as_int;
+#if CONFIG_SIMP_MV_PRED
+        ref_mv_stack[idx].pred_mv[0] = prev_frame_mvs->mv[ref];
+#else
         ref_mv_stack[idx].pred_mv[0] = prev_frame_mvs->pred_mv[ref];
+#endif
         ref_mv_stack[idx].weight = 2;
         ++(*refmv_count);
       }
@@ -420,12 +424,25 @@
   }
 
   // Scan the second outer area.
+#if CONFIG_SIMP_MV_PRED
+  scan_blk_mbmi(cm, xd, mi_row, mi_col, block, rf, -1, -1, ref_mv_stack,
+                refmv_count);
+  for (idx = 2; idx <= 3; ++idx) {
+    scan_row_mbmi(cm, xd, mi_row, mi_col, block, rf, -idx, ref_mv_stack,
+                  refmv_count);
+    scan_col_mbmi(cm, xd, mi_row, mi_col, block, rf, -idx, ref_mv_stack,
+                  refmv_count);
+  }
+  scan_col_mbmi(cm, xd, mi_row, mi_col, block, rf, -4, ref_mv_stack,
+                refmv_count);
+#else
   for (idx = 2; idx <= 4; ++idx) {
     scan_row_mbmi(cm, xd, mi_row, mi_col, block, rf, -idx, ref_mv_stack,
                   refmv_count);
     scan_col_mbmi(cm, xd, mi_row, mi_col, block, rf, -idx, ref_mv_stack,
                   refmv_count);
   }
+#endif
 
   switch (nearest_refmv_count) {
     case 0:
@@ -530,7 +547,9 @@
                              void *const data, int16_t *mode_context) {
   const int *ref_sign_bias = cm->ref_frame_sign_bias;
   int i, refmv_count = 0;
+#if !CONFIG_SIMP_MV_PRED
   const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type];
+#endif
   int different_ref_found = 0;
   int context_counter = 0;
   const MV_REF *const prev_frame_mvs =
@@ -540,6 +559,29 @@
   const TileInfo *const tile = &xd->tile;
   const int bw = num_8x8_blocks_wide_lookup[mi->mbmi.sb_type] << 3;
   const int bh = num_8x8_blocks_high_lookup[mi->mbmi.sb_type] << 3;
+#if CONFIG_SIMP_MV_PRED
+  POSITION mv_ref_search[MVREF_NEIGHBOURS];
+  const int num_8x8_blocks_wide = bw >> 3;
+  const int num_8x8_blocks_high = bh >> 3;
+  mv_ref_search[0].row = num_8x8_blocks_high - 1;
+  mv_ref_search[0].col = -1;
+  mv_ref_search[1].row = -1;
+  mv_ref_search[1].col = num_8x8_blocks_wide - 1;
+  mv_ref_search[2].row = -1;
+  mv_ref_search[2].col = (num_8x8_blocks_wide - 1) >> 1;
+  mv_ref_search[3].row = (num_8x8_blocks_high - 1) >> 1;
+  mv_ref_search[3].col = -1;
+  mv_ref_search[4].row = -1;
+  mv_ref_search[4].col = -1;
+  mv_ref_search[5].row = -1;
+  mv_ref_search[5].col = num_8x8_blocks_wide;
+  mv_ref_search[6].row = num_8x8_blocks_high;
+  mv_ref_search[6].col = -1;
+  mv_ref_search[7].row = -1;
+  mv_ref_search[7].col = -3;
+  mv_ref_search[8].row = num_8x8_blocks_high - 1;
+  mv_ref_search[8].col = -3;
+#endif
 
   // The nearest 2 blocks are treated differently
   // if the size < 8x8 we get the mv from the bmi substructure,
@@ -571,6 +613,12 @@
     if (is_inside(tile, mi_col, mi_row, mv_ref)) {
       const MB_MODE_INFO *const candidate =
           &xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride]->mbmi;
+#if CONFIG_SIMP_MV_PRED
+      if (candidate == NULL)
+        continue;
+      if ((mi_row % 8) + mv_ref->row >= 8 || (mi_col % 8) + mv_ref->col >= 8)
+        continue;
+#endif
       different_ref_found = 1;
 
       if (candidate->ref_frame[0] == ref_frame)
@@ -617,6 +665,12 @@
       if (is_inside(tile, mi_col, mi_row, mv_ref)) {
         const MB_MODE_INFO *const candidate =
             &xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride]->mbmi;
+#if CONFIG_SIMP_MV_PRED
+        if (candidate == NULL)
+          continue;
+        if ((mi_row % 8) + mv_ref->row >= 8 || (mi_col % 8) + mv_ref->col >= 8)
+          continue;
+#endif
 
         // If the candidate is INTRA we don't want to consider its mv.
         IF_DIFF_REF_FRAME_ADD_MV(candidate, ref_frame, ref_sign_bias,