Commit 119c9812 authored by John Koleszar's avatar John Koleszar

Add vp9 test vectors unit test

These files can stand in until we get proper syntax vectors. They
should provide some additional assurance against inadvertant
bitstream changes.

Change-Id: I12f6c9a5f054e30df40a7ff1f33145abf7e1d59d
parent a81bd12a
This diff is collapsed.
This diff is collapsed.
......@@ -15,6 +15,7 @@
#include "test/codec_factory.h"
#include "test/decode_test_driver.h"
#include "test/ivf_video_source.h"
#include "test/webm_video_source.h"
#include "test/util.h"
#include "test/md5_helper.h"
extern "C" {
......@@ -22,8 +23,8 @@ extern "C" {
}
namespace {
// There are 61 test vectors in total.
const char *kTestVectors[] = {
#if CONFIG_VP8_DECODER
const char *kVP8TestVectors[] = {
"vp80-00-comprehensive-001.ivf",
"vp80-00-comprehensive-002.ivf", "vp80-00-comprehensive-003.ivf",
"vp80-00-comprehensive-004.ivf", "vp80-00-comprehensive-005.ivf",
......@@ -56,6 +57,66 @@ const char *kTestVectors[] = {
"vp80-05-sharpness-1438.ivf", "vp80-05-sharpness-1439.ivf",
"vp80-05-sharpness-1440.ivf", "vp80-05-sharpness-1443.ivf"
};
#endif
#if CONFIG_VP9_DECODER
const char *kVP9TestVectors[] = {
"vp90-00-akiyo-200.webm", "vp90-00-akiyo-300.webm",
"vp90-00-akiyo-50.webm", "vp90-00-bowing-150.webm",
"vp90-00-bowing-25.webm", "vp90-00-bowing-400.webm",
"vp90-00-bus-100.webm", "vp90-00-bus-2000.webm",
"vp90-00-bus-300.webm", "vp90-00-bus-4400.webm",
"vp90-00-bus-800.webm", "vp90-00-cheer-1600.webm",
"vp90-00-cheer-2800.webm", "vp90-00-cheer-400.webm",
"vp90-00-cheer-600.webm", "vp90-00-city-1200.webm",
"vp90-00-city-2000.webm", "vp90-00-city-300.webm",
"vp90-00-city-600.webm", "vp90-00-coastguard-1200.webm",
"vp90-00-coastguard-200.webm", "vp90-00-coastguard-3600.webm",
"vp90-00-coastguard-5200.webm", "vp90-00-container-1000.webm",
"vp90-00-container-200.webm", "vp90-00-container-50.webm",
"vp90-00-deadline-1000.webm", "vp90-00-deadline-200.webm",
"vp90-00-deadline-50.webm", "vp90-00-flower-100.webm",
"vp90-00-flower-2000.webm", "vp90-00-flower-300.webm",
"vp90-00-flower-4400.webm", "vp90-00-flower-800.webm",
"vp90-00-football-1600.webm", "vp90-00-football-2800.webm",
"vp90-00-football-400.webm", "vp90-00-football-600.webm",
"vp90-00-foreman-1200.webm", "vp90-00-foreman-2000.webm",
"vp90-00-foreman-300.webm", "vp90-00-foreman-600.webm",
"vp90-00-hallmonitor-1200.webm", "vp90-00-hallmonitor-2000.webm",
"vp90-00-hallmonitor-300.webm", "vp90-00-hallmonitor-600.webm",
"vp90-00-harbour-1200.webm", "vp90-00-harbour-200.webm",
"vp90-00-harbour-3600.webm", "vp90-00-harbour-5200.webm",
"vp90-00-highway-100.webm", "vp90-00-highway-1600.webm",
"vp90-00-highway-2800.webm", "vp90-00-highway-50.webm",
"vp90-00-husky-100.webm", "vp90-00-husky-2000.webm",
"vp90-00-husky-300.webm", "vp90-00-husky-4400.webm",
"vp90-00-husky-800.webm", "vp90-00-ice-150.webm",
"vp90-00-ice-400.webm", "vp90-00-ice-800.webm",
"vp90-00-mobile-1600.webm", "vp90-00-mobile-2800.webm",
"vp90-00-mobile-400.webm", "vp90-00-mobile-600.webm",
"vp90-00-motherdaughter-100.webm", "vp90-00-motherdaughter-300.webm",
"vp90-00-motherdaughter-600.webm", "vp90-00-news-100.webm",
"vp90-00-news-300.webm", "vp90-00-news-600.webm",
"vp90-00-pamphlet-150.webm", "vp90-00-pamphlet-25.webm",
"vp90-00-pamphlet-400.webm", "vp90-00-paris-1000.webm",
"vp90-00-paris-200.webm", "vp90-00-paris-50.webm",
"vp90-00-signirene-1000.webm", "vp90-00-signirene-200.webm",
"vp90-00-signirene-50.webm", "vp90-00-silent-1000.webm",
"vp90-00-silent-200.webm", "vp90-00-silent-50.webm",
"vp90-00-soccer-100.webm", "vp90-00-soccer-2000.webm",
"vp90-00-soccer-300.webm", "vp90-00-soccer-4400.webm",
"vp90-00-soccer-800.webm", "vp90-00-stefan-1600.webm",
"vp90-00-stefan-2800.webm", "vp90-00-stefan-400.webm",
"vp90-00-stefan-600.webm", "vp90-00-students-100.webm",
"vp90-00-students-300.webm", "vp90-00-students-600.webm",
"vp90-00-tempete-1200.webm", "vp90-00-tempete-200.webm",
"vp90-00-tempete-3600.webm", "vp90-00-tempete-5200.webm",
"vp90-00-tennis-100.webm", "vp90-00-tennis-2000.webm",
"vp90-00-tennis-300.webm", "vp90-00-tennis-4400.webm",
"vp90-00-tennis-800.webm", "vp90-00-waterfall-150.webm",
"vp90-00-waterfall-200.webm", "vp90-00-waterfall-400.webm",
"vp90-00-waterfall-800.webm",
};
#endif
class TestVectorTest : public ::libvpx_test::DecoderTest,
public ::libvpx_test::CodecTestWithParam<const char*> {
......@@ -102,20 +163,28 @@ class TestVectorTest : public ::libvpx_test::DecoderTest,
// the test failed.
TEST_P(TestVectorTest, MD5Match) {
const std::string filename = GET_PARAM(1);
// Open compressed video file.
libvpx_test::IVFVideoSource video(filename);
libvpx_test::CompressedVideoSource *video = NULL;
video.Init();
// Open compressed video file.
if (filename.substr(filename.length() - 3, 3) == "ivf") {
video = new libvpx_test::IVFVideoSource(filename);
} else if (filename.substr(filename.length() - 4, 4) == "webm") {
video = new libvpx_test::WebMVideoSource(filename);
}
video->Init();
// Construct md5 file name.
const std::string md5_filename = filename + ".md5";
OpenMD5File(md5_filename);
// Decode frame, and check the md5 matching.
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
ASSERT_NO_FATAL_FAILURE(RunLoop(video));
delete video;
}
VP8_INSTANTIATE_TEST_CASE(TestVectorTest,
::testing::ValuesIn(kTestVectors));
::testing::ValuesIn(kVP8TestVectors));
VP9_INSTANTIATE_TEST_CASE(TestVectorTest,
::testing::ValuesIn(kVP9TestVectors));
} // namespace
/*
* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef TEST_WEBM_VIDEO_SOURCE_H_
#define TEST_WEBM_VIDEO_SOURCE_H_
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <new>
#include <string>
#include "nestegg/include/nestegg/nestegg.h"
#include "test/video_source.h"
namespace libvpx_test {
static int
nestegg_read_cb(void *buffer, size_t length, void *userdata) {
FILE *f = reinterpret_cast<FILE *>(userdata);
if (fread(buffer, 1, length, f) < length) {
if (ferror(f))
return -1;
if (feof(f))
return 0;
}
return 1;
}
static int
nestegg_seek_cb(int64_t offset, int whence, void *userdata) {
FILE *f = reinterpret_cast<FILE *>(userdata);
switch (whence) {
case NESTEGG_SEEK_SET:
whence = SEEK_SET;
break;
case NESTEGG_SEEK_CUR:
whence = SEEK_CUR;
break;
case NESTEGG_SEEK_END:
whence = SEEK_END;
break;
};
return fseek(f, (long)offset, whence) ? -1 : 0;
}
static int64_t
nestegg_tell_cb(void *userdata) {
FILE *f = reinterpret_cast<FILE *>(userdata);
return ftell(f);
}
static void
nestegg_log_cb(nestegg *context, unsigned int severity, char const *format,
...) {
va_list ap;
va_start(ap, format);
vfprintf(stderr, format, ap);
fprintf(stderr, "\n");
va_end(ap);
}
// This class extends VideoSource to allow parsing of WebM files,
// so that we can do actual file decodes.
class WebMVideoSource : public CompressedVideoSource {
public:
explicit WebMVideoSource(const std::string &file_name)
: file_name_(file_name),
input_file_(NULL),
nestegg_ctx_(NULL),
pkt_(NULL),
video_track_(0),
chunk_(0),
chunks_(0),
buf_(NULL),
buf_sz_(0),
frame_(0),
end_of_file_(false) {
}
virtual ~WebMVideoSource() {
if (input_file_)
fclose(input_file_);
if (nestegg_ctx_)
nestegg_destroy(nestegg_ctx_);
}
virtual void Init() {
}
virtual void Begin() {
input_file_ = OpenTestDataFile(file_name_);
ASSERT_TRUE(input_file_) << "Input file open failed. Filename: "
<< file_name_;
nestegg_io io = {nestegg_read_cb, nestegg_seek_cb, nestegg_tell_cb,
input_file_};
ASSERT_FALSE(nestegg_init(&nestegg_ctx_, io, NULL))
<< "nestegg_init failed";
unsigned int n;
ASSERT_FALSE(nestegg_track_count(nestegg_ctx_, &n))
<< "failed to get track count";
for (unsigned int i = 0; i < n; i++) {
int track_type = nestegg_track_type(nestegg_ctx_, i);
ASSERT_GE(track_type, 0) << "failed to get track type";
if (track_type == NESTEGG_TRACK_VIDEO) {
video_track_ = i;
break;
}
}
FillFrame();
}
virtual void Next() {
++frame_;
FillFrame();
}
void FillFrame() {
if (chunk_ >= chunks_) {
unsigned int track;
do {
/* End of this packet, get another. */
if (pkt_)
nestegg_free_packet(pkt_);
int again = nestegg_read_packet(nestegg_ctx_, &pkt_);
ASSERT_GE(again, 0) << "nestegg_read_packet failed";
if (!again) {
end_of_file_ = true;
return;
}
ASSERT_FALSE(nestegg_packet_track(pkt_, &track))
<< "nestegg_packet_track failed";
} while (track != video_track_);
ASSERT_FALSE(nestegg_packet_count(pkt_, &chunks_))
<< "nestegg_packet_count failed";
chunk_ = 0;
}
ASSERT_FALSE(nestegg_packet_data(pkt_, chunk_, &buf_, &buf_sz_))
<< "nestegg_packet_data failed";
chunk_++;
}
virtual const uint8_t *cxdata() const {
return end_of_file_ ? NULL : buf_;
}
virtual const unsigned int frame_size() const { return buf_sz_; }
virtual const unsigned int frame_number() const { return frame_; }
protected:
std::string file_name_;
FILE *input_file_;
nestegg *nestegg_ctx_;
nestegg_packet *pkt_;
unsigned int video_track_;
unsigned int chunk_;
unsigned int chunks_;
uint8_t *buf_;
size_t buf_sz_;
unsigned int frame_;
bool end_of_file_;
};
} // namespace libvpx_test
#endif // TEST_WEBM_VIDEO_SOURCE_H_
......@@ -1759,6 +1759,7 @@ static void parse_global_config(struct global_config *global, char **argv) {
else
argj++;
}
global->limit = 50;
/* Validate global config */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment