2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
14 #include "third_party/googletest/src/include/gtest/gtest.h"
15 #include "./vpx_config.h"
16 #include "test/codec_factory.h"
17 #include "test/decode_test_driver.h"
18 #include "test/ivf_video_source.h"
19 #include "test/md5_helper.h"
20 #include "test/util.h"
22 #include "test/webm_video_source.h"
24 #include "vpx_mem/vpx_mem.h"
31 // Decodes |filename|. Passes in user_priv data when calling DecodeFrame and
32 // compares the user_priv from return img with the original user_priv to see if
33 // they match. Both the pointer values and the values inside the addresses
35 string DecodeFile(const string &filename) {
36 libvpx_test::WebMVideoSource video(filename);
39 vpx_codec_dec_cfg_t cfg = {0};
40 libvpx_test::VP9Decoder decoder(cfg, 0);
44 for (video.Begin(); video.cxdata(); video.Next()) {
45 void *user_priv = reinterpret_cast<void *>(&frame_num);
46 const vpx_codec_err_t res =
47 decoder.DecodeFrame(video.cxdata(), video.frame_size(),
48 (frame_num == 0) ? NULL : user_priv);
49 if (res != VPX_CODEC_OK) {
50 EXPECT_EQ(VPX_CODEC_OK, res) << decoder.DecodeError();
53 libvpx_test::DxDataIterator dec_iter = decoder.GetDxData();
54 const vpx_image_t *img = NULL;
56 // Get decompressed data.
57 while ((img = dec_iter.Next())) {
59 // user_priv pointer value should be the same.
60 EXPECT_EQ(img->user_priv, reinterpret_cast<void *>(NULL)) <<
61 "user_priv pointer value does not match.";
63 // user_priv pointer value should be the same.
64 EXPECT_EQ(img->user_priv, reinterpret_cast<void *>(&frame_num)) <<
65 "user_priv pointer value does not match.";
66 // value in user_priv pointer should also be the same.
67 EXPECT_EQ(*reinterpret_cast<int *>(img->user_priv), frame_num) <<
68 "Value in user_priv does not match.";
75 return string(md5.Get());
78 TEST(UserPrivTest, VideoDecode) {
79 // no tiles or frame parallel; this exercises the decoding to test the
81 EXPECT_STREQ("b35a1b707b28e82be025d960aba039bc",
82 DecodeFile("vp90-2-03-size-226x226.webm").c_str());
85 #endif // CONFIG_WEBM_IO