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

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

Issue 11555023: libvpx: Add VP9 decoder. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 8 years 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2012 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 #include <stdlib.h>
11 #include <new>
12
13 #include "third_party/googletest/src/include/gtest/gtest.h"
14
15 #include "vpx_config.h"
16 extern "C" {
17 #include "vp9/encoder/vp9_variance.h"
18 #include "vpx/vpx_integer.h"
19 #include "vp9_rtcd.h"
20 }
21
22 namespace {
23
24 using ::std::tr1::get;
25 using ::std::tr1::make_tuple;
26 using ::std::tr1::tuple;
27
28 class VP9VarianceTest :
29 public ::testing::TestWithParam<tuple<int, int, vp9_variance_fn_t> > {
30 public:
31 virtual void SetUp() {
32 const tuple<int, int, vp9_variance_fn_t>& params = GetParam();
33 width_ = get<0>(params);
34 height_ = get<1>(params);
35 variance_ = get<2>(params);
36
37 block_size_ = width_ * height_;
38 src_ = new uint8_t[block_size_];
39 ref_ = new uint8_t[block_size_];
40 ASSERT_TRUE(src_ != NULL);
41 ASSERT_TRUE(ref_ != NULL);
42 }
43
44 virtual void TearDown() {
45 delete[] src_;
46 delete[] ref_;
47 }
48
49 protected:
50 uint8_t* src_;
51 uint8_t* ref_;
52 int width_;
53 int height_;
54 int block_size_;
55 vp9_variance_fn_t variance_;
56 };
57
58 TEST_P(VP9VarianceTest, Zero) {
59 for (int i = 0; i <= 255; ++i) {
60 memset(src_, i, block_size_);
61 for (int j = 0; j <= 255; ++j) {
62 memset(ref_, j, block_size_);
63 unsigned int sse;
64 const unsigned int var = variance_(src_, width_, ref_, width_, &sse);
65 EXPECT_EQ(0u, var) << "src values: " << i << "ref values: " << j;
66 }
67 }
68 }
69
70 TEST_P(VP9VarianceTest, OneQuarter) {
71 memset(src_, 255, block_size_);
72 const int half = block_size_ / 2;
73 memset(ref_, 255, half);
74 memset(ref_ + half, 0, half);
75 unsigned int sse;
76 const unsigned int var = variance_(src_, width_, ref_, width_, &sse);
77 const unsigned int expected = block_size_ * 255 * 255 / 4;
78 EXPECT_EQ(expected, var);
79 }
80
81 const vp9_variance_fn_t variance4x4_c = vp9_variance4x4_c;
82 const vp9_variance_fn_t variance8x8_c = vp9_variance8x8_c;
83 const vp9_variance_fn_t variance8x16_c = vp9_variance8x16_c;
84 const vp9_variance_fn_t variance16x8_c = vp9_variance16x8_c;
85 const vp9_variance_fn_t variance16x16_c = vp9_variance16x16_c;
86 INSTANTIATE_TEST_CASE_P(
87 C, VP9VarianceTest,
88 ::testing::Values(make_tuple(4, 4, variance4x4_c),
89 make_tuple(8, 8, variance8x8_c),
90 make_tuple(8, 16, variance8x16_c),
91 make_tuple(16, 8, variance16x8_c),
92 make_tuple(16, 16, variance16x16_c)));
93
94 #if HAVE_MMX
95 const vp9_variance_fn_t variance4x4_mmx = vp9_variance4x4_mmx;
96 const vp9_variance_fn_t variance8x8_mmx = vp9_variance8x8_mmx;
97 const vp9_variance_fn_t variance8x16_mmx = vp9_variance8x16_mmx;
98 const vp9_variance_fn_t variance16x8_mmx = vp9_variance16x8_mmx;
99 const vp9_variance_fn_t variance16x16_mmx = vp9_variance16x16_mmx;
100 INSTANTIATE_TEST_CASE_P(
101 MMX, VP9VarianceTest,
102 ::testing::Values(make_tuple(4, 4, variance4x4_mmx),
103 make_tuple(8, 8, variance8x8_mmx),
104 make_tuple(8, 16, variance8x16_mmx),
105 make_tuple(16, 8, variance16x8_mmx),
106 make_tuple(16, 16, variance16x16_mmx)));
107 #endif
108
109 #if HAVE_SSE2
110 const vp9_variance_fn_t variance4x4_wmt = vp9_variance4x4_wmt;
111 const vp9_variance_fn_t variance8x8_wmt = vp9_variance8x8_wmt;
112 const vp9_variance_fn_t variance8x16_wmt = vp9_variance8x16_wmt;
113 const vp9_variance_fn_t variance16x8_wmt = vp9_variance16x8_wmt;
114 const vp9_variance_fn_t variance16x16_wmt = vp9_variance16x16_wmt;
115 INSTANTIATE_TEST_CASE_P(
116 SSE2, VP9VarianceTest,
117 ::testing::Values(make_tuple(4, 4, variance4x4_wmt),
118 make_tuple(8, 8, variance8x8_wmt),
119 make_tuple(8, 16, variance8x16_wmt),
120 make_tuple(16, 8, variance16x8_wmt),
121 make_tuple(16, 16, variance16x16_wmt)));
122 #endif
123 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698