av1_convolve_ x,y _avx2() -- use 256 bit load/store
[aom.git] / test / user_priv_test.cc
blobda289c9901df269319cc66f82aefd11f1983d7d3
1 /*
2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
12 #include <cstdio>
13 #include <cstdlib>
14 #include <string>
15 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
16 #include "./aom_config.h"
17 #include "test/acm_random.h"
18 #include "test/codec_factory.h"
19 #include "test/decode_test_driver.h"
20 #include "test/ivf_video_source.h"
21 #include "test/md5_helper.h"
22 #include "test/util.h"
23 #if CONFIG_WEBM_IO
24 #include "test/webm_video_source.h"
25 #endif
26 #include "aom_mem/aom_mem.h"
27 #include "aom/aom.h"
29 namespace {
31 using std::string;
32 using libaom_test::ACMRandom;
34 #if CONFIG_WEBM_IO
36 void CheckUserPrivateData(void *user_priv, int *target) {
37 // actual pointer value should be the same as expected.
38 EXPECT_EQ(reinterpret_cast<void *>(target), user_priv)
39 << "user_priv pointer value does not match.";
42 // Decodes |filename|. Passes in user_priv data when calling DecodeFrame and
43 // compares the user_priv from return img with the original user_priv to see if
44 // they match. Both the pointer values and the values inside the addresses
45 // should match.
46 string DecodeFile(const string &filename) {
47 ACMRandom rnd(ACMRandom::DeterministicSeed());
48 libaom_test::WebMVideoSource video(filename);
49 video.Init();
51 aom_codec_dec_cfg_t cfg = aom_codec_dec_cfg_t();
52 cfg.allow_lowbitdepth = 1;
53 libaom_test::AV1Decoder decoder(cfg, 0);
55 libaom_test::MD5 md5;
56 int frame_num = 0;
57 for (video.Begin(); !::testing::Test::HasFailure() && video.cxdata();
58 video.Next()) {
59 void *user_priv = reinterpret_cast<void *>(&frame_num);
60 const aom_codec_err_t res =
61 decoder.DecodeFrame(video.cxdata(), video.frame_size(),
62 (frame_num == 0) ? NULL : user_priv);
63 if (res != AOM_CODEC_OK) {
64 EXPECT_EQ(AOM_CODEC_OK, res) << decoder.DecodeError();
65 break;
67 libaom_test::DxDataIterator dec_iter = decoder.GetDxData();
68 const aom_image_t *img = NULL;
70 // Get decompressed data.
71 while ((img = dec_iter.Next())) {
72 if (frame_num == 0) {
73 CheckUserPrivateData(img->user_priv, NULL);
74 } else {
75 CheckUserPrivateData(img->user_priv, &frame_num);
77 // Also test ctrl_get_reference api.
78 struct av1_ref_frame ref;
79 // Randomly fetch a reference frame.
80 ref.idx = rnd.Rand8() % 3;
81 decoder.Control(AV1_GET_REFERENCE, &ref);
83 CheckUserPrivateData(ref.img.user_priv, NULL);
85 md5.Add(img);
88 frame_num++;
90 return string(md5.Get());
93 TEST(UserPrivTest, VideoDecode) {
94 // no tiles or frame parallel; this exercises the decoding to test the
95 // user_priv.
96 EXPECT_STREQ("b35a1b707b28e82be025d960aba039bc",
97 DecodeFile("av10-2-03-size-226x226.webm").c_str());
100 #endif // CONFIG_WEBM_IO
102 } // namespace