| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 "test/codec_factory.h" | 11 #include "test/codec_factory.h" |
| 12 #include "test/encode_test_driver.h" | 12 #include "test/encode_test_driver.h" |
| 13 #include "test/y4m_video_source.h" | 13 #include "test/y4m_video_source.h" |
| 14 #include "test/yuv_video_source.h" | 14 #include "test/yuv_video_source.h" |
| 15 #include "test/util.h" | 15 #include "test/util.h" |
| 16 #include "third_party/googletest/src/include/gtest/gtest.h" | 16 #include "third_party/googletest/src/include/gtest/gtest.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 const unsigned int kWidth = 160; | 20 const unsigned int kWidth = 160; |
| 21 const unsigned int kHeight = 90; | 21 const unsigned int kHeight = 90; |
| 22 const unsigned int kFramerate = 50; | 22 const unsigned int kFramerate = 50; |
| 23 const unsigned int kFrames = 10; | 23 const unsigned int kFrames = 10; |
| 24 const int kBitrate = 500; | 24 const int kBitrate = 500; |
| 25 const int kCpuUsed = 2; | 25 // List of psnr thresholds for speed settings 0-7 and 5 encoding modes |
| 26 const double psnr_threshold = 35.0; | 26 const double kPsnrThreshold[][5] = { |
| 27 { 36.0, 37.0, 37.0, 37.0, 37.0 }, |
| 28 { 35.0, 36.0, 36.0, 36.0, 36.0 }, |
| 29 { 34.0, 35.0, 35.0, 35.0, 35.0 }, |
| 30 { 33.0, 34.0, 34.0, 34.0, 34.0 }, |
| 31 { 32.0, 33.0, 33.0, 33.0, 33.0 }, |
| 32 { 31.0, 32.0, 32.0, 32.0, 32.0 }, |
| 33 { 30.0, 31.0, 31.0, 31.0, 31.0 }, |
| 34 { 29.0, 30.0, 30.0, 30.0, 30.0 }, |
| 35 }; |
| 27 | 36 |
| 28 typedef struct { | 37 typedef struct { |
| 29 const char *filename; | 38 const char *filename; |
| 30 unsigned int input_bit_depth; | 39 unsigned int input_bit_depth; |
| 31 vpx_img_fmt fmt; | 40 vpx_img_fmt fmt; |
| 32 vpx_bit_depth_t bit_depth; | 41 vpx_bit_depth_t bit_depth; |
| 33 unsigned int profile; | 42 unsigned int profile; |
| 34 } TestVideoParam; | 43 } TestVideoParam; |
| 35 | 44 |
| 36 const TestVideoParam TestVectors[] = { | 45 const TestVideoParam kTestVectors[] = { |
| 37 {"park_joy_90p_8_420.y4m", 8, VPX_IMG_FMT_I420, VPX_BITS_8, 0}, | 46 {"park_joy_90p_8_420.y4m", 8, VPX_IMG_FMT_I420, VPX_BITS_8, 0}, |
| 38 {"park_joy_90p_8_422.y4m", 8, VPX_IMG_FMT_I422, VPX_BITS_8, 1}, | 47 {"park_joy_90p_8_422.y4m", 8, VPX_IMG_FMT_I422, VPX_BITS_8, 1}, |
| 39 {"park_joy_90p_8_444.y4m", 8, VPX_IMG_FMT_I444, VPX_BITS_8, 1}, | 48 {"park_joy_90p_8_444.y4m", 8, VPX_IMG_FMT_I444, VPX_BITS_8, 1}, |
| 40 {"park_joy_90p_8_440.yuv", 8, VPX_IMG_FMT_I440, VPX_BITS_8, 1}, | 49 {"park_joy_90p_8_440.yuv", 8, VPX_IMG_FMT_I440, VPX_BITS_8, 1}, |
| 41 #if CONFIG_VP9_HIGHBITDEPTH | 50 #if CONFIG_VP9_HIGHBITDEPTH |
| 42 {"park_joy_90p_10_420.y4m", 10, VPX_IMG_FMT_I42016, VPX_BITS_10, 2}, | 51 {"park_joy_90p_10_420.y4m", 10, VPX_IMG_FMT_I42016, VPX_BITS_10, 2}, |
| 43 {"park_joy_90p_10_422.y4m", 10, VPX_IMG_FMT_I42216, VPX_BITS_10, 3}, | 52 {"park_joy_90p_10_422.y4m", 10, VPX_IMG_FMT_I42216, VPX_BITS_10, 3}, |
| 44 {"park_joy_90p_10_444.y4m", 10, VPX_IMG_FMT_I44416, VPX_BITS_10, 3}, | 53 {"park_joy_90p_10_444.y4m", 10, VPX_IMG_FMT_I44416, VPX_BITS_10, 3}, |
| 45 {"park_joy_90p_10_440.yuv", 10, VPX_IMG_FMT_I44016, VPX_BITS_10, 3}, | 54 {"park_joy_90p_10_440.yuv", 10, VPX_IMG_FMT_I44016, VPX_BITS_10, 3}, |
| 46 {"park_joy_90p_12_420.y4m", 12, VPX_IMG_FMT_I42016, VPX_BITS_12, 2}, | 55 {"park_joy_90p_12_420.y4m", 12, VPX_IMG_FMT_I42016, VPX_BITS_12, 2}, |
| 47 {"park_joy_90p_12_422.y4m", 12, VPX_IMG_FMT_I42216, VPX_BITS_12, 3}, | 56 {"park_joy_90p_12_422.y4m", 12, VPX_IMG_FMT_I42216, VPX_BITS_12, 3}, |
| 48 {"park_joy_90p_12_444.y4m", 12, VPX_IMG_FMT_I44416, VPX_BITS_12, 3}, | 57 {"park_joy_90p_12_444.y4m", 12, VPX_IMG_FMT_I44416, VPX_BITS_12, 3}, |
| 49 {"park_joy_90p_12_440.yuv", 12, VPX_IMG_FMT_I44016, VPX_BITS_12, 3}, | 58 {"park_joy_90p_12_440.yuv", 12, VPX_IMG_FMT_I44016, VPX_BITS_12, 3}, |
| 50 #endif // CONFIG_VP9_HIGHBITDEPTH | 59 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 51 }; | 60 }; |
| 52 | 61 |
| 62 // Encoding modes tested |
| 63 const libvpx_test::TestMode kEncodingModeVectors[] = { |
| 64 ::libvpx_test::kTwoPassGood, |
| 65 ::libvpx_test::kOnePassGood, |
| 66 ::libvpx_test::kRealTime, |
| 67 }; |
| 68 |
| 69 // Speed settings tested |
| 70 const int kCpuUsedVectors[] = {1, 2, 3, 5, 6}; |
| 71 |
| 53 int is_extension_y4m(const char *filename) { | 72 int is_extension_y4m(const char *filename) { |
| 54 const char *dot = strrchr(filename, '.'); | 73 const char *dot = strrchr(filename, '.'); |
| 55 if (!dot || dot == filename) | 74 if (!dot || dot == filename) |
| 56 return 0; | 75 return 0; |
| 57 else | 76 else |
| 58 return !strcmp(dot, ".y4m"); | 77 return !strcmp(dot, ".y4m"); |
| 59 } | 78 } |
| 60 | 79 |
| 61 class EndToEndTestLarge | 80 class EndToEndTestLarge |
| 62 : public ::libvpx_test::EncoderTest, | 81 : public ::libvpx_test::EncoderTest, |
| 63 public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, \ | 82 public ::libvpx_test::CodecTestWith3Params<libvpx_test::TestMode, \ |
| 64 TestVideoParam> { | 83 TestVideoParam, int> { |
| 65 protected: | 84 protected: |
| 66 EndToEndTestLarge() | 85 EndToEndTestLarge() |
| 67 : EncoderTest(GET_PARAM(0)), | 86 : EncoderTest(GET_PARAM(0)), |
| 87 test_video_param_(GET_PARAM(2)), |
| 88 cpu_used_(GET_PARAM(3)), |
| 68 psnr_(0.0), | 89 psnr_(0.0), |
| 69 nframes_(0), | 90 nframes_(0), |
| 70 encoding_mode_(GET_PARAM(1)) { | 91 encoding_mode_(GET_PARAM(1)) { |
| 71 } | 92 } |
| 72 | 93 |
| 73 virtual ~EndToEndTestLarge() {} | 94 virtual ~EndToEndTestLarge() {} |
| 74 | 95 |
| 75 virtual void SetUp() { | 96 virtual void SetUp() { |
| 76 InitializeConfig(); | 97 InitializeConfig(); |
| 77 SetMode(encoding_mode_); | 98 SetMode(encoding_mode_); |
| 78 if (encoding_mode_ != ::libvpx_test::kRealTime) { | 99 if (encoding_mode_ != ::libvpx_test::kRealTime) { |
| 79 cfg_.g_lag_in_frames = 5; | 100 cfg_.g_lag_in_frames = 5; |
| 80 cfg_.rc_end_usage = VPX_VBR; | 101 cfg_.rc_end_usage = VPX_VBR; |
| 81 } else { | 102 } else { |
| 82 cfg_.g_lag_in_frames = 0; | 103 cfg_.g_lag_in_frames = 0; |
| 83 cfg_.rc_end_usage = VPX_CBR; | 104 cfg_.rc_end_usage = VPX_CBR; |
| 105 cfg_.rc_buf_sz = 1000; |
| 106 cfg_.rc_buf_initial_sz = 500; |
| 107 cfg_.rc_buf_optimal_sz = 600; |
| 84 } | 108 } |
| 85 test_video_param_ = GET_PARAM(2); | 109 dec_cfg_.threads = 4; |
| 86 } | 110 } |
| 87 | 111 |
| 88 virtual void BeginPassHook(unsigned int) { | 112 virtual void BeginPassHook(unsigned int) { |
| 89 psnr_ = 0.0; | 113 psnr_ = 0.0; |
| 90 nframes_ = 0; | 114 nframes_ = 0; |
| 91 } | 115 } |
| 92 | 116 |
| 93 virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) { | 117 virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) { |
| 94 psnr_ += pkt->data.psnr.psnr[0]; | 118 psnr_ += pkt->data.psnr.psnr[0]; |
| 95 nframes_++; | 119 nframes_++; |
| 96 } | 120 } |
| 97 | 121 |
| 98 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, | 122 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, |
| 99 ::libvpx_test::Encoder *encoder) { | 123 ::libvpx_test::Encoder *encoder) { |
| 100 if (video->frame() == 1) { | 124 if (video->frame() == 1) { |
| 101 encoder->Control(VP8E_SET_CPUUSED, kCpuUsed); | 125 encoder->Control(VP9E_SET_FRAME_PARALLEL_DECODING, 1); |
| 126 encoder->Control(VP9E_SET_TILE_COLUMNS, 4); |
| 127 encoder->Control(VP8E_SET_CPUUSED, cpu_used_); |
| 102 if (encoding_mode_ != ::libvpx_test::kRealTime) { | 128 if (encoding_mode_ != ::libvpx_test::kRealTime) { |
| 103 encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1); | 129 encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1); |
| 104 encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7); | 130 encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7); |
| 105 encoder->Control(VP8E_SET_ARNR_STRENGTH, 5); | 131 encoder->Control(VP8E_SET_ARNR_STRENGTH, 5); |
| 106 encoder->Control(VP8E_SET_ARNR_TYPE, 3); | 132 encoder->Control(VP8E_SET_ARNR_TYPE, 3); |
| 107 } | 133 } |
| 108 } | 134 } |
| 109 } | 135 } |
| 110 | 136 |
| 111 double GetAveragePsnr() const { | 137 double GetAveragePsnr() const { |
| 112 if (nframes_) | 138 if (nframes_) |
| 113 return psnr_ / nframes_; | 139 return psnr_ / nframes_; |
| 114 return 0.0; | 140 return 0.0; |
| 115 } | 141 } |
| 116 | 142 |
| 143 double GetPsnrThreshold() { |
| 144 return kPsnrThreshold[cpu_used_][encoding_mode_]; |
| 145 } |
| 146 |
| 117 TestVideoParam test_video_param_; | 147 TestVideoParam test_video_param_; |
| 148 int cpu_used_; |
| 118 | 149 |
| 119 private: | 150 private: |
| 120 double psnr_; | 151 double psnr_; |
| 121 unsigned int nframes_; | 152 unsigned int nframes_; |
| 122 libvpx_test::TestMode encoding_mode_; | 153 libvpx_test::TestMode encoding_mode_; |
| 123 }; | 154 }; |
| 124 | 155 |
| 125 TEST_P(EndToEndTestLarge, EndtoEndPSNRTest) { | 156 TEST_P(EndToEndTestLarge, EndtoEndPSNRTest) { |
| 126 cfg_.rc_target_bitrate = kBitrate; | 157 cfg_.rc_target_bitrate = kBitrate; |
| 127 cfg_.g_error_resilient = 0; | 158 cfg_.g_error_resilient = 0; |
| 128 cfg_.g_profile = test_video_param_.profile; | 159 cfg_.g_profile = test_video_param_.profile; |
| 129 cfg_.g_input_bit_depth = test_video_param_.input_bit_depth; | 160 cfg_.g_input_bit_depth = test_video_param_.input_bit_depth; |
| 130 cfg_.g_bit_depth = test_video_param_.bit_depth; | 161 cfg_.g_bit_depth = test_video_param_.bit_depth; |
| 131 init_flags_ = VPX_CODEC_USE_PSNR; | 162 init_flags_ = VPX_CODEC_USE_PSNR; |
| 163 if (cfg_.g_bit_depth > 8) |
| 164 init_flags_ |= VPX_CODEC_USE_HIGHBITDEPTH; |
| 132 | 165 |
| 133 libvpx_test::VideoSource *video; | 166 libvpx_test::VideoSource *video; |
| 134 if (is_extension_y4m(test_video_param_.filename)) { | 167 if (is_extension_y4m(test_video_param_.filename)) { |
| 135 video = new libvpx_test::Y4mVideoSource(test_video_param_.filename, | 168 video = new libvpx_test::Y4mVideoSource(test_video_param_.filename, |
| 136 0, kFrames); | 169 0, kFrames); |
| 137 } else { | 170 } else { |
| 138 video = new libvpx_test::YUVVideoSource(test_video_param_.filename, | 171 video = new libvpx_test::YUVVideoSource(test_video_param_.filename, |
| 139 test_video_param_.fmt, | 172 test_video_param_.fmt, |
| 140 kWidth, kHeight, | 173 kWidth, kHeight, |
| 141 kFramerate, 1, 0, kFrames); | 174 kFramerate, 1, 0, kFrames); |
| 142 } | 175 } |
| 143 | 176 |
| 144 ASSERT_NO_FATAL_FAILURE(RunLoop(video)); | 177 ASSERT_NO_FATAL_FAILURE(RunLoop(video)); |
| 145 const double psnr = GetAveragePsnr(); | 178 const double psnr = GetAveragePsnr(); |
| 146 EXPECT_GT(psnr, psnr_threshold); | 179 EXPECT_GT(psnr, GetPsnrThreshold()); |
| 147 delete(video); | 180 delete(video); |
| 148 } | 181 } |
| 149 | 182 |
| 150 VP9_INSTANTIATE_TEST_CASE( | 183 VP9_INSTANTIATE_TEST_CASE( |
| 151 EndToEndTestLarge, | 184 EndToEndTestLarge, |
| 152 ::testing::Values(::libvpx_test::kTwoPassGood, ::libvpx_test::kOnePassGood), | 185 ::testing::ValuesIn(kEncodingModeVectors), |
| 153 ::testing::ValuesIn(TestVectors)); | 186 ::testing::ValuesIn(kTestVectors), |
| 187 ::testing::ValuesIn(kCpuUsedVectors)); |
| 154 | 188 |
| 155 } // namespace | 189 } // namespace |
| OLD | NEW |