Correct reference updates in error resilient mode

Error resilient mode disables show_existing_frame,
but it is still necessary to keep track of which frames
would have originally been show_existing in order to properly
update the gf_group index and reference buffers.

BUG=aomedia:2021
BUG=aomedia:1994

Change-Id: Idc1f3038f313fd6c1efb90c992780a17a1423f8e
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 6cb531c..86101b1 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -887,6 +887,14 @@
   return !av1_superres_scaled(cm) && av1_resize_scaled(cm);
 }
 
+// Don't allow a show_existing_frame to coincide with an error resilient
+// frame. An exception can be made for a forward keyframe since it has no
+// previous dependencies.
+static INLINE int encode_show_existing_frame(const AV1_COMMON *cm) {
+  return cm->show_existing_frame &&
+         (!cm->error_resilient_mode || cm->frame_type == KEY_FRAME);
+}
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif