[NORMATIVE]Cut off tpl mvs from error resilient frames

Cut of the use of reference frame motion vectors from all the
reference frames decoded before an error resilient frame.

BUG=aomedia:1564

Change-Id: I3110f5432f5e1fde5047f051d0e953a123e3bec2
diff --git a/av1/common/entropymode.c b/av1/common/entropymode.c
index 889a5dc..26ed86e 100644
--- a/av1/common/entropymode.c
+++ b/av1/common/entropymode.c
@@ -1189,6 +1189,13 @@
 #endif  // CONFIG_NO_FRAME_CONTEXT_SIGNALING
 }
 
+static void reset_use_mvs_flags(AV1_COMMON *cm) {
+  for (MV_REFERENCE_FRAME rf = LAST_FRAME; rf <= INTER_REFS_PER_FRAME; ++rf) {
+    int buf_idx = cm->frame_refs[FWD_RF_OFFSET(rf)].idx;
+    if (buf_idx >= 0) cm->buffer_pool->frame_bufs[buf_idx].allow_mvs = 0;
+  }
+}
+
 void av1_setup_past_independence(AV1_COMMON *cm) {
   // Reset the segment feature data to the default stats:
   // Features disabled, 0, with delta coding (Default state).
@@ -1196,6 +1203,8 @@
 
   av1_clearall_segfeatures(&cm->seg);
 
+  reset_use_mvs_flags(cm);
+
 #if CONFIG_SEGMENT_PRED_LAST
   cm->current_frame_seg_map = cm->cur_frame->seg_map;
 #endif
diff --git a/av1/common/mvref_common.c b/av1/common/mvref_common.c
index ef0b816..6aceee1 100644
--- a/av1/common/mvref_common.c
+++ b/av1/common/mvref_common.c
@@ -1129,6 +1129,8 @@
       cm->buffer_pool->frame_bufs[ref_frame_idx].mi_cols != cm->mi_cols)
     return 0;
 
+  if (cm->buffer_pool->frame_bufs[ref_frame_idx].allow_mvs == 0) return 0;
+
   int ref_frame_index =
       cm->buffer_pool->frame_bufs[ref_frame_idx].cur_frame_offset;
   unsigned int *ref_rf_idx =
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index 3f9950b..9f5340e 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -134,7 +134,9 @@
   unsigned int cur_frame_offset;
   unsigned int ref_frame_offset[INTER_REFS_PER_FRAME];
 
+  uint8_t allow_mvs;
   MV_REF *mvs;
+
 #if CONFIG_SEGMENT_PRED_LAST
   uint8_t *seg_map;
 #endif
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 0e641d3..3fba08b 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -3399,6 +3399,7 @@
   cm->current_frame_seg_map = cm->cur_frame->seg_map;
 #endif
 
+  cm->cur_frame->allow_mvs = 1;
   av1_setup_motion_field(cm);
 
   av1_setup_block_planes(xd, cm->subsampling_x, cm->subsampling_y, num_planes);
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 0d9c19a..4eaf6f6 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -4316,6 +4316,7 @@
   x->txb_split_count = 0;
   av1_zero(x->blk_skip_drl);
 
+  cm->cur_frame->allow_mvs = 1;
   av1_setup_motion_field(cm);
 
   cpi->all_one_sided_refs =