Make error resilience configurable through VideoCodecVP9 resilience setting (removes hard coded value in vp9_impl.cc).

Make resilience configurable in video processor integration tests.

BUG=webrtc:6783

Review-Url: https://codereview.webrtc.org/2919803002
Cr-Commit-Position: refs/heads/master@{#18493}
diff --git a/webrtc/modules/video_coding/codec_database.cc b/webrtc/modules/video_coding/codec_database.cc
index 51152fd..794e955 100644
--- a/webrtc/modules/video_coding/codec_database.cc
+++ b/webrtc/modules/video_coding/codec_database.cc
@@ -44,7 +44,7 @@
   VideoCodecVP9 vp9_settings;
   memset(&vp9_settings, 0, sizeof(vp9_settings));
 
-  vp9_settings.resilience = 1;
+  vp9_settings.resilienceOn = true;
   vp9_settings.numberOfTemporalLayers = 1;
   vp9_settings.denoisingOn = true;
   vp9_settings.frameDroppingOn = true;
diff --git a/webrtc/modules/video_coding/codecs/test/plot_videoprocessor_integrationtest.cc b/webrtc/modules/video_coding/codecs/test/plot_videoprocessor_integrationtest.cc
index bd12b68..42f0e69 100644
--- a/webrtc/modules/video_coding/codecs/test/plot_videoprocessor_integrationtest.cc
+++ b/webrtc/modules/video_coding/codecs/test/plot_videoprocessor_integrationtest.cc
@@ -21,6 +21,7 @@
 const bool kDenoisingOn = false;
 const bool kFrameDropperOn = true;
 const bool kSpatialResizeOn = false;
+const bool kResilienceOn = false;
 const VideoCodecType kVideoCodecType[] = {kVideoCodecVP8};
 const bool kHwCodec = false;
 const bool kUseSingleCore = true;
@@ -70,7 +71,7 @@
         -1,  // key_frame_interval
         1,   // num_temporal_layers
         kErrorConcealmentOn, kDenoisingOn, kFrameDropperOn, kSpatialResizeOn,
-        width, height, filename, kVerboseLogging, kBatchMode);
+        kResilienceOn, width, height, filename, kVerboseLogging, kBatchMode);
 
     // Use default thresholds for quality (PSNR and SSIM).
     QualityThresholds quality_thresholds;
diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor.cc b/webrtc/modules/video_coding/codecs/test/videoprocessor.cc
index f919ced..b6f4b9d 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor.cc
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor.cc
@@ -74,7 +74,7 @@
   } else if (config->codecType == kVideoCodecVP9) {
     printf("    Denoising        : %d\n", config->VP9().denoisingOn);
     printf("    Frame dropping   : %d\n", config->VP9().frameDroppingOn);
-    printf("    Resilience       : %d\n", config->VP9().resilience);
+    printf("    Resilience       : %d\n", config->VP9().resilienceOn);
   }
 }
 
diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc
index 7a127c9..7ea594e 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc
@@ -21,6 +21,9 @@
 // Only allow encoder/decoder to use single core, for predictability.
 const bool kUseSingleCore = true;
 
+// Default codec setting is on.
+const bool kResilienceOn = true;
+
 }  // namespace
 
 #if defined(WEBRTC_VIDEOPROCESSOR_H264_TESTS)
@@ -39,7 +42,7 @@
   // Codec/network settings.
   CodecParams process_settings;
   SetCodecParams(&process_settings, kVideoCodecH264, kHwCodec, kUseSingleCore,
-                 0.0f, -1, 1, false, false, true, false);
+                 0.0f, -1, 1, false, false, true, false, kResilienceOn);
   // Thresholds for expected quality.
   QualityThresholds quality_thresholds;
   SetQualityThresholds(&quality_thresholds, 35.0, 25.0, 0.93, 0.70);
@@ -68,7 +71,7 @@
   // Codec/network settings.
   CodecParams process_settings;
   SetCodecParams(&process_settings, kVideoCodecVP9, kHwCodec, kUseSingleCore,
-                 0.0f, -1, 1, false, false, true, false);
+                 0.0f, -1, 1, false, false, true, false, kResilienceOn);
   // Thresholds for expected quality.
   QualityThresholds quality_thresholds;
   SetQualityThresholds(&quality_thresholds, 37.0, 36.0, 0.93, 0.92);
@@ -90,7 +93,7 @@
   // Codec/network settings.
   CodecParams process_settings;
   SetCodecParams(&process_settings, kVideoCodecVP9, kHwCodec, kUseSingleCore,
-                 0.05f, -1, 1, false, false, true, false);
+                 0.05f, -1, 1, false, false, true, false, kResilienceOn);
   // Thresholds for expected quality.
   QualityThresholds quality_thresholds;
   SetQualityThresholds(&quality_thresholds, 17.0, 14.0, 0.45, 0.36);
