Add SetCodecSettings method for configuring VideoCodec settings.
Remove video codec settings from CodecParams (and rename to ProcessParams).
Removes intermediate step of configuring video settings via CodecParams.
BUG=webrtc:6634
Review-Url: https://codereview.webrtc.org/2956243002
Cr-Commit-Position: refs/heads/master@{#18830}
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 42f0e69..d082985 100644
--- a/webrtc/modules/video_coding/codecs/test/plot_videoprocessor_integrationtest.cc
+++ b/webrtc/modules/video_coding/codecs/test/plot_videoprocessor_integrationtest.cc
@@ -17,6 +17,8 @@
// Codec settings.
const int kBitrates[] = {30, 50, 100, 200, 300, 500, 1000};
const int kFps[] = {30};
+const int kNumTemporalLayers = 1;
+const int kKeyFrameInterval = -1;
const bool kErrorConcealmentOn = false;
const bool kDenoisingOn = false;
const bool kFrameDropperOn = true;
@@ -65,13 +67,13 @@
rate_profile.num_frames = kNumFramesLong;
// Codec/network settings.
- CodecParams process_settings;
- SetCodecParams(
- &process_settings, codec_type_, kHwCodec, kUseSingleCore, kPacketLoss,
- -1, // key_frame_interval
- 1, // num_temporal_layers
- kErrorConcealmentOn, kDenoisingOn, kFrameDropperOn, kSpatialResizeOn,
- kResilienceOn, width, height, filename, kVerboseLogging, kBatchMode);
+ ProcessParams process_settings(kHwCodec, kUseSingleCore, kPacketLoss,
+ kKeyFrameInterval, filename, kVerboseLogging,
+ kBatchMode);
+ SetCodecSettings(&config_, &codec_settings_, codec_type_,
+ kNumTemporalLayers, kErrorConcealmentOn, kDenoisingOn,
+ kFrameDropperOn, kSpatialResizeOn, kResilienceOn, width,
+ height);
// 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 21fd67f..9b8b72a 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor.cc
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor.cc
@@ -99,23 +99,6 @@
}
}
-TestConfig::TestConfig()
- : name(""),
- description(""),
- test_number(0),
- input_filename(""),
- output_filename(""),
- output_dir("out"),
- networking_config(),
- exclude_frame_types(kExcludeOnlyFirstKeyFrame),
- frame_length_in_bytes(0),
- use_single_core(false),
- keyframe_interval(0),
- codec_settings(nullptr),
- verbose(true) {}
-
-TestConfig::~TestConfig() {}
-
VideoProcessorImpl::VideoProcessorImpl(webrtc::VideoEncoder* encoder,
webrtc::VideoDecoder* decoder,
FrameReader* analysis_frame_reader,
diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor.h b/webrtc/modules/video_coding/codecs/test/videoprocessor.h
index 1177772..cb15912 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor.h
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor.h
@@ -49,22 +49,18 @@
// Test configuration for a test run.
struct TestConfig {
- TestConfig();
- ~TestConfig();
-
- // Name of the test. This is purely metadata and does not affect
- // the test in any way.
+ // Name of the test. This is purely metadata and does not affect the test.
std::string name;
// More detailed description of the test. This is purely metadata and does
- // not affect the test in any way.
+ // not affect the test.
std::string description;
// Number of this test. Useful if multiple runs of the same test with
// different configurations shall be managed.
- int test_number;
+ int test_number = 0;
- // File to process for the test. This must be a video file in the YUV format.
+ // File to process. This must be a video file in the YUV format.
std::string input_filename;
// File to write to during processing for the test. Will be a video file
@@ -72,20 +68,20 @@
std::string output_filename;
// Path to the directory where encoded files will be put
- // (absolute or relative to the executable). Default: "out".
- std::string output_dir;
+ // (absolute or relative to the executable).
+ std::string output_dir = "out";
// Configurations related to networking.
NetworkingConfig networking_config;
// Decides how the packet loss simulations shall exclude certain frames
- // from packet loss. Default: kExcludeOnlyFirstKeyFrame.
- ExcludeFrameTypes exclude_frame_types;
+ // from packet loss.
+ ExcludeFrameTypes exclude_frame_types = kExcludeOnlyFirstKeyFrame;
// The length of a single frame of the input video file. This value is
// calculated out of the width and height according to the video format
// specification. Must be set before processing.
- size_t frame_length_in_bytes;
+ size_t frame_length_in_bytes = 0;
// Force the encoder and decoder to use a single core for processing.
// Using a single core is necessary to get a deterministic behavior for the
@@ -93,8 +89,7 @@
// since multiple cores are competing to consume the byte budget for each
// frame in parallel.
// If set to false, the maximum number of available cores will be used.
- // Default: false.
- bool use_single_core;
+ bool use_single_core = false;
// If set to a value >0 this setting forces the encoder to create a keyframe
// every Nth frame. Note that the encoder may create a keyframe in other
@@ -102,16 +97,15 @@
// Forcing key frames may also affect encoder planning optimizations in
// a negative way, since it will suddenly be forced to produce an expensive
// key frame.
- // Default: 0.
- int keyframe_interval;
+ int keyframe_interval = 0;
// The codec settings to use for the test (target bitrate, video size,
// framerate and so on). This struct must be created and filled in using
// the VideoCodingModule::Codec() method.
- webrtc::VideoCodec* codec_settings;
+ webrtc::VideoCodec* codec_settings = nullptr;
// If printing of information to stdout shall be performed during processing.
- bool verbose;
+ bool verbose = true;
};
// Handles encoding/decoding of video using the VideoEncoder/VideoDecoder
@@ -141,10 +135,10 @@
// Processes a single frame. Returns true as long as there's more frames
// available in the source clip.
- // Frame number must be an integer >= 0.
+ // |frame_number| must be an integer >= 0.
virtual bool ProcessFrame(int frame_number) = 0;
- // Updates the encoder with the target bit rate and the frame rate.
+ // Updates the encoder with the target |bit_rate| and the |frame_rate|.
virtual void SetRates(int bit_rate, int frame_rate) = 0;
// Return the size of the encoded frame in bytes. Dropped frames by the
diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc
index 7ea594e..ee6c2f2 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc
@@ -17,6 +17,8 @@
// In these correctness tests, we only consider SW codecs.
const bool kHwCodec = false;
+const bool kBatchMode = false;
+const bool kVerboseLogging = false;
// Only allow encoder/decoder to use single core, for predictability.
const bool kUseSingleCore = true;
@@ -24,6 +26,11 @@
// Default codec setting is on.
const bool kResilienceOn = true;
+// Default sequence is foreman (CIF): may be better to use VGA for resize test.
+const int kCifWidth = 352;
+const int kCifHeight = 288;
+const char kForemanCif[] = "foreman_cif";
+
} // namespace
#if defined(WEBRTC_VIDEOPROCESSOR_H264_TESTS)
@@ -40,9 +47,10 @@
rate_profile.frame_index_rate_update[1] = kNumFramesShort + 1;
rate_profile.num_frames = kNumFramesShort;
// Codec/network settings.
- CodecParams process_settings;
- SetCodecParams(&process_settings, kVideoCodecH264, kHwCodec, kUseSingleCore,
- 0.0f, -1, 1, false, false, true, false, kResilienceOn);
+ ProcessParams process_settings(kHwCodec, kUseSingleCore, 0.0f, -1,
+ kForemanCif, kVerboseLogging, kBatchMode);
+ SetCodecSettings(&config_, &codec_settings_, kVideoCodecH264, 1, false, false,
+ true, false, kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds;
SetQualityThresholds(&quality_thresholds, 35.0, 25.0, 0.93, 0.70);
@@ -69,9 +77,10 @@
rate_profile.frame_index_rate_update[1] = kNumFramesShort + 1;
rate_profile.num_frames = kNumFramesShort;
// Codec/network settings.
- CodecParams process_settings;
- SetCodecParams(&process_settings, kVideoCodecVP9, kHwCodec, kUseSingleCore,
- 0.0f, -1, 1, false, false, true, false, kResilienceOn);
+ ProcessParams process_settings(kHwCodec, kUseSingleCore, 0.0f, -1,
+ kForemanCif, kVerboseLogging, kBatchMode);
+ SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP9, 1, false, false,
+ true, false, kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds;
SetQualityThresholds(&quality_thresholds, 37.0, 36.0, 0.93, 0.92);
@@ -91,9 +100,10 @@
rate_profile.frame_index_rate_update[1] = kNumFramesShort + 1;
rate_profile.num_frames = kNumFramesShort;
// Codec/network settings.
- CodecParams process_settings;
- SetCodecParams(&process_settings, kVideoCodecVP9, kHwCodec, kUseSingleCore,
- 0.05f, -1, 1, false, false, true, false, kResilienceOn);
+ ProcessParams process_settings(kHwCodec, kUseSingleCore, 0.05f, -1,
+ kForemanCif, kVerboseLogging, kBatchMode);
+ SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP9, 1, false, false,
+ true, false, kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds;
SetQualityThresholds(&quality_thresholds, 17.0, 14.0, 0.45, 0.36);
@@ -117,9 +127,10 @@
rate_profile.frame_index_rate_update[3] = kNumFramesLong + 1;
rate_profile.num_frames = kNumFramesLong;
// Codec/network settings.
- CodecParams process_settings;
- SetCodecParams(&process_settings, kVideoCodecVP9, kHwCodec, kUseSingleCore,
- 0.0f, -1, 1, false, false, true, false, kResilienceOn);
+ ProcessParams process_settings(kHwCodec, kUseSingleCore, 0.0f, -1,
+ kForemanCif, kVerboseLogging, kBatchMode);
+ SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP9, 1, false, false,
+ true, false, kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds;
SetQualityThresholds(&quality_thresholds, 35.5, 30.0, 0.90, 0.85);
@@ -150,9 +161,10 @@
rate_profile.frame_index_rate_update[3] = kNumFramesLong + 1;
rate_profile.num_frames = kNumFramesLong;
// Codec/network settings.
- CodecParams process_settings;
- SetCodecParams(&process_settings, kVideoCodecVP9, kHwCodec, kUseSingleCore,
- 0.0f, -1, 1, false, false, true, false, kResilienceOn);
+ ProcessParams process_settings(kHwCodec, kUseSingleCore, 0.0f, -1,
+ kForemanCif, kVerboseLogging, kBatchMode);
+ SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP9, 1, false, false,
+ true, false, kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds;
SetQualityThresholds(&quality_thresholds, 31.5, 18.0, 0.80, 0.43);
@@ -173,9 +185,10 @@
rate_profile.frame_index_rate_update[1] = kNumFramesShort + 1;
rate_profile.num_frames = kNumFramesShort;
// Codec/network settings.
- CodecParams process_settings;
- SetCodecParams(&process_settings, kVideoCodecVP9, kHwCodec, kUseSingleCore,
- 0.0f, -1, 1, false, true, true, false, kResilienceOn);
+ ProcessParams process_settings(kHwCodec, kUseSingleCore, 0.0f, -1,
+ kForemanCif, kVerboseLogging, kBatchMode);
+ SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP9, 1, false, true,
+ true, false, kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds;
SetQualityThresholds(&quality_thresholds, 36.8, 35.8, 0.92, 0.91);
@@ -198,9 +211,10 @@
rate_profile.frame_index_rate_update[1] = kNumFramesLong + 1;
rate_profile.num_frames = kNumFramesLong;
// Codec/network settings.
- CodecParams process_settings;
- SetCodecParams(&process_settings, kVideoCodecVP9, kHwCodec, kUseSingleCore,
- 0.0f, -1, 1, false, false, true, true, kResilienceOn);
+ ProcessParams process_settings(kHwCodec, kUseSingleCore, 0.0f, -1,
+ kForemanCif, kVerboseLogging, kBatchMode);
+ SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP9, 1, false, false,
+ true, true, kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds;
SetQualityThresholds(&quality_thresholds, 24.0, 13.0, 0.65, 0.37);
@@ -226,9 +240,10 @@
rate_profile.frame_index_rate_update[1] = kNumFramesShort + 1;
rate_profile.num_frames = kNumFramesShort;
// Codec/network settings.
- CodecParams process_settings;
- SetCodecParams(&process_settings, kVideoCodecVP8, kHwCodec, kUseSingleCore,
- 0.0f, -1, 1, false, true, true, false, kResilienceOn);
+ ProcessParams process_settings(kHwCodec, kUseSingleCore, 0.0f, -1,
+ kForemanCif, kVerboseLogging, kBatchMode);
+ SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP8, 1, false, true,
+ true, false, kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds;
SetQualityThresholds(&quality_thresholds, 34.95, 33.0, 0.90, 0.89);
@@ -248,9 +263,10 @@
rate_profile.frame_index_rate_update[1] = kNumFramesShort + 1;
rate_profile.num_frames = kNumFramesShort;
// Codec/network settings.
- CodecParams process_settings;
- SetCodecParams(&process_settings, kVideoCodecVP8, kHwCodec, kUseSingleCore,
- 0.05f, -1, 1, false, true, true, false, kResilienceOn);
+ ProcessParams process_settings(kHwCodec, kUseSingleCore, 0.05f, -1,
+ kForemanCif, kVerboseLogging, kBatchMode);
+ SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP8, 1, false, true,
+ true, false, kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds;
SetQualityThresholds(&quality_thresholds, 20.0, 16.0, 0.60, 0.40);
@@ -270,9 +286,10 @@
rate_profile.frame_index_rate_update[1] = kNumFramesShort + 1;
rate_profile.num_frames = kNumFramesShort;
// Codec/network settings.
- CodecParams process_settings;
- SetCodecParams(&process_settings, kVideoCodecVP8, kHwCodec, kUseSingleCore,
- 0.1f, -1, 1, false, true, true, false, kResilienceOn);
+ ProcessParams process_settings(kHwCodec, kUseSingleCore, 0.1f, -1,
+ kForemanCif, kVerboseLogging, kBatchMode);
+ SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP8, 1, false, true,
+ true, false, kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds;
SetQualityThresholds(&quality_thresholds, 19.0, 16.0, 0.50, 0.35);
@@ -294,11 +311,11 @@
rate_profile.frame_index_rate_update[1] = kNumFramesShort + 1;
rate_profile.num_frames = kNumFramesShort;
// Codec/network settings.
- CodecParams process_settings;
- SetCodecParams(&process_settings, kVideoCodecVP8, kHwCodec, kUseSingleCore,
- 0.0f, -1, 1, false, true, true, false, kResilienceOn, 352, 288,
- "foreman_cif", false /* verbose_logging */,
- true /* batch_mode */);
+ ProcessParams process_settings(kHwCodec, kUseSingleCore, 0.0f, -1,
+ kForemanCif, kVerboseLogging,
+ true /* batch_mode */);
+ SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP8, 1, false, true,
+ true, false, kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds;
SetQualityThresholds(&quality_thresholds, 34.95, 33.0, 0.90, 0.89);
@@ -340,9 +357,10 @@
rate_profile.frame_index_rate_update[3] = kNumFramesLong + 1;
rate_profile.num_frames = kNumFramesLong;
// Codec/network settings.
- CodecParams process_settings;
- SetCodecParams(&process_settings, kVideoCodecVP8, kHwCodec, kUseSingleCore,
- 0.0f, -1, 1, false, true, true, false, kResilienceOn);
+ ProcessParams process_settings(kHwCodec, kUseSingleCore, 0.0f, -1,
+ kForemanCif, kVerboseLogging, kBatchMode);
+ SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP8, 1, false, true,
+ true, false, kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds;
SetQualityThresholds(&quality_thresholds, 34.0, 32.0, 0.85, 0.80);
@@ -381,9 +399,10 @@
rate_profile.frame_index_rate_update[3] = kNumFramesLong + 1;
rate_profile.num_frames = kNumFramesLong;
// Codec/network settings.
- CodecParams process_settings;
- SetCodecParams(&process_settings, kVideoCodecVP8, kHwCodec, kUseSingleCore,
- 0.0f, -1, 1, false, true, true, false, kResilienceOn);
+ ProcessParams process_settings(kHwCodec, kUseSingleCore, 0.0f, -1,
+ kForemanCif, kVerboseLogging, kBatchMode);
+ SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP8, 1, false, true,
+ true, false, kResilienceOn, kCifWidth, kCifHeight);
// Thresholds for expected quality.
QualityThresholds quality_thresholds;
SetQualityThresholds(&quality_thresholds, 31.0, 22.0, 0.80, 0.65);
@@ -417,9 +436,10 @@
rate_profile.frame_index_rate_update[2] = kNumFramesLong + 1;
rate_profile.num_frames = kNumFramesLong;
// Codec/network settings.
- CodecParams process_settings;
- SetCodecParams(&process_settings, kVideoCodecVP8, kHwCodec, kUseSingleCore,
- 0.0f, -1, 3, false, true, true, false, kResilienceOn);
+ ProcessParams process_settings(kHwCodec, kUseSingleCore, 0.0f, -1,
+ kForemanCif, kVerboseLogging, kBatchMode);
+ SetCodecSettings(&config_, &codec_settings_, kVideoCodecVP8, 3, false, true,
+ true, false, kResilienceOn, kCifWidth, kCifHeight);
// 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 5c275aa..8c19ae5 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.h
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.h
@@ -61,30 +61,27 @@
const int kPercTargetvsActualMismatch = 20;
const int kBaseKeyFrameInterval = 3000;
-// Default sequence is foreman (CIF): may be better to use VGA for resize test.
-const int kCifWidth = 352;
-const int kCifHeight = 288;
-const char kFilenameForemanCif[] = "foreman_cif";
+// Process and network settings.
+struct ProcessParams {
+ ProcessParams(bool hw_codec,
+ bool use_single_core,
+ float packet_loss_probability,
+ int key_frame_interval,
+ std::string filename,
+ bool verbose_logging,
+ bool batch_mode)
+ : hw_codec(hw_codec),
+ use_single_core(use_single_core),
+ key_frame_interval(key_frame_interval),
+ packet_loss_probability(packet_loss_probability),
+ filename(filename),
+ verbose_logging(verbose_logging),
+ batch_mode(batch_mode) {}
-// Codec and network settings.
-struct CodecParams {
- VideoCodecType codec_type;
bool hw_codec;
bool use_single_core;
-
- int width;
- int height;
-
- int num_temporal_layers;
int key_frame_interval;
- bool error_concealment_on;
- bool denoising_on;
- bool frame_dropper_on;
- bool spatial_resize_on;
- bool resilience_on;
-
float packet_loss_probability; // [0.0, 1.0].
-
std::string filename;
bool verbose_logging;
@@ -169,7 +166,7 @@
}
virtual ~VideoProcessorIntegrationTest() = default;
- void CreateEncoderAndDecoder(bool hw_codec, VideoCodecType codec_type) {
+ void CreateEncoderAndDecoder(bool hw_codec) {
if (hw_codec) {
#if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED)
#if defined(WEBRTC_ANDROID)
@@ -177,7 +174,7 @@
// allocated them. For the particular case of the Android
// MediaCodecVideo{En,De}coderFactory's, however, it turns out that it is
// fine for the std::unique_ptr to destroy the owned codec directly.
- switch (codec_type) {
+ switch (config_.codec_settings->codecType) {
case kVideoCodecH264:
encoder_.reset(external_encoder_factory_->CreateVideoEncoder(
cricket::VideoCodec(cricket::kH264CodecName)));
@@ -201,7 +198,7 @@
break;
}
#elif defined(WEBRTC_IOS)
- ASSERT_EQ(kVideoCodecH264, codec_type)
+ ASSERT_EQ(kVideoCodecH264, config_.codec_settings->codecType)
<< "iOS HW codecs only support H264.";
encoder_.reset(new H264VideoToolboxEncoder(
cricket::VideoCodec(cricket::kH264CodecName)));
@@ -216,7 +213,7 @@
}
// SW codecs.
- switch (codec_type) {
+ switch (config_.codec_settings->codecType) {
case kVideoCodecH264:
encoder_.reset(
H264Encoder::Create(cricket::VideoCodec(cricket::kH264CodecName)));
@@ -236,9 +233,9 @@
}
}
- void SetUpCodecConfig(const CodecParams& process,
+ void SetUpCodecConfig(const ProcessParams& process,
const VisualizationParams* visualization_params) {
- CreateEncoderAndDecoder(process.hw_codec, process.codec_type);
+ CreateEncoderAndDecoder(process.hw_codec);
// Configure input filename.
config_.input_filename = test::ResourcePath(process.filename, "yuv");
@@ -249,58 +246,15 @@
test::OutputPath(), "videoprocessor_integrationtest");
config_.frame_length_in_bytes =
- CalcBufferSize(VideoType::kI420, process.width, process.height);
+ CalcBufferSize(VideoType::kI420, config_.codec_settings->width,
+ config_.codec_settings->height);
config_.verbose = process.verbose_logging;
config_.use_single_core = process.use_single_core;
+
// Key frame interval and packet loss are set for each test.
config_.keyframe_interval = process.key_frame_interval;
config_.networking_config.packet_loss_probability =
- packet_loss_probability_;
-
- // Configure codec settings.
- VideoCodingModule::Codec(process.codec_type, &codec_settings_);
- config_.codec_settings = &codec_settings_;
- config_.codec_settings->startBitrate = start_bitrate_;
- config_.codec_settings->width = process.width;
- config_.codec_settings->height = process.height;
-
- // These features may be set depending on the test.
- switch (config_.codec_settings->codecType) {
- case kVideoCodecH264:
- config_.codec_settings->H264()->frameDroppingOn =
- process.frame_dropper_on;
- config_.codec_settings->H264()->keyFrameInterval =
- kBaseKeyFrameInterval;
- break;
- case kVideoCodecVP8:
- config_.codec_settings->VP8()->errorConcealmentOn =
- process.error_concealment_on;
- config_.codec_settings->VP8()->denoisingOn = process.denoising_on;
- config_.codec_settings->VP8()->numberOfTemporalLayers =
- num_temporal_layers_;
- config_.codec_settings->VP8()->frameDroppingOn =
- process.frame_dropper_on;
- 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;
- config_.codec_settings->VP9()->numberOfTemporalLayers =
- num_temporal_layers_;
- config_.codec_settings->VP9()->frameDroppingOn =
- process.frame_dropper_on;
- 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();
- break;
- }
+ process.packet_loss_probability;
// Create file objects for quality analysis.
analysis_frame_reader_.reset(new test::YuvFrameReaderImpl(
@@ -316,10 +270,12 @@
// clang-format off
const std::string output_filename_base =
test::OutputPath() + process.filename +
- "_cd-" + CodecTypeToPayloadName(process.codec_type).value_or("") +
+ "_cd-" + CodecTypeToPayloadName(
+ config_.codec_settings->codecType).value_or("") +
"_hw-" + std::to_string(process.hw_codec) +
"_fr-" + std::to_string(start_frame_rate_) +
- "_br-" + std::to_string(static_cast<int>(start_bitrate_));
+ "_br-" + std::to_string(
+ static_cast<int>(config_.codec_settings->startBitrate));
// clang-format on
if (visualization_params->save_source_y4m) {
source_frame_writer_.reset(new test::Y4mFrameWriterImpl(
@@ -498,14 +454,25 @@
EXPECT_GT(ssim_result.min, quality_thresholds.min_min_ssim);
}
- void VerifyQpParser(const CodecParams& process, int frame_number) {
- if (!process.hw_codec && (process.codec_type == kVideoCodecVP8 ||
- process.codec_type == kVideoCodecVP9)) {
+ void VerifyQpParser(const ProcessParams& process, int frame_number) {
+ if (!process.hw_codec &&
+ (config_.codec_settings->codecType == kVideoCodecVP8 ||
+ config_.codec_settings->codecType == kVideoCodecVP9)) {
EXPECT_EQ(processor_->GetQpFromEncoder(frame_number),
processor_->GetQpFromBitstream(frame_number));
}
}
+ int NumberOfTemporalLayers(const VideoCodec* codec_settings) {
+ if (codec_settings->codecType == kVideoCodecVP8) {
+ return codec_settings->VP8().numberOfTemporalLayers;
+ } else if (codec_settings->codecType == kVideoCodecVP9) {
+ return codec_settings->VP9().numberOfTemporalLayers;
+ } else {
+ return 1;
+ }
+ }
+
// Temporal layer index corresponding to frame number, for up to 3 layers.
int TemporalLayerIndexForFrame(int frame_number) {
int tl_idx = -1;
@@ -566,14 +533,14 @@
// e.g., when we are operating in batch mode.
void ProcessFramesAndVerify(QualityThresholds quality_thresholds,
RateProfile rate_profile,
- CodecParams process,
+ ProcessParams process,
RateControlThresholds* rc_thresholds,
const VisualizationParams* visualization_params) {
// Codec/config settings.
- start_bitrate_ = rate_profile.target_bit_rate[0];
+ RTC_CHECK(config_.codec_settings);
+ num_temporal_layers_ = NumberOfTemporalLayers(config_.codec_settings);
+ config_.codec_settings->startBitrate = rate_profile.target_bit_rate[0];
start_frame_rate_ = rate_profile.input_frame_rate[0];
- packet_loss_probability_ = process.packet_loss_probability;
- num_temporal_layers_ = process.num_temporal_layers;
SetUpCodecConfig(process, visualization_params);
// Update the temporal layers and the codec with the initial rates.
bit_rate_ = rate_profile.target_bit_rate[0];
@@ -689,59 +656,52 @@
}
}
- static void SetCodecParams(CodecParams* process_settings,
- VideoCodecType codec_type,
- bool hw_codec,
- bool use_single_core,
- float packet_loss_probability,
- int key_frame_interval,
- int num_temporal_layers,
- bool error_concealment_on,
- bool denoising_on,
- bool frame_dropper_on,
- bool spatial_resize_on,
- bool resilience_on,
- int width,
- int height,
- const std::string& filename,
- bool verbose_logging,
- bool batch_mode) {
- process_settings->codec_type = codec_type;
- process_settings->hw_codec = hw_codec;
- process_settings->use_single_core = use_single_core;
- process_settings->packet_loss_probability = packet_loss_probability;
- process_settings->key_frame_interval = key_frame_interval;
- process_settings->num_temporal_layers = num_temporal_layers,
- process_settings->error_concealment_on = error_concealment_on;
- 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;
- process_settings->verbose_logging = verbose_logging;
- process_settings->batch_mode = batch_mode;
- }
-
- static void SetCodecParams(CodecParams* process_settings,
- VideoCodecType codec_type,
- bool hw_codec,
- bool use_single_core,
- float packet_loss_probability,
- int key_frame_interval,
- int num_temporal_layers,
- bool error_concealment_on,
- bool denoising_on,
- bool frame_dropper_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, resilience_on,
- kCifWidth, kCifHeight, kFilenameForemanCif,
- false /* verbose_logging */, false /* batch_mode */);
+ static void SetCodecSettings(test::TestConfig* config,
+ VideoCodec* codec_settings,
+ VideoCodecType codec_type,
+ int num_temporal_layers,
+ bool error_concealment_on,
+ bool denoising_on,
+ bool frame_dropper_on,
+ bool spatial_resize_on,
+ bool resilience_on,
+ int width,
+ int height) {
+ VideoCodingModule::Codec(codec_type, codec_settings);
+ config->codec_settings = codec_settings;
+ config->codec_settings->width = width;
+ config->codec_settings->height = height;
+ switch (config->codec_settings->codecType) {
+ case kVideoCodecH264:
+ config->codec_settings->H264()->frameDroppingOn = frame_dropper_on;
+ config->codec_settings->H264()->keyFrameInterval =
+ kBaseKeyFrameInterval;
+ break;
+ case kVideoCodecVP8:
+ config->codec_settings->VP8()->errorConcealmentOn =
+ error_concealment_on;
+ config->codec_settings->VP8()->denoisingOn = denoising_on;
+ config->codec_settings->VP8()->numberOfTemporalLayers =
+ num_temporal_layers;
+ config->codec_settings->VP8()->frameDroppingOn = frame_dropper_on;
+ config->codec_settings->VP8()->automaticResizeOn = spatial_resize_on;
+ config->codec_settings->VP8()->keyFrameInterval = kBaseKeyFrameInterval;
+ config->codec_settings->VP8()->resilience =
+ resilience_on ? kResilientStream : kResilienceOff;
+ break;
+ case kVideoCodecVP9:
+ config->codec_settings->VP9()->denoisingOn = denoising_on;
+ config->codec_settings->VP9()->numberOfTemporalLayers =
+ num_temporal_layers;
+ config->codec_settings->VP9()->frameDroppingOn = frame_dropper_on;
+ config->codec_settings->VP9()->automaticResizeOn = spatial_resize_on;
+ config->codec_settings->VP9()->keyFrameInterval = kBaseKeyFrameInterval;
+ config->codec_settings->VP9()->resilienceOn = resilience_on;
+ break;
+ default:
+ RTC_NOTREACHED();
+ break;
+ }
}
static void SetQualityThresholds(QualityThresholds* quality_thresholds,
@@ -829,11 +789,9 @@
float target_size_key_frame_;
float sum_key_frame_size_mismatch_;
int num_key_frames_;
- float start_bitrate_;
int start_frame_rate_;
// Codec and network settings.
- float packet_loss_probability_;
int num_temporal_layers_;
};