1 /*
2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3  *
4  * This source code is subject to the terms of the BSD 2 Clause License and
5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6  * was not distributed with this source code in the LICENSE file, you can
7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8  * Media Patent License 1.0 was not distributed with this source code in the
9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10  */
11 
12 #include <string.h>
13 #include <limits.h>
14 #include <stdio.h>
15 
16 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
17 
18 #include "config/aom_config.h"
19 #include "config/aom_dsp_rtcd.h"
20 
21 #include "test/acm_random.h"
22 #include "test/clear_system_state.h"
23 #include "test/register_state_check.h"
24 #include "test/util.h"
25 #include "aom/aom_codec.h"
26 #include "aom_mem/aom_mem.h"
27 #include "aom_ports/mem.h"
28 
29 typedef unsigned int (*SadMxNFunc)(const uint8_t *src_ptr, int src_stride,
30                                    const uint8_t *ref_ptr, int ref_stride);
31 typedef ::testing::tuple<int, int, SadMxNFunc, int> SadMxNParam;
32 
33 typedef uint32_t (*SadMxNAvgFunc)(const uint8_t *src_ptr, int src_stride,
34                                   const uint8_t *ref_ptr, int ref_stride,
35                                   const uint8_t *second_pred);
36 typedef ::testing::tuple<int, int, SadMxNAvgFunc, int> SadMxNAvgParam;
37 
38 typedef void (*JntCompAvgFunc)(uint8_t *comp_pred, const uint8_t *pred,
39                                int width, int height, const uint8_t *ref,
40                                int ref_stride,
41                                const JNT_COMP_PARAMS *jcp_param);
42 typedef ::testing::tuple<int, int, JntCompAvgFunc, int> JntCompAvgParam;
43 
44 typedef unsigned int (*JntSadMxhFunc)(const uint8_t *src_ptr, int src_stride,
45                                       const uint8_t *ref_ptr, int ref_stride,
46                                       int width, int height);
47 typedef ::testing::tuple<int, int, JntSadMxhFunc, int> JntSadMxhParam;
48 
49 typedef uint32_t (*JntSadMxNAvgFunc)(const uint8_t *src_ptr, int src_stride,
50                                      const uint8_t *ref_ptr, int ref_stride,
51                                      const uint8_t *second_pred,
52                                      const JNT_COMP_PARAMS *jcp_param);
53 typedef ::testing::tuple<int, int, JntSadMxNAvgFunc, int> JntSadMxNAvgParam;
54 
55 typedef void (*SadMxNx4Func)(const uint8_t *src_ptr, int src_stride,
56                              const uint8_t *const ref_ptr[], int ref_stride,
57                              uint32_t *sad_array);
58 typedef ::testing::tuple<int, int, SadMxNx4Func, int> SadMxNx4Param;
59 
60 using libaom_test::ACMRandom;
61 
62 namespace {
63 class SADTestBase : public ::testing::Test {
64  public:
SADTestBase(int width,int height,int bit_depth)65   SADTestBase(int width, int height, int bit_depth)
66       : width_(width), height_(height), bd_(bit_depth) {}
67 
SetUpTestCase()68   static void SetUpTestCase() {
69     source_data8_ = reinterpret_cast<uint8_t *>(
70         aom_memalign(kDataAlignment, kDataBlockSize));
71     reference_data8_ = reinterpret_cast<uint8_t *>(
72         aom_memalign(kDataAlignment, kDataBufferSize));
73     second_pred8_ =
74         reinterpret_cast<uint8_t *>(aom_memalign(kDataAlignment, 128 * 128));
75     comp_pred8_ =
76         reinterpret_cast<uint8_t *>(aom_memalign(kDataAlignment, 128 * 128));
77     comp_pred8_test_ =
78         reinterpret_cast<uint8_t *>(aom_memalign(kDataAlignment, 128 * 128));
79     source_data16_ = reinterpret_cast<uint16_t *>(
80         aom_memalign(kDataAlignment, kDataBlockSize * sizeof(uint16_t)));
81     reference_data16_ = reinterpret_cast<uint16_t *>(
82         aom_memalign(kDataAlignment, kDataBufferSize * sizeof(uint16_t)));
83     second_pred16_ = reinterpret_cast<uint16_t *>(
84         aom_memalign(kDataAlignment, 128 * 128 * sizeof(uint16_t)));
85     comp_pred16_ = reinterpret_cast<uint16_t *>(
86         aom_memalign(kDataAlignment, 128 * 128 * sizeof(uint16_t)));
87     comp_pred16_test_ = reinterpret_cast<uint16_t *>(
88         aom_memalign(kDataAlignment, 128 * 128 * sizeof(uint16_t)));
89   }
90 
TearDownTestCase()91   static void TearDownTestCase() {
92     aom_free(source_data8_);
93     source_data8_ = NULL;
94     aom_free(reference_data8_);
95     reference_data8_ = NULL;
96     aom_free(second_pred8_);
97     second_pred8_ = NULL;
98     aom_free(comp_pred8_);
99     comp_pred8_ = NULL;
100     aom_free(comp_pred8_test_);
101     comp_pred8_test_ = NULL;
102     aom_free(source_data16_);
103     source_data16_ = NULL;
104     aom_free(reference_data16_);
105     reference_data16_ = NULL;
106     aom_free(second_pred16_);
107     second_pred16_ = NULL;
108     aom_free(comp_pred16_);
109     comp_pred16_ = NULL;
110     aom_free(comp_pred16_test_);
111     comp_pred16_test_ = NULL;
112   }
113 
TearDown()114   virtual void TearDown() { libaom_test::ClearSystemState(); }
115 
116  protected:
117   // Handle up to 4 128x128 blocks, with stride up to 256
118   static const int kDataAlignment = 16;
119   static const int kDataBlockSize = 128 * 256;
120   static const int kDataBufferSize = 4 * kDataBlockSize;
121 
SetUp()122   virtual void SetUp() {
123     if (bd_ == -1) {
124       use_high_bit_depth_ = false;
125       bit_depth_ = AOM_BITS_8;
126       source_data_ = source_data8_;
127       reference_data_ = reference_data8_;
128       second_pred_ = second_pred8_;
129       comp_pred_ = comp_pred8_;
130       comp_pred_test_ = comp_pred8_test_;
131     } else {
132       use_high_bit_depth_ = true;
133       bit_depth_ = static_cast<aom_bit_depth_t>(bd_);
134       source_data_ = CONVERT_TO_BYTEPTR(source_data16_);
135       reference_data_ = CONVERT_TO_BYTEPTR(reference_data16_);
136       second_pred_ = CONVERT_TO_BYTEPTR(second_pred16_);
137       comp_pred_ = CONVERT_TO_BYTEPTR(comp_pred16_);
138       comp_pred_test_ = CONVERT_TO_BYTEPTR(comp_pred16_test_);
139     }
140     mask_ = (1 << bit_depth_) - 1;
141     source_stride_ = (width_ + 31) & ~31;
142     reference_stride_ = width_ * 2;
143     rnd_.Reset(ACMRandom::DeterministicSeed());
144   }
145 
GetReference(int block_idx)146   virtual uint8_t *GetReference(int block_idx) {
147     if (use_high_bit_depth_)
148       return CONVERT_TO_BYTEPTR(CONVERT_TO_SHORTPTR(reference_data_) +
149                                 block_idx * kDataBlockSize);
150     return reference_data_ + block_idx * kDataBlockSize;
151   }
152 
153   // Sum of Absolute Differences. Given two blocks, calculate the absolute
154   // difference between two pixels in the same relative location; accumulate.
ReferenceSAD(int block_idx)155   unsigned int ReferenceSAD(int block_idx) {
156     unsigned int sad = 0;
157     const uint8_t *const reference8 = GetReference(block_idx);
158     const uint8_t *const source8 = source_data_;
159     const uint16_t *const reference16 =
160         CONVERT_TO_SHORTPTR(GetReference(block_idx));
161     const uint16_t *const source16 = CONVERT_TO_SHORTPTR(source_data_);
162     for (int h = 0; h < height_; ++h) {
163       for (int w = 0; w < width_; ++w) {
164         if (!use_high_bit_depth_) {
165           sad += abs(source8[h * source_stride_ + w] -
166                      reference8[h * reference_stride_ + w]);
167         } else {
168           sad += abs(source16[h * source_stride_ + w] -
169                      reference16[h * reference_stride_ + w]);
170         }
171       }
172     }
173     return sad;
174   }
175 
176   // Sum of Absolute Differences Average. Given two blocks, and a prediction
177   // calculate the absolute difference between one pixel and average of the
178   // corresponding and predicted pixels; accumulate.
ReferenceSADavg(int block_idx)179   unsigned int ReferenceSADavg(int block_idx) {
180     unsigned int sad = 0;
181     const uint8_t *const reference8 = GetReference(block_idx);
182     const uint8_t *const source8 = source_data_;
183     const uint8_t *const second_pred8 = second_pred_;
184     const uint16_t *const reference16 =
185         CONVERT_TO_SHORTPTR(GetReference(block_idx));
186     const uint16_t *const source16 = CONVERT_TO_SHORTPTR(source_data_);
187     const uint16_t *const second_pred16 = CONVERT_TO_SHORTPTR(second_pred_);
188     for (int h = 0; h < height_; ++h) {
189       for (int w = 0; w < width_; ++w) {
190         if (!use_high_bit_depth_) {
191           const int tmp = second_pred8[h * width_ + w] +
192                           reference8[h * reference_stride_ + w];
193           const uint8_t comp_pred = ROUND_POWER_OF_TWO(tmp, 1);
194           sad += abs(source8[h * source_stride_ + w] - comp_pred);
195         } else {
196           const int tmp = second_pred16[h * width_ + w] +
197                           reference16[h * reference_stride_ + w];
198           const uint16_t comp_pred = ROUND_POWER_OF_TWO(tmp, 1);
199           sad += abs(source16[h * source_stride_ + w] - comp_pred);
200         }
201       }
202     }
203     return sad;
204   }
205 
ReferenceJntCompAvg(int block_idx)206   void ReferenceJntCompAvg(int block_idx) {
207     const uint8_t *const reference8 = GetReference(block_idx);
208     const uint8_t *const second_pred8 = second_pred_;
209     uint8_t *const comp_pred8 = comp_pred_;
210     const uint16_t *const reference16 =
211         CONVERT_TO_SHORTPTR(GetReference(block_idx));
212     const uint16_t *const second_pred16 = CONVERT_TO_SHORTPTR(second_pred_);
213     uint16_t *const comp_pred16 = CONVERT_TO_SHORTPTR(comp_pred_);
214     for (int h = 0; h < height_; ++h) {
215       for (int w = 0; w < width_; ++w) {
216         if (!use_high_bit_depth_) {
217           const int tmp =
218               second_pred8[h * width_ + w] * jcp_param_.bck_offset +
219               reference8[h * reference_stride_ + w] * jcp_param_.fwd_offset;
220           comp_pred8[h * width_ + w] = ROUND_POWER_OF_TWO(tmp, 4);
221         } else {
222           const int tmp =
223               second_pred16[h * width_ + w] * jcp_param_.bck_offset +
224               reference16[h * reference_stride_ + w] * jcp_param_.fwd_offset;
225           comp_pred16[h * width_ + w] = ROUND_POWER_OF_TWO(tmp, 4);
226         }
227       }
228     }
229   }
230 
ReferenceJntSADavg(int block_idx)231   unsigned int ReferenceJntSADavg(int block_idx) {
232     unsigned int sad = 0;
233     const uint8_t *const reference8 = GetReference(block_idx);
234     const uint8_t *const source8 = source_data_;
235     const uint8_t *const second_pred8 = second_pred_;
236     const uint16_t *const reference16 =
237         CONVERT_TO_SHORTPTR(GetReference(block_idx));
238     const uint16_t *const source16 = CONVERT_TO_SHORTPTR(source_data_);
239     const uint16_t *const second_pred16 = CONVERT_TO_SHORTPTR(second_pred_);
240     for (int h = 0; h < height_; ++h) {
241       for (int w = 0; w < width_; ++w) {
242         if (!use_high_bit_depth_) {
243           const int tmp =
244               second_pred8[h * width_ + w] * jcp_param_.bck_offset +
245               reference8[h * reference_stride_ + w] * jcp_param_.fwd_offset;
246           const uint8_t comp_pred = ROUND_POWER_OF_TWO(tmp, 4);
247           sad += abs(source8[h * source_stride_ + w] - comp_pred);
248         } else {
249           const int tmp =
250               second_pred16[h * width_ + w] * jcp_param_.bck_offset +
251               reference16[h * reference_stride_ + w] * jcp_param_.fwd_offset;
252           const uint16_t comp_pred = ROUND_POWER_OF_TWO(tmp, 4);
253           sad += abs(source16[h * source_stride_ + w] - comp_pred);
254         }
255       }
256     }
257     return sad;
258   }
259 
FillConstant(uint8_t * data,int stride,uint16_t fill_constant)260   void FillConstant(uint8_t *data, int stride, uint16_t fill_constant) {
261     uint8_t *data8 = data;
262     uint16_t *data16 = CONVERT_TO_SHORTPTR(data);
263     for (int h = 0; h < height_; ++h) {
264       for (int w = 0; w < width_; ++w) {
265         if (!use_high_bit_depth_) {
266           data8[h * stride + w] = static_cast<uint8_t>(fill_constant);
267         } else {
268           data16[h * stride + w] = fill_constant;
269         }
270       }
271     }
272   }
273 
FillRandom(uint8_t * data,int stride)274   void FillRandom(uint8_t *data, int stride) {
275     uint8_t *data8 = data;
276     uint16_t *data16 = CONVERT_TO_SHORTPTR(data);
277     for (int h = 0; h < height_; ++h) {
278       for (int w = 0; w < width_; ++w) {
279         if (!use_high_bit_depth_) {
280           data8[h * stride + w] = rnd_.Rand8();
281         } else {
282           data16[h * stride + w] = rnd_.Rand16() & mask_;
283         }
284       }
285     }
286   }
287 
288   int width_, height_, mask_, bd_;
289   aom_bit_depth_t bit_depth_;
290   static uint8_t *source_data_;
291   static uint8_t *reference_data_;
292   static uint8_t *second_pred_;
293   int source_stride_;
294   bool use_high_bit_depth_;
295   static uint8_t *source_data8_;
296   static uint8_t *reference_data8_;
297   static uint8_t *second_pred8_;
298   static uint16_t *source_data16_;
299   static uint16_t *reference_data16_;
300   static uint16_t *second_pred16_;
301   int reference_stride_;
302   static uint8_t *comp_pred_;
303   static uint8_t *comp_pred8_;
304   static uint16_t *comp_pred16_;
305   static uint8_t *comp_pred_test_;
306   static uint8_t *comp_pred8_test_;
307   static uint16_t *comp_pred16_test_;
308   JNT_COMP_PARAMS jcp_param_;
309 
310   ACMRandom rnd_;
311 };
312 
313 class SADx4Test : public ::testing::WithParamInterface<SadMxNx4Param>,
314                   public SADTestBase {
315  public:
SADx4Test()316   SADx4Test() : SADTestBase(GET_PARAM(0), GET_PARAM(1), GET_PARAM(3)) {}
317 
318  protected:
SADs(unsigned int * results)319   void SADs(unsigned int *results) {
320     const uint8_t *references[] = { GetReference(0), GetReference(1),
321                                     GetReference(2), GetReference(3) };
322 
323     ASM_REGISTER_STATE_CHECK(GET_PARAM(2)(
324         source_data_, source_stride_, references, reference_stride_, results));
325   }
326 
CheckSADs()327   void CheckSADs() {
328     unsigned int reference_sad, exp_sad[4];
329 
330     SADs(exp_sad);
331     for (int block = 0; block < 4; ++block) {
332       reference_sad = ReferenceSAD(block);
333 
334       EXPECT_EQ(reference_sad, exp_sad[block]) << "block " << block;
335     }
336   }
337 };
338 
339 class SADTest : public ::testing::WithParamInterface<SadMxNParam>,
340                 public SADTestBase {
341  public:
SADTest()342   SADTest() : SADTestBase(GET_PARAM(0), GET_PARAM(1), GET_PARAM(3)) {}
343 
344  protected:
SAD(int block_idx)345   unsigned int SAD(int block_idx) {
346     unsigned int ret;
347     const uint8_t *const reference = GetReference(block_idx);
348 
349     ASM_REGISTER_STATE_CHECK(ret = GET_PARAM(2)(source_data_, source_stride_,
350                                                 reference, reference_stride_));
351     return ret;
352   }
353 
CheckSAD()354   void CheckSAD() {
355     const unsigned int reference_sad = ReferenceSAD(0);
356     const unsigned int exp_sad = SAD(0);
357 
358     ASSERT_EQ(reference_sad, exp_sad);
359   }
360 
SpeedSAD()361   void SpeedSAD() {
362     int test_count = 20000000;
363     while (test_count > 0) {
364       SAD(0);
365       test_count -= 1;
366     }
367   }
368 };
369 
370 class SADavgTest : public ::testing::WithParamInterface<SadMxNAvgParam>,
371                    public SADTestBase {
372  public:
SADavgTest()373   SADavgTest() : SADTestBase(GET_PARAM(0), GET_PARAM(1), GET_PARAM(3)) {}
374 
375  protected:
SAD_avg(int block_idx)376   unsigned int SAD_avg(int block_idx) {
377     unsigned int ret;
378     const uint8_t *const reference = GetReference(block_idx);
379 
380     ASM_REGISTER_STATE_CHECK(ret = GET_PARAM(2)(source_data_, source_stride_,
381                                                 reference, reference_stride_,
382                                                 second_pred_));
383     return ret;
384   }
385 
CheckSAD()386   void CheckSAD() {
387     const unsigned int reference_sad = ReferenceSADavg(0);
388     const unsigned int exp_sad = SAD_avg(0);
389 
390     ASSERT_EQ(reference_sad, exp_sad);
391   }
392 };
393 
394 class JntCompAvgTest : public ::testing::WithParamInterface<JntCompAvgParam>,
395                        public SADTestBase {
396  public:
JntCompAvgTest()397   JntCompAvgTest() : SADTestBase(GET_PARAM(0), GET_PARAM(1), GET_PARAM(3)) {}
398 
399  protected:
jnt_comp_avg(int block_idx)400   void jnt_comp_avg(int block_idx) {
401     const uint8_t *const reference = GetReference(block_idx);
402 
403     ASM_REGISTER_STATE_CHECK(GET_PARAM(2)(comp_pred_test_, second_pred_, width_,
404                                           height_, reference, reference_stride_,
405                                           &jcp_param_));
406   }
407 
CheckCompAvg()408   void CheckCompAvg() {
409     for (int j = 0; j < 2; ++j) {
410       for (int i = 0; i < 4; ++i) {
411         jcp_param_.fwd_offset = quant_dist_lookup_table[j][i][0];
412         jcp_param_.bck_offset = quant_dist_lookup_table[j][i][1];
413 
414         ReferenceJntCompAvg(0);
415         jnt_comp_avg(0);
416 
417         for (int y = 0; y < height_; ++y)
418           for (int x = 0; x < width_; ++x)
419             ASSERT_EQ(comp_pred_[y * width_ + x],
420                       comp_pred_test_[y * width_ + x]);
421       }
422     }
423   }
424 };
425 
426 class JntSADTest : public ::testing::WithParamInterface<JntSadMxhParam>,
427                    public SADTestBase {
428  public:
JntSADTest()429   JntSADTest() : SADTestBase(GET_PARAM(0), GET_PARAM(1), GET_PARAM(3)) {}
430 
431  protected:
SAD(int block_idx)432   unsigned int SAD(int block_idx) {
433     unsigned int ret;
434     const uint8_t *const reference = GetReference(block_idx);
435 
436     ASM_REGISTER_STATE_CHECK(ret = GET_PARAM(2)(source_data_, source_stride_,
437                                                 reference, reference_stride_,
438                                                 GET_PARAM(0), GET_PARAM(1)));
439     return ret;
440   }
441 
CheckSAD()442   void CheckSAD() {
443     const unsigned int reference_sad = ReferenceSAD(0);
444     const unsigned int exp_sad = SAD(0);
445 
446     ASSERT_EQ(reference_sad, exp_sad);
447   }
448 
SpeedSAD()449   void SpeedSAD() {
450     int test_count = 20000000;
451     while (test_count > 0) {
452       SAD(0);
453       test_count -= 1;
454     }
455   }
456 };
457 
458 class JntSADavgTest : public ::testing::WithParamInterface<JntSadMxNAvgParam>,
459                       public SADTestBase {
460  public:
JntSADavgTest()461   JntSADavgTest() : SADTestBase(GET_PARAM(0), GET_PARAM(1), GET_PARAM(3)) {}
462 
463  protected:
jnt_SAD_avg(int block_idx)464   unsigned int jnt_SAD_avg(int block_idx) {
465     unsigned int ret;
466     const uint8_t *const reference = GetReference(block_idx);
467 
468     ASM_REGISTER_STATE_CHECK(ret = GET_PARAM(2)(source_data_, source_stride_,
469                                                 reference, reference_stride_,
470                                                 second_pred_, &jcp_param_));
471     return ret;
472   }
473 
CheckSAD()474   void CheckSAD() {
475     for (int j = 0; j < 2; ++j) {
476       for (int i = 0; i < 4; ++i) {
477         jcp_param_.fwd_offset = quant_dist_lookup_table[j][i][0];
478         jcp_param_.bck_offset = quant_dist_lookup_table[j][i][1];
479 
480         const unsigned int reference_sad = ReferenceJntSADavg(0);
481         const unsigned int exp_sad = jnt_SAD_avg(0);
482 
483         ASSERT_EQ(reference_sad, exp_sad);
484       }
485     }
486   }
487 };
488 
489 uint8_t *SADTestBase::source_data_ = NULL;
490 uint8_t *SADTestBase::reference_data_ = NULL;
491 uint8_t *SADTestBase::second_pred_ = NULL;
492 uint8_t *SADTestBase::comp_pred_ = NULL;
493 uint8_t *SADTestBase::comp_pred_test_ = NULL;
494 uint8_t *SADTestBase::source_data8_ = NULL;
495 uint8_t *SADTestBase::reference_data8_ = NULL;
496 uint8_t *SADTestBase::second_pred8_ = NULL;
497 uint8_t *SADTestBase::comp_pred8_ = NULL;
498 uint8_t *SADTestBase::comp_pred8_test_ = NULL;
499 uint16_t *SADTestBase::source_data16_ = NULL;
500 uint16_t *SADTestBase::reference_data16_ = NULL;
501 uint16_t *SADTestBase::second_pred16_ = NULL;
502 uint16_t *SADTestBase::comp_pred16_ = NULL;
503 uint16_t *SADTestBase::comp_pred16_test_ = NULL;
504 
TEST_P(SADTest,MaxRef)505 TEST_P(SADTest, MaxRef) {
506   FillConstant(source_data_, source_stride_, 0);
507   FillConstant(reference_data_, reference_stride_, mask_);
508   CheckSAD();
509 }
510 
TEST_P(SADTest,MaxSrc)511 TEST_P(SADTest, MaxSrc) {
512   FillConstant(source_data_, source_stride_, mask_);
513   FillConstant(reference_data_, reference_stride_, 0);
514   CheckSAD();
515 }
516 
TEST_P(SADTest,ShortRef)517 TEST_P(SADTest, ShortRef) {
518   const int tmp_stride = reference_stride_;
519   reference_stride_ >>= 1;
520   FillRandom(source_data_, source_stride_);
521   FillRandom(reference_data_, reference_stride_);
522   CheckSAD();
523   reference_stride_ = tmp_stride;
524 }
525 
TEST_P(SADTest,UnalignedRef)526 TEST_P(SADTest, UnalignedRef) {
527   // The reference frame, but not the source frame, may be unaligned for
528   // certain types of searches.
529   const int tmp_stride = reference_stride_;
530   reference_stride_ -= 1;
531   FillRandom(source_data_, source_stride_);
532   FillRandom(reference_data_, reference_stride_);
533   CheckSAD();
534   reference_stride_ = tmp_stride;
535 }
536 
TEST_P(SADTest,ShortSrc)537 TEST_P(SADTest, ShortSrc) {
538   const int tmp_stride = source_stride_;
539   source_stride_ >>= 1;
540   int test_count = 2000;
541   while (test_count > 0) {
542     FillRandom(source_data_, source_stride_);
543     FillRandom(reference_data_, reference_stride_);
544     CheckSAD();
545     test_count -= 1;
546   }
547   source_stride_ = tmp_stride;
548 }
549 
550 #define SPEED_TEST (0)
551 #if SPEED_TEST
TEST_P(SADTest,Speed)552 TEST_P(SADTest, Speed) {
553   const int tmp_stride = source_stride_;
554   source_stride_ >>= 1;
555   FillRandom(source_data_, source_stride_);
556   FillRandom(reference_data_, reference_stride_);
557   SpeedSAD();
558   source_stride_ = tmp_stride;
559 }
560 #endif
561 
TEST_P(SADavgTest,MaxRef)562 TEST_P(SADavgTest, MaxRef) {
563   FillConstant(source_data_, source_stride_, 0);
564   FillConstant(reference_data_, reference_stride_, mask_);
565   FillConstant(second_pred_, width_, 0);
566   CheckSAD();
567 }
TEST_P(SADavgTest,MaxSrc)568 TEST_P(SADavgTest, MaxSrc) {
569   FillConstant(source_data_, source_stride_, mask_);
570   FillConstant(reference_data_, reference_stride_, 0);
571   FillConstant(second_pred_, width_, 0);
572   CheckSAD();
573 }
574 
TEST_P(SADavgTest,ShortRef)575 TEST_P(SADavgTest, ShortRef) {
576   const int tmp_stride = reference_stride_;
577   reference_stride_ >>= 1;
578   FillRandom(source_data_, source_stride_);
579   FillRandom(reference_data_, reference_stride_);
580   FillRandom(second_pred_, width_);
581   CheckSAD();
582   reference_stride_ = tmp_stride;
583 }
584 
TEST_P(SADavgTest,UnalignedRef)585 TEST_P(SADavgTest, UnalignedRef) {
586   // The reference frame, but not the source frame, may be unaligned for
587   // certain types of searches.
588   const int tmp_stride = reference_stride_;
589   reference_stride_ -= 1;
590   FillRandom(source_data_, source_stride_);
591   FillRandom(reference_data_, reference_stride_);
592   FillRandom(second_pred_, width_);
593   CheckSAD();
594   reference_stride_ = tmp_stride;
595 }
596 
TEST_P(SADavgTest,ShortSrc)597 TEST_P(SADavgTest, ShortSrc) {
598   const int tmp_stride = source_stride_;
599   source_stride_ >>= 1;
600   int test_count = 2000;
601   while (test_count > 0) {
602     FillRandom(source_data_, source_stride_);
603     FillRandom(reference_data_, reference_stride_);
604     FillRandom(second_pred_, width_);
605     CheckSAD();
606     test_count -= 1;
607   }
608   source_stride_ = tmp_stride;
609 }
610 
TEST_P(JntCompAvgTest,MaxRef)611 TEST_P(JntCompAvgTest, MaxRef) {
612   FillConstant(reference_data_, reference_stride_, mask_);
613   FillConstant(second_pred_, width_, 0);
614   CheckCompAvg();
615 }
616 
TEST_P(JntCompAvgTest,MaxSecondPred)617 TEST_P(JntCompAvgTest, MaxSecondPred) {
618   FillConstant(reference_data_, reference_stride_, 0);
619   FillConstant(second_pred_, width_, mask_);
620   CheckCompAvg();
621 }
622 
TEST_P(JntCompAvgTest,ShortRef)623 TEST_P(JntCompAvgTest, ShortRef) {
624   const int tmp_stride = reference_stride_;
625   reference_stride_ >>= 1;
626   FillRandom(reference_data_, reference_stride_);
627   FillRandom(second_pred_, width_);
628   CheckCompAvg();
629   reference_stride_ = tmp_stride;
630 }
631 
TEST_P(JntCompAvgTest,UnalignedRef)632 TEST_P(JntCompAvgTest, UnalignedRef) {
633   // The reference frame, but not the source frame, may be unaligned for
634   // certain types of searches.
635   const int tmp_stride = reference_stride_;
636   reference_stride_ -= 1;
637   FillRandom(reference_data_, reference_stride_);
638   FillRandom(second_pred_, width_);
639   CheckCompAvg();
640   reference_stride_ = tmp_stride;
641 }
642 
TEST_P(JntSADTest,MaxRef)643 TEST_P(JntSADTest, MaxRef) {
644   FillConstant(source_data_, source_stride_, 0);
645   FillConstant(reference_data_, reference_stride_, mask_);
646   CheckSAD();
647 }
648 
TEST_P(JntSADTest,MaxSrc)649 TEST_P(JntSADTest, MaxSrc) {
650   FillConstant(source_data_, source_stride_, mask_);
651   FillConstant(reference_data_, reference_stride_, 0);
652   CheckSAD();
653 }
654 
TEST_P(JntSADTest,ShortRef)655 TEST_P(JntSADTest, ShortRef) {
656   const int tmp_stride = reference_stride_;
657   reference_stride_ >>= 1;
658   FillRandom(source_data_, source_stride_);
659   FillRandom(reference_data_, reference_stride_);
660   CheckSAD();
661   reference_stride_ = tmp_stride;
662 }
663 
TEST_P(JntSADTest,UnalignedRef)664 TEST_P(JntSADTest, UnalignedRef) {
665   // The reference frame, but not the source frame, may be unaligned for
666   // certain types of searches.
667   const int tmp_stride = reference_stride_;
668   reference_stride_ -= 1;
669   FillRandom(source_data_, source_stride_);
670   FillRandom(reference_data_, reference_stride_);
671   CheckSAD();
672   reference_stride_ = tmp_stride;
673 }
674 
TEST_P(JntSADTest,ShortSrc)675 TEST_P(JntSADTest, ShortSrc) {
676   const int tmp_stride = source_stride_;
677   source_stride_ >>= 1;
678   int test_count = 2000;
679   while (test_count > 0) {
680     FillRandom(source_data_, source_stride_);
681     FillRandom(reference_data_, reference_stride_);
682     CheckSAD();
683     test_count -= 1;
684   }
685   source_stride_ = tmp_stride;
686 }
687 
TEST_P(JntSADavgTest,MaxRef)688 TEST_P(JntSADavgTest, MaxRef) {
689   FillConstant(source_data_, source_stride_, 0);
690   FillConstant(reference_data_, reference_stride_, mask_);
691   FillConstant(second_pred_, width_, 0);
692   CheckSAD();
693 }
TEST_P(JntSADavgTest,MaxSrc)694 TEST_P(JntSADavgTest, MaxSrc) {
695   FillConstant(source_data_, source_stride_, mask_);
696   FillConstant(reference_data_, reference_stride_, 0);
697   FillConstant(second_pred_, width_, 0);
698   CheckSAD();
699 }
700 
TEST_P(JntSADavgTest,ShortRef)701 TEST_P(JntSADavgTest, ShortRef) {
702   const int tmp_stride = reference_stride_;
703   reference_stride_ >>= 1;
704   FillRandom(source_data_, source_stride_);
705   FillRandom(reference_data_, reference_stride_);
706   FillRandom(second_pred_, width_);
707   CheckSAD();
708   reference_stride_ = tmp_stride;
709 }
710 
TEST_P(JntSADavgTest,UnalignedRef)711 TEST_P(JntSADavgTest, UnalignedRef) {
712   // The reference frame, but not the source frame, may be unaligned for
713   // certain types of searches.
714   const int tmp_stride = reference_stride_;
715   reference_stride_ -= 1;
716   FillRandom(source_data_, source_stride_);
717   FillRandom(reference_data_, reference_stride_);
718   FillRandom(second_pred_, width_);
719   CheckSAD();
720   reference_stride_ = tmp_stride;
721 }
722 
TEST_P(JntSADavgTest,ShortSrc)723 TEST_P(JntSADavgTest, ShortSrc) {
724   const int tmp_stride = source_stride_;
725   source_stride_ >>= 1;
726   int test_count = 2000;
727   while (test_count > 0) {
728     FillRandom(source_data_, source_stride_);
729     FillRandom(reference_data_, reference_stride_);
730     FillRandom(second_pred_, width_);
731     CheckSAD();
732     test_count -= 1;
733   }
734   source_stride_ = tmp_stride;
735 }
736 
TEST_P(SADx4Test,MaxRef)737 TEST_P(SADx4Test, MaxRef) {
738   FillConstant(source_data_, source_stride_, 0);
739   FillConstant(GetReference(0), reference_stride_, mask_);
740   FillConstant(GetReference(1), reference_stride_, mask_);
741   FillConstant(GetReference(2), reference_stride_, mask_);
742   FillConstant(GetReference(3), reference_stride_, mask_);
743   CheckSADs();
744 }
745 
TEST_P(SADx4Test,MaxSrc)746 TEST_P(SADx4Test, MaxSrc) {
747   FillConstant(source_data_, source_stride_, mask_);
748   FillConstant(GetReference(0), reference_stride_, 0);
749   FillConstant(GetReference(1), reference_stride_, 0);
750   FillConstant(GetReference(2), reference_stride_, 0);
751   FillConstant(GetReference(3), reference_stride_, 0);
752   CheckSADs();
753 }
754 
TEST_P(SADx4Test,ShortRef)755 TEST_P(SADx4Test, ShortRef) {
756   int tmp_stride = reference_stride_;
757   reference_stride_ >>= 1;
758   FillRandom(source_data_, source_stride_);
759   FillRandom(GetReference(0), reference_stride_);
760   FillRandom(GetReference(1), reference_stride_);
761   FillRandom(GetReference(2), reference_stride_);
762   FillRandom(GetReference(3), reference_stride_);
763   CheckSADs();
764   reference_stride_ = tmp_stride;
765 }
766 
TEST_P(SADx4Test,UnalignedRef)767 TEST_P(SADx4Test, UnalignedRef) {
768   // The reference frame, but not the source frame, may be unaligned for
769   // certain types of searches.
770   int tmp_stride = reference_stride_;
771   reference_stride_ -= 1;
772   FillRandom(source_data_, source_stride_);
773   FillRandom(GetReference(0), reference_stride_);
774   FillRandom(GetReference(1), reference_stride_);
775   FillRandom(GetReference(2), reference_stride_);
776   FillRandom(GetReference(3), reference_stride_);
777   CheckSADs();
778   reference_stride_ = tmp_stride;
779 }
780 
TEST_P(SADx4Test,ShortSrc)781 TEST_P(SADx4Test, ShortSrc) {
782   int tmp_stride = source_stride_;
783   source_stride_ >>= 1;
784   int test_count = 1000;
785   while (test_count > 0) {
786     FillRandom(source_data_, source_stride_);
787     FillRandom(GetReference(0), reference_stride_);
788     FillRandom(GetReference(1), reference_stride_);
789     FillRandom(GetReference(2), reference_stride_);
790     FillRandom(GetReference(3), reference_stride_);
791     CheckSADs();
792     test_count -= 1;
793   }
794   source_stride_ = tmp_stride;
795 }
796 
TEST_P(SADx4Test,SrcAlignedByWidth)797 TEST_P(SADx4Test, SrcAlignedByWidth) {
798   uint8_t *tmp_source_data = source_data_;
799   source_data_ += width_;
800   FillRandom(source_data_, source_stride_);
801   FillRandom(GetReference(0), reference_stride_);
802   FillRandom(GetReference(1), reference_stride_);
803   FillRandom(GetReference(2), reference_stride_);
804   FillRandom(GetReference(3), reference_stride_);
805   CheckSADs();
806   source_data_ = tmp_source_data;
807 }
808 
809 using ::testing::make_tuple;
810 
811 //------------------------------------------------------------------------------
812 // C functions
813 const SadMxNParam c_tests[] = {
814   make_tuple(128, 128, &aom_sad128x128_c, -1),
815   make_tuple(128, 64, &aom_sad128x64_c, -1),
816   make_tuple(64, 128, &aom_sad64x128_c, -1),
817   make_tuple(64, 64, &aom_sad64x64_c, -1),
818   make_tuple(64, 32, &aom_sad64x32_c, -1),
819   make_tuple(32, 64, &aom_sad32x64_c, -1),
820   make_tuple(32, 32, &aom_sad32x32_c, -1),
821   make_tuple(32, 16, &aom_sad32x16_c, -1),
822   make_tuple(16, 32, &aom_sad16x32_c, -1),
823   make_tuple(16, 16, &aom_sad16x16_c, -1),
824   make_tuple(16, 8, &aom_sad16x8_c, -1),
825   make_tuple(8, 16, &aom_sad8x16_c, -1),
826   make_tuple(8, 8, &aom_sad8x8_c, -1),
827   make_tuple(8, 4, &aom_sad8x4_c, -1),
828   make_tuple(4, 8, &aom_sad4x8_c, -1),
829   make_tuple(4, 4, &aom_sad4x4_c, -1),
830   make_tuple(128, 128, &aom_highbd_sad128x128_c, 8),
831   make_tuple(128, 64, &aom_highbd_sad128x64_c, 8),
832   make_tuple(64, 128, &aom_highbd_sad64x128_c, 8),
833   make_tuple(64, 64, &aom_highbd_sad64x64_c, 8),
834   make_tuple(64, 32, &aom_highbd_sad64x32_c, 8),
835   make_tuple(32, 64, &aom_highbd_sad32x64_c, 8),
836   make_tuple(32, 32, &aom_highbd_sad32x32_c, 8),
837   make_tuple(32, 16, &aom_highbd_sad32x16_c, 8),
838   make_tuple(16, 32, &aom_highbd_sad16x32_c, 8),
839   make_tuple(16, 16, &aom_highbd_sad16x16_c, 8),
840   make_tuple(16, 8, &aom_highbd_sad16x8_c, 8),
841   make_tuple(8, 16, &aom_highbd_sad8x16_c, 8),
842   make_tuple(8, 8, &aom_highbd_sad8x8_c, 8),
843   make_tuple(8, 4, &aom_highbd_sad8x4_c, 8),
844   make_tuple(4, 8, &aom_highbd_sad4x8_c, 8),
845   make_tuple(4, 4, &aom_highbd_sad4x4_c, 8),
846   make_tuple(128, 128, &aom_highbd_sad128x128_c, 10),
847   make_tuple(128, 64, &aom_highbd_sad128x64_c, 10),
848   make_tuple(64, 128, &aom_highbd_sad64x128_c, 10),
849   make_tuple(64, 64, &aom_highbd_sad64x64_c, 10),
850   make_tuple(64, 32, &aom_highbd_sad64x32_c, 10),
851   make_tuple(32, 64, &aom_highbd_sad32x64_c, 10),
852   make_tuple(32, 32, &aom_highbd_sad32x32_c, 10),
853   make_tuple(32, 16, &aom_highbd_sad32x16_c, 10),
854   make_tuple(16, 32, &aom_highbd_sad16x32_c, 10),
855   make_tuple(16, 16, &aom_highbd_sad16x16_c, 10),
856   make_tuple(16, 8, &aom_highbd_sad16x8_c, 10),
857   make_tuple(8, 16, &aom_highbd_sad8x16_c, 10),
858   make_tuple(8, 8, &aom_highbd_sad8x8_c, 10),
859   make_tuple(8, 4, &aom_highbd_sad8x4_c, 10),
860   make_tuple(4, 8, &aom_highbd_sad4x8_c, 10),
861   make_tuple(4, 4, &aom_highbd_sad4x4_c, 10),
862   make_tuple(128, 128, &aom_highbd_sad128x128_c, 12),
863   make_tuple(128, 64, &aom_highbd_sad128x64_c, 12),
864   make_tuple(64, 128, &aom_highbd_sad64x128_c, 12),
865   make_tuple(64, 64, &aom_highbd_sad64x64_c, 12),
866   make_tuple(64, 32, &aom_highbd_sad64x32_c, 12),
867   make_tuple(32, 64, &aom_highbd_sad32x64_c, 12),
868   make_tuple(32, 32, &aom_highbd_sad32x32_c, 12),
869   make_tuple(32, 16, &aom_highbd_sad32x16_c, 12),
870   make_tuple(16, 32, &aom_highbd_sad16x32_c, 12),
871   make_tuple(16, 16, &aom_highbd_sad16x16_c, 12),
872   make_tuple(16, 8, &aom_highbd_sad16x8_c, 12),
873   make_tuple(8, 16, &aom_highbd_sad8x16_c, 12),
874   make_tuple(8, 8, &aom_highbd_sad8x8_c, 12),
875   make_tuple(8, 4, &aom_highbd_sad8x4_c, 12),
876   make_tuple(4, 8, &aom_highbd_sad4x8_c, 12),
877   make_tuple(4, 4, &aom_highbd_sad4x4_c, 12),
878 };
879 INSTANTIATE_TEST_CASE_P(C, SADTest, ::testing::ValuesIn(c_tests));
880 
881 const SadMxNAvgParam avg_c_tests[] = {
882   make_tuple(128, 128, &aom_sad128x128_avg_c, -1),
883   make_tuple(128, 64, &aom_sad128x64_avg_c, -1),
884   make_tuple(64, 128, &aom_sad64x128_avg_c, -1),
885   make_tuple(64, 64, &aom_sad64x64_avg_c, -1),
886   make_tuple(64, 32, &aom_sad64x32_avg_c, -1),
887   make_tuple(32, 64, &aom_sad32x64_avg_c, -1),
888   make_tuple(32, 32, &aom_sad32x32_avg_c, -1),
889   make_tuple(32, 16, &aom_sad32x16_avg_c, -1),
890   make_tuple(16, 32, &aom_sad16x32_avg_c, -1),
891   make_tuple(16, 16, &aom_sad16x16_avg_c, -1),
892   make_tuple(16, 8, &aom_sad16x8_avg_c, -1),
893   make_tuple(8, 16, &aom_sad8x16_avg_c, -1),
894   make_tuple(8, 8, &aom_sad8x8_avg_c, -1),
895   make_tuple(8, 4, &aom_sad8x4_avg_c, -1),
896   make_tuple(4, 8, &aom_sad4x8_avg_c, -1),
897   make_tuple(4, 4, &aom_sad4x4_avg_c, -1),
898   make_tuple(128, 128, &aom_highbd_sad128x128_avg_c, 8),
899   make_tuple(128, 64, &aom_highbd_sad128x64_avg_c, 8),
900   make_tuple(64, 128, &aom_highbd_sad64x128_avg_c, 8),
901   make_tuple(64, 64, &aom_highbd_sad64x64_avg_c, 8),
902   make_tuple(64, 32, &aom_highbd_sad64x32_avg_c, 8),
903   make_tuple(32, 64, &aom_highbd_sad32x64_avg_c, 8),
904   make_tuple(32, 32, &aom_highbd_sad32x32_avg_c, 8),
905   make_tuple(32, 16, &aom_highbd_sad32x16_avg_c, 8),
906   make_tuple(16, 32, &aom_highbd_sad16x32_avg_c, 8),
907   make_tuple(16, 16, &aom_highbd_sad16x16_avg_c, 8),
908   make_tuple(16, 8, &aom_highbd_sad16x8_avg_c, 8),
909   make_tuple(8, 16, &aom_highbd_sad8x16_avg_c, 8),
910   make_tuple(8, 8, &aom_highbd_sad8x8_avg_c, 8),
911   make_tuple(8, 4, &aom_highbd_sad8x4_avg_c, 8),
912   make_tuple(4, 8, &aom_highbd_sad4x8_avg_c, 8),
913   make_tuple(4, 4, &aom_highbd_sad4x4_avg_c, 8),
914   make_tuple(128, 128, &aom_highbd_sad128x128_avg_c, 10),
915   make_tuple(128, 64, &aom_highbd_sad128x64_avg_c, 10),
916   make_tuple(64, 128, &aom_highbd_sad64x128_avg_c, 10),
917   make_tuple(64, 64, &aom_highbd_sad64x64_avg_c, 10),
918   make_tuple(64, 32, &aom_highbd_sad64x32_avg_c, 10),
919   make_tuple(32, 64, &aom_highbd_sad32x64_avg_c, 10),
920   make_tuple(32, 32, &aom_highbd_sad32x32_avg_c, 10),
921   make_tuple(32, 16, &aom_highbd_sad32x16_avg_c, 10),
922   make_tuple(16, 32, &aom_highbd_sad16x32_avg_c, 10),
923   make_tuple(16, 16, &aom_highbd_sad16x16_avg_c, 10),
924   make_tuple(16, 8, &aom_highbd_sad16x8_avg_c, 10),
925   make_tuple(8, 16, &aom_highbd_sad8x16_avg_c, 10),
926   make_tuple(8, 8, &aom_highbd_sad8x8_avg_c, 10),
927   make_tuple(8, 4, &aom_highbd_sad8x4_avg_c, 10),
928   make_tuple(4, 8, &aom_highbd_sad4x8_avg_c, 10),
929   make_tuple(4, 4, &aom_highbd_sad4x4_avg_c, 10),
930   make_tuple(128, 128, &aom_highbd_sad128x128_avg_c, 12),
931   make_tuple(128, 64, &aom_highbd_sad128x64_avg_c, 12),
932   make_tuple(64, 128, &aom_highbd_sad64x128_avg_c, 12),
933   make_tuple(64, 64, &aom_highbd_sad64x64_avg_c, 12),
934   make_tuple(64, 32, &aom_highbd_sad64x32_avg_c, 12),
935   make_tuple(32, 64, &aom_highbd_sad32x64_avg_c, 12),
936   make_tuple(32, 32, &aom_highbd_sad32x32_avg_c, 12),
937   make_tuple(32, 16, &aom_highbd_sad32x16_avg_c, 12),
938   make_tuple(16, 32, &aom_highbd_sad16x32_avg_c, 12),
939   make_tuple(16, 16, &aom_highbd_sad16x16_avg_c, 12),
940   make_tuple(16, 8, &aom_highbd_sad16x8_avg_c, 12),
941   make_tuple(8, 16, &aom_highbd_sad8x16_avg_c, 12),
942   make_tuple(8, 8, &aom_highbd_sad8x8_avg_c, 12),
943   make_tuple(8, 4, &aom_highbd_sad8x4_avg_c, 12),
944   make_tuple(4, 8, &aom_highbd_sad4x8_avg_c, 12),
945   make_tuple(4, 4, &aom_highbd_sad4x4_avg_c, 12),
946 };
947 INSTANTIATE_TEST_CASE_P(C, SADavgTest, ::testing::ValuesIn(avg_c_tests));
948 
949 // TODO(chengchen): add highbd tests
950 const JntCompAvgParam jnt_comp_avg_c_tests[] = {
951   make_tuple(128, 128, &aom_jnt_comp_avg_pred_c, -1),
952   make_tuple(128, 64, &aom_jnt_comp_avg_pred_c, -1),
953   make_tuple(64, 128, &aom_jnt_comp_avg_pred_c, -1),
954   make_tuple(64, 64, &aom_jnt_comp_avg_pred_c, -1),
955   make_tuple(64, 32, &aom_jnt_comp_avg_pred_c, -1),
956   make_tuple(32, 64, &aom_jnt_comp_avg_pred_c, -1),
957   make_tuple(32, 32, &aom_jnt_comp_avg_pred_c, -1),
958   make_tuple(32, 16, &aom_jnt_comp_avg_pred_c, -1),
959   make_tuple(16, 32, &aom_jnt_comp_avg_pred_c, -1),
960   make_tuple(16, 16, &aom_jnt_comp_avg_pred_c, -1),
961   make_tuple(16, 8, &aom_jnt_comp_avg_pred_c, -1),
962   make_tuple(8, 16, &aom_jnt_comp_avg_pred_c, -1),
963   make_tuple(8, 8, &aom_jnt_comp_avg_pred_c, -1),
964   make_tuple(8, 4, &aom_jnt_comp_avg_pred_c, -1),
965   make_tuple(4, 8, &aom_jnt_comp_avg_pred_c, -1),
966   make_tuple(4, 4, &aom_jnt_comp_avg_pred_c, -1),
967 };
968 
969 INSTANTIATE_TEST_CASE_P(C, JntCompAvgTest,
970                         ::testing::ValuesIn(jnt_comp_avg_c_tests));
971 
972 const JntSadMxNAvgParam jnt_avg_c_tests[] = {
973   make_tuple(128, 128, &aom_jnt_sad128x128_avg_c, -1),
974   make_tuple(128, 64, &aom_jnt_sad128x64_avg_c, -1),
975   make_tuple(64, 128, &aom_jnt_sad64x128_avg_c, -1),
976   make_tuple(64, 64, &aom_jnt_sad64x64_avg_c, -1),
977   make_tuple(64, 32, &aom_jnt_sad64x32_avg_c, -1),
978   make_tuple(32, 64, &aom_jnt_sad32x64_avg_c, -1),
979   make_tuple(32, 32, &aom_jnt_sad32x32_avg_c, -1),
980   make_tuple(32, 16, &aom_jnt_sad32x16_avg_c, -1),
981   make_tuple(16, 32, &aom_jnt_sad16x32_avg_c, -1),
982   make_tuple(16, 16, &aom_jnt_sad16x16_avg_c, -1),
983   make_tuple(16, 8, &aom_jnt_sad16x8_avg_c, -1),
984   make_tuple(8, 16, &aom_jnt_sad8x16_avg_c, -1),
985   make_tuple(8, 8, &aom_jnt_sad8x8_avg_c, -1),
986   make_tuple(8, 4, &aom_jnt_sad8x4_avg_c, -1),
987   make_tuple(4, 8, &aom_jnt_sad4x8_avg_c, -1),
988   make_tuple(4, 4, &aom_jnt_sad4x4_avg_c, -1),
989 };
990 INSTANTIATE_TEST_CASE_P(C, JntSADavgTest, ::testing::ValuesIn(jnt_avg_c_tests));
991 
992 const SadMxNx4Param x4d_c_tests[] = {
993   make_tuple(128, 128, &aom_sad128x128x4d_c, -1),
994   make_tuple(128, 64, &aom_sad128x64x4d_c, -1),
995   make_tuple(64, 128, &aom_sad64x128x4d_c, -1),
996   make_tuple(64, 64, &aom_sad64x64x4d_c, -1),
997   make_tuple(64, 32, &aom_sad64x32x4d_c, -1),
998   make_tuple(32, 64, &aom_sad32x64x4d_c, -1),
999   make_tuple(32, 32, &aom_sad32x32x4d_c, -1),
1000   make_tuple(32, 16, &aom_sad32x16x4d_c, -1),
1001   make_tuple(16, 32, &aom_sad16x32x4d_c, -1),
1002   make_tuple(16, 16, &aom_sad16x16x4d_c, -1),
1003   make_tuple(16, 8, &aom_sad16x8x4d_c, -1),
1004   make_tuple(8, 16, &aom_sad8x16x4d_c, -1),
1005   make_tuple(8, 8, &aom_sad8x8x4d_c, -1),
1006   make_tuple(8, 4, &aom_sad8x4x4d_c, -1),
1007   make_tuple(4, 8, &aom_sad4x8x4d_c, -1),
1008   make_tuple(4, 4, &aom_sad4x4x4d_c, -1),
1009   make_tuple(128, 128, &aom_highbd_sad128x128x4d_c, 8),
1010   make_tuple(128, 64, &aom_highbd_sad128x64x4d_c, 8),
1011   make_tuple(64, 128, &aom_highbd_sad64x128x4d_c, 8),
1012   make_tuple(64, 64, &aom_highbd_sad64x64x4d_c, 8),
1013   make_tuple(64, 32, &aom_highbd_sad64x32x4d_c, 8),
1014   make_tuple(32, 64, &aom_highbd_sad32x64x4d_c, 8),
1015   make_tuple(32, 32, &aom_highbd_sad32x32x4d_c, 8),
1016   make_tuple(32, 16, &aom_highbd_sad32x16x4d_c, 8),
1017   make_tuple(16, 32, &aom_highbd_sad16x32x4d_c, 8),
1018   make_tuple(16, 16, &aom_highbd_sad16x16x4d_c, 8),
1019   make_tuple(16, 8, &aom_highbd_sad16x8x4d_c, 8),
1020   make_tuple(8, 16, &aom_highbd_sad8x16x4d_c, 8),
1021   make_tuple(8, 8, &aom_highbd_sad8x8x4d_c, 8),
1022   make_tuple(8, 4, &aom_highbd_sad8x4x4d_c, 8),
1023   make_tuple(4, 8, &aom_highbd_sad4x8x4d_c, 8),
1024   make_tuple(4, 4, &aom_highbd_sad4x4x4d_c, 8),
1025   make_tuple(128, 128, &aom_highbd_sad128x128x4d_c, 10),
1026   make_tuple(128, 64, &aom_highbd_sad128x64x4d_c, 10),
1027   make_tuple(64, 128, &aom_highbd_sad64x128x4d_c, 10),
1028   make_tuple(64, 64, &aom_highbd_sad64x64x4d_c, 10),
1029   make_tuple(64, 32, &aom_highbd_sad64x32x4d_c, 10),
1030   make_tuple(32, 64, &aom_highbd_sad32x64x4d_c, 10),
1031   make_tuple(32, 32, &aom_highbd_sad32x32x4d_c, 10),
1032   make_tuple(32, 16, &aom_highbd_sad32x16x4d_c, 10),
1033   make_tuple(16, 32, &aom_highbd_sad16x32x4d_c, 10),
1034   make_tuple(16, 16, &aom_highbd_sad16x16x4d_c, 10),
1035   make_tuple(16, 8, &aom_highbd_sad16x8x4d_c, 10),
1036   make_tuple(8, 16, &aom_highbd_sad8x16x4d_c, 10),
1037   make_tuple(8, 8, &aom_highbd_sad8x8x4d_c, 10),
1038   make_tuple(8, 4, &aom_highbd_sad8x4x4d_c, 10),
1039   make_tuple(4, 8, &aom_highbd_sad4x8x4d_c, 10),
1040   make_tuple(4, 4, &aom_highbd_sad4x4x4d_c, 10),
1041   make_tuple(128, 128, &aom_highbd_sad128x128x4d_c, 12),
1042   make_tuple(128, 64, &aom_highbd_sad128x64x4d_c, 12),
1043   make_tuple(64, 128, &aom_highbd_sad64x128x4d_c, 12),
1044   make_tuple(64, 64, &aom_highbd_sad64x64x4d_c, 12),
1045   make_tuple(64, 32, &aom_highbd_sad64x32x4d_c, 12),
1046   make_tuple(32, 64, &aom_highbd_sad32x64x4d_c, 12),
1047   make_tuple(32, 32, &aom_highbd_sad32x32x4d_c, 12),
1048   make_tuple(32, 16, &aom_highbd_sad32x16x4d_c, 12),
1049   make_tuple(16, 32, &aom_highbd_sad16x32x4d_c, 12),
1050   make_tuple(16, 16, &aom_highbd_sad16x16x4d_c, 12),
1051   make_tuple(16, 8, &aom_highbd_sad16x8x4d_c, 12),
1052   make_tuple(8, 16, &aom_highbd_sad8x16x4d_c, 12),
1053   make_tuple(8, 8, &aom_highbd_sad8x8x4d_c, 12),
1054   make_tuple(8, 4, &aom_highbd_sad8x4x4d_c, 12),
1055   make_tuple(4, 8, &aom_highbd_sad4x8x4d_c, 12),
1056   make_tuple(4, 4, &aom_highbd_sad4x4x4d_c, 12),
1057 };
1058 INSTANTIATE_TEST_CASE_P(C, SADx4Test, ::testing::ValuesIn(x4d_c_tests));
1059 
1060 //------------------------------------------------------------------------------
1061 // ARM functions
1062 #if HAVE_NEON
1063 const SadMxNParam neon_tests[] = {
1064   make_tuple(64, 64, &aom_sad64x64_neon, -1),
1065   make_tuple(32, 32, &aom_sad32x32_neon, -1),
1066   make_tuple(16, 16, &aom_sad16x16_neon, -1),
1067   make_tuple(16, 8, &aom_sad16x8_neon, -1),
1068   make_tuple(8, 16, &aom_sad8x16_neon, -1),
1069   make_tuple(8, 8, &aom_sad8x8_neon, -1),
1070   make_tuple(4, 4, &aom_sad4x4_neon, -1),
1071 };
1072 INSTANTIATE_TEST_CASE_P(NEON, SADTest, ::testing::ValuesIn(neon_tests));
1073 
1074 const SadMxNx4Param x4d_neon_tests[] = {
1075   make_tuple(64, 64, &aom_sad64x64x4d_neon, -1),
1076   make_tuple(32, 32, &aom_sad32x32x4d_neon, -1),
1077   make_tuple(16, 16, &aom_sad16x16x4d_neon, -1),
1078 };
1079 INSTANTIATE_TEST_CASE_P(NEON, SADx4Test, ::testing::ValuesIn(x4d_neon_tests));
1080 #endif  // HAVE_NEON
1081 
1082 //------------------------------------------------------------------------------
1083 // x86 functions
1084 #if HAVE_SSE2
1085 const SadMxNParam sse2_tests[] = {
1086   make_tuple(128, 128, &aom_sad128x128_sse2, -1),
1087   make_tuple(128, 64, &aom_sad128x64_sse2, -1),
1088   make_tuple(64, 128, &aom_sad64x128_sse2, -1),
1089   make_tuple(64, 64, &aom_sad64x64_sse2, -1),
1090   make_tuple(64, 32, &aom_sad64x32_sse2, -1),
1091   make_tuple(32, 64, &aom_sad32x64_sse2, -1),
1092   make_tuple(32, 32, &aom_sad32x32_sse2, -1),
1093   make_tuple(32, 16, &aom_sad32x16_sse2, -1),
1094   make_tuple(16, 32, &aom_sad16x32_sse2, -1),
1095   make_tuple(16, 16, &aom_sad16x16_sse2, -1),
1096   make_tuple(16, 8, &aom_sad16x8_sse2, -1),
1097   make_tuple(8, 16, &aom_sad8x16_sse2, -1),
1098   make_tuple(8, 8, &aom_sad8x8_sse2, -1),
1099   make_tuple(8, 4, &aom_sad8x4_sse2, -1),
1100   make_tuple(4, 8, &aom_sad4x8_sse2, -1),
1101   make_tuple(4, 4, &aom_sad4x4_sse2, -1),
1102   make_tuple(64, 64, &aom_highbd_sad64x64_sse2, 8),
1103   make_tuple(64, 32, &aom_highbd_sad64x32_sse2, 8),
1104   make_tuple(32, 64, &aom_highbd_sad32x64_sse2, 8),
1105   make_tuple(32, 32, &aom_highbd_sad32x32_sse2, 8),
1106   make_tuple(32, 16, &aom_highbd_sad32x16_sse2, 8),
1107   make_tuple(16, 32, &aom_highbd_sad16x32_sse2, 8),
1108   make_tuple(16, 16, &aom_highbd_sad16x16_sse2, 8),
1109   make_tuple(16, 8, &aom_highbd_sad16x8_sse2, 8),
1110   make_tuple(8, 16, &aom_highbd_sad8x16_sse2, 8),
1111   make_tuple(8, 8, &aom_highbd_sad8x8_sse2, 8),
1112   make_tuple(8, 4, &aom_highbd_sad8x4_sse2, 8),
1113   make_tuple(64, 64, &aom_highbd_sad64x64_sse2, 10),
1114   make_tuple(64, 32, &aom_highbd_sad64x32_sse2, 10),
1115   make_tuple(32, 64, &aom_highbd_sad32x64_sse2, 10),
1116   make_tuple(32, 32, &aom_highbd_sad32x32_sse2, 10),
1117   make_tuple(32, 16, &aom_highbd_sad32x16_sse2, 10),
1118   make_tuple(16, 32, &aom_highbd_sad16x32_sse2, 10),
1119   make_tuple(16, 16, &aom_highbd_sad16x16_sse2, 10),
1120   make_tuple(16, 8, &aom_highbd_sad16x8_sse2, 10),
1121   make_tuple(8, 16, &aom_highbd_sad8x16_sse2, 10),
1122   make_tuple(8, 8, &aom_highbd_sad8x8_sse2, 10),
1123   make_tuple(8, 4, &aom_highbd_sad8x4_sse2, 10),
1124   make_tuple(64, 64, &aom_highbd_sad64x64_sse2, 12),
1125   make_tuple(64, 32, &aom_highbd_sad64x32_sse2, 12),
1126   make_tuple(32, 64, &aom_highbd_sad32x64_sse2, 12),
1127   make_tuple(32, 32, &aom_highbd_sad32x32_sse2, 12),
1128   make_tuple(32, 16, &aom_highbd_sad32x16_sse2, 12),
1129   make_tuple(16, 32, &aom_highbd_sad16x32_sse2, 12),
1130   make_tuple(16, 16, &aom_highbd_sad16x16_sse2, 12),
1131   make_tuple(16, 8, &aom_highbd_sad16x8_sse2, 12),
1132   make_tuple(8, 16, &aom_highbd_sad8x16_sse2, 12),
1133   make_tuple(8, 8, &aom_highbd_sad8x8_sse2, 12),
1134   make_tuple(8, 4, &aom_highbd_sad8x4_sse2, 12),
1135 };
1136 INSTANTIATE_TEST_CASE_P(SSE2, SADTest, ::testing::ValuesIn(sse2_tests));
1137 
1138 const SadMxNAvgParam avg_sse2_tests[] = {
1139   make_tuple(128, 128, &aom_sad128x128_avg_sse2, -1),
1140   make_tuple(128, 64, &aom_sad128x64_avg_sse2, -1),
1141   make_tuple(64, 128, &aom_sad64x128_avg_sse2, -1),
1142   make_tuple(64, 64, &aom_sad64x64_avg_sse2, -1),
1143   make_tuple(64, 32, &aom_sad64x32_avg_sse2, -1),
1144   make_tuple(32, 64, &aom_sad32x64_avg_sse2, -1),
1145   make_tuple(32, 32, &aom_sad32x32_avg_sse2, -1),
1146   make_tuple(32, 16, &aom_sad32x16_avg_sse2, -1),
1147   make_tuple(16, 32, &aom_sad16x32_avg_sse2, -1),
1148   make_tuple(16, 16, &aom_sad16x16_avg_sse2, -1),
1149   make_tuple(16, 8, &aom_sad16x8_avg_sse2, -1),
1150   make_tuple(8, 16, &aom_sad8x16_avg_sse2, -1),
1151   make_tuple(8, 8, &aom_sad8x8_avg_sse2, -1),
1152   make_tuple(8, 4, &aom_sad8x4_avg_sse2, -1),
1153   make_tuple(4, 8, &aom_sad4x8_avg_sse2, -1),
1154   make_tuple(4, 4, &aom_sad4x4_avg_sse2, -1),
1155   make_tuple(64, 64, &aom_highbd_sad64x64_avg_sse2, 8),
1156   make_tuple(64, 32, &aom_highbd_sad64x32_avg_sse2, 8),
1157   make_tuple(32, 64, &aom_highbd_sad32x64_avg_sse2, 8),
1158   make_tuple(32, 32, &aom_highbd_sad32x32_avg_sse2, 8),
1159   make_tuple(32, 16, &aom_highbd_sad32x16_avg_sse2, 8),
1160   make_tuple(16, 32, &aom_highbd_sad16x32_avg_sse2, 8),
1161   make_tuple(16, 16, &aom_highbd_sad16x16_avg_sse2, 8),
1162   make_tuple(16, 8, &aom_highbd_sad16x8_avg_sse2, 8),
1163   make_tuple(8, 16, &aom_highbd_sad8x16_avg_sse2, 8),
1164   make_tuple(8, 8, &aom_highbd_sad8x8_avg_sse2, 8),
1165   make_tuple(8, 4, &aom_highbd_sad8x4_avg_sse2, 8),
1166   make_tuple(64, 64, &aom_highbd_sad64x64_avg_sse2, 10),
1167   make_tuple(64, 32, &aom_highbd_sad64x32_avg_sse2, 10),
1168   make_tuple(32, 64, &aom_highbd_sad32x64_avg_sse2, 10),
1169   make_tuple(32, 32, &aom_highbd_sad32x32_avg_sse2, 10),
1170   make_tuple(32, 16, &aom_highbd_sad32x16_avg_sse2, 10),
1171   make_tuple(16, 32, &aom_highbd_sad16x32_avg_sse2, 10),
1172   make_tuple(16, 16, &aom_highbd_sad16x16_avg_sse2, 10),
1173   make_tuple(16, 8, &aom_highbd_sad16x8_avg_sse2, 10),
1174   make_tuple(8, 16, &aom_highbd_sad8x16_avg_sse2, 10),
1175   make_tuple(8, 8, &aom_highbd_sad8x8_avg_sse2, 10),
1176   make_tuple(8, 4, &aom_highbd_sad8x4_avg_sse2, 10),
1177   make_tuple(64, 64, &aom_highbd_sad64x64_avg_sse2, 12),
1178   make_tuple(64, 32, &aom_highbd_sad64x32_avg_sse2, 12),
1179   make_tuple(32, 64, &aom_highbd_sad32x64_avg_sse2, 12),
1180   make_tuple(32, 32, &aom_highbd_sad32x32_avg_sse2, 12),
1181   make_tuple(32, 16, &aom_highbd_sad32x16_avg_sse2, 12),
1182   make_tuple(16, 32, &aom_highbd_sad16x32_avg_sse2, 12),
1183   make_tuple(16, 16, &aom_highbd_sad16x16_avg_sse2, 12),
1184   make_tuple(16, 8, &aom_highbd_sad16x8_avg_sse2, 12),
1185   make_tuple(8, 16, &aom_highbd_sad8x16_avg_sse2, 12),
1186   make_tuple(8, 8, &aom_highbd_sad8x8_avg_sse2, 12),
1187   make_tuple(8, 4, &aom_highbd_sad8x4_avg_sse2, 12),
1188 };
1189 INSTANTIATE_TEST_CASE_P(SSE2, SADavgTest, ::testing::ValuesIn(avg_sse2_tests));
1190 
1191 const SadMxNx4Param x4d_sse2_tests[] = {
1192   make_tuple(128, 128, &aom_sad128x128x4d_sse2, -1),
1193   make_tuple(128, 64, &aom_sad128x64x4d_sse2, -1),
1194   make_tuple(64, 128, &aom_sad64x128x4d_sse2, -1),
1195   make_tuple(64, 64, &aom_sad64x64x4d_sse2, -1),
1196   make_tuple(64, 32, &aom_sad64x32x4d_sse2, -1),
1197   make_tuple(32, 64, &aom_sad32x64x4d_sse2, -1),
1198   make_tuple(32, 32, &aom_sad32x32x4d_sse2, -1),
1199   make_tuple(32, 16, &aom_sad32x16x4d_sse2, -1),
1200   make_tuple(16, 32, &aom_sad16x32x4d_sse2, -1),
1201   make_tuple(16, 16, &aom_sad16x16x4d_sse2, -1),
1202   make_tuple(16, 8, &aom_sad16x8x4d_sse2, -1),
1203   make_tuple(8, 16, &aom_sad8x16x4d_sse2, -1),
1204   make_tuple(8, 8, &aom_sad8x8x4d_sse2, -1),
1205   make_tuple(8, 4, &aom_sad8x4x4d_sse2, -1),
1206   make_tuple(4, 8, &aom_sad4x8x4d_sse2, -1),
1207   make_tuple(4, 4, &aom_sad4x4x4d_sse2, -1),
1208   make_tuple(64, 64, &aom_highbd_sad64x64x4d_sse2, 8),
1209   make_tuple(64, 32, &aom_highbd_sad64x32x4d_sse2, 8),
1210   make_tuple(32, 64, &aom_highbd_sad32x64x4d_sse2, 8),
1211   make_tuple(32, 32, &aom_highbd_sad32x32x4d_sse2, 8),
1212   make_tuple(32, 16, &aom_highbd_sad32x16x4d_sse2, 8),
1213   make_tuple(16, 32, &aom_highbd_sad16x32x4d_sse2, 8),
1214   make_tuple(16, 16, &aom_highbd_sad16x16x4d_sse2, 8),
1215   make_tuple(16, 8, &aom_highbd_sad16x8x4d_sse2, 8),
1216   make_tuple(8, 16, &aom_highbd_sad8x16x4d_sse2, 8),
1217   make_tuple(8, 8, &aom_highbd_sad8x8x4d_sse2, 8),
1218   make_tuple(8, 4, &aom_highbd_sad8x4x4d_sse2, 8),
1219   make_tuple(4, 8, &aom_highbd_sad4x8x4d_sse2, 8),
1220   make_tuple(4, 4, &aom_highbd_sad4x4x4d_sse2, 8),
1221   make_tuple(64, 64, &aom_highbd_sad64x64x4d_sse2, 10),
1222   make_tuple(64, 32, &aom_highbd_sad64x32x4d_sse2, 10),
1223   make_tuple(32, 64, &aom_highbd_sad32x64x4d_sse2, 10),
1224   make_tuple(32, 32, &aom_highbd_sad32x32x4d_sse2, 10),
1225   make_tuple(32, 16, &aom_highbd_sad32x16x4d_sse2, 10),
1226   make_tuple(16, 32, &aom_highbd_sad16x32x4d_sse2, 10),
1227   make_tuple(16, 16, &aom_highbd_sad16x16x4d_sse2, 10),
1228   make_tuple(16, 8, &aom_highbd_sad16x8x4d_sse2, 10),
1229   make_tuple(8, 16, &aom_highbd_sad8x16x4d_sse2, 10),
1230   make_tuple(8, 8, &aom_highbd_sad8x8x4d_sse2, 10),
1231   make_tuple(8, 4, &aom_highbd_sad8x4x4d_sse2, 10),
1232   make_tuple(4, 8, &aom_highbd_sad4x8x4d_sse2, 10),
1233   make_tuple(4, 4, &aom_highbd_sad4x4x4d_sse2, 10),
1234   make_tuple(64, 64, &aom_highbd_sad64x64x4d_sse2, 12),
1235   make_tuple(64, 32, &aom_highbd_sad64x32x4d_sse2, 12),
1236   make_tuple(32, 64, &aom_highbd_sad32x64x4d_sse2, 12),
1237   make_tuple(32, 32, &aom_highbd_sad32x32x4d_sse2, 12),
1238   make_tuple(32, 16, &aom_highbd_sad32x16x4d_sse2, 12),
1239   make_tuple(16, 32, &aom_highbd_sad16x32x4d_sse2, 12),
1240   make_tuple(16, 16, &aom_highbd_sad16x16x4d_sse2, 12),
1241   make_tuple(16, 8, &aom_highbd_sad16x8x4d_sse2, 12),
1242   make_tuple(8, 16, &aom_highbd_sad8x16x4d_sse2, 12),
1243   make_tuple(8, 8, &aom_highbd_sad8x8x4d_sse2, 12),
1244   make_tuple(8, 4, &aom_highbd_sad8x4x4d_sse2, 12),
1245   make_tuple(4, 8, &aom_highbd_sad4x8x4d_sse2, 12),
1246   make_tuple(4, 4, &aom_highbd_sad4x4x4d_sse2, 12),
1247 };
1248 INSTANTIATE_TEST_CASE_P(SSE2, SADx4Test, ::testing::ValuesIn(x4d_sse2_tests));
1249 #endif  // HAVE_SSE2
1250 
1251 #if HAVE_SSSE3
1252 // Note: These are named sse2, but part of ssse3 file and only built and linked
1253 // when ssse3 is enabled.
1254 const JntSadMxhParam jnt_sad_sse2_tests[] = {
1255   make_tuple(4, 4, &aom_sad4xh_sse2, -1),
1256   make_tuple(4, 8, &aom_sad4xh_sse2, -1),
1257   make_tuple(8, 4, &aom_sad8xh_sse2, -1),
1258   make_tuple(8, 8, &aom_sad8xh_sse2, -1),
1259   make_tuple(8, 16, &aom_sad8xh_sse2, -1),
1260   make_tuple(16, 8, &aom_sad16xh_sse2, -1),
1261   make_tuple(16, 16, &aom_sad16xh_sse2, -1),
1262   make_tuple(16, 32, &aom_sad16xh_sse2, -1),
1263   make_tuple(32, 16, &aom_sad32xh_sse2, -1),
1264   make_tuple(32, 32, &aom_sad32xh_sse2, -1),
1265   make_tuple(32, 64, &aom_sad32xh_sse2, -1),
1266   make_tuple(64, 32, &aom_sad64xh_sse2, -1),
1267   make_tuple(64, 64, &aom_sad64xh_sse2, -1),
1268   make_tuple(128, 128, &aom_sad128xh_sse2, -1),
1269   make_tuple(128, 64, &aom_sad128xh_sse2, -1),
1270   make_tuple(64, 128, &aom_sad64xh_sse2, -1),
1271   make_tuple(4, 16, &aom_sad4xh_sse2, -1),
1272   make_tuple(16, 4, &aom_sad16xh_sse2, -1),
1273   make_tuple(8, 32, &aom_sad8xh_sse2, -1),
1274   make_tuple(32, 8, &aom_sad32xh_sse2, -1),
1275   make_tuple(16, 64, &aom_sad16xh_sse2, -1),
1276   make_tuple(64, 16, &aom_sad64xh_sse2, -1),
1277 };
1278 INSTANTIATE_TEST_CASE_P(SSE2, JntSADTest,
1279                         ::testing::ValuesIn(jnt_sad_sse2_tests));
1280 
1281 #endif  // HAVE_SSSE3
1282 
1283 #if HAVE_SSE3
1284 // Only functions are x3, which do not have tests.
1285 #endif  // HAVE_SSE3
1286 
1287 #if HAVE_SSSE3
1288 const JntCompAvgParam jnt_comp_avg_ssse3_tests[] = {
1289   make_tuple(128, 128, &aom_jnt_comp_avg_pred_ssse3, -1),
1290   make_tuple(128, 64, &aom_jnt_comp_avg_pred_ssse3, -1),
1291   make_tuple(64, 128, &aom_jnt_comp_avg_pred_ssse3, -1),
1292   make_tuple(64, 64, &aom_jnt_comp_avg_pred_ssse3, -1),
1293   make_tuple(64, 32, &aom_jnt_comp_avg_pred_ssse3, -1),
1294   make_tuple(32, 64, &aom_jnt_comp_avg_pred_ssse3, -1),
1295   make_tuple(32, 32, &aom_jnt_comp_avg_pred_ssse3, -1),
1296   make_tuple(32, 16, &aom_jnt_comp_avg_pred_ssse3, -1),
1297   make_tuple(16, 32, &aom_jnt_comp_avg_pred_ssse3, -1),
1298   make_tuple(16, 16, &aom_jnt_comp_avg_pred_ssse3, -1),
1299   make_tuple(16, 8, &aom_jnt_comp_avg_pred_ssse3, -1),
1300   make_tuple(8, 16, &aom_jnt_comp_avg_pred_ssse3, -1),
1301   make_tuple(8, 8, &aom_jnt_comp_avg_pred_ssse3, -1),
1302   make_tuple(8, 4, &aom_jnt_comp_avg_pred_ssse3, -1),
1303   make_tuple(4, 8, &aom_jnt_comp_avg_pred_ssse3, -1),
1304   make_tuple(4, 4, &aom_jnt_comp_avg_pred_ssse3, -1),
1305   make_tuple(16, 16, &aom_jnt_comp_avg_pred_ssse3, -1),
1306 };
1307 
1308 INSTANTIATE_TEST_CASE_P(SSSE3, JntCompAvgTest,
1309                         ::testing::ValuesIn(jnt_comp_avg_ssse3_tests));
1310 
1311 const JntSadMxNAvgParam jnt_avg_ssse3_tests[] = {
1312   make_tuple(128, 128, &aom_jnt_sad128x128_avg_ssse3, -1),
1313   make_tuple(128, 64, &aom_jnt_sad128x64_avg_ssse3, -1),
1314   make_tuple(64, 128, &aom_jnt_sad64x128_avg_ssse3, -1),
1315   make_tuple(64, 64, &aom_jnt_sad64x64_avg_ssse3, -1),
1316   make_tuple(64, 32, &aom_jnt_sad64x32_avg_ssse3, -1),
1317   make_tuple(32, 64, &aom_jnt_sad32x64_avg_ssse3, -1),
1318   make_tuple(32, 32, &aom_jnt_sad32x32_avg_ssse3, -1),
1319   make_tuple(32, 16, &aom_jnt_sad32x16_avg_ssse3, -1),
1320   make_tuple(16, 32, &aom_jnt_sad16x32_avg_ssse3, -1),
1321   make_tuple(16, 16, &aom_jnt_sad16x16_avg_ssse3, -1),
1322   make_tuple(16, 8, &aom_jnt_sad16x8_avg_ssse3, -1),
1323   make_tuple(8, 16, &aom_jnt_sad8x16_avg_ssse3, -1),
1324   make_tuple(8, 8, &aom_jnt_sad8x8_avg_ssse3, -1),
1325   make_tuple(8, 4, &aom_jnt_sad8x4_avg_ssse3, -1),
1326   make_tuple(4, 8, &aom_jnt_sad4x8_avg_ssse3, -1),
1327   make_tuple(4, 4, &aom_jnt_sad4x4_avg_ssse3, -1),
1328 };
1329 INSTANTIATE_TEST_CASE_P(SSSE3, JntSADavgTest,
1330                         ::testing::ValuesIn(jnt_avg_ssse3_tests));
1331 #endif  // HAVE_SSSE3
1332 
1333 #if HAVE_SSE4_1
1334 // Only functions are x8, which do not have tests.
1335 #endif  // HAVE_SSE4_1
1336 
1337 #if HAVE_AVX2
1338 const SadMxNParam avx2_tests[] = {
1339   make_tuple(64, 128, &aom_sad64x128_avx2, -1),
1340   make_tuple(128, 64, &aom_sad128x64_avx2, -1),
1341   make_tuple(128, 128, &aom_sad128x128_avx2, -1),
1342   make_tuple(64, 64, &aom_sad64x64_avx2, -1),
1343   make_tuple(64, 32, &aom_sad64x32_avx2, -1),
1344   make_tuple(32, 64, &aom_sad32x64_avx2, -1),
1345   make_tuple(32, 32, &aom_sad32x32_avx2, -1),
1346   make_tuple(32, 16, &aom_sad32x16_avx2, -1),
1347   make_tuple(128, 128, &aom_highbd_sad128x128_avx2, 8),
1348   make_tuple(128, 128, &aom_highbd_sad128x128_avx2, 10),
1349   make_tuple(128, 128, &aom_highbd_sad128x128_avx2, 12),
1350   make_tuple(128, 64, &aom_highbd_sad128x64_avx2, 8),
1351   make_tuple(128, 64, &aom_highbd_sad128x64_avx2, 10),
1352   make_tuple(128, 64, &aom_highbd_sad128x64_avx2, 12),
1353   make_tuple(64, 128, &aom_highbd_sad64x128_avx2, 8),
1354   make_tuple(64, 128, &aom_highbd_sad64x128_avx2, 10),
1355   make_tuple(64, 128, &aom_highbd_sad64x128_avx2, 12),
1356   make_tuple(64, 64, &aom_highbd_sad64x64_avx2, 8),
1357   make_tuple(64, 64, &aom_highbd_sad64x64_avx2, 10),
1358   make_tuple(64, 64, &aom_highbd_sad64x64_avx2, 12),
1359   make_tuple(64, 32, &aom_highbd_sad64x32_avx2, 8),
1360   make_tuple(64, 32, &aom_highbd_sad64x32_avx2, 10),
1361   make_tuple(64, 32, &aom_highbd_sad64x32_avx2, 12),
1362   make_tuple(32, 64, &aom_highbd_sad32x64_avx2, 8),
1363   make_tuple(32, 64, &aom_highbd_sad32x64_avx2, 10),
1364   make_tuple(32, 64, &aom_highbd_sad32x64_avx2, 12),
1365   make_tuple(32, 32, &aom_highbd_sad32x32_avx2, 8),
1366   make_tuple(32, 32, &aom_highbd_sad32x32_avx2, 10),
1367   make_tuple(32, 32, &aom_highbd_sad32x32_avx2, 12),
1368   make_tuple(32, 16, &aom_highbd_sad32x16_avx2, 8),
1369   make_tuple(32, 16, &aom_highbd_sad32x16_avx2, 10),
1370   make_tuple(32, 16, &aom_highbd_sad32x16_avx2, 12),
1371   make_tuple(16, 32, &aom_highbd_sad16x32_avx2, 8),
1372   make_tuple(16, 32, &aom_highbd_sad16x32_avx2, 10),
1373   make_tuple(16, 32, &aom_highbd_sad16x32_avx2, 12),
1374   make_tuple(16, 16, &aom_highbd_sad16x16_avx2, 8),
1375   make_tuple(16, 16, &aom_highbd_sad16x16_avx2, 10),
1376   make_tuple(16, 16, &aom_highbd_sad16x16_avx2, 12),
1377   make_tuple(16, 8, &aom_highbd_sad16x8_avx2, 8),
1378   make_tuple(16, 8, &aom_highbd_sad16x8_avx2, 10),
1379   make_tuple(16, 8, &aom_highbd_sad16x8_avx2, 12),
1380 };
1381 INSTANTIATE_TEST_CASE_P(AVX2, SADTest, ::testing::ValuesIn(avx2_tests));
1382 
1383 const SadMxNAvgParam avg_avx2_tests[] = {
1384   make_tuple(64, 128, &aom_sad64x128_avg_avx2, -1),
1385   make_tuple(128, 64, &aom_sad128x64_avg_avx2, -1),
1386   make_tuple(128, 128, &aom_sad128x128_avg_avx2, -1),
1387   make_tuple(64, 64, &aom_sad64x64_avg_avx2, -1),
1388   make_tuple(64, 32, &aom_sad64x32_avg_avx2, -1),
1389   make_tuple(32, 64, &aom_sad32x64_avg_avx2, -1),
1390   make_tuple(32, 32, &aom_sad32x32_avg_avx2, -1),
1391   make_tuple(32, 16, &aom_sad32x16_avg_avx2, -1),
1392   make_tuple(128, 128, &aom_highbd_sad128x128_avg_avx2, 8),
1393   make_tuple(128, 128, &aom_highbd_sad128x128_avg_avx2, 10),
1394   make_tuple(128, 128, &aom_highbd_sad128x128_avg_avx2, 12),
1395   make_tuple(128, 64, &aom_highbd_sad128x64_avg_avx2, 8),
1396   make_tuple(128, 64, &aom_highbd_sad128x64_avg_avx2, 10),
1397   make_tuple(128, 64, &aom_highbd_sad128x64_avg_avx2, 12),
1398   make_tuple(64, 128, &aom_highbd_sad64x128_avg_avx2, 8),
1399   make_tuple(64, 128, &aom_highbd_sad64x128_avg_avx2, 10),
1400   make_tuple(64, 128, &aom_highbd_sad64x128_avg_avx2, 12),
1401   make_tuple(64, 64, &aom_highbd_sad64x64_avg_avx2, 8),
1402   make_tuple(64, 64, &aom_highbd_sad64x64_avg_avx2, 10),
1403   make_tuple(64, 64, &aom_highbd_sad64x64_avg_avx2, 12),
1404   make_tuple(64, 32, &aom_highbd_sad64x32_avg_avx2, 8),
1405   make_tuple(64, 32, &aom_highbd_sad64x32_avg_avx2, 10),
1406   make_tuple(64, 32, &aom_highbd_sad64x32_avg_avx2, 12),
1407   make_tuple(32, 64, &aom_highbd_sad32x64_avg_avx2, 8),
1408   make_tuple(32, 64, &aom_highbd_sad32x64_avg_avx2, 10),
1409   make_tuple(32, 64, &aom_highbd_sad32x64_avg_avx2, 12),
1410   make_tuple(32, 32, &aom_highbd_sad32x32_avg_avx2, 8),
1411   make_tuple(32, 32, &aom_highbd_sad32x32_avg_avx2, 10),
1412   make_tuple(32, 32, &aom_highbd_sad32x32_avg_avx2, 12),
1413   make_tuple(32, 16, &aom_highbd_sad32x16_avg_avx2, 8),
1414   make_tuple(32, 16, &aom_highbd_sad32x16_avg_avx2, 10),
1415   make_tuple(32, 16, &aom_highbd_sad32x16_avg_avx2, 12),
1416   make_tuple(16, 32, &aom_highbd_sad16x32_avg_avx2, 8),
1417   make_tuple(16, 32, &aom_highbd_sad16x32_avg_avx2, 10),
1418   make_tuple(16, 32, &aom_highbd_sad16x32_avg_avx2, 12),
1419   make_tuple(16, 16, &aom_highbd_sad16x16_avg_avx2, 8),
1420   make_tuple(16, 16, &aom_highbd_sad16x16_avg_avx2, 10),
1421   make_tuple(16, 16, &aom_highbd_sad16x16_avg_avx2, 12),
1422   make_tuple(16, 8, &aom_highbd_sad16x8_avg_avx2, 8),
1423   make_tuple(16, 8, &aom_highbd_sad16x8_avg_avx2, 10),
1424   make_tuple(16, 8, &aom_highbd_sad16x8_avg_avx2, 12),
1425 };
1426 INSTANTIATE_TEST_CASE_P(AVX2, SADavgTest, ::testing::ValuesIn(avg_avx2_tests));
1427 
1428 const SadMxNx4Param x4d_avx2_tests[] = {
1429   make_tuple(64, 128, &aom_sad64x128x4d_avx2, -1),
1430   make_tuple(128, 64, &aom_sad128x64x4d_avx2, -1),
1431   make_tuple(128, 128, &aom_sad128x128x4d_avx2, -1),
1432   make_tuple(64, 64, &aom_sad64x64x4d_avx2, -1),
1433   make_tuple(32, 64, &aom_sad32x64x4d_avx2, -1),
1434   make_tuple(64, 32, &aom_sad64x32x4d_avx2, -1),
1435   make_tuple(32, 32, &aom_sad32x32x4d_avx2, -1),
1436   make_tuple(128, 128, &aom_highbd_sad128x128x4d_avx2, 8),
1437   make_tuple(128, 128, &aom_highbd_sad128x128x4d_avx2, 10),
1438   make_tuple(128, 128, &aom_highbd_sad128x128x4d_avx2, 12),
1439   make_tuple(128, 64, &aom_highbd_sad128x64x4d_avx2, 8),
1440   make_tuple(128, 64, &aom_highbd_sad128x64x4d_avx2, 10),
1441   make_tuple(128, 64, &aom_highbd_sad128x64x4d_avx2, 12),
1442   make_tuple(64, 128, &aom_highbd_sad64x128x4d_avx2, 8),
1443   make_tuple(64, 128, &aom_highbd_sad64x128x4d_avx2, 10),
1444   make_tuple(64, 128, &aom_highbd_sad64x128x4d_avx2, 12),
1445   make_tuple(64, 64, &aom_highbd_sad64x64x4d_avx2, 8),
1446   make_tuple(64, 64, &aom_highbd_sad64x64x4d_avx2, 10),
1447   make_tuple(64, 64, &aom_highbd_sad64x64x4d_avx2, 12),
1448   make_tuple(64, 32, &aom_highbd_sad64x32x4d_avx2, 8),
1449   make_tuple(64, 32, &aom_highbd_sad64x32x4d_avx2, 10),
1450   make_tuple(64, 32, &aom_highbd_sad64x32x4d_avx2, 12),
1451   make_tuple(32, 64, &aom_highbd_sad32x64x4d_avx2, 8),
1452   make_tuple(32, 64, &aom_highbd_sad32x64x4d_avx2, 10),
1453   make_tuple(32, 64, &aom_highbd_sad32x64x4d_avx2, 12),
1454   make_tuple(32, 32, &aom_highbd_sad32x32x4d_avx2, 8),
1455   make_tuple(32, 32, &aom_highbd_sad32x32x4d_avx2, 10),
1456   make_tuple(32, 32, &aom_highbd_sad32x32x4d_avx2, 12),
1457   make_tuple(32, 16, &aom_highbd_sad32x16x4d_avx2, 8),
1458   make_tuple(32, 16, &aom_highbd_sad32x16x4d_avx2, 10),
1459   make_tuple(32, 16, &aom_highbd_sad32x16x4d_avx2, 12),
1460   make_tuple(16, 32, &aom_highbd_sad16x32x4d_avx2, 8),
1461   make_tuple(16, 32, &aom_highbd_sad16x32x4d_avx2, 10),
1462   make_tuple(16, 32, &aom_highbd_sad16x32x4d_avx2, 12),
1463   make_tuple(16, 16, &aom_highbd_sad16x16x4d_avx2, 8),
1464   make_tuple(16, 16, &aom_highbd_sad16x16x4d_avx2, 10),
1465   make_tuple(16, 16, &aom_highbd_sad16x16x4d_avx2, 12),
1466   make_tuple(16, 8, &aom_highbd_sad16x8x4d_avx2, 8),
1467   make_tuple(16, 8, &aom_highbd_sad16x8x4d_avx2, 10),
1468   make_tuple(16, 8, &aom_highbd_sad16x8x4d_avx2, 12),
1469 };
1470 INSTANTIATE_TEST_CASE_P(AVX2, SADx4Test, ::testing::ValuesIn(x4d_avx2_tests));
1471 #endif  // HAVE_AVX2
1472 
1473 //------------------------------------------------------------------------------
1474 // MIPS functions
1475 #if HAVE_MSA
1476 const SadMxNParam msa_tests[] = {
1477   make_tuple(64, 64, &aom_sad64x64_msa, -1),
1478   make_tuple(64, 32, &aom_sad64x32_msa, -1),
1479   make_tuple(32, 64, &aom_sad32x64_msa, -1),
1480   make_tuple(32, 32, &aom_sad32x32_msa, -1),
1481   make_tuple(32, 16, &aom_sad32x16_msa, -1),
1482   make_tuple(16, 32, &aom_sad16x32_msa, -1),
1483   make_tuple(16, 16, &aom_sad16x16_msa, -1),
1484   make_tuple(16, 8, &aom_sad16x8_msa, -1),
1485   make_tuple(8, 16, &aom_sad8x16_msa, -1),
1486   make_tuple(8, 8, &aom_sad8x8_msa, -1),
1487   make_tuple(8, 4, &aom_sad8x4_msa, -1),
1488   make_tuple(4, 8, &aom_sad4x8_msa, -1),
1489   make_tuple(4, 4, &aom_sad4x4_msa, -1),
1490 };
1491 INSTANTIATE_TEST_CASE_P(MSA, SADTest, ::testing::ValuesIn(msa_tests));
1492 
1493 const SadMxNAvgParam avg_msa_tests[] = {
1494   make_tuple(64, 64, &aom_sad64x64_avg_msa, -1),
1495   make_tuple(64, 32, &aom_sad64x32_avg_msa, -1),
1496   make_tuple(32, 64, &aom_sad32x64_avg_msa, -1),
1497   make_tuple(32, 32, &aom_sad32x32_avg_msa, -1),
1498   make_tuple(32, 16, &aom_sad32x16_avg_msa, -1),
1499   make_tuple(16, 32, &aom_sad16x32_avg_msa, -1),
1500   make_tuple(16, 16, &aom_sad16x16_avg_msa, -1),
1501   make_tuple(16, 8, &aom_sad16x8_avg_msa, -1),
1502   make_tuple(8, 16, &aom_sad8x16_avg_msa, -1),
1503   make_tuple(8, 8, &aom_sad8x8_avg_msa, -1),
1504   make_tuple(8, 4, &aom_sad8x4_avg_msa, -1),
1505   make_tuple(4, 8, &aom_sad4x8_avg_msa, -1),
1506   make_tuple(4, 4, &aom_sad4x4_avg_msa, -1),
1507 };
1508 INSTANTIATE_TEST_CASE_P(MSA, SADavgTest, ::testing::ValuesIn(avg_msa_tests));
1509 
1510 const SadMxNx4Param x4d_msa_tests[] = {
1511   make_tuple(64, 64, &aom_sad64x64x4d_msa, -1),
1512   make_tuple(64, 32, &aom_sad64x32x4d_msa, -1),
1513   make_tuple(32, 64, &aom_sad32x64x4d_msa, -1),
1514   make_tuple(32, 32, &aom_sad32x32x4d_msa, -1),
1515   make_tuple(32, 16, &aom_sad32x16x4d_msa, -1),
1516   make_tuple(16, 32, &aom_sad16x32x4d_msa, -1),
1517   make_tuple(16, 16, &aom_sad16x16x4d_msa, -1),
1518   make_tuple(16, 8, &aom_sad16x8x4d_msa, -1),
1519   make_tuple(8, 16, &aom_sad8x16x4d_msa, -1),
1520   make_tuple(8, 8, &aom_sad8x8x4d_msa, -1),
1521   make_tuple(8, 4, &aom_sad8x4x4d_msa, -1),
1522   make_tuple(4, 8, &aom_sad4x8x4d_msa, -1),
1523   make_tuple(4, 4, &aom_sad4x4x4d_msa, -1),
1524 };
1525 INSTANTIATE_TEST_CASE_P(MSA, SADx4Test, ::testing::ValuesIn(x4d_msa_tests));
1526 #endif  // HAVE_MSA
1527 
1528 }  // namespace
1529