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

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

Issue 13042014: Description: (Closed) Base URL: https://src.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: libvpx: Pull from upstream Created 7 years, 9 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
« no previous file with comments | « source/libvpx/test/test.mk ('k') | source/libvpx/third_party/x86inc/x86inc.asm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #include <stdlib.h> 10 #include <stdlib.h>
11 #include <new> 11 #include <new>
12 12
13 #include "third_party/googletest/src/include/gtest/gtest.h" 13 #include "third_party/googletest/src/include/gtest/gtest.h"
14 14
15 #include "vpx/vpx_integer.h"
15 #include "vpx_config.h" 16 #include "vpx_config.h"
16 extern "C" { 17 extern "C" {
17 #include "vp9/encoder/vp9_variance.h" 18 #if CONFIG_VP8_ENCODER
18 #include "vpx/vpx_integer.h" 19 # include "vp8/common/variance.h"
19 #include "vp9_rtcd.h" 20 # include "vp8_rtcd.h"
21 #endif
22 #if CONFIG_VP9_ENCODER
23 # include "vp9/encoder/vp9_variance.h"
24 # include "vp9_rtcd.h"
25 #endif
20 } 26 }
21 27
22 namespace { 28 namespace {
23 29
24 using ::std::tr1::get; 30 using ::std::tr1::get;
25 using ::std::tr1::make_tuple; 31 using ::std::tr1::make_tuple;
26 using ::std::tr1::tuple; 32 using ::std::tr1::tuple;
27 33
28 class VP9VarianceTest : 34 template<typename VarianceFunctionType>
29 public ::testing::TestWithParam<tuple<int, int, vp9_variance_fn_t> > { 35 class VarianceTest :
36 public ::testing::TestWithParam<tuple<int, int, VarianceFunctionType> > {
30 public: 37 public:
31 virtual void SetUp() { 38 virtual void SetUp() {
32 const tuple<int, int, vp9_variance_fn_t>& params = GetParam(); 39 const tuple<int, int, VarianceFunctionType>& params = this->GetParam();
33 width_ = get<0>(params); 40 width_ = get<0>(params);
34 height_ = get<1>(params); 41 height_ = get<1>(params);
35 variance_ = get<2>(params); 42 variance_ = get<2>(params);
36 43
37 block_size_ = width_ * height_; 44 block_size_ = width_ * height_;
38 src_ = new uint8_t[block_size_]; 45 src_ = new uint8_t[block_size_];
39 ref_ = new uint8_t[block_size_]; 46 ref_ = new uint8_t[block_size_];
40 ASSERT_TRUE(src_ != NULL); 47 ASSERT_TRUE(src_ != NULL);
41 ASSERT_TRUE(ref_ != NULL); 48 ASSERT_TRUE(ref_ != NULL);
42 } 49 }
43 50
44 virtual void TearDown() { 51 virtual void TearDown() {
45 delete[] src_; 52 delete[] src_;
46 delete[] ref_; 53 delete[] ref_;
47 } 54 }
48 55
49 protected: 56 protected:
57 void ZeroTest();
58 void OneQuarterTest();
59
50 uint8_t* src_; 60 uint8_t* src_;
51 uint8_t* ref_; 61 uint8_t* ref_;
52 int width_; 62 int width_;
53 int height_; 63 int height_;
54 int block_size_; 64 int block_size_;
55 vp9_variance_fn_t variance_; 65 VarianceFunctionType variance_;
66
56 }; 67 };
57 68
58 TEST_P(VP9VarianceTest, Zero) { 69 template<typename VarianceFunctionType>
70 void VarianceTest<VarianceFunctionType>::ZeroTest() {
59 for (int i = 0; i <= 255; ++i) { 71 for (int i = 0; i <= 255; ++i) {
60 memset(src_, i, block_size_); 72 memset(src_, i, block_size_);
61 for (int j = 0; j <= 255; ++j) { 73 for (int j = 0; j <= 255; ++j) {
62 memset(ref_, j, block_size_); 74 memset(ref_, j, block_size_);
63 unsigned int sse; 75 unsigned int sse;
64 const unsigned int var = variance_(src_, width_, ref_, width_, &sse); 76 const unsigned int var = variance_(src_, width_, ref_, width_, &sse);
65 EXPECT_EQ(0u, var) << "src values: " << i << "ref values: " << j; 77 EXPECT_EQ(0u, var) << "src values: " << i << "ref values: " << j;
66 } 78 }
67 } 79 }
68 } 80 }
69 81
70 TEST_P(VP9VarianceTest, OneQuarter) { 82 template<typename VarianceFunctionType>
83 void VarianceTest<VarianceFunctionType>::OneQuarterTest() {
71 memset(src_, 255, block_size_); 84 memset(src_, 255, block_size_);
72 const int half = block_size_ / 2; 85 const int half = block_size_ / 2;
73 memset(ref_, 255, half); 86 memset(ref_, 255, half);
74 memset(ref_ + half, 0, half); 87 memset(ref_ + half, 0, half);
75 unsigned int sse; 88 unsigned int sse;
76 const unsigned int var = variance_(src_, width_, ref_, width_, &sse); 89 const unsigned int var = variance_(src_, width_, ref_, width_, &sse);
77 const unsigned int expected = block_size_ * 255 * 255 / 4; 90 const unsigned int expected = block_size_ * 255 * 255 / 4;
78 EXPECT_EQ(expected, var); 91 EXPECT_EQ(expected, var);
79 } 92 }
80 93
94 // -----------------------------------------------------------------------------
95 // VP8 test cases.
96
97 namespace vp8 {
98
99 #if CONFIG_VP8_ENCODER
100 typedef VarianceTest<vp8_variance_fn_t> VP8VarianceTest;
101
102 TEST_P(VP8VarianceTest, Zero) { ZeroTest(); }
103 TEST_P(VP8VarianceTest, OneQuarter) { OneQuarterTest(); }
104
105 const vp8_variance_fn_t variance4x4_c = vp8_variance4x4_c;
106 const vp8_variance_fn_t variance8x8_c = vp8_variance8x8_c;
107 const vp8_variance_fn_t variance8x16_c = vp8_variance8x16_c;
108 const vp8_variance_fn_t variance16x8_c = vp8_variance16x8_c;
109 const vp8_variance_fn_t variance16x16_c = vp8_variance16x16_c;
110 INSTANTIATE_TEST_CASE_P(
111 C, VP8VarianceTest,
112 ::testing::Values(make_tuple(4, 4, variance4x4_c),
113 make_tuple(8, 8, variance8x8_c),
114 make_tuple(8, 16, variance8x16_c),
115 make_tuple(16, 8, variance16x8_c),
116 make_tuple(16, 16, variance16x16_c)));
117
118 #if HAVE_MMX
119 const vp8_variance_fn_t variance4x4_mmx = vp8_variance4x4_mmx;
120 const vp8_variance_fn_t variance8x8_mmx = vp8_variance8x8_mmx;
121 const vp8_variance_fn_t variance8x16_mmx = vp8_variance8x16_mmx;
122 const vp8_variance_fn_t variance16x8_mmx = vp8_variance16x8_mmx;
123 const vp8_variance_fn_t variance16x16_mmx = vp8_variance16x16_mmx;
124 INSTANTIATE_TEST_CASE_P(
125 MMX, VP8VarianceTest,
126 ::testing::Values(make_tuple(4, 4, variance4x4_mmx),
127 make_tuple(8, 8, variance8x8_mmx),
128 make_tuple(8, 16, variance8x16_mmx),
129 make_tuple(16, 8, variance16x8_mmx),
130 make_tuple(16, 16, variance16x16_mmx)));
131 #endif
132
133 #if HAVE_SSE2
134 const vp8_variance_fn_t variance4x4_wmt = vp8_variance4x4_wmt;
135 const vp8_variance_fn_t variance8x8_wmt = vp8_variance8x8_wmt;
136 const vp8_variance_fn_t variance8x16_wmt = vp8_variance8x16_wmt;
137 const vp8_variance_fn_t variance16x8_wmt = vp8_variance16x8_wmt;
138 const vp8_variance_fn_t variance16x16_wmt = vp8_variance16x16_wmt;
139 INSTANTIATE_TEST_CASE_P(
140 SSE2, VP8VarianceTest,
141 ::testing::Values(make_tuple(4, 4, variance4x4_wmt),
142 make_tuple(8, 8, variance8x8_wmt),
143 make_tuple(8, 16, variance8x16_wmt),
144 make_tuple(16, 8, variance16x8_wmt),
145 make_tuple(16, 16, variance16x16_wmt)));
146 #endif
147 #endif // CONFIG_VP8_ENCODER
148
149 } // namespace vp8
150
151 // -----------------------------------------------------------------------------
152 // VP9 test cases.
153
154 namespace vp9 {
155
156 #if CONFIG_VP9_ENCODER
157 typedef VarianceTest<vp9_variance_fn_t> VP9VarianceTest;
158
159 TEST_P(VP9VarianceTest, Zero) { ZeroTest(); }
160 TEST_P(VP9VarianceTest, OneQuarter) { OneQuarterTest(); }
161
81 const vp9_variance_fn_t variance4x4_c = vp9_variance4x4_c; 162 const vp9_variance_fn_t variance4x4_c = vp9_variance4x4_c;
82 const vp9_variance_fn_t variance8x8_c = vp9_variance8x8_c; 163 const vp9_variance_fn_t variance8x8_c = vp9_variance8x8_c;
83 const vp9_variance_fn_t variance8x16_c = vp9_variance8x16_c; 164 const vp9_variance_fn_t variance8x16_c = vp9_variance8x16_c;
84 const vp9_variance_fn_t variance16x8_c = vp9_variance16x8_c; 165 const vp9_variance_fn_t variance16x8_c = vp9_variance16x8_c;
85 const vp9_variance_fn_t variance16x16_c = vp9_variance16x16_c; 166 const vp9_variance_fn_t variance16x16_c = vp9_variance16x16_c;
86 INSTANTIATE_TEST_CASE_P( 167 INSTANTIATE_TEST_CASE_P(
87 C, VP9VarianceTest, 168 C, VP9VarianceTest,
88 ::testing::Values(make_tuple(4, 4, variance4x4_c), 169 ::testing::Values(make_tuple(4, 4, variance4x4_c),
89 make_tuple(8, 8, variance8x8_c), 170 make_tuple(8, 8, variance8x8_c),
90 make_tuple(8, 16, variance8x16_c), 171 make_tuple(8, 16, variance8x16_c),
(...skipping 22 matching lines...) Expand all
113 const vp9_variance_fn_t variance16x8_wmt = vp9_variance16x8_wmt; 194 const vp9_variance_fn_t variance16x8_wmt = vp9_variance16x8_wmt;
114 const vp9_variance_fn_t variance16x16_wmt = vp9_variance16x16_wmt; 195 const vp9_variance_fn_t variance16x16_wmt = vp9_variance16x16_wmt;
115 INSTANTIATE_TEST_CASE_P( 196 INSTANTIATE_TEST_CASE_P(
116 SSE2, VP9VarianceTest, 197 SSE2, VP9VarianceTest,
117 ::testing::Values(make_tuple(4, 4, variance4x4_wmt), 198 ::testing::Values(make_tuple(4, 4, variance4x4_wmt),
118 make_tuple(8, 8, variance8x8_wmt), 199 make_tuple(8, 8, variance8x8_wmt),
119 make_tuple(8, 16, variance8x16_wmt), 200 make_tuple(8, 16, variance8x16_wmt),
120 make_tuple(16, 8, variance16x8_wmt), 201 make_tuple(16, 8, variance16x8_wmt),
121 make_tuple(16, 16, variance16x16_wmt))); 202 make_tuple(16, 16, variance16x16_wmt)));
122 #endif 203 #endif
204 #endif // CONFIG_VP9_ENCODER
205
206 } // namespace vp9
207
123 } // namespace 208 } // namespace
OLDNEW
« no previous file with comments | « source/libvpx/test/test.mk ('k') | source/libvpx/third_party/x86inc/x86inc.asm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698