Add unit test for decoder test_vector_test

Got 61 test vectors from vp8-test-vectors.git
(http://git.chromium.org/gitweb/?p=webm/vp8-test-vectors.git)

Added decoder test vectors downloading in unit tests. Uploaded
the test vectors and their md5 files to WebM website.
  $ gsutil cp *.* gs://downloads.webmproject.org/test_data/libvpx

Added their sha1sum to the test/test-data.sha1 file.

In unit tests, download the test vectors to LIBVPX_TEST_DATA_PATH.

Test_vector_test goes through the test vectors, decodes them, and
compute the md5 checksums. The checksums are compared with the
expected md5 checksums to tell if the decoder decodes correctly.

Change-Id: Ia1e84f9347ddf1d4a02e056c0fee7d28dccfae15
This commit is contained in:
Yunqing Wang 2012-10-04 12:59:36 -07:00
parent 9da8a34437
commit 15dffcfefa
9 changed files with 587 additions and 21 deletions

View File

@ -9,11 +9,12 @@
*/
#include "test/decode_test_driver.h"
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "test/video_source.h"
namespace libvpx_test {
#if CONFIG_VP8_DECODER
void Decoder::DecodeFrame(const uint8_t *cxdata, int size) {
if(!decoder_.priv) {
if (!decoder_.priv) {
const vpx_codec_err_t res_init = vpx_codec_dec_init(&decoder_,
&vpx_codec_vp8_dx_algo,
&cfg_, 0);
@ -24,5 +25,22 @@ void Decoder::DecodeFrame(const uint8_t *cxdata, int size) {
cxdata, size, NULL, 0);
ASSERT_EQ(VPX_CODEC_OK, res_dec) << DecodeError();
}
void DecoderTest::RunLoop(CompressedVideoSource *video) {
vpx_codec_dec_cfg_t dec_cfg = {0};
Decoder decoder(dec_cfg, 0);
// Decode frames.
for (video->Begin(); video->cxdata(); video->Next()) {
decoder.DecodeFrame(video->cxdata(), video->frame_size());
DxDataIterator dec_iter = decoder.GetDxData();
const vpx_image_t *img = NULL;
// Get decompressed data
while ((img = dec_iter.Next()))
DecompressedFrameHook(*img, video->frame_number());
}
}
#endif
} // namespace libvpx_test

View File

@ -10,20 +10,21 @@
#ifndef TEST_DECODE_TEST_DRIVER_H_
#define TEST_DECODE_TEST_DRIVER_H_
#include <string>
#include <vector>
#include <cstring>
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "vpx_config.h"
#include "vpx/vpx_decoder.h"
#include "vpx/vp8dx.h"
namespace libvpx_test {
class CompressedVideoSource;
// Provides an object to handle decoding output
class DxDataIterator {
public:
explicit DxDataIterator(vpx_codec_ctx_t *decoder)
: decoder_(decoder), iter_(NULL) {}
: decoder_(decoder), iter_(NULL) {}
const vpx_image_t *Next() {
return vpx_codec_get_frame(decoder_, &iter_);
@ -40,12 +41,12 @@ class DxDataIterator {
// added as more tests are added.
class Decoder {
public:
Decoder (vpx_codec_dec_cfg_t cfg, unsigned long deadline = 0)
: cfg_(cfg), deadline_(deadline) {
Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
: cfg_(cfg), deadline_(deadline) {
memset(&decoder_, 0, sizeof(decoder_));
}
~Decoder () {
~Decoder() {
vpx_codec_destroy(&decoder_);
}
@ -75,5 +76,22 @@ class Decoder {
unsigned int deadline_;
};
// Common test functionality for all Decoder tests.
class DecoderTest {
public:
// Main loop.
virtual void RunLoop(CompressedVideoSource *video);
// Hook to be called on every decompressed frame.
virtual void DecompressedFrameHook(const vpx_image_t& img,
const unsigned int frame_number) {}
protected:
DecoderTest() {}
virtual ~DecoderTest() {}
};
} // namespace libvpx_test
#endif /* TEST_DECODE_TEST_DRIVER_H_ */
#endif // TEST_DECODE_TEST_DRIVER_H_

View File

@ -143,7 +143,7 @@ void EncoderTest::RunLoop(VideoSource *video) {
BeginPassHook(pass);
Encoder encoder(cfg_, deadline_, init_flags_, &stats_);
#if CONFIG_VP8_DECODER
Decoder decoder(dec_cfg);
Decoder decoder(dec_cfg, 0);
bool has_cxdata = false;
#endif
bool again;

View File

@ -45,16 +45,9 @@ class I420VideoSource : public VideoSource {
}
virtual void Begin() {
std::string path_to_source = file_name_;
const char *kDataPath = getenv("LIBVPX_TEST_DATA_PATH");
if (kDataPath) {
path_to_source = kDataPath;
path_to_source += "/";
path_to_source += file_name_;
}
input_file_ = fopen(path_to_source.c_str(), "rb");
ASSERT_TRUE(input_file_) << "File open failed.";
input_file_ = OpenTestDataFile(file_name_);
ASSERT_TRUE(input_file_) << "Input file open failed. Filename: "
<< file_name_;
if (start_) {
fseek(input_file_, raw_sz_ * start_, SEEK_SET);

109
test/ivf_video_source.h Normal file
View File

@ -0,0 +1,109 @@
/*
* 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_IVF_VIDEO_SOURCE_H_
#define TEST_IVF_VIDEO_SOURCE_H_
#include <cstdio>
#include <cstdlib>
#include <new>
#include <string>
#include "test/video_source.h"
namespace libvpx_test {
const unsigned int kCodeBufferSize = 256 * 1024;
const unsigned int kIvfFileHdrSize = 32;
const unsigned int kIvfFrameHdrSize = 12;
static unsigned int MemGetLe32(const uint8_t *mem) {
return (mem[3] << 24) | (mem[2] << 16) | (mem[1] << 8) | (mem[0]);
}
// This class extends VideoSource to allow parsing of ivf files,
// so that we can do actual file decodes.
class IVFVideoSource : public CompressedVideoSource {
public:
IVFVideoSource(const std::string &file_name)
: file_name_(file_name),
input_file_(NULL),
compressed_frame_buf_(NULL),
frame_sz_(0),
frame_(0),
end_of_file_(false) {
}
virtual ~IVFVideoSource() {
delete[] compressed_frame_buf_;
if (input_file_)
fclose(input_file_);
}
virtual void Init() {
// Allocate a buffer for read in the compressed video frame.
compressed_frame_buf_ = new uint8_t[libvpx_test::kCodeBufferSize];
ASSERT_TRUE(compressed_frame_buf_) << "Allocate frame buffer failed";
}
virtual void Begin() {
input_file_ = OpenTestDataFile(file_name_);
ASSERT_TRUE(input_file_) << "Input file open failed. Filename: "
<< file_name_;
// Read file header
uint8_t file_hdr[kIvfFileHdrSize];
ASSERT_EQ(kIvfFileHdrSize, fread(file_hdr, 1, kIvfFileHdrSize, input_file_))
<< "File header read failed.";
// Check file header
ASSERT_TRUE(file_hdr[0] == 'D' && file_hdr[1] == 'K' && file_hdr[2] == 'I'
&& file_hdr[3] == 'F') << "Input is not an IVF file.";
FillFrame();
}
virtual void Next() {
++frame_;
FillFrame();
}
void FillFrame() {
uint8_t frame_hdr[kIvfFrameHdrSize];
// Check frame header and read a frame from input_file.
if (fread(frame_hdr, 1, kIvfFrameHdrSize, input_file_)
!= kIvfFrameHdrSize) {
end_of_file_ = true;
} else {
end_of_file_ = false;
frame_sz_ = MemGetLe32(frame_hdr);
ASSERT_LE(frame_sz_, kCodeBufferSize)
<< "Frame is too big for allocated code buffer";
ASSERT_EQ(frame_sz_,
fread(compressed_frame_buf_, 1, frame_sz_, input_file_))
<< "Failed to read complete frame";
}
}
virtual const uint8_t *cxdata() const {
return end_of_file_ ? NULL : compressed_frame_buf_;
}
virtual const unsigned int frame_size() const { return frame_sz_; }
virtual const unsigned int frame_number() const { return frame_; }
protected:
std::string file_name_;
FILE *input_file_;
uint8_t *compressed_frame_buf_;
unsigned int frame_sz_;
unsigned int frame_;
bool end_of_file_;
};
} // namespace libvpx_test
#endif // TEST_IVF_VIDEO_SOURCE_H_

View File

@ -1 +1,123 @@
d5dfb0151c9051f8c85999255645d7a23916d3c0 hantro_collage_w352h288.yuv
5184c46ddca8b1fadd16742e8500115bc8f749da vp80-00-comprehensive-001.ivf
65bf1bbbced81b97bd030f376d1b7f61a224793f vp80-00-comprehensive-002.ivf
906b4c1e99eb734504c504b3f1ad8052137ce672 vp80-00-comprehensive-003.ivf
ec144b1af53af895db78355785650b96dd3f0ade vp80-00-comprehensive-004.ivf
afc7091785c62f1c121c4554a2830c30704587d9 vp80-00-comprehensive-005.ivf
42ea9d55c818145d06a9b633b8e85c6a6164fd3e vp80-00-comprehensive-006.ivf
e5b3a73ab79fe024c14309d653d6bed92902ee3b vp80-00-comprehensive-007.ivf
f3c50a58875930adfb84525c0ef59d7e4c08540c vp80-00-comprehensive-008.ivf
4b2841fdb83db51ae322096ae468bbb9dc2c8362 vp80-00-comprehensive-009.ivf
efbff736e3a91ab6a98c5bc2dce65d645944c7b1 vp80-00-comprehensive-010.ivf
6b315102cae008d22a3d2c231be92cb704a222f8 vp80-00-comprehensive-011.ivf
f3214a4fea14c2d5ec689936c1613f274c859ee8 vp80-00-comprehensive-012.ivf
e4094e96d308c8a35b74c480a43d853c5294cd34 vp80-00-comprehensive-013.ivf
5b0adfaf60a69e0aaf3ec021a39d0a68fc0e1b5a vp80-00-comprehensive-014.ivf
e8467688ddf26b5000664f904faf0d70506aa653 vp80-00-comprehensive-015.ivf
aab55582337dfd2a39ff54fb2576a91910d49337 vp80-00-comprehensive-016.ivf
1ba24724f80203c9bae4f1d0f99d534721980016 vp80-00-comprehensive-017.ivf
143a15512b46f436280ddb4d0e6411eb4af434f2 vp80-00-comprehensive-018.ivf
c5baeaf5714fdfb3a8bc960a8e33ac438e83b16b vp80-01-intra-1400.ivf
f383955229afe3408453e316d11553d923ca60d5 vp80-01-intra-1411.ivf
84e1f4343f174c9f3c83f834bac3196fb325bf2c vp80-01-intra-1416.ivf
fb6e712a47dd57a28a3727d2ae2c97a8b7c7ca51 vp80-01-intra-1417.ivf
71ea772d3e9d315b8cbecf41207b8a237c34853b vp80-02-inter-1402.ivf
d85dbc4271525dcd128c503f936fe69091d1f8d0 vp80-02-inter-1412.ivf
d4e5d3ad56511867d025f93724d090f92ba6ec3d vp80-02-inter-1418.ivf
91791cbcc37c60f35dbd8090bacb54e5ec6dd4fa vp80-02-inter-1424.ivf
17fbfe2fea70f6e2f3fa6ca4efaae6c0b03b5f02 vp80-03-segmentation-01.ivf
3c3600dbbcde08e20d54c66fe3b7eadd4f09bdbb vp80-03-segmentation-02.ivf
c156778d5340967d4b369c490848076e92f1f875 vp80-03-segmentation-03.ivf
d25dcff6c60e87a1af70945b8911b6b4998533b0 vp80-03-segmentation-04.ivf
362baba2ce454c9db21218f35e81c27a5ed0b730 vp80-03-segmentation-1401.ivf
d223ae7ee748ce07e74c4679bfd219e84aa9f4b0 vp80-03-segmentation-1403.ivf
033adf7f3a13836a3f1cffcb87c1972900f2b5c6 vp80-03-segmentation-1407.ivf
4d51dfbf9f3e2c590ec99d1d6f59dd731d04375f vp80-03-segmentation-1408.ivf
f37a62b197c2600d75e0ccfbb31b60efdedac251 vp80-03-segmentation-1409.ivf
eb25bd7bfba5b2f6935018a930f42d123b1e7fcd vp80-03-segmentation-1410.ivf
b9d5c436663a30c27cfff84b53a002e501258843 vp80-03-segmentation-1413.ivf
6da92b9d1a180cc3a8afe348ab12258f5a37be1a vp80-03-segmentation-1414.ivf
a4f5842602886bd669f115f93d8a35c035cb0948 vp80-03-segmentation-1415.ivf
f295dceb8ef278b77251b3f9df8aee22e161d547 vp80-03-segmentation-1425.ivf
198dbf9f36f733200e432664cc8c5752d59779de vp80-03-segmentation-1426.ivf
7704804e32f5de976803929934a7fafe101ac7b0 vp80-03-segmentation-1427.ivf
831ccd862ea95ca025d2f3bd8b88678752f5416d vp80-03-segmentation-1432.ivf
b3c11978529289f9109f2766fcaba3ebc40e11ef vp80-03-segmentation-1435.ivf
a835a731f5520ebfc1002c40121264d0020559ac vp80-03-segmentation-1436.ivf
1d1732942f773bb2a5775fcb9689b1579ce28eab vp80-03-segmentation-1437.ivf
db04799adfe089dfdf74dbd43cc05ede7161f99e vp80-03-segmentation-1441.ivf
7caf39b3f20cfd52b998210878062e52a5edf1e6 vp80-03-segmentation-1442.ivf
3607f6bb4ee106c38fa1ea370dc4ff8b8cde2261 vp80-04-partitions-1404.ivf
93cc323b6b6867f1b12dd48773424549c6960a6b vp80-04-partitions-1405.ivf
047eedb14b865bdac8a3538e63801054e0295e9c vp80-04-partitions-1406.ivf
0f1233bd2bc33f56ce5e495dbd455d122339f384 vp80-05-sharpness-1428.ivf
51767fc136488a9535c2a4c38067c542ee2048df vp80-05-sharpness-1429.ivf
9805aa107672de25d6fb8c35e20d06deca5efe18 vp80-05-sharpness-1430.ivf
61db6b965f9c27aebe71b85bf2d5877e58e4bbdf vp80-05-sharpness-1431.ivf
10420d266290d2923555f84af38eeb96edbd3ae8 vp80-05-sharpness-1433.ivf
3ed24f9a80cddfdf75824ba95cdb4ff9286cb443 vp80-05-sharpness-1434.ivf
c87599cbecd72d4cd4f7ace3313b7a6bc6eb8163 vp80-05-sharpness-1438.ivf
aff51d865c2621b60510459244ea83e958e4baed vp80-05-sharpness-1439.ivf
da386e72b19b5485a6af199c5eb60ef25e510dd1 vp80-05-sharpness-1440.ivf
6759a095203d96ccd267ce09b1b050b8cc4c2f1f vp80-05-sharpness-1443.ivf
db55ec7fd02c864ba996ff060b25b1e08611330b vp80-00-comprehensive-001.ivf.md5
29db0ad011cba1e45f856d5623cd38dac3e3bf19 vp80-00-comprehensive-002.ivf.md5
e84f258f69e173e7d68f8f8c037a0a3766902182 vp80-00-comprehensive-003.ivf.md5
eb7912eaf69559a16fd82bc3f5fb1524cf4a4466 vp80-00-comprehensive-004.ivf.md5
4206f71c94894bd5b5b376f6c09b3817dbc65206 vp80-00-comprehensive-005.ivf.md5
4f89b356f6f2fecb928f330a10f804f00f5325f5 vp80-00-comprehensive-006.ivf.md5
2813236a32964dd8007e17648bcf035a20fcda6c vp80-00-comprehensive-007.ivf.md5
10746c72098f872803c900e17c5680e451f5f498 vp80-00-comprehensive-008.ivf.md5
39a23d0692ce64421a7bb7cdf6ccec5928d37fff vp80-00-comprehensive-009.ivf.md5
f6e3de8931a0cc659bda8fbc14050346955e72d4 vp80-00-comprehensive-010.ivf.md5
101683ec195b6e944f7cd1e468fc8921439363e6 vp80-00-comprehensive-011.ivf.md5
1f592751ce46d8688998fa0fa4fbdcda0fd4058c vp80-00-comprehensive-012.ivf.md5
6066176f90ca790251e795fca1a5797d59999841 vp80-00-comprehensive-013.ivf.md5
2656da94ba93691f23edc4d60b3a09e2be46c217 vp80-00-comprehensive-014.ivf.md5
c6e0d5f5d61460c8ac8edfa4e701f10312c03133 vp80-00-comprehensive-015.ivf.md5
ee60fee501d8493e34e8d6a1fe315b51ed09b24a vp80-00-comprehensive-016.ivf.md5
9f1914ceffcad4546c0a29de3ef591d8bea304dc vp80-00-comprehensive-017.ivf.md5
e0305178fe288a9fd8082b39e2d03181edb19054 vp80-00-comprehensive-018.ivf.md5
612494da2fa799cc9d76dcdd835ae6c7cb2e5c05 vp80-01-intra-1400.ivf.md5
48ea06097ac8269c5e8c2131d3d0639f431fcf0e vp80-01-intra-1411.ivf.md5
6e2ab4e7677ad0ba868083ca6bc387ee922b400c vp80-01-intra-1416.ivf.md5
eca0a90348959ce3854142f8d8641b13050e8349 vp80-01-intra-1417.ivf.md5
920feea203145d5c2258a91c4e6991934a79a99e vp80-02-inter-1402.ivf.md5
f71d97909fe2b3dd65be7e1f56c72237f0cef200 vp80-02-inter-1412.ivf.md5
e911254569a30bbb2a237ff8b79f69ed9da0672d vp80-02-inter-1418.ivf.md5
58c789c50c9bb9cc90580bed291164a0939d28ba vp80-02-inter-1424.ivf.md5
ff3e2f441327b9c20a0b37c524e0f5a48a36de7b vp80-03-segmentation-01.ivf.md5
0791f417f076a542ae66fbc3426ab4d94cbd6c75 vp80-03-segmentation-02.ivf.md5
722e50f1a6a91c34302d68681faffc1c26d1cc57 vp80-03-segmentation-03.ivf.md5
c701f1885bcfb27fb8e70cc65606b289172ef889 vp80-03-segmentation-04.ivf.md5
f79bc9ec189a2b4807632a3d0c5bf04a178b5300 vp80-03-segmentation-1401.ivf.md5
b9aa4c74c0219b639811c44760d0b24cd8bb436a vp80-03-segmentation-1403.ivf.md5
70d5a2207ca1891bcaebd5cf6dd88ce8d57b4334 vp80-03-segmentation-1407.ivf.md5
265f962ee781531f9a93b9309461316fd32b2a1d vp80-03-segmentation-1408.ivf.md5
0c4ecbbd6dc042d30e626d951b65f460dd6cd563 vp80-03-segmentation-1409.ivf.md5
cf779af36a937f06570a0fca9db64ba133451dee vp80-03-segmentation-1410.ivf.md5
0e6c5036d51ab078842f133934926c598a9cff02 vp80-03-segmentation-1413.ivf.md5
eb3930aaf229116c80d507516c34759c3f6cdf69 vp80-03-segmentation-1414.ivf.md5
123d6c0f72ee87911c4ae7538e87b7d163b22d6c vp80-03-segmentation-1415.ivf.md5
e70551d1a38920e097a5d8782390b79ecaeb7505 vp80-03-segmentation-1425.ivf.md5
44e8f4117e46dbb302b2cfd81171cc1a1846e431 vp80-03-segmentation-1426.ivf.md5
52636e54aee5f95bbace37021bd67de5db767e9a vp80-03-segmentation-1427.ivf.md5
b1ad3eff20215c28e295b15ef3636ed926d59cba vp80-03-segmentation-1432.ivf.md5
24c22a552fa28a90e5978f67f57181cc2d7546d7 vp80-03-segmentation-1435.ivf.md5
96c49c390abfced18a7a8c9b9ea10af778e10edb vp80-03-segmentation-1436.ivf.md5
f95eb6214571434f1f73ab7833b9ccdf47588020 vp80-03-segmentation-1437.ivf.md5
1c0700ca27c9b0090a7747a4b0b4dc21d1843181 vp80-03-segmentation-1441.ivf.md5
81d4f23ca32667ee958bae579c8f5e97ba72eb97 vp80-03-segmentation-1442.ivf.md5
272efcef07a3a30fbca51bfd566063d8258ec0be vp80-04-partitions-1404.ivf.md5
66ed219ab812ac801b256d35cf495d193d4cf478 vp80-04-partitions-1405.ivf.md5
36083f37f56f502bd60ec5e07502ee9e6b8699b0 vp80-04-partitions-1406.ivf.md5
6ca909bf168a64c09415626294665dc1be3d1973 vp80-05-sharpness-1428.ivf.md5
1667d2ee2334e5fdea8a8a866f4ccf3cf76f033a vp80-05-sharpness-1429.ivf.md5
71bcbe5357d36a19df5b07fbe3e27bffa8893f0a vp80-05-sharpness-1430.ivf.md5
89a09b1dffce2d55770a89e58d9925c70ef79bf8 vp80-05-sharpness-1431.ivf.md5
08444a18b4e6ba3450c0796dd728d48c399a2dc9 vp80-05-sharpness-1433.ivf.md5
6d6223719a90c13e848aa2a8a6642098cdb5977a vp80-05-sharpness-1434.ivf.md5
41d70bb5fa45bc88da1604a0af466930b8dd77b5 vp80-05-sharpness-1438.ivf.md5
086c56378df81b6cee264d7540a7b8f2b405c7a4 vp80-05-sharpness-1439.ivf.md5
d32dc2c4165eb266ea4c23c14a45459b363def32 vp80-05-sharpness-1440.ivf.md5
8c69dc3d8e563f56ffab5ad1e400d9e689dd23df vp80-05-sharpness-1443.ivf.md5

View File

@ -2,6 +2,7 @@ LIBVPX_TEST_SRCS-yes += acm_random.h
LIBVPX_TEST_SRCS-yes += test.mk
LIBVPX_TEST_SRCS-yes += test_libvpx.cc
LIBVPX_TEST_SRCS-yes += util.h
LIBVPX_TEST_SRCS-yes += video_source.h
##
## BLACK BOX TESTS
@ -17,10 +18,12 @@ LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += error_resilience_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += i420_video_source.h
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += keyframe_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += resize_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += video_source.h
LIBVPX_TEST_SRCS-$(CONFIG_VP8_DECODER) += ../md5_utils.h ../md5_utils.c
LIBVPX_TEST_SRCS-$(CONFIG_VP8_DECODER) += decode_test_driver.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP8_DECODER) += decode_test_driver.h
LIBVPX_TEST_SRCS-$(CONFIG_VP8_DECODER) += ivf_video_source.h
LIBVPX_TEST_SRCS-$(CONFIG_VP8_DECODER) += test_vector_test.cc
##
## WHITE BOX TESTS
##
@ -50,3 +53,125 @@ endif
## TEST DATA
##
LIBVPX_TEST_DATA-$(CONFIG_VP8_ENCODER) += hantro_collage_w352h288.yuv
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-001.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-002.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-003.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-004.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-005.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-006.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-007.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-008.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-009.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-010.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-011.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-012.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-013.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-014.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-015.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-016.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-017.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-018.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-01-intra-1400.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-01-intra-1411.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-01-intra-1416.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-01-intra-1417.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-02-inter-1402.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-02-inter-1412.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-02-inter-1418.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-02-inter-1424.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-01.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-02.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-03.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-04.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1401.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1403.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1407.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1408.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1409.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1410.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1413.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1414.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1415.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1425.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1426.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1427.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1432.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1435.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1436.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1437.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1441.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1442.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-04-partitions-1404.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-04-partitions-1405.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-04-partitions-1406.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1428.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1429.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1430.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1431.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1433.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1434.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1438.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1439.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1440.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1443.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-001.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-002.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-003.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-004.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-005.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-006.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-007.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-008.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-009.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-010.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-011.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-012.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-013.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-014.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-015.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-016.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-017.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-00-comprehensive-018.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-01-intra-1400.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-01-intra-1411.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-01-intra-1416.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-01-intra-1417.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-02-inter-1402.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-02-inter-1412.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-02-inter-1418.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-02-inter-1424.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1401.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1403.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1407.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1408.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1409.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1410.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1413.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1414.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1415.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1425.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1426.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1427.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1432.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1435.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1436.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1437.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1441.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-1442.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-01.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-02.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-03.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-03-segmentation-04.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-04-partitions-1404.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-04-partitions-1405.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-04-partitions-1406.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1428.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1429.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1430.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1431.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1433.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1434.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1438.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1439.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1440.ivf.md5
LIBVPX_TEST_DATA-$(CONFIG_VP8_DECODER) += vp80-05-sharpness-1443.ivf.md5

144
test/test_vector_test.cc Normal file
View File

@ -0,0 +1,144 @@
/*
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.
*/
#include <cstdio>
#include <cstdlib>
#include <string>
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "test/decode_test_driver.h"
#include "test/ivf_video_source.h"
extern "C" {
#include "./md5_utils.h"
#include "vpx_mem/vpx_mem.h"
}
#if defined(_MSC_VER)
#define snprintf sprintf_s
#endif
namespace {
// There are 61 test vectors in total.
const char *kTestVectors[] = {
"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",
"vp80-00-comprehensive-006.ivf", "vp80-00-comprehensive-007.ivf",
"vp80-00-comprehensive-008.ivf", "vp80-00-comprehensive-009.ivf",
"vp80-00-comprehensive-010.ivf", "vp80-00-comprehensive-011.ivf",
"vp80-00-comprehensive-012.ivf", "vp80-00-comprehensive-013.ivf",
"vp80-00-comprehensive-014.ivf", "vp80-00-comprehensive-015.ivf",
"vp80-00-comprehensive-016.ivf", "vp80-00-comprehensive-017.ivf",
"vp80-00-comprehensive-018.ivf", "vp80-01-intra-1400.ivf",
"vp80-01-intra-1411.ivf", "vp80-01-intra-1416.ivf",
"vp80-01-intra-1417.ivf", "vp80-02-inter-1402.ivf",
"vp80-02-inter-1412.ivf", "vp80-02-inter-1418.ivf",
"vp80-02-inter-1424.ivf", "vp80-03-segmentation-01.ivf",
"vp80-03-segmentation-02.ivf", "vp80-03-segmentation-03.ivf",
"vp80-03-segmentation-04.ivf", "vp80-03-segmentation-1401.ivf",
"vp80-03-segmentation-1403.ivf", "vp80-03-segmentation-1407.ivf",
"vp80-03-segmentation-1408.ivf", "vp80-03-segmentation-1409.ivf",
"vp80-03-segmentation-1410.ivf", "vp80-03-segmentation-1413.ivf",
"vp80-03-segmentation-1414.ivf", "vp80-03-segmentation-1415.ivf",
"vp80-03-segmentation-1425.ivf", "vp80-03-segmentation-1426.ivf",
"vp80-03-segmentation-1427.ivf", "vp80-03-segmentation-1432.ivf",
"vp80-03-segmentation-1435.ivf", "vp80-03-segmentation-1436.ivf",
"vp80-03-segmentation-1437.ivf", "vp80-03-segmentation-1441.ivf",
"vp80-03-segmentation-1442.ivf", "vp80-04-partitions-1404.ivf",
"vp80-04-partitions-1405.ivf", "vp80-04-partitions-1406.ivf",
"vp80-05-sharpness-1428.ivf", "vp80-05-sharpness-1429.ivf",
"vp80-05-sharpness-1430.ivf", "vp80-05-sharpness-1431.ivf",
"vp80-05-sharpness-1433.ivf", "vp80-05-sharpness-1434.ivf",
"vp80-05-sharpness-1438.ivf", "vp80-05-sharpness-1439.ivf",
"vp80-05-sharpness-1440.ivf", "vp80-05-sharpness-1443.ivf"
};
class TestVectorTest : public libvpx_test::DecoderTest,
public ::testing::TestWithParam<const char*> {
protected:
TestVectorTest() : md5_file_(NULL) {}
virtual ~TestVectorTest() {
if (md5_file_)
fclose(md5_file_);
}
void OpenMD5File(const std::string& md5_file_name_) {
md5_file_ = libvpx_test::OpenTestDataFile(md5_file_name_);
ASSERT_TRUE(md5_file_) << "Md5 file open failed. Filename: "
<< md5_file_name_;
}
virtual void DecompressedFrameHook(const vpx_image_t& img,
const unsigned int frame_number) {
char expected_md5[33];
char junk[128];
// Read correct md5 checksums.
const int res = fscanf(md5_file_, "%s %s", expected_md5, junk);
ASSERT_NE(res, EOF) << "Read md5 data failed";
expected_md5[32] = '\0';
MD5Context md5;
MD5Init(&md5);
// Compute and update md5 for each raw in decompressed data.
for (int plane = 0; plane < 3; ++plane) {
uint8_t *buf = img.planes[plane];
for (unsigned int y = 0; y < (plane ? (img.d_h + 1) >> 1 : img.d_h);
++y) {
MD5Update(&md5, buf, (plane ? (img.d_w + 1) >> 1 : img.d_w));
buf += img.stride[plane];
}
}
uint8_t md5_sum[16];
MD5Final(md5_sum, &md5);
char actual_md5[33];
// Convert to get the actual md5.
for (int i = 0; i < 16; i++) {
snprintf(&actual_md5[i * 2], sizeof(actual_md5) - i * 2, "%02x",
md5_sum[i]);
}
actual_md5[32] = '\0';
// Check md5 match.
ASSERT_STREQ(expected_md5, actual_md5)
<< "Md5 checksums don't match: frame number = " << frame_number;
}
private:
FILE *md5_file_;
};
// This test runs through the whole set of test vectors, and decodes them.
// The md5 checksums are computed for each frame in the video file. If md5
// checksums match the correct md5 data, then the test is passed. Otherwise,
// the test failed.
TEST_P(TestVectorTest, MD5Match) {
const std::string filename = GetParam();
// Open compressed video file.
libvpx_test::IVFVideoSource video(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));
}
INSTANTIATE_TEST_CASE_P(TestVectorSequence, TestVectorTest,
::testing::ValuesIn(kTestVectors));
} // namespace

View File

@ -10,11 +10,27 @@
#ifndef TEST_VIDEO_SOURCE_H_
#define TEST_VIDEO_SOURCE_H_
#include <cstdio>
#include <cstdlib>
#include <string>
#include "test/acm_random.h"
#include "vpx/vpx_encoder.h"
namespace libvpx_test {
static FILE *OpenTestDataFile(const std::string& file_name) {
std::string path_to_source = file_name;
const char *kDataPath = getenv("LIBVPX_TEST_DATA_PATH");
if (kDataPath) {
path_to_source = kDataPath;
path_to_source += "/";
path_to_source += file_name;
}
return fopen(path_to_source.c_str(), "rb");
}
// Abstract base class for test video sources, which provide a stream of
// vpx_image_t images with associated timestamps and duration.
class VideoSource {
@ -128,6 +144,27 @@ class RandomVideoSource : public DummyVideoSource {
int seed_;
};
// Abstract base class for test video sources, which provide a stream of
// decompressed images to the decoder.
class CompressedVideoSource {
public:
virtual ~CompressedVideoSource() {}
virtual void Init() = 0;
// Prepare the stream for reading, rewind/open as necessary.
virtual void Begin() = 0;
// Advance the cursor to the next frame
virtual void Next() = 0;
virtual const uint8_t *cxdata() const = 0;
virtual const unsigned int frame_size() const = 0;
virtual const unsigned int frame_number() const = 0;
};
} // namespace libvpx_test
#endif // TEST_VIDEO_SOURCE_H_