Set AV1E_SET_ERROR_RESILIENT_MODE on T1 and T2 enhanced layers

TBR=marpan@webrtc.org

Bug: webrtc:11404
Change-Id: I21c97861d6df06a0e50641a9fdf26d56e50c2030
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/201627
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Marco Paniconi <marpan@google.com>
Cr-Commit-Position: refs/heads/master@{#32997}
diff --git a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc
index a99c642..e728837 100644
--- a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc
+++ b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc
@@ -512,6 +512,15 @@
     if (SvcEnabled()) {
       SetSvcLayerId(layer_frame);
       SetSvcRefFrameConfig(layer_frame);
+
+      aom_codec_err_t ret =
+          aom_codec_control(&ctx_, AV1E_SET_ERROR_RESILIENT_MODE,
+                            layer_frame.TemporalId() > 0 ? 1 : 0);
+      if (ret != AOM_CODEC_OK) {
+        RTC_LOG(LS_WARNING) << "LibaomAv1Encoder::Encode returned " << ret
+                            << " on control AV1E_SET_ERROR_RESILIENT_MODE.";
+        return WEBRTC_VIDEO_CODEC_ERROR;
+      }
     }
 
     // Encode a frame.