Add option to disable EXPECT_EQ's in VideoProcessor integration tests.

Since HW codecs are not as well-behaved as SW codecs, we need a
way to disable the EXPECT_EQ's in the VideoProcessor integration tests
for the former. This CL introduces such an ability.

BUG=webrtc:6634

Review-Url: https://codereview.webrtc.org/2710913004
Cr-Commit-Position: refs/heads/master@{#17166}
This commit is contained in:
brandtr
2017-03-10 05:34:01 -08:00
committed by Commit bot
parent 2ad5e38709
commit 60dcda4943
2 changed files with 38 additions and 21 deletions

View File

@ -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_;

View File

@ -13,6 +13,7 @@
#include <math.h>
#include <limits>
#include <memory>
#include <string>
#include <utility>
@ -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<double>::min();
double min_min_psnr = std::numeric_limits<double>::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<RateControlThresholds>&, 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,