Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(645)

Side by Side Diff: source/libvpx/test/test_vector_test.cc

Issue 958693004: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/libvpx/test/test-data.sha1 ('k') | source/libvpx/test/test_vectors.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
15 #include "./vpx_config.h" 16 #include "./vpx_config.h"
16 #include "test/codec_factory.h" 17 #include "test/codec_factory.h"
17 #include "test/decode_test_driver.h" 18 #include "test/decode_test_driver.h"
18 #include "test/ivf_video_source.h" 19 #include "test/ivf_video_source.h"
19 #include "test/md5_helper.h" 20 #include "test/md5_helper.h"
20 #include "test/test_vectors.h" 21 #include "test/test_vectors.h"
21 #include "test/util.h" 22 #include "test/util.h"
22 #if CONFIG_WEBM_IO 23 #if CONFIG_WEBM_IO
23 #include "test/webm_video_source.h" 24 #include "test/webm_video_source.h"
24 #endif 25 #endif
25 #include "vpx_mem/vpx_mem.h" 26 #include "vpx_mem/vpx_mem.h"
26 27
27 namespace { 28 namespace {
28 29
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
29 class TestVectorTest : public ::libvpx_test::DecoderTest, 41 class TestVectorTest : public ::libvpx_test::DecoderTest,
30 public ::libvpx_test::CodecTestWithParam<const char*> { 42 public ::libvpx_test::CodecTestWithParam<DecodeParam> {
31 protected: 43 protected:
32 TestVectorTest() : DecoderTest(GET_PARAM(0)), md5_file_(NULL) {} 44 TestVectorTest()
45 : DecoderTest(GET_PARAM(0)),
46 md5_file_(NULL) {
47 }
33 48
34 virtual ~TestVectorTest() { 49 virtual ~TestVectorTest() {
35 if (md5_file_) 50 if (md5_file_)
36 fclose(md5_file_); 51 fclose(md5_file_);
37 } 52 }
38 53
39 void OpenMD5File(const std::string& md5_file_name_) { 54 void OpenMD5File(const std::string& md5_file_name_) {
40 md5_file_ = libvpx_test::OpenTestDataFile(md5_file_name_); 55 md5_file_ = libvpx_test::OpenTestDataFile(md5_file_name_);
41 ASSERT_TRUE(md5_file_ != NULL) << "Md5 file open failed. Filename: " 56 ASSERT_TRUE(md5_file_ != NULL) << "Md5 file open failed. Filename: "
42 << md5_file_name_; 57 << md5_file_name_;
(...skipping 21 matching lines...) Expand all
64 79
65 private: 80 private:
66 FILE *md5_file_; 81 FILE *md5_file_;
67 }; 82 };
68 83
69 // This test runs through the whole set of test vectors, and decodes them. 84 // This test runs through the whole set of test vectors, and decodes them.
70 // The md5 checksums are computed for each frame in the video file. If md5 85 // The md5 checksums are computed for each frame in the video file. If md5
71 // checksums match the correct md5 data, then the test is passed. Otherwise, 86 // checksums match the correct md5 data, then the test is passed. Otherwise,
72 // the test failed. 87 // the test failed.
73 TEST_P(TestVectorTest, MD5Match) { 88 TEST_P(TestVectorTest, MD5Match) {
74 const std::string filename = GET_PARAM(1); 89 const DecodeParam input = 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);
75 libvpx_test::CompressedVideoSource *video = NULL; 93 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);
76 108
77 // Open compressed video file. 109 // Open compressed video file.
78 if (filename.substr(filename.length() - 3, 3) == "ivf") { 110 if (filename.substr(filename.length() - 3, 3) == "ivf") {
79 video = new libvpx_test::IVFVideoSource(filename); 111 video = new libvpx_test::IVFVideoSource(filename);
80 } else if (filename.substr(filename.length() - 4, 4) == "webm") { 112 } else if (filename.substr(filename.length() - 4, 4) == "webm") {
81 #if CONFIG_WEBM_IO 113 #if CONFIG_WEBM_IO
82 video = new libvpx_test::WebMVideoSource(filename); 114 video = new libvpx_test::WebMVideoSource(filename);
83 #else 115 #else
84 fprintf(stderr, "WebM IO is disabled, skipping test vector %s\n", 116 fprintf(stderr, "WebM IO is disabled, skipping test vector %s\n",
85 filename.c_str()); 117 filename.c_str());
86 return; 118 return;
87 #endif 119 #endif
88 } 120 }
89 video->Init(); 121 video->Init();
90 122
91 // Construct md5 file name. 123 // Construct md5 file name.
92 const std::string md5_filename = filename + ".md5"; 124 const std::string md5_filename = filename + ".md5";
93 OpenMD5File(md5_filename); 125 OpenMD5File(md5_filename);
94 126
127 // Set decode config and flags.
128 set_cfg(cfg);
129 set_flags(flags);
130
95 // Decode frame, and check the md5 matching. 131 // Decode frame, and check the md5 matching.
96 ASSERT_NO_FATAL_FAILURE(RunLoop(video)); 132 ASSERT_NO_FATAL_FAILURE(RunLoop(video, cfg));
97 delete video; 133 delete video;
98 } 134 }
99 135
100 VP8_INSTANTIATE_TEST_CASE(TestVectorTest, 136 // Test VP8 decode in serial mode with single thread.
101 ::testing::ValuesIn(libvpx_test::kVP8TestVectors, 137 // NOTE: VP8 only support serial mode.
102 libvpx_test::kVP8TestVectors + 138 VP8_INSTANTIATE_TEST_CASE(
103 libvpx_test::kNumVP8TestVectors)); 139 TestVectorTest,
104 VP9_INSTANTIATE_TEST_CASE(TestVectorTest, 140 ::testing::Combine(
105 ::testing::ValuesIn(libvpx_test::kVP9TestVectors, 141 ::testing::Values(0), // Serial Mode.
106 libvpx_test::kVP9TestVectors + 142 ::testing::Values(1), // Single thread.
107 libvpx_test::kNumVP9TestVectors)); 143 ::testing::ValuesIn(libvpx_test::kVP8TestVectors,
144 libvpx_test::kVP8TestVectors +
145 libvpx_test::kNumVP8TestVectors)));
108 146
147 // Test VP9 decode in serial mode with single thread.
148 VP9_INSTANTIATE_TEST_CASE(
149 TestVectorTest,
150 ::testing::Combine(
151 ::testing::Values(0), // Serial Mode.
152 ::testing::Values(1), // Single thread.
153 ::testing::ValuesIn(libvpx_test::kVP9TestVectors,
154 libvpx_test::kVP9TestVectors +
155 libvpx_test::kNumVP9TestVectors)));
156
157
158 #if CONFIG_VP9_DECODER
159 // Test VP9 decode in frame parallel mode with different number of threads.
160 INSTANTIATE_TEST_CASE_P(
161 VP9MultiThreadedFrameParallel, TestVectorTest,
162 ::testing::Combine(
163 ::testing::Values(
164 static_cast<const libvpx_test::CodecFactory *>(&libvpx_test::kVP9)),
165 ::testing::Combine(
166 ::testing::Values(1), // Frame Parallel mode.
167 ::testing::Range(2, 9), // With 2 ~ 8 threads.
168 ::testing::ValuesIn(libvpx_test::kVP9TestVectors,
169 libvpx_test::kVP9TestVectors +
170 libvpx_test::kNumVP9TestVectors))));
171 #endif
109 } // namespace 172 } // namespace
OLDNEW
« no previous file with comments | « source/libvpx/test/test-data.sha1 ('k') | source/libvpx/test/test_vectors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698