2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
15 #include "third_party/googletest/src/include/gtest/gtest.h"
16 #include "./vpx_config.h"
17 #include "test/codec_factory.h"
18 #include "test/decode_test_driver.h"
19 #include "test/ivf_video_source.h"
20 #include "test/util.h"
22 #include "test/webm_video_source.h"
24 #include "vpx_mem/vpx_mem.h"
33 std::ostream &operator<<(std::ostream &os, const DecodeParam &dp) {
34 return os << "threads: " << dp.threads << " file: " << dp.filename;
38 : public ::libvpx_test::DecoderTest,
39 public ::libvpx_test::CodecTestWithParam<DecodeParam> {
41 InvalidFileTest() : DecoderTest(GET_PARAM(0)), res_file_(NULL) {}
43 virtual ~InvalidFileTest() {
44 if (res_file_ != NULL)
48 void OpenResFile(const std::string &res_file_name_) {
49 res_file_ = libvpx_test::OpenTestDataFile(res_file_name_);
50 ASSERT_TRUE(res_file_ != NULL) << "Result file open failed. Filename: "
54 virtual bool HandleDecodeResult(
55 const vpx_codec_err_t res_dec,
56 const libvpx_test::CompressedVideoSource &video,
57 libvpx_test::Decoder *decoder) {
58 EXPECT_TRUE(res_file_ != NULL);
61 // Read integer result.
62 const int res = fscanf(res_file_, "%d", &expected_res_dec);
63 EXPECT_NE(res, EOF) << "Read result data failed";
65 // Check results match.
66 EXPECT_EQ(expected_res_dec, res_dec)
67 << "Results don't match: frame number = " << video.frame_number()
68 << ". (" << decoder->DecodeError() << ")";
74 const DecodeParam input = GET_PARAM(1);
75 libvpx_test::CompressedVideoSource *video = NULL;
76 vpx_codec_dec_cfg_t cfg = vpx_codec_dec_cfg_t();
77 cfg.threads = input.threads;
78 const std::string filename = input.filename;
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") {
85 video = new libvpx_test::WebMVideoSource(filename);
87 fprintf(stderr, "WebM IO is disabled, skipping test vector %s\n",
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);
100 // Decode frame, and check the md5 matching.
101 ASSERT_NO_FATAL_FAILURE(RunLoop(video, cfg));
109 TEST_P(InvalidFileTest, ReturnCode) {
113 const DecodeParam kVP9InvalidFileTests[] = {
114 {1, "invalid-vp90-02-v2.webm"},
115 {1, "invalid-vp90-2-00-quantizer-00.webm.ivf.s5861_r01-05_b6-.v2.ivf"},
116 {1, "invalid-vp90-03-v3.webm"},
117 {1, "invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf"},
118 {1, "invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf"},
119 {1, "invalid-vp90-2-12-droppable_1.ivf.s3676_r01-05_b6-.ivf"},
120 {1, "invalid-vp90-2-05-resize.ivf.s59293_r01-05_b6-.ivf"},
121 {1, "invalid-vp90-2-09-subpixel-00.ivf.s20492_r01-05_b6-.v2.ivf"},
122 {1, "invalid-vp91-2-mixedrefcsp-444to420.ivf"},
123 {1, "invalid-vp90-2-12-droppable_1.ivf.s73804_r01-05_b6-.ivf"},
126 VP9_INSTANTIATE_TEST_CASE(InvalidFileTest,
127 ::testing::ValuesIn(kVP9InvalidFileTests));
129 // This class will include test vectors that are expected to fail
130 // peek. However they are still expected to have no fatal failures.
131 class InvalidFileInvalidPeekTest : public InvalidFileTest {
133 InvalidFileInvalidPeekTest() : InvalidFileTest() {}
134 virtual void HandlePeekResult(libvpx_test::Decoder *const /*decoder*/,
135 libvpx_test::CompressedVideoSource* /*video*/,
136 const vpx_codec_err_t /*res_peek*/) {}
139 TEST_P(InvalidFileInvalidPeekTest, ReturnCode) {
143 const DecodeParam kVP9InvalidFileInvalidPeekTests[] = {
144 {1, "invalid-vp90-01-v2.webm"},
147 VP9_INSTANTIATE_TEST_CASE(InvalidFileInvalidPeekTest,
148 ::testing::ValuesIn(kVP9InvalidFileInvalidPeekTests));
150 const DecodeParam kMultiThreadedVP9InvalidFileTests[] = {
151 {4, "invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm"},
153 "vp90-2-08-tile_1x2_frame_parallel.webm.ivf.s47039_r01-05_b6-.ivf"},
154 {2, "invalid-vp90-2-09-aq2.webm.ivf.s3984_r01-05_b6-.v2.ivf"},
155 {4, "invalid-vp90-2-09-subpixel-00.ivf.s19552_r01-05_b6-.v2.ivf"},
158 INSTANTIATE_TEST_CASE_P(
159 VP9MultiThreaded, InvalidFileTest,
162 static_cast<const libvpx_test::CodecFactory*>(&libvpx_test::kVP9)),
163 ::testing::ValuesIn(kMultiThreadedVP9InvalidFileTests)));