summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJoey Parrish <joeyparrish@google.com>2014-04-15 14:10:58 -0700
committerJoey Parrish <joeyparrish@google.com>2014-04-23 16:11:54 -0700
commit18c08607e0a216962fd3df4f7926ce288ee81b9b (patch)
tree471f1eafca2091dc47a18288b6999165d5ac2a7b /test
parentdddc3c6906f0d840935214ab0b26ea9a6e06cc27 (diff)
downloadlibvpx-18c08607e0a216962fd3df4f7926ce288ee81b9b.tar
libvpx-18c08607e0a216962fd3df4f7926ce288ee81b9b.tar.gz
libvpx-18c08607e0a216962fd3df4f7926ce288ee81b9b.tar.bz2
libvpx-18c08607e0a216962fd3df4f7926ce288ee81b9b.zip
Add VPXD_SET_DECRYPTOR support to the VP9 decoder.
Change-Id: I88f86c8ff9af34e0b6531028b691921b54c2fc48
Diffstat (limited to 'test')
-rw-r--r--test/test.mk1
-rw-r--r--test/vp8_boolcoder_test.cc8
-rw-r--r--test/vp8_decrypt_test.cc10
-rw-r--r--test/vp9_boolcoder_test.cc2
-rw-r--r--test/vp9_decrypt_test.cc71
5 files changed, 79 insertions, 13 deletions
diff --git a/test/test.mk b/test/test.mk
index f1a8ed9a0..bceedee66 100644
--- a/test/test.mk
+++ b/test/test.mk
@@ -106,6 +106,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/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