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.
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"
24 #include "test/webm_video_source.h"
26 #include "aom_mem/aom_mem.h"
32 using libaom_test::ACMRandom
;
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
46 string
DecodeFile(const string
&filename
) {
47 ACMRandom
rnd(ACMRandom::DeterministicSeed());
48 libaom_test::WebMVideoSource
video(filename
);
51 aom_codec_dec_cfg_t cfg
= aom_codec_dec_cfg_t();
52 cfg
.allow_lowbitdepth
= 1;
53 libaom_test::AV1Decoder
decoder(cfg
, 0);
57 for (video
.Begin(); !::testing::Test::HasFailure() && video
.cxdata();
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();
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())) {
73 CheckUserPrivateData(img
->user_priv
, NULL
);
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
);
90 return string(md5
.Get());
93 TEST(UserPrivTest
, VideoDecode
) {
94 // no tiles or frame parallel; this exercises the decoding to test the
96 EXPECT_STREQ("b35a1b707b28e82be025d960aba039bc",
97 DecodeFile("av10-2-03-size-226x226.webm").c_str());
100 #endif // CONFIG_WEBM_IO