| 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 LosslessTestLarge : public ::libvpx_test::EncoderTest, | 22 class LosslessTest : 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 LosslessTestLarge() | 25 LosslessTest() |
| 26 : EncoderTest(GET_PARAM(0)), | 26 : EncoderTest(GET_PARAM(0)), |
| 27 psnr_(kMaxPsnr), | 27 psnr_(kMaxPsnr), |
| 28 nframes_(0), | 28 nframes_(0), |
| 29 encoding_mode_(GET_PARAM(1)) { | 29 encoding_mode_(GET_PARAM(1)) { |
| 30 } | 30 } |
| 31 | 31 |
| 32 virtual ~LosslessTestLarge() {} | 32 virtual ~LosslessTest() {} |
| 33 | 33 |
| 34 virtual void SetUp() { | 34 virtual void SetUp() { |
| 35 InitializeConfig(); | 35 InitializeConfig(); |
| 36 SetMode(encoding_mode_); | 36 SetMode(encoding_mode_); |
| 37 } | 37 } |
| 38 | 38 |
| 39 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, | 39 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, |
| 40 ::libvpx_test::Encoder *encoder) { | 40 ::libvpx_test::Encoder *encoder) { |
| 41 if (video->frame() == 1) { | 41 if (video->frame() == 1) { |
| 42 // Only call Control if quantizer > 0 to verify that using quantizer | 42 // Only call Control if quantizer > 0 to verify that using quantizer |
| (...skipping 17 matching lines...) Expand all Loading... |
| 60 double GetMinPsnr() const { | 60 double GetMinPsnr() const { |
| 61 return psnr_; | 61 return psnr_; |
| 62 } | 62 } |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 double psnr_; | 65 double psnr_; |
| 66 unsigned int nframes_; | 66 unsigned int nframes_; |
| 67 libvpx_test::TestMode encoding_mode_; | 67 libvpx_test::TestMode encoding_mode_; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 TEST_P(LosslessTestLarge, TestLossLessEncoding) { | 70 TEST_P(LosslessTest, TestLossLessEncoding) { |
| 71 const vpx_rational timebase = { 33333333, 1000000000 }; | 71 const vpx_rational timebase = { 33333333, 1000000000 }; |
| 72 cfg_.g_timebase = timebase; | 72 cfg_.g_timebase = timebase; |
| 73 cfg_.rc_target_bitrate = 2000; | 73 cfg_.rc_target_bitrate = 2000; |
| 74 cfg_.g_lag_in_frames = 25; | 74 cfg_.g_lag_in_frames = 25; |
| 75 cfg_.rc_min_quantizer = 0; | 75 cfg_.rc_min_quantizer = 0; |
| 76 cfg_.rc_max_quantizer = 0; | 76 cfg_.rc_max_quantizer = 0; |
| 77 | 77 |
| 78 init_flags_ = VPX_CODEC_USE_PSNR; | 78 init_flags_ = VPX_CODEC_USE_PSNR; |
| 79 | 79 |
| 80 // intentionally changed the dimension for better testing coverage | 80 // intentionally changed the dimension for better testing coverage |
| 81 libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, | 81 libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, |
| 82 timebase.den, timebase.num, 0, 10); | 82 timebase.den, timebase.num, 0, 10); |
| 83 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); | 83 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 84 const double psnr_lossless = GetMinPsnr(); | 84 const double psnr_lossless = GetMinPsnr(); |
| 85 EXPECT_GE(psnr_lossless, kMaxPsnr); | 85 EXPECT_GE(psnr_lossless, kMaxPsnr); |
| 86 } | 86 } |
| 87 | 87 |
| 88 TEST_P(LosslessTestLarge, TestLossLessEncoding444) { | 88 TEST_P(LosslessTest, TestLossLessEncoding444) { |
| 89 libvpx_test::Y4mVideoSource video("rush_hour_444.y4m", 0, 10); | 89 libvpx_test::Y4mVideoSource video("rush_hour_444.y4m", 0, 10); |
| 90 | 90 |
| 91 cfg_.g_profile = 1; | 91 cfg_.g_profile = 1; |
| 92 cfg_.g_timebase = video.timebase(); | 92 cfg_.g_timebase = video.timebase(); |
| 93 cfg_.rc_target_bitrate = 2000; | 93 cfg_.rc_target_bitrate = 2000; |
| 94 cfg_.g_lag_in_frames = 25; | 94 cfg_.g_lag_in_frames = 25; |
| 95 cfg_.rc_min_quantizer = 0; | 95 cfg_.rc_min_quantizer = 0; |
| 96 cfg_.rc_max_quantizer = 0; | 96 cfg_.rc_max_quantizer = 0; |
| 97 | 97 |
| 98 init_flags_ = VPX_CODEC_USE_PSNR; | 98 init_flags_ = VPX_CODEC_USE_PSNR; |
| 99 | 99 |
| 100 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); | 100 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 101 const double psnr_lossless = GetMinPsnr(); | 101 const double psnr_lossless = GetMinPsnr(); |
| 102 EXPECT_GE(psnr_lossless, kMaxPsnr); | 102 EXPECT_GE(psnr_lossless, kMaxPsnr); |
| 103 } | 103 } |
| 104 | 104 |
| 105 TEST_P(LosslessTestLarge, TestLossLessEncodingCtrl) { | 105 TEST_P(LosslessTest, TestLossLessEncodingCtrl) { |
| 106 const vpx_rational timebase = { 33333333, 1000000000 }; | 106 const vpx_rational timebase = { 33333333, 1000000000 }; |
| 107 cfg_.g_timebase = timebase; | 107 cfg_.g_timebase = timebase; |
| 108 cfg_.rc_target_bitrate = 2000; | 108 cfg_.rc_target_bitrate = 2000; |
| 109 cfg_.g_lag_in_frames = 25; | 109 cfg_.g_lag_in_frames = 25; |
| 110 // Intentionally set Q > 0, to make sure control can be used to activate | 110 // Intentionally set Q > 0, to make sure control can be used to activate |
| 111 // lossless | 111 // lossless |
| 112 cfg_.rc_min_quantizer = 10; | 112 cfg_.rc_min_quantizer = 10; |
| 113 cfg_.rc_max_quantizer = 20; | 113 cfg_.rc_max_quantizer = 20; |
| 114 | 114 |
| 115 init_flags_ = VPX_CODEC_USE_PSNR; | 115 init_flags_ = VPX_CODEC_USE_PSNR; |
| 116 | 116 |
| 117 libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, | 117 libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, |
| 118 timebase.den, timebase.num, 0, 10); | 118 timebase.den, timebase.num, 0, 10); |
| 119 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); | 119 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 120 const double psnr_lossless = GetMinPsnr(); | 120 const double psnr_lossless = GetMinPsnr(); |
| 121 EXPECT_GE(psnr_lossless, kMaxPsnr); | 121 EXPECT_GE(psnr_lossless, kMaxPsnr); |
| 122 } | 122 } |
| 123 | 123 |
| 124 VP9_INSTANTIATE_TEST_CASE(LosslessTestLarge, ALL_TEST_MODES); | 124 VP9_INSTANTIATE_TEST_CASE(LosslessTest, |
| 125 ::testing::Values(::libvpx_test::kRealTime, |
| 126 ::libvpx_test::kOnePassGood, |
| 127 ::libvpx_test::kTwoPassGood)); |
| 125 } // namespace | 128 } // namespace |
| OLD | NEW |