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 <cstdlib>
13 #include <new>
14 
15 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
16 
17 #include "./aom_config.h"
18 #include "./aom_dsp_rtcd.h"
19 #include "test/acm_random.h"
20 #include "test/clear_system_state.h"
21 #include "test/register_state_check.h"
22 #include "aom/aom_codec.h"
23 #include "aom/aom_integer.h"
24 #include "aom_mem/aom_mem.h"
25 #include "aom_ports/mem.h"
26 
27 namespace {
28 
29 typedef unsigned int (*VarianceMxNFunc)(const uint8_t *a, int a_stride,
30                                         const uint8_t *b, int b_stride,
31                                         unsigned int *sse);
32 typedef unsigned int (*SubpixVarMxNFunc)(const uint8_t *a, int a_stride,
33                                          int xoffset, int yoffset,
34                                          const uint8_t *b, int b_stride,
35                                          unsigned int *sse);
36 typedef unsigned int (*SubpixAvgVarMxNFunc)(const uint8_t *a, int a_stride,
37                                             int xoffset, int yoffset,
38                                             const uint8_t *b, int b_stride,
39                                             uint32_t *sse,
40                                             const uint8_t *second_pred);
41 typedef unsigned int (*Get4x4SseFunc)(const uint8_t *a, int a_stride,
42                                       const uint8_t *b, int b_stride);
43 typedef unsigned int (*SumOfSquaresFunction)(const int16_t *src);
44 
45 using libaom_test::ACMRandom;
46 
47 // Truncate high bit depth results by downshifting (with rounding) by:
48 // 2 * (bit_depth - 8) for sse
49 // (bit_depth - 8) for se
RoundHighBitDepth(int bit_depth,int64_t * se,uint64_t * sse)50 static void RoundHighBitDepth(int bit_depth, int64_t *se, uint64_t *sse) {
51   switch (bit_depth) {
52     case AOM_BITS_12:
53       *sse = (*sse + 128) >> 8;
54       *se = (*se + 8) >> 4;
55       break;
56     case AOM_BITS_10:
57       *sse = (*sse + 8) >> 4;
58       *se = (*se + 2) >> 2;
59       break;
60     case AOM_BITS_8:
61     default: break;
62   }
63 }
64 
mb_ss_ref(const int16_t * src)65 static unsigned int mb_ss_ref(const int16_t *src) {
66   unsigned int res = 0;
67   for (int i = 0; i < 256; ++i) {
68     res += src[i] * src[i];
69   }
70   return res;
71 }
72 
73 /* Note:
74  *  Our codebase calculates the "diff" value in the variance algorithm by
75  *  (src - ref).
76  */
variance_ref(const uint8_t * src,const uint8_t * ref,int l2w,int l2h,int src_stride,int ref_stride,uint32_t * sse_ptr,bool use_high_bit_depth_,aom_bit_depth_t bit_depth)77 static uint32_t variance_ref(const uint8_t *src, const uint8_t *ref, int l2w,
78                              int l2h, int src_stride, int ref_stride,
79                              uint32_t *sse_ptr, bool use_high_bit_depth_,
80                              aom_bit_depth_t bit_depth) {
81   int64_t se = 0;
82   uint64_t sse = 0;
83   const int w = 1 << l2w;
84   const int h = 1 << l2h;
85   for (int y = 0; y < h; y++) {
86     for (int x = 0; x < w; x++) {
87       int diff;
88       if (!use_high_bit_depth_) {
89         diff = src[y * src_stride + x] - ref[y * ref_stride + x];
90         se += diff;
91         sse += diff * diff;
92 #if CONFIG_HIGHBITDEPTH
93       } else {
94         diff = CONVERT_TO_SHORTPTR(src)[y * src_stride + x] -
95                CONVERT_TO_SHORTPTR(ref)[y * ref_stride + x];
96         se += diff;
97         sse += diff * diff;
98 #endif  // CONFIG_HIGHBITDEPTH
99       }
100     }
101   }
102   RoundHighBitDepth(bit_depth, &se, &sse);
103   *sse_ptr = static_cast<uint32_t>(sse);
104   return static_cast<uint32_t>(sse - ((se * se) >> (l2w + l2h)));
105 }
106 
107 /* The subpel reference functions differ from the codec version in one aspect:
108  * they calculate the bilinear factors directly instead of using a lookup table
109  * and therefore upshift xoff and yoff by 1. Only every other calculated value
110  * is used so the codec version shrinks the table to save space and maintain
111  * compatibility with vp8.
112  */
subpel_variance_ref(const uint8_t * ref,const uint8_t * src,int l2w,int l2h,int xoff,int yoff,uint32_t * sse_ptr,bool use_high_bit_depth_,aom_bit_depth_t bit_depth)113 static uint32_t subpel_variance_ref(const uint8_t *ref, const uint8_t *src,
114                                     int l2w, int l2h, int xoff, int yoff,
115                                     uint32_t *sse_ptr, bool use_high_bit_depth_,
116                                     aom_bit_depth_t bit_depth) {
117   int64_t se = 0;
118   uint64_t sse = 0;
119   const int w = 1 << l2w;
120   const int h = 1 << l2h;
121 
122   xoff <<= 1;
123   yoff <<= 1;
124 
125   for (int y = 0; y < h; y++) {
126     for (int x = 0; x < w; x++) {
127       // Bilinear interpolation at a 16th pel step.
128       if (!use_high_bit_depth_) {
129         const int a1 = ref[(w + 1) * (y + 0) + x + 0];
130         const int a2 = ref[(w + 1) * (y + 0) + x + 1];
131         const int b1 = ref[(w + 1) * (y + 1) + x + 0];
132         const int b2 = ref[(w + 1) * (y + 1) + x + 1];
133         const int a = a1 + (((a2 - a1) * xoff + 8) >> 4);
134         const int b = b1 + (((b2 - b1) * xoff + 8) >> 4);
135         const int r = a + (((b - a) * yoff + 8) >> 4);
136         const int diff = r - src[w * y + x];
137         se += diff;
138         sse += diff * diff;
139 #if CONFIG_HIGHBITDEPTH
140       } else {
141         uint16_t *ref16 = CONVERT_TO_SHORTPTR(ref);
142         uint16_t *src16 = CONVERT_TO_SHORTPTR(src);
143         const int a1 = ref16[(w + 1) * (y + 0) + x + 0];
144         const int a2 = ref16[(w + 1) * (y + 0) + x + 1];
145         const int b1 = ref16[(w + 1) * (y + 1) + x + 0];
146         const int b2 = ref16[(w + 1) * (y + 1) + x + 1];
147         const int a = a1 + (((a2 - a1) * xoff + 8) >> 4);
148         const int b = b1 + (((b2 - b1) * xoff + 8) >> 4);
149         const int r = a + (((b - a) * yoff + 8) >> 4);
150         const int diff = r - src16[w * y + x];
151         se += diff;
152         sse += diff * diff;
153 #endif  // CONFIG_HIGHBITDEPTH
154       }
155     }
156   }
157   RoundHighBitDepth(bit_depth, &se, &sse);
158   *sse_ptr = static_cast<uint32_t>(sse);
159   return static_cast<uint32_t>(sse - ((se * se) >> (l2w + l2h)));
160 }
161 
subpel_avg_variance_ref(const uint8_t * ref,const uint8_t * src,const uint8_t * second_pred,int l2w,int l2h,int xoff,int yoff,uint32_t * sse_ptr,bool use_high_bit_depth,aom_bit_depth_t bit_depth)162 static uint32_t subpel_avg_variance_ref(const uint8_t *ref, const uint8_t *src,
163                                         const uint8_t *second_pred, int l2w,
164                                         int l2h, int xoff, int yoff,
165                                         uint32_t *sse_ptr,
166                                         bool use_high_bit_depth,
167                                         aom_bit_depth_t bit_depth) {
168   int64_t se = 0;
169   uint64_t sse = 0;
170   const int w = 1 << l2w;
171   const int h = 1 << l2h;
172 
173   xoff <<= 1;
174   yoff <<= 1;
175 
176   for (int y = 0; y < h; y++) {
177     for (int x = 0; x < w; x++) {
178       // bilinear interpolation at a 16th pel step
179       if (!use_high_bit_depth) {
180         const int a1 = ref[(w + 1) * (y + 0) + x + 0];
181         const int a2 = ref[(w + 1) * (y + 0) + x + 1];
182         const int b1 = ref[(w + 1) * (y + 1) + x + 0];
183         const int b2 = ref[(w + 1) * (y + 1) + x + 1];
184         const int a = a1 + (((a2 - a1) * xoff + 8) >> 4);
185         const int b = b1 + (((b2 - b1) * xoff + 8) >> 4);
186         const int r = a + (((b - a) * yoff + 8) >> 4);
187         const int diff =
188             ((r + second_pred[w * y + x] + 1) >> 1) - src[w * y + x];
189         se += diff;
190         sse += diff * diff;
191 #if CONFIG_HIGHBITDEPTH
192       } else {
193         const uint16_t *ref16 = CONVERT_TO_SHORTPTR(ref);
194         const uint16_t *src16 = CONVERT_TO_SHORTPTR(src);
195         const uint16_t *sec16 = CONVERT_TO_SHORTPTR(second_pred);
196         const int a1 = ref16[(w + 1) * (y + 0) + x + 0];
197         const int a2 = ref16[(w + 1) * (y + 0) + x + 1];
198         const int b1 = ref16[(w + 1) * (y + 1) + x + 0];
199         const int b2 = ref16[(w + 1) * (y + 1) + x + 1];
200         const int a = a1 + (((a2 - a1) * xoff + 8) >> 4);
201         const int b = b1 + (((b2 - b1) * xoff + 8) >> 4);
202         const int r = a + (((b - a) * yoff + 8) >> 4);
203         const int diff = ((r + sec16[w * y + x] + 1) >> 1) - src16[w * y + x];
204         se += diff;
205         sse += diff * diff;
206 #endif  // CONFIG_HIGHBITDEPTH
207       }
208     }
209   }
210   RoundHighBitDepth(bit_depth, &se, &sse);
211   *sse_ptr = static_cast<uint32_t>(sse);
212   return static_cast<uint32_t>(sse - ((se * se) >> (l2w + l2h)));
213 }
214 
215 ////////////////////////////////////////////////////////////////////////////////
216 
217 class SumOfSquaresTest : public ::testing::TestWithParam<SumOfSquaresFunction> {
218  public:
SumOfSquaresTest()219   SumOfSquaresTest() : func_(GetParam()) {}
220 
~SumOfSquaresTest()221   virtual ~SumOfSquaresTest() { libaom_test::ClearSystemState(); }
222 
223  protected:
224   void ConstTest();
225   void RefTest();
226 
227   SumOfSquaresFunction func_;
228   ACMRandom rnd_;
229 };
230 
ConstTest()231 void SumOfSquaresTest::ConstTest() {
232   int16_t mem[256];
233   unsigned int res;
234   for (int v = 0; v < 256; ++v) {
235     for (int i = 0; i < 256; ++i) {
236       mem[i] = v;
237     }
238     ASM_REGISTER_STATE_CHECK(res = func_(mem));
239     EXPECT_EQ(256u * (v * v), res);
240   }
241 }
242 
RefTest()243 void SumOfSquaresTest::RefTest() {
244   int16_t mem[256];
245   for (int i = 0; i < 100; ++i) {
246     for (int j = 0; j < 256; ++j) {
247       mem[j] = rnd_.Rand8() - rnd_.Rand8();
248     }
249 
250     const unsigned int expected = mb_ss_ref(mem);
251     unsigned int res;
252     ASM_REGISTER_STATE_CHECK(res = func_(mem));
253     EXPECT_EQ(expected, res);
254   }
255 }
256 
257 ////////////////////////////////////////////////////////////////////////////////
258 // Encapsulating struct to store the function to test along with
259 // some testing context.
260 // Can be used for MSE, SSE, Variance, etc.
261 
262 template <typename Func>
263 struct TestParams {
TestParams__anon3db672540111::TestParams264   TestParams(int log2w = 0, int log2h = 0, Func function = NULL,
265              int bit_depth_value = 0)
266       : log2width(log2w), log2height(log2h), func(function) {
267     use_high_bit_depth = (bit_depth_value > 0);
268     if (use_high_bit_depth) {
269       bit_depth = static_cast<aom_bit_depth_t>(bit_depth_value);
270     } else {
271       bit_depth = AOM_BITS_8;
272     }
273     width = 1 << log2width;
274     height = 1 << log2height;
275     block_size = width * height;
276     mask = (1u << bit_depth) - 1;
277   }
278 
279   int log2width, log2height;
280   int width, height;
281   int block_size;
282   Func func;
283   aom_bit_depth_t bit_depth;
284   bool use_high_bit_depth;
285   uint32_t mask;
286 };
287 
288 template <typename Func>
operator <<(std::ostream & os,const TestParams<Func> & p)289 std::ostream &operator<<(std::ostream &os, const TestParams<Func> &p) {
290   return os << "log2width/height:" << p.log2width << "/" << p.log2height
291             << " function:" << reinterpret_cast<const void *>(p.func)
292             << " bit-depth:" << p.bit_depth;
293 }
294 
295 // Main class for testing a function type
296 template <typename FunctionType>
297 class MainTestClass
298     : public ::testing::TestWithParam<TestParams<FunctionType> > {
299  public:
SetUp()300   virtual void SetUp() {
301     params_ = this->GetParam();
302 
303     rnd_.Reset(ACMRandom::DeterministicSeed());
304     const size_t unit =
305         use_high_bit_depth() ? sizeof(uint16_t) : sizeof(uint8_t);
306     src_ = reinterpret_cast<uint8_t *>(aom_memalign(16, block_size() * unit));
307     ref_ = new uint8_t[block_size() * unit];
308     ASSERT_TRUE(src_ != NULL);
309     ASSERT_TRUE(ref_ != NULL);
310 #if CONFIG_HIGHBITDEPTH
311     if (use_high_bit_depth()) {
312       // TODO(skal): remove!
313       src_ = CONVERT_TO_BYTEPTR(src_);
314       ref_ = CONVERT_TO_BYTEPTR(ref_);
315     }
316 #endif
317   }
318 
TearDown()319   virtual void TearDown() {
320 #if CONFIG_HIGHBITDEPTH
321     if (use_high_bit_depth()) {
322       // TODO(skal): remove!
323       src_ = reinterpret_cast<uint8_t *>(CONVERT_TO_SHORTPTR(src_));
324       ref_ = reinterpret_cast<uint8_t *>(CONVERT_TO_SHORTPTR(ref_));
325     }
326 #endif
327 
328     aom_free(src_);
329     delete[] ref_;
330     src_ = NULL;
331     ref_ = NULL;
332     libaom_test::ClearSystemState();
333   }
334 
335  protected:
336   // We could sub-class MainTestClass into dedicated class for Variance
337   // and MSE/SSE, but it involves a lot of 'this->xxx' dereferencing
338   // to access top class fields xxx. That's cumbersome, so for now we'll just
339   // implement the testing methods here:
340 
341   // Variance tests
342   void ZeroTest();
343   void RefTest();
344   void RefStrideTest();
345   void OneQuarterTest();
346 
347   // MSE/SSE tests
348   void RefTestMse();
349   void RefTestSse();
350   void MaxTestMse();
351   void MaxTestSse();
352 
353  protected:
354   ACMRandom rnd_;
355   uint8_t *src_;
356   uint8_t *ref_;
357   TestParams<FunctionType> params_;
358 
359   // some relay helpers
use_high_bit_depth() const360   bool use_high_bit_depth() const { return params_.use_high_bit_depth; }
byte_shift() const361   int byte_shift() const { return params_.bit_depth - 8; }
block_size() const362   int block_size() const { return params_.block_size; }
width() const363   int width() const { return params_.width; }
mask() const364   uint32_t mask() const { return params_.mask; }
365 };
366 
367 ////////////////////////////////////////////////////////////////////////////////
368 // Tests related to variance.
369 
370 template <typename VarianceFunctionType>
ZeroTest()371 void MainTestClass<VarianceFunctionType>::ZeroTest() {
372   for (int i = 0; i <= 255; ++i) {
373     if (!use_high_bit_depth()) {
374       memset(src_, i, block_size());
375     } else {
376       uint16_t *const src16 = CONVERT_TO_SHORTPTR(src_);
377       for (int k = 0; k < block_size(); ++k) src16[k] = i << byte_shift();
378     }
379     for (int j = 0; j <= 255; ++j) {
380       if (!use_high_bit_depth()) {
381         memset(ref_, j, block_size());
382       } else {
383         uint16_t *const ref16 = CONVERT_TO_SHORTPTR(ref_);
384         for (int k = 0; k < block_size(); ++k) ref16[k] = j << byte_shift();
385       }
386       unsigned int sse, var;
387       ASM_REGISTER_STATE_CHECK(
388           var = params_.func(src_, width(), ref_, width(), &sse));
389       EXPECT_EQ(0u, var) << "src values: " << i << " ref values: " << j;
390     }
391   }
392 }
393 
394 template <typename VarianceFunctionType>
RefTest()395 void MainTestClass<VarianceFunctionType>::RefTest() {
396   for (int i = 0; i < 10; ++i) {
397     for (int j = 0; j < block_size(); j++) {
398       if (!use_high_bit_depth()) {
399         src_[j] = rnd_.Rand8();
400         ref_[j] = rnd_.Rand8();
401 #if CONFIG_HIGHBITDEPTH
402       } else {
403         CONVERT_TO_SHORTPTR(src_)[j] = rnd_.Rand16() & mask();
404         CONVERT_TO_SHORTPTR(ref_)[j] = rnd_.Rand16() & mask();
405 #endif  // CONFIG_HIGHBITDEPTH
406       }
407     }
408     unsigned int sse1, sse2, var1, var2;
409     const int stride = width();
410     ASM_REGISTER_STATE_CHECK(
411         var1 = params_.func(src_, stride, ref_, stride, &sse1));
412     var2 =
413         variance_ref(src_, ref_, params_.log2width, params_.log2height, stride,
414                      stride, &sse2, use_high_bit_depth(), params_.bit_depth);
415     EXPECT_EQ(sse1, sse2) << "Error at test index: " << i;
416     EXPECT_EQ(var1, var2) << "Error at test index: " << i;
417   }
418 }
419 
420 template <typename VarianceFunctionType>
RefStrideTest()421 void MainTestClass<VarianceFunctionType>::RefStrideTest() {
422   for (int i = 0; i < 10; ++i) {
423     const int ref_stride = (i & 1) * width();
424     const int src_stride = ((i >> 1) & 1) * width();
425     for (int j = 0; j < block_size(); j++) {
426       const int ref_ind = (j / width()) * ref_stride + j % width();
427       const int src_ind = (j / width()) * src_stride + j % width();
428       if (!use_high_bit_depth()) {
429         src_[src_ind] = rnd_.Rand8();
430         ref_[ref_ind] = rnd_.Rand8();
431 #if CONFIG_HIGHBITDEPTH
432       } else {
433         CONVERT_TO_SHORTPTR(src_)[src_ind] = rnd_.Rand16() & mask();
434         CONVERT_TO_SHORTPTR(ref_)[ref_ind] = rnd_.Rand16() & mask();
435 #endif  // CONFIG_HIGHBITDEPTH
436       }
437     }
438     unsigned int sse1, sse2;
439     unsigned int var1, var2;
440 
441     ASM_REGISTER_STATE_CHECK(
442         var1 = params_.func(src_, src_stride, ref_, ref_stride, &sse1));
443     var2 = variance_ref(src_, ref_, params_.log2width, params_.log2height,
444                         src_stride, ref_stride, &sse2, use_high_bit_depth(),
445                         params_.bit_depth);
446     EXPECT_EQ(sse1, sse2) << "Error at test index: " << i;
447     EXPECT_EQ(var1, var2) << "Error at test index: " << i;
448   }
449 }
450 
451 template <typename VarianceFunctionType>
OneQuarterTest()452 void MainTestClass<VarianceFunctionType>::OneQuarterTest() {
453   const int half = block_size() / 2;
454   if (!use_high_bit_depth()) {
455     memset(src_, 255, block_size());
456     memset(ref_, 255, half);
457     memset(ref_ + half, 0, half);
458 #if CONFIG_HIGHBITDEPTH
459   } else {
460     aom_memset16(CONVERT_TO_SHORTPTR(src_), 255 << byte_shift(), block_size());
461     aom_memset16(CONVERT_TO_SHORTPTR(ref_), 255 << byte_shift(), half);
462     aom_memset16(CONVERT_TO_SHORTPTR(ref_) + half, 0, half);
463 #endif  // CONFIG_HIGHBITDEPTH
464   }
465   unsigned int sse, var, expected;
466   ASM_REGISTER_STATE_CHECK(
467       var = params_.func(src_, width(), ref_, width(), &sse));
468   expected = block_size() * 255 * 255 / 4;
469   EXPECT_EQ(expected, var);
470 }
471 
472 ////////////////////////////////////////////////////////////////////////////////
473 // Tests related to MSE / SSE.
474 
475 template <typename FunctionType>
RefTestMse()476 void MainTestClass<FunctionType>::RefTestMse() {
477   for (int i = 0; i < 10; ++i) {
478     for (int j = 0; j < block_size(); ++j) {
479       src_[j] = rnd_.Rand8();
480       ref_[j] = rnd_.Rand8();
481     }
482     unsigned int sse1, sse2;
483     const int stride = width();
484     ASM_REGISTER_STATE_CHECK(params_.func(src_, stride, ref_, stride, &sse1));
485     variance_ref(src_, ref_, params_.log2width, params_.log2height, stride,
486                  stride, &sse2, false, AOM_BITS_8);
487     EXPECT_EQ(sse1, sse2);
488   }
489 }
490 
491 template <typename FunctionType>
RefTestSse()492 void MainTestClass<FunctionType>::RefTestSse() {
493   for (int i = 0; i < 10; ++i) {
494     for (int j = 0; j < block_size(); ++j) {
495       src_[j] = rnd_.Rand8();
496       ref_[j] = rnd_.Rand8();
497     }
498     unsigned int sse2;
499     unsigned int var1;
500     const int stride = width();
501     ASM_REGISTER_STATE_CHECK(var1 = params_.func(src_, stride, ref_, stride));
502     variance_ref(src_, ref_, params_.log2width, params_.log2height, stride,
503                  stride, &sse2, false, AOM_BITS_8);
504     EXPECT_EQ(var1, sse2);
505   }
506 }
507 
508 template <typename FunctionType>
MaxTestMse()509 void MainTestClass<FunctionType>::MaxTestMse() {
510   memset(src_, 255, block_size());
511   memset(ref_, 0, block_size());
512   unsigned int sse;
513   ASM_REGISTER_STATE_CHECK(params_.func(src_, width(), ref_, width(), &sse));
514   const unsigned int expected = block_size() * 255 * 255;
515   EXPECT_EQ(expected, sse);
516 }
517 
518 template <typename FunctionType>
MaxTestSse()519 void MainTestClass<FunctionType>::MaxTestSse() {
520   memset(src_, 255, block_size());
521   memset(ref_, 0, block_size());
522   unsigned int var;
523   ASM_REGISTER_STATE_CHECK(var = params_.func(src_, width(), ref_, width()));
524   const unsigned int expected = block_size() * 255 * 255;
525   EXPECT_EQ(expected, var);
526 }
527 
528 ////////////////////////////////////////////////////////////////////////////////
529 
530 using ::std::tr1::get;
531 using ::std::tr1::make_tuple;
532 using ::std::tr1::tuple;
533 
534 template <typename FunctionType>
535 class SubpelVarianceTest
536     : public ::testing::TestWithParam<TestParams<FunctionType> > {
537  public:
SetUp()538   virtual void SetUp() {
539     params_ = this->GetParam();
540 
541     rnd_.Reset(ACMRandom::DeterministicSeed());
542     if (!use_high_bit_depth()) {
543       src_ = reinterpret_cast<uint8_t *>(aom_memalign(16, block_size()));
544       sec_ = reinterpret_cast<uint8_t *>(aom_memalign(16, block_size()));
545       ref_ = new uint8_t[block_size() + width() + height() + 1];
546 #if CONFIG_HIGHBITDEPTH
547     } else {
548       src_ = CONVERT_TO_BYTEPTR(reinterpret_cast<uint16_t *>(
549           aom_memalign(16, block_size() * sizeof(uint16_t))));
550       sec_ = CONVERT_TO_BYTEPTR(reinterpret_cast<uint16_t *>(
551           aom_memalign(16, block_size() * sizeof(uint16_t))));
552       ref_ = CONVERT_TO_BYTEPTR(aom_memalign(
553           16, (block_size() + width() + height() + 1) * sizeof(uint16_t)));
554 #endif  // CONFIG_HIGHBITDEPTH
555     }
556     ASSERT_TRUE(src_ != NULL);
557     ASSERT_TRUE(sec_ != NULL);
558     ASSERT_TRUE(ref_ != NULL);
559   }
560 
TearDown()561   virtual void TearDown() {
562     if (!use_high_bit_depth()) {
563       aom_free(src_);
564       delete[] ref_;
565       aom_free(sec_);
566 #if CONFIG_HIGHBITDEPTH
567     } else {
568       aom_free(CONVERT_TO_SHORTPTR(src_));
569       aom_free(CONVERT_TO_SHORTPTR(ref_));
570       aom_free(CONVERT_TO_SHORTPTR(sec_));
571 #endif  // CONFIG_HIGHBITDEPTH
572     }
573     libaom_test::ClearSystemState();
574   }
575 
576  protected:
577   void RefTest();
578   void ExtremeRefTest();
579 
580   ACMRandom rnd_;
581   uint8_t *src_;
582   uint8_t *ref_;
583   uint8_t *sec_;
584   TestParams<FunctionType> params_;
585 
586   // some relay helpers
use_high_bit_depth() const587   bool use_high_bit_depth() const { return params_.use_high_bit_depth; }
byte_shift() const588   int byte_shift() const { return params_.bit_depth - 8; }
block_size() const589   int block_size() const { return params_.block_size; }
width() const590   int width() const { return params_.width; }
height() const591   int height() const { return params_.height; }
mask() const592   uint32_t mask() const { return params_.mask; }
593 };
594 
595 template <typename SubpelVarianceFunctionType>
RefTest()596 void SubpelVarianceTest<SubpelVarianceFunctionType>::RefTest() {
597   for (int x = 0; x < 8; ++x) {
598     for (int y = 0; y < 8; ++y) {
599       if (!use_high_bit_depth()) {
600         for (int j = 0; j < block_size(); j++) {
601           src_[j] = rnd_.Rand8();
602         }
603         for (int j = 0; j < block_size() + width() + height() + 1; j++) {
604           ref_[j] = rnd_.Rand8();
605         }
606 #if CONFIG_HIGHBITDEPTH
607       } else {
608         for (int j = 0; j < block_size(); j++) {
609           CONVERT_TO_SHORTPTR(src_)[j] = rnd_.Rand16() & mask();
610         }
611         for (int j = 0; j < block_size() + width() + height() + 1; j++) {
612           CONVERT_TO_SHORTPTR(ref_)[j] = rnd_.Rand16() & mask();
613         }
614 #endif  // CONFIG_HIGHBITDEPTH
615       }
616       unsigned int sse1, sse2;
617       unsigned int var1;
618       ASM_REGISTER_STATE_CHECK(
619           var1 = params_.func(ref_, width() + 1, x, y, src_, width(), &sse1));
620       const unsigned int var2 = subpel_variance_ref(
621           ref_, src_, params_.log2width, params_.log2height, x, y, &sse2,
622           use_high_bit_depth(), params_.bit_depth);
623       EXPECT_EQ(sse1, sse2) << "at position " << x << ", " << y;
624       EXPECT_EQ(var1, var2) << "at position " << x << ", " << y;
625     }
626   }
627 }
628 
629 template <typename SubpelVarianceFunctionType>
ExtremeRefTest()630 void SubpelVarianceTest<SubpelVarianceFunctionType>::ExtremeRefTest() {
631   // Compare against reference.
632   // Src: Set the first half of values to 0, the second half to the maximum.
633   // Ref: Set the first half of values to the maximum, the second half to 0.
634   for (int x = 0; x < 8; ++x) {
635     for (int y = 0; y < 8; ++y) {
636       const int half = block_size() / 2;
637       if (!use_high_bit_depth()) {
638         memset(src_, 0, half);
639         memset(src_ + half, 255, half);
640         memset(ref_, 255, half);
641         memset(ref_ + half, 0, half + width() + height() + 1);
642 #if CONFIG_HIGHBITDEPTH
643       } else {
644         aom_memset16(CONVERT_TO_SHORTPTR(src_), mask(), half);
645         aom_memset16(CONVERT_TO_SHORTPTR(src_) + half, 0, half);
646         aom_memset16(CONVERT_TO_SHORTPTR(ref_), 0, half);
647         aom_memset16(CONVERT_TO_SHORTPTR(ref_) + half, mask(),
648                      half + width() + height() + 1);
649 #endif  // CONFIG_HIGHBITDEPTH
650       }
651       unsigned int sse1, sse2;
652       unsigned int var1;
653       ASM_REGISTER_STATE_CHECK(
654           var1 = params_.func(ref_, width() + 1, x, y, src_, width(), &sse1));
655       const unsigned int var2 = subpel_variance_ref(
656           ref_, src_, params_.log2width, params_.log2height, x, y, &sse2,
657           use_high_bit_depth(), params_.bit_depth);
658       EXPECT_EQ(sse1, sse2) << "for xoffset " << x << " and yoffset " << y;
659       EXPECT_EQ(var1, var2) << "for xoffset " << x << " and yoffset " << y;
660     }
661   }
662 }
663 
664 template <>
RefTest()665 void SubpelVarianceTest<SubpixAvgVarMxNFunc>::RefTest() {
666   for (int x = 0; x < 8; ++x) {
667     for (int y = 0; y < 8; ++y) {
668       if (!use_high_bit_depth()) {
669         for (int j = 0; j < block_size(); j++) {
670           src_[j] = rnd_.Rand8();
671           sec_[j] = rnd_.Rand8();
672         }
673         for (int j = 0; j < block_size() + width() + height() + 1; j++) {
674           ref_[j] = rnd_.Rand8();
675         }
676 #if CONFIG_HIGHBITDEPTH
677       } else {
678         for (int j = 0; j < block_size(); j++) {
679           CONVERT_TO_SHORTPTR(src_)[j] = rnd_.Rand16() & mask();
680           CONVERT_TO_SHORTPTR(sec_)[j] = rnd_.Rand16() & mask();
681         }
682         for (int j = 0; j < block_size() + width() + height() + 1; j++) {
683           CONVERT_TO_SHORTPTR(ref_)[j] = rnd_.Rand16() & mask();
684         }
685 #endif  // CONFIG_HIGHBITDEPTH
686       }
687       uint32_t sse1, sse2;
688       uint32_t var1, var2;
689       ASM_REGISTER_STATE_CHECK(var1 = params_.func(ref_, width() + 1, x, y,
690                                                    src_, width(), &sse1, sec_));
691       var2 = subpel_avg_variance_ref(ref_, src_, sec_, params_.log2width,
692                                      params_.log2height, x, y, &sse2,
693                                      use_high_bit_depth(), params_.bit_depth);
694       EXPECT_EQ(sse1, sse2) << "at position " << x << ", " << y;
695       EXPECT_EQ(var1, var2) << "at position " << x << ", " << y;
696     }
697   }
698 }
699 
700 typedef MainTestClass<Get4x4SseFunc> AvxSseTest;
701 typedef MainTestClass<VarianceMxNFunc> AvxMseTest;
702 typedef MainTestClass<VarianceMxNFunc> AvxVarianceTest;
703 typedef SubpelVarianceTest<SubpixVarMxNFunc> AvxSubpelVarianceTest;
704 typedef SubpelVarianceTest<SubpixAvgVarMxNFunc> AvxSubpelAvgVarianceTest;
705 
TEST_P(AvxSseTest,RefSse)706 TEST_P(AvxSseTest, RefSse) { RefTestSse(); }
TEST_P(AvxSseTest,MaxSse)707 TEST_P(AvxSseTest, MaxSse) { MaxTestSse(); }
TEST_P(AvxMseTest,RefMse)708 TEST_P(AvxMseTest, RefMse) { RefTestMse(); }
TEST_P(AvxMseTest,MaxMse)709 TEST_P(AvxMseTest, MaxMse) { MaxTestMse(); }
TEST_P(AvxVarianceTest,Zero)710 TEST_P(AvxVarianceTest, Zero) { ZeroTest(); }
TEST_P(AvxVarianceTest,Ref)711 TEST_P(AvxVarianceTest, Ref) { RefTest(); }
TEST_P(AvxVarianceTest,RefStride)712 TEST_P(AvxVarianceTest, RefStride) { RefStrideTest(); }
TEST_P(AvxVarianceTest,OneQuarter)713 TEST_P(AvxVarianceTest, OneQuarter) { OneQuarterTest(); }
TEST_P(SumOfSquaresTest,Const)714 TEST_P(SumOfSquaresTest, Const) { ConstTest(); }
TEST_P(SumOfSquaresTest,Ref)715 TEST_P(SumOfSquaresTest, Ref) { RefTest(); }
TEST_P(AvxSubpelVarianceTest,Ref)716 TEST_P(AvxSubpelVarianceTest, Ref) { RefTest(); }
TEST_P(AvxSubpelVarianceTest,ExtremeRef)717 TEST_P(AvxSubpelVarianceTest, ExtremeRef) { ExtremeRefTest(); }
TEST_P(AvxSubpelAvgVarianceTest,Ref)718 TEST_P(AvxSubpelAvgVarianceTest, Ref) { RefTest(); }
719 
720 INSTANTIATE_TEST_CASE_P(C, SumOfSquaresTest,
721                         ::testing::Values(aom_get_mb_ss_c));
722 
723 typedef TestParams<Get4x4SseFunc> SseParams;
724 INSTANTIATE_TEST_CASE_P(C, AvxSseTest,
725                         ::testing::Values(SseParams(2, 2,
726                                                     &aom_get4x4sse_cs_c)));
727 
728 typedef TestParams<VarianceMxNFunc> MseParams;
729 INSTANTIATE_TEST_CASE_P(C, AvxMseTest,
730                         ::testing::Values(MseParams(4, 4, &aom_mse16x16_c),
731                                           MseParams(4, 3, &aom_mse16x8_c),
732                                           MseParams(3, 4, &aom_mse8x16_c),
733                                           MseParams(3, 3, &aom_mse8x8_c)));
734 
735 typedef TestParams<VarianceMxNFunc> VarianceParams;
736 INSTANTIATE_TEST_CASE_P(
737     C, AvxVarianceTest,
738     ::testing::Values(VarianceParams(6, 6, &aom_variance64x64_c),
739                       VarianceParams(6, 5, &aom_variance64x32_c),
740                       VarianceParams(5, 6, &aom_variance32x64_c),
741                       VarianceParams(5, 5, &aom_variance32x32_c),
742                       VarianceParams(5, 4, &aom_variance32x16_c),
743                       VarianceParams(4, 5, &aom_variance16x32_c),
744                       VarianceParams(4, 4, &aom_variance16x16_c),
745                       VarianceParams(4, 3, &aom_variance16x8_c),
746                       VarianceParams(3, 4, &aom_variance8x16_c),
747                       VarianceParams(3, 3, &aom_variance8x8_c),
748                       VarianceParams(3, 2, &aom_variance8x4_c),
749                       VarianceParams(2, 3, &aom_variance4x8_c),
750                       VarianceParams(2, 2, &aom_variance4x4_c)));
751 
752 typedef TestParams<SubpixVarMxNFunc> SubpelVarianceParams;
753 INSTANTIATE_TEST_CASE_P(
754     C, AvxSubpelVarianceTest,
755     ::testing::Values(
756         SubpelVarianceParams(6, 6, &aom_sub_pixel_variance64x64_c, 0),
757         SubpelVarianceParams(6, 5, &aom_sub_pixel_variance64x32_c, 0),
758         SubpelVarianceParams(5, 6, &aom_sub_pixel_variance32x64_c, 0),
759         SubpelVarianceParams(5, 5, &aom_sub_pixel_variance32x32_c, 0),
760         SubpelVarianceParams(5, 4, &aom_sub_pixel_variance32x16_c, 0),
761         SubpelVarianceParams(4, 5, &aom_sub_pixel_variance16x32_c, 0),
762         SubpelVarianceParams(4, 4, &aom_sub_pixel_variance16x16_c, 0),
763         SubpelVarianceParams(4, 3, &aom_sub_pixel_variance16x8_c, 0),
764         SubpelVarianceParams(3, 4, &aom_sub_pixel_variance8x16_c, 0),
765         SubpelVarianceParams(3, 3, &aom_sub_pixel_variance8x8_c, 0),
766         SubpelVarianceParams(3, 2, &aom_sub_pixel_variance8x4_c, 0),
767         SubpelVarianceParams(2, 3, &aom_sub_pixel_variance4x8_c, 0),
768         SubpelVarianceParams(2, 2, &aom_sub_pixel_variance4x4_c, 0)));
769 
770 typedef TestParams<SubpixAvgVarMxNFunc> SubpelAvgVarianceParams;
771 INSTANTIATE_TEST_CASE_P(
772     C, AvxSubpelAvgVarianceTest,
773     ::testing::Values(
774         SubpelAvgVarianceParams(6, 6, &aom_sub_pixel_avg_variance64x64_c, 0),
775         SubpelAvgVarianceParams(6, 5, &aom_sub_pixel_avg_variance64x32_c, 0),
776         SubpelAvgVarianceParams(5, 6, &aom_sub_pixel_avg_variance32x64_c, 0),
777         SubpelAvgVarianceParams(5, 5, &aom_sub_pixel_avg_variance32x32_c, 0),
778         SubpelAvgVarianceParams(5, 4, &aom_sub_pixel_avg_variance32x16_c, 0),
779         SubpelAvgVarianceParams(4, 5, &aom_sub_pixel_avg_variance16x32_c, 0),
780         SubpelAvgVarianceParams(4, 4, &aom_sub_pixel_avg_variance16x16_c, 0),
781         SubpelAvgVarianceParams(4, 3, &aom_sub_pixel_avg_variance16x8_c, 0),
782         SubpelAvgVarianceParams(3, 4, &aom_sub_pixel_avg_variance8x16_c, 0),
783         SubpelAvgVarianceParams(3, 3, &aom_sub_pixel_avg_variance8x8_c, 0),
784         SubpelAvgVarianceParams(3, 2, &aom_sub_pixel_avg_variance8x4_c, 0),
785         SubpelAvgVarianceParams(2, 3, &aom_sub_pixel_avg_variance4x8_c, 0),
786         SubpelAvgVarianceParams(2, 2, &aom_sub_pixel_avg_variance4x4_c, 0)));
787 
788 #if CONFIG_HIGHBITDEPTH
789 typedef MainTestClass<VarianceMxNFunc> AvxHBDMseTest;
790 typedef MainTestClass<VarianceMxNFunc> AvxHBDVarianceTest;
791 typedef SubpelVarianceTest<SubpixVarMxNFunc> AvxHBDSubpelVarianceTest;
792 typedef SubpelVarianceTest<SubpixAvgVarMxNFunc> AvxHBDSubpelAvgVarianceTest;
793 
TEST_P(AvxHBDMseTest,RefMse)794 TEST_P(AvxHBDMseTest, RefMse) { RefTestMse(); }
TEST_P(AvxHBDMseTest,MaxMse)795 TEST_P(AvxHBDMseTest, MaxMse) { MaxTestMse(); }
TEST_P(AvxHBDVarianceTest,Zero)796 TEST_P(AvxHBDVarianceTest, Zero) { ZeroTest(); }
TEST_P(AvxHBDVarianceTest,Ref)797 TEST_P(AvxHBDVarianceTest, Ref) { RefTest(); }
TEST_P(AvxHBDVarianceTest,RefStride)798 TEST_P(AvxHBDVarianceTest, RefStride) { RefStrideTest(); }
TEST_P(AvxHBDVarianceTest,OneQuarter)799 TEST_P(AvxHBDVarianceTest, OneQuarter) { OneQuarterTest(); }
TEST_P(AvxHBDSubpelVarianceTest,Ref)800 TEST_P(AvxHBDSubpelVarianceTest, Ref) { RefTest(); }
TEST_P(AvxHBDSubpelVarianceTest,ExtremeRef)801 TEST_P(AvxHBDSubpelVarianceTest, ExtremeRef) { ExtremeRefTest(); }
TEST_P(AvxHBDSubpelAvgVarianceTest,Ref)802 TEST_P(AvxHBDSubpelAvgVarianceTest, Ref) { RefTest(); }
803 
804 /* TODO(debargha): This test does not support the highbd version
805 INSTANTIATE_TEST_CASE_P(
806     C, AvxHBDMseTest,
807     ::testing::Values(make_tuple(4, 4, &aom_highbd_12_mse16x16_c),
808                       make_tuple(4, 4, &aom_highbd_12_mse16x8_c),
809                       make_tuple(4, 4, &aom_highbd_12_mse8x16_c),
810                       make_tuple(4, 4, &aom_highbd_12_mse8x8_c),
811                       make_tuple(4, 4, &aom_highbd_10_mse16x16_c),
812                       make_tuple(4, 4, &aom_highbd_10_mse16x8_c),
813                       make_tuple(4, 4, &aom_highbd_10_mse8x16_c),
814                       make_tuple(4, 4, &aom_highbd_10_mse8x8_c),
815                       make_tuple(4, 4, &aom_highbd_8_mse16x16_c),
816                       make_tuple(4, 4, &aom_highbd_8_mse16x8_c),
817                       make_tuple(4, 4, &aom_highbd_8_mse8x16_c),
818                       make_tuple(4, 4, &aom_highbd_8_mse8x8_c)));
819 */
820 
821 const VarianceParams kArrayHBDVariance_c[] = {
822 #if CONFIG_AV1 && CONFIG_EXT_PARTITION
823   VarianceParams(7, 7, &aom_highbd_12_variance128x128_c, 12),
824   VarianceParams(7, 6, &aom_highbd_12_variance128x64_c, 12),
825   VarianceParams(6, 7, &aom_highbd_12_variance64x128_c, 12),
826 #endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
827   VarianceParams(6, 6, &aom_highbd_12_variance64x64_c, 12),
828   VarianceParams(6, 5, &aom_highbd_12_variance64x32_c, 12),
829   VarianceParams(5, 6, &aom_highbd_12_variance32x64_c, 12),
830   VarianceParams(5, 5, &aom_highbd_12_variance32x32_c, 12),
831   VarianceParams(5, 4, &aom_highbd_12_variance32x16_c, 12),
832   VarianceParams(4, 5, &aom_highbd_12_variance16x32_c, 12),
833   VarianceParams(4, 4, &aom_highbd_12_variance16x16_c, 12),
834   VarianceParams(4, 3, &aom_highbd_12_variance16x8_c, 12),
835   VarianceParams(3, 4, &aom_highbd_12_variance8x16_c, 12),
836   VarianceParams(3, 3, &aom_highbd_12_variance8x8_c, 12),
837   VarianceParams(3, 2, &aom_highbd_12_variance8x4_c, 12),
838   VarianceParams(2, 3, &aom_highbd_12_variance4x8_c, 12),
839   VarianceParams(2, 2, &aom_highbd_12_variance4x4_c, 12),
840 #if CONFIG_AV1 && CONFIG_EXT_PARTITION
841   VarianceParams(7, 7, &aom_highbd_10_variance128x128_c, 10),
842   VarianceParams(7, 6, &aom_highbd_10_variance128x64_c, 10),
843   VarianceParams(6, 7, &aom_highbd_10_variance64x128_c, 10),
844 #endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
845   VarianceParams(6, 6, &aom_highbd_10_variance64x64_c, 10),
846   VarianceParams(6, 5, &aom_highbd_10_variance64x32_c, 10),
847   VarianceParams(5, 6, &aom_highbd_10_variance32x64_c, 10),
848   VarianceParams(5, 5, &aom_highbd_10_variance32x32_c, 10),
849   VarianceParams(5, 4, &aom_highbd_10_variance32x16_c, 10),
850   VarianceParams(4, 5, &aom_highbd_10_variance16x32_c, 10),
851   VarianceParams(4, 4, &aom_highbd_10_variance16x16_c, 10),
852   VarianceParams(4, 3, &aom_highbd_10_variance16x8_c, 10),
853   VarianceParams(3, 4, &aom_highbd_10_variance8x16_c, 10),
854   VarianceParams(3, 3, &aom_highbd_10_variance8x8_c, 10),
855   VarianceParams(3, 2, &aom_highbd_10_variance8x4_c, 10),
856   VarianceParams(2, 3, &aom_highbd_10_variance4x8_c, 10),
857   VarianceParams(2, 2, &aom_highbd_10_variance4x4_c, 10),
858 #if CONFIG_AV1 && CONFIG_EXT_PARTITION
859   VarianceParams(7, 7, &aom_highbd_8_variance128x128_c, 8),
860   VarianceParams(7, 6, &aom_highbd_8_variance128x64_c, 8),
861   VarianceParams(6, 7, &aom_highbd_8_variance64x128_c, 8),
862 #endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
863   VarianceParams(6, 6, &aom_highbd_8_variance64x64_c, 8),
864   VarianceParams(6, 5, &aom_highbd_8_variance64x32_c, 8),
865   VarianceParams(5, 6, &aom_highbd_8_variance32x64_c, 8),
866   VarianceParams(5, 5, &aom_highbd_8_variance32x32_c, 8),
867   VarianceParams(5, 4, &aom_highbd_8_variance32x16_c, 8),
868   VarianceParams(4, 5, &aom_highbd_8_variance16x32_c, 8),
869   VarianceParams(4, 4, &aom_highbd_8_variance16x16_c, 8),
870   VarianceParams(4, 3, &aom_highbd_8_variance16x8_c, 8),
871   VarianceParams(3, 4, &aom_highbd_8_variance8x16_c, 8),
872   VarianceParams(3, 3, &aom_highbd_8_variance8x8_c, 8),
873   VarianceParams(3, 2, &aom_highbd_8_variance8x4_c, 8),
874   VarianceParams(2, 3, &aom_highbd_8_variance4x8_c, 8),
875   VarianceParams(2, 2, &aom_highbd_8_variance4x4_c, 8)
876 };
877 INSTANTIATE_TEST_CASE_P(C, AvxHBDVarianceTest,
878                         ::testing::ValuesIn(kArrayHBDVariance_c));
879 
880 #if HAVE_SSE4_1 && CONFIG_HIGHBITDEPTH
881 INSTANTIATE_TEST_CASE_P(
882     SSE4_1, AvxHBDVarianceTest,
883     ::testing::Values(
884         VarianceParams(2, 2, &aom_highbd_8_variance4x4_sse4_1, 8),
885         VarianceParams(2, 2, &aom_highbd_10_variance4x4_sse4_1, 10),
886         VarianceParams(2, 2, &aom_highbd_12_variance4x4_sse4_1, 12)));
887 #endif  // HAVE_SSE4_1 && CONFIG_HIGHBITDEPTH
888 
889 const SubpelVarianceParams kArrayHBDSubpelVariance_c[] = {
890 #if CONFIG_AV1 && CONFIG_EXT_PARTITION
891   SubpelVarianceParams(7, 7, &aom_highbd_8_sub_pixel_variance128x128_c, 8),
892   SubpelVarianceParams(7, 6, &aom_highbd_8_sub_pixel_variance128x64_c, 8),
893   SubpelVarianceParams(6, 7, &aom_highbd_8_sub_pixel_variance64x128_c, 8),
894 #endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
895   SubpelVarianceParams(6, 6, &aom_highbd_8_sub_pixel_variance64x64_c, 8),
896   SubpelVarianceParams(6, 5, &aom_highbd_8_sub_pixel_variance64x32_c, 8),
897   SubpelVarianceParams(5, 6, &aom_highbd_8_sub_pixel_variance32x64_c, 8),
898   SubpelVarianceParams(5, 5, &aom_highbd_8_sub_pixel_variance32x32_c, 8),
899   SubpelVarianceParams(5, 4, &aom_highbd_8_sub_pixel_variance32x16_c, 8),
900   SubpelVarianceParams(4, 5, &aom_highbd_8_sub_pixel_variance16x32_c, 8),
901   SubpelVarianceParams(4, 4, &aom_highbd_8_sub_pixel_variance16x16_c, 8),
902   SubpelVarianceParams(4, 3, &aom_highbd_8_sub_pixel_variance16x8_c, 8),
903   SubpelVarianceParams(3, 4, &aom_highbd_8_sub_pixel_variance8x16_c, 8),
904   SubpelVarianceParams(3, 3, &aom_highbd_8_sub_pixel_variance8x8_c, 8),
905   SubpelVarianceParams(3, 2, &aom_highbd_8_sub_pixel_variance8x4_c, 8),
906   SubpelVarianceParams(2, 3, &aom_highbd_8_sub_pixel_variance4x8_c, 8),
907   SubpelVarianceParams(2, 2, &aom_highbd_8_sub_pixel_variance4x4_c, 8),
908 #if CONFIG_AV1 && CONFIG_EXT_PARTITION
909   SubpelVarianceParams(7, 7, &aom_highbd_10_sub_pixel_variance128x128_c, 10),
910   SubpelVarianceParams(7, 6, &aom_highbd_10_sub_pixel_variance128x64_c, 10),
911   SubpelVarianceParams(6, 7, &aom_highbd_10_sub_pixel_variance64x128_c, 10),
912 #endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
913   SubpelVarianceParams(6, 6, &aom_highbd_10_sub_pixel_variance64x64_c, 10),
914   SubpelVarianceParams(6, 5, &aom_highbd_10_sub_pixel_variance64x32_c, 10),
915   SubpelVarianceParams(5, 6, &aom_highbd_10_sub_pixel_variance32x64_c, 10),
916   SubpelVarianceParams(5, 5, &aom_highbd_10_sub_pixel_variance32x32_c, 10),
917   SubpelVarianceParams(5, 4, &aom_highbd_10_sub_pixel_variance32x16_c, 10),
918   SubpelVarianceParams(4, 5, &aom_highbd_10_sub_pixel_variance16x32_c, 10),
919   SubpelVarianceParams(4, 4, &aom_highbd_10_sub_pixel_variance16x16_c, 10),
920   SubpelVarianceParams(4, 3, &aom_highbd_10_sub_pixel_variance16x8_c, 10),
921   SubpelVarianceParams(3, 4, &aom_highbd_10_sub_pixel_variance8x16_c, 10),
922   SubpelVarianceParams(3, 3, &aom_highbd_10_sub_pixel_variance8x8_c, 10),
923   SubpelVarianceParams(3, 2, &aom_highbd_10_sub_pixel_variance8x4_c, 10),
924   SubpelVarianceParams(2, 3, &aom_highbd_10_sub_pixel_variance4x8_c, 10),
925   SubpelVarianceParams(2, 2, &aom_highbd_10_sub_pixel_variance4x4_c, 10),
926 #if CONFIG_AV1 && CONFIG_EXT_PARTITION
927   SubpelVarianceParams(7, 7, &aom_highbd_12_sub_pixel_variance128x128_c, 12),
928   SubpelVarianceParams(7, 6, &aom_highbd_12_sub_pixel_variance128x64_c, 12),
929   SubpelVarianceParams(6, 7, &aom_highbd_12_sub_pixel_variance64x128_c, 12),
930 #endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
931   SubpelVarianceParams(6, 6, &aom_highbd_12_sub_pixel_variance64x64_c, 12),
932   SubpelVarianceParams(6, 5, &aom_highbd_12_sub_pixel_variance64x32_c, 12),
933   SubpelVarianceParams(5, 6, &aom_highbd_12_sub_pixel_variance32x64_c, 12),
934   SubpelVarianceParams(5, 5, &aom_highbd_12_sub_pixel_variance32x32_c, 12),
935   SubpelVarianceParams(5, 4, &aom_highbd_12_sub_pixel_variance32x16_c, 12),
936   SubpelVarianceParams(4, 5, &aom_highbd_12_sub_pixel_variance16x32_c, 12),
937   SubpelVarianceParams(4, 4, &aom_highbd_12_sub_pixel_variance16x16_c, 12),
938   SubpelVarianceParams(4, 3, &aom_highbd_12_sub_pixel_variance16x8_c, 12),
939   SubpelVarianceParams(3, 4, &aom_highbd_12_sub_pixel_variance8x16_c, 12),
940   SubpelVarianceParams(3, 3, &aom_highbd_12_sub_pixel_variance8x8_c, 12),
941   SubpelVarianceParams(3, 2, &aom_highbd_12_sub_pixel_variance8x4_c, 12),
942   SubpelVarianceParams(2, 3, &aom_highbd_12_sub_pixel_variance4x8_c, 12),
943   SubpelVarianceParams(2, 2, &aom_highbd_12_sub_pixel_variance4x4_c, 12),
944 };
945 INSTANTIATE_TEST_CASE_P(C, AvxHBDSubpelVarianceTest,
946                         ::testing::ValuesIn(kArrayHBDSubpelVariance_c));
947 
948 const SubpelAvgVarianceParams kArrayHBDSubpelAvgVariance_c[] = {
949 #if CONFIG_AV1 && CONFIG_EXT_PARTITION
950   SubpelAvgVarianceParams(7, 7, &aom_highbd_8_sub_pixel_avg_variance128x128_c,
951                           8),
952   SubpelAvgVarianceParams(7, 6, &aom_highbd_8_sub_pixel_avg_variance128x64_c,
953                           8),
954   SubpelAvgVarianceParams(6, 7, &aom_highbd_8_sub_pixel_avg_variance64x128_c,
955                           8),
956 #endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
957   SubpelAvgVarianceParams(6, 6, &aom_highbd_8_sub_pixel_avg_variance64x64_c, 8),
958   SubpelAvgVarianceParams(6, 5, &aom_highbd_8_sub_pixel_avg_variance64x32_c, 8),
959   SubpelAvgVarianceParams(5, 6, &aom_highbd_8_sub_pixel_avg_variance32x64_c, 8),
960   SubpelAvgVarianceParams(5, 5, &aom_highbd_8_sub_pixel_avg_variance32x32_c, 8),
961   SubpelAvgVarianceParams(5, 4, &aom_highbd_8_sub_pixel_avg_variance32x16_c, 8),
962   SubpelAvgVarianceParams(4, 5, &aom_highbd_8_sub_pixel_avg_variance16x32_c, 8),
963   SubpelAvgVarianceParams(4, 4, &aom_highbd_8_sub_pixel_avg_variance16x16_c, 8),
964   SubpelAvgVarianceParams(4, 3, &aom_highbd_8_sub_pixel_avg_variance16x8_c, 8),
965   SubpelAvgVarianceParams(3, 4, &aom_highbd_8_sub_pixel_avg_variance8x16_c, 8),
966   SubpelAvgVarianceParams(3, 3, &aom_highbd_8_sub_pixel_avg_variance8x8_c, 8),
967   SubpelAvgVarianceParams(3, 2, &aom_highbd_8_sub_pixel_avg_variance8x4_c, 8),
968   SubpelAvgVarianceParams(2, 3, &aom_highbd_8_sub_pixel_avg_variance4x8_c, 8),
969   SubpelAvgVarianceParams(2, 2, &aom_highbd_8_sub_pixel_avg_variance4x4_c, 8),
970 #if CONFIG_AV1 && CONFIG_EXT_PARTITION
971   SubpelAvgVarianceParams(7, 7, &aom_highbd_10_sub_pixel_avg_variance128x128_c,
972                           10),
973   SubpelAvgVarianceParams(7, 6, &aom_highbd_10_sub_pixel_avg_variance128x64_c,
974                           10),
975   SubpelAvgVarianceParams(6, 7, &aom_highbd_10_sub_pixel_avg_variance64x128_c,
976                           10),
977 #endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
978   SubpelAvgVarianceParams(6, 6, &aom_highbd_10_sub_pixel_avg_variance64x64_c,
979                           10),
980   SubpelAvgVarianceParams(6, 5, &aom_highbd_10_sub_pixel_avg_variance64x32_c,
981                           10),
982   SubpelAvgVarianceParams(5, 6, &aom_highbd_10_sub_pixel_avg_variance32x64_c,
983                           10),
984   SubpelAvgVarianceParams(5, 5, &aom_highbd_10_sub_pixel_avg_variance32x32_c,
985                           10),
986   SubpelAvgVarianceParams(5, 4, &aom_highbd_10_sub_pixel_avg_variance32x16_c,
987                           10),
988   SubpelAvgVarianceParams(4, 5, &aom_highbd_10_sub_pixel_avg_variance16x32_c,
989                           10),
990   SubpelAvgVarianceParams(4, 4, &aom_highbd_10_sub_pixel_avg_variance16x16_c,
991                           10),
992   SubpelAvgVarianceParams(4, 3, &aom_highbd_10_sub_pixel_avg_variance16x8_c,
993                           10),
994   SubpelAvgVarianceParams(3, 4, &aom_highbd_10_sub_pixel_avg_variance8x16_c,
995                           10),
996   SubpelAvgVarianceParams(3, 3, &aom_highbd_10_sub_pixel_avg_variance8x8_c, 10),
997   SubpelAvgVarianceParams(3, 2, &aom_highbd_10_sub_pixel_avg_variance8x4_c, 10),
998   SubpelAvgVarianceParams(2, 3, &aom_highbd_10_sub_pixel_avg_variance4x8_c, 10),
999   SubpelAvgVarianceParams(2, 2, &aom_highbd_10_sub_pixel_avg_variance4x4_c, 10),
1000 #if CONFIG_AV1 && CONFIG_EXT_PARTITION
1001   SubpelAvgVarianceParams(7, 7, &aom_highbd_12_sub_pixel_avg_variance128x128_c,
1002                           12),
1003   SubpelAvgVarianceParams(7, 6, &aom_highbd_12_sub_pixel_avg_variance128x64_c,
1004                           12),
1005   SubpelAvgVarianceParams(6, 7, &aom_highbd_12_sub_pixel_avg_variance64x128_c,
1006                           12),
1007 #endif  // CONFIG_AV1 && CONFIG_EXT_PARTITION
1008   SubpelAvgVarianceParams(6, 6, &aom_highbd_12_sub_pixel_avg_variance64x64_c,
1009                           12),
1010   SubpelAvgVarianceParams(6, 5, &aom_highbd_12_sub_pixel_avg_variance64x32_c,
1011                           12),
1012   SubpelAvgVarianceParams(5, 6, &aom_highbd_12_sub_pixel_avg_variance32x64_c,
1013                           12),
1014   SubpelAvgVarianceParams(5, 5, &aom_highbd_12_sub_pixel_avg_variance32x32_c,
1015                           12),
1016   SubpelAvgVarianceParams(5, 4, &aom_highbd_12_sub_pixel_avg_variance32x16_c,
1017                           12),
1018   SubpelAvgVarianceParams(4, 5, &aom_highbd_12_sub_pixel_avg_variance16x32_c,
1019                           12),
1020   SubpelAvgVarianceParams(4, 4, &aom_highbd_12_sub_pixel_avg_variance16x16_c,
1021                           12),
1022   SubpelAvgVarianceParams(4, 3, &aom_highbd_12_sub_pixel_avg_variance16x8_c,
1023                           12),
1024   SubpelAvgVarianceParams(3, 4, &aom_highbd_12_sub_pixel_avg_variance8x16_c,
1025                           12),
1026   SubpelAvgVarianceParams(3, 3, &aom_highbd_12_sub_pixel_avg_variance8x8_c, 12),
1027   SubpelAvgVarianceParams(3, 2, &aom_highbd_12_sub_pixel_avg_variance8x4_c, 12),
1028   SubpelAvgVarianceParams(2, 3, &aom_highbd_12_sub_pixel_avg_variance4x8_c, 12),
1029   SubpelAvgVarianceParams(2, 2, &aom_highbd_12_sub_pixel_avg_variance4x4_c, 12)
1030 };
1031 INSTANTIATE_TEST_CASE_P(C, AvxHBDSubpelAvgVarianceTest,
1032                         ::testing::ValuesIn(kArrayHBDSubpelAvgVariance_c));
1033 #endif  // CONFIG_HIGHBITDEPTH
1034 
1035 #if HAVE_SSE2
1036 INSTANTIATE_TEST_CASE_P(SSE2, SumOfSquaresTest,
1037                         ::testing::Values(aom_get_mb_ss_sse2));
1038 
1039 INSTANTIATE_TEST_CASE_P(SSE2, AvxMseTest,
1040                         ::testing::Values(MseParams(4, 4, &aom_mse16x16_sse2),
1041                                           MseParams(4, 3, &aom_mse16x8_sse2),
1042                                           MseParams(3, 4, &aom_mse8x16_sse2),
1043                                           MseParams(3, 3, &aom_mse8x8_sse2)));
1044 
1045 INSTANTIATE_TEST_CASE_P(
1046     SSE2, AvxVarianceTest,
1047     ::testing::Values(VarianceParams(6, 6, &aom_variance64x64_sse2),
1048                       VarianceParams(6, 5, &aom_variance64x32_sse2),
1049                       VarianceParams(5, 6, &aom_variance32x64_sse2),
1050                       VarianceParams(5, 5, &aom_variance32x32_sse2),
1051                       VarianceParams(5, 4, &aom_variance32x16_sse2),
1052                       VarianceParams(4, 5, &aom_variance16x32_sse2),
1053                       VarianceParams(4, 4, &aom_variance16x16_sse2),
1054                       VarianceParams(4, 3, &aom_variance16x8_sse2),
1055                       VarianceParams(3, 4, &aom_variance8x16_sse2),
1056                       VarianceParams(3, 3, &aom_variance8x8_sse2),
1057                       VarianceParams(3, 2, &aom_variance8x4_sse2),
1058                       VarianceParams(2, 3, &aom_variance4x8_sse2),
1059                       VarianceParams(2, 2, &aom_variance4x4_sse2)));
1060 
1061 INSTANTIATE_TEST_CASE_P(
1062     SSE2, AvxSubpelVarianceTest,
1063     ::testing::Values(
1064         SubpelVarianceParams(6, 6, &aom_sub_pixel_variance64x64_sse2, 0),
1065         SubpelVarianceParams(6, 5, &aom_sub_pixel_variance64x32_sse2, 0),
1066         SubpelVarianceParams(5, 6, &aom_sub_pixel_variance32x64_sse2, 0),
1067         SubpelVarianceParams(5, 5, &aom_sub_pixel_variance32x32_sse2, 0),
1068         SubpelVarianceParams(5, 4, &aom_sub_pixel_variance32x16_sse2, 0),
1069         SubpelVarianceParams(4, 5, &aom_sub_pixel_variance16x32_sse2, 0),
1070         SubpelVarianceParams(4, 4, &aom_sub_pixel_variance16x16_sse2, 0),
1071         SubpelVarianceParams(4, 3, &aom_sub_pixel_variance16x8_sse2, 0),
1072         SubpelVarianceParams(3, 4, &aom_sub_pixel_variance8x16_sse2, 0),
1073         SubpelVarianceParams(3, 3, &aom_sub_pixel_variance8x8_sse2, 0),
1074         SubpelVarianceParams(3, 2, &aom_sub_pixel_variance8x4_sse2, 0),
1075         SubpelVarianceParams(2, 3, &aom_sub_pixel_variance4x8_sse2, 0),
1076         SubpelVarianceParams(2, 2, &aom_sub_pixel_variance4x4_sse2, 0)));
1077 
1078 INSTANTIATE_TEST_CASE_P(
1079     SSE2, AvxSubpelAvgVarianceTest,
1080     ::testing::Values(
1081         SubpelAvgVarianceParams(6, 6, &aom_sub_pixel_avg_variance64x64_sse2, 0),
1082         SubpelAvgVarianceParams(6, 5, &aom_sub_pixel_avg_variance64x32_sse2, 0),
1083         SubpelAvgVarianceParams(5, 6, &aom_sub_pixel_avg_variance32x64_sse2, 0),
1084         SubpelAvgVarianceParams(5, 5, &aom_sub_pixel_avg_variance32x32_sse2, 0),
1085         SubpelAvgVarianceParams(5, 4, &aom_sub_pixel_avg_variance32x16_sse2, 0),
1086         SubpelAvgVarianceParams(4, 5, &aom_sub_pixel_avg_variance16x32_sse2, 0),
1087         SubpelAvgVarianceParams(4, 4, &aom_sub_pixel_avg_variance16x16_sse2, 0),
1088         SubpelAvgVarianceParams(4, 3, &aom_sub_pixel_avg_variance16x8_sse2, 0),
1089         SubpelAvgVarianceParams(3, 4, &aom_sub_pixel_avg_variance8x16_sse2, 0),
1090         SubpelAvgVarianceParams(3, 3, &aom_sub_pixel_avg_variance8x8_sse2, 0),
1091         SubpelAvgVarianceParams(3, 2, &aom_sub_pixel_avg_variance8x4_sse2, 0),
1092         SubpelAvgVarianceParams(2, 3, &aom_sub_pixel_avg_variance4x8_sse2, 0),
1093         SubpelAvgVarianceParams(2, 2, &aom_sub_pixel_avg_variance4x4_sse2, 0)));
1094 
1095 #if HAVE_SSE4_1 && CONFIG_HIGHBITDEPTH
1096 INSTANTIATE_TEST_CASE_P(
1097     SSE4_1, AvxSubpelVarianceTest,
1098     ::testing::Values(
1099         SubpelVarianceParams(2, 2, &aom_highbd_8_sub_pixel_variance4x4_sse4_1,
1100                              8),
1101         SubpelVarianceParams(2, 2, &aom_highbd_10_sub_pixel_variance4x4_sse4_1,
1102                              10),
1103         SubpelVarianceParams(2, 2, &aom_highbd_12_sub_pixel_variance4x4_sse4_1,
1104                              12)));
1105 
1106 INSTANTIATE_TEST_CASE_P(
1107     SSE4_1, AvxSubpelAvgVarianceTest,
1108     ::testing::Values(
1109         SubpelAvgVarianceParams(2, 2,
1110                                 &aom_highbd_8_sub_pixel_avg_variance4x4_sse4_1,
1111                                 8),
1112         SubpelAvgVarianceParams(2, 2,
1113                                 &aom_highbd_10_sub_pixel_avg_variance4x4_sse4_1,
1114                                 10),
1115         SubpelAvgVarianceParams(2, 2,
1116                                 &aom_highbd_12_sub_pixel_avg_variance4x4_sse4_1,
1117                                 12)));
1118 #endif  // HAVE_SSE4_1 && CONFIG_HIGHBITDEPTH
1119 
1120 #if CONFIG_HIGHBITDEPTH
1121 /* TODO(debargha): This test does not support the highbd version
1122 INSTANTIATE_TEST_CASE_P(
1123     SSE2, AvxHBDMseTest,
1124     ::testing::Values(MseParams(4, 4, &aom_highbd_12_mse16x16_sse2),
1125                       MseParams(4, 3, &aom_highbd_12_mse16x8_sse2),
1126                       MseParams(3, 4, &aom_highbd_12_mse8x16_sse2),
1127                       MseParams(3, 3, &aom_highbd_12_mse8x8_sse2),
1128                       MseParams(4, 4, &aom_highbd_10_mse16x16_sse2),
1129                       MseParams(4, 3, &aom_highbd_10_mse16x8_sse2),
1130                       MseParams(3, 4, &aom_highbd_10_mse8x16_sse2),
1131                       MseParams(3, 3, &aom_highbd_10_mse8x8_sse2),
1132                       MseParams(4, 4, &aom_highbd_8_mse16x16_sse2),
1133                       MseParams(4, 3, &aom_highbd_8_mse16x8_sse2),
1134                       MseParams(3, 4, &aom_highbd_8_mse8x16_sse2),
1135                       MseParams(3, 3, &aom_highbd_8_mse8x8_sse2)));
1136 */
1137 
1138 INSTANTIATE_TEST_CASE_P(
1139     SSE2, AvxHBDVarianceTest,
1140     ::testing::Values(
1141         VarianceParams(6, 6, &aom_highbd_12_variance64x64_sse2, 12),
1142         VarianceParams(6, 5, &aom_highbd_12_variance64x32_sse2, 12),
1143         VarianceParams(5, 6, &aom_highbd_12_variance32x64_sse2, 12),
1144         VarianceParams(5, 5, &aom_highbd_12_variance32x32_sse2, 12),
1145         VarianceParams(5, 4, &aom_highbd_12_variance32x16_sse2, 12),
1146         VarianceParams(4, 5, &aom_highbd_12_variance16x32_sse2, 12),
1147         VarianceParams(4, 4, &aom_highbd_12_variance16x16_sse2, 12),
1148         VarianceParams(4, 3, &aom_highbd_12_variance16x8_sse2, 12),
1149         VarianceParams(3, 4, &aom_highbd_12_variance8x16_sse2, 12),
1150         VarianceParams(3, 3, &aom_highbd_12_variance8x8_sse2, 12),
1151         VarianceParams(6, 6, &aom_highbd_10_variance64x64_sse2, 10),
1152         VarianceParams(6, 5, &aom_highbd_10_variance64x32_sse2, 10),
1153         VarianceParams(5, 6, &aom_highbd_10_variance32x64_sse2, 10),
1154         VarianceParams(5, 5, &aom_highbd_10_variance32x32_sse2, 10),
1155         VarianceParams(5, 4, &aom_highbd_10_variance32x16_sse2, 10),
1156         VarianceParams(4, 5, &aom_highbd_10_variance16x32_sse2, 10),
1157         VarianceParams(4, 4, &aom_highbd_10_variance16x16_sse2, 10),
1158         VarianceParams(4, 3, &aom_highbd_10_variance16x8_sse2, 10),
1159         VarianceParams(3, 4, &aom_highbd_10_variance8x16_sse2, 10),
1160         VarianceParams(3, 3, &aom_highbd_10_variance8x8_sse2, 10),
1161         VarianceParams(6, 6, &aom_highbd_8_variance64x64_sse2, 8),
1162         VarianceParams(6, 5, &aom_highbd_8_variance64x32_sse2, 8),
1163         VarianceParams(5, 6, &aom_highbd_8_variance32x64_sse2, 8),
1164         VarianceParams(5, 5, &aom_highbd_8_variance32x32_sse2, 8),
1165         VarianceParams(5, 4, &aom_highbd_8_variance32x16_sse2, 8),
1166         VarianceParams(4, 5, &aom_highbd_8_variance16x32_sse2, 8),
1167         VarianceParams(4, 4, &aom_highbd_8_variance16x16_sse2, 8),
1168         VarianceParams(4, 3, &aom_highbd_8_variance16x8_sse2, 8),
1169         VarianceParams(3, 4, &aom_highbd_8_variance8x16_sse2, 8),
1170         VarianceParams(3, 3, &aom_highbd_8_variance8x8_sse2, 8)));
1171 
1172 const SubpelVarianceParams kArrayHBDSubpelVariance_sse2[] = {
1173   SubpelVarianceParams(6, 6, &aom_highbd_12_sub_pixel_variance64x64_sse2, 12),
1174   SubpelVarianceParams(6, 5, &aom_highbd_12_sub_pixel_variance64x32_sse2, 12),
1175   SubpelVarianceParams(5, 6, &aom_highbd_12_sub_pixel_variance32x64_sse2, 12),
1176   SubpelVarianceParams(5, 5, &aom_highbd_12_sub_pixel_variance32x32_sse2, 12),
1177   SubpelVarianceParams(5, 4, &aom_highbd_12_sub_pixel_variance32x16_sse2, 12),
1178   SubpelVarianceParams(4, 5, &aom_highbd_12_sub_pixel_variance16x32_sse2, 12),
1179   SubpelVarianceParams(4, 4, &aom_highbd_12_sub_pixel_variance16x16_sse2, 12),
1180   SubpelVarianceParams(4, 3, &aom_highbd_12_sub_pixel_variance16x8_sse2, 12),
1181   SubpelVarianceParams(3, 4, &aom_highbd_12_sub_pixel_variance8x16_sse2, 12),
1182   SubpelVarianceParams(3, 3, &aom_highbd_12_sub_pixel_variance8x8_sse2, 12),
1183   SubpelVarianceParams(3, 2, &aom_highbd_12_sub_pixel_variance8x4_sse2, 12),
1184   SubpelVarianceParams(6, 6, &aom_highbd_10_sub_pixel_variance64x64_sse2, 10),
1185   SubpelVarianceParams(6, 5, &aom_highbd_10_sub_pixel_variance64x32_sse2, 10),
1186   SubpelVarianceParams(5, 6, &aom_highbd_10_sub_pixel_variance32x64_sse2, 10),
1187   SubpelVarianceParams(5, 5, &aom_highbd_10_sub_pixel_variance32x32_sse2, 10),
1188   SubpelVarianceParams(5, 4, &aom_highbd_10_sub_pixel_variance32x16_sse2, 10),
1189   SubpelVarianceParams(4, 5, &aom_highbd_10_sub_pixel_variance16x32_sse2, 10),
1190   SubpelVarianceParams(4, 4, &aom_highbd_10_sub_pixel_variance16x16_sse2, 10),
1191   SubpelVarianceParams(4, 3, &aom_highbd_10_sub_pixel_variance16x8_sse2, 10),
1192   SubpelVarianceParams(3, 4, &aom_highbd_10_sub_pixel_variance8x16_sse2, 10),
1193   SubpelVarianceParams(3, 3, &aom_highbd_10_sub_pixel_variance8x8_sse2, 10),
1194   SubpelVarianceParams(3, 2, &aom_highbd_10_sub_pixel_variance8x4_sse2, 10),
1195   SubpelVarianceParams(6, 6, &aom_highbd_8_sub_pixel_variance64x64_sse2, 8),
1196   SubpelVarianceParams(6, 5, &aom_highbd_8_sub_pixel_variance64x32_sse2, 8),
1197   SubpelVarianceParams(5, 6, &aom_highbd_8_sub_pixel_variance32x64_sse2, 8),
1198   SubpelVarianceParams(5, 5, &aom_highbd_8_sub_pixel_variance32x32_sse2, 8),
1199   SubpelVarianceParams(5, 4, &aom_highbd_8_sub_pixel_variance32x16_sse2, 8),
1200   SubpelVarianceParams(4, 5, &aom_highbd_8_sub_pixel_variance16x32_sse2, 8),
1201   SubpelVarianceParams(4, 4, &aom_highbd_8_sub_pixel_variance16x16_sse2, 8),
1202   SubpelVarianceParams(4, 3, &aom_highbd_8_sub_pixel_variance16x8_sse2, 8),
1203   SubpelVarianceParams(3, 4, &aom_highbd_8_sub_pixel_variance8x16_sse2, 8),
1204   SubpelVarianceParams(3, 3, &aom_highbd_8_sub_pixel_variance8x8_sse2, 8),
1205   SubpelVarianceParams(3, 2, &aom_highbd_8_sub_pixel_variance8x4_sse2, 8)
1206 };
1207 
1208 INSTANTIATE_TEST_CASE_P(SSE2, AvxHBDSubpelVarianceTest,
1209                         ::testing::ValuesIn(kArrayHBDSubpelVariance_sse2));
1210 
1211 const SubpelAvgVarianceParams kArrayHBDSubpelAvgVariance_sse2[] = {
1212   SubpelAvgVarianceParams(6, 6, &aom_highbd_12_sub_pixel_avg_variance64x64_sse2,
1213                           12),
1214   SubpelAvgVarianceParams(6, 5, &aom_highbd_12_sub_pixel_avg_variance64x32_sse2,
1215                           12),
1216   SubpelAvgVarianceParams(5, 6, &aom_highbd_12_sub_pixel_avg_variance32x64_sse2,
1217                           12),
1218   SubpelAvgVarianceParams(5, 5, &aom_highbd_12_sub_pixel_avg_variance32x32_sse2,
1219                           12),
1220   SubpelAvgVarianceParams(5, 4, &aom_highbd_12_sub_pixel_avg_variance32x16_sse2,
1221                           12),
1222   SubpelAvgVarianceParams(4, 5, &aom_highbd_12_sub_pixel_avg_variance16x32_sse2,
1223                           12),
1224   SubpelAvgVarianceParams(4, 4, &aom_highbd_12_sub_pixel_avg_variance16x16_sse2,
1225                           12),
1226   SubpelAvgVarianceParams(4, 3, &aom_highbd_12_sub_pixel_avg_variance16x8_sse2,
1227                           12),
1228   SubpelAvgVarianceParams(3, 4, &aom_highbd_12_sub_pixel_avg_variance8x16_sse2,
1229                           12),
1230   SubpelAvgVarianceParams(3, 3, &aom_highbd_12_sub_pixel_avg_variance8x8_sse2,
1231                           12),
1232   SubpelAvgVarianceParams(3, 2, &aom_highbd_12_sub_pixel_avg_variance8x4_sse2,
1233                           12),
1234   SubpelAvgVarianceParams(6, 6, &aom_highbd_10_sub_pixel_avg_variance64x64_sse2,
1235                           10),
1236   SubpelAvgVarianceParams(6, 5, &aom_highbd_10_sub_pixel_avg_variance64x32_sse2,
1237                           10),
1238   SubpelAvgVarianceParams(5, 6, &aom_highbd_10_sub_pixel_avg_variance32x64_sse2,
1239                           10),
1240   SubpelAvgVarianceParams(5, 5, &aom_highbd_10_sub_pixel_avg_variance32x32_sse2,
1241                           10),
1242   SubpelAvgVarianceParams(5, 4, &aom_highbd_10_sub_pixel_avg_variance32x16_sse2,
1243                           10),
1244   SubpelAvgVarianceParams(4, 5, &aom_highbd_10_sub_pixel_avg_variance16x32_sse2,
1245                           10),
1246   SubpelAvgVarianceParams(4, 4, &aom_highbd_10_sub_pixel_avg_variance16x16_sse2,
1247                           10),
1248   SubpelAvgVarianceParams(4, 3, &aom_highbd_10_sub_pixel_avg_variance16x8_sse2,
1249                           10),
1250   SubpelAvgVarianceParams(3, 4, &aom_highbd_10_sub_pixel_avg_variance8x16_sse2,
1251                           10),
1252   SubpelAvgVarianceParams(3, 3, &aom_highbd_10_sub_pixel_avg_variance8x8_sse2,
1253                           10),
1254   SubpelAvgVarianceParams(3, 2, &aom_highbd_10_sub_pixel_avg_variance8x4_sse2,
1255                           10),
1256   SubpelAvgVarianceParams(6, 6, &aom_highbd_8_sub_pixel_avg_variance64x64_sse2,
1257                           8),
1258   SubpelAvgVarianceParams(6, 5, &aom_highbd_8_sub_pixel_avg_variance64x32_sse2,
1259                           8),
1260   SubpelAvgVarianceParams(5, 6, &aom_highbd_8_sub_pixel_avg_variance32x64_sse2,
1261                           8),
1262   SubpelAvgVarianceParams(5, 5, &aom_highbd_8_sub_pixel_avg_variance32x32_sse2,
1263                           8),
1264   SubpelAvgVarianceParams(5, 4, &aom_highbd_8_sub_pixel_avg_variance32x16_sse2,
1265                           8),
1266   SubpelAvgVarianceParams(4, 5, &aom_highbd_8_sub_pixel_avg_variance16x32_sse2,
1267                           8),
1268   SubpelAvgVarianceParams(4, 4, &aom_highbd_8_sub_pixel_avg_variance16x16_sse2,
1269                           8),
1270   SubpelAvgVarianceParams(4, 3, &aom_highbd_8_sub_pixel_avg_variance16x8_sse2,
1271                           8),
1272   SubpelAvgVarianceParams(3, 4, &aom_highbd_8_sub_pixel_avg_variance8x16_sse2,
1273                           8),
1274   SubpelAvgVarianceParams(3, 3, &aom_highbd_8_sub_pixel_avg_variance8x8_sse2,
1275                           8),
1276   SubpelAvgVarianceParams(3, 2, &aom_highbd_8_sub_pixel_avg_variance8x4_sse2, 8)
1277 };
1278 
1279 INSTANTIATE_TEST_CASE_P(SSE2, AvxHBDSubpelAvgVarianceTest,
1280                         ::testing::ValuesIn(kArrayHBDSubpelAvgVariance_sse2));
1281 #endif  // CONFIG_HIGHBITDEPTH
1282 #endif  // HAVE_SSE2
1283 
1284 #if HAVE_SSSE3
1285 INSTANTIATE_TEST_CASE_P(
1286     SSSE3, AvxSubpelVarianceTest,
1287     ::testing::Values(
1288         SubpelVarianceParams(6, 6, &aom_sub_pixel_variance64x64_ssse3, 0),
1289         SubpelVarianceParams(6, 5, &aom_sub_pixel_variance64x32_ssse3, 0),
1290         SubpelVarianceParams(5, 6, &aom_sub_pixel_variance32x64_ssse3, 0),
1291         SubpelVarianceParams(5, 5, &aom_sub_pixel_variance32x32_ssse3, 0),
1292         SubpelVarianceParams(5, 4, &aom_sub_pixel_variance32x16_ssse3, 0),
1293         SubpelVarianceParams(4, 5, &aom_sub_pixel_variance16x32_ssse3, 0),
1294         SubpelVarianceParams(4, 4, &aom_sub_pixel_variance16x16_ssse3, 0),
1295         SubpelVarianceParams(4, 3, &aom_sub_pixel_variance16x8_ssse3, 0),
1296         SubpelVarianceParams(3, 4, &aom_sub_pixel_variance8x16_ssse3, 0),
1297         SubpelVarianceParams(3, 3, &aom_sub_pixel_variance8x8_ssse3, 0),
1298         SubpelVarianceParams(3, 2, &aom_sub_pixel_variance8x4_ssse3, 0),
1299         SubpelVarianceParams(2, 3, &aom_sub_pixel_variance4x8_ssse3, 0),
1300         SubpelVarianceParams(2, 2, &aom_sub_pixel_variance4x4_ssse3, 0)));
1301 
1302 INSTANTIATE_TEST_CASE_P(
1303     SSSE3, AvxSubpelAvgVarianceTest,
1304     ::testing::Values(
1305         SubpelAvgVarianceParams(6, 6, &aom_sub_pixel_avg_variance64x64_ssse3,
1306                                 0),
1307         SubpelAvgVarianceParams(6, 5, &aom_sub_pixel_avg_variance64x32_ssse3,
1308                                 0),
1309         SubpelAvgVarianceParams(5, 6, &aom_sub_pixel_avg_variance32x64_ssse3,
1310                                 0),
1311         SubpelAvgVarianceParams(5, 5, &aom_sub_pixel_avg_variance32x32_ssse3,
1312                                 0),
1313         SubpelAvgVarianceParams(5, 4, &aom_sub_pixel_avg_variance32x16_ssse3,
1314                                 0),
1315         SubpelAvgVarianceParams(4, 5, &aom_sub_pixel_avg_variance16x32_ssse3,
1316                                 0),
1317         SubpelAvgVarianceParams(4, 4, &aom_sub_pixel_avg_variance16x16_ssse3,
1318                                 0),
1319         SubpelAvgVarianceParams(4, 3, &aom_sub_pixel_avg_variance16x8_ssse3, 0),
1320         SubpelAvgVarianceParams(3, 4, &aom_sub_pixel_avg_variance8x16_ssse3, 0),
1321         SubpelAvgVarianceParams(3, 3, &aom_sub_pixel_avg_variance8x8_ssse3, 0),
1322         SubpelAvgVarianceParams(3, 2, &aom_sub_pixel_avg_variance8x4_ssse3, 0),
1323         SubpelAvgVarianceParams(2, 3, &aom_sub_pixel_avg_variance4x8_ssse3, 0),
1324         SubpelAvgVarianceParams(2, 2, &aom_sub_pixel_avg_variance4x4_ssse3,
1325                                 0)));
1326 #endif  // HAVE_SSSE3
1327 
1328 #if HAVE_AVX2
1329 INSTANTIATE_TEST_CASE_P(AVX2, AvxMseTest,
1330                         ::testing::Values(MseParams(4, 4, &aom_mse16x16_avx2)));
1331 
1332 INSTANTIATE_TEST_CASE_P(
1333     AVX2, AvxVarianceTest,
1334     ::testing::Values(VarianceParams(6, 6, &aom_variance64x64_avx2),
1335                       VarianceParams(6, 5, &aom_variance64x32_avx2),
1336                       VarianceParams(5, 5, &aom_variance32x32_avx2),
1337                       VarianceParams(5, 4, &aom_variance32x16_avx2),
1338                       VarianceParams(4, 4, &aom_variance16x16_avx2)));
1339 
1340 INSTANTIATE_TEST_CASE_P(
1341     AVX2, AvxSubpelVarianceTest,
1342     ::testing::Values(
1343         SubpelVarianceParams(6, 6, &aom_sub_pixel_variance64x64_avx2, 0),
1344         SubpelVarianceParams(5, 5, &aom_sub_pixel_variance32x32_avx2, 0)));
1345 
1346 INSTANTIATE_TEST_CASE_P(
1347     AVX2, AvxSubpelAvgVarianceTest,
1348     ::testing::Values(
1349         SubpelAvgVarianceParams(6, 6, &aom_sub_pixel_avg_variance64x64_avx2, 0),
1350         SubpelAvgVarianceParams(5, 5, &aom_sub_pixel_avg_variance32x32_avx2,
1351                                 0)));
1352 #endif  // HAVE_AVX2
1353 
1354 #if HAVE_NEON
1355 INSTANTIATE_TEST_CASE_P(NEON, AvxSseTest,
1356                         ::testing::Values(SseParams(2, 2,
1357                                                     &aom_get4x4sse_cs_neon)));
1358 
1359 INSTANTIATE_TEST_CASE_P(NEON, AvxMseTest,
1360                         ::testing::Values(MseParams(4, 4, &aom_mse16x16_neon)));
1361 
1362 INSTANTIATE_TEST_CASE_P(
1363     NEON, AvxVarianceTest,
1364     ::testing::Values(VarianceParams(6, 6, &aom_variance64x64_neon),
1365                       VarianceParams(6, 5, &aom_variance64x32_neon),
1366                       VarianceParams(5, 6, &aom_variance32x64_neon),
1367                       VarianceParams(5, 5, &aom_variance32x32_neon),
1368                       VarianceParams(4, 4, &aom_variance16x16_neon),
1369                       VarianceParams(4, 3, &aom_variance16x8_neon),
1370                       VarianceParams(3, 4, &aom_variance8x16_neon),
1371                       VarianceParams(3, 3, &aom_variance8x8_neon)));
1372 
1373 INSTANTIATE_TEST_CASE_P(
1374     NEON, AvxSubpelVarianceTest,
1375     ::testing::Values(
1376         SubpelVarianceParams(6, 6, &aom_sub_pixel_variance64x64_neon, 0),
1377         SubpelVarianceParams(5, 5, &aom_sub_pixel_variance32x32_neon, 0),
1378         SubpelVarianceParams(4, 4, &aom_sub_pixel_variance16x16_neon, 0),
1379         SubpelVarianceParams(3, 3, &aom_sub_pixel_variance8x8_neon, 0)));
1380 #endif  // HAVE_NEON
1381 
1382 #if HAVE_MSA
1383 INSTANTIATE_TEST_CASE_P(MSA, SumOfSquaresTest,
1384                         ::testing::Values(aom_get_mb_ss_msa));
1385 
1386 INSTANTIATE_TEST_CASE_P(MSA, AvxSseTest,
1387                         ::testing::Values(SseParams(2, 2,
1388                                                     &aom_get4x4sse_cs_msa)));
1389 
1390 INSTANTIATE_TEST_CASE_P(MSA, AvxMseTest,
1391                         ::testing::Values(MseParams(4, 4, &aom_mse16x16_msa),
1392                                           MseParams(4, 3, &aom_mse16x8_msa),
1393                                           MseParams(3, 4, &aom_mse8x16_msa),
1394                                           MseParams(3, 3, &aom_mse8x8_msa)));
1395 
1396 INSTANTIATE_TEST_CASE_P(
1397     MSA, AvxVarianceTest,
1398     ::testing::Values(VarianceParams(6, 6, &aom_variance64x64_msa),
1399                       VarianceParams(6, 5, &aom_variance64x32_msa),
1400                       VarianceParams(5, 6, &aom_variance32x64_msa),
1401                       VarianceParams(5, 5, &aom_variance32x32_msa),
1402                       VarianceParams(5, 4, &aom_variance32x16_msa),
1403                       VarianceParams(4, 5, &aom_variance16x32_msa),
1404                       VarianceParams(4, 4, &aom_variance16x16_msa),
1405                       VarianceParams(4, 3, &aom_variance16x8_msa),
1406                       VarianceParams(3, 4, &aom_variance8x16_msa),
1407                       VarianceParams(3, 3, &aom_variance8x8_msa),
1408                       VarianceParams(3, 2, &aom_variance8x4_msa),
1409                       VarianceParams(2, 3, &aom_variance4x8_msa),
1410                       VarianceParams(2, 2, &aom_variance4x4_msa)));
1411 
1412 INSTANTIATE_TEST_CASE_P(
1413     MSA, AvxSubpelVarianceTest,
1414     ::testing::Values(
1415         SubpelVarianceParams(2, 2, &aom_sub_pixel_variance4x4_msa, 0),
1416         SubpelVarianceParams(2, 3, &aom_sub_pixel_variance4x8_msa, 0),
1417         SubpelVarianceParams(3, 2, &aom_sub_pixel_variance8x4_msa, 0),
1418         SubpelVarianceParams(3, 3, &aom_sub_pixel_variance8x8_msa, 0),
1419         SubpelVarianceParams(3, 4, &aom_sub_pixel_variance8x16_msa, 0),
1420         SubpelVarianceParams(4, 3, &aom_sub_pixel_variance16x8_msa, 0),
1421         SubpelVarianceParams(4, 4, &aom_sub_pixel_variance16x16_msa, 0),
1422         SubpelVarianceParams(4, 5, &aom_sub_pixel_variance16x32_msa, 0),
1423         SubpelVarianceParams(5, 4, &aom_sub_pixel_variance32x16_msa, 0),
1424         SubpelVarianceParams(5, 5, &aom_sub_pixel_variance32x32_msa, 0),
1425         SubpelVarianceParams(5, 6, &aom_sub_pixel_variance32x64_msa, 0),
1426         SubpelVarianceParams(6, 5, &aom_sub_pixel_variance64x32_msa, 0),
1427         SubpelVarianceParams(6, 6, &aom_sub_pixel_variance64x64_msa, 0)));
1428 
1429 INSTANTIATE_TEST_CASE_P(
1430     MSA, AvxSubpelAvgVarianceTest,
1431     ::testing::Values(
1432         SubpelAvgVarianceParams(6, 6, &aom_sub_pixel_avg_variance64x64_msa, 0),
1433         SubpelAvgVarianceParams(6, 5, &aom_sub_pixel_avg_variance64x32_msa, 0),
1434         SubpelAvgVarianceParams(5, 6, &aom_sub_pixel_avg_variance32x64_msa, 0),
1435         SubpelAvgVarianceParams(5, 5, &aom_sub_pixel_avg_variance32x32_msa, 0),
1436         SubpelAvgVarianceParams(5, 4, &aom_sub_pixel_avg_variance32x16_msa, 0),
1437         SubpelAvgVarianceParams(4, 5, &aom_sub_pixel_avg_variance16x32_msa, 0),
1438         SubpelAvgVarianceParams(4, 4, &aom_sub_pixel_avg_variance16x16_msa, 0),
1439         SubpelAvgVarianceParams(4, 3, &aom_sub_pixel_avg_variance16x8_msa, 0),
1440         SubpelAvgVarianceParams(3, 4, &aom_sub_pixel_avg_variance8x16_msa, 0),
1441         SubpelAvgVarianceParams(3, 3, &aom_sub_pixel_avg_variance8x8_msa, 0),
1442         SubpelAvgVarianceParams(3, 2, &aom_sub_pixel_avg_variance8x4_msa, 0),
1443         SubpelAvgVarianceParams(2, 3, &aom_sub_pixel_avg_variance4x8_msa, 0),
1444         SubpelAvgVarianceParams(2, 2, &aom_sub_pixel_avg_variance4x4_msa, 0)));
1445 #endif  // HAVE_MSA
1446 }  // namespace
1447