OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 | 10 |
11 #include "third_party/googletest/src/include/gtest/gtest.h" | 11 #include "third_party/googletest/src/include/gtest/gtest.h" |
12 #include "test/codec_factory.h" | 12 #include "test/codec_factory.h" |
13 #include "test/encode_test_driver.h" | 13 #include "test/encode_test_driver.h" |
14 #include "test/i420_video_source.h" | 14 #include "test/i420_video_source.h" |
15 #include "test/util.h" | 15 #include "test/util.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 const int kMaxErrorFrames = 12; | 19 const int kMaxErrorFrames = 12; |
20 const int kMaxDroppableFrames = 12; | 20 const int kMaxDroppableFrames = 12; |
21 | 21 |
22 class ErrorResilienceTest : public ::libvpx_test::EncoderTest, | 22 class ErrorResilienceTestLarge : public ::libvpx_test::EncoderTest, |
23 public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> { | 23 public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> { |
24 protected: | 24 protected: |
25 ErrorResilienceTest() : EncoderTest(GET_PARAM(0)), | 25 ErrorResilienceTestLarge() |
26 psnr_(0.0), | 26 : EncoderTest(GET_PARAM(0)), |
27 nframes_(0), | 27 psnr_(0.0), |
28 mismatch_psnr_(0.0), | 28 nframes_(0), |
29 mismatch_nframes_(0), | 29 mismatch_psnr_(0.0), |
30 encoding_mode_(GET_PARAM(1)) { | 30 mismatch_nframes_(0), |
| 31 encoding_mode_(GET_PARAM(1)) { |
31 Reset(); | 32 Reset(); |
32 } | 33 } |
33 | 34 |
34 virtual ~ErrorResilienceTest() {} | 35 virtual ~ErrorResilienceTestLarge() {} |
35 | 36 |
36 void Reset() { | 37 void Reset() { |
37 error_nframes_ = 0; | 38 error_nframes_ = 0; |
38 droppable_nframes_ = 0; | 39 droppable_nframes_ = 0; |
39 } | 40 } |
40 | 41 |
41 virtual void SetUp() { | 42 virtual void SetUp() { |
42 InitializeConfig(); | 43 InitializeConfig(); |
43 SetMode(encoding_mode_); | 44 SetMode(encoding_mode_); |
44 } | 45 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 unsigned int nframes_; | 138 unsigned int nframes_; |
138 unsigned int error_nframes_; | 139 unsigned int error_nframes_; |
139 unsigned int droppable_nframes_; | 140 unsigned int droppable_nframes_; |
140 double mismatch_psnr_; | 141 double mismatch_psnr_; |
141 unsigned int mismatch_nframes_; | 142 unsigned int mismatch_nframes_; |
142 unsigned int error_frames_[kMaxErrorFrames]; | 143 unsigned int error_frames_[kMaxErrorFrames]; |
143 unsigned int droppable_frames_[kMaxDroppableFrames]; | 144 unsigned int droppable_frames_[kMaxDroppableFrames]; |
144 libvpx_test::TestMode encoding_mode_; | 145 libvpx_test::TestMode encoding_mode_; |
145 }; | 146 }; |
146 | 147 |
147 TEST_P(ErrorResilienceTest, OnVersusOff) { | 148 TEST_P(ErrorResilienceTestLarge, OnVersusOff) { |
148 const vpx_rational timebase = { 33333333, 1000000000 }; | 149 const vpx_rational timebase = { 33333333, 1000000000 }; |
149 cfg_.g_timebase = timebase; | 150 cfg_.g_timebase = timebase; |
150 cfg_.rc_target_bitrate = 2000; | 151 cfg_.rc_target_bitrate = 2000; |
151 cfg_.g_lag_in_frames = 10; | 152 cfg_.g_lag_in_frames = 10; |
152 | 153 |
153 init_flags_ = VPX_CODEC_USE_PSNR; | 154 init_flags_ = VPX_CODEC_USE_PSNR; |
154 | 155 |
155 libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, | 156 libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, |
156 timebase.den, timebase.num, 0, 30); | 157 timebase.den, timebase.num, 0, 30); |
157 | 158 |
(...skipping 14 matching lines...) Expand all Loading... |
172 const double psnr_ratio = psnr_resilience_on / psnr_resilience_off; | 173 const double psnr_ratio = psnr_resilience_on / psnr_resilience_off; |
173 EXPECT_GE(psnr_ratio, 0.9); | 174 EXPECT_GE(psnr_ratio, 0.9); |
174 EXPECT_LE(psnr_ratio, 1.1); | 175 EXPECT_LE(psnr_ratio, 1.1); |
175 } | 176 } |
176 } | 177 } |
177 | 178 |
178 // Check for successful decoding and no encoder/decoder mismatch | 179 // Check for successful decoding and no encoder/decoder mismatch |
179 // if we lose (i.e., drop before decoding) a set of droppable | 180 // if we lose (i.e., drop before decoding) a set of droppable |
180 // frames (i.e., frames that don't update any reference buffers). | 181 // frames (i.e., frames that don't update any reference buffers). |
181 // Check both isolated and consecutive loss. | 182 // Check both isolated and consecutive loss. |
182 TEST_P(ErrorResilienceTest, DropFramesWithoutRecovery) { | 183 TEST_P(ErrorResilienceTestLarge, DropFramesWithoutRecovery) { |
183 const vpx_rational timebase = { 33333333, 1000000000 }; | 184 const vpx_rational timebase = { 33333333, 1000000000 }; |
184 cfg_.g_timebase = timebase; | 185 cfg_.g_timebase = timebase; |
185 cfg_.rc_target_bitrate = 500; | 186 cfg_.rc_target_bitrate = 500; |
186 // FIXME(debargha): Fix this to work for any lag. | 187 // FIXME(debargha): Fix this to work for any lag. |
187 // Currently this test only works for lag = 0 | 188 // Currently this test only works for lag = 0 |
188 cfg_.g_lag_in_frames = 0; | 189 cfg_.g_lag_in_frames = 0; |
189 | 190 |
190 init_flags_ = VPX_CODEC_USE_PSNR; | 191 init_flags_ = VPX_CODEC_USE_PSNR; |
191 | 192 |
192 libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, | 193 libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 // Note the Average Mismatch PSNR is the average of the PSNR between | 229 // Note the Average Mismatch PSNR is the average of the PSNR between |
229 // decoded frame and encoder's version of the same frame for all frames | 230 // decoded frame and encoder's version of the same frame for all frames |
230 // with mismatch. | 231 // with mismatch. |
231 const double psnr_resilience_mismatch = GetAverageMismatchPsnr(); | 232 const double psnr_resilience_mismatch = GetAverageMismatchPsnr(); |
232 std::cout << " Mismatch PSNR: " | 233 std::cout << " Mismatch PSNR: " |
233 << psnr_resilience_mismatch << "\n"; | 234 << psnr_resilience_mismatch << "\n"; |
234 EXPECT_GT(psnr_resilience_mismatch, 20.0); | 235 EXPECT_GT(psnr_resilience_mismatch, 20.0); |
235 #endif | 236 #endif |
236 } | 237 } |
237 | 238 |
238 VP8_INSTANTIATE_TEST_CASE(ErrorResilienceTest, ONE_PASS_TEST_MODES); | 239 VP8_INSTANTIATE_TEST_CASE(ErrorResilienceTestLarge, ONE_PASS_TEST_MODES); |
239 VP9_INSTANTIATE_TEST_CASE(ErrorResilienceTest, ONE_PASS_TEST_MODES); | 240 VP9_INSTANTIATE_TEST_CASE(ErrorResilienceTestLarge, ONE_PASS_TEST_MODES); |
240 | 241 |
241 } // namespace | 242 } // namespace |
OLD | NEW |