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 #include "./vpx_config.h" | 10 #include "./vpx_config.h" |
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 #include "test/y4m_video_source.h" | 16 #include "test/y4m_video_source.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 const int kMaxPsnr = 100; | 20 const int kMaxPsnr = 100; |
21 | 21 |
22 class LossLessTest : public ::libvpx_test::EncoderTest, | 22 class LosslessTestLarge : 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 LossLessTest() : EncoderTest(GET_PARAM(0)), | 25 LosslessTestLarge() |
26 psnr_(kMaxPsnr), | 26 : EncoderTest(GET_PARAM(0)), |
27 nframes_(0), | 27 psnr_(kMaxPsnr), |
28 encoding_mode_(GET_PARAM(1)) { | 28 nframes_(0), |
| 29 encoding_mode_(GET_PARAM(1)) { |
29 } | 30 } |
30 | 31 |
31 virtual ~LossLessTest() {} | 32 virtual ~LosslessTestLarge() {} |
32 | 33 |
33 virtual void SetUp() { | 34 virtual void SetUp() { |
34 InitializeConfig(); | 35 InitializeConfig(); |
35 SetMode(encoding_mode_); | 36 SetMode(encoding_mode_); |
36 } | 37 } |
37 | 38 |
38 virtual void BeginPassHook(unsigned int /*pass*/) { | 39 virtual void BeginPassHook(unsigned int /*pass*/) { |
39 psnr_ = kMaxPsnr; | 40 psnr_ = kMaxPsnr; |
40 nframes_ = 0; | 41 nframes_ = 0; |
41 } | 42 } |
42 | 43 |
43 virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) { | 44 virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) { |
44 if (pkt->data.psnr.psnr[0] < psnr_) | 45 if (pkt->data.psnr.psnr[0] < psnr_) |
45 psnr_= pkt->data.psnr.psnr[0]; | 46 psnr_= pkt->data.psnr.psnr[0]; |
46 } | 47 } |
47 | 48 |
48 double GetMinPsnr() const { | 49 double GetMinPsnr() const { |
49 return psnr_; | 50 return psnr_; |
50 } | 51 } |
51 | 52 |
52 private: | 53 private: |
53 double psnr_; | 54 double psnr_; |
54 unsigned int nframes_; | 55 unsigned int nframes_; |
55 libvpx_test::TestMode encoding_mode_; | 56 libvpx_test::TestMode encoding_mode_; |
56 }; | 57 }; |
57 | 58 |
58 TEST_P(LossLessTest, TestLossLessEncoding) { | 59 TEST_P(LosslessTestLarge, TestLossLessEncoding) { |
59 const vpx_rational timebase = { 33333333, 1000000000 }; | 60 const vpx_rational timebase = { 33333333, 1000000000 }; |
60 cfg_.g_timebase = timebase; | 61 cfg_.g_timebase = timebase; |
61 cfg_.rc_target_bitrate = 2000; | 62 cfg_.rc_target_bitrate = 2000; |
62 cfg_.g_lag_in_frames = 25; | 63 cfg_.g_lag_in_frames = 25; |
63 cfg_.rc_min_quantizer = 0; | 64 cfg_.rc_min_quantizer = 0; |
64 cfg_.rc_max_quantizer = 0; | 65 cfg_.rc_max_quantizer = 0; |
65 | 66 |
66 init_flags_ = VPX_CODEC_USE_PSNR; | 67 init_flags_ = VPX_CODEC_USE_PSNR; |
67 | 68 |
68 // intentionally changed the dimension for better testing coverage | 69 // intentionally changed the dimension for better testing coverage |
69 libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, | 70 libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, |
70 timebase.den, timebase.num, 0, 10); | 71 timebase.den, timebase.num, 0, 10); |
71 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); | 72 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
72 const double psnr_lossless = GetMinPsnr(); | 73 const double psnr_lossless = GetMinPsnr(); |
73 EXPECT_GE(psnr_lossless, kMaxPsnr); | 74 EXPECT_GE(psnr_lossless, kMaxPsnr); |
74 } | 75 } |
75 | 76 |
76 TEST_P(LossLessTest, TestLossLessEncoding444) { | 77 TEST_P(LosslessTestLarge, TestLossLessEncoding444) { |
77 libvpx_test::Y4mVideoSource video("rush_hour_444.y4m", 0, 10); | 78 libvpx_test::Y4mVideoSource video("rush_hour_444.y4m", 0, 10); |
78 | 79 |
79 cfg_.g_profile = 1; | 80 cfg_.g_profile = 1; |
80 cfg_.g_timebase = video.timebase(); | 81 cfg_.g_timebase = video.timebase(); |
81 cfg_.rc_target_bitrate = 2000; | 82 cfg_.rc_target_bitrate = 2000; |
82 cfg_.g_lag_in_frames = 25; | 83 cfg_.g_lag_in_frames = 25; |
83 cfg_.rc_min_quantizer = 0; | 84 cfg_.rc_min_quantizer = 0; |
84 cfg_.rc_max_quantizer = 0; | 85 cfg_.rc_max_quantizer = 0; |
85 | 86 |
86 init_flags_ = VPX_CODEC_USE_PSNR; | 87 init_flags_ = VPX_CODEC_USE_PSNR; |
87 | 88 |
88 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); | 89 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
89 const double psnr_lossless = GetMinPsnr(); | 90 const double psnr_lossless = GetMinPsnr(); |
90 EXPECT_GE(psnr_lossless, kMaxPsnr); | 91 EXPECT_GE(psnr_lossless, kMaxPsnr); |
91 } | 92 } |
92 | 93 |
93 VP9_INSTANTIATE_TEST_CASE(LossLessTest, ALL_TEST_MODES); | 94 VP9_INSTANTIATE_TEST_CASE(LosslessTestLarge, ALL_TEST_MODES); |
94 } // namespace | 95 } // namespace |
OLD | NEW |