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 |
(...skipping 12 matching lines...) Expand all Loading... |
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 { | 28 struct DecodeParam { |
29 int threads; | 29 int threads; |
30 const char *filename; | 30 const char *filename; |
31 }; | 31 }; |
32 | 32 |
| 33 std::ostream &operator<<(std::ostream &os, const DecodeParam &dp) { |
| 34 return os << "threads: " << dp.threads << " file: " << dp.filename; |
| 35 } |
| 36 |
33 class InvalidFileTest | 37 class InvalidFileTest |
34 : public ::libvpx_test::DecoderTest, | 38 : public ::libvpx_test::DecoderTest, |
35 public ::libvpx_test::CodecTestWithParam<DecodeParam> { | 39 public ::libvpx_test::CodecTestWithParam<DecodeParam> { |
36 protected: | 40 protected: |
37 InvalidFileTest() : DecoderTest(GET_PARAM(0)), res_file_(NULL) {} | 41 InvalidFileTest() : DecoderTest(GET_PARAM(0)), res_file_(NULL) {} |
38 | 42 |
39 virtual ~InvalidFileTest() { | 43 virtual ~InvalidFileTest() { |
40 if (res_file_ != NULL) | 44 if (res_file_ != NULL) |
41 fclose(res_file_); | 45 fclose(res_file_); |
42 } | 46 } |
(...skipping 16 matching lines...) Expand all Loading... |
59 EXPECT_NE(res, EOF) << "Read result data failed"; | 63 EXPECT_NE(res, EOF) << "Read result data failed"; |
60 | 64 |
61 // Check results match. | 65 // Check results match. |
62 EXPECT_EQ(expected_res_dec, res_dec) | 66 EXPECT_EQ(expected_res_dec, res_dec) |
63 << "Results don't match: frame number = " << video.frame_number() | 67 << "Results don't match: frame number = " << video.frame_number() |
64 << ". (" << decoder->DecodeError() << ")"; | 68 << ". (" << decoder->DecodeError() << ")"; |
65 | 69 |
66 return !HasFailure(); | 70 return !HasFailure(); |
67 } | 71 } |
68 | 72 |
| 73 void RunTest() { |
| 74 const DecodeParam input = GET_PARAM(1); |
| 75 libvpx_test::CompressedVideoSource *video = NULL; |
| 76 vpx_codec_dec_cfg_t cfg = {0}; |
| 77 cfg.threads = input.threads; |
| 78 const std::string filename = input.filename; |
| 79 |
| 80 // Open compressed video file. |
| 81 if (filename.substr(filename.length() - 3, 3) == "ivf") { |
| 82 video = new libvpx_test::IVFVideoSource(filename); |
| 83 } else if (filename.substr(filename.length() - 4, 4) == "webm") { |
| 84 #if CONFIG_WEBM_IO |
| 85 video = new libvpx_test::WebMVideoSource(filename); |
| 86 #else |
| 87 fprintf(stderr, "WebM IO is disabled, skipping test vector %s\n", |
| 88 filename.c_str()); |
| 89 return; |
| 90 #endif |
| 91 } |
| 92 video->Init(); |
| 93 |
| 94 // Construct result file name. The file holds a list of expected integer |
| 95 // results, one for each decoded frame. Any result that doesn't match |
| 96 // the files list will cause a test failure. |
| 97 const std::string res_filename = filename + ".res"; |
| 98 OpenResFile(res_filename); |
| 99 |
| 100 // Decode frame, and check the md5 matching. |
| 101 ASSERT_NO_FATAL_FAILURE(RunLoop(video, cfg)); |
| 102 delete video; |
| 103 } |
| 104 |
69 private: | 105 private: |
70 FILE *res_file_; | 106 FILE *res_file_; |
71 }; | 107 }; |
72 | 108 |
73 TEST_P(InvalidFileTest, ReturnCode) { | 109 TEST_P(InvalidFileTest, ReturnCode) { |
74 libvpx_test::CompressedVideoSource *video = NULL; | 110 RunTest(); |
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; | |
79 | |
80 // Open compressed video file. | |
81 if (filename.substr(filename.length() - 3, 3) == "ivf") { | |
82 video = new libvpx_test::IVFVideoSource(filename); | |
83 } else if (filename.substr(filename.length() - 4, 4) == "webm") { | |
84 #if CONFIG_WEBM_IO | |
85 video = new libvpx_test::WebMVideoSource(filename); | |
86 #else | |
87 fprintf(stderr, "WebM IO is disabled, skipping test vector %s\n", | |
88 filename.c_str()); | |
89 return; | |
90 #endif | |
91 } | |
92 video->Init(); | |
93 | |
94 // Construct result file name. The file holds a list of expected integer | |
95 // results, one for each decoded frame. Any result that doesn't match | |
96 // the files list will cause a test failure. | |
97 const std::string res_filename = filename + ".res"; | |
98 OpenResFile(res_filename); | |
99 | |
100 // Decode frame, and check the md5 matching. | |
101 ASSERT_NO_FATAL_FAILURE(RunLoop(video, cfg)); | |
102 delete video; | |
103 } | 111 } |
104 | 112 |
105 const DecodeParam kVP9InvalidFileTests[] = { | 113 const DecodeParam kVP9InvalidFileTests[] = { |
106 {1, "invalid-vp90-01-v2.webm"}, | |
107 {1, "invalid-vp90-02-v2.webm"}, | 114 {1, "invalid-vp90-02-v2.webm"}, |
108 {1, "invalid-vp90-2-00-quantizer-00.webm.ivf.s5861_r01-05_b6-.ivf"}, | 115 {1, "invalid-vp90-2-00-quantizer-00.webm.ivf.s5861_r01-05_b6-.v2.ivf"}, |
109 {1, "invalid-vp90-03-v2.webm"}, | 116 {1, "invalid-vp90-03-v2.webm"}, |
110 {1, "invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf"}, | 117 {1, "invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf"}, |
111 {1, "invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf"}, | 118 {1, "invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf"}, |
112 }; | 119 }; |
113 | 120 |
114 VP9_INSTANTIATE_TEST_CASE(InvalidFileTest, | 121 VP9_INSTANTIATE_TEST_CASE(InvalidFileTest, |
115 ::testing::ValuesIn(kVP9InvalidFileTests)); | 122 ::testing::ValuesIn(kVP9InvalidFileTests)); |
116 | 123 |
| 124 // This class will include test vectors that are expected to fail |
| 125 // peek. However they are still expected to have no fatal failures. |
| 126 class InvalidFileInvalidPeekTest : public InvalidFileTest { |
| 127 protected: |
| 128 InvalidFileInvalidPeekTest() : InvalidFileTest() {} |
| 129 virtual void HandlePeekResult(libvpx_test::Decoder *const decoder, |
| 130 libvpx_test::CompressedVideoSource *video, |
| 131 const vpx_codec_err_t res_peek) {} |
| 132 }; |
| 133 |
| 134 TEST_P(InvalidFileInvalidPeekTest, ReturnCode) { |
| 135 RunTest(); |
| 136 } |
| 137 |
| 138 const DecodeParam kVP9InvalidFileInvalidPeekTests[] = { |
| 139 {1, "invalid-vp90-01-v2.webm"}, |
| 140 }; |
| 141 |
| 142 VP9_INSTANTIATE_TEST_CASE(InvalidFileInvalidPeekTest, |
| 143 ::testing::ValuesIn(kVP9InvalidFileInvalidPeekTests)); |
| 144 |
117 const DecodeParam kMultiThreadedVP9InvalidFileTests[] = { | 145 const DecodeParam kMultiThreadedVP9InvalidFileTests[] = { |
118 {4, "invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm"}, | 146 {4, "invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm"}, |
119 }; | 147 }; |
120 | 148 |
121 INSTANTIATE_TEST_CASE_P( | 149 INSTANTIATE_TEST_CASE_P( |
122 VP9MultiThreaded, InvalidFileTest, | 150 VP9MultiThreaded, InvalidFileTest, |
123 ::testing::Combine( | 151 ::testing::Combine( |
124 ::testing::Values( | 152 ::testing::Values( |
125 static_cast<const libvpx_test::CodecFactory*>(&libvpx_test::kVP9)), | 153 static_cast<const libvpx_test::CodecFactory*>(&libvpx_test::kVP9)), |
126 ::testing::ValuesIn(kMultiThreadedVP9InvalidFileTests))); | 154 ::testing::ValuesIn(kMultiThreadedVP9InvalidFileTests))); |
127 } // namespace | 155 } // namespace |
OLD | NEW |