Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(465)

Side by Side Diff: source/libvpx/test/vp9_thread_test.cc

Issue 23600008: libvpx: Pull from upstream (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/test/vp9_subtract_test.cc ('k') | source/libvpx/vp8/encoder/picklpf.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
3 *
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.
9 */
10
11 #include "vp9/decoder/vp9_thread.h"
12
13 #include "third_party/googletest/src/include/gtest/gtest.h"
14 #include "test/codec_factory.h"
15 #include "test/decode_test_driver.h"
16 #include "test/md5_helper.h"
17 #include "test/webm_video_source.h"
18
19 namespace {
20
21 class VP9WorkerThreadTest : public ::testing::Test {
22 protected:
23 virtual ~VP9WorkerThreadTest() {}
24 virtual void SetUp() {
25 vp9_worker_init(&worker_);
26 }
27
28 virtual void TearDown() {
29 vp9_worker_end(&worker_);
30 }
31
32 VP9Worker worker_;
33 };
34
35 int ThreadHook(void* data, void* return_value) {
36 int* const hook_data = reinterpret_cast<int*>(data);
37 *hook_data = 5;
38 return *reinterpret_cast<int*>(return_value);
39 }
40
41 TEST_F(VP9WorkerThreadTest, HookSuccess) {
42 EXPECT_TRUE(vp9_worker_sync(&worker_)); // should be a no-op.
43
44 for (int i = 0; i < 2; ++i) {
45 EXPECT_TRUE(vp9_worker_reset(&worker_));
46
47 int hook_data = 0;
48 int return_value = 1; // return successfully from the hook
49 worker_.hook = ThreadHook;
50 worker_.data1 = &hook_data;
51 worker_.data2 = &return_value;
52
53 vp9_worker_launch(&worker_);
54 EXPECT_TRUE(vp9_worker_sync(&worker_));
55 EXPECT_FALSE(worker_.had_error);
56 EXPECT_EQ(5, hook_data);
57
58 EXPECT_TRUE(vp9_worker_sync(&worker_)); // should be a no-op.
59 }
60 }
61
62 TEST_F(VP9WorkerThreadTest, HookFailure) {
63 EXPECT_TRUE(vp9_worker_reset(&worker_));
64
65 int hook_data = 0;
66 int return_value = 0; // return failure from the hook
67 worker_.hook = ThreadHook;
68 worker_.data1 = &hook_data;
69 worker_.data2 = &return_value;
70
71 vp9_worker_launch(&worker_);
72 EXPECT_FALSE(vp9_worker_sync(&worker_));
73 EXPECT_TRUE(worker_.had_error);
74
75 // Ensure _reset() clears the error and _launch() can be called again.
76 return_value = 1;
77 EXPECT_TRUE(vp9_worker_reset(&worker_));
78 EXPECT_FALSE(worker_.had_error);
79 vp9_worker_launch(&worker_);
80 EXPECT_TRUE(vp9_worker_sync(&worker_));
81 EXPECT_FALSE(worker_.had_error);
82 }
83
84 TEST(VP9DecodeMTTest, MTDecode) {
85 libvpx_test::WebMVideoSource video("vp90-2-03-size-226x226.webm");
86 video.Init();
87
88 vpx_codec_dec_cfg_t cfg = {0};
89 cfg.threads = 2;
90 libvpx_test::VP9Decoder decoder(cfg, 0);
91
92 libvpx_test::MD5 md5;
93 for (video.Begin(); video.cxdata(); video.Next()) {
94 const vpx_codec_err_t res =
95 decoder.DecodeFrame(video.cxdata(), video.frame_size());
96 ASSERT_EQ(VPX_CODEC_OK, res) << decoder.DecodeError();
97
98 libvpx_test::DxDataIterator dec_iter = decoder.GetDxData();
99 const vpx_image_t *img = NULL;
100
101 // Get decompressed data
102 while ((img = dec_iter.Next())) {
103 md5.Add(img);
104 }
105 }
106 EXPECT_STREQ("b35a1b707b28e82be025d960aba039bc", md5.Get());
107 }
108
109 } // namespace
OLDNEW
« no previous file with comments | « source/libvpx/test/vp9_subtract_test.cc ('k') | source/libvpx/vp8/encoder/picklpf.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698