| 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 <cstdio> | 11 #include <cstdio> |
| 12 #include <cstdlib> | 12 #include <cstdlib> |
| 13 #include <string> | 13 #include <string> |
| 14 #include "third_party/googletest/src/include/gtest/gtest.h" | 14 #include "third_party/googletest/src/include/gtest/gtest.h" |
| 15 #include "../tools_common.h" | |
| 16 #include "./vpx_config.h" | 15 #include "./vpx_config.h" |
| 17 #include "test/codec_factory.h" | 16 #include "test/codec_factory.h" |
| 18 #include "test/decode_test_driver.h" | 17 #include "test/decode_test_driver.h" |
| 19 #include "test/ivf_video_source.h" | 18 #include "test/ivf_video_source.h" |
| 20 #include "test/md5_helper.h" | 19 #include "test/md5_helper.h" |
| 21 #include "test/test_vectors.h" | 20 #include "test/test_vectors.h" |
| 22 #include "test/util.h" | 21 #include "test/util.h" |
| 23 #if CONFIG_WEBM_IO | 22 #if CONFIG_WEBM_IO |
| 24 #include "test/webm_video_source.h" | 23 #include "test/webm_video_source.h" |
| 25 #endif | 24 #endif |
| 26 #include "vpx_mem/vpx_mem.h" | 25 #include "vpx_mem/vpx_mem.h" |
| 27 | 26 |
| 28 namespace { | 27 namespace { |
| 29 | 28 |
| 30 enum DecodeMode { | |
| 31 kSerialMode, | |
| 32 kFrameParallMode | |
| 33 }; | |
| 34 | |
| 35 const int kDecodeMode = 0; | |
| 36 const int kThreads = 1; | |
| 37 const int kFileName = 2; | |
| 38 | |
| 39 typedef std::tr1::tuple<int, int, const char*> DecodeParam; | |
| 40 | |
| 41 class TestVectorTest : public ::libvpx_test::DecoderTest, | 29 class TestVectorTest : public ::libvpx_test::DecoderTest, |
| 42 public ::libvpx_test::CodecTestWithParam<DecodeParam> { | 30 public ::libvpx_test::CodecTestWithParam<const char*> { |
| 43 protected: | 31 protected: |
| 44 TestVectorTest() | 32 TestVectorTest() : DecoderTest(GET_PARAM(0)), md5_file_(NULL) {} |
| 45 : DecoderTest(GET_PARAM(0)), | |
| 46 md5_file_(NULL) { | |
| 47 } | |
| 48 | 33 |
| 49 virtual ~TestVectorTest() { | 34 virtual ~TestVectorTest() { |
| 50 if (md5_file_) | 35 if (md5_file_) |
| 51 fclose(md5_file_); | 36 fclose(md5_file_); |
| 52 } | 37 } |
| 53 | 38 |
| 54 void OpenMD5File(const std::string& md5_file_name_) { | 39 void OpenMD5File(const std::string& md5_file_name_) { |
| 55 md5_file_ = libvpx_test::OpenTestDataFile(md5_file_name_); | 40 md5_file_ = libvpx_test::OpenTestDataFile(md5_file_name_); |
| 56 ASSERT_TRUE(md5_file_ != NULL) << "Md5 file open failed. Filename: " | 41 ASSERT_TRUE(md5_file_ != NULL) << "Md5 file open failed. Filename: " |
| 57 << md5_file_name_; | 42 << md5_file_name_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 79 | 64 |
| 80 private: | 65 private: |
| 81 FILE *md5_file_; | 66 FILE *md5_file_; |
| 82 }; | 67 }; |
| 83 | 68 |
| 84 // This test runs through the whole set of test vectors, and decodes them. | 69 // This test runs through the whole set of test vectors, and decodes them. |
| 85 // The md5 checksums are computed for each frame in the video file. If md5 | 70 // The md5 checksums are computed for each frame in the video file. If md5 |
| 86 // checksums match the correct md5 data, then the test is passed. Otherwise, | 71 // checksums match the correct md5 data, then the test is passed. Otherwise, |
| 87 // the test failed. | 72 // the test failed. |
| 88 TEST_P(TestVectorTest, MD5Match) { | 73 TEST_P(TestVectorTest, MD5Match) { |
| 89 const DecodeParam input = GET_PARAM(1); | 74 const std::string filename = GET_PARAM(1); |
| 90 const std::string filename = std::tr1::get<kFileName>(input); | |
| 91 const int threads = std::tr1::get<kThreads>(input); | |
| 92 const int mode = std::tr1::get<kDecodeMode>(input); | |
| 93 libvpx_test::CompressedVideoSource *video = NULL; | 75 libvpx_test::CompressedVideoSource *video = NULL; |
| 94 vpx_codec_flags_t flags = 0; | |
| 95 vpx_codec_dec_cfg_t cfg = {0}; | |
| 96 char str[256]; | |
| 97 | |
| 98 if (mode == kFrameParallMode) { | |
| 99 flags |= VPX_CODEC_USE_FRAME_THREADING; | |
| 100 } | |
| 101 | |
| 102 cfg.threads = threads; | |
| 103 | |
| 104 snprintf(str, sizeof(str) / sizeof(str[0]) - 1, | |
| 105 "file: %s mode: %s threads: %d", | |
| 106 filename.c_str(), mode == 0 ? "Serial" : "Parallel", threads); | |
| 107 SCOPED_TRACE(str); | |
| 108 | 76 |
| 109 // Open compressed video file. | 77 // Open compressed video file. |
| 110 if (filename.substr(filename.length() - 3, 3) == "ivf") { | 78 if (filename.substr(filename.length() - 3, 3) == "ivf") { |
| 111 video = new libvpx_test::IVFVideoSource(filename); | 79 video = new libvpx_test::IVFVideoSource(filename); |
| 112 } else if (filename.substr(filename.length() - 4, 4) == "webm") { | 80 } else if (filename.substr(filename.length() - 4, 4) == "webm") { |
| 113 #if CONFIG_WEBM_IO | 81 #if CONFIG_WEBM_IO |
| 114 video = new libvpx_test::WebMVideoSource(filename); | 82 video = new libvpx_test::WebMVideoSource(filename); |
| 115 #else | 83 #else |
| 116 fprintf(stderr, "WebM IO is disabled, skipping test vector %s\n", | 84 fprintf(stderr, "WebM IO is disabled, skipping test vector %s\n", |
| 117 filename.c_str()); | 85 filename.c_str()); |
| 118 return; | 86 return; |
| 119 #endif | 87 #endif |
| 120 } | 88 } |
| 121 video->Init(); | 89 video->Init(); |
| 122 | 90 |
| 123 // Construct md5 file name. | 91 // Construct md5 file name. |
| 124 const std::string md5_filename = filename + ".md5"; | 92 const std::string md5_filename = filename + ".md5"; |
| 125 OpenMD5File(md5_filename); | 93 OpenMD5File(md5_filename); |
| 126 | 94 |
| 127 // Set decode config and flags. | |
| 128 set_cfg(cfg); | |
| 129 set_flags(flags); | |
| 130 | |
| 131 // Decode frame, and check the md5 matching. | 95 // Decode frame, and check the md5 matching. |
| 132 ASSERT_NO_FATAL_FAILURE(RunLoop(video, cfg)); | 96 ASSERT_NO_FATAL_FAILURE(RunLoop(video)); |
| 133 delete video; | 97 delete video; |
| 134 } | 98 } |
| 135 | 99 |
| 136 // Test VP8 decode in serial mode with single thread. | 100 VP8_INSTANTIATE_TEST_CASE(TestVectorTest, |
| 137 // NOTE: VP8 only support serial mode. | 101 ::testing::ValuesIn(libvpx_test::kVP8TestVectors, |
| 138 INSTANTIATE_TEST_CASE_P( | 102 libvpx_test::kVP8TestVectors + |
| 139 VP8, TestVectorTest, | 103 libvpx_test::kNumVP8TestVectors)); |
| 140 ::testing::Combine( | 104 VP9_INSTANTIATE_TEST_CASE(TestVectorTest, |
| 141 ::testing::Values( | 105 ::testing::ValuesIn(libvpx_test::kVP9TestVectors, |
| 142 static_cast<const libvpx_test::CodecFactory *>(&libvpx_test::kVP8)), | 106 libvpx_test::kVP9TestVectors + |
| 143 ::testing::Combine( | 107 libvpx_test::kNumVP9TestVectors)); |
| 144 ::testing::Values(0), // Serial Mode. | |
| 145 ::testing::Values(1), // Single thread. | |
| 146 ::testing::ValuesIn(libvpx_test::kVP8TestVectors, | |
| 147 libvpx_test::kVP8TestVectors + | |
| 148 libvpx_test::kNumVP8TestVectors)))); | |
| 149 | 108 |
| 150 // Test VP9 decode in serial mode with single thread. | |
| 151 INSTANTIATE_TEST_CASE_P( | |
| 152 VP9, TestVectorTest, | |
| 153 ::testing::Combine( | |
| 154 ::testing::Values( | |
| 155 static_cast<const libvpx_test::CodecFactory *>(&libvpx_test::kVP9)), | |
| 156 ::testing::Combine( | |
| 157 ::testing::Values(0), // Serial Mode. | |
| 158 ::testing::Values(1), // Single thread. | |
| 159 ::testing::ValuesIn(libvpx_test::kVP9TestVectors, | |
| 160 libvpx_test::kVP9TestVectors + | |
| 161 libvpx_test::kNumVP9TestVectors)))); | |
| 162 | |
| 163 | |
| 164 // Test VP9 decode in frame parallel mode with different number of threads. | |
| 165 INSTANTIATE_TEST_CASE_P( | |
| 166 VP9MultiThreadedFrameParallel, TestVectorTest, | |
| 167 ::testing::Combine( | |
| 168 ::testing::Values( | |
| 169 static_cast<const libvpx_test::CodecFactory *>(&libvpx_test::kVP9)), | |
| 170 ::testing::Combine( | |
| 171 ::testing::Values(1), // Frame Parallel mode. | |
| 172 ::testing::Range(2, 9), // With 2 ~ 8 threads. | |
| 173 ::testing::ValuesIn(libvpx_test::kVP9TestVectors, | |
| 174 libvpx_test::kVP9TestVectors + | |
| 175 libvpx_test::kNumVP9TestVectors)))); | |
| 176 } // namespace | 109 } // namespace |
| OLD | NEW |