@@ -116,7 +119,7 @@
   // Codec/network settings.
   CodecParams process_settings;
   SetCodecParams(&process_settings, kVideoCodecVP9, kHwCodec, kUseSingleCore,
-                 0.0f, -1, 1, false, false, true, false);
+                 0.0f, -1, 1, false, false, true, false, kResilienceOn);
   // Thresholds for expected quality.
   QualityThresholds quality_thresholds;
   SetQualityThresholds(&quality_thresholds, 35.5, 30.0, 0.90, 0.85);
@@ -149,7 +152,7 @@
   // Codec/network settings.
   CodecParams process_settings;
   SetCodecParams(&process_settings, kVideoCodecVP9, kHwCodec, kUseSingleCore,
-                 0.0f, -1, 1, false, false, true, false);
+                 0.0f, -1, 1, false, false, true, false, kResilienceOn);
   // Thresholds for expected quality.
   QualityThresholds quality_thresholds;
   SetQualityThresholds(&quality_thresholds, 31.5, 18.0, 0.80, 0.43);
@@ -172,7 +175,7 @@
   // Codec/network settings.
   CodecParams process_settings;
   SetCodecParams(&process_settings, kVideoCodecVP9, kHwCodec, kUseSingleCore,
-                 0.0f, -1, 1, false, true, true, false);
+                 0.0f, -1, 1, false, true, true, false, kResilienceOn);
   // Thresholds for expected quality.
   QualityThresholds quality_thresholds;
   SetQualityThresholds(&quality_thresholds, 36.8, 35.8, 0.92, 0.91);
@@ -197,7 +200,7 @@
   // Codec/network settings.
   CodecParams process_settings;
   SetCodecParams(&process_settings, kVideoCodecVP9, kHwCodec, kUseSingleCore,
-                 0.0f, -1, 1, false, false, true, true);
+                 0.0f, -1, 1, false, false, true, true, kResilienceOn);
   // Thresholds for expected quality.
   QualityThresholds quality_thresholds;
   SetQualityThresholds(&quality_thresholds, 24.0, 13.0, 0.65, 0.37);
@@ -225,7 +228,7 @@
   // Codec/network settings.
   CodecParams process_settings;
   SetCodecParams(&process_settings, kVideoCodecVP8, kHwCodec, kUseSingleCore,
-                 0.0f, -1, 1, false, true, true, false);
+                 0.0f, -1, 1, false, true, true, false, kResilienceOn);
   // Thresholds for expected quality.
   QualityThresholds quality_thresholds;
   SetQualityThresholds(&quality_thresholds, 34.95, 33.0, 0.90, 0.89);
@@ -247,7 +250,7 @@
   // Codec/network settings.
   CodecParams process_settings;
   SetCodecParams(&process_settings, kVideoCodecVP8, kHwCodec, kUseSingleCore,
-                 0.05f, -1, 1, false, true, true, false);
+                 0.05f, -1, 1, false, true, true, false, kResilienceOn);
   // Thresholds for expected quality.
   QualityThresholds quality_thresholds;
   SetQualityThresholds(&quality_thresholds, 20.0, 16.0, 0.60, 0.40);
@@ -269,7 +272,7 @@
   // Codec/network settings.
   CodecParams process_settings;
   SetCodecParams(&process_settings, kVideoCodecVP8, kHwCodec, kUseSingleCore,
-                 0.1f, -1, 1, false, true, true, false);
+                 0.1f, -1, 1, false, true, true, false, kResilienceOn);
   // Thresholds for expected quality.
   QualityThresholds quality_thresholds;
   SetQualityThresholds(&quality_thresholds, 19.0, 16.0, 0.50, 0.35);
@@ -293,8 +296,9 @@
   // Codec/network settings.
   CodecParams process_settings;
   SetCodecParams(&process_settings, kVideoCodecVP8, kHwCodec, kUseSingleCore,
-                 0.0f, -1, 1, false, true, true, false, 352, 288, "foreman_cif",
-                 false /* verbose_logging */, true /* batch_mode */);
+                 0.0f, -1, 1, false, true, true, false, kResilienceOn, 352, 288,
+                 "foreman_cif", false /* verbose_logging */,
+                 true /* batch_mode */);
   // Thresholds for expected quality.
   QualityThresholds quality_thresholds;
   SetQualityThresholds(&quality_thresholds, 34.95, 33.0, 0.90, 0.89);
