VideoProcessorIntegrationTest: remove arrays in RateProfile and use vector of RateProfiles instead.
Move num_frames from RateProfile to TestConfig struct.
Remove methods: SetRateProfile, AddRateControlThresholds.
Bug: none
Change-Id: I14bcafb8c5b3c1d3b6119417dde038fd82381e3f
Reviewed-on: https://webrtc-review.googlesource.com/8540
Commit-Queue: Åsa Persson <asapersson@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20265}
diff --git a/modules/video_coding/codecs/test/videoprocessor.h b/modules/video_coding/codecs/test/videoprocessor.h
index cf96923..d02f220 100644
--- a/modules/video_coding/codecs/test/videoprocessor.h
+++ b/modules/video_coding/codecs/test/videoprocessor.h
@@ -64,6 +64,9 @@
// in the YUV format.
std::string output_filename;
+ // Number of frames to process.
+ int num_frames = 0;
+
// Configurations related to networking.
NetworkingConfig networking_config;
diff --git a/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc b/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc
index 7d9a81a..0802239 100644
--- a/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc
+++ b/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc
@@ -135,67 +135,32 @@
}
}
-void VideoProcessorIntegrationTest::SetRateProfile(
- RateProfile* rate_profile,
- int rate_update_index,
- int bitrate_kbps,
- int framerate_fps,
- int frame_index_rate_update) {
- rate_profile->target_bit_rate[rate_update_index] = bitrate_kbps;
- rate_profile->input_frame_rate[rate_update_index] = framerate_fps;
- rate_profile->frame_index_rate_update[rate_update_index] =
- frame_index_rate_update;
-}
-
-void VideoProcessorIntegrationTest::AddRateControlThresholds(
- int max_num_dropped_frames,
- int max_key_framesize_mismatch_percent,
- int max_delta_framesize_mismatch_percent,
- int max_bitrate_mismatch_percent,
- int max_num_frames_to_hit_target,
- int num_spatial_resizes,
- int num_key_frames,
- std::vector<RateControlThresholds>* rc_thresholds) {
- RTC_DCHECK(rc_thresholds);
-
- rc_thresholds->emplace_back();
- RateControlThresholds* rc_threshold = &rc_thresholds->back();
- rc_threshold->max_num_dropped_frames = max_num_dropped_frames;
- rc_threshold->max_key_framesize_mismatch_percent =
- max_key_framesize_mismatch_percent;
- rc_threshold->max_delta_framesize_mismatch_percent =
- max_delta_framesize_mismatch_percent;
- rc_threshold->max_bitrate_mismatch_percent = max_bitrate_mismatch_percent;
- rc_threshold->max_num_frames_to_hit_target = max_num_frames_to_hit_target;
- rc_threshold->num_spatial_resizes = num_spatial_resizes;
- rc_threshold->num_key_frames = num_key_frames;
-}
-
// Processes all frames in the clip and verifies the result.
void VideoProcessorIntegrationTest::ProcessFramesAndMaybeVerify(
- const RateProfile& rate_profile,
+ const std::vector<RateProfile>& rate_profiles,
const std::vector<RateControlThresholds>* rc_thresholds,
const QualityThresholds* quality_thresholds,
const BitstreamThresholds* bs_thresholds,
const VisualizationParams* visualization_params) {
+ RTC_DCHECK(!rate_profiles.empty());
// The Android HW codec needs to be run on a task queue, so we simply always
// run the test on a task queue.
rtc::TaskQueue task_queue("VidProc TQ");
rtc::Event sync_event(false, false);
- SetUpAndInitObjects(&task_queue, rate_profile.target_bit_rate[0],
- rate_profile.input_frame_rate[0], visualization_params);
+ SetUpAndInitObjects(&task_queue, rate_profiles[0].target_kbps,
+ rate_profiles[0].input_fps, visualization_params);
// Set initial rates.
int rate_update_index = 0;
- task_queue.PostTask([this, &rate_profile, rate_update_index] {
- processor_->SetRates(rate_profile.target_bit_rate[rate_update_index],
- rate_profile.input_frame_rate[rate_update_index]);
+ task_queue.PostTask([this, &rate_profiles, rate_update_index] {
+ processor_->SetRates(rate_profiles[rate_update_index].target_kbps,
+ rate_profiles[rate_update_index].input_fps);
});
// Process all frames.
int frame_number = 0;
- const int num_frames = rate_profile.num_frames;
+ const int num_frames = config_.num_frames;
RTC_DCHECK_GE(num_frames, 1);
while (frame_number < num_frames) {
// In order to not overwhelm the OpenMAX buffers in the Android
@@ -204,7 +169,7 @@
#if defined(WEBRTC_ANDROID)
if (config_.hw_encoder || config_.hw_decoder) {
SleepMs(rtc::kNumMillisecsPerSec /
- rate_profile.input_frame_rate[rate_update_index]);
+ rate_profiles[rate_update_index].input_fps);
}
#endif
@@ -212,12 +177,13 @@
++frame_number;
if (frame_number ==
- rate_profile.frame_index_rate_update[rate_update_index + 1]) {
+ rate_profiles[rate_update_index].frame_index_rate_update) {
++rate_update_index;
+ RTC_DCHECK_GT(rate_profiles.size(), rate_update_index);
- task_queue.PostTask([this, &rate_profile, rate_update_index] {
- processor_->SetRates(rate_profile.target_bit_rate[rate_update_index],
- rate_profile.input_frame_rate[rate_update_index]);
+ task_queue.PostTask([this, &rate_profiles, rate_update_index] {
+ processor_->SetRates(rate_profiles[rate_update_index].target_kbps,
+ rate_profiles[rate_update_index].input_fps);
});
}
}
@@ -243,7 +209,7 @@
rate_update_index = 0;
frame_number = 0;
- ResetRateControlMetrics(rate_update_index, rate_profile);
+ ResetRateControlMetrics(rate_update_index, rate_profiles);
while (frame_number < num_frames) {
UpdateRateControlMetrics(frame_number);
@@ -254,13 +220,13 @@
++frame_number;
if (frame_number ==
- rate_profile.frame_index_rate_update[rate_update_index + 1]) {
+ rate_profiles[rate_update_index].frame_index_rate_update) {
PrintRateControlMetrics(rate_update_index, num_dropped_frames,
num_spatial_resizes);
VerifyRateControlMetrics(rate_update_index, rc_thresholds,
num_dropped_frames, num_spatial_resizes);
++rate_update_index;
- ResetRateControlMetrics(rate_update_index, rate_profile);
+ ResetRateControlMetrics(rate_update_index, rate_profiles);
}
}
@@ -617,10 +583,11 @@
// Reset quantities before each encoder rate update.
void VideoProcessorIntegrationTest::ResetRateControlMetrics(
int rate_update_index,
- const RateProfile& rate_profile) {
+ const std::vector<RateProfile>& rate_profiles) {
+ RTC_DCHECK_GT(rate_profiles.size(), rate_update_index);
// Set new rates.
- target_.kbps = rate_profile.target_bit_rate[rate_update_index];
- target_.fps = rate_profile.input_frame_rate[rate_update_index];
+ target_.kbps = rate_profiles[rate_update_index].target_kbps;
+ target_.fps = rate_profiles[rate_update_index].input_fps;
SetRatesPerTemporalLayer();
// Set key frame target sizes.
@@ -642,7 +609,7 @@
// Reset rate control metrics.
actual_ = TestResults();
actual_.num_frames_to_hit_target = // Set to max number of frames.
- rate_profile.frame_index_rate_update[rate_update_index + 1];
+ rate_profiles[rate_update_index].frame_index_rate_update;
}
void VideoProcessorIntegrationTest::SetRatesPerTemporalLayer() {
diff --git a/modules/video_coding/codecs/test/videoprocessor_integrationtest.h b/modules/video_coding/codecs/test/videoprocessor_integrationtest.h
index d383915..740aed5 100644
--- a/modules/video_coding/codecs/test/videoprocessor_integrationtest.h
+++ b/modules/video_coding/codecs/test/videoprocessor_integrationtest.h
@@ -30,15 +30,11 @@
namespace webrtc {
namespace test {
-// The sequence of bit rate and frame rate changes for the encoder, the frame
-// number where the changes are made, and the total number of frames to process.
+// Rates for the encoder and the frame number when to change profile.
struct RateProfile {
- static const int kMaxNumRateUpdates = 3;
-
- int target_bit_rate[kMaxNumRateUpdates];
- int input_frame_rate[kMaxNumRateUpdates];
- int frame_index_rate_update[kMaxNumRateUpdates + 1];
- int num_frames;
+ int target_kbps;
+ int input_fps;
+ int frame_index_rate_update;
};
// Thresholds for the rate control metrics. The thresholds are defined for each
@@ -108,24 +104,8 @@
int width,
int height);
- static void SetRateProfile(RateProfile* rate_profile,
- int rate_update_index,
- int bitrate_kbps,
- int framerate_fps,
- int frame_index_rate_update);
-
- static void AddRateControlThresholds(
- int max_num_dropped_frames,
- int max_key_framesize_mismatch_percent,
- int max_delta_framesize_mismatch_percent,
- int max_bitrate_mismatch_percent,
- int max_num_frames_to_hit_target,
- int num_spatial_resizes,
- int num_key_frames,
- std::vector<RateControlThresholds>* rc_thresholds);
-
void ProcessFramesAndMaybeVerify(
- const RateProfile& rate_profile,
+ const std::vector<RateProfile>& rate_profiles,
const std::vector<RateControlThresholds>* rc_thresholds,
const QualityThresholds* quality_thresholds,
const BitstreamThresholds* bs_thresholds,
@@ -186,7 +166,7 @@
// Rate control metrics.
void ResetRateControlMetrics(int rate_update_index,
- const RateProfile& rate_profile);
+ const std::vector<RateProfile>& rate_profiles);
void SetRatesPerTemporalLayer();
void UpdateRateControlMetrics(int frame_number);
void PrintRateControlMetrics(
diff --git a/modules/video_coding/codecs/test/videoprocessor_integrationtest_libvpx.cc b/modules/video_coding/codecs/test/videoprocessor_integrationtest_libvpx.cc
index 3e43a76..7ba146e 100644
--- a/modules/video_coding/codecs/test/videoprocessor_integrationtest_libvpx.cc
+++ b/modules/video_coding/codecs/test/videoprocessor_integrationtest_libvpx.cc
@@ -40,6 +40,7 @@
config_.input_filename = ResourcePath(config_.filename, "yuv");
config_.output_filename =
TempFilename(OutputPath(), "videoprocessor_integrationtest_libvpx");
+ config_.num_frames = kNumFramesLong;
config_.networking_config.packet_loss_probability = 0.0;
// Only allow encoder/decoder to use single core, for predictability.
config_.use_single_core = true;
@@ -58,40 +59,38 @@
TEST_F(VideoProcessorIntegrationTestLibvpx, Process0PercentPacketLossVP9) {
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
+ config_.num_frames = kNumFramesShort;
- RateProfile rate_profile;
- SetRateProfile(&rate_profile, 0, 500, 30, 0);
- rate_profile.frame_index_rate_update[1] = kNumFramesShort + 1;
- rate_profile.num_frames = kNumFramesShort;
+ std::vector<RateProfile> rate_profiles = {{500, 30, kNumFramesShort + 1}};
- std::vector<RateControlThresholds> rc_thresholds;
- AddRateControlThresholds(0, 40, 20, 10, 20, 0, 1, &rc_thresholds);
+ std::vector<RateControlThresholds> rc_thresholds = {
+ {0, 40, 20, 10, 20, 0, 1}};
QualityThresholds quality_thresholds(37.0, 36.0, 0.93, 0.92);
- ProcessFramesAndMaybeVerify(rate_profile, &rc_thresholds, &quality_thresholds,
- nullptr, kNoVisualizationParams);
+ ProcessFramesAndMaybeVerify(rate_profiles, &rc_thresholds,
+ &quality_thresholds, nullptr,
+ kNoVisualizationParams);
}
// VP9: Run with 5% packet loss and fixed bitrate. Quality should be a bit
// lower. One key frame (first frame only) in sequence.
TEST_F(VideoProcessorIntegrationTestLibvpx, Process5PercentPacketLossVP9) {
config_.networking_config.packet_loss_probability = 0.05f;
+ config_.num_frames = kNumFramesShort;
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
- RateProfile rate_profile;
- SetRateProfile(&rate_profile, 0, 500, 30, 0);
- rate_profile.frame_index_rate_update[1] = kNumFramesShort + 1;
- rate_profile.num_frames = kNumFramesShort;
+ std::vector<RateProfile> rate_profiles = {{500, 30, kNumFramesShort + 1}};
- std::vector<RateControlThresholds> rc_thresholds;
- AddRateControlThresholds(0, 40, 20, 10, 20, 0, 1, &rc_thresholds);
+ std::vector<RateControlThresholds> rc_thresholds = {
+ {0, 40, 20, 10, 20, 0, 1}};
QualityThresholds quality_thresholds(17.0, 14.0, 0.45, 0.36);
- ProcessFramesAndMaybeVerify(rate_profile, &rc_thresholds, &quality_thresholds,
- nullptr, kNoVisualizationParams);
+ ProcessFramesAndMaybeVerify(rate_profiles, &rc_thresholds,
+ &quality_thresholds, nullptr,
+ kNoVisualizationParams);
}
// VP9: Run with no packet loss, with varying bitrate (3 rate updates):
@@ -102,22 +101,20 @@
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
- RateProfile rate_profile;
- SetRateProfile(&rate_profile, 0, 200, 30, 0);
- SetRateProfile(&rate_profile, 1, 700, 30, 100);
- SetRateProfile(&rate_profile, 2, 500, 30, 200);
- rate_profile.frame_index_rate_update[3] = kNumFramesLong + 1;
- rate_profile.num_frames = kNumFramesLong;
+ std::vector<RateProfile> rate_profiles = {
+ {200, 30, 100}, // target_kbps, input_fps, frame_index_rate_update
+ {700, 30, 200},
+ {500, 30, kNumFramesLong + 1}};
- std::vector<RateControlThresholds> rc_thresholds;
- AddRateControlThresholds(0, 30, 20, 20, 35, 0, 1, &rc_thresholds);
- AddRateControlThresholds(2, 0, 20, 20, 60, 0, 0, &rc_thresholds);
- AddRateControlThresholds(0, 0, 25, 20, 40, 0, 0, &rc_thresholds);
+ std::vector<RateControlThresholds> rc_thresholds = {{0, 30, 20, 20, 35, 0, 1},
+ {2, 0, 20, 20, 60, 0, 0},
+ {0, 0, 25, 20, 40, 0, 0}};
QualityThresholds quality_thresholds(35.5, 30.0, 0.90, 0.85);
- ProcessFramesAndMaybeVerify(rate_profile, &rc_thresholds, &quality_thresholds,
- nullptr, kNoVisualizationParams);
+ ProcessFramesAndMaybeVerify(rate_profiles, &rc_thresholds,
+ &quality_thresholds, nullptr,
+ kNoVisualizationParams);
}
// VP9: Run with no packet loss, with an update (decrease) in frame rate.
@@ -132,41 +129,39 @@
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
- RateProfile rate_profile;
- SetRateProfile(&rate_profile, 0, 100, 24, 0);
- SetRateProfile(&rate_profile, 1, 100, 15, 100);
- SetRateProfile(&rate_profile, 2, 100, 10, 200);
- rate_profile.frame_index_rate_update[3] = kNumFramesLong + 1;
- rate_profile.num_frames = kNumFramesLong;
+ std::vector<RateProfile> rate_profiles = {
+ {100, 24, 100}, // target_kbps, input_fps, frame_index_rate_update
+ {100, 15, 200},
+ {100, 10, kNumFramesLong + 1}};
- std::vector<RateControlThresholds> rc_thresholds;
- AddRateControlThresholds(45, 50, 95, 15, 45, 0, 1, &rc_thresholds);
- AddRateControlThresholds(20, 0, 50, 10, 30, 0, 0, &rc_thresholds);
- AddRateControlThresholds(5, 0, 30, 5, 25, 0, 0, &rc_thresholds);
+ std::vector<RateControlThresholds> rc_thresholds = {
+ {45, 50, 95, 15, 45, 0, 1},
+ {20, 0, 50, 10, 30, 0, 0},
+ {5, 0, 30, 5, 25, 0, 0}};
QualityThresholds quality_thresholds(31.5, 18.0, 0.80, 0.43);
- ProcessFramesAndMaybeVerify(rate_profile, &rc_thresholds, &quality_thresholds,
- nullptr, kNoVisualizationParams);
+ ProcessFramesAndMaybeVerify(rate_profiles, &rc_thresholds,
+ &quality_thresholds, nullptr,
+ kNoVisualizationParams);
}
// VP9: Run with no packet loss and denoiser on. One key frame (first frame).
TEST_F(VideoProcessorIntegrationTestLibvpx, ProcessNoLossDenoiserOnVP9) {
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
+ config_.num_frames = kNumFramesShort;
- RateProfile rate_profile;
- SetRateProfile(&rate_profile, 0, 500, 30, 0);
- rate_profile.frame_index_rate_update[1] = kNumFramesShort + 1;
- rate_profile.num_frames = kNumFramesShort;
+ std::vector<RateProfile> rate_profiles = {{500, 30, kNumFramesShort + 1}};
- std::vector<RateControlThresholds> rc_thresholds;
- AddRateControlThresholds(0, 40, 20, 10, 20, 0, 1, &rc_thresholds);
+ std::vector<RateControlThresholds> rc_thresholds = {
+ {0, 40, 20, 10, 20, 0, 1}};
QualityThresholds quality_thresholds(36.8, 35.8, 0.92, 0.91);
- ProcessFramesAndMaybeVerify(rate_profile, &rc_thresholds, &quality_thresholds,
- nullptr, kNoVisualizationParams);
+ ProcessFramesAndMaybeVerify(rate_profiles, &rc_thresholds,
+ &quality_thresholds, nullptr,
+ kNoVisualizationParams);
}
// Run with no packet loss, at low bitrate.
@@ -177,18 +172,16 @@
SetCodecSettings(&config_, kVideoCodecVP9, 1, false, false, true, true,
kResilienceOn, kCifWidth, kCifHeight);
- RateProfile rate_profile;
- SetRateProfile(&rate_profile, 0, 50, 30, 0);
- rate_profile.frame_index_rate_update[1] = kNumFramesLong + 1;
- rate_profile.num_frames = kNumFramesLong;
+ std::vector<RateProfile> rate_profiles = {{50, 30, kNumFramesLong + 1}};
- std::vector<RateControlThresholds> rc_thresholds;
- AddRateControlThresholds(228, 70, 160, 15, 80, 1, 1, &rc_thresholds);
+ std::vector<RateControlThresholds> rc_thresholds = {
+ {228, 70, 160, 15, 80, 1, 1}};
QualityThresholds quality_thresholds(24.0, 13.0, 0.65, 0.37);
- ProcessFramesAndMaybeVerify(rate_profile, &rc_thresholds, &quality_thresholds,
- nullptr, kNoVisualizationParams);
+ ProcessFramesAndMaybeVerify(rate_profiles, &rc_thresholds,
+ &quality_thresholds, nullptr,
+ kNoVisualizationParams);
}
// TODO(marpan): Add temporal layer test for VP9, once changes are in
@@ -202,19 +195,18 @@
TEST_F(VideoProcessorIntegrationTestLibvpx, ProcessZeroPacketLoss) {
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
+ config_.num_frames = kNumFramesShort;
- RateProfile rate_profile;
- SetRateProfile(&rate_profile, 0, 500, 30, 0);
- rate_profile.frame_index_rate_update[1] = kNumFramesShort + 1;
- rate_profile.num_frames = kNumFramesShort;
+ std::vector<RateProfile> rate_profiles = {{500, 30, kNumFramesShort + 1}};
- std::vector<RateControlThresholds> rc_thresholds;
- AddRateControlThresholds(0, 40, 20, 10, 15, 0, 1, &rc_thresholds);
+ std::vector<RateControlThresholds> rc_thresholds = {
+ {0, 40, 20, 10, 15, 0, 1}};
QualityThresholds quality_thresholds(34.95, 33.0, 0.90, 0.89);
- ProcessFramesAndMaybeVerify(rate_profile, &rc_thresholds, &quality_thresholds,
- nullptr, kNoVisualizationParams);
+ ProcessFramesAndMaybeVerify(rate_profiles, &rc_thresholds,
+ &quality_thresholds, nullptr,
+ kNoVisualizationParams);
}
// VP8: Run with 5% packet loss and fixed bitrate. Quality should be a bit
@@ -223,19 +215,18 @@
config_.networking_config.packet_loss_probability = 0.05f;
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
+ config_.num_frames = kNumFramesShort;
- RateProfile rate_profile;
- SetRateProfile(&rate_profile, 0, 500, 30, 0);
- rate_profile.frame_index_rate_update[1] = kNumFramesShort + 1;
- rate_profile.num_frames = kNumFramesShort;
+ std::vector<RateProfile> rate_profiles = {{500, 30, kNumFramesShort + 1}};
- std::vector<RateControlThresholds> rc_thresholds;
- AddRateControlThresholds(0, 40, 20, 10, 15, 0, 1, &rc_thresholds);
+ std::vector<RateControlThresholds> rc_thresholds = {
+ {0, 40, 20, 10, 15, 0, 1}};
QualityThresholds quality_thresholds(20.0, 16.0, 0.60, 0.40);
- ProcessFramesAndMaybeVerify(rate_profile, &rc_thresholds, &quality_thresholds,
- nullptr, kNoVisualizationParams);
+ ProcessFramesAndMaybeVerify(rate_profiles, &rc_thresholds,
+ &quality_thresholds, nullptr,
+ kNoVisualizationParams);
}
// VP8: Run with 10% packet loss and fixed bitrate. Quality should be lower.
@@ -244,19 +235,18 @@
config_.networking_config.packet_loss_probability = 0.1f;
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
+ config_.num_frames = kNumFramesShort;
- RateProfile rate_profile;
- SetRateProfile(&rate_profile, 0, 500, 30, 0);
- rate_profile.frame_index_rate_update[1] = kNumFramesShort + 1;
- rate_profile.num_frames = kNumFramesShort;
+ std::vector<RateProfile> rate_profiles = {{500, 30, kNumFramesShort + 1}};
- std::vector<RateControlThresholds> rc_thresholds;
- AddRateControlThresholds(0, 40, 20, 10, 15, 0, 1, &rc_thresholds);
+ std::vector<RateControlThresholds> rc_thresholds = {
+ {0, 40, 20, 10, 15, 0, 1}};
QualityThresholds quality_thresholds(19.0, 16.0, 0.50, 0.35);
- ProcessFramesAndMaybeVerify(rate_profile, &rc_thresholds, &quality_thresholds,
- nullptr, kNoVisualizationParams);
+ ProcessFramesAndMaybeVerify(rate_profiles, &rc_thresholds,
+ &quality_thresholds, nullptr,
+ kNoVisualizationParams);
}
#endif // !defined(WEBRTC_IOS)
@@ -286,22 +276,20 @@
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
- RateProfile rate_profile;
- SetRateProfile(&rate_profile, 0, 200, 30, 0);
- SetRateProfile(&rate_profile, 1, 800, 30, 100);
- SetRateProfile(&rate_profile, 2, 500, 30, 200);
- rate_profile.frame_index_rate_update[3] = kNumFramesLong + 1;
- rate_profile.num_frames = kNumFramesLong;
+ std::vector<RateProfile> rate_profiles = {
+ {200, 30, 100}, // target_kbps, input_fps, frame_index_rate_update
+ {800, 30, 200},
+ {500, 30, kNumFramesLong + 1}};
- std::vector<RateControlThresholds> rc_thresholds;
- AddRateControlThresholds(0, 45, 20, 10, 15, 0, 1, &rc_thresholds);
- AddRateControlThresholds(0, 0, 25, 20, 10, 0, 0, &rc_thresholds);
- AddRateControlThresholds(0, 0, 25, 15, 10, 0, 0, &rc_thresholds);
+ std::vector<RateControlThresholds> rc_thresholds = {{0, 45, 20, 10, 15, 0, 1},
+ {0, 0, 25, 20, 10, 0, 0},
+ {0, 0, 25, 15, 10, 0, 0}};
QualityThresholds quality_thresholds(34.0, 32.0, 0.85, 0.80);
- ProcessFramesAndMaybeVerify(rate_profile, &rc_thresholds, &quality_thresholds,
- nullptr, kNoVisualizationParams);
+ ProcessFramesAndMaybeVerify(rate_profiles, &rc_thresholds,
+ &quality_thresholds, nullptr,
+ kNoVisualizationParams);
}
// VP8: Run with no packet loss, with an update (decrease) in frame rate.
@@ -324,22 +312,21 @@
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
- RateProfile rate_profile;
- SetRateProfile(&rate_profile, 0, 80, 24, 0);
- SetRateProfile(&rate_profile, 1, 80, 15, 100);
- SetRateProfile(&rate_profile, 2, 80, 10, 200);
- rate_profile.frame_index_rate_update[3] = kNumFramesLong + 1;
- rate_profile.num_frames = kNumFramesLong;
+ std::vector<RateProfile> rate_profiles = {
+ {80, 24, 100}, // target_kbps, input_fps, frame_index_rate_update
+ {80, 15, 200},
+ {80, 10, kNumFramesLong + 1}};
- std::vector<RateControlThresholds> rc_thresholds;
- AddRateControlThresholds(40, 20, 75, 15, 60, 0, 1, &rc_thresholds);
- AddRateControlThresholds(10, 0, 25, 10, 35, 0, 0, &rc_thresholds);
- AddRateControlThresholds(0, 0, 20, 10, 15, 0, 0, &rc_thresholds);
+ std::vector<RateControlThresholds> rc_thresholds = {
+ {40, 20, 75, 15, 60, 0, 1},
+ {10, 0, 25, 10, 35, 0, 0},
+ {0, 0, 20, 10, 15, 0, 0}};
QualityThresholds quality_thresholds(31.0, 22.0, 0.80, 0.65);
- ProcessFramesAndMaybeVerify(rate_profile, &rc_thresholds, &quality_thresholds,
- nullptr, kNoVisualizationParams);
+ ProcessFramesAndMaybeVerify(rate_profiles, &rc_thresholds,
+ &quality_thresholds, nullptr,
+ kNoVisualizationParams);
}
// VP8: Run with no packet loss, with 3 temporal layers, with a rate update in
@@ -359,20 +346,17 @@
SetCodecSettings(&config_, kVideoCodecVP8, 3, false, true, true, false,
kResilienceOn, kCifWidth, kCifHeight);
- RateProfile rate_profile;
- SetRateProfile(&rate_profile, 0, 200, 30, 0);
- SetRateProfile(&rate_profile, 1, 400, 30, 150);
- rate_profile.frame_index_rate_update[2] = kNumFramesLong + 1;
- rate_profile.num_frames = kNumFramesLong;
+ std::vector<RateProfile> rate_profiles = {{200, 30, 150},
+ {400, 30, kNumFramesLong + 1}};
- std::vector<RateControlThresholds> rc_thresholds;
- AddRateControlThresholds(0, 20, 30, 10, 10, 0, 1, &rc_thresholds);
- AddRateControlThresholds(0, 0, 30, 15, 10, 0, 0, &rc_thresholds);
+ std::vector<RateControlThresholds> rc_thresholds = {{0, 20, 30, 10, 10, 0, 1},
+ {0, 0, 30, 15, 10, 0, 0}};
QualityThresholds quality_thresholds(32.5, 30.0, 0.85, 0.80);
- ProcessFramesAndMaybeVerify(rate_profile, &rc_thresholds, &quality_thresholds,
- nullptr, kNoVisualizationParams);
+ ProcessFramesAndMaybeVerify(rate_profiles, &rc_thresholds,
+ &quality_thresholds, nullptr,
+ kNoVisualizationParams);
}
} // namespace test
diff --git a/modules/video_coding/codecs/test/videoprocessor_integrationtest_mediacodec.cc b/modules/video_coding/codecs/test/videoprocessor_integrationtest_mediacodec.cc
index 6e20244..9f03308 100644
--- a/modules/video_coding/codecs/test/videoprocessor_integrationtest_mediacodec.cc
+++ b/modules/video_coding/codecs/test/videoprocessor_integrationtest_mediacodec.cc
@@ -33,6 +33,7 @@
config_.input_filename = ResourcePath(config_.filename, "yuv");
config_.output_filename =
TempFilename(OutputPath(), "videoprocessor_integrationtest_mediacodec");
+ config_.num_frames = kForemanNumFrames;
config_.verbose = false;
config_.hw_encoder = true;
config_.hw_decoder = true;
@@ -43,21 +44,19 @@
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, false, false, false,
false, 352, 288);
- RateProfile rate_profile;
- SetRateProfile(&rate_profile, 0, 500, 30, 0); // Start below |low_kbps|.
- rate_profile.frame_index_rate_update[1] = kForemanNumFrames + 1;
- rate_profile.num_frames = kForemanNumFrames;
+ std::vector<RateProfile> rate_profiles = {{500, 30, kForemanNumFrames + 1}};
// The thresholds below may have to be tweaked to let even poor MediaCodec
// implementations pass. If this test fails on the bots, disable it and
// ping brandtr@.
- std::vector<RateControlThresholds> rc_thresholds;
- AddRateControlThresholds(20, 95, 22, 11, 10, 0, 1, &rc_thresholds);
+ std::vector<RateControlThresholds> rc_thresholds = {
+ {20, 95, 22, 11, 10, 0, 1}};
QualityThresholds quality_thresholds(30.0, 14.0, 0.86, 0.39);
- ProcessFramesAndMaybeVerify(rate_profile, &rc_thresholds, &quality_thresholds,
- nullptr, kNoVisualizationParams);
+ ProcessFramesAndMaybeVerify(rate_profiles, &rc_thresholds,
+ &quality_thresholds, nullptr,
+ kNoVisualizationParams);
}
TEST_F(VideoProcessorIntegrationTestMediaCodec,
@@ -71,25 +70,23 @@
SetCodecSettings(&config_, kVideoCodecVP8, 1, false, false, false, false,
false, 320, 240);
- RateProfile rate_profile;
- SetRateProfile(&rate_profile, 0, 100, 10, 0); // Start below |low_kbps|.
- SetRateProfile(&rate_profile, 1, 100, 10, 80); // Fallback in this bucket.
- SetRateProfile(&rate_profile, 2, 200, 10, 200); // Switch back here.
- rate_profile.frame_index_rate_update[3] = kForemanNumFrames + 1;
- rate_profile.num_frames = kForemanNumFrames;
+ std::vector<RateProfile> rate_profiles = {
+ {100, 10, 80}, // Start below |low_kbps|.
+ {100, 10, 200}, // Fallback in this bucket.
+ {200, 10, kForemanNumFrames + 1}}; // Switch back here.
// The thresholds below may have to be tweaked to let even poor MediaCodec
// implementations pass. If this test fails on the bots, disable it and
// ping brandtr@.
- std::vector<RateControlThresholds> rc_thresholds;
- AddRateControlThresholds(0, 50, 75, 70, 10, 0, 1, &rc_thresholds);
- AddRateControlThresholds(0, 50, 25, 12, 60, 0, 1, &rc_thresholds);
- AddRateControlThresholds(0, 65, 15, 5, 5, 0, 1, &rc_thresholds);
+ std::vector<RateControlThresholds> rc_thresholds = {{0, 50, 75, 70, 10, 0, 1},
+ {0, 50, 25, 12, 60, 0, 1},
+ {0, 65, 15, 5, 5, 0, 1}};
QualityThresholds quality_thresholds(33.0, 30.0, 0.90, 0.85);
- ProcessFramesAndMaybeVerify(rate_profile, &rc_thresholds, &quality_thresholds,
- nullptr, kNoVisualizationParams);
+ ProcessFramesAndMaybeVerify(rate_profiles, &rc_thresholds,
+ &quality_thresholds, nullptr,
+ kNoVisualizationParams);
}
#endif // defined(WEBRTC_ANDROID)
diff --git a/modules/video_coding/codecs/test/videoprocessor_integrationtest_openh264.cc b/modules/video_coding/codecs/test/videoprocessor_integrationtest_openh264.cc
index df3e4d0..d4c42ff 100644
--- a/modules/video_coding/codecs/test/videoprocessor_integrationtest_openh264.cc
+++ b/modules/video_coding/codecs/test/videoprocessor_integrationtest_openh264.cc
@@ -39,6 +39,7 @@
config_.input_filename = ResourcePath(config_.filename, "yuv");
config_.output_filename =
TempFilename(OutputPath(), "videoprocessor_integrationtest_libvpx");
+ config_.num_frames = kNumFrames;
config_.networking_config.packet_loss_probability = 0.0;
// Only allow encoder/decoder to use single core, for predictability.
config_.use_single_core = true;
@@ -57,18 +58,16 @@
SetCodecSettings(&config_, kVideoCodecH264, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
- RateProfile rate_profile;
- SetRateProfile(&rate_profile, 0, 500, 30, 0);
- rate_profile.frame_index_rate_update[1] = kNumFrames + 1;
- rate_profile.num_frames = kNumFrames;
+ std::vector<RateProfile> rate_profiles = {{500, 30, kNumFrames + 1}};
- std::vector<RateControlThresholds> rc_thresholds;
- AddRateControlThresholds(2, 60, 20, 10, 20, 0, 1, &rc_thresholds);
+ std::vector<RateControlThresholds> rc_thresholds = {
+ {2, 60, 20, 10, 20, 0, 1}};
QualityThresholds quality_thresholds(35.0, 25.0, 0.93, 0.70);
- ProcessFramesAndMaybeVerify(rate_profile, &rc_thresholds, &quality_thresholds,
- nullptr, kNoVisualizationParams);
+ ProcessFramesAndMaybeVerify(rate_profiles, &rc_thresholds,
+ &quality_thresholds, nullptr,
+ kNoVisualizationParams);
}
// H264: Enable SingleNalUnit packetization mode. Encoder should split
@@ -79,21 +78,19 @@
SetCodecSettings(&config_, kVideoCodecH264, 1, false, false, true, false,
kResilienceOn, kCifWidth, kCifHeight);
- RateProfile rate_profile;
- SetRateProfile(&rate_profile, 0, 500, 30, 0);
- rate_profile.frame_index_rate_update[1] = kNumFrames + 1;
- rate_profile.num_frames = kNumFrames;
+ std::vector<RateProfile> rate_profiles = {{500, 30, kNumFrames + 1}};
- std::vector<RateControlThresholds> rc_thresholds;
- AddRateControlThresholds(2, 60, 30, 10, 20, 0, 1, &rc_thresholds);
+ std::vector<RateControlThresholds> rc_thresholds = {
+ {2, 60, 30, 10, 20, 0, 1}};
QualityThresholds quality_thresholds(35.0, 25.0, 0.93, 0.70);
BitstreamThresholds bs_thresholds(
config_.networking_config.max_payload_size_in_bytes);
- ProcessFramesAndMaybeVerify(rate_profile, &rc_thresholds, &quality_thresholds,
- &bs_thresholds, kNoVisualizationParams);
+ ProcessFramesAndMaybeVerify(rate_profiles, &rc_thresholds,
+ &quality_thresholds, &bs_thresholds,
+ kNoVisualizationParams);
}
#endif // defined(WEBRTC_USE_H264)
diff --git a/modules/video_coding/codecs/test/videoprocessor_integrationtest_parameterized.cc b/modules/video_coding/codecs/test/videoprocessor_integrationtest_parameterized.cc
index 8a182f9..e725daf 100644
--- a/modules/video_coding/codecs/test/videoprocessor_integrationtest_parameterized.cc
+++ b/modules/video_coding/codecs/test/videoprocessor_integrationtest_parameterized.cc
@@ -65,19 +65,15 @@
config_.verbose = true;
config_.hw_encoder = hw_codec_;
config_.hw_decoder = hw_codec_;
+ config_.num_frames = kNumFrames;
SetCodecSettings(&config_, codec_type_, kNumTemporalLayers,
kErrorConcealmentOn, kDenoisingOn, kFrameDropperOn,
kSpatialResizeOn, kResilienceOn, width, height);
- RateProfile rate_profile;
- SetRateProfile(&rate_profile,
- 0, // update_index
- bitrate_, framerate,
- 0); // frame_index_rate_update
- rate_profile.frame_index_rate_update[1] = kNumFrames + 1;
- rate_profile.num_frames = kNumFrames;
+ std::vector<RateProfile> rate_profiles = {
+ {bitrate_, framerate, kNumFrames + 1}};
- ProcessFramesAndMaybeVerify(rate_profile, nullptr, nullptr, nullptr,
+ ProcessFramesAndMaybeVerify(rate_profiles, nullptr, nullptr, nullptr,
&kVisualizationParams);
}