diff --git a/webrtc/common_types.h b/webrtc/common_types.h index 424afd9139..c7428ffecf 100644 --- a/webrtc/common_types.h +++ b/webrtc/common_types.h @@ -480,7 +480,7 @@ struct VideoCodecVP8 { // VP9 specific. struct VideoCodecVP9 { VideoCodecComplexity complexity; - int resilience; + bool resilienceOn; unsigned char numberOfTemporalLayers; bool denoisingOn; bool frameDroppingOn; diff --git a/webrtc/modules/video_coding/codec_database.cc b/webrtc/modules/video_coding/codec_database.cc index 51152fd052..794e955723 100644 --- a/webrtc/modules/video_coding/codec_database.cc +++ b/webrtc/modules/video_coding/codec_database.cc @@ -44,7 +44,7 @@ VideoCodecVP9 VideoEncoder::GetDefaultVp9Settings() { 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 bd12b684b8..42f0e69e83 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 kErrorConcealmentOn = false; 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 @@ class PlotVideoProcessorIntegrationTest -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 f919ced617..b6f4b9d90f 100644 --- a/webrtc/modules/video_coding/codecs/test/videoprocessor.cc +++ b/webrtc/modules/video_coding/codecs/test/videoprocessor.cc @@ -74,7 +74,7 @@ void PrintCodecSettings(const VideoCodec* config) { } 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 7a127c904f..7ea594e5c1 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 @@ const bool kHwCodec = false; // 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 @@ TEST_F(VideoProcessorIntegrationTest, Process0PercentPacketLossH264) { // 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 @@ TEST_F(VideoProcessorIntegrationTest, Process0PercentPacketLossVP9) { // 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 @@ TEST_F(VideoProcessorIntegrationTest, Process5PercentPacketLossVP9) { // 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 @@ TEST_F(VideoProcessorIntegrationTest, ProcessNoLossChangeBitRateVP9) { // 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 @@ TEST_F(VideoProcessorIntegrationTest, // 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 @@ TEST_F(VideoProcessorIntegrationTest, ProcessNoLossDenoiserOnVP9) { // 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 @@ TEST_F(VideoProcessorIntegrationTest, // 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 @@ TEST_F(VideoProcessorIntegrationTest, ProcessZeroPacketLoss) { // 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 @@ TEST_F(VideoProcessorIntegrationTest, Process5PercentPacketLoss) { // 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 @@ TEST_F(VideoProcessorIntegrationTest, Process10PercentPacketLoss) { // 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 @@ TEST_F(VideoProcessorIntegrationTest, ProcessInBatchMode) { // 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 @@ TEST_F(VideoProcessorIntegrationTest, MAYBE_ProcessNoLossChangeBitRateVP8) { // 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 @@ TEST_F(VideoProcessorIntegrationTest, // 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 @@ TEST_F(VideoProcessorIntegrationTest, MAYBE_ProcessNoLossTemporalLayersVP8) { // 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 6192ab894a..d978b6508d 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 @@ struct CodecParams { 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 @@ class VideoProcessorIntegrationTest : public testing::Test { 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 @@ class VideoProcessorIntegrationTest : public testing::Test { 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 @@ class VideoProcessorIntegrationTest : public testing::Test { 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 @@ class VideoProcessorIntegrationTest : public testing::Test { 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 @@ class VideoProcessorIntegrationTest : public testing::Test { 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 b09f5d8077..064e0819fb 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 @@ int VP9EncoderImpl::InitEncode(const VideoCodec* inst, 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;