OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include "./vpx_config.h" | 10 #include "./vpx_config.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 int frame_number_; | 119 int frame_number_; |
120 vpx_codec_pts_t first_drop_; | 120 vpx_codec_pts_t first_drop_; |
121 int64_t bits_total_; | 121 int64_t bits_total_; |
122 double duration_; | 122 double duration_; |
123 double file_datarate_; | 123 double file_datarate_; |
124 double effective_datarate_; | 124 double effective_datarate_; |
125 size_t bits_in_last_frame_; | 125 size_t bits_in_last_frame_; |
126 int denoiser_on_; | 126 int denoiser_on_; |
127 }; | 127 }; |
128 | 128 |
| 129 #if CONFIG_TEMPORAL_DENOISING |
129 // Check basic datarate targeting, for a single bitrate, but loop over the | 130 // Check basic datarate targeting, for a single bitrate, but loop over the |
130 // various denoiser settings. | 131 // various denoiser settings. |
131 TEST_P(DatarateTestLarge, DenoiserLevels) { | 132 TEST_P(DatarateTestLarge, DenoiserLevels) { |
132 cfg_.rc_buf_initial_sz = 500; | 133 cfg_.rc_buf_initial_sz = 500; |
133 cfg_.rc_dropframe_thresh = 1; | 134 cfg_.rc_dropframe_thresh = 1; |
134 cfg_.rc_max_quantizer = 56; | 135 cfg_.rc_max_quantizer = 56; |
135 cfg_.rc_end_usage = VPX_CBR; | 136 cfg_.rc_end_usage = VPX_CBR; |
136 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, | 137 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, |
137 30, 1, 0, 140); | 138 30, 1, 0, 140); |
138 for (int j = 1; j < 5; ++j) { | 139 for (int j = 1; j < 5; ++j) { |
139 // Run over the denoiser levels. | 140 // Run over the denoiser levels. |
140 // For the temporal denoiser (#if CONFIG_TEMPORAL_DENOISING) the level j | 141 // For the temporal denoiser (#if CONFIG_TEMPORAL_DENOISING) the level j |
141 // refers to the 4 denoiser modes: denoiserYonly, denoiserOnYUV, | 142 // refers to the 4 denoiser modes: denoiserYonly, denoiserOnYUV, |
142 // denoiserOnAggressive, and denoiserOnAdaptive. | 143 // denoiserOnAggressive, and denoiserOnAdaptive. |
143 // For the spatial denoiser (if !CONFIG_TEMPORAL_DENOISING), the level j | 144 // For the spatial denoiser (if !CONFIG_TEMPORAL_DENOISING), the level j |
144 // refers to the blur thresholds: 20, 40, 60 80. | 145 // refers to the blur thresholds: 20, 40, 60 80. |
145 // The j = 0 case (denoiser off) is covered in the tests below. | 146 // The j = 0 case (denoiser off) is covered in the tests below. |
146 denoiser_on_ = j; | 147 denoiser_on_ = j; |
147 cfg_.rc_target_bitrate = 300; | 148 cfg_.rc_target_bitrate = 300; |
148 ResetModel(); | 149 ResetModel(); |
149 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); | 150 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
150 ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95) | 151 ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95) |
151 << " The datarate for the file exceeds the target!"; | 152 << " The datarate for the file exceeds the target!"; |
152 | 153 |
153 ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.3) | 154 ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.3) |
154 << " The datarate for the file missed the target!"; | 155 << " The datarate for the file missed the target!"; |
155 } | 156 } |
156 } | 157 } |
| 158 #endif // CONFIG_TEMPORAL_DENOISING |
157 | 159 |
158 TEST_P(DatarateTestLarge, BasicBufferModel) { | 160 TEST_P(DatarateTestLarge, BasicBufferModel) { |
159 denoiser_on_ = 0; | 161 denoiser_on_ = 0; |
160 cfg_.rc_buf_initial_sz = 500; | 162 cfg_.rc_buf_initial_sz = 500; |
161 cfg_.rc_dropframe_thresh = 1; | 163 cfg_.rc_dropframe_thresh = 1; |
162 cfg_.rc_max_quantizer = 56; | 164 cfg_.rc_max_quantizer = 56; |
163 cfg_.rc_end_usage = VPX_CBR; | 165 cfg_.rc_end_usage = VPX_CBR; |
164 // 2 pass cbr datarate control has a bug hidden by the small # of | 166 // 2 pass cbr datarate control has a bug hidden by the small # of |
165 // frames selected in this encode. The problem is that even if the buffer is | 167 // frames selected in this encode. The problem is that even if the buffer is |
166 // negative we produce a keyframe on a cutscene. Ignoring datarate | 168 // negative we produce a keyframe on a cutscene. Ignoring datarate |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 ResetModel(); | 233 ResetModel(); |
232 } | 234 } |
233 | 235 |
234 virtual void ResetModel() { | 236 virtual void ResetModel() { |
235 last_pts_ = 0; | 237 last_pts_ = 0; |
236 bits_in_buffer_model_ = cfg_.rc_target_bitrate * cfg_.rc_buf_initial_sz; | 238 bits_in_buffer_model_ = cfg_.rc_target_bitrate * cfg_.rc_buf_initial_sz; |
237 frame_number_ = 0; | 239 frame_number_ = 0; |
238 tot_frame_number_ = 0; | 240 tot_frame_number_ = 0; |
239 first_drop_ = 0; | 241 first_drop_ = 0; |
240 num_drops_ = 0; | 242 num_drops_ = 0; |
| 243 // Denoiser is off by default. |
| 244 denoiser_on_ = 0; |
241 // For testing up to 3 layers. | 245 // For testing up to 3 layers. |
242 for (int i = 0; i < 3; ++i) { | 246 for (int i = 0; i < 3; ++i) { |
243 bits_total_[i] = 0; | 247 bits_total_[i] = 0; |
244 } | 248 } |
245 } | 249 } |
246 | 250 |
247 // | 251 // |
248 // Frame flags and layer id for temporal layers. | 252 // Frame flags and layer id for temporal layers. |
249 // | 253 // |
250 | 254 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 layer_id = 2; | 308 layer_id = 2; |
305 } | 309 } |
306 } | 310 } |
307 return layer_id; | 311 return layer_id; |
308 } | 312 } |
309 | 313 |
310 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, | 314 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, |
311 ::libvpx_test::Encoder *encoder) { | 315 ::libvpx_test::Encoder *encoder) { |
312 if (video->frame() == 1) { | 316 if (video->frame() == 1) { |
313 encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_); | 317 encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_); |
| 318 encoder->Control(VP9E_SET_NOISE_SENSITIVITY, denoiser_on_); |
314 } | 319 } |
315 if (cfg_.ts_number_layers > 1) { | 320 if (cfg_.ts_number_layers > 1) { |
316 if (video->frame() == 1) { | 321 if (video->frame() == 1) { |
317 encoder->Control(VP9E_SET_SVC, 1); | 322 encoder->Control(VP9E_SET_SVC, 1); |
318 } | 323 } |
319 vpx_svc_layer_id_t layer_id = {0, 0}; | 324 vpx_svc_layer_id_t layer_id = {0, 0}; |
320 layer_id.spatial_layer_id = 0; | 325 layer_id.spatial_layer_id = 0; |
321 frame_flags_ = SetFrameFlags(video->frame(), cfg_.ts_number_layers); | 326 frame_flags_ = SetFrameFlags(video->frame(), cfg_.ts_number_layers); |
322 layer_id.temporal_layer_id = SetLayerId(video->frame(), | 327 layer_id.temporal_layer_id = SetLayerId(video->frame(), |
323 cfg_.ts_number_layers); | 328 cfg_.ts_number_layers); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 double timebase_; | 390 double timebase_; |
386 int frame_number_; // Counter for number of non-dropped/encoded frames. | 391 int frame_number_; // Counter for number of non-dropped/encoded frames. |
387 int tot_frame_number_; // Counter for total number of input frames. | 392 int tot_frame_number_; // Counter for total number of input frames. |
388 int64_t bits_total_[3]; | 393 int64_t bits_total_[3]; |
389 double duration_; | 394 double duration_; |
390 double effective_datarate_[3]; | 395 double effective_datarate_[3]; |
391 int set_cpu_used_; | 396 int set_cpu_used_; |
392 int64_t bits_in_buffer_model_; | 397 int64_t bits_in_buffer_model_; |
393 vpx_codec_pts_t first_drop_; | 398 vpx_codec_pts_t first_drop_; |
394 int num_drops_; | 399 int num_drops_; |
| 400 int denoiser_on_; |
395 }; | 401 }; |
396 | 402 |
397 // Check basic rate targeting, | 403 // Check basic rate targeting, |
398 TEST_P(DatarateTestVP9Large, BasicRateTargeting) { | 404 TEST_P(DatarateTestVP9Large, BasicRateTargeting) { |
399 cfg_.rc_buf_initial_sz = 500; | 405 cfg_.rc_buf_initial_sz = 500; |
400 cfg_.rc_buf_optimal_sz = 500; | 406 cfg_.rc_buf_optimal_sz = 500; |
401 cfg_.rc_buf_sz = 1000; | 407 cfg_.rc_buf_sz = 1000; |
402 cfg_.rc_dropframe_thresh = 1; | 408 cfg_.rc_dropframe_thresh = 1; |
403 cfg_.rc_min_quantizer = 0; | 409 cfg_.rc_min_quantizer = 0; |
404 cfg_.rc_max_quantizer = 63; | 410 cfg_.rc_max_quantizer = 63; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 ASSERT_LE(effective_datarate_[j], cfg_.ts_target_bitrate[j] * 1.15) | 614 ASSERT_LE(effective_datarate_[j], cfg_.ts_target_bitrate[j] * 1.15) |
609 << " The datarate for the file is greater than target by too much, " | 615 << " The datarate for the file is greater than target by too much, " |
610 "for layer: " << j; | 616 "for layer: " << j; |
611 // Expect some frame drops in this test: for this 200 frames test, | 617 // Expect some frame drops in this test: for this 200 frames test, |
612 // expect at least 10% and not more than 60% drops. | 618 // expect at least 10% and not more than 60% drops. |
613 ASSERT_GE(num_drops_, 20); | 619 ASSERT_GE(num_drops_, 20); |
614 ASSERT_LE(num_drops_, 130); | 620 ASSERT_LE(num_drops_, 130); |
615 } | 621 } |
616 } | 622 } |
617 | 623 |
| 624 #if CONFIG_VP9_TEMPORAL_DENOISING |
| 625 // Check basic datarate targeting, for a single bitrate, when denoiser is on. |
| 626 TEST_P(DatarateTestVP9Large, DenoiserLevels) { |
| 627 cfg_.rc_buf_initial_sz = 500; |
| 628 cfg_.rc_buf_optimal_sz = 500; |
| 629 cfg_.rc_buf_sz = 1000; |
| 630 cfg_.rc_dropframe_thresh = 1; |
| 631 cfg_.rc_min_quantizer = 2; |
| 632 cfg_.rc_max_quantizer = 56; |
| 633 cfg_.rc_end_usage = VPX_CBR; |
| 634 cfg_.g_lag_in_frames = 0; |
| 635 |
| 636 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, |
| 637 30, 1, 0, 140); |
| 638 |
| 639 // For the temporal denoiser (#if CONFIG_VP9_TEMPORAL_DENOISING), |
| 640 // there is only one denoiser mode: denoiserYonly(which is 1), |
| 641 // but may add more modes in the future. |
| 642 cfg_.rc_target_bitrate = 300; |
| 643 ResetModel(); |
| 644 // Turn on the denoiser. |
| 645 denoiser_on_ = 1; |
| 646 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 647 ASSERT_GE(effective_datarate_[0], cfg_.rc_target_bitrate * 0.85) |
| 648 << " The datarate for the file is lower than target by too much!"; |
| 649 ASSERT_LE(effective_datarate_[0], cfg_.rc_target_bitrate * 1.15) |
| 650 << " The datarate for the file is greater than target by too much!"; |
| 651 } |
| 652 #endif // CONFIG_VP9_TEMPORAL_DENOISING |
| 653 |
618 VP8_INSTANTIATE_TEST_CASE(DatarateTestLarge, ALL_TEST_MODES); | 654 VP8_INSTANTIATE_TEST_CASE(DatarateTestLarge, ALL_TEST_MODES); |
619 VP9_INSTANTIATE_TEST_CASE(DatarateTestVP9Large, | 655 VP9_INSTANTIATE_TEST_CASE(DatarateTestVP9Large, |
620 ::testing::Values(::libvpx_test::kOnePassGood, | 656 ::testing::Values(::libvpx_test::kOnePassGood, |
621 ::libvpx_test::kRealTime), | 657 ::libvpx_test::kRealTime), |
622 ::testing::Range(2, 7)); | 658 ::testing::Range(2, 7)); |
623 } // namespace | 659 } // namespace |
OLD | NEW |