blob: bf3e0b81908a39f9e82aa0b847ede94b1913363b [file] [log] [blame]
Johannfbea8972012-06-28 11:43:58 -07001/*
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
11
12#include <string.h>
13#include <limits.h>
14#include <stdio.h>
15
16extern "C" {
17#include "./vpx_config.h"
John Koleszar6b653cb2013-02-28 17:03:02 -080018#if CONFIG_VP8_ENCODER
John Koleszara9c75972012-11-08 17:09:30 -080019#include "./vp8_rtcd.h"
John Koleszar6b653cb2013-02-28 17:03:02 -080020//#include "vp8/common/blockd.h"
21#endif
22#if CONFIG_VP9_ENCODER
23#include "./vp9_rtcd.h"
24#endif
James Zern10f8b362012-08-27 17:13:09 -070025#include "vpx_mem/vpx_mem.h"
Johannfbea8972012-06-28 11:43:58 -070026}
27
28#include "test/acm_random.h"
James Zern5b756742013-06-17 22:58:40 -070029#include "test/clear_system_state.h"
James Zerneebb6482012-11-27 13:08:05 -080030#include "test/register_state_check.h"
Johannfbea8972012-06-28 11:43:58 -070031#include "test/util.h"
32#include "third_party/googletest/src/include/gtest/gtest.h"
33
34
35typedef unsigned int (*sad_m_by_n_fn_t)(const unsigned char *source_ptr,
36 int source_stride,
37 const unsigned char *reference_ptr,
38 int reference_stride,
Johann11610552012-06-26 11:37:33 -070039 unsigned int max_sad);
James Zern5e3439b2013-05-29 17:47:18 -070040typedef std::tr1::tuple<int, int, sad_m_by_n_fn_t> sad_m_by_n_test_param_t;
Johannfbea8972012-06-28 11:43:58 -070041
John Koleszar1cfc86e2013-03-01 12:43:41 -080042typedef void (*sad_n_by_n_by_4_fn_t)(const uint8_t *src_ptr,
43 int src_stride,
44 const unsigned char * const ref_ptr[],
45 int ref_stride,
46 unsigned int *sad_array);
James Zern5e3439b2013-05-29 17:47:18 -070047typedef std::tr1::tuple<int, int, sad_n_by_n_by_4_fn_t>
48 sad_n_by_n_by_4_test_param_t;
John Koleszar1cfc86e2013-03-01 12:43:41 -080049
Johannfbea8972012-06-28 11:43:58 -070050using libvpx_test::ACMRandom;
51
52namespace {
John Koleszar1cfc86e2013-03-01 12:43:41 -080053class SADTestBase : public ::testing::Test {
James Zern10f8b362012-08-27 17:13:09 -070054 public:
John Koleszar1cfc86e2013-03-01 12:43:41 -080055 SADTestBase(int width, int height) : width_(width), height_(height) {}
56
James Zern10f8b362012-08-27 17:13:09 -070057 static void SetUpTestCase() {
58 source_data_ = reinterpret_cast<uint8_t*>(
John Koleszar1cfc86e2013-03-01 12:43:41 -080059 vpx_memalign(kDataAlignment, kDataBlockSize));
James Zern10f8b362012-08-27 17:13:09 -070060 reference_data_ = reinterpret_cast<uint8_t*>(
61 vpx_memalign(kDataAlignment, kDataBufferSize));
62 }
63
64 static void TearDownTestCase() {
65 vpx_free(source_data_);
66 source_data_ = NULL;
67 vpx_free(reference_data_);
68 reference_data_ = NULL;
69 }
70
James Zern5b756742013-06-17 22:58:40 -070071 virtual void TearDown() {
72 libvpx_test::ClearSystemState();
73 }
74
James Zern10f8b362012-08-27 17:13:09 -070075 protected:
John Koleszar6b653cb2013-02-28 17:03:02 -080076 // Handle blocks up to 4 blocks 64x64 with stride up to 128
James Zern10f8b362012-08-27 17:13:09 -070077 static const int kDataAlignment = 16;
John Koleszar1cfc86e2013-03-01 12:43:41 -080078 static const int kDataBlockSize = 64 * 128;
79 static const int kDataBufferSize = 4 * kDataBlockSize;
James Zern10f8b362012-08-27 17:13:09 -070080
Johannfbea8972012-06-28 11:43:58 -070081 virtual void SetUp() {
John Koleszar6b653cb2013-02-28 17:03:02 -080082 source_stride_ = (width_ + 31) & ~31;
Johannfbea8972012-06-28 11:43:58 -070083 reference_stride_ = width_ * 2;
84 rnd_.Reset(ACMRandom::DeterministicSeed());
85 }
86
John Koleszar1cfc86e2013-03-01 12:43:41 -080087 virtual uint8_t* GetReference(int block_idx) {
88 return reference_data_ + block_idx * kDataBlockSize;
Johannfbea8972012-06-28 11:43:58 -070089 }
90
91 // Sum of Absolute Differences. Given two blocks, calculate the absolute
92 // difference between two pixels in the same relative location; accumulate.
John Koleszar1cfc86e2013-03-01 12:43:41 -080093 unsigned int ReferenceSAD(unsigned int max_sad, int block_idx = 0) {
Johannfbea8972012-06-28 11:43:58 -070094 unsigned int sad = 0;
John Koleszar1cfc86e2013-03-01 12:43:41 -080095 const uint8_t* const reference = GetReference(block_idx);
Johannfbea8972012-06-28 11:43:58 -070096
97 for (int h = 0; h < height_; ++h) {
98 for (int w = 0; w < width_; ++w) {
99 sad += abs(source_data_[h * source_stride_ + w]
John Koleszar1cfc86e2013-03-01 12:43:41 -0800100 - reference[h * reference_stride_ + w]);
Johannfbea8972012-06-28 11:43:58 -0700101 }
102 if (sad > max_sad) {
103 break;
104 }
105 }
106 return sad;
107 }
108
109 void FillConstant(uint8_t *data, int stride, uint8_t fill_constant) {
110 for (int h = 0; h < height_; ++h) {
111 for (int w = 0; w < width_; ++w) {
112 data[h * stride + w] = fill_constant;
113 }
114 }
115 }
116
117 void FillRandom(uint8_t *data, int stride) {
118 for (int h = 0; h < height_; ++h) {
119 for (int w = 0; w < width_; ++w) {
120 data[h * stride + w] = rnd_.Rand8();
121 }
122 }
123 }
124
John Koleszar1cfc86e2013-03-01 12:43:41 -0800125 int width_, height_;
126 static uint8_t* source_data_;
127 int source_stride_;
128 static uint8_t* reference_data_;
129 int reference_stride_;
130
131 ACMRandom rnd_;
132};
133
134class SADTest : public SADTestBase,
James Zern5e3439b2013-05-29 17:47:18 -0700135 public ::testing::WithParamInterface<sad_m_by_n_test_param_t> {
John Koleszar1cfc86e2013-03-01 12:43:41 -0800136 public:
137 SADTest() : SADTestBase(GET_PARAM(0), GET_PARAM(1)) {}
138
139 protected:
140 unsigned int SAD(unsigned int max_sad, int block_idx = 0) {
141 unsigned int ret;
142 const uint8_t* const reference = GetReference(block_idx);
143
144 REGISTER_STATE_CHECK(ret = GET_PARAM(2)(source_data_, source_stride_,
145 reference, reference_stride_,
146 max_sad));
147 return ret;
148 }
149
Johannfbea8972012-06-28 11:43:58 -0700150 void CheckSad(unsigned int max_sad) {
151 unsigned int reference_sad, exp_sad;
152
153 reference_sad = ReferenceSAD(max_sad);
154 exp_sad = SAD(max_sad);
155
156 if (reference_sad <= max_sad) {
157 ASSERT_EQ(exp_sad, reference_sad);
158 } else {
159 // Alternative implementations are not required to check max_sad
160 ASSERT_GE(exp_sad, reference_sad);
161 }
162 }
Johannfbea8972012-06-28 11:43:58 -0700163};
164
John Koleszar1cfc86e2013-03-01 12:43:41 -0800165class SADx4Test : public SADTestBase,
James Zern5e3439b2013-05-29 17:47:18 -0700166 public ::testing::WithParamInterface<sad_n_by_n_by_4_test_param_t> {
John Koleszar1cfc86e2013-03-01 12:43:41 -0800167 public:
168 SADx4Test() : SADTestBase(GET_PARAM(0), GET_PARAM(1)) {}
169
170 protected:
171 void SADs(unsigned int *results) {
172 const uint8_t* refs[] = {GetReference(0), GetReference(1),
173 GetReference(2), GetReference(3)};
174
175 REGISTER_STATE_CHECK(GET_PARAM(2)(source_data_, source_stride_,
176 refs, reference_stride_,
177 results));
178 }
179
180 void CheckSADs() {
181 unsigned int reference_sad, exp_sad[4];
182
183 SADs(exp_sad);
184 for (int block = 0; block < 4; block++) {
185 reference_sad = ReferenceSAD(UINT_MAX, block);
186
187 EXPECT_EQ(exp_sad[block], reference_sad) << "block " << block;
188 }
189 }
190};
191
192uint8_t* SADTestBase::source_data_ = NULL;
193uint8_t* SADTestBase::reference_data_ = NULL;
James Zern10f8b362012-08-27 17:13:09 -0700194
Johannfbea8972012-06-28 11:43:58 -0700195TEST_P(SADTest, MaxRef) {
196 FillConstant(source_data_, source_stride_, 0);
197 FillConstant(reference_data_, reference_stride_, 255);
Johann11610552012-06-26 11:37:33 -0700198 CheckSad(UINT_MAX);
Johannfbea8972012-06-28 11:43:58 -0700199}
200
John Koleszar1cfc86e2013-03-01 12:43:41 -0800201TEST_P(SADx4Test, MaxRef) {
202 FillConstant(source_data_, source_stride_, 0);
203 FillConstant(GetReference(0), reference_stride_, 255);
204 FillConstant(GetReference(1), reference_stride_, 255);
205 FillConstant(GetReference(2), reference_stride_, 255);
206 FillConstant(GetReference(3), reference_stride_, 255);
207 CheckSADs();
208}
209
Johannfbea8972012-06-28 11:43:58 -0700210TEST_P(SADTest, MaxSrc) {
211 FillConstant(source_data_, source_stride_, 255);
212 FillConstant(reference_data_, reference_stride_, 0);
Johann11610552012-06-26 11:37:33 -0700213 CheckSad(UINT_MAX);
Johannfbea8972012-06-28 11:43:58 -0700214}
215
John Koleszar1cfc86e2013-03-01 12:43:41 -0800216TEST_P(SADx4Test, MaxSrc) {
217 FillConstant(source_data_, source_stride_, 255);
218 FillConstant(GetReference(0), reference_stride_, 0);
219 FillConstant(GetReference(1), reference_stride_, 0);
220 FillConstant(GetReference(2), reference_stride_, 0);
221 FillConstant(GetReference(3), reference_stride_, 0);
222 CheckSADs();
223}
224
Johannfbea8972012-06-28 11:43:58 -0700225TEST_P(SADTest, ShortRef) {
226 int tmp_stride = reference_stride_;
227 reference_stride_ >>= 1;
228 FillRandom(source_data_, source_stride_);
229 FillRandom(reference_data_, reference_stride_);
Johann11610552012-06-26 11:37:33 -0700230 CheckSad(UINT_MAX);
Johannfbea8972012-06-28 11:43:58 -0700231 reference_stride_ = tmp_stride;
232}
233
John Koleszar1cfc86e2013-03-01 12:43:41 -0800234TEST_P(SADx4Test, ShortRef) {
235 int tmp_stride = reference_stride_;
236 reference_stride_ >>= 1;
237 FillRandom(source_data_, source_stride_);
238 FillRandom(GetReference(0), reference_stride_);
239 FillRandom(GetReference(1), reference_stride_);
240 FillRandom(GetReference(2), reference_stride_);
241 FillRandom(GetReference(3), reference_stride_);
242 CheckSADs();
243 reference_stride_ = tmp_stride;
244}
245
Johannfbea8972012-06-28 11:43:58 -0700246TEST_P(SADTest, UnalignedRef) {
247 // The reference frame, but not the source frame, may be unaligned for
248 // certain types of searches.
249 int tmp_stride = reference_stride_;
250 reference_stride_ -= 1;
251 FillRandom(source_data_, source_stride_);
252 FillRandom(reference_data_, reference_stride_);
Johann11610552012-06-26 11:37:33 -0700253 CheckSad(UINT_MAX);
Johannfbea8972012-06-28 11:43:58 -0700254 reference_stride_ = tmp_stride;
255}
256
John Koleszar1cfc86e2013-03-01 12:43:41 -0800257TEST_P(SADx4Test, UnalignedRef) {
258 // The reference frame, but not the source frame, may be unaligned for
259 // certain types of searches.
260 int tmp_stride = reference_stride_;
261 reference_stride_ -= 1;
262 FillRandom(source_data_, source_stride_);
263 FillRandom(GetReference(0), reference_stride_);
264 FillRandom(GetReference(1), reference_stride_);
265 FillRandom(GetReference(2), reference_stride_);
266 FillRandom(GetReference(3), reference_stride_);
267 CheckSADs();
268 reference_stride_ = tmp_stride;
269}
270
Johannfbea8972012-06-28 11:43:58 -0700271TEST_P(SADTest, ShortSrc) {
272 int tmp_stride = source_stride_;
273 source_stride_ >>= 1;
274 FillRandom(source_data_, source_stride_);
275 FillRandom(reference_data_, reference_stride_);
Johann11610552012-06-26 11:37:33 -0700276 CheckSad(UINT_MAX);
Johannfbea8972012-06-28 11:43:58 -0700277 source_stride_ = tmp_stride;
278}
279
John Koleszar1cfc86e2013-03-01 12:43:41 -0800280TEST_P(SADx4Test, ShortSrc) {
281 int tmp_stride = source_stride_;
282 source_stride_ >>= 1;
283 FillRandom(source_data_, source_stride_);
284 FillRandom(GetReference(0), reference_stride_);
285 FillRandom(GetReference(1), reference_stride_);
286 FillRandom(GetReference(2), reference_stride_);
287 FillRandom(GetReference(3), reference_stride_);
288 CheckSADs();
289 source_stride_ = tmp_stride;
290}
291
Johannfbea8972012-06-28 11:43:58 -0700292TEST_P(SADTest, MaxSAD) {
293 // Verify that, when max_sad is set, the implementation does not return a
294 // value lower than the reference.
295 FillConstant(source_data_, source_stride_, 255);
296 FillConstant(reference_data_, reference_stride_, 0);
297 CheckSad(128);
298}
299
James Zern12ddb752012-08-15 11:54:41 -0700300using std::tr1::make_tuple;
301
John Koleszar6b653cb2013-02-28 17:03:02 -0800302#if CONFIG_VP8_ENCODER
James Zern12ddb752012-08-15 11:54:41 -0700303const sad_m_by_n_fn_t sad_16x16_c = vp8_sad16x16_c;
304const sad_m_by_n_fn_t sad_8x16_c = vp8_sad8x16_c;
305const sad_m_by_n_fn_t sad_16x8_c = vp8_sad16x8_c;
306const sad_m_by_n_fn_t sad_8x8_c = vp8_sad8x8_c;
307const sad_m_by_n_fn_t sad_4x4_c = vp8_sad4x4_c;
John Koleszar6b653cb2013-02-28 17:03:02 -0800308#endif
309#if CONFIG_VP9_ENCODER
310const sad_m_by_n_fn_t sad_64x64_c_vp9 = vp9_sad64x64_c;
311const sad_m_by_n_fn_t sad_32x32_c_vp9 = vp9_sad32x32_c;
312const sad_m_by_n_fn_t sad_16x16_c_vp9 = vp9_sad16x16_c;
313const sad_m_by_n_fn_t sad_8x16_c_vp9 = vp9_sad8x16_c;
314const sad_m_by_n_fn_t sad_16x8_c_vp9 = vp9_sad16x8_c;
315const sad_m_by_n_fn_t sad_8x8_c_vp9 = vp9_sad8x8_c;
Jingning Han15f50e72013-06-13 11:07:12 -0700316const sad_m_by_n_fn_t sad_8x4_c_vp9 = vp9_sad8x4_c;
317const sad_m_by_n_fn_t sad_4x8_c_vp9 = vp9_sad4x8_c;
John Koleszar6b653cb2013-02-28 17:03:02 -0800318const sad_m_by_n_fn_t sad_4x4_c_vp9 = vp9_sad4x4_c;
319#endif
James Zern5e3439b2013-05-29 17:47:18 -0700320const sad_m_by_n_test_param_t c_tests[] = {
John Koleszar6b653cb2013-02-28 17:03:02 -0800321#if CONFIG_VP8_ENCODER
James Zern5e3439b2013-05-29 17:47:18 -0700322 make_tuple(16, 16, sad_16x16_c),
323 make_tuple(8, 16, sad_8x16_c),
324 make_tuple(16, 8, sad_16x8_c),
325 make_tuple(8, 8, sad_8x8_c),
326 make_tuple(4, 4, sad_4x4_c),
John Koleszar6b653cb2013-02-28 17:03:02 -0800327#endif
John Koleszar6b653cb2013-02-28 17:03:02 -0800328#if CONFIG_VP9_ENCODER
James Zern5e3439b2013-05-29 17:47:18 -0700329 make_tuple(64, 64, sad_64x64_c_vp9),
330 make_tuple(32, 32, sad_32x32_c_vp9),
331 make_tuple(16, 16, sad_16x16_c_vp9),
332 make_tuple(8, 16, sad_8x16_c_vp9),
333 make_tuple(16, 8, sad_16x8_c_vp9),
334 make_tuple(8, 8, sad_8x8_c_vp9),
Jingning Han15f50e72013-06-13 11:07:12 -0700335 make_tuple(8, 4, sad_8x4_c_vp9),
336 make_tuple(4, 8, sad_4x8_c_vp9),
James Zern5e3439b2013-05-29 17:47:18 -0700337 make_tuple(4, 4, sad_4x4_c_vp9),
John Koleszar6b653cb2013-02-28 17:03:02 -0800338#endif
James Zern5e3439b2013-05-29 17:47:18 -0700339};
340INSTANTIATE_TEST_CASE_P(C, SADTest, ::testing::ValuesIn(c_tests));
Johannfbea8972012-06-28 11:43:58 -0700341
John Koleszar1cfc86e2013-03-01 12:43:41 -0800342#if CONFIG_VP9_ENCODER
343const sad_n_by_n_by_4_fn_t sad_64x64x4d_c = vp9_sad64x64x4d_c;
Ronald S. Bultjefa96eeb2013-06-11 15:19:14 -0700344const sad_n_by_n_by_4_fn_t sad_64x32x4d_c = vp9_sad64x32x4d_c;
345const sad_n_by_n_by_4_fn_t sad_32x64x4d_c = vp9_sad32x64x4d_c;
John Koleszar1cfc86e2013-03-01 12:43:41 -0800346const sad_n_by_n_by_4_fn_t sad_32x32x4d_c = vp9_sad32x32x4d_c;
Ronald S. Bultjefa96eeb2013-06-11 15:19:14 -0700347const sad_n_by_n_by_4_fn_t sad_32x16x4d_c = vp9_sad32x16x4d_c;
348const sad_n_by_n_by_4_fn_t sad_16x32x4d_c = vp9_sad16x32x4d_c;
John Koleszar1cfc86e2013-03-01 12:43:41 -0800349const sad_n_by_n_by_4_fn_t sad_16x16x4d_c = vp9_sad16x16x4d_c;
Ronald S. Bultjefa96eeb2013-06-11 15:19:14 -0700350const sad_n_by_n_by_4_fn_t sad_16x8x4d_c = vp9_sad16x8x4d_c;
351const sad_n_by_n_by_4_fn_t sad_8x16x4d_c = vp9_sad8x16x4d_c;
John Koleszar1cfc86e2013-03-01 12:43:41 -0800352const sad_n_by_n_by_4_fn_t sad_8x8x4d_c = vp9_sad8x8x4d_c;
Ronald S. Bultjefa96eeb2013-06-11 15:19:14 -0700353const sad_n_by_n_by_4_fn_t sad_8x4x4d_c = vp9_sad8x4x4d_c;
354const sad_n_by_n_by_4_fn_t sad_4x8x4d_c = vp9_sad4x8x4d_c;
John Koleszar1cfc86e2013-03-01 12:43:41 -0800355const sad_n_by_n_by_4_fn_t sad_4x4x4d_c = vp9_sad4x4x4d_c;
356INSTANTIATE_TEST_CASE_P(C, SADx4Test, ::testing::Values(
357 make_tuple(64, 64, sad_64x64x4d_c),
Ronald S. Bultjefa96eeb2013-06-11 15:19:14 -0700358 make_tuple(64, 32, sad_64x32x4d_c),
359 make_tuple(32, 64, sad_32x64x4d_c),
John Koleszar1cfc86e2013-03-01 12:43:41 -0800360 make_tuple(32, 32, sad_32x32x4d_c),
Ronald S. Bultjefa96eeb2013-06-11 15:19:14 -0700361 make_tuple(32, 16, sad_32x16x4d_c),
362 make_tuple(16, 32, sad_16x32x4d_c),
John Koleszar1cfc86e2013-03-01 12:43:41 -0800363 make_tuple(16, 16, sad_16x16x4d_c),
Ronald S. Bultjefa96eeb2013-06-11 15:19:14 -0700364 make_tuple(16, 8, sad_16x8x4d_c),
365 make_tuple(8, 16, sad_8x16x4d_c),
John Koleszar1cfc86e2013-03-01 12:43:41 -0800366 make_tuple(8, 8, sad_8x8x4d_c),
Ronald S. Bultjefa96eeb2013-06-11 15:19:14 -0700367 make_tuple(8, 4, sad_8x4x4d_c),
368 make_tuple(4, 8, sad_4x8x4d_c),
John Koleszar1cfc86e2013-03-01 12:43:41 -0800369 make_tuple(4, 4, sad_4x4x4d_c)));
370#endif
371
Johannfbea8972012-06-28 11:43:58 -0700372// ARM tests
373#if HAVE_MEDIA
James Zern12ddb752012-08-15 11:54:41 -0700374const sad_m_by_n_fn_t sad_16x16_armv6 = vp8_sad16x16_armv6;
Johannfbea8972012-06-28 11:43:58 -0700375INSTANTIATE_TEST_CASE_P(MEDIA, SADTest, ::testing::Values(
James Zern12ddb752012-08-15 11:54:41 -0700376 make_tuple(16, 16, sad_16x16_armv6)));
Johannfbea8972012-06-28 11:43:58 -0700377
378#endif
379#if HAVE_NEON
James Zern12ddb752012-08-15 11:54:41 -0700380const sad_m_by_n_fn_t sad_16x16_neon = vp8_sad16x16_neon;
381const sad_m_by_n_fn_t sad_8x16_neon = vp8_sad8x16_neon;
382const sad_m_by_n_fn_t sad_16x8_neon = vp8_sad16x8_neon;
383const sad_m_by_n_fn_t sad_8x8_neon = vp8_sad8x8_neon;
384const sad_m_by_n_fn_t sad_4x4_neon = vp8_sad4x4_neon;
Johannfbea8972012-06-28 11:43:58 -0700385INSTANTIATE_TEST_CASE_P(NEON, SADTest, ::testing::Values(
James Zern12ddb752012-08-15 11:54:41 -0700386 make_tuple(16, 16, sad_16x16_neon),
387 make_tuple(8, 16, sad_8x16_neon),
388 make_tuple(16, 8, sad_16x8_neon),
389 make_tuple(8, 8, sad_8x8_neon),
390 make_tuple(4, 4, sad_4x4_neon)));
Johannfbea8972012-06-28 11:43:58 -0700391#endif
392
393// X86 tests
394#if HAVE_MMX
John Koleszar6b653cb2013-02-28 17:03:02 -0800395#if CONFIG_VP8_ENCODER
James Zern12ddb752012-08-15 11:54:41 -0700396const sad_m_by_n_fn_t sad_16x16_mmx = vp8_sad16x16_mmx;
397const sad_m_by_n_fn_t sad_8x16_mmx = vp8_sad8x16_mmx;
398const sad_m_by_n_fn_t sad_16x8_mmx = vp8_sad16x8_mmx;
399const sad_m_by_n_fn_t sad_8x8_mmx = vp8_sad8x8_mmx;
400const sad_m_by_n_fn_t sad_4x4_mmx = vp8_sad4x4_mmx;
John Koleszar6b653cb2013-02-28 17:03:02 -0800401#endif
402#if CONFIG_VP9_ENCODER
403const sad_m_by_n_fn_t sad_16x16_mmx_vp9 = vp9_sad16x16_mmx;
404const sad_m_by_n_fn_t sad_8x16_mmx_vp9 = vp9_sad8x16_mmx;
405const sad_m_by_n_fn_t sad_16x8_mmx_vp9 = vp9_sad16x8_mmx;
406const sad_m_by_n_fn_t sad_8x8_mmx_vp9 = vp9_sad8x8_mmx;
407const sad_m_by_n_fn_t sad_4x4_mmx_vp9 = vp9_sad4x4_mmx;
408#endif
409
James Zern5e3439b2013-05-29 17:47:18 -0700410const sad_m_by_n_test_param_t mmx_tests[] = {
John Koleszar6b653cb2013-02-28 17:03:02 -0800411#if CONFIG_VP8_ENCODER
James Zern5e3439b2013-05-29 17:47:18 -0700412 make_tuple(16, 16, sad_16x16_mmx),
413 make_tuple(8, 16, sad_8x16_mmx),
414 make_tuple(16, 8, sad_16x8_mmx),
415 make_tuple(8, 8, sad_8x8_mmx),
416 make_tuple(4, 4, sad_4x4_mmx),
Johannfbea8972012-06-28 11:43:58 -0700417#endif
John Koleszar6b653cb2013-02-28 17:03:02 -0800418#if CONFIG_VP9_ENCODER
James Zern5e3439b2013-05-29 17:47:18 -0700419 make_tuple(16, 16, sad_16x16_mmx_vp9),
420 make_tuple(8, 16, sad_8x16_mmx_vp9),
421 make_tuple(16, 8, sad_16x8_mmx_vp9),
422 make_tuple(8, 8, sad_8x8_mmx_vp9),
423 make_tuple(4, 4, sad_4x4_mmx_vp9),
John Koleszar6b653cb2013-02-28 17:03:02 -0800424#endif
James Zern5e3439b2013-05-29 17:47:18 -0700425};
426INSTANTIATE_TEST_CASE_P(MMX, SADTest, ::testing::ValuesIn(mmx_tests));
John Koleszar6b653cb2013-02-28 17:03:02 -0800427#endif
428
429#if HAVE_SSE
430#if CONFIG_VP9_ENCODER
431const sad_m_by_n_fn_t sad_4x4_sse_vp9 = vp9_sad4x4_sse;
Jingning Han15f50e72013-06-13 11:07:12 -0700432const sad_m_by_n_fn_t sad_4x8_sse_vp9 = vp9_sad4x8_sse;
John Koleszar6b653cb2013-02-28 17:03:02 -0800433INSTANTIATE_TEST_CASE_P(SSE, SADTest, ::testing::Values(
Jingning Han15f50e72013-06-13 11:07:12 -0700434 make_tuple(4, 4, sad_4x4_sse_vp9),
435 make_tuple(4, 8, sad_4x8_sse_vp9)));
John Koleszar1cfc86e2013-03-01 12:43:41 -0800436
Ronald S. Bultjefa96eeb2013-06-11 15:19:14 -0700437const sad_n_by_n_by_4_fn_t sad_4x8x4d_sse = vp9_sad4x8x4d_sse;
John Koleszar1cfc86e2013-03-01 12:43:41 -0800438const sad_n_by_n_by_4_fn_t sad_4x4x4d_sse = vp9_sad4x4x4d_sse;
439INSTANTIATE_TEST_CASE_P(SSE, SADx4Test, ::testing::Values(
Ronald S. Bultjefa96eeb2013-06-11 15:19:14 -0700440 make_tuple(4, 8, sad_4x8x4d_sse),
John Koleszar1cfc86e2013-03-01 12:43:41 -0800441 make_tuple(4, 4, sad_4x4x4d_sse)));
John Koleszar6b653cb2013-02-28 17:03:02 -0800442#endif
443#endif
444
Johannfbea8972012-06-28 11:43:58 -0700445#if HAVE_SSE2
John Koleszar6b653cb2013-02-28 17:03:02 -0800446#if CONFIG_VP8_ENCODER
James Zern12ddb752012-08-15 11:54:41 -0700447const sad_m_by_n_fn_t sad_16x16_wmt = vp8_sad16x16_wmt;
448const sad_m_by_n_fn_t sad_8x16_wmt = vp8_sad8x16_wmt;
449const sad_m_by_n_fn_t sad_16x8_wmt = vp8_sad16x8_wmt;
450const sad_m_by_n_fn_t sad_8x8_wmt = vp8_sad8x8_wmt;
451const sad_m_by_n_fn_t sad_4x4_wmt = vp8_sad4x4_wmt;
John Koleszar6b653cb2013-02-28 17:03:02 -0800452#endif
453#if CONFIG_VP9_ENCODER
454const sad_m_by_n_fn_t sad_64x64_sse2_vp9 = vp9_sad64x64_sse2;
Ronald S. Bultje3c4abbe2013-06-24 11:28:19 -0700455const sad_m_by_n_fn_t sad_64x32_sse2_vp9 = vp9_sad64x32_sse2;
456const sad_m_by_n_fn_t sad_32x64_sse2_vp9 = vp9_sad32x64_sse2;
John Koleszar6b653cb2013-02-28 17:03:02 -0800457const sad_m_by_n_fn_t sad_32x32_sse2_vp9 = vp9_sad32x32_sse2;
Ronald S. Bultje3c4abbe2013-06-24 11:28:19 -0700458const sad_m_by_n_fn_t sad_32x16_sse2_vp9 = vp9_sad32x16_sse2;
459const sad_m_by_n_fn_t sad_16x32_sse2_vp9 = vp9_sad16x32_sse2;
John Koleszar6b653cb2013-02-28 17:03:02 -0800460const sad_m_by_n_fn_t sad_16x16_sse2_vp9 = vp9_sad16x16_sse2;
John Koleszar6b653cb2013-02-28 17:03:02 -0800461const sad_m_by_n_fn_t sad_16x8_sse2_vp9 = vp9_sad16x8_sse2;
Ronald S. Bultje3c4abbe2013-06-24 11:28:19 -0700462const sad_m_by_n_fn_t sad_8x16_sse2_vp9 = vp9_sad8x16_sse2;
John Koleszar6b653cb2013-02-28 17:03:02 -0800463const sad_m_by_n_fn_t sad_8x8_sse2_vp9 = vp9_sad8x8_sse2;
Jingning Han15f50e72013-06-13 11:07:12 -0700464const sad_m_by_n_fn_t sad_8x4_sse2_vp9 = vp9_sad8x4_sse2;
John Koleszar6b653cb2013-02-28 17:03:02 -0800465#endif
James Zern5e3439b2013-05-29 17:47:18 -0700466const sad_m_by_n_test_param_t sse2_tests[] = {
John Koleszar6b653cb2013-02-28 17:03:02 -0800467#if CONFIG_VP8_ENCODER
James Zern5e3439b2013-05-29 17:47:18 -0700468 make_tuple(16, 16, sad_16x16_wmt),
469 make_tuple(8, 16, sad_8x16_wmt),
470 make_tuple(16, 8, sad_16x8_wmt),
471 make_tuple(8, 8, sad_8x8_wmt),
472 make_tuple(4, 4, sad_4x4_wmt),
Johannfbea8972012-06-28 11:43:58 -0700473#endif
John Koleszar6b653cb2013-02-28 17:03:02 -0800474#if CONFIG_VP9_ENCODER
James Zern5e3439b2013-05-29 17:47:18 -0700475 make_tuple(64, 64, sad_64x64_sse2_vp9),
Ronald S. Bultje3c4abbe2013-06-24 11:28:19 -0700476 make_tuple(64, 32, sad_64x32_sse2_vp9),
477 make_tuple(32, 64, sad_32x64_sse2_vp9),
James Zern5e3439b2013-05-29 17:47:18 -0700478 make_tuple(32, 32, sad_32x32_sse2_vp9),
Ronald S. Bultje3c4abbe2013-06-24 11:28:19 -0700479 make_tuple(32, 16, sad_32x16_sse2_vp9),
480 make_tuple(16, 32, sad_16x32_sse2_vp9),
James Zern5e3439b2013-05-29 17:47:18 -0700481 make_tuple(16, 16, sad_16x16_sse2_vp9),
James Zern5e3439b2013-05-29 17:47:18 -0700482 make_tuple(16, 8, sad_16x8_sse2_vp9),
Ronald S. Bultje3c4abbe2013-06-24 11:28:19 -0700483 make_tuple(8, 16, sad_8x16_sse2_vp9),
James Zern5e3439b2013-05-29 17:47:18 -0700484 make_tuple(8, 8, sad_8x8_sse2_vp9),
Jingning Han15f50e72013-06-13 11:07:12 -0700485 make_tuple(8, 4, sad_8x4_sse2_vp9),
John Koleszar6b653cb2013-02-28 17:03:02 -0800486#endif
James Zern5e3439b2013-05-29 17:47:18 -0700487};
488INSTANTIATE_TEST_CASE_P(SSE2, SADTest, ::testing::ValuesIn(sse2_tests));
John Koleszar1cfc86e2013-03-01 12:43:41 -0800489
490#if CONFIG_VP9_ENCODER
491const sad_n_by_n_by_4_fn_t sad_64x64x4d_sse2 = vp9_sad64x64x4d_sse2;
Ronald S. Bultjefa96eeb2013-06-11 15:19:14 -0700492const sad_n_by_n_by_4_fn_t sad_64x32x4d_sse2 = vp9_sad64x32x4d_sse2;
493const sad_n_by_n_by_4_fn_t sad_32x64x4d_sse2 = vp9_sad32x64x4d_sse2;
John Koleszar1cfc86e2013-03-01 12:43:41 -0800494const sad_n_by_n_by_4_fn_t sad_32x32x4d_sse2 = vp9_sad32x32x4d_sse2;
Ronald S. Bultjefa96eeb2013-06-11 15:19:14 -0700495const sad_n_by_n_by_4_fn_t sad_32x16x4d_sse2 = vp9_sad32x16x4d_sse2;
496const sad_n_by_n_by_4_fn_t sad_16x32x4d_sse2 = vp9_sad16x32x4d_sse2;
John Koleszar1cfc86e2013-03-01 12:43:41 -0800497const sad_n_by_n_by_4_fn_t sad_16x16x4d_sse2 = vp9_sad16x16x4d_sse2;
498const sad_n_by_n_by_4_fn_t sad_16x8x4d_sse2 = vp9_sad16x8x4d_sse2;
499const sad_n_by_n_by_4_fn_t sad_8x16x4d_sse2 = vp9_sad8x16x4d_sse2;
500const sad_n_by_n_by_4_fn_t sad_8x8x4d_sse2 = vp9_sad8x8x4d_sse2;
Ronald S. Bultjefa96eeb2013-06-11 15:19:14 -0700501const sad_n_by_n_by_4_fn_t sad_8x4x4d_sse2 = vp9_sad8x4x4d_sse2;
John Koleszar1cfc86e2013-03-01 12:43:41 -0800502INSTANTIATE_TEST_CASE_P(SSE2, SADx4Test, ::testing::Values(
503 make_tuple(64, 64, sad_64x64x4d_sse2),
Ronald S. Bultjefa96eeb2013-06-11 15:19:14 -0700504 make_tuple(64, 32, sad_64x32x4d_sse2),
505 make_tuple(32, 64, sad_32x64x4d_sse2),
John Koleszar1cfc86e2013-03-01 12:43:41 -0800506 make_tuple(32, 32, sad_32x32x4d_sse2),
Ronald S. Bultjefa96eeb2013-06-11 15:19:14 -0700507 make_tuple(32, 16, sad_32x16x4d_sse2),
508 make_tuple(16, 32, sad_16x32x4d_sse2),
John Koleszar1cfc86e2013-03-01 12:43:41 -0800509 make_tuple(16, 16, sad_16x16x4d_sse2),
510 make_tuple(16, 8, sad_16x8x4d_sse2),
511 make_tuple(8, 16, sad_8x16x4d_sse2),
Ronald S. Bultjefa96eeb2013-06-11 15:19:14 -0700512 make_tuple(8, 8, sad_8x8x4d_sse2),
513 make_tuple(8, 4, sad_8x4x4d_sse2)));
John Koleszar1cfc86e2013-03-01 12:43:41 -0800514#endif
515#endif
516
517#if HAVE_SSE3
518#if CONFIG_VP8_ENCODER
519const sad_n_by_n_by_4_fn_t sad_16x16x4d_sse3 = vp8_sad16x16x4d_sse3;
520const sad_n_by_n_by_4_fn_t sad_16x8x4d_sse3 = vp8_sad16x8x4d_sse3;
521const sad_n_by_n_by_4_fn_t sad_8x16x4d_sse3 = vp8_sad8x16x4d_sse3;
522const sad_n_by_n_by_4_fn_t sad_8x8x4d_sse3 = vp8_sad8x8x4d_sse3;
523const sad_n_by_n_by_4_fn_t sad_4x4x4d_sse3 = vp8_sad4x4x4d_sse3;
524INSTANTIATE_TEST_CASE_P(SSE3, SADx4Test, ::testing::Values(
525 make_tuple(16, 16, sad_16x16x4d_sse3),
526 make_tuple(16, 8, sad_16x8x4d_sse3),
527 make_tuple(8, 16, sad_8x16x4d_sse3),
528 make_tuple(8, 8, sad_8x8x4d_sse3),
529 make_tuple(4, 4, sad_4x4x4d_sse3)));
530#endif
John Koleszar6b653cb2013-02-28 17:03:02 -0800531#endif
532
Johannfbea8972012-06-28 11:43:58 -0700533#if HAVE_SSSE3
James Zern12ddb752012-08-15 11:54:41 -0700534const sad_m_by_n_fn_t sad_16x16_sse3 = vp8_sad16x16_sse3;
Johannfbea8972012-06-28 11:43:58 -0700535INSTANTIATE_TEST_CASE_P(SSE3, SADTest, ::testing::Values(
James Zern12ddb752012-08-15 11:54:41 -0700536 make_tuple(16, 16, sad_16x16_sse3)));
Johannfbea8972012-06-28 11:43:58 -0700537#endif
538
539} // namespace