sad_test.cc 18.8 KB
Newer Older
Johann's avatar
Johann committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
 *  Copyright (c) 2012 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */


#include <string.h>
#include <limits.h>
#include <stdio.h>

extern "C" {
#include "./vpx_config.h"
18
#if CONFIG_VP8_ENCODER
19
#include "./vp8_rtcd.h"
20
21
22
23
24
//#include "vp8/common/blockd.h"
#endif
#if CONFIG_VP9_ENCODER
#include "./vp9_rtcd.h"
#endif
25
#include "vpx_mem/vpx_mem.h"
Johann's avatar
Johann committed
26
27
28
}

#include "test/acm_random.h"
29
#include "test/clear_system_state.h"
30
#include "test/register_state_check.h"
Johann's avatar
Johann committed
31
32
33
34
35
36
37
38
#include "test/util.h"
#include "third_party/googletest/src/include/gtest/gtest.h"


typedef unsigned int (*sad_m_by_n_fn_t)(const unsigned char *source_ptr,
                                        int source_stride,
                                        const unsigned char *reference_ptr,
                                        int reference_stride,
Johann's avatar
Johann committed
39
                                        unsigned int max_sad);
James Zern's avatar
James Zern committed
40
typedef std::tr1::tuple<int, int, sad_m_by_n_fn_t> sad_m_by_n_test_param_t;
Johann's avatar
Johann committed
41

42
43
44
45
46
typedef void (*sad_n_by_n_by_4_fn_t)(const uint8_t *src_ptr,
                                     int src_stride,
                                     const unsigned char * const ref_ptr[],
                                     int ref_stride,
                                     unsigned int *sad_array);
James Zern's avatar
James Zern committed
47
48
typedef std::tr1::tuple<int, int, sad_n_by_n_by_4_fn_t>
        sad_n_by_n_by_4_test_param_t;
49

Johann's avatar
Johann committed
50
51
52
using libvpx_test::ACMRandom;

namespace {
53
class SADTestBase : public ::testing::Test {
54
 public:
55
56
  SADTestBase(int width, int height) : width_(width), height_(height) {}

57
58
  static void SetUpTestCase() {
    source_data_ = reinterpret_cast<uint8_t*>(
59
        vpx_memalign(kDataAlignment, kDataBlockSize));
60
61
62
63
64
65
66
67
68
69
70
    reference_data_ = reinterpret_cast<uint8_t*>(
        vpx_memalign(kDataAlignment, kDataBufferSize));
  }

  static void TearDownTestCase() {
    vpx_free(source_data_);
    source_data_ = NULL;
    vpx_free(reference_data_);
    reference_data_ = NULL;
  }

71
72
73
74
  virtual void TearDown() {
    libvpx_test::ClearSystemState();
  }

75
 protected:
76
  // Handle blocks up to 4 blocks 64x64 with stride up to 128
77
  static const int kDataAlignment = 16;
78
79
  static const int kDataBlockSize = 64 * 128;
  static const int kDataBufferSize = 4 * kDataBlockSize;
80

Johann's avatar
Johann committed
81
  virtual void SetUp() {
82
    source_stride_ = (width_ + 31) & ~31;
Johann's avatar
Johann committed
83
84
85
86
    reference_stride_ = width_ * 2;
    rnd_.Reset(ACMRandom::DeterministicSeed());
  }

87
88
  virtual uint8_t* GetReference(int block_idx) {
    return reference_data_ + block_idx * kDataBlockSize;
Johann's avatar
Johann committed
89
90
91
92
  }

  // Sum of Absolute Differences. Given two blocks, calculate the absolute
  // difference between two pixels in the same relative location; accumulate.
93
  unsigned int ReferenceSAD(unsigned int max_sad, int block_idx = 0) {
Johann's avatar
Johann committed
94
    unsigned int sad = 0;
95
    const uint8_t* const reference = GetReference(block_idx);
Johann's avatar
Johann committed
96
97
98
99

    for (int h = 0; h < height_; ++h) {
      for (int w = 0; w < width_; ++w) {
        sad += abs(source_data_[h * source_stride_ + w]
100
               - reference[h * reference_stride_ + w]);
Johann's avatar
Johann committed
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
      }
      if (sad > max_sad) {
        break;
      }
    }
    return sad;
  }

