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 d11398b911..bd12b684b8 100644 --- a/webrtc/modules/video_coding/codecs/test/plot_videoprocessor_integrationtest.cc +++ b/webrtc/modules/video_coding/codecs/test/plot_videoprocessor_integrationtest.cc @@ -62,6 +62,7 @@ class PlotVideoProcessorIntegrationTest 0); // frame_index_rate_update rate_profile.frame_index_rate_update[1] = kNumFramesLong + 1; rate_profile.num_frames = kNumFramesLong; + // Codec/network settings. CodecParams process_settings; SetCodecParams( @@ -70,23 +71,30 @@ class PlotVideoProcessorIntegrationTest 1, // num_temporal_layers kErrorConcealmentOn, kDenoisingOn, kFrameDropperOn, kSpatialResizeOn, width, height, filename, kVerboseLogging, kBatchMode); - // Thresholds for expected quality (PSNR avg, PSNR min, SSIM avg, SSIM min). + + // Use default thresholds for quality (PSNR and SSIM). QualityThresholds quality_thresholds; - SetQualityThresholds(&quality_thresholds, 15.0, 10.0, 0.2, 0.1); - // Thresholds for rate control. + + // Use very loose thresholds for rate control, so even poor HW codecs will + // pass the requirements. RateControlThresholds rc_thresholds[1]; - SetRateControlThresholds(rc_thresholds, - 0, // update_index - 300, // max_num_dropped_frames, - 400, // max_key_frame_size_mismatch - 200, // max_delta_frame_size_mismatch - 100, // max_encoding_rate_mismatch - 300, // max_time_hit_target - 0, // num_spatial_resizes - 1); // num_key_frames + // clang-format off + SetRateControlThresholds( + rc_thresholds, + 0, // update_index + kNumFramesLong + 1, // max_num_dropped_frames + 10000, // max_key_frame_size_mismatch + 10000, // max_delta_frame_size_mismatch + 10000, // max_encoding_rate_mismatch + kNumFramesLong + 1, // max_time_hit_target + 0, // num_spatial_resizes + 1); // num_key_frames + // clang-format on + ProcessFramesAndVerify(quality_thresholds, rate_profile, process_settings, rc_thresholds, &kVisualizationParams); } + const int bitrate_; const int framerate_; const VideoCodecType codec_type_; diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.h b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.h index 672b1d2588..a3776186e1 100644 --- a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.h +++ b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.h @@ -13,6 +13,7 @@ #include +#include #include #include #include @@ -93,12 +94,12 @@ struct CodecParams { bool batch_mode; }; -// Thresholds for the quality metrics. +// Thresholds for the quality metrics. Defaults are maximally minimal. struct QualityThresholds { - double min_avg_psnr; - double min_min_psnr; - double min_avg_ssim; - double min_min_ssim; + double min_avg_psnr = std::numeric_limits::min(); + double min_min_psnr = std::numeric_limits::min(); + double min_avg_ssim = 0; + double min_min_ssim = 0; }; // The sequence of bit rate and frame rate changes for the encoder, the frame @@ -122,8 +123,8 @@ struct RateControlThresholds { int max_delta_frame_size_mismatch; int max_encoding_rate_mismatch; int max_time_hit_target; - int num_spatial_resizes; - int num_key_frames; + int num_spatial_resizes; // Set to -1 to disable check. + int num_key_frames; // Set to -1 to disable check. }; // Should video files be saved persistently to disk for post-run visualization? @@ -474,8 +475,12 @@ class VideoProcessorIntegrationTest : public testing::Test { printf("\n"); EXPECT_LE(num_frames_to_hit_target_, rc_expected.max_time_hit_target); EXPECT_LE(num_dropped_frames, rc_expected.max_num_dropped_frames); - EXPECT_EQ(rc_expected.num_spatial_resizes, num_resize_actions); - EXPECT_EQ(rc_expected.num_key_frames, num_key_frames_); + if (rc_expected.num_spatial_resizes >= 0) { + EXPECT_EQ(rc_expected.num_spatial_resizes, num_resize_actions); + } + if (rc_expected.num_key_frames >= 0) { + EXPECT_EQ(rc_expected.num_key_frames, num_key_frames_); + } } void VerifyQuality(const test::QualityMetricsResult& psnr_result, @@ -541,6 +546,10 @@ class VideoProcessorIntegrationTest : public testing::Test { } // Processes all frames in the clip and verifies the result. + // TODO(brandtr): Change the second last argument to be a + // const std::vector&, so we can ensure that the user + // does not expect us to do mid-clip rate updates when we are not able to, + // e.g., when we are operating in batch mode. void ProcessFramesAndVerify(QualityThresholds quality_thresholds, RateProfile rate_profile, CodecParams process,