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 <cstdio> | 11 #include <cstdio> |
12 #include <cstdlib> | 12 #include <cstdlib> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 #include "third_party/googletest/src/include/gtest/gtest.h" | 15 #include "third_party/googletest/src/include/gtest/gtest.h" |
16 #include "./vpx_config.h" | 16 #include "./vpx_config.h" |
17 #include "test/codec_factory.h" | 17 #include "test/codec_factory.h" |
18 #include "test/decode_test_driver.h" | 18 #include "test/decode_test_driver.h" |
19 #include "test/ivf_video_source.h" | 19 #include "test/ivf_video_source.h" |
20 #include "test/util.h" | 20 #include "test/util.h" |
21 #if CONFIG_WEBM_IO | 21 #if CONFIG_WEBM_IO |
22 #include "test/webm_video_source.h" | 22 #include "test/webm_video_source.h" |
23 #endif | 23 #endif |
24 #include "vpx_mem/vpx_mem.h" | 24 #include "vpx_mem/vpx_mem.h" |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
| 28 struct DecodeParam { |
| 29 int threads; |
| 30 const char *filename; |
| 31 }; |
| 32 |
28 class InvalidFileTest | 33 class InvalidFileTest |
29 : public ::libvpx_test::DecoderTest, | 34 : public ::libvpx_test::DecoderTest, |
30 public ::libvpx_test::CodecTestWithParam<const char*> { | 35 public ::libvpx_test::CodecTestWithParam<DecodeParam> { |
31 protected: | 36 protected: |
32 InvalidFileTest() : DecoderTest(GET_PARAM(0)), res_file_(NULL) {} | 37 InvalidFileTest() : DecoderTest(GET_PARAM(0)), res_file_(NULL) {} |
33 | 38 |
34 virtual ~InvalidFileTest() { | 39 virtual ~InvalidFileTest() { |
35 if (res_file_ != NULL) | 40 if (res_file_ != NULL) |
36 fclose(res_file_); | 41 fclose(res_file_); |
37 } | 42 } |
38 | 43 |
39 void OpenResFile(const std::string &res_file_name_) { | 44 void OpenResFile(const std::string &res_file_name_) { |
40 res_file_ = libvpx_test::OpenTestDataFile(res_file_name_); | 45 res_file_ = libvpx_test::OpenTestDataFile(res_file_name_); |
41 ASSERT_TRUE(res_file_ != NULL) << "Result file open failed. Filename: " | 46 ASSERT_TRUE(res_file_ != NULL) << "Result file open failed. Filename: " |
42 << res_file_name_; | 47 << res_file_name_; |
43 } | 48 } |
44 | 49 |
45 virtual bool HandleDecodeResult( | 50 virtual bool HandleDecodeResult( |
46 const vpx_codec_err_t res_dec, | 51 const vpx_codec_err_t res_dec, |
47 const libvpx_test::CompressedVideoSource &video, | 52 const libvpx_test::CompressedVideoSource &video, |
48 libvpx_test::Decoder *decoder) { | 53 libvpx_test::Decoder *decoder) { |
49 EXPECT_TRUE(res_file_ != NULL); | 54 EXPECT_TRUE(res_file_ != NULL); |
50 int expected_res_dec; | 55 int expected_res_dec; |
51 | 56 |
52 // Read integer result. | 57 // Read integer result. |
53 const int res = fscanf(res_file_, "%d", &expected_res_dec); | 58 const int res = fscanf(res_file_, "%d", &expected_res_dec); |
54 EXPECT_NE(res, EOF) << "Read result data failed"; | 59 EXPECT_NE(res, EOF) << "Read result data failed"; |
55 | 60 |
56 // Check results match. | 61 // Check results match. |
57 EXPECT_EQ(expected_res_dec, res_dec) | 62 EXPECT_EQ(expected_res_dec, res_dec) |
58 << "Results don't match: frame number = " << video.frame_number(); | 63 << "Results don't match: frame number = " << video.frame_number() |
| 64 << ". (" << decoder->DecodeError() << ")"; |
59 | 65 |
60 return !HasFailure(); | 66 return !HasFailure(); |
61 } | 67 } |
62 | 68 |
63 private: | 69 private: |
64 FILE *res_file_; | 70 FILE *res_file_; |
65 }; | 71 }; |
66 | 72 |
67 TEST_P(InvalidFileTest, ReturnCode) { | 73 TEST_P(InvalidFileTest, ReturnCode) { |
68 const std::string filename = GET_PARAM(1); | |
69 libvpx_test::CompressedVideoSource *video = NULL; | 74 libvpx_test::CompressedVideoSource *video = NULL; |
| 75 const DecodeParam input = GET_PARAM(1); |
| 76 vpx_codec_dec_cfg_t cfg = {0}; |
| 77 cfg.threads = input.threads; |
| 78 const std::string filename = input.filename; |
70 | 79 |
71 // Open compressed video file. | 80 // Open compressed video file. |
72 if (filename.substr(filename.length() - 3, 3) == "ivf") { | 81 if (filename.substr(filename.length() - 3, 3) == "ivf") { |
73 video = new libvpx_test::IVFVideoSource(filename); | 82 video = new libvpx_test::IVFVideoSource(filename); |
74 } else if (filename.substr(filename.length() - 4, 4) == "webm") { | 83 } else if (filename.substr(filename.length() - 4, 4) == "webm") { |
75 #if CONFIG_WEBM_IO | 84 #if CONFIG_WEBM_IO |
76 video = new libvpx_test::WebMVideoSource(filename); | 85 video = new libvpx_test::WebMVideoSource(filename); |
77 #else | 86 #else |
78 fprintf(stderr, "WebM IO is disabled, skipping test vector %s\n", | 87 fprintf(stderr, "WebM IO is disabled, skipping test vector %s\n", |
79 filename.c_str()); | 88 filename.c_str()); |
80 return; | 89 return; |
81 #endif | 90 #endif |
82 } | 91 } |
83 video->Init(); | 92 video->Init(); |
84 | 93 |
85 // Construct result file name. The file holds a list of expected integer | 94 // Construct result file name. The file holds a list of expected integer |
86 // results, one for each decoded frame. Any result that doesn't match | 95 // results, one for each decoded frame. Any result that doesn't match |
87 // the files list will cause a test failure. | 96 // the files list will cause a test failure. |
88 const std::string res_filename = filename + ".res"; | 97 const std::string res_filename = filename + ".res"; |
89 OpenResFile(res_filename); | 98 OpenResFile(res_filename); |
90 | 99 |
91 // Decode frame, and check the md5 matching. | 100 // Decode frame, and check the md5 matching. |
92 ASSERT_NO_FATAL_FAILURE(RunLoop(video)); | 101 ASSERT_NO_FATAL_FAILURE(RunLoop(video, cfg)); |
93 delete video; | 102 delete video; |
94 } | 103 } |
95 | 104 |
96 const char *const kVP9InvalidFileTests[] = { | 105 const DecodeParam kVP9InvalidFileTests[] = { |
97 "invalid-vp90-01.webm", | 106 {1, "invalid-vp90-01-v2.webm"}, |
98 "invalid-vp90-02.webm", | 107 {1, "invalid-vp90-02-v2.webm"}, |
99 "invalid-vp90-2-00-quantizer-00.webm.ivf.s5861_r01-05_b6-.ivf", | 108 {1, "invalid-vp90-2-00-quantizer-00.webm.ivf.s5861_r01-05_b6-.ivf"}, |
100 "invalid-vp90-03.webm", | 109 {1, "invalid-vp90-03-v2.webm"}, |
101 "invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf", | 110 {1, "invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf"}, |
102 "invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf", | 111 {1, "invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf"}, |
103 }; | 112 }; |
104 | 113 |
105 #define NELEMENTS(x) static_cast<int>(sizeof(x) / sizeof(x[0])) | 114 VP9_INSTANTIATE_TEST_CASE(InvalidFileTest, |
| 115 ::testing::ValuesIn(kVP9InvalidFileTests)); |
106 | 116 |
107 VP9_INSTANTIATE_TEST_CASE(InvalidFileTest, | 117 const DecodeParam kMultiThreadedVP9InvalidFileTests[] = { |
108 ::testing::ValuesIn(kVP9InvalidFileTests, | 118 {4, "invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm"}, |
109 kVP9InvalidFileTests + | 119 }; |
110 NELEMENTS(kVP9InvalidFileTests))); | |
111 | 120 |
| 121 INSTANTIATE_TEST_CASE_P( |
| 122 VP9MultiThreaded, InvalidFileTest, |
| 123 ::testing::Combine( |
| 124 ::testing::Values( |
| 125 static_cast<const libvpx_test::CodecFactory*>(&libvpx_test::kVP9)), |
| 126 ::testing::ValuesIn(kMultiThreadedVP9InvalidFileTests))); |
112 } // namespace | 127 } // namespace |
OLD | NEW |