diff options
Diffstat (limited to 'test')
-rwxr-xr-x | test/decode_to_md5.sh | 68 | ||||
-rw-r--r-- | test/external_frame_buffer_test.cc | 13 | ||||
-rwxr-xr-x | test/simple_decoder.sh | 57 | ||||
-rw-r--r-- | test/test.mk | 9 | ||||
-rw-r--r-- | test/test_vector_test.cc | 9 | ||||
-rwxr-xr-x | test/tools_common.sh | 11 | ||||
-rw-r--r-- | test/vp8_boolcoder_test.cc | 8 | ||||
-rw-r--r-- | test/vp8_decrypt_test.cc | 10 | ||||
-rw-r--r-- | test/vp9_boolcoder_test.cc | 2 | ||||
-rw-r--r-- | test/vp9_decrypt_test.cc | 71 | ||||
-rw-r--r-- | test/vp9_thread_test.cc | 5 | ||||
-rwxr-xr-x | test/vpxdec.sh | 3 | ||||
-rwxr-xr-x | test/vpxenc.sh | 3 |
13 files changed, 248 insertions, 21 deletions
diff --git a/test/decode_to_md5.sh b/test/decode_to_md5.sh new file mode 100755 index 000000000..da1a87062 --- /dev/null +++ b/test/decode_to_md5.sh @@ -0,0 +1,68 @@ +#!/bin/sh +## +## Copyright (c) 2014 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. +## +## This file tests the libvpx decode_to_md5 example. To add new tests to this +## file, do the following: +## 1. Write a shell function (this is your test). +## 2. Add the function to decode_to_md5_tests (on a new line). +## +. $(dirname $0)/tools_common.sh + +# Environment check: Make sure input is available: +# $VP8_IVF_FILE and $VP9_IVF_FILE are required. +decode_to_md5_verify_environment() { + if [ ! -e "${VP8_IVF_FILE}" ] || [ ! -e "${VP9_IVF_FILE}" ]; then + echo "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH." + return 1 + fi +} + +# Runs decode_to_md5 on $1 and echoes the MD5 sum for the final frame. $2 is +# interpreted as codec name and used solely to name the output file. +decode_to_md5() { + local decoder="${LIBVPX_BIN_PATH}/decode_to_md5${VPX_TEST_EXE_SUFFIX}" + local input_file="$1" + local codec="$2" + local output_file="${VPX_TEST_OUTPUT_DIR}/decode_to_md5_${codec}" + + [ -x "${decoder}" ] || return 1 + + "${decoder}" "${input_file}" "${output_file}" > /dev/null 2>&1 + + [ -e "${output_file}" ] || return 1 + + local md5_last_frame=$(tail -n1 "${output_file}") + echo "${md5_last_frame% *}" | tr -d [:space:] +} + +decode_to_md5_vp8() { + # expected MD5 sum for the last frame. + local expected_md5="56794d911b02190212bca92f88ad60c6" + + if [ "$(vp8_decode_available)" = "yes" ]; then + local actual_md5="$(decode_to_md5 "${VP8_IVF_FILE}" vp8)" || return 1 + [ "${actual_md5}" = "${expected_md5}" ] || return 1 + fi +} + +decode_to_md5_vp9() { + # expected MD5 sum for the last frame. + local expected_md5="2952c0eae93f3dadd1aa84c50d3fd6d2" + + if [ "$(vp9_decode_available)" = "yes" ]; then + local actual_md5="$(decode_to_md5 "${VP9_IVF_FILE}" vp9)" || return 1 + [ "${actual_md5}" = "${expected_md5}" ] || return 1 + fi +} + +decode_to_md5_tests="decode_to_md5_vp8 + decode_to_md5_vp9" + +run_tests decode_to_md5_verify_environment "${decode_to_md5_tests}" diff --git a/test/external_frame_buffer_test.cc b/test/external_frame_buffer_test.cc index 54c79e903..fb0449deb 100644 --- a/test/external_frame_buffer_test.cc +++ b/test/external_frame_buffer_test.cc @@ -10,13 +10,16 @@ #include <string> +#include "./vpx_config.h" #include "test/codec_factory.h" #include "test/decode_test_driver.h" #include "test/ivf_video_source.h" #include "test/md5_helper.h" #include "test/test_vectors.h" #include "test/util.h" +#if CONFIG_WEBM_IO #include "test/webm_video_source.h" +#endif namespace { @@ -267,6 +270,7 @@ class ExternalFrameBufferMD5Test ExternalFrameBufferList fb_list_; }; +#if CONFIG_WEBM_IO // Class for testing passing in external frame buffers to libvpx. class ExternalFrameBufferTest : public ::testing::Test { protected: @@ -340,6 +344,7 @@ class ExternalFrameBufferTest : public ::testing::Test { int num_buffers_; ExternalFrameBufferList fb_list_; }; +#endif // CONFIG_WEBM_IO // This test runs through the set of test vectors, and decodes them. // Libvpx will call into the application to allocate a frame buffer when @@ -366,7 +371,13 @@ TEST_P(ExternalFrameBufferMD5Test, ExtFBMD5Match) { if (filename.substr(filename.length() - 3, 3) == "ivf") { video = new libvpx_test::IVFVideoSource(filename); } else { +#if CONFIG_WEBM_IO video = new libvpx_test::WebMVideoSource(filename); +#else + fprintf(stderr, "WebM IO is disabled, skipping test vector %s\n", + filename.c_str()); + return; +#endif } ASSERT_TRUE(video != NULL); video->Init(); @@ -380,6 +391,7 @@ TEST_P(ExternalFrameBufferMD5Test, ExtFBMD5Match) { delete video; } +#if CONFIG_WEBM_IO TEST_F(ExternalFrameBufferTest, MinFrameBuffers) { // Minimum number of external frame buffers for VP9 is // #VP9_MAXIMUM_REF_BUFFERS + #VPX_MAXIMUM_WORK_BUFFERS. @@ -460,6 +472,7 @@ TEST_F(ExternalFrameBufferTest, SetAfterDecode) { SetFrameBufferFunctions( num_buffers, get_vp9_frame_buffer, release_vp9_frame_buffer)); } +#endif // CONFIG_WEBM_IO VP9_INSTANTIATE_TEST_CASE(ExternalFrameBufferMD5Test, ::testing::ValuesIn(libvpx_test::kVP9TestVectors, diff --git a/test/simple_decoder.sh b/test/simple_decoder.sh new file mode 100755 index 000000000..a0db58ff8 --- /dev/null +++ b/test/simple_decoder.sh @@ -0,0 +1,57 @@ +#!/bin/sh +## +## Copyright (c) 2014 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. +## +## This file tests the libvpx simple_decoder example code. To add new tests to +## this file, do the following: +## 1. Write a shell function (this is your test). +## 2. Add the function to simple_decoder_tests (on a new line). +## +. $(dirname $0)/tools_common.sh + +# Environment check: Make sure input is available: +# $VP8_IVF_FILE and $VP9_IVF_FILE are required. +simple_decoder_verify_environment() { + if [ ! -e "${VP8_IVF_FILE}" ] || [ ! -e "${VP9_IVF_FILE}" ]; then + echo "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH." + return 1 + fi +} + +# Runs simple_decoder using $1 as input file. $2 is the codec name, and is used +# solely to name the output file. +simple_decoder() { + local decoder="${LIBVPX_BIN_PATH}/simple_decoder${VPX_TEST_EXE_SUFFIX}" + local input_file="$1" + local codec="$2" + local output_file="${VPX_TEST_OUTPUT_DIR}/simple_decoder_${codec}.raw" + + [ -x "${decoder}" ] || return 1 + + "${decoder}" "${input_file}" "${output_file}" > /dev/null 2>&1 + + [ -e "${output_file}" ] || return 1 +} + +simple_decoder_vp8() { + if [ "$(vp8_decode_available)" = "yes" ]; then + simple_decoder "${VP8_IVF_FILE}" vp8 || return 1 + fi +} + +simple_decoder_vp9() { + if [ "$(vp9_decode_available)" = "yes" ]; then + simple_decoder "${VP9_IVF_FILE}" vp9 || return 1 + fi +} + +simple_decoder_tests="simple_decoder_vp8 + simple_decoder_vp9" + +run_tests simple_decoder_verify_environment "${simple_decoder_tests}" diff --git a/test/test.mk b/test/test.mk index f1a8ed9a0..da56b00ec 100644 --- a/test/test.mk +++ b/test/test.mk @@ -42,6 +42,7 @@ LIBVPX_TEST_SRCS-yes += encode_test_driver.cc LIBVPX_TEST_SRCS-yes += encode_test_driver.h ## WebM Parsing +ifeq ($(CONFIG_WEBM_IO), yes) NESTEGG_SRCS += ../third_party/nestegg/halloc/halloc.h NESTEGG_SRCS += ../third_party/nestegg/halloc/src/align.h NESTEGG_SRCS += ../third_party/nestegg/halloc/src/halloc.c @@ -53,11 +54,14 @@ LIBVPX_TEST_SRCS-$(CONFIG_DECODERS) += ../tools_common.h LIBVPX_TEST_SRCS-$(CONFIG_DECODERS) += ../webmdec.c LIBVPX_TEST_SRCS-$(CONFIG_DECODERS) += ../webmdec.h LIBVPX_TEST_SRCS-$(CONFIG_DECODERS) += webm_video_source.h +endif LIBVPX_TEST_SRCS-$(CONFIG_DECODERS) += test_vector_test.cc -# Currently we only support decoder perf tests for vp9 -ifeq ($(CONFIG_DECODE_PERF_TESTS)$(CONFIG_VP9_DECODER), yesyes) +# Currently we only support decoder perf tests for vp9. Also they read from WebM +# files, so WebM IO is required. +ifeq ($(CONFIG_DECODE_PERF_TESTS)$(CONFIG_VP9_DECODER)$(CONFIG_WEBM_IO), \ + yesyesyes) LIBVPX_TEST_SRCS-yes += decode_perf_test.cc endif @@ -106,6 +110,7 @@ endif LIBVPX_TEST_SRCS-$(CONFIG_VP9) += convolve_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_DECODER) += vp9_thread_test.cc +LIBVPX_TEST_SRCS-$(CONFIG_VP9_DECODER) += vp9_decrypt_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += dct16x16_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += dct32x32_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += fdct4x4_test.cc diff --git a/test/test_vector_test.cc b/test/test_vector_test.cc index 9ba18daef..1f294f20b 100644 --- a/test/test_vector_test.cc +++ b/test/test_vector_test.cc @@ -12,13 +12,16 @@ #include <cstdlib> #include <string> #include "third_party/googletest/src/include/gtest/gtest.h" +#include "./vpx_config.h" #include "test/codec_factory.h" #include "test/decode_test_driver.h" #include "test/ivf_video_source.h" #include "test/md5_helper.h" #include "test/test_vectors.h" #include "test/util.h" +#if CONFIG_WEBM_IO #include "test/webm_video_source.h" +#endif #include "vpx_mem/vpx_mem.h" namespace { @@ -75,7 +78,13 @@ TEST_P(TestVectorTest, MD5Match) { if (filename.substr(filename.length() - 3, 3) == "ivf") { video = new libvpx_test::IVFVideoSource(filename); } else if (filename.substr(filename.length() - 4, 4) == "webm") { +#if CONFIG_WEBM_IO video = new libvpx_test::WebMVideoSource(filename); +#else + fprintf(stderr, "WebM IO is disabled, skipping test vector %s\n", + filename.c_str()); + return; +#endif } video->Init(); diff --git a/test/tools_common.sh b/test/tools_common.sh index aa446c9c2..45b777178 100755 --- a/test/tools_common.sh +++ b/test/tools_common.sh @@ -416,6 +416,17 @@ if [ "$(is_windows_target)" = "yes" ]; then VPX_TEST_EXE_SUFFIX=".exe" fi +# Variables shared by tests. +VP8_IVF_FILE="${LIBVPX_TEST_DATA_PATH}/vp80-00-comprehensive-001.ivf" +VP9_IVF_FILE="${LIBVPX_TEST_DATA_PATH}/vp90-2-09-subpixel-00.ivf" + +VP9_WEBM_FILE="${LIBVPX_TEST_DATA_PATH}/vp90-2-00-quantizer-00.webm" + +YUV_RAW_INPUT="${LIBVPX_TEST_DATA_PATH}/hantro_collage_w352h288.yuv" +YUV_RAW_INPUT_WIDTH=352 +YUV_RAW_INPUT_HEIGHT=288 + +# Setup a trap function to clean up after tests complete. trap cleanup EXIT if [ "${VPX_TEST_VERBOSE_OUTPUT}" = "yes" ]; then diff --git a/test/vp8_boolcoder_test.cc b/test/vp8_boolcoder_test.cc index 9cd198787..99b5f0c86 100644 --- a/test/vp8_boolcoder_test.cc +++ b/test/vp8_boolcoder_test.cc @@ -94,14 +94,10 @@ TEST(VP8, TestBitIO) { vp8_stop_encode(&bw); BOOL_DECODER br; -#if CONFIG_DECRYPT - encrypt_buffer(bw_buffer, buffer_size); - vp8dx_start_decode(&br, bw_buffer, buffer_size, + encrypt_buffer(bw_buffer, kBufferSize); + vp8dx_start_decode(&br, bw_buffer, kBufferSize, test_decrypt_cb, reinterpret_cast<void *>(bw_buffer)); -#else - vp8dx_start_decode(&br, bw_buffer, kBufferSize, NULL, NULL); -#endif bit_rnd.Reset(random_seed); for (int i = 0; i < kBitsToTest; ++i) { if (bit_method == 2) { diff --git a/test/vp8_decrypt_test.cc b/test/vp8_decrypt_test.cc index 1b5b08344..470fdf10d 100644 --- a/test/vp8_decrypt_test.cc +++ b/test/vp8_decrypt_test.cc @@ -43,7 +43,7 @@ void test_decrypt_cb(void *decrypt_state, const uint8_t *input, namespace libvpx_test { -TEST(TestDecrypt, DecryptWorks) { +TEST(TestDecrypt, DecryptWorksVp8) { libvpx_test::IVFVideoSource video("vp80-00-comprehensive-001.ivf"); video.Init(); @@ -59,14 +59,12 @@ TEST(TestDecrypt, DecryptWorks) { // decrypt frame video.Next(); -#if CONFIG_DECRYPT std::vector<uint8_t> encrypted(video.frame_size()); encrypt_buffer(video.cxdata(), &encrypted[0], video.frame_size(), 0); - vp8_decrypt_init di = { test_decrypt_cb, &encrypted[0] }; - decoder.Control(VP8D_SET_DECRYPTOR, &di); -#endif // CONFIG_DECRYPT + vpx_decrypt_init di = { test_decrypt_cb, &encrypted[0] }; + decoder.Control(VPXD_SET_DECRYPTOR, &di); - res = decoder.DecodeFrame(video.cxdata(), video.frame_size()); + res = decoder.DecodeFrame(&encrypted[0], encrypted.size()); ASSERT_EQ(VPX_CODEC_OK, res) << decoder.DecodeError(); } diff --git a/test/vp9_boolcoder_test.cc b/test/vp9_boolcoder_test.cc index c579adeac..c7f0cd80f 100644 --- a/test/vp9_boolcoder_test.cc +++ b/test/vp9_boolcoder_test.cc @@ -70,7 +70,7 @@ TEST(VP9, TestBitIO) { GTEST_ASSERT_EQ(bw_buffer[0] & 0x80, 0); vp9_reader br; - vp9_reader_init(&br, bw_buffer, kBufferSize); + vp9_reader_init(&br, bw_buffer, kBufferSize, NULL, NULL); bit_rnd.Reset(random_seed); for (int i = 0; i < kBitsToTest; ++i) { if (bit_method == 2) { diff --git a/test/vp9_decrypt_test.cc b/test/vp9_decrypt_test.cc new file mode 100644 index 000000000..88a3c14f5 --- /dev/null +++ b/test/vp9_decrypt_test.cc @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2013 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 <vector> +#include "third_party/googletest/src/include/gtest/gtest.h" +#include "test/codec_factory.h" +#include "test/ivf_video_source.h" + +namespace { +// In a real use the 'decrypt_state' parameter will be a pointer to a struct +// with whatever internal state the decryptor uses. For testing we'll just +// xor with a constant key, and decrypt_state will point to the start of +// the original buffer. +const uint8_t test_key[16] = { + 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, + 0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xf0 +}; + +void encrypt_buffer(const uint8_t *src, uint8_t *dst, size_t size, + ptrdiff_t offset) { + for (size_t i = 0; i < size; ++i) { + dst[i] = src[i] ^ test_key[(offset + i) & 15]; + } +} + +void test_decrypt_cb(void *decrypt_state, const uint8_t *input, + uint8_t *output, int count) { + encrypt_buffer(input, output, count, + input - reinterpret_cast<uint8_t *>(decrypt_state)); +} + +} // namespace + +namespace libvpx_test { + +TEST(TestDecrypt, DecryptWorksVp9) { + libvpx_test::IVFVideoSource video("vp90-2-05-resize.ivf"); + video.Init(); + + vpx_codec_dec_cfg_t dec_cfg = {0}; + VP9Decoder decoder(dec_cfg, 0); + + video.Begin(); + + // no decryption + vpx_codec_err_t res = decoder.DecodeFrame(video.cxdata(), video.frame_size()); + ASSERT_EQ(VPX_CODEC_OK, res) << decoder.DecodeError(); + + // decrypt frame + video.Next(); + + std::vector<uint8_t> encrypted(video.frame_size()); + encrypt_buffer(video.cxdata(), &encrypted[0], video.frame_size(), 0); + vpx_decrypt_init di = { test_decrypt_cb, &encrypted[0] }; + decoder.Control(VPXD_SET_DECRYPTOR, &di); + + res = decoder.DecodeFrame(&encrypted[0], encrypted.size()); + ASSERT_EQ(VPX_CODEC_OK, res) << decoder.DecodeError(); +} + +} // namespace libvpx_test diff --git a/test/vp9_thread_test.cc b/test/vp9_thread_test.cc index 5523f2024..0c9f71bc5 100644 --- a/test/vp9_thread_test.cc +++ b/test/vp9_thread_test.cc @@ -11,10 +11,13 @@ #include <string> #include "third_party/googletest/src/include/gtest/gtest.h" +#include "./vpx_config.h" #include "test/codec_factory.h" #include "test/decode_test_driver.h" #include "test/md5_helper.h" +#if CONFIG_WEBM_IO #include "test/webm_video_source.h" +#endif #include "vp9/decoder/vp9_thread.h" namespace { @@ -97,6 +100,7 @@ TEST_P(VP9WorkerThreadTest, HookFailure) { // ----------------------------------------------------------------------------- // Multi-threaded decode tests +#if CONFIG_WEBM_IO // Decodes |filename| with |num_threads|. Returns the md5 of the decoded frames. string DecodeFile(const string& filename, int num_threads) { libvpx_test::WebMVideoSource video(filename); @@ -212,6 +216,7 @@ TEST(VP9DecodeMTTest, MTDecode3) { } } } +#endif // CONFIG_WEBM_IO INSTANTIATE_TEST_CASE_P(Synchronous, VP9WorkerThreadTest, ::testing::Bool()); diff --git a/test/vpxdec.sh b/test/vpxdec.sh index d236f973b..093230b69 100755 --- a/test/vpxdec.sh +++ b/test/vpxdec.sh @@ -14,9 +14,6 @@ ## . $(dirname $0)/tools_common.sh -VP8_IVF_FILE="${LIBVPX_TEST_DATA_PATH}/vp80-00-comprehensive-001.ivf" -VP9_WEBM_FILE="${LIBVPX_TEST_DATA_PATH}/vp90-2-00-quantizer-00.webm" - # Environment check: Make sure input is available. vpxdec_verify_environment() { if [ ! -e "${VP8_IVF_FILE}" ] || [ ! -e "${VP9_WEBM_FILE}" ]; then diff --git a/test/vpxenc.sh b/test/vpxenc.sh index 89e4eb39c..f08c04878 100755 --- a/test/vpxenc.sh +++ b/test/vpxenc.sh @@ -15,9 +15,6 @@ ## . $(dirname $0)/tools_common.sh -YUV_RAW_INPUT="${LIBVPX_TEST_DATA_PATH}/hantro_collage_w352h288.yuv" -YUV_RAW_INPUT_WIDTH=352 -YUV_RAW_INPUT_HEIGHT=288 TEST_FRAMES=10 # Environment check: Make sure input is available. |