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 20 matching lines...) Expand all Loading... |
31 ResetModel(); | 31 ResetModel(); |
32 } | 32 } |
33 | 33 |
34 virtual void ResetModel() { | 34 virtual void ResetModel() { |
35 last_pts_ = 0; | 35 last_pts_ = 0; |
36 bits_in_buffer_model_ = cfg_.rc_target_bitrate * cfg_.rc_buf_initial_sz; | 36 bits_in_buffer_model_ = cfg_.rc_target_bitrate * cfg_.rc_buf_initial_sz; |
37 frame_number_ = 0; | 37 frame_number_ = 0; |
38 first_drop_ = 0; | 38 first_drop_ = 0; |
39 bits_total_ = 0; | 39 bits_total_ = 0; |
40 duration_ = 0.0; | 40 duration_ = 0.0; |
| 41 denoiser_offon_test_ = 0; |
| 42 denoiser_offon_period_ = -1; |
41 } | 43 } |
42 | 44 |
43 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, | 45 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, |
44 ::libvpx_test::Encoder *encoder) { | 46 ::libvpx_test::Encoder *encoder) { |
45 if (video->frame() == 1) { | 47 if (video->frame() == 1) { |
46 encoder->Control(VP8E_SET_NOISE_SENSITIVITY, denoiser_on_); | 48 encoder->Control(VP8E_SET_NOISE_SENSITIVITY, denoiser_on_); |
47 } | 49 } |
| 50 |
| 51 if (denoiser_offon_test_) { |
| 52 ASSERT_GT(denoiser_offon_period_, 0) |
| 53 << "denoiser_offon_period_ is not positive."; |
| 54 if ((video->frame() + 1) % denoiser_offon_period_ == 0) { |
| 55 // Flip denoiser_on_ periodically |
| 56 denoiser_on_ ^= 1; |
| 57 } |
| 58 encoder->Control(VP8E_SET_NOISE_SENSITIVITY, denoiser_on_); |
| 59 } |
| 60 |
48 const vpx_rational_t tb = video->timebase(); | 61 const vpx_rational_t tb = video->timebase(); |
49 timebase_ = static_cast<double>(tb.num) / tb.den; | 62 timebase_ = static_cast<double>(tb.num) / tb.den; |
50 duration_ = 0; | 63 duration_ = 0; |
51 } | 64 } |
52 | 65 |
53 virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) { | 66 virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) { |
54 // Time since last timestamp = duration. | 67 // Time since last timestamp = duration. |
55 vpx_codec_pts_t duration = pkt->data.frame.pts - last_pts_; | 68 vpx_codec_pts_t duration = pkt->data.frame.pts - last_pts_; |
56 | 69 |
57 // TODO(jimbankoski): Remove these lines when the issue: | 70 // TODO(jimbankoski): Remove these lines when the issue: |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 int64_t bits_in_buffer_model_; | 130 int64_t bits_in_buffer_model_; |
118 double timebase_; | 131 double timebase_; |
119 int frame_number_; | 132 int frame_number_; |
120 vpx_codec_pts_t first_drop_; | 133 vpx_codec_pts_t first_drop_; |
121 int64_t bits_total_; | 134 int64_t bits_total_; |
122 double duration_; | 135 double duration_; |
123 double file_datarate_; | 136 double file_datarate_; |
124 double effective_datarate_; | 137 double effective_datarate_; |
125 size_t bits_in_last_frame_; | 138 size_t bits_in_last_frame_; |
126 int denoiser_on_; | 139 int denoiser_on_; |
| 140 int denoiser_offon_test_; |
| 141 int denoiser_offon_period_; |
127 }; | 142 }; |
128 | 143 |
129 #if CONFIG_TEMPORAL_DENOISING | 144 #if CONFIG_TEMPORAL_DENOISING |
130 // Check basic datarate targeting, for a single bitrate, but loop over the | 145 // Check basic datarate targeting, for a single bitrate, but loop over the |
131 // various denoiser settings. | 146 // various denoiser settings. |
132 TEST_P(DatarateTestLarge, DenoiserLevels) { | 147 TEST_P(DatarateTestLarge, DenoiserLevels) { |
133 cfg_.rc_buf_initial_sz = 500; | 148 cfg_.rc_buf_initial_sz = 500; |
134 cfg_.rc_dropframe_thresh = 1; | 149 cfg_.rc_dropframe_thresh = 1; |
135 cfg_.rc_max_quantizer = 56; | 150 cfg_.rc_max_quantizer = 56; |
136 cfg_.rc_end_usage = VPX_CBR; | 151 cfg_.rc_end_usage = VPX_CBR; |
(...skipping 11 matching lines...) Expand all Loading... |
148 cfg_.rc_target_bitrate = 300; | 163 cfg_.rc_target_bitrate = 300; |
149 ResetModel(); | 164 ResetModel(); |
150 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); | 165 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
151 ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95) | 166 ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95) |
152 << " The datarate for the file exceeds the target!"; | 167 << " The datarate for the file exceeds the target!"; |
153 | 168 |
154 ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.3) | 169 ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.3) |
155 << " The datarate for the file missed the target!"; | 170 << " The datarate for the file missed the target!"; |
156 } | 171 } |
157 } | 172 } |
| 173 |
| 174 // Check basic datarate targeting, for a single bitrate, when denoiser is off |
| 175 // and on. |
| 176 TEST_P(DatarateTestLarge, DenoiserOffOn) { |
| 177 cfg_.rc_buf_initial_sz = 500; |
| 178 cfg_.rc_dropframe_thresh = 1; |
| 179 cfg_.rc_max_quantizer = 56; |
| 180 cfg_.rc_end_usage = VPX_CBR; |
| 181 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, |
| 182 30, 1, 0, 299); |
| 183 cfg_.rc_target_bitrate = 300; |
| 184 ResetModel(); |
| 185 // The denoiser is off by default. |
| 186 denoiser_on_ = 0; |
| 187 // Set the offon test flag. |
| 188 denoiser_offon_test_ = 1; |
| 189 denoiser_offon_period_ = 100; |
| 190 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 191 ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95) |
| 192 << " The datarate for the file exceeds the target!"; |
| 193 ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.3) |
| 194 << " The datarate for the file missed the target!"; |
| 195 } |
158 #endif // CONFIG_TEMPORAL_DENOISING | 196 #endif // CONFIG_TEMPORAL_DENOISING |
159 | 197 |
160 TEST_P(DatarateTestLarge, BasicBufferModel) { | 198 TEST_P(DatarateTestLarge, BasicBufferModel) { |
161 denoiser_on_ = 0; | 199 denoiser_on_ = 0; |
162 cfg_.rc_buf_initial_sz = 500; | 200 cfg_.rc_buf_initial_sz = 500; |
163 cfg_.rc_dropframe_thresh = 1; | 201 cfg_.rc_dropframe_thresh = 1; |
164 cfg_.rc_max_quantizer = 56; | 202 cfg_.rc_max_quantizer = 56; |
165 cfg_.rc_end_usage = VPX_CBR; | 203 cfg_.rc_end_usage = VPX_CBR; |
166 // 2 pass cbr datarate control has a bug hidden by the small # of | 204 // 2 pass cbr datarate control has a bug hidden by the small # of |
167 // frames selected in this encode. The problem is that even if the buffer is | 205 // frames selected in this encode. The problem is that even if the buffer is |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 denoiser_on_ = 1; | 700 denoiser_on_ = 1; |
663 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); | 701 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
664 ASSERT_GE(effective_datarate_[0], cfg_.rc_target_bitrate * 0.85) | 702 ASSERT_GE(effective_datarate_[0], cfg_.rc_target_bitrate * 0.85) |
665 << " The datarate for the file is lower than target by too much!"; | 703 << " The datarate for the file is lower than target by too much!"; |
666 ASSERT_LE(effective_datarate_[0], cfg_.rc_target_bitrate * 1.15) | 704 ASSERT_LE(effective_datarate_[0], cfg_.rc_target_bitrate * 1.15) |
667 << " The datarate for the file is greater than target by too much!"; | 705 << " The datarate for the file is greater than target by too much!"; |
668 } | 706 } |
669 | 707 |
670 // Check basic datarate targeting, for a single bitrate, when denoiser is off | 708 // Check basic datarate targeting, for a single bitrate, when denoiser is off |
671 // and on. | 709 // and on. |
672 TEST_P(DatarateTestVP9Large, DenoiserOffon) { | 710 TEST_P(DatarateTestVP9Large, DenoiserOffOn) { |
673 cfg_.rc_buf_initial_sz = 500; | 711 cfg_.rc_buf_initial_sz = 500; |
674 cfg_.rc_buf_optimal_sz = 500; | 712 cfg_.rc_buf_optimal_sz = 500; |
675 cfg_.rc_buf_sz = 1000; | 713 cfg_.rc_buf_sz = 1000; |
676 cfg_.rc_dropframe_thresh = 1; | 714 cfg_.rc_dropframe_thresh = 1; |
677 cfg_.rc_min_quantizer = 2; | 715 cfg_.rc_min_quantizer = 2; |
678 cfg_.rc_max_quantizer = 56; | 716 cfg_.rc_max_quantizer = 56; |
679 cfg_.rc_end_usage = VPX_CBR; | 717 cfg_.rc_end_usage = VPX_CBR; |
680 cfg_.g_lag_in_frames = 0; | 718 cfg_.g_lag_in_frames = 0; |
681 | 719 |
682 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, | 720 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, |
(...skipping 16 matching lines...) Expand all Loading... |
699 << " The datarate for the file is greater than target by too much!"; | 737 << " The datarate for the file is greater than target by too much!"; |
700 } | 738 } |
701 #endif // CONFIG_VP9_TEMPORAL_DENOISING | 739 #endif // CONFIG_VP9_TEMPORAL_DENOISING |
702 | 740 |
703 VP8_INSTANTIATE_TEST_CASE(DatarateTestLarge, ALL_TEST_MODES); | 741 VP8_INSTANTIATE_TEST_CASE(DatarateTestLarge, ALL_TEST_MODES); |
704 VP9_INSTANTIATE_TEST_CASE(DatarateTestVP9Large, | 742 VP9_INSTANTIATE_TEST_CASE(DatarateTestVP9Large, |
705 ::testing::Values(::libvpx_test::kOnePassGood, | 743 ::testing::Values(::libvpx_test::kOnePassGood, |
706 ::libvpx_test::kRealTime), | 744 ::libvpx_test::kRealTime), |
707 ::testing::Range(2, 7)); | 745 ::testing::Range(2, 7)); |
708 } // namespace | 746 } // namespace |
OLD | NEW |