ref: da4c8bd04f77f62b294541d24619d1fd7fece22b
parent: 950fecd01c73f913117a7769f97a8362db588ba9
parent: c7dcd6f5d95961a942c09823558138a2d5705064
author: Jerome Jiang <[email protected]>
date: Tue May 7 00:01:44 EDT 2019
Merge "vp8: Remove duplicated code in datarate tests."
--- a/test/vp8_datarate_test.cc
+++ b/test/vp8_datarate_test.cc
@@ -135,6 +135,131 @@
}
}
+ virtual void DenoiserLevelsTest() {
+ cfg_.rc_buf_initial_sz = 500;
+ cfg_.rc_dropframe_thresh = 1;
+ cfg_.rc_max_quantizer = 56;
+ cfg_.rc_end_usage = VPX_CBR;
+ ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
+ 288, 30, 1, 0, 140);
+ for (int j = 1; j < 5; ++j) {
+ // Run over the denoiser levels.
+ // For the temporal denoiser (#if CONFIG_TEMPORAL_DENOISING) the level j
+ // refers to the 4 denoiser modes: denoiserYonly, denoiserOnYUV,
+ // denoiserOnAggressive, and denoiserOnAdaptive.
+ denoiser_on_ = j;
+ cfg_.rc_target_bitrate = 300;
+ ResetModel();
+ ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
+ ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
+ << " The datarate for the file exceeds the target!";
+
+ ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.4)
+ << " The datarate for the file missed the target!";
+ }
+ }
+
+ virtual void DenoiserOffOnTest() {
+ cfg_.rc_buf_initial_sz = 500;
+ cfg_.rc_dropframe_thresh = 1;
+ cfg_.rc_max_quantizer = 56;
+ cfg_.rc_end_usage = VPX_CBR;
+ ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
+ 288, 30, 1, 0, 299);
+ cfg_.rc_target_bitrate = 300;
+ ResetModel();
+ // The denoiser is off by default.
+ denoiser_on_ = 0;
+ // Set the offon test flag.
+ denoiser_offon_test_ = 1;
+ denoiser_offon_period_ = 100;
+ ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
+ ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
+ << " The datarate for the file exceeds the target!";
+ ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.4)
+ << " The datarate for the file missed the target!";
+ }
+
+ virtual void BasicBufferModelTest() {
+ denoiser_on_ = 0;
+ cfg_.rc_buf_initial_sz = 500;
+ cfg_.rc_dropframe_thresh = 1;
+ cfg_.rc_max_quantizer = 56;
+ cfg_.rc_end_usage = VPX_CBR;
+ // 2 pass cbr datarate control has a bug hidden by the small # of
+ // frames selected in this encode. The problem is that even if the buffer is
+ // negative we produce a keyframe on a cutscene. Ignoring datarate
+ // constraints
+ // TODO(jimbankoski): ( Fix when issue
+ // http://code.google.com/p/webm/issues/detail?id=495 is addressed. )
+ ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
+ 288, 30, 1, 0, 140);
+
+ // There is an issue for low bitrates in real-time mode, where the
+ // effective_datarate slightly overshoots the target bitrate.
+ // This is same the issue as noted about (#495).
+ // TODO(jimbankoski/marpan): Update test to run for lower bitrates (< 100),
+ // when the issue is resolved.
+ for (int i = 100; i < 800; i += 200) {
+ cfg_.rc_target_bitrate = i;
+ ResetModel();
+ ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
+ ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
+ << " The datarate for the file exceeds the target!";
+ ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.4)
+ << " The datarate for the file missed the target!";
+ }
+ }
+
+ virtual void ChangingDropFrameThreshTest() {
+ denoiser_on_ = 0;
+ cfg_.rc_buf_initial_sz = 500;
+ cfg_.rc_max_quantizer = 36;
+ cfg_.rc_end_usage = VPX_CBR;
+ cfg_.rc_target_bitrate = 200;
+ cfg_.kf_mode = VPX_KF_DISABLED;
+
+ const int frame_count = 40;
+ ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
+ 288, 30, 1, 0, frame_count);
+
+ // Here we check that the first dropped frame gets earlier and earlier
+ // as the drop frame threshold is increased.
+
+ const int kDropFrameThreshTestStep = 30;
+ vpx_codec_pts_t last_drop = frame_count;
+ for (int i = 1; i < 91; i += kDropFrameThreshTestStep) {
+ cfg_.rc_dropframe_thresh = i;
+ ResetModel();
+ ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
+ ASSERT_LE(first_drop_, last_drop)
+ << " The first dropped frame for drop_thresh " << i
+ << " > first dropped frame for drop_thresh "
+ << i - kDropFrameThreshTestStep;
+ last_drop = first_drop_;
+ }
+ }
+
+ virtual void DropFramesMultiThreadsTest() {
+ denoiser_on_ = 0;
+ cfg_.rc_buf_initial_sz = 500;
+ cfg_.rc_dropframe_thresh = 30;
+ cfg_.rc_max_quantizer = 56;
+ cfg_.rc_end_usage = VPX_CBR;
+ cfg_.g_threads = 2;
+
+ ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352,
+ 288, 30, 1, 0, 140);
+ cfg_.rc_target_bitrate = 200;
+ ResetModel();
+ ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
+ ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
+ << " The datarate for the file exceeds the target!";
+
+ ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.4)
+ << " The datarate for the file missed the target!";
+ }
+
vpx_codec_pts_t last_pts_;
int64_t bits_in_buffer_model_;
double timebase_;
@@ -157,132 +282,21 @@
#if CONFIG_TEMPORAL_DENOISING
// Check basic datarate targeting, for a single bitrate, but loop over the
// various denoiser settings.
-TEST_P(DatarateTestLarge, DenoiserLevels) {
- cfg_.rc_buf_initial_sz = 500;
- cfg_.rc_dropframe_thresh = 1;
- cfg_.rc_max_quantizer = 56;
- cfg_.rc_end_usage = VPX_CBR;
- ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
- 30, 1, 0, 140);
- for (int j = 1; j < 5; ++j) {
- // Run over the denoiser levels.
- // For the temporal denoiser (#if CONFIG_TEMPORAL_DENOISING) the level j
- // refers to the 4 denoiser modes: denoiserYonly, denoiserOnYUV,
- // denoiserOnAggressive, and denoiserOnAdaptive.
- denoiser_on_ = j;
- cfg_.rc_target_bitrate = 300;
- ResetModel();
- ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
- ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
- << " The datarate for the file exceeds the target!";
+TEST_P(DatarateTestLarge, DenoiserLevels) { DenoiserLevelsTest(); }
- ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.4)
- << " The datarate for the file missed the target!";
- }
-}
-
// Check basic datarate targeting, for a single bitrate, when denoiser is off
// and on.
-TEST_P(DatarateTestLarge, DenoiserOffOn) {
- cfg_.rc_buf_initial_sz = 500;
- cfg_.rc_dropframe_thresh = 1;
- cfg_.rc_max_quantizer = 56;
- cfg_.rc_end_usage = VPX_CBR;
- ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
- 30, 1, 0, 299);
- cfg_.rc_target_bitrate = 300;
- ResetModel();
- // The denoiser is off by default.
- denoiser_on_ = 0;
- // Set the offon test flag.
- denoiser_offon_test_ = 1;
- denoiser_offon_period_ = 100;
- ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
- ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
- << " The datarate for the file exceeds the target!";
- ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.4)
- << " The datarate for the file missed the target!";
-}
+TEST_P(DatarateTestLarge, DenoiserOffOn) { DenoiserOffOnTest(); }
#endif // CONFIG_TEMPORAL_DENOISING
-TEST_P(DatarateTestLarge, BasicBufferModel) {
- denoiser_on_ = 0;
- cfg_.rc_buf_initial_sz = 500;
- cfg_.rc_dropframe_thresh = 1;
- cfg_.rc_max_quantizer = 56;
- cfg_.rc_end_usage = VPX_CBR;
- // 2 pass cbr datarate control has a bug hidden by the small # of
- // frames selected in this encode. The problem is that even if the buffer is
- // negative we produce a keyframe on a cutscene. Ignoring datarate
- // constraints
- // TODO(jimbankoski): ( Fix when issue
- // http://code.google.com/p/webm/issues/detail?id=495 is addressed. )
- ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
- 30, 1, 0, 140);
+TEST_P(DatarateTestLarge, BasicBufferModel) { BasicBufferModelTest(); }
- // There is an issue for low bitrates in real-time mode, where the
- // effective_datarate slightly overshoots the target bitrate.
- // This is same the issue as noted about (#495).
- // TODO(jimbankoski/marpan): Update test to run for lower bitrates (< 100),
- // when the issue is resolved.
- for (int i = 100; i < 800; i += 200) {
- cfg_.rc_target_bitrate = i;
- ResetModel();
- ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
- ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
- << " The datarate for the file exceeds the target!";
- ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.4)
- << " The datarate for the file missed the target!";
- }
-}
-
TEST_P(DatarateTestLarge, ChangingDropFrameThresh) {
- denoiser_on_ = 0;
- cfg_.rc_buf_initial_sz = 500;
- cfg_.rc_max_quantizer = 36;
- cfg_.rc_end_usage = VPX_CBR;
- cfg_.rc_target_bitrate = 200;
- cfg_.kf_mode = VPX_KF_DISABLED;
-
- const int frame_count = 40;
- ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
- 30, 1, 0, frame_count);
-
- // Here we check that the first dropped frame gets earlier and earlier
- // as the drop frame threshold is increased.
-
- const int kDropFrameThreshTestStep = 30;
- vpx_codec_pts_t last_drop = frame_count;
- for (int i = 1; i < 91; i += kDropFrameThreshTestStep) {
- cfg_.rc_dropframe_thresh = i;
- ResetModel();
- ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
- ASSERT_LE(first_drop_, last_drop)
- << " The first dropped frame for drop_thresh " << i
- << " > first dropped frame for drop_thresh "
- << i - kDropFrameThreshTestStep;
- last_drop = first_drop_;
- }
+ ChangingDropFrameThreshTest();
}
TEST_P(DatarateTestLarge, DropFramesMultiThreads) {
- denoiser_on_ = 0;
- cfg_.rc_buf_initial_sz = 500;
- cfg_.rc_dropframe_thresh = 30;
- cfg_.rc_max_quantizer = 56;
- cfg_.rc_end_usage = VPX_CBR;
- cfg_.g_threads = 2;
-
- ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
- 30, 1, 0, 140);
- cfg_.rc_target_bitrate = 200;
- ResetModel();
- ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
- ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
- << " The datarate for the file exceeds the target!";
-
- ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.4)
- << " The datarate for the file missed the target!";
+ DropFramesMultiThreadsTest();
}
class DatarateTestRealTime : public DatarateTestLarge {
@@ -293,132 +307,21 @@
#if CONFIG_TEMPORAL_DENOISING
// Check basic datarate targeting, for a single bitrate, but loop over the
// various denoiser settings.
-TEST_P(DatarateTestRealTime, DenoiserLevels) {
- cfg_.rc_buf_initial_sz = 500;
- cfg_.rc_dropframe_thresh = 1;
- cfg_.rc_max_quantizer = 56;
- cfg_.rc_end_usage = VPX_CBR;
- ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
- 30, 1, 0, 140);
- for (int j = 1; j < 5; ++j) {
- // Run over the denoiser levels.
- // For the temporal denoiser (#if CONFIG_TEMPORAL_DENOISING) the level j
- // refers to the 4 denoiser modes: denoiserYonly, denoiserOnYUV,
- // denoiserOnAggressive, and denoiserOnAdaptive.
- denoiser_on_ = j;
- cfg_.rc_target_bitrate = 300;
- ResetModel();
- ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
- ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
- << " The datarate for the file exceeds the target!";
- ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.4)
- << " The datarate for the file missed the target!";
- }
-}
+TEST_P(DatarateTestRealTime, DenoiserLevels) { DenoiserLevelsTest(); }
// Check basic datarate targeting, for a single bitrate, when denoiser is off
// and on.
-TEST_P(DatarateTestRealTime, DenoiserOffOn) {
- cfg_.rc_buf_initial_sz = 500;
- cfg_.rc_dropframe_thresh = 1;
- cfg_.rc_max_quantizer = 56;
- cfg_.rc_end_usage = VPX_CBR;
- ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
- 30, 1, 0, 299);
- cfg_.rc_target_bitrate = 300;
- ResetModel();
- // The denoiser is off by default.
- denoiser_on_ = 0;
- // Set the offon test flag.
- denoiser_offon_test_ = 1;
- denoiser_offon_period_ = 100;
- ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
- ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
- << " The datarate for the file exceeds the target!";
- ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.4)
- << " The datarate for the file missed the target!";
-}
+TEST_P(DatarateTestRealTime, DenoiserOffOn) {}
#endif // CONFIG_TEMPORAL_DENOISING
-TEST_P(DatarateTestRealTime, BasicBufferModel) {
- denoiser_on_ = 0;
- cfg_.rc_buf_initial_sz = 500;
- cfg_.rc_dropframe_thresh = 1;
- cfg_.rc_max_quantizer = 56;
- cfg_.rc_end_usage = VPX_CBR;
- // 2 pass cbr datarate control has a bug hidden by the small # of
- // frames selected in this encode. The problem is that even if the buffer is
- // negative we produce a keyframe on a cutscene, ignoring datarate
- // constraints
- // TODO(jimbankoski): Fix when issue
- // http://bugs.chromium.org/p/webm/issues/detail?id=495 is addressed.
- ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
- 30, 1, 0, 140);
+TEST_P(DatarateTestRealTime, BasicBufferModel) { BasicBufferModelTest(); }
- // There is an issue for low bitrates in real-time mode, where the
- // effective_datarate slightly overshoots the target bitrate.
- // This is same the issue as noted above (#495).
- // TODO(jimbankoski/marpan): Update test to run for lower bitrates (< 100),
- // when the issue is resolved.
- for (int i = 100; i <= 700; i += 200) {
- cfg_.rc_target_bitrate = i;
- ResetModel();
- ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
- ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
- << " The datarate for the file exceeds the target!";
- ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.4)
- << " The datarate for the file missed the target!";
- }
-}
-
TEST_P(DatarateTestRealTime, ChangingDropFrameThresh) {
- denoiser_on_ = 0;
- cfg_.rc_buf_initial_sz = 500;
- cfg_.rc_max_quantizer = 36;
- cfg_.rc_end_usage = VPX_CBR;
- cfg_.rc_target_bitrate = 200;
- cfg_.kf_mode = VPX_KF_DISABLED;
-
- const int frame_count = 40;
- ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
- 30, 1, 0, frame_count);
-
- // Check that the first dropped frame gets earlier and earlier
- // as the drop frame threshold is increased.
-
- const int kDropFrameThreshTestStep = 30;
- vpx_codec_pts_t last_drop = frame_count;
- for (int i = 1; i < 91; i += kDropFrameThreshTestStep) {
- cfg_.rc_dropframe_thresh = i;
- ResetModel();
- ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
- ASSERT_LE(first_drop_, last_drop)
- << " The first dropped frame for drop_thresh " << i
- << " > first dropped frame for drop_thresh "
- << i - kDropFrameThreshTestStep;
- last_drop = first_drop_;
- }
+ ChangingDropFrameThreshTest();
}
TEST_P(DatarateTestRealTime, DropFramesMultiThreads) {
- denoiser_on_ = 0;
- cfg_.rc_buf_initial_sz = 500;
- cfg_.rc_dropframe_thresh = 30;
- cfg_.rc_max_quantizer = 56;
- cfg_.rc_end_usage = VPX_CBR;
- // Encode using multiple threads.
- cfg_.g_threads = 2;
-
- ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
- 30, 1, 0, 140);
- cfg_.rc_target_bitrate = 200;
- ResetModel();
- ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
- ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
- << " The datarate for the file exceeds the target!";
-
- ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.4)
- << " The datarate for the file missed the target!";
+ DropFramesMultiThreadsTest();
}
TEST_P(DatarateTestRealTime, RegionOfInterest) {