Add flag to enable error resilience

This finalizes the fix for the ParseAbilityTest for
lag_in_frames > 0.

Change-Id: I5eba86dc9526f8496212090605690f538f3c5451
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 95073b6..4f0cb6a 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -4514,6 +4514,7 @@
     cpi->ext_refresh_frame_flags_pending = 0;
   }
   cpi->common.allow_ref_frame_mvs = cpi->ext_use_ref_frame_mvs;
+  cpi->common.error_resilient_mode = cpi->ext_use_error_resilient;
 }
 
 static int setup_interp_filter_search_mask(AV1_COMP *cpi) {
@@ -4679,7 +4680,7 @@
   cm->cur_frame->frame_type = cm->frame_type;
 
   // S_FRAMEs are always error resilient
-  cm->error_resilient_mode = oxcf->error_resilient_mode || frame_is_sframe(cm);
+  cm->error_resilient_mode |= frame_is_sframe(cm);
   cm->allow_ref_frame_mvs &= frame_might_allow_ref_frame_mvs(cm);
   cm->allow_warped_motion =
       cpi->oxcf.allow_warped_motion && frame_might_allow_warped_motion(cm);
@@ -5542,10 +5543,9 @@
     cpi->multi_arf_allowed = 0;
 
   // Normal defaults
-  cm->refresh_frame_context =
-      (oxcf->error_resilient_mode || oxcf->frame_parallel_decoding_mode)
-          ? REFRESH_FRAME_CONTEXT_DISABLED
-          : REFRESH_FRAME_CONTEXT_BACKWARD;
+  cm->refresh_frame_context = oxcf->frame_parallel_decoding_mode
+                                  ? REFRESH_FRAME_CONTEXT_DISABLED
+                                  : REFRESH_FRAME_CONTEXT_BACKWARD;
   if (oxcf->large_scale_tile)
     cm->refresh_frame_context = REFRESH_FRAME_CONTEXT_DISABLED;
 
@@ -6063,6 +6063,8 @@
 
   cpi->ext_use_ref_frame_mvs = cpi->oxcf.allow_ref_frame_mvs &
                                ((flags & AOM_EFLAG_NO_REF_FRAME_MVS) == 0);
+  cpi->ext_use_error_resilient = cpi->oxcf.error_resilient_mode |
+                                 ((flags & AOM_EFLAG_ERROR_RESILIENT) != 0);
 
   if (flags & AOM_EFLAG_NO_UPD_ENTROPY) {
     av1_update_entropy(cpi, 0);
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index a58332d..f7b3b4f 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -411,6 +411,7 @@
   int ext_refresh_frame_context_pending;
   int ext_refresh_frame_context;
   int ext_use_ref_frame_mvs;
+  int ext_use_error_resilient;
 
   YV12_BUFFER_CONFIG last_frame_uf;
   YV12_BUFFER_CONFIG trial_frame_rst;