  void FillConstant(uint8_t *data, int stride, uint8_t fill_constant) {
    for (int h = 0; h < height_; ++h) {
      for (int w = 0; w < width_; ++w) {
        data[h * stride + w] = fill_constant;
      }
    }
  }

  void FillRandom(uint8_t *data, int stride) {
    for (int h = 0; h < height_; ++h) {
      for (int w = 0; w < width_; ++w) {
        data[h * stride + w] = rnd_.Rand8();
      }
    }
  }

125
126
127
128
129
130
131
132
133
134
  int width_, height_;
  static uint8_t* source_data_;
  int source_stride_;
  static uint8_t* reference_data_;
  int reference_stride_;

  ACMRandom rnd_;
};

class SADTest : public SADTestBase,
James Zern's avatar
James Zern committed
135
    public ::testing::WithParamInterface<sad_m_by_n_test_param_t> {
136
137
138
139
140
141
142
143
144
145
146
147
148
149
 public:
  SADTest() : SADTestBase(GET_PARAM(0), GET_PARAM(1)) {}

 protected:
  unsigned int SAD(unsigned int max_sad, int block_idx = 0) {
    unsigned int ret;
    const uint8_t* const reference = GetReference(block_idx);

    REGISTER_STATE_CHECK(ret = GET_PARAM(2)(source_data_, source_stride_,
                                            reference, reference_stride_,
                                            max_sad));
    return ret;
  }

Johann's avatar
Johann committed
150
151
152
153
154
155
156
157
158
159
160
161
162
  void CheckSad(unsigned int max_sad) {
    unsigned int reference_sad, exp_sad;

    reference_sad = ReferenceSAD(max_sad);
    exp_sad = SAD(max_sad);

    if (reference_sad <= max_sad) {
      ASSERT_EQ(exp_sad, reference_sad);
    } else {
      // Alternative implementations are not required to check max_sad
      ASSERT_GE(exp_sad, reference_sad);
    }
  }
163
};
Johann's avatar
Johann committed
164

165
class SADx4Test : public SADTestBase,
James Zern's avatar
James Zern committed
166
    public ::testing::WithParamInterface<sad_n_by_n_by_4_test_param_t> {
167
168
 public:
  SADx4Test() : SADTestBase(GET_PARAM(0), GET_PARAM(1)) {}
Johann's avatar
Johann committed
169

170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
 protected:
  void SADs(unsigned int *results) {
    const uint8_t* refs[] = {GetReference(0), GetReference(1),
                             GetReference(2), GetReference(3)};

    REGISTER_STATE_CHECK(GET_PARAM(2)(source_data_, source_stride_,
                                      refs, reference_stride_,
                                      results));
  }

  void CheckSADs() {
    unsigned int reference_sad, exp_sad[4];

    SADs(exp_sad);
    for (int block = 0; block < 4; block++) {
      reference_sad = ReferenceSAD(UINT_MAX, block);

      EXPECT_EQ(exp_sad[block], reference_sad) << "block " << block;
    }
  }
Johann's avatar
Johann committed
190
191
};

192
193
uint8_t* SADTestBase::source_data_ = NULL;
uint8_t* SADTestBase::reference_data_ = NULL;
194

Johann's avatar
Johann committed
195
196
197
TEST_P(SADTest, MaxRef) {
  FillConstant(source_data_, source_stride_, 0);
  FillConstant(reference_data_, reference_stride_, 255);
Johann's avatar
Johann committed
198
  CheckSad(UINT_MAX);
Johann's avatar
Johann committed
199
200
}

201
202
203
204
205
206
207
208
209
TEST_P(SADx4Test, MaxRef) {
  FillConstant(source_data_, source_stride_, 0);
  FillConstant(GetReference(0), reference_stride_, 255);
  FillConstant(GetReference(1), reference_stride_, 255);
  FillConstant(GetReference(2), reference_stride_, 255);
  FillConstant(GetReference(3), reference_stride_, 255);
  CheckSADs();
}

Johann's avatar
Johann committed
210
211
212
TEST_P(SADTest, MaxSrc) {
  FillConstant(source_data_, source_stride_, 255);
  FillConstant(reference_data_, reference_stride_, 0);
Johann's avatar
Johann committed
213
  CheckSad(UINT_MAX);
Johann's avatar
Johann committed
214
215
}

216
217
218
219
220
221
222
223
224
TEST_P(SADx4Test, MaxSrc) {
  FillConstant(source_data_, source_stride_, 255);
  FillConstant(GetReference(0), reference_stride_, 0);
  FillConstant(GetReference(1), reference_stride_, 0);
  FillConstant(GetReference(2), reference_stride_, 0);
  FillConstant(GetReference(3), reference_stride_, 0);
  CheckSADs();
}

Johann's avatar
Johann committed
225
226
227
228
229
TEST_P(SADTest, ShortRef) {
  int tmp_stride = reference_stride_;
  reference_stride_ >>= 1;
  FillRandom(source_data_, source_stride_);
  FillRandom(reference_data_, reference_stride_);
Johann's avatar
Johann committed
230
  CheckSad(UINT_MAX);
Johann's avatar
Johann committed
231
232
233
  reference_stride_ = tmp_stride;
}

234
235
236
237
238
239
240
241
242
243
244
245
TEST_P(SADx4Test, ShortRef) {
  int tmp_stride = reference_stride_;
  reference_stride_ >>= 1;
  FillRandom(source_data_, source_stride_);
  FillRandom(GetReference(0), reference_stride_);
  FillRandom(GetReference(1), reference_stride_);
  FillRandom(GetReference(2), reference_stride_);
  FillRandom(GetReference(3), reference_stride_);
  CheckSADs();
  reference_stride_ = tmp_stride;
}

Johann's avatar
Johann committed
246
247
248
249
250
251
252
TEST_P(SADTest, UnalignedRef) {
  // The reference frame, but not the source frame, may be unaligned for
  // certain types of searches.
  int tmp_stride = reference_stride_;
  reference_stride_ -= 1;
  FillRandom(source_data_, source_stride_);
  FillRandom(reference_data_, reference_stride_);
Johann's avatar
Johann committed
253
  CheckSad(UINT_MAX);
Johann's avatar
Johann committed
254
255
256
  reference_stride_ = tmp_stride;
}

257
258
259
260
261
262
263
264
265
266
267
268
269
270
TEST_P(SADx4Test, UnalignedRef) {
  // The reference frame, but not the source frame, may be unaligned for
  // certain types of searches.
  int tmp_stride = reference_stride_;
  reference_stride_ -= 1;
  FillRandom(source_data_, source_stride_);
  FillRandom(GetReference(0), reference_stride_);
  FillRandom(GetReference(1), reference_stride_);
  FillRandom(GetReference(2), reference_stride_);
  FillRandom(GetReference(3), reference_stride_);
  CheckSADs();
  reference_stride_ = tmp_stride;
}

Johann's avatar
Johann committed
271
272
273
274
275
TEST_P(SADTest, ShortSrc) {
  int tmp_stride = source_stride_;
  source_stride_ >>= 1;
  FillRandom(source_data_, source_stride_);
  FillRandom(reference_data_, reference_stride_);
Johann's avatar
Johann committed
276
  CheckSad(UINT_MAX);
Johann's avatar
Johann committed
277
278
279
  source_stride_ = tmp_stride;
}

280
281
282
283
284
285
286
287
288
289
290
291
TEST_P(SADx4Test, ShortSrc) {
  int tmp_stride = source_stride_;
  source_stride_ >>= 1;
  FillRandom(source_data_, source_stride_);
  FillRandom(GetReference(0), reference_stride_);
  FillRandom(GetReference(1), reference_stride_);
  FillRandom(GetReference(2), reference_stride_);
  FillRandom(GetReference(3), reference_stride_);
  CheckSADs();
  source_stride_ = tmp_stride;
}

Johann's avatar
Johann committed
292
293
294
295
296
297
298
299
TEST_P(SADTest, MaxSAD) {
  // Verify that, when max_sad is set, the implementation does not return a
  // value lower than the reference.
  FillConstant(source_data_, source_stride_, 255);
  FillConstant(reference_data_, reference_stride_, 0);
  CheckSad(128);
}

James Zern's avatar
James Zern committed
300
301
using std::tr1::make_tuple;

302
#if CONFIG_VP8_ENCODER
James Zern's avatar
James Zern committed
303
304
305
306
307
const sad_m_by_n_fn_t sad_16x16_c = vp8_sad16x16_c;
const sad_m_by_n_fn_t sad_8x16_c = vp8_sad8x16_c;
const sad_m_by_n_fn_t sad_16x8_c = vp8_sad16x8_c;
const sad_m_by_n_fn_t sad_8x8_c = vp8_sad8x8_c;
const sad_m_by_n_fn_t sad_4x4_c = vp8_sad4x4_c;
308
309
310
311
312
313
314
315
#endif
#if CONFIG_VP9_ENCODER
const sad_m_by_n_fn_t sad_64x64_c_vp9 = vp9_sad64x64_c;
const sad_m_by_n_fn_t sad_32x32_c_vp9 = vp9_sad32x32_c;
const sad_m_by_n_fn_t sad_16x16_c_vp9 = vp9_sad16x16_c;
const sad_m_by_n_fn_t sad_8x16_c_vp9 = vp9_sad8x16_c;
const sad_m_by_n_fn_t sad_16x8_c_vp9 = vp9_sad16x8_c;
const sad_m_by_n_fn_t sad_8x8_c_vp9 = vp9_sad8x8_c;
316
317
const sad_m_by_n_fn_t sad_8x4_c_vp9 = vp9_sad8x4_c;
const sad_m_by_n_fn_t sad_4x8_c_vp9 = vp9_sad4x8_c;
318
319
const sad_m_by_n_fn_t sad_4x4_c_vp9 = vp9_sad4x4_c;
#endif
James Zern's avatar
James Zern committed
320
const sad_m_by_n_test_param_t c_tests[] = {
321
#if CONFIG_VP8_ENCODER
James Zern's avatar
James Zern committed
322
323
324
325
326
  make_tuple(16, 16, sad_16x16_c),
  make_tuple(8, 16, sad_8x16_c),
  make_tuple(16, 8, sad_16x8_c),
  make_tuple(8, 8, sad_8x8_c),
  make_tuple(4, 4, sad_4x4_c),
327
328
#endif
#if CONFIG_VP9_ENCODER
James Zern's avatar
James Zern committed
329
330
331
332
333
334
  make_tuple(64, 64, sad_64x64_c_vp9),
  make_tuple(32, 32, sad_32x32_c_vp9),
  make_tuple(16, 16, sad_16x16_c_vp9),
  make_tuple(8, 16, sad_8x16_c_vp9),
  make_tuple(16, 8, sad_16x8_c_vp9),
  make_tuple(8, 8, sad_8x8_c_vp9),
335
336
  make_tuple(8, 4, sad_8x4_c_vp9),
  make_tuple(4, 8, sad_4x8_c_vp9),
James Zern's avatar
James Zern committed
337
  make_tuple(4, 4, sad_4x4_c_vp9),
338
#endif
James Zern's avatar
James Zern committed
339
340
};
INSTANTIATE_TEST_CASE_P(C, SADTest, ::testing::ValuesIn(c_tests));
Johann's avatar
Johann committed
341

342
343
#if CONFIG_VP9_ENCODER
const sad_n_by_n_by_4_fn_t sad_64x64x4d_c = vp9_sad64x64x4d_c;
344
345
const sad_n_by_n_by_4_fn_t sad_64x32x4d_c = vp9_sad64x32x4d_c;
const sad_n_by_n_by_4_fn_t sad_32x64x4d_c = vp9_sad32x64x4d_c;
346
const sad_n_by_n_by_4_fn_t sad_32x32x4d_c = vp9_sad32x32x4d_c;
347
348
const sad_n_by_n_by_4_fn_t sad_32x16x4d_c = vp9_sad32x16x4d_c;
const sad_n_by_n_by_4_fn_t sad_16x32x4d_c = vp9_sad16x32x4d_c;
349
const sad_n_by_n_by_4_fn_t sad_16x16x4d_c = vp9_sad16x16x4d_c;
350
351
const sad_n_by_n_by_4_fn_t sad_16x8x4d_c = vp9_sad16x8x4d_c;
const sad_n_by_n_by_4_fn_t sad_8x16x4d_c = vp9_sad8x16x4d_c;
352
const sad_n_by_n_by_4_fn_t sad_8x8x4d_c = vp9_sad8x8x4d_c;
353
354
const sad_n_by_n_by_4_fn_t sad_8x4x4d_c = vp9_sad8x4x4d_c;
const sad_n_by_n_by_4_fn_t sad_4x8x4d_c = vp9_sad4x8x4d_c;
355
356
357
const sad_n_by_n_by_4_fn_t sad_4x4x4d_c = vp9_sad4x4x4d_c;
INSTANTIATE_TEST_CASE_P(C, SADx4Test, ::testing::Values(
                        make_tuple(64, 64, sad_64x64x4d_c),
358
359
                        make_tuple(64, 32, sad_64x32x4d_c),
                        make_tuple(32, 64, sad_32x64x4d_c),
360
                        make_tuple(32, 32, sad_32x32x4d_c),
361
362
                        make_tuple(32, 16, sad_32x16x4d_c),
                        make_tuple(16, 32, sad_16x32x4d_c),
363
                        make_tuple(16, 16, sad_16x16x4d_c),
364
365
                        make_tuple(16, 8, sad_16x8x4d_c),
                        make_tuple(8, 16, sad_8x16x4d_c),
366
                        make_tuple(8, 8, sad_8x8x4d_c),
367
368
                        make_tuple(8, 4, sad_8x4x4d_c),
                        make_tuple(4, 8, sad_4x8x4d_c),
369
370
371
                        make_tuple(4, 4, sad_4x4x4d_c)));
#endif

Johann's avatar
Johann committed
372
373
// ARM tests
#if HAVE_MEDIA
James Zern's avatar
James Zern committed
374
const sad_m_by_n_fn_t sad_16x16_armv6 = vp8_sad16x16_armv6;
Johann's avatar
Johann committed
375
INSTANTIATE_TEST_CASE_P(MEDIA, SADTest, ::testing::Values(
James Zern's avatar
James Zern committed
376
                        make_tuple(16, 16, sad_16x16_armv6)));
Johann's avatar
Johann committed
377
378
379

#endif
#if HAVE_NEON
James Zern's avatar
James Zern committed
380
381
382
383
384
const sad_m_by_n_fn_t sad_16x16_neon = vp8_sad16x16_neon;
const sad_m_by_n_fn_t sad_8x16_neon = vp8_sad8x16_neon;
const sad_m_by_n_fn_t sad_16x8_neon = vp8_sad16x8_neon;
const sad_m_by_n_fn_t sad_8x8_neon = vp8_sad8x8_neon;
const sad_m_by_n_fn_t sad_4x4_neon = vp8_sad4x4_neon;
Johann's avatar
Johann committed
385
INSTANTIATE_TEST_CASE_P(NEON, SADTest, ::testing::Values(
James Zern's avatar
James Zern committed
386
387
388
389
390
                        make_tuple(16, 16, sad_16x16_neon),
                        make_tuple(8, 16, sad_8x16_neon),
                        make_tuple(16, 8, sad_16x8_neon),
                        make_tuple(8, 8, sad_8x8_neon),
                        make_tuple(4, 4, sad_4x4_neon)));
Johann's avatar
Johann committed
391
392
393
394
#endif

// X86 tests
#if HAVE_MMX
395
#if CONFIG_VP8_ENCODER
James Zern's avatar
James Zern committed
396
397
398
399
400
const sad_m_by_n_fn_t sad_16x16_mmx = vp8_sad16x16_mmx;
const sad_m_by_n_fn_t sad_8x16_mmx = vp8_sad8x16_mmx;
const sad_m_by_n_fn_t sad_16x8_mmx = vp8_sad16x8_mmx;
const sad_m_by_n_fn_t sad_8x8_mmx = vp8_sad8x8_mmx;
const sad_m_by_n_fn_t sad_4x4_mmx = vp8_sad4x4_mmx;
401
402
403
404
405
406
407
408
409
#endif
#if CONFIG_VP9_ENCODER
const sad_m_by_n_fn_t sad_16x16_mmx_vp9 = vp9_sad16x16_mmx;
const sad_m_by_n_fn_t sad_8x16_mmx_vp9 = vp9_sad8x16_mmx;
const sad_m_by_n_fn_t sad_16x8_mmx_vp9 = vp9_sad16x8_mmx;
const sad_m_by_n_fn_t sad_8x8_mmx_vp9 = vp9_sad8x8_mmx;
const sad_m_by_n_fn_t sad_4x4_mmx_vp9 = vp9_sad4x4_mmx;
#endif

James Zern's avatar
James Zern committed
410
const sad_m_by_n_test_param_t mmx_tests[] = {
411
#if CONFIG_VP8_ENCODER
James Zern's avatar
James Zern committed
412
413
414
415
416
  make_tuple(16, 16, sad_16x16_mmx),
  make_tuple(8, 16, sad_8x16_mmx),
  make_tuple(16, 8, sad_16x8_mmx),
  make_tuple(8, 8, sad_8x8_mmx),
  make_tuple(4, 4, sad_4x4_mmx),
Johann's avatar
Johann committed
417
#endif
418
#if CONFIG_VP9_ENCODER
James Zern's avatar
James Zern committed
419
420
421
422
423
  make_tuple(16, 16, sad_16x16_mmx_vp9),
  make_tuple(8, 16, sad_8x16_mmx_vp9),
  make_tuple(16, 8, sad_16x8_mmx_vp9),
  make_tuple(8, 8, sad_8x8_mmx_vp9),
  make_tuple(4, 4, sad_4x4_mmx_vp9),
424
#endif
James Zern's avatar
James Zern committed
425
426
};
INSTANTIATE_TEST_CASE_P(MMX, SADTest, ::testing::ValuesIn(mmx_tests));
427
428
429
430
431
#endif

#if HAVE_SSE
#if CONFIG_VP9_ENCODER
const sad_m_by_n_fn_t sad_4x4_sse_vp9 = vp9_sad4x4_sse;
432
const sad_m_by_n_fn_t sad_4x8_sse_vp9 = vp9_sad4x8_sse;
433
INSTANTIATE_TEST_CASE_P(SSE, SADTest, ::testing::Values(
434
435
                        make_tuple(4, 4, sad_4x4_sse_vp9),
                        make_tuple(4, 8, sad_4x8_sse_vp9)));
436

437
const sad_n_by_n_by_4_fn_t sad_4x8x4d_sse = vp9_sad4x8x4d_sse;
438
439
const sad_n_by_n_by_4_fn_t sad_4x4x4d_sse = vp9_sad4x4x4d_sse;
INSTANTIATE_TEST_CASE_P(SSE, SADx4Test, ::testing::Values(
440
                        make_tuple(4, 8, sad_4x8x4d_sse),
441
                        make_tuple(4, 4, sad_4x4x4d_sse)));
442
443
444
#endif
#endif

Johann's avatar
Johann committed
445
#if HAVE_SSE2
446
#if CONFIG_VP8_ENCODER
James Zern's avatar
James Zern committed
447
448
449
450
451
const sad_m_by_n_fn_t sad_16x16_wmt = vp8_sad16x16_wmt;
const sad_m_by_n_fn_t sad_8x16_wmt = vp8_sad8x16_wmt;
const sad_m_by_n_fn_t sad_16x8_wmt = vp8_sad16x8_wmt;
const sad_m_by_n_fn_t sad_8x8_wmt = vp8_sad8x8_wmt;
const sad_m_by_n_fn_t sad_4x4_wmt = vp8_sad4x4_wmt;
452
453
454
#endif
#if CONFIG_VP9_ENCODER
const sad_m_by_n_fn_t sad_64x64_sse2_vp9 = vp9_sad64x64_sse2;
455
456
const sad_m_by_n_fn_t sad_64x32_sse2_vp9 = vp9_sad64x32_sse2;
const sad_m_by_n_fn_t sad_32x64_sse2_vp9 = vp9_sad32x64_sse2;
457
const sad_m_by_n_fn_t sad_32x32_sse2_vp9 = vp9_sad32x32_sse2;
458
459
const sad_m_by_n_fn_t sad_32x16_sse2_vp9 = vp9_sad32x16_sse2;
const sad_m_by_n_fn_t sad_16x32_sse2_vp9 = vp9_sad16x32_sse2;
460
461
const sad_m_by_n_fn_t sad_16x16_sse2_vp9 = vp9_sad16x16_sse2;
const sad_m_by_n_fn_t sad_16x8_sse2_vp9 = vp9_sad16x8_sse2;
462
const sad_m_by_n_fn_t sad_8x16_sse2_vp9 = vp9_sad8x16_sse2;
463
const sad_m_by_n_fn_t sad_8x8_sse2_vp9 = vp9_sad8x8_sse2;
464
const sad_m_by_n_fn_t sad_8x4_sse2_vp9 = vp9_sad8x4_sse2;
465
#endif
James Zern's avatar
James Zern committed
466
const sad_m_by_n_test_param_t sse2_tests[] = {
467
#if CONFIG_VP8_ENCODER
James Zern's avatar
James Zern committed
468
469
470
471
472
  make_tuple(16, 16, sad_16x16_wmt),
  make_tuple(8, 16, sad_8x16_wmt),
  make_tuple(16, 8, sad_16x8_wmt),
  make_tuple(8, 8, sad_8x8_wmt),
  make_tuple(4, 4, sad_4x4_wmt),
473
474
#endif
#if CONFIG_VP9_ENCODER
James Zern's avatar
James Zern committed
475
  make_tuple(64, 64, sad_64x64_sse2_vp9),
476
477
  make_tuple(64, 32, sad_64x32_sse2_vp9),
  make_tuple(32, 64, sad_32x64_sse2_vp9),
James Zern's avatar
James Zern committed
478
  make_tuple(32, 32, sad_32x32_sse2_vp9),
479
480
  make_tuple(32, 16, sad_32x16_sse2_vp9),
  make_tuple(16, 32, sad_16x32_sse2_vp9),
James Zern's avatar
James Zern committed
481
482
  make_tuple(16, 16, sad_16x16_sse2_vp9),
  make_tuple(16, 8, sad_16x8_sse2_vp9),
483
  make_tuple(8, 16, sad_8x16_sse2_vp9),
James Zern's avatar
James Zern committed
484
  make_tuple(8, 8, sad_8x8_sse2_vp9),
485
  make_tuple(8, 4, sad_8x4_sse2_vp9),
Johann's avatar
Johann committed
486
#endif
James Zern's avatar
James Zern committed
487
488
};
INSTANTIATE_TEST_CASE_P(SSE2, SADTest, ::testing::ValuesIn(sse2_tests));
489
490
491

#if CONFIG_VP9_ENCODER
const sad_n_by_n_by_4_fn_t sad_64x64x4d_sse2 = vp9_sad64x64x4d_sse2;
492
493
const sad_n_by_n_by_4_fn_t sad_64x32x4d_sse2 = vp9_sad64x32x4d_sse2;
const sad_n_by_n_by_4_fn_t sad_32x64x4d_sse2 = vp9_sad32x64x4d_sse2;
494
const sad_n_by_n_by_4_fn_t sad_32x32x4d_sse2 = vp9_sad32x32x4d_sse2;
495
496
const sad_n_by_n_by_4_fn_t sad_32x16x4d_sse2 = vp9_sad32x16x4d_sse2;
const sad_n_by_n_by_4_fn_t sad_16x32x4d_sse2 = vp9_sad16x32x4d_sse2;
497
498
499
500
const sad_n_by_n_by_4_fn_t sad_16x16x4d_sse2 = vp9_sad16x16x4d_sse2;
const sad_n_by_n_by_4_fn_t sad_16x8x4d_sse2 = vp9_sad16x8x4d_sse2;
const sad_n_by_n_by_4_fn_t sad_8x16x4d_sse2 = vp9_sad8x16x4d_sse2;
const sad_n_by_n_by_4_fn_t sad_8x8x4d_sse2 = vp9_sad8x8x4d_sse2;
501
const sad_n_by_n_by_4_fn_t sad_8x4x4d_sse2 = vp9_sad8x4x4d_sse2;
502
503
INSTANTIATE_TEST_CASE_P(SSE2, SADx4Test, ::testing::Values(
                        make_tuple(64, 64, sad_64x64x4d_sse2),
504
505
                        make_tuple(64, 32, sad_64x32x4d_sse2),
                        make_tuple(32, 64, sad_32x64x4d_sse2),
506
                        make_tuple(32, 32, sad_32x32x4d_sse2),
507
508
                        make_tuple(32, 16, sad_32x16x4d_sse2),
                        make_tuple(16, 32, sad_16x32x4d_sse2),
509
510
511
                        make_tuple(16, 16, sad_16x16x4d_sse2),
                        make_tuple(16, 8, sad_16x8x4d_sse2),
                        make_tuple(8, 16, sad_8x16x4d_sse2),
512
513
                        make_tuple(8, 8, sad_8x8x4d_sse2),
                        make_tuple(8, 4, sad_8x4x4d_sse2)));
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
#endif
#endif

#if HAVE_SSE3
#if CONFIG_VP8_ENCODER
const sad_n_by_n_by_4_fn_t sad_16x16x4d_sse3 = vp8_sad16x16x4d_sse3;
const sad_n_by_n_by_4_fn_t sad_16x8x4d_sse3 = vp8_sad16x8x4d_sse3;
const sad_n_by_n_by_4_fn_t sad_8x16x4d_sse3 = vp8_sad8x16x4d_sse3;
const sad_n_by_n_by_4_fn_t sad_8x8x4d_sse3 = vp8_sad8x8x4d_sse3;
const sad_n_by_n_by_4_fn_t sad_4x4x4d_sse3 = vp8_sad4x4x4d_sse3;
INSTANTIATE_TEST_CASE_P(SSE3, SADx4Test, ::testing::Values(
                        make_tuple(16, 16, sad_16x16x4d_sse3),
                        make_tuple(16, 8, sad_16x8x4d_sse3),
                        make_tuple(8, 16, sad_8x16x4d_sse3),
                        make_tuple(8, 8, sad_8x8x4d_sse3),
                        make_tuple(4, 4, sad_4x4x4d_sse3)));
#endif
531
532
#endif

Johann's avatar
Johann committed
533
#if HAVE_SSSE3
James Zern's avatar
James Zern committed
534
const sad_m_by_n_fn_t sad_16x16_sse3 = vp8_sad16x16_sse3;
Johann's avatar
Johann committed
535
INSTANTIATE_TEST_CASE_P(SSE3, SADTest, ::testing::Values(
James Zern's avatar
James Zern committed
536
                        make_tuple(16, 16, sad_16x16_sse3)));
Johann's avatar
Johann committed
537
538
539
#endif

}  // namespace