@@ -338,7 +342,7 @@
   // Codec/network settings.
   CodecParams process_settings;
   SetCodecParams(&process_settings, kVideoCodecVP8, kHwCodec, kUseSingleCore,
-                 0.0f, -1, 1, false, true, true, false);
+                 0.0f, -1, 1, false, true, true, false, kResilienceOn);
   // Thresholds for expected quality.
   QualityThresholds quality_thresholds;
   SetQualityThresholds(&quality_thresholds, 34.0, 32.0, 0.85, 0.80);
@@ -379,7 +383,7 @@
   // Codec/network settings.
   CodecParams process_settings;
   SetCodecParams(&process_settings, kVideoCodecVP8, kHwCodec, kUseSingleCore,
-                 0.0f, -1, 1, false, true, true, false);
+                 0.0f, -1, 1, false, true, true, false, kResilienceOn);
   // Thresholds for expected quality.
   QualityThresholds quality_thresholds;
   SetQualityThresholds(&quality_thresholds, 31.0, 22.0, 0.80, 0.65);
@@ -415,7 +419,7 @@
   // Codec/network settings.
   CodecParams process_settings;
   SetCodecParams(&process_settings, kVideoCodecVP8, kHwCodec, kUseSingleCore,
-                 0.0f, -1, 3, false, true, true, false);
+                 0.0f, -1, 3, false, true, true, false, kResilienceOn);
   // Thresholds for expected quality.
   QualityThresholds quality_thresholds;
   SetQualityThresholds(&quality_thresholds, 32.5, 30.0, 0.85, 0.80);
diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.h b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.h
index 6192ab8..d978b65 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.h
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.h
@@ -81,6 +81,7 @@
   bool denoising_on;
   bool frame_dropper_on;
   bool spatial_resize_on;
+  bool resilience_on;
 
   float packet_loss_probability;  // [0.0, 1.0].
 
@@ -282,6 +283,8 @@
         config_.codec_settings->VP8()->automaticResizeOn =
             process.spatial_resize_on;
         config_.codec_settings->VP8()->keyFrameInterval = kBaseKeyFrameInterval;
+        config_.codec_settings->VP8()->resilience =
+            process.resilience_on ? kResilientStream : kResilienceOff;
         break;
       case kVideoCodecVP9:
         config_.codec_settings->VP9()->denoisingOn = process.denoising_on;
@@ -292,6 +295,7 @@
         config_.codec_settings->VP9()->automaticResizeOn =
             process.spatial_resize_on;
         config_.codec_settings->VP9()->keyFrameInterval = kBaseKeyFrameInterval;
+        config_.codec_settings->VP9()->resilienceOn = process.resilience_on;
         break;
       default:
         RTC_NOTREACHED();
@@ -696,6 +700,7 @@
                              bool denoising_on,
                              bool frame_dropper_on,
                              bool spatial_resize_on,
+                             bool resilience_on,
                              int width,
                              int height,
                              const std::string& filename,
@@ -711,6 +716,7 @@
     process_settings->denoising_on = denoising_on;
     process_settings->frame_dropper_on = frame_dropper_on;
     process_settings->spatial_resize_on = spatial_resize_on;
+    process_settings->resilience_on = resilience_on;
     process_settings->width = width;
     process_settings->height = height;
     process_settings->filename = filename;
@@ -728,13 +734,14 @@
                              bool error_concealment_on,
                              bool denoising_on,
                              bool frame_dropper_on,
-                             bool spatial_resize_on) {
+                             bool spatial_resize_on,
+                             bool resilience_on) {
     SetCodecParams(process_settings, codec_type, hw_codec, use_single_core,
                    packet_loss_probability, key_frame_interval,
                    num_temporal_layers, error_concealment_on, denoising_on,
-                   frame_dropper_on, spatial_resize_on, kCifWidth, kCifHeight,
-                   kFilenameForemanCif, false /* verbose_logging */,
-                   false /* batch_mode */);
+                   frame_dropper_on, spatial_resize_on, resilience_on,
+                   kCifWidth, kCifHeight, kFilenameForemanCif,
+                   false /* verbose_logging */, false /* batch_mode */);
   }
 
   static void SetQualityThresholds(QualityThresholds* quality_thresholds,
diff --git a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
index b09f5d8..064e081 100644
--- a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
+++ b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
@@ -297,7 +297,7 @@
   config_->g_w = codec_.width;
   config_->g_h = codec_.height;
   config_->rc_target_bitrate = inst->startBitrate;  // in kbit/s
-  config_->g_error_resilient = 1;
+  config_->g_error_resilient = inst->VP9().resilienceOn ? 1 : 0;
   // Setting the time base of the codec.
   config_->g_timebase.num = 1;
   config_->g_timebase.den = 90000;