blob: 87dbb33afef82219d60a63dd914c5727c137940a [file] [log] [blame]
Johannfbea8972012-06-28 11:43:58 -07001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Johannfbea8972012-06-28 11:43:58 -07003 *
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07004 * 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.
Johann123e8a62017-12-28 14:40:49 -080010 */
Johannfbea8972012-06-28 11:43:58 -070011
Johannfbea8972012-06-28 11:43:58 -070012#include <string.h>
13#include <limits.h>
14#include <stdio.h>
15
Tom Finegan7a07ece2017-02-07 17:14:05 -080016#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
Jingning Han097d59c2015-07-29 14:51:36 -070017
Tom Finegan60e653d2018-05-22 11:34:58 -070018#include "config/aom_config.h"
Tom Finegan44702c82018-05-22 13:00:39 -070019#include "config/aom_dsp_rtcd.h"
Tom Finegan60e653d2018-05-22 11:34:58 -070020
Johannfbea8972012-06-28 11:43:58 -070021#include "test/acm_random.h"
James Zern5b756742013-06-17 22:58:40 -070022#include "test/clear_system_state.h"
James Zerneebb6482012-11-27 13:08:05 -080023#include "test/register_state_check.h"
Johannfbea8972012-06-28 11:43:58 -070024#include "test/util.h"
Yaowu Xuf883b422016-08-30 14:01:10 -070025#include "aom/aom_codec.h"
26#include "aom_mem/aom_mem.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070027#include "aom_ports/mem.h"
Johannfbea8972012-06-28 11:43:58 -070028
clang-format3a826f12016-08-11 17:46:05 -070029typedef unsigned int (*SadMxNFunc)(const uint8_t *src_ptr, int src_stride,
30 const uint8_t *ref_ptr, int ref_stride);
James Zern95612802018-03-30 11:37:54 -070031typedef ::testing::tuple<int, int, SadMxNFunc, int> SadMxNParam;
Johannd5d92892015-04-17 16:11:38 -040032
clang-format3a826f12016-08-11 17:46:05 -070033typedef uint32_t (*SadMxNAvgFunc)(const uint8_t *src_ptr, int src_stride,
34 const uint8_t *ref_ptr, int ref_stride,
Johannd5d92892015-04-17 16:11:38 -040035 const uint8_t *second_pred);
James Zern95612802018-03-30 11:37:54 -070036typedef ::testing::tuple<int, int, SadMxNAvgFunc, int> SadMxNAvgParam;
Johannfbea8972012-06-28 11:43:58 -070037
Debargha Mukherjee0c96c112018-12-20 16:04:18 -080038typedef void (*DistWtdCompAvgFunc)(uint8_t *comp_pred, const uint8_t *pred,
39 int width, int height, const uint8_t *ref,
40 int ref_stride,
41 const DIST_WTD_COMP_PARAMS *jcp_param);
42typedef ::testing::tuple<int, int, DistWtdCompAvgFunc, int> DistWtdCompAvgParam;
Cheng Chena0367dc2017-11-16 19:20:42 -080043
Debargha Mukherjee0c96c112018-12-20 16:04:18 -080044typedef unsigned int (*DistWtdSadMxhFunc)(const uint8_t *src_ptr,
45 int src_stride,
46 const uint8_t *ref_ptr,
47 int ref_stride, int width,
48 int height);
49typedef ::testing::tuple<int, int, DistWtdSadMxhFunc, int> DistWtdSadMxhParam;
Cheng Chena0367dc2017-11-16 19:20:42 -080050
Debargha Mukherjee0c96c112018-12-20 16:04:18 -080051typedef uint32_t (*DistWtdSadMxNAvgFunc)(const uint8_t *src_ptr, int src_stride,
52 const uint8_t *ref_ptr, int ref_stride,
53 const uint8_t *second_pred,
54 const DIST_WTD_COMP_PARAMS *jcp_param);
55typedef ::testing::tuple<int, int, DistWtdSadMxNAvgFunc, int>
56 DistWtdSadMxNAvgParam;
Cheng Chena0367dc2017-11-16 19:20:42 -080057
clang-format3a826f12016-08-11 17:46:05 -070058typedef void (*SadMxNx4Func)(const uint8_t *src_ptr, int src_stride,
59 const uint8_t *const ref_ptr[], int ref_stride,
Peter de Rivaz7eee4872014-10-16 13:41:55 +010060 uint32_t *sad_array);
James Zern95612802018-03-30 11:37:54 -070061typedef ::testing::tuple<int, int, SadMxNx4Func, int> SadMxNx4Param;
John Koleszar1cfc86e2013-03-01 12:43:41 -080062
Yaowu Xuc27fc142016-08-22 16:08:15 -070063using libaom_test::ACMRandom;
Johannfbea8972012-06-28 11:43:58 -070064
65namespace {
John Koleszar1cfc86e2013-03-01 12:43:41 -080066class SADTestBase : public ::testing::Test {
James Zern10f8b362012-08-27 17:13:09 -070067 public:
clang-format3a826f12016-08-11 17:46:05 -070068 SADTestBase(int width, int height, int bit_depth)
69 : width_(width), height_(height), bd_(bit_depth) {}
John Koleszar1cfc86e2013-03-01 12:43:41 -080070
James Zern10f8b362012-08-27 17:13:09 -070071 static void SetUpTestCase() {
clang-format3a826f12016-08-11 17:46:05 -070072 source_data8_ = reinterpret_cast<uint8_t *>(
Yaowu Xuf883b422016-08-30 14:01:10 -070073 aom_memalign(kDataAlignment, kDataBlockSize));
clang-format3a826f12016-08-11 17:46:05 -070074 reference_data8_ = reinterpret_cast<uint8_t *>(
Yaowu Xuf883b422016-08-30 14:01:10 -070075 aom_memalign(kDataAlignment, kDataBufferSize));
clang-format3a826f12016-08-11 17:46:05 -070076 second_pred8_ =
Yaowu Xuf883b422016-08-30 14:01:10 -070077 reinterpret_cast<uint8_t *>(aom_memalign(kDataAlignment, 128 * 128));
Cheng Chena0367dc2017-11-16 19:20:42 -080078 comp_pred8_ =
79 reinterpret_cast<uint8_t *>(aom_memalign(kDataAlignment, 128 * 128));
80 comp_pred8_test_ =
81 reinterpret_cast<uint8_t *>(aom_memalign(kDataAlignment, 128 * 128));
clang-format3a826f12016-08-11 17:46:05 -070082 source_data16_ = reinterpret_cast<uint16_t *>(
Yaowu Xuf883b422016-08-30 14:01:10 -070083 aom_memalign(kDataAlignment, kDataBlockSize * sizeof(uint16_t)));
clang-format3a826f12016-08-11 17:46:05 -070084 reference_data16_ = reinterpret_cast<uint16_t *>(
Yaowu Xuf883b422016-08-30 14:01:10 -070085 aom_memalign(kDataAlignment, kDataBufferSize * sizeof(uint16_t)));
clang-format3a826f12016-08-11 17:46:05 -070086 second_pred16_ = reinterpret_cast<uint16_t *>(
Yaowu Xuf883b422016-08-30 14:01:10 -070087 aom_memalign(kDataAlignment, 128 * 128 * sizeof(uint16_t)));
Cheng Chena0367dc2017-11-16 19:20:42 -080088 comp_pred16_ = reinterpret_cast<uint16_t *>(
89 aom_memalign(kDataAlignment, 128 * 128 * sizeof(uint16_t)));
90 comp_pred16_test_ = reinterpret_cast<uint16_t *>(
91 aom_memalign(kDataAlignment, 128 * 128 * sizeof(uint16_t)));
James Zern10f8b362012-08-27 17:13:09 -070092 }
93
94 static void TearDownTestCase() {
Yaowu Xuf883b422016-08-30 14:01:10 -070095 aom_free(source_data8_);
Peter de Rivaz7eee4872014-10-16 13:41:55 +010096 source_data8_ = NULL;
Yaowu Xuf883b422016-08-30 14:01:10 -070097 aom_free(reference_data8_);
Peter de Rivaz7eee4872014-10-16 13:41:55 +010098 reference_data8_ = NULL;
Yaowu Xuf883b422016-08-30 14:01:10 -070099 aom_free(second_pred8_);
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100100 second_pred8_ = NULL;
Cheng Chena0367dc2017-11-16 19:20:42 -0800101 aom_free(comp_pred8_);
102 comp_pred8_ = NULL;
103 aom_free(comp_pred8_test_);
104 comp_pred8_test_ = NULL;
Yaowu Xuf883b422016-08-30 14:01:10 -0700105 aom_free(source_data16_);
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100106 source_data16_ = NULL;
Yaowu Xuf883b422016-08-30 14:01:10 -0700107 aom_free(reference_data16_);
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100108 reference_data16_ = NULL;
Yaowu Xuf883b422016-08-30 14:01:10 -0700109 aom_free(second_pred16_);
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100110 second_pred16_ = NULL;
Cheng Chena0367dc2017-11-16 19:20:42 -0800111 aom_free(comp_pred16_);
112 comp_pred16_ = NULL;
113 aom_free(comp_pred16_test_);
114 comp_pred16_test_ = NULL;
James Zern10f8b362012-08-27 17:13:09 -0700115 }
116
Yaowu Xuc27fc142016-08-22 16:08:15 -0700117 virtual void TearDown() { libaom_test::ClearSystemState(); }
James Zern5b756742013-06-17 22:58:40 -0700118
James Zern10f8b362012-08-27 17:13:09 -0700119 protected:
Geza Lore697bf5b2016-03-02 11:12:52 +0000120 // Handle up to 4 128x128 blocks, with stride up to 256
James Zern10f8b362012-08-27 17:13:09 -0700121 static const int kDataAlignment = 16;
Geza Lore697bf5b2016-03-02 11:12:52 +0000122 static const int kDataBlockSize = 128 * 256;
John Koleszar1cfc86e2013-03-01 12:43:41 -0800123 static const int kDataBufferSize = 4 * kDataBlockSize;
James Zern10f8b362012-08-27 17:13:09 -0700124
Johannfbea8972012-06-28 11:43:58 -0700125 virtual void SetUp() {
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100126 if (bd_ == -1) {
127 use_high_bit_depth_ = false;
Yaowu Xuf883b422016-08-30 14:01:10 -0700128 bit_depth_ = AOM_BITS_8;
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100129 source_data_ = source_data8_;
130 reference_data_ = reference_data8_;
131 second_pred_ = second_pred8_;
Cheng Chena0367dc2017-11-16 19:20:42 -0800132 comp_pred_ = comp_pred8_;
133 comp_pred_test_ = comp_pred8_test_;
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100134 } else {
135 use_high_bit_depth_ = true;
Yaowu Xuf883b422016-08-30 14:01:10 -0700136 bit_depth_ = static_cast<aom_bit_depth_t>(bd_);
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100137 source_data_ = CONVERT_TO_BYTEPTR(source_data16_);
138 reference_data_ = CONVERT_TO_BYTEPTR(reference_data16_);
139 second_pred_ = CONVERT_TO_BYTEPTR(second_pred16_);
Cheng Chena0367dc2017-11-16 19:20:42 -0800140 comp_pred_ = CONVERT_TO_BYTEPTR(comp_pred16_);
141 comp_pred_test_ = CONVERT_TO_BYTEPTR(comp_pred16_test_);
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100142 }
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100143 mask_ = (1 << bit_depth_) - 1;
John Koleszar6b653cb2013-02-28 17:03:02 -0800144 source_stride_ = (width_ + 31) & ~31;
Johannfbea8972012-06-28 11:43:58 -0700145 reference_stride_ = width_ * 2;
146 rnd_.Reset(ACMRandom::DeterministicSeed());
147 }
148
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100149 virtual uint8_t *GetReference(int block_idx) {
Johannd5d92892015-04-17 16:11:38 -0400150 if (use_high_bit_depth_)
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100151 return CONVERT_TO_BYTEPTR(CONVERT_TO_SHORTPTR(reference_data_) +
152 block_idx * kDataBlockSize);
John Koleszar1cfc86e2013-03-01 12:43:41 -0800153 return reference_data_ + block_idx * kDataBlockSize;
Johannfbea8972012-06-28 11:43:58 -0700154 }
155
156 // Sum of Absolute Differences. Given two blocks, calculate the absolute
157 // difference between two pixels in the same relative location; accumulate.
Johannd5d92892015-04-17 16:11:38 -0400158 unsigned int ReferenceSAD(int block_idx) {
Johannfbea8972012-06-28 11:43:58 -0700159 unsigned int sad = 0;
clang-format3a826f12016-08-11 17:46:05 -0700160 const uint8_t *const reference8 = GetReference(block_idx);
161 const uint8_t *const source8 = source_data_;
clang-format3a826f12016-08-11 17:46:05 -0700162 const uint16_t *const reference16 =
163 CONVERT_TO_SHORTPTR(GetReference(block_idx));
164 const uint16_t *const source16 = CONVERT_TO_SHORTPTR(source_data_);
Johannfbea8972012-06-28 11:43:58 -0700165 for (int h = 0; h < height_; ++h) {
166 for (int w = 0; w < width_; ++w) {
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100167 if (!use_high_bit_depth_) {
Johannd5d92892015-04-17 16:11:38 -0400168 sad += abs(source8[h * source_stride_ + w] -
169 reference8[h * reference_stride_ + w]);
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100170 } else {
Johannd5d92892015-04-17 16:11:38 -0400171 sad += abs(source16[h * source_stride_ + w] -
172 reference16[h * reference_stride_ + w]);
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100173 }
Jim Bankoskia16794d2014-05-15 08:31:20 -0700174 }
Johannfbea8972012-06-28 11:43:58 -0700175 }
176 return sad;
177 }
178
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100179 // Sum of Absolute Differences Average. Given two blocks, and a prediction
180 // calculate the absolute difference between one pixel and average of the
181 // corresponding and predicted pixels; accumulate.
Johannd5d92892015-04-17 16:11:38 -0400182 unsigned int ReferenceSADavg(int block_idx) {
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100183 unsigned int sad = 0;
Johannd5d92892015-04-17 16:11:38 -0400184 const uint8_t *const reference8 = GetReference(block_idx);
185 const uint8_t *const source8 = source_data_;
186 const uint8_t *const second_pred8 = second_pred_;
Johannd5d92892015-04-17 16:11:38 -0400187 const uint16_t *const reference16 =
188 CONVERT_TO_SHORTPTR(GetReference(block_idx));
189 const uint16_t *const source16 = CONVERT_TO_SHORTPTR(source_data_);
190 const uint16_t *const second_pred16 = CONVERT_TO_SHORTPTR(second_pred_);
Johannfbea8972012-06-28 11:43:58 -0700191 for (int h = 0; h < height_; ++h) {
192 for (int w = 0; w < width_; ++w) {
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100193 if (!use_high_bit_depth_) {
194 const int tmp = second_pred8[h * width_ + w] +
clang-format3a826f12016-08-11 17:46:05 -0700195 reference8[h * reference_stride_ + w];
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100196 const uint8_t comp_pred = ROUND_POWER_OF_TWO(tmp, 1);
197 sad += abs(source8[h * source_stride_ + w] - comp_pred);
198 } else {
199 const int tmp = second_pred16[h * width_ + w] +
clang-format3a826f12016-08-11 17:46:05 -0700200 reference16[h * reference_stride_ + w];
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100201 const uint16_t comp_pred = ROUND_POWER_OF_TWO(tmp, 1);
202 sad += abs(source16[h * source_stride_ + w] - comp_pred);
203 }
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100204 }
205 }
206 return sad;
207 }
208
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800209 void ReferenceDistWtdCompAvg(int block_idx) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800210 const uint8_t *const reference8 = GetReference(block_idx);
211 const uint8_t *const second_pred8 = second_pred_;
212 uint8_t *const comp_pred8 = comp_pred_;
Cheng Chena0367dc2017-11-16 19:20:42 -0800213 const uint16_t *const reference16 =
214 CONVERT_TO_SHORTPTR(GetReference(block_idx));
215 const uint16_t *const second_pred16 = CONVERT_TO_SHORTPTR(second_pred_);
216 uint16_t *const comp_pred16 = CONVERT_TO_SHORTPTR(comp_pred_);
Cheng Chena0367dc2017-11-16 19:20:42 -0800217 for (int h = 0; h < height_; ++h) {
218 for (int w = 0; w < width_; ++w) {
219 if (!use_high_bit_depth_) {
220 const int tmp =
221 second_pred8[h * width_ + w] * jcp_param_.bck_offset +
222 reference8[h * reference_stride_ + w] * jcp_param_.fwd_offset;
223 comp_pred8[h * width_ + w] = ROUND_POWER_OF_TWO(tmp, 4);
Cheng Chena0367dc2017-11-16 19:20:42 -0800224 } else {
225 const int tmp =
226 second_pred16[h * width_ + w] * jcp_param_.bck_offset +
227 reference16[h * reference_stride_ + w] * jcp_param_.fwd_offset;
228 comp_pred16[h * width_ + w] = ROUND_POWER_OF_TWO(tmp, 4);
Cheng Chena0367dc2017-11-16 19:20:42 -0800229 }
230 }
231 }
232 }
233
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800234 unsigned int ReferenceDistWtdSADavg(int block_idx) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800235 unsigned int sad = 0;
236 const uint8_t *const reference8 = GetReference(block_idx);
237 const uint8_t *const source8 = source_data_;
238 const uint8_t *const second_pred8 = second_pred_;
Cheng Chena0367dc2017-11-16 19:20:42 -0800239 const uint16_t *const reference16 =
240 CONVERT_TO_SHORTPTR(GetReference(block_idx));
241 const uint16_t *const source16 = CONVERT_TO_SHORTPTR(source_data_);
242 const uint16_t *const second_pred16 = CONVERT_TO_SHORTPTR(second_pred_);
Cheng Chena0367dc2017-11-16 19:20:42 -0800243 for (int h = 0; h < height_; ++h) {
244 for (int w = 0; w < width_; ++w) {
245 if (!use_high_bit_depth_) {
246 const int tmp =
247 second_pred8[h * width_ + w] * jcp_param_.bck_offset +
248 reference8[h * reference_stride_ + w] * jcp_param_.fwd_offset;
249 const uint8_t comp_pred = ROUND_POWER_OF_TWO(tmp, 4);
250 sad += abs(source8[h * source_stride_ + w] - comp_pred);
Cheng Chena0367dc2017-11-16 19:20:42 -0800251 } else {
252 const int tmp =
253 second_pred16[h * width_ + w] * jcp_param_.bck_offset +
254 reference16[h * reference_stride_ + w] * jcp_param_.fwd_offset;
255 const uint16_t comp_pred = ROUND_POWER_OF_TWO(tmp, 4);
256 sad += abs(source16[h * source_stride_ + w] - comp_pred);
Cheng Chena0367dc2017-11-16 19:20:42 -0800257 }
258 }
259 }
260 return sad;
261 }
Cheng Chena0367dc2017-11-16 19:20:42 -0800262
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100263 void FillConstant(uint8_t *data, int stride, uint16_t fill_constant) {
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100264 uint8_t *data8 = data;
265 uint16_t *data16 = CONVERT_TO_SHORTPTR(data);
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100266 for (int h = 0; h < height_; ++h) {
267 for (int w = 0; w < width_; ++w) {
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100268 if (!use_high_bit_depth_) {
Deb Mukherjee00c385f2014-11-14 15:12:01 -0800269 data8[h * stride + w] = static_cast<uint8_t>(fill_constant);
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100270 } else {
271 data16[h * stride + w] = fill_constant;
272 }
Johannfbea8972012-06-28 11:43:58 -0700273 }
274 }
275 }
276
277 void FillRandom(uint8_t *data, int stride) {
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100278 uint8_t *data8 = data;
279 uint16_t *data16 = CONVERT_TO_SHORTPTR(data);
Johannfbea8972012-06-28 11:43:58 -0700280 for (int h = 0; h < height_; ++h) {
281 for (int w = 0; w < width_; ++w) {
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100282 if (!use_high_bit_depth_) {
283 data8[h * stride + w] = rnd_.Rand8();
284 } else {
285 data16[h * stride + w] = rnd_.Rand16() & mask_;
286 }
Johannfbea8972012-06-28 11:43:58 -0700287 }
288 }
289 }
290
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100291 int width_, height_, mask_, bd_;
Yaowu Xuf883b422016-08-30 14:01:10 -0700292 aom_bit_depth_t bit_depth_;
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100293 static uint8_t *source_data_;
294 static uint8_t *reference_data_;
295 static uint8_t *second_pred_;
John Koleszar1cfc86e2013-03-01 12:43:41 -0800296 int source_stride_;
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100297 bool use_high_bit_depth_;
298 static uint8_t *source_data8_;
299 static uint8_t *reference_data8_;
300 static uint8_t *second_pred8_;
301 static uint16_t *source_data16_;
302 static uint16_t *reference_data16_;
303 static uint16_t *second_pred16_;
John Koleszar1cfc86e2013-03-01 12:43:41 -0800304 int reference_stride_;
Cheng Chena0367dc2017-11-16 19:20:42 -0800305 static uint8_t *comp_pred_;
306 static uint8_t *comp_pred8_;
307 static uint16_t *comp_pred16_;
308 static uint8_t *comp_pred_test_;
309 static uint8_t *comp_pred8_test_;
310 static uint16_t *comp_pred16_test_;
Debargha Mukherjeef90004a2018-12-20 13:35:06 -0800311 DIST_WTD_COMP_PARAMS jcp_param_;
John Koleszar1cfc86e2013-03-01 12:43:41 -0800312
313 ACMRandom rnd_;
314};
315
Sebastien Alaiwan4322bc12017-06-05 10:18:28 +0200316class SADx4Test : public ::testing::WithParamInterface<SadMxNx4Param>,
317 public SADTestBase {
John Koleszar1cfc86e2013-03-01 12:43:41 -0800318 public:
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100319 SADx4Test() : SADTestBase(GET_PARAM(0), GET_PARAM(1), GET_PARAM(3)) {}
John Koleszar1cfc86e2013-03-01 12:43:41 -0800320
321 protected:
322 void SADs(unsigned int *results) {
clang-format3a826f12016-08-11 17:46:05 -0700323 const uint8_t *references[] = { GetReference(0), GetReference(1),
324 GetReference(2), GetReference(3) };
John Koleszar1cfc86e2013-03-01 12:43:41 -0800325
clang-format3a826f12016-08-11 17:46:05 -0700326 ASM_REGISTER_STATE_CHECK(GET_PARAM(2)(
327 source_data_, source_stride_, references, reference_stride_, results));
John Koleszar1cfc86e2013-03-01 12:43:41 -0800328 }
329
330 void CheckSADs() {
331 unsigned int reference_sad, exp_sad[4];
332
333 SADs(exp_sad);
Deb Mukherjeefc882922014-05-13 10:11:42 -0700334 for (int block = 0; block < 4; ++block) {
Johannd5d92892015-04-17 16:11:38 -0400335 reference_sad = ReferenceSAD(block);
John Koleszar1cfc86e2013-03-01 12:43:41 -0800336
Deb Mukherjeefc882922014-05-13 10:11:42 -0700337 EXPECT_EQ(reference_sad, exp_sad[block]) << "block " << block;
John Koleszar1cfc86e2013-03-01 12:43:41 -0800338 }
339 }
340};
341
Sebastien Alaiwan4322bc12017-06-05 10:18:28 +0200342class SADTest : public ::testing::WithParamInterface<SadMxNParam>,
343 public SADTestBase {
Deb Mukherjeefc882922014-05-13 10:11:42 -0700344 public:
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100345 SADTest() : SADTestBase(GET_PARAM(0), GET_PARAM(1), GET_PARAM(3)) {}
Deb Mukherjeefc882922014-05-13 10:11:42 -0700346
347 protected:
Deb Mukherjeefc882922014-05-13 10:11:42 -0700348 unsigned int SAD(int block_idx) {
349 unsigned int ret;
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100350 const uint8_t *const reference = GetReference(block_idx);
Deb Mukherjeefc882922014-05-13 10:11:42 -0700351
James Zern29e1b1a2014-07-09 21:02:02 -0700352 ASM_REGISTER_STATE_CHECK(ret = GET_PARAM(2)(source_data_, source_stride_,
353 reference, reference_stride_));
Deb Mukherjeefc882922014-05-13 10:11:42 -0700354 return ret;
355 }
356
357 void CheckSAD() {
Johannd5d92892015-04-17 16:11:38 -0400358 const unsigned int reference_sad = ReferenceSAD(0);
Deb Mukherjeefc882922014-05-13 10:11:42 -0700359 const unsigned int exp_sad = SAD(0);
360
361 ASSERT_EQ(reference_sad, exp_sad);
362 }
Yi Luoe9832582016-11-29 19:38:12 -0800363
364 void SpeedSAD() {
365 int test_count = 20000000;
366 while (test_count > 0) {
367 SAD(0);
368 test_count -= 1;
369 }
370 }
Deb Mukherjeefc882922014-05-13 10:11:42 -0700371};
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100372
Sebastien Alaiwan4322bc12017-06-05 10:18:28 +0200373class SADavgTest : public ::testing::WithParamInterface<SadMxNAvgParam>,
374 public SADTestBase {
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100375 public:
Johannd5d92892015-04-17 16:11:38 -0400376 SADavgTest() : SADTestBase(GET_PARAM(0), GET_PARAM(1), GET_PARAM(3)) {}
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100377
378 protected:
379 unsigned int SAD_avg(int block_idx) {
380 unsigned int ret;
381 const uint8_t *const reference = GetReference(block_idx);
382
383 ASM_REGISTER_STATE_CHECK(ret = GET_PARAM(2)(source_data_, source_stride_,
384 reference, reference_stride_,
385 second_pred_));
386 return ret;
387 }
388
389 void CheckSAD() {
Johannd5d92892015-04-17 16:11:38 -0400390 const unsigned int reference_sad = ReferenceSADavg(0);
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100391 const unsigned int exp_sad = SAD_avg(0);
392
393 ASSERT_EQ(reference_sad, exp_sad);
394 }
395};
Deb Mukherjeefc882922014-05-13 10:11:42 -0700396
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800397class DistWtdCompAvgTest
398 : public ::testing::WithParamInterface<DistWtdCompAvgParam>,
399 public SADTestBase {
Cheng Chena0367dc2017-11-16 19:20:42 -0800400 public:
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800401 DistWtdCompAvgTest()
402 : SADTestBase(GET_PARAM(0), GET_PARAM(1), GET_PARAM(3)) {}
Cheng Chena0367dc2017-11-16 19:20:42 -0800403
404 protected:
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800405 void dist_wtd_comp_avg(int block_idx) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800406 const uint8_t *const reference = GetReference(block_idx);
407
408 ASM_REGISTER_STATE_CHECK(GET_PARAM(2)(comp_pred_test_, second_pred_, width_,
409 height_, reference, reference_stride_,
410 &jcp_param_));
411 }
412
413 void CheckCompAvg() {
414 for (int j = 0; j < 2; ++j) {
415 for (int i = 0; i < 4; ++i) {
416 jcp_param_.fwd_offset = quant_dist_lookup_table[j][i][0];
417 jcp_param_.bck_offset = quant_dist_lookup_table[j][i][1];
418
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800419 ReferenceDistWtdCompAvg(0);
420 dist_wtd_comp_avg(0);
Cheng Chena0367dc2017-11-16 19:20:42 -0800421
422 for (int y = 0; y < height_; ++y)
423 for (int x = 0; x < width_; ++x)
424 ASSERT_EQ(comp_pred_[y * width_ + x],
425 comp_pred_test_[y * width_ + x]);
426 }
427 }
428 }
429};
430
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800431class DistWtdSADTest : public ::testing::WithParamInterface<DistWtdSadMxhParam>,
432 public SADTestBase {
Cheng Chena0367dc2017-11-16 19:20:42 -0800433 public:
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800434 DistWtdSADTest() : SADTestBase(GET_PARAM(0), GET_PARAM(1), GET_PARAM(3)) {}
Cheng Chena0367dc2017-11-16 19:20:42 -0800435
436 protected:
437 unsigned int SAD(int block_idx) {
438 unsigned int ret;
439 const uint8_t *const reference = GetReference(block_idx);
440
441 ASM_REGISTER_STATE_CHECK(ret = GET_PARAM(2)(source_data_, source_stride_,
442 reference, reference_stride_,
443 GET_PARAM(0), GET_PARAM(1)));
444 return ret;
445 }
446
447 void CheckSAD() {
448 const unsigned int reference_sad = ReferenceSAD(0);
449 const unsigned int exp_sad = SAD(0);
450
451 ASSERT_EQ(reference_sad, exp_sad);
452 }
453
454 void SpeedSAD() {
455 int test_count = 20000000;
456 while (test_count > 0) {
457 SAD(0);
458 test_count -= 1;
459 }
460 }
461};
462
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800463class DistWtdSADavgTest
464 : public ::testing::WithParamInterface<DistWtdSadMxNAvgParam>,
465 public SADTestBase {
Cheng Chena0367dc2017-11-16 19:20:42 -0800466 public:
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800467 DistWtdSADavgTest() : SADTestBase(GET_PARAM(0), GET_PARAM(1), GET_PARAM(3)) {}
Cheng Chena0367dc2017-11-16 19:20:42 -0800468
469 protected:
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800470 unsigned int dist_wtd_SAD_avg(int block_idx) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800471 unsigned int ret;
472 const uint8_t *const reference = GetReference(block_idx);
473
474 ASM_REGISTER_STATE_CHECK(ret = GET_PARAM(2)(source_data_, source_stride_,
475 reference, reference_stride_,
476 second_pred_, &jcp_param_));
477 return ret;
478 }
479
480 void CheckSAD() {
481 for (int j = 0; j < 2; ++j) {
482 for (int i = 0; i < 4; ++i) {
483 jcp_param_.fwd_offset = quant_dist_lookup_table[j][i][0];
484 jcp_param_.bck_offset = quant_dist_lookup_table[j][i][1];
485
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800486 const unsigned int reference_sad = ReferenceDistWtdSADavg(0);
487 const unsigned int exp_sad = dist_wtd_SAD_avg(0);
Cheng Chena0367dc2017-11-16 19:20:42 -0800488
489 ASSERT_EQ(reference_sad, exp_sad);
490 }
491 }
492 }
493};
Cheng Chena0367dc2017-11-16 19:20:42 -0800494
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100495uint8_t *SADTestBase::source_data_ = NULL;
496uint8_t *SADTestBase::reference_data_ = NULL;
497uint8_t *SADTestBase::second_pred_ = NULL;
Cheng Chena0367dc2017-11-16 19:20:42 -0800498uint8_t *SADTestBase::comp_pred_ = NULL;
499uint8_t *SADTestBase::comp_pred_test_ = NULL;
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100500uint8_t *SADTestBase::source_data8_ = NULL;
501uint8_t *SADTestBase::reference_data8_ = NULL;
502uint8_t *SADTestBase::second_pred8_ = NULL;
Cheng Chena0367dc2017-11-16 19:20:42 -0800503uint8_t *SADTestBase::comp_pred8_ = NULL;
504uint8_t *SADTestBase::comp_pred8_test_ = NULL;
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100505uint16_t *SADTestBase::source_data16_ = NULL;
506uint16_t *SADTestBase::reference_data16_ = NULL;
507uint16_t *SADTestBase::second_pred16_ = NULL;
Cheng Chena0367dc2017-11-16 19:20:42 -0800508uint16_t *SADTestBase::comp_pred16_ = NULL;
509uint16_t *SADTestBase::comp_pred16_test_ = NULL;
James Zern10f8b362012-08-27 17:13:09 -0700510
Johannfbea8972012-06-28 11:43:58 -0700511TEST_P(SADTest, MaxRef) {
512 FillConstant(source_data_, source_stride_, 0);
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100513 FillConstant(reference_data_, reference_stride_, mask_);
Johannd5d92892015-04-17 16:11:38 -0400514 CheckSAD();
Johannfbea8972012-06-28 11:43:58 -0700515}
516
Deb Mukherjeefc882922014-05-13 10:11:42 -0700517TEST_P(SADTest, MaxSrc) {
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100518 FillConstant(source_data_, source_stride_, mask_);
Deb Mukherjeefc882922014-05-13 10:11:42 -0700519 FillConstant(reference_data_, reference_stride_, 0);
Johannd5d92892015-04-17 16:11:38 -0400520 CheckSAD();
Deb Mukherjeefc882922014-05-13 10:11:42 -0700521}
522
523TEST_P(SADTest, ShortRef) {
Johannd5d92892015-04-17 16:11:38 -0400524 const int tmp_stride = reference_stride_;
Deb Mukherjeefc882922014-05-13 10:11:42 -0700525 reference_stride_ >>= 1;
526 FillRandom(source_data_, source_stride_);
527 FillRandom(reference_data_, reference_stride_);
Johannd5d92892015-04-17 16:11:38 -0400528 CheckSAD();
Deb Mukherjeefc882922014-05-13 10:11:42 -0700529 reference_stride_ = tmp_stride;
530}
531
532TEST_P(SADTest, UnalignedRef) {
533 // The reference frame, but not the source frame, may be unaligned for
534 // certain types of searches.
535 const int tmp_stride = reference_stride_;
536 reference_stride_ -= 1;
537 FillRandom(source_data_, source_stride_);
538 FillRandom(reference_data_, reference_stride_);
Johannd5d92892015-04-17 16:11:38 -0400539 CheckSAD();
Deb Mukherjeefc882922014-05-13 10:11:42 -0700540 reference_stride_ = tmp_stride;
541}
542
543TEST_P(SADTest, ShortSrc) {
544 const int tmp_stride = source_stride_;
545 source_stride_ >>= 1;
Yi Luoe9832582016-11-29 19:38:12 -0800546 int test_count = 2000;
547 while (test_count > 0) {
548 FillRandom(source_data_, source_stride_);
549 FillRandom(reference_data_, reference_stride_);
550 CheckSAD();
551 test_count -= 1;
552 }
Deb Mukherjeefc882922014-05-13 10:11:42 -0700553 source_stride_ = tmp_stride;
554}
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100555
Yi Luoe9832582016-11-29 19:38:12 -0800556#define SPEED_TEST (0)
557#if SPEED_TEST
558TEST_P(SADTest, Speed) {
559 const int tmp_stride = source_stride_;
560 source_stride_ >>= 1;
561 FillRandom(source_data_, source_stride_);
562 FillRandom(reference_data_, reference_stride_);
563 SpeedSAD();
564 source_stride_ = tmp_stride;
565}
566#endif
567
Johannd5d92892015-04-17 16:11:38 -0400568TEST_P(SADavgTest, MaxRef) {
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100569 FillConstant(source_data_, source_stride_, 0);
570 FillConstant(reference_data_, reference_stride_, mask_);
571 FillConstant(second_pred_, width_, 0);
572 CheckSAD();
573}
Johannd5d92892015-04-17 16:11:38 -0400574TEST_P(SADavgTest, MaxSrc) {
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100575 FillConstant(source_data_, source_stride_, mask_);
576 FillConstant(reference_data_, reference_stride_, 0);
577 FillConstant(second_pred_, width_, 0);
578 CheckSAD();
579}
580
Johannd5d92892015-04-17 16:11:38 -0400581TEST_P(SADavgTest, ShortRef) {
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100582 const int tmp_stride = reference_stride_;
583 reference_stride_ >>= 1;
584 FillRandom(source_data_, source_stride_);
585 FillRandom(reference_data_, reference_stride_);
586 FillRandom(second_pred_, width_);
587 CheckSAD();
588 reference_stride_ = tmp_stride;
589}
590
Johannd5d92892015-04-17 16:11:38 -0400591TEST_P(SADavgTest, UnalignedRef) {
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100592 // The reference frame, but not the source frame, may be unaligned for
593 // certain types of searches.
594 const int tmp_stride = reference_stride_;
595 reference_stride_ -= 1;
596 FillRandom(source_data_, source_stride_);
597 FillRandom(reference_data_, reference_stride_);
598 FillRandom(second_pred_, width_);
599 CheckSAD();
600 reference_stride_ = tmp_stride;
601}
602
Johannd5d92892015-04-17 16:11:38 -0400603TEST_P(SADavgTest, ShortSrc) {
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100604 const int tmp_stride = source_stride_;
605 source_stride_ >>= 1;
Yi Luoe9832582016-11-29 19:38:12 -0800606 int test_count = 2000;
607 while (test_count > 0) {
608 FillRandom(source_data_, source_stride_);
609 FillRandom(reference_data_, reference_stride_);
610 FillRandom(second_pred_, width_);
611 CheckSAD();
612 test_count -= 1;
613 }
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100614 source_stride_ = tmp_stride;
615}
Deb Mukherjeefc882922014-05-13 10:11:42 -0700616
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800617TEST_P(DistWtdCompAvgTest, MaxRef) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800618 FillConstant(reference_data_, reference_stride_, mask_);
619 FillConstant(second_pred_, width_, 0);
620 CheckCompAvg();
621}
622
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800623TEST_P(DistWtdCompAvgTest, MaxSecondPred) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800624 FillConstant(reference_data_, reference_stride_, 0);
625 FillConstant(second_pred_, width_, mask_);
626 CheckCompAvg();
627}
628
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800629TEST_P(DistWtdCompAvgTest, ShortRef) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800630 const int tmp_stride = reference_stride_;
631 reference_stride_ >>= 1;
632 FillRandom(reference_data_, reference_stride_);
633 FillRandom(second_pred_, width_);
634 CheckCompAvg();
635 reference_stride_ = tmp_stride;
636}
637
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800638TEST_P(DistWtdCompAvgTest, UnalignedRef) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800639 // The reference frame, but not the source frame, may be unaligned for
640 // certain types of searches.
641 const int tmp_stride = reference_stride_;
642 reference_stride_ -= 1;
643 FillRandom(reference_data_, reference_stride_);
644 FillRandom(second_pred_, width_);
645 CheckCompAvg();
646 reference_stride_ = tmp_stride;
647}
648
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800649TEST_P(DistWtdSADTest, MaxRef) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800650 FillConstant(source_data_, source_stride_, 0);
651 FillConstant(reference_data_, reference_stride_, mask_);
652 CheckSAD();
653}
654
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800655TEST_P(DistWtdSADTest, MaxSrc) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800656 FillConstant(source_data_, source_stride_, mask_);
657 FillConstant(reference_data_, reference_stride_, 0);
658 CheckSAD();
659}
660
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800661TEST_P(DistWtdSADTest, ShortRef) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800662 const int tmp_stride = reference_stride_;
663 reference_stride_ >>= 1;
664 FillRandom(source_data_, source_stride_);
665 FillRandom(reference_data_, reference_stride_);
666 CheckSAD();
667 reference_stride_ = tmp_stride;
668}
669
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800670TEST_P(DistWtdSADTest, UnalignedRef) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800671 // The reference frame, but not the source frame, may be unaligned for
672 // certain types of searches.
673 const int tmp_stride = reference_stride_;
674 reference_stride_ -= 1;
675 FillRandom(source_data_, source_stride_);
676 FillRandom(reference_data_, reference_stride_);
677 CheckSAD();
678 reference_stride_ = tmp_stride;
679}
680
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800681TEST_P(DistWtdSADTest, ShortSrc) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800682 const int tmp_stride = source_stride_;
683 source_stride_ >>= 1;
684 int test_count = 2000;
685 while (test_count > 0) {
686 FillRandom(source_data_, source_stride_);
687 FillRandom(reference_data_, reference_stride_);
688 CheckSAD();
689 test_count -= 1;
690 }
691 source_stride_ = tmp_stride;
692}
693
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800694TEST_P(DistWtdSADavgTest, MaxRef) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800695 FillConstant(source_data_, source_stride_, 0);
696 FillConstant(reference_data_, reference_stride_, mask_);
697 FillConstant(second_pred_, width_, 0);
698 CheckSAD();
699}
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800700TEST_P(DistWtdSADavgTest, MaxSrc) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800701 FillConstant(source_data_, source_stride_, mask_);
702 FillConstant(reference_data_, reference_stride_, 0);
703 FillConstant(second_pred_, width_, 0);
704 CheckSAD();
705}
706
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800707TEST_P(DistWtdSADavgTest, ShortRef) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800708 const int tmp_stride = reference_stride_;
709 reference_stride_ >>= 1;
710 FillRandom(source_data_, source_stride_);
711 FillRandom(reference_data_, reference_stride_);
712 FillRandom(second_pred_, width_);
713 CheckSAD();
714 reference_stride_ = tmp_stride;
715}
716
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800717TEST_P(DistWtdSADavgTest, UnalignedRef) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800718 // The reference frame, but not the source frame, may be unaligned for
719 // certain types of searches.
720 const int tmp_stride = reference_stride_;
721 reference_stride_ -= 1;
722 FillRandom(source_data_, source_stride_);
723 FillRandom(reference_data_, reference_stride_);
724 FillRandom(second_pred_, width_);
725 CheckSAD();
726 reference_stride_ = tmp_stride;
727}
728
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800729TEST_P(DistWtdSADavgTest, ShortSrc) {
Cheng Chena0367dc2017-11-16 19:20:42 -0800730 const int tmp_stride = source_stride_;
731 source_stride_ >>= 1;
732 int test_count = 2000;
733 while (test_count > 0) {
734 FillRandom(source_data_, source_stride_);
735 FillRandom(reference_data_, reference_stride_);
736 FillRandom(second_pred_, width_);
737 CheckSAD();
738 test_count -= 1;
739 }
740 source_stride_ = tmp_stride;
741}
Cheng Chena0367dc2017-11-16 19:20:42 -0800742
John Koleszar1cfc86e2013-03-01 12:43:41 -0800743TEST_P(SADx4Test, MaxRef) {
744 FillConstant(source_data_, source_stride_, 0);
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100745 FillConstant(GetReference(0), reference_stride_, mask_);
746 FillConstant(GetReference(1), reference_stride_, mask_);
747 FillConstant(GetReference(2), reference_stride_, mask_);
748 FillConstant(GetReference(3), reference_stride_, mask_);
John Koleszar1cfc86e2013-03-01 12:43:41 -0800749 CheckSADs();
750}
751
John Koleszar1cfc86e2013-03-01 12:43:41 -0800752TEST_P(SADx4Test, MaxSrc) {
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100753 FillConstant(source_data_, source_stride_, mask_);
John Koleszar1cfc86e2013-03-01 12:43:41 -0800754 FillConstant(GetReference(0), reference_stride_, 0);
755 FillConstant(GetReference(1), reference_stride_, 0);
756 FillConstant(GetReference(2), reference_stride_, 0);
757 FillConstant(GetReference(3), reference_stride_, 0);
758 CheckSADs();
759}
760
John Koleszar1cfc86e2013-03-01 12:43:41 -0800761TEST_P(SADx4Test, ShortRef) {
762 int tmp_stride = reference_stride_;
763 reference_stride_ >>= 1;
764 FillRandom(source_data_, source_stride_);
765 FillRandom(GetReference(0), reference_stride_);
766 FillRandom(GetReference(1), reference_stride_);
767 FillRandom(GetReference(2), reference_stride_);
768 FillRandom(GetReference(3), reference_stride_);
769 CheckSADs();
770 reference_stride_ = tmp_stride;
771}
772
John Koleszar1cfc86e2013-03-01 12:43:41 -0800773TEST_P(SADx4Test, UnalignedRef) {
774 // The reference frame, but not the source frame, may be unaligned for
775 // certain types of searches.
776 int tmp_stride = reference_stride_;
777 reference_stride_ -= 1;
778 FillRandom(source_data_, source_stride_);
779 FillRandom(GetReference(0), reference_stride_);
780 FillRandom(GetReference(1), reference_stride_);
781 FillRandom(GetReference(2), reference_stride_);
782 FillRandom(GetReference(3), reference_stride_);
783 CheckSADs();
784 reference_stride_ = tmp_stride;
785}
786
John Koleszar1cfc86e2013-03-01 12:43:41 -0800787TEST_P(SADx4Test, ShortSrc) {
788 int tmp_stride = source_stride_;
789 source_stride_ >>= 1;
Yi Luoe9832582016-11-29 19:38:12 -0800790 int test_count = 1000;
791 while (test_count > 0) {
792 FillRandom(source_data_, source_stride_);
793 FillRandom(GetReference(0), reference_stride_);
794 FillRandom(GetReference(1), reference_stride_);
795 FillRandom(GetReference(2), reference_stride_);
796 FillRandom(GetReference(3), reference_stride_);
797 CheckSADs();
798 test_count -= 1;
799 }
John Koleszar1cfc86e2013-03-01 12:43:41 -0800800 source_stride_ = tmp_stride;
801}
802
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100803TEST_P(SADx4Test, SrcAlignedByWidth) {
clang-format3a826f12016-08-11 17:46:05 -0700804 uint8_t *tmp_source_data = source_data_;
Peter de Rivaz7eee4872014-10-16 13:41:55 +0100805 source_data_ += width_;
806 FillRandom(source_data_, source_stride_);
807 FillRandom(GetReference(0), reference_stride_);
808 FillRandom(GetReference(1), reference_stride_);
809 FillRandom(GetReference(2), reference_stride_);
810 FillRandom(GetReference(3), reference_stride_);
811 CheckSADs();
812 source_data_ = tmp_source_data;
813}
814
James Zern95612802018-03-30 11:37:54 -0700815using ::testing::make_tuple;
James Zern12ddb752012-08-15 11:54:41 -0700816
James Zernd7cff282014-02-27 12:49:02 -0800817//------------------------------------------------------------------------------
818// C functions
James Zern18e733b2014-07-16 18:59:28 -0700819const SadMxNParam c_tests[] = {
Yaowu Xuf883b422016-08-30 14:01:10 -0700820 make_tuple(128, 128, &aom_sad128x128_c, -1),
821 make_tuple(128, 64, &aom_sad128x64_c, -1),
822 make_tuple(64, 128, &aom_sad64x128_c, -1),
Yaowu Xuf883b422016-08-30 14:01:10 -0700823 make_tuple(64, 64, &aom_sad64x64_c, -1),
824 make_tuple(64, 32, &aom_sad64x32_c, -1),
825 make_tuple(32, 64, &aom_sad32x64_c, -1),
826 make_tuple(32, 32, &aom_sad32x32_c, -1),
827 make_tuple(32, 16, &aom_sad32x16_c, -1),
828 make_tuple(16, 32, &aom_sad16x32_c, -1),
829 make_tuple(16, 16, &aom_sad16x16_c, -1),
830 make_tuple(16, 8, &aom_sad16x8_c, -1),
831 make_tuple(8, 16, &aom_sad8x16_c, -1),
832 make_tuple(8, 8, &aom_sad8x8_c, -1),
833 make_tuple(8, 4, &aom_sad8x4_c, -1),
834 make_tuple(4, 8, &aom_sad4x8_c, -1),
835 make_tuple(4, 4, &aom_sad4x4_c, -1),
Yaowu Xuf883b422016-08-30 14:01:10 -0700836 make_tuple(128, 128, &aom_highbd_sad128x128_c, 8),
837 make_tuple(128, 64, &aom_highbd_sad128x64_c, 8),
838 make_tuple(64, 128, &aom_highbd_sad64x128_c, 8),
Yaowu Xuf883b422016-08-30 14:01:10 -0700839 make_tuple(64, 64, &aom_highbd_sad64x64_c, 8),
840 make_tuple(64, 32, &aom_highbd_sad64x32_c, 8),
841 make_tuple(32, 64, &aom_highbd_sad32x64_c, 8),
842 make_tuple(32, 32, &aom_highbd_sad32x32_c, 8),
843 make_tuple(32, 16, &aom_highbd_sad32x16_c, 8),
844 make_tuple(16, 32, &aom_highbd_sad16x32_c, 8),
845 make_tuple(16, 16, &aom_highbd_sad16x16_c, 8),
846 make_tuple(16, 8, &aom_highbd_sad16x8_c, 8),
847 make_tuple(8, 16, &aom_highbd_sad8x16_c, 8),
848 make_tuple(8, 8, &aom_highbd_sad8x8_c, 8),
849 make_tuple(8, 4, &aom_highbd_sad8x4_c, 8),
850 make_tuple(4, 8, &aom_highbd_sad4x8_c, 8),
851 make_tuple(4, 4, &aom_highbd_sad4x4_c, 8),
Yaowu Xuf883b422016-08-30 14:01:10 -0700852 make_tuple(128, 128, &aom_highbd_sad128x128_c, 10),
853 make_tuple(128, 64, &aom_highbd_sad128x64_c, 10),
854 make_tuple(64, 128, &aom_highbd_sad64x128_c, 10),
Yaowu Xuf883b422016-08-30 14:01:10 -0700855 make_tuple(64, 64, &aom_highbd_sad64x64_c, 10),
856 make_tuple(64, 32, &aom_highbd_sad64x32_c, 10),
857 make_tuple(32, 64, &aom_highbd_sad32x64_c, 10),
858 make_tuple(32, 32, &aom_highbd_sad32x32_c, 10),
859 make_tuple(32, 16, &aom_highbd_sad32x16_c, 10),
860 make_tuple(16, 32, &aom_highbd_sad16x32_c, 10),
861 make_tuple(16, 16, &aom_highbd_sad16x16_c, 10),
862 make_tuple(16, 8, &aom_highbd_sad16x8_c, 10),
863 make_tuple(8, 16, &aom_highbd_sad8x16_c, 10),
864 make_tuple(8, 8, &aom_highbd_sad8x8_c, 10),
865 make_tuple(8, 4, &aom_highbd_sad8x4_c, 10),
866 make_tuple(4, 8, &aom_highbd_sad4x8_c, 10),
867 make_tuple(4, 4, &aom_highbd_sad4x4_c, 10),
Yaowu Xuf883b422016-08-30 14:01:10 -0700868 make_tuple(128, 128, &aom_highbd_sad128x128_c, 12),
869 make_tuple(128, 64, &aom_highbd_sad128x64_c, 12),
870 make_tuple(64, 128, &aom_highbd_sad64x128_c, 12),
Yaowu Xuf883b422016-08-30 14:01:10 -0700871 make_tuple(64, 64, &aom_highbd_sad64x64_c, 12),
872 make_tuple(64, 32, &aom_highbd_sad64x32_c, 12),
873 make_tuple(32, 64, &aom_highbd_sad32x64_c, 12),
874 make_tuple(32, 32, &aom_highbd_sad32x32_c, 12),
875 make_tuple(32, 16, &aom_highbd_sad32x16_c, 12),
876 make_tuple(16, 32, &aom_highbd_sad16x32_c, 12),
877 make_tuple(16, 16, &aom_highbd_sad16x16_c, 12),
878 make_tuple(16, 8, &aom_highbd_sad16x8_c, 12),
879 make_tuple(8, 16, &aom_highbd_sad8x16_c, 12),
880 make_tuple(8, 8, &aom_highbd_sad8x8_c, 12),
881 make_tuple(8, 4, &aom_highbd_sad8x4_c, 12),
882 make_tuple(4, 8, &aom_highbd_sad4x8_c, 12),
883 make_tuple(4, 4, &aom_highbd_sad4x4_c, 12),
Deb Mukherjeefc882922014-05-13 10:11:42 -0700884};
885INSTANTIATE_TEST_CASE_P(C, SADTest, ::testing::ValuesIn(c_tests));
Deb Mukherjeefc882922014-05-13 10:11:42 -0700886
Johannd5d92892015-04-17 16:11:38 -0400887const SadMxNAvgParam avg_c_tests[] = {
Yaowu Xuf883b422016-08-30 14:01:10 -0700888 make_tuple(128, 128, &aom_sad128x128_avg_c, -1),
889 make_tuple(128, 64, &aom_sad128x64_avg_c, -1),
890 make_tuple(64, 128, &aom_sad64x128_avg_c, -1),
Yaowu Xuf883b422016-08-30 14:01:10 -0700891 make_tuple(64, 64, &aom_sad64x64_avg_c, -1),
892 make_tuple(64, 32, &aom_sad64x32_avg_c, -1),
893 make_tuple(32, 64, &aom_sad32x64_avg_c, -1),
894 make_tuple(32, 32, &aom_sad32x32_avg_c, -1),
895 make_tuple(32, 16, &aom_sad32x16_avg_c, -1),
896 make_tuple(16, 32, &aom_sad16x32_avg_c, -1),
897 make_tuple(16, 16, &aom_sad16x16_avg_c, -1),
898 make_tuple(16, 8, &aom_sad16x8_avg_c, -1),
899 make_tuple(8, 16, &aom_sad8x16_avg_c, -1),
900 make_tuple(8, 8, &aom_sad8x8_avg_c, -1),
901 make_tuple(8, 4, &aom_sad8x4_avg_c, -1),
902 make_tuple(4, 8, &aom_sad4x8_avg_c, -1),
903 make_tuple(4, 4, &aom_sad4x4_avg_c, -1),
Yaowu Xuf883b422016-08-30 14:01:10 -0700904 make_tuple(128, 128, &aom_highbd_sad128x128_avg_c, 8),
905 make_tuple(128, 64, &aom_highbd_sad128x64_avg_c, 8),
906 make_tuple(64, 128, &aom_highbd_sad64x128_avg_c, 8),
Yaowu Xuf883b422016-08-30 14:01:10 -0700907 make_tuple(64, 64, &aom_highbd_sad64x64_avg_c, 8),
908 make_tuple(64, 32, &aom_highbd_sad64x32_avg_c, 8),
909 make_tuple(32, 64, &aom_highbd_sad32x64_avg_c, 8),
910 make_tuple(32, 32, &aom_highbd_sad32x32_avg_c, 8),
911 make_tuple(32, 16, &aom_highbd_sad32x16_avg_c, 8),
912 make_tuple(16, 32, &aom_highbd_sad16x32_avg_c, 8),
913 make_tuple(16, 16, &aom_highbd_sad16x16_avg_c, 8),
914 make_tuple(16, 8, &aom_highbd_sad16x8_avg_c, 8),
915 make_tuple(8, 16, &aom_highbd_sad8x16_avg_c, 8),
916 make_tuple(8, 8, &aom_highbd_sad8x8_avg_c, 8),
917 make_tuple(8, 4, &aom_highbd_sad8x4_avg_c, 8),
918 make_tuple(4, 8, &aom_highbd_sad4x8_avg_c, 8),
919 make_tuple(4, 4, &aom_highbd_sad4x4_avg_c, 8),
Yaowu Xuf883b422016-08-30 14:01:10 -0700920 make_tuple(128, 128, &aom_highbd_sad128x128_avg_c, 10),
921 make_tuple(128, 64, &aom_highbd_sad128x64_avg_c, 10),
922 make_tuple(64, 128, &aom_highbd_sad64x128_avg_c, 10),
Yaowu Xuf883b422016-08-30 14:01:10 -0700923 make_tuple(64, 64, &aom_highbd_sad64x64_avg_c, 10),
924 make_tuple(64, 32, &aom_highbd_sad64x32_avg_c, 10),
925 make_tuple(32, 64, &aom_highbd_sad32x64_avg_c, 10),
926 make_tuple(32, 32, &aom_highbd_sad32x32_avg_c, 10),
927 make_tuple(32, 16, &aom_highbd_sad32x16_avg_c, 10),
928 make_tuple(16, 32, &aom_highbd_sad16x32_avg_c, 10),
929 make_tuple(16, 16, &aom_highbd_sad16x16_avg_c, 10),
930 make_tuple(16, 8, &aom_highbd_sad16x8_avg_c, 10),
931 make_tuple(8, 16, &aom_highbd_sad8x16_avg_c, 10),
932 make_tuple(8, 8, &aom_highbd_sad8x8_avg_c, 10),
933 make_tuple(8, 4, &aom_highbd_sad8x4_avg_c, 10),
934 make_tuple(4, 8, &aom_highbd_sad4x8_avg_c, 10),
935 make_tuple(4, 4, &aom_highbd_sad4x4_avg_c, 10),
Yaowu Xuf883b422016-08-30 14:01:10 -0700936 make_tuple(128, 128, &aom_highbd_sad128x128_avg_c, 12),
937 make_tuple(128, 64, &aom_highbd_sad128x64_avg_c, 12),
938 make_tuple(64, 128, &aom_highbd_sad64x128_avg_c, 12),
Yaowu Xuf883b422016-08-30 14:01:10 -0700939 make_tuple(64, 64, &aom_highbd_sad64x64_avg_c, 12),
940 make_tuple(64, 32, &aom_highbd_sad64x32_avg_c, 12),
941 make_tuple(32, 64, &aom_highbd_sad32x64_avg_c, 12),
942 make_tuple(32, 32, &aom_highbd_sad32x32_avg_c, 12),
943 make_tuple(32, 16, &aom_highbd_sad32x16_avg_c, 12),
944 make_tuple(16, 32, &aom_highbd_sad16x32_avg_c, 12),
945 make_tuple(16, 16, &aom_highbd_sad16x16_avg_c, 12),
946 make_tuple(16, 8, &aom_highbd_sad16x8_avg_c, 12),
947 make_tuple(8, 16, &aom_highbd_sad8x16_avg_c, 12),
948 make_tuple(8, 8, &aom_highbd_sad8x8_avg_c, 12),
949 make_tuple(8, 4, &aom_highbd_sad8x4_avg_c, 12),
950 make_tuple(4, 8, &aom_highbd_sad4x8_avg_c, 12),
951 make_tuple(4, 4, &aom_highbd_sad4x4_avg_c, 12),
Johannd5d92892015-04-17 16:11:38 -0400952};
953INSTANTIATE_TEST_CASE_P(C, SADavgTest, ::testing::ValuesIn(avg_c_tests));
954
Cheng Chena0367dc2017-11-16 19:20:42 -0800955// TODO(chengchen): add highbd tests
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800956const DistWtdCompAvgParam dist_wtd_comp_avg_c_tests[] = {
957 make_tuple(128, 128, &aom_dist_wtd_comp_avg_pred_c, -1),
958 make_tuple(128, 64, &aom_dist_wtd_comp_avg_pred_c, -1),
959 make_tuple(64, 128, &aom_dist_wtd_comp_avg_pred_c, -1),
960 make_tuple(64, 64, &aom_dist_wtd_comp_avg_pred_c, -1),
961 make_tuple(64, 32, &aom_dist_wtd_comp_avg_pred_c, -1),
962 make_tuple(32, 64, &aom_dist_wtd_comp_avg_pred_c, -1),
963 make_tuple(32, 32, &aom_dist_wtd_comp_avg_pred_c, -1),
964 make_tuple(32, 16, &aom_dist_wtd_comp_avg_pred_c, -1),
965 make_tuple(16, 32, &aom_dist_wtd_comp_avg_pred_c, -1),
966 make_tuple(16, 16, &aom_dist_wtd_comp_avg_pred_c, -1),
967 make_tuple(16, 8, &aom_dist_wtd_comp_avg_pred_c, -1),
968 make_tuple(8, 16, &aom_dist_wtd_comp_avg_pred_c, -1),
969 make_tuple(8, 8, &aom_dist_wtd_comp_avg_pred_c, -1),
970 make_tuple(8, 4, &aom_dist_wtd_comp_avg_pred_c, -1),
971 make_tuple(4, 8, &aom_dist_wtd_comp_avg_pred_c, -1),
972 make_tuple(4, 4, &aom_dist_wtd_comp_avg_pred_c, -1),
Cheng Chena0367dc2017-11-16 19:20:42 -0800973};
974
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800975INSTANTIATE_TEST_CASE_P(C, DistWtdCompAvgTest,
976 ::testing::ValuesIn(dist_wtd_comp_avg_c_tests));
Cheng Chena0367dc2017-11-16 19:20:42 -0800977
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800978const DistWtdSadMxNAvgParam dist_wtd_avg_c_tests[] = {
979 make_tuple(128, 128, &aom_dist_wtd_sad128x128_avg_c, -1),
980 make_tuple(128, 64, &aom_dist_wtd_sad128x64_avg_c, -1),
981 make_tuple(64, 128, &aom_dist_wtd_sad64x128_avg_c, -1),
982 make_tuple(64, 64, &aom_dist_wtd_sad64x64_avg_c, -1),
983 make_tuple(64, 32, &aom_dist_wtd_sad64x32_avg_c, -1),
984 make_tuple(32, 64, &aom_dist_wtd_sad32x64_avg_c, -1),
985 make_tuple(32, 32, &aom_dist_wtd_sad32x32_avg_c, -1),
986 make_tuple(32, 16, &aom_dist_wtd_sad32x16_avg_c, -1),
987 make_tuple(16, 32, &aom_dist_wtd_sad16x32_avg_c, -1),
988 make_tuple(16, 16, &aom_dist_wtd_sad16x16_avg_c, -1),
989 make_tuple(16, 8, &aom_dist_wtd_sad16x8_avg_c, -1),
990 make_tuple(8, 16, &aom_dist_wtd_sad8x16_avg_c, -1),
991 make_tuple(8, 8, &aom_dist_wtd_sad8x8_avg_c, -1),
992 make_tuple(8, 4, &aom_dist_wtd_sad8x4_avg_c, -1),
993 make_tuple(4, 8, &aom_dist_wtd_sad4x8_avg_c, -1),
994 make_tuple(4, 4, &aom_dist_wtd_sad4x4_avg_c, -1),
Cheng Chena0367dc2017-11-16 19:20:42 -0800995};
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800996INSTANTIATE_TEST_CASE_P(C, DistWtdSADavgTest,
997 ::testing::ValuesIn(dist_wtd_avg_c_tests));
Cheng Chena0367dc2017-11-16 19:20:42 -0800998
Johannd5d92892015-04-17 16:11:38 -0400999const SadMxNx4Param x4d_c_tests[] = {
Yaowu Xuf883b422016-08-30 14:01:10 -07001000 make_tuple(128, 128, &aom_sad128x128x4d_c, -1),
1001 make_tuple(128, 64, &aom_sad128x64x4d_c, -1),
1002 make_tuple(64, 128, &aom_sad64x128x4d_c, -1),
Yaowu Xuf883b422016-08-30 14:01:10 -07001003 make_tuple(64, 64, &aom_sad64x64x4d_c, -1),
1004 make_tuple(64, 32, &aom_sad64x32x4d_c, -1),
1005 make_tuple(32, 64, &aom_sad32x64x4d_c, -1),
1006 make_tuple(32, 32, &aom_sad32x32x4d_c, -1),
1007 make_tuple(32, 16, &aom_sad32x16x4d_c, -1),
1008 make_tuple(16, 32, &aom_sad16x32x4d_c, -1),
1009 make_tuple(16, 16, &aom_sad16x16x4d_c, -1),
1010 make_tuple(16, 8, &aom_sad16x8x4d_c, -1),
1011 make_tuple(8, 16, &aom_sad8x16x4d_c, -1),
1012 make_tuple(8, 8, &aom_sad8x8x4d_c, -1),
1013 make_tuple(8, 4, &aom_sad8x4x4d_c, -1),
1014 make_tuple(4, 8, &aom_sad4x8x4d_c, -1),
1015 make_tuple(4, 4, &aom_sad4x4x4d_c, -1),
Yaowu Xuf883b422016-08-30 14:01:10 -07001016 make_tuple(128, 128, &aom_highbd_sad128x128x4d_c, 8),
1017 make_tuple(128, 64, &aom_highbd_sad128x64x4d_c, 8),
1018 make_tuple(64, 128, &aom_highbd_sad64x128x4d_c, 8),
Yaowu Xuf883b422016-08-30 14:01:10 -07001019 make_tuple(64, 64, &aom_highbd_sad64x64x4d_c, 8),
1020 make_tuple(64, 32, &aom_highbd_sad64x32x4d_c, 8),
1021 make_tuple(32, 64, &aom_highbd_sad32x64x4d_c, 8),
1022 make_tuple(32, 32, &aom_highbd_sad32x32x4d_c, 8),
1023 make_tuple(32, 16, &aom_highbd_sad32x16x4d_c, 8),
1024 make_tuple(16, 32, &aom_highbd_sad16x32x4d_c, 8),
1025 make_tuple(16, 16, &aom_highbd_sad16x16x4d_c, 8),
1026 make_tuple(16, 8, &aom_highbd_sad16x8x4d_c, 8),
1027 make_tuple(8, 16, &aom_highbd_sad8x16x4d_c, 8),
1028 make_tuple(8, 8, &aom_highbd_sad8x8x4d_c, 8),
1029 make_tuple(8, 4, &aom_highbd_sad8x4x4d_c, 8),
1030 make_tuple(4, 8, &aom_highbd_sad4x8x4d_c, 8),
1031 make_tuple(4, 4, &aom_highbd_sad4x4x4d_c, 8),
Yaowu Xuf883b422016-08-30 14:01:10 -07001032 make_tuple(128, 128, &aom_highbd_sad128x128x4d_c, 10),
1033 make_tuple(128, 64, &aom_highbd_sad128x64x4d_c, 10),
1034 make_tuple(64, 128, &aom_highbd_sad64x128x4d_c, 10),
Yaowu Xuf883b422016-08-30 14:01:10 -07001035 make_tuple(64, 64, &aom_highbd_sad64x64x4d_c, 10),
1036 make_tuple(64, 32, &aom_highbd_sad64x32x4d_c, 10),
1037 make_tuple(32, 64, &aom_highbd_sad32x64x4d_c, 10),
1038 make_tuple(32, 32, &aom_highbd_sad32x32x4d_c, 10),
1039 make_tuple(32, 16, &aom_highbd_sad32x16x4d_c, 10),
1040 make_tuple(16, 32, &aom_highbd_sad16x32x4d_c, 10),
1041 make_tuple(16, 16, &aom_highbd_sad16x16x4d_c, 10),
1042 make_tuple(16, 8, &aom_highbd_sad16x8x4d_c, 10),
1043 make_tuple(8, 16, &aom_highbd_sad8x16x4d_c, 10),
1044 make_tuple(8, 8, &aom_highbd_sad8x8x4d_c, 10),
1045 make_tuple(8, 4, &aom_highbd_sad8x4x4d_c, 10),
1046 make_tuple(4, 8, &aom_highbd_sad4x8x4d_c, 10),
1047 make_tuple(4, 4, &aom_highbd_sad4x4x4d_c, 10),
Yaowu Xuf883b422016-08-30 14:01:10 -07001048 make_tuple(128, 128, &aom_highbd_sad128x128x4d_c, 12),
1049 make_tuple(128, 64, &aom_highbd_sad128x64x4d_c, 12),
1050 make_tuple(64, 128, &aom_highbd_sad64x128x4d_c, 12),
Yaowu Xuf883b422016-08-30 14:01:10 -07001051 make_tuple(64, 64, &aom_highbd_sad64x64x4d_c, 12),
1052 make_tuple(64, 32, &aom_highbd_sad64x32x4d_c, 12),
1053 make_tuple(32, 64, &aom_highbd_sad32x64x4d_c, 12),
1054 make_tuple(32, 32, &aom_highbd_sad32x32x4d_c, 12),
1055 make_tuple(32, 16, &aom_highbd_sad32x16x4d_c, 12),
1056 make_tuple(16, 32, &aom_highbd_sad16x32x4d_c, 12),
1057 make_tuple(16, 16, &aom_highbd_sad16x16x4d_c, 12),
1058 make_tuple(16, 8, &aom_highbd_sad16x8x4d_c, 12),
1059 make_tuple(8, 16, &aom_highbd_sad8x16x4d_c, 12),
1060 make_tuple(8, 8, &aom_highbd_sad8x8x4d_c, 12),
1061 make_tuple(8, 4, &aom_highbd_sad8x4x4d_c, 12),
1062 make_tuple(4, 8, &aom_highbd_sad4x8x4d_c, 12),
1063 make_tuple(4, 4, &aom_highbd_sad4x4x4d_c, 12),
Johannd5d92892015-04-17 16:11:38 -04001064};
1065INSTANTIATE_TEST_CASE_P(C, SADx4Test, ::testing::ValuesIn(x4d_c_tests));
John Koleszar1cfc86e2013-03-01 12:43:41 -08001066
James Zernd7cff282014-02-27 12:49:02 -08001067//------------------------------------------------------------------------------
1068// ARM functions
Johannfbea8972012-06-28 11:43:58 -07001069#if HAVE_NEON
Johannd5d92892015-04-17 16:11:38 -04001070const SadMxNParam neon_tests[] = {
Yaowu Xuf883b422016-08-30 14:01:10 -07001071 make_tuple(64, 64, &aom_sad64x64_neon, -1),
1072 make_tuple(32, 32, &aom_sad32x32_neon, -1),
1073 make_tuple(16, 16, &aom_sad16x16_neon, -1),
1074 make_tuple(16, 8, &aom_sad16x8_neon, -1),
1075 make_tuple(8, 16, &aom_sad8x16_neon, -1),
1076 make_tuple(8, 8, &aom_sad8x8_neon, -1),
1077 make_tuple(4, 4, &aom_sad4x4_neon, -1),
Scott LaVarnway696fa522014-07-16 12:54:46 -07001078};
Johannd5d92892015-04-17 16:11:38 -04001079INSTANTIATE_TEST_CASE_P(NEON, SADTest, ::testing::ValuesIn(neon_tests));
1080
Johannd5d92892015-04-17 16:11:38 -04001081const SadMxNx4Param x4d_neon_tests[] = {
Yaowu Xuf883b422016-08-30 14:01:10 -07001082 make_tuple(64, 64, &aom_sad64x64x4d_neon, -1),
1083 make_tuple(32, 32, &aom_sad32x32x4d_neon, -1),
1084 make_tuple(16, 16, &aom_sad16x16x4d_neon, -1),
Johannd5d92892015-04-17 16:11:38 -04001085};
1086INSTANTIATE_TEST_CASE_P(NEON, SADx4Test, ::testing::ValuesIn(x4d_neon_tests));
Deb Mukherjeefc882922014-05-13 10:11:42 -07001087#endif // HAVE_NEON
Johannfbea8972012-06-28 11:43:58 -07001088
James Zernd7cff282014-02-27 12:49:02 -08001089//------------------------------------------------------------------------------
1090// x86 functions
Johannfbea8972012-06-28 11:43:58 -07001091#if HAVE_SSE2
James Zern18e733b2014-07-16 18:59:28 -07001092const SadMxNParam sse2_tests[] = {
Yaowu Xuf883b422016-08-30 14:01:10 -07001093 make_tuple(128, 128, &aom_sad128x128_sse2, -1),
1094 make_tuple(128, 64, &aom_sad128x64_sse2, -1),
1095 make_tuple(64, 128, &aom_sad64x128_sse2, -1),
Yaowu Xuf883b422016-08-30 14:01:10 -07001096 make_tuple(64, 64, &aom_sad64x64_sse2, -1),
1097 make_tuple(64, 32, &aom_sad64x32_sse2, -1),
1098 make_tuple(32, 64, &aom_sad32x64_sse2, -1),
1099 make_tuple(32, 32, &aom_sad32x32_sse2, -1),
1100 make_tuple(32, 16, &aom_sad32x16_sse2, -1),
1101 make_tuple(16, 32, &aom_sad16x32_sse2, -1),
1102 make_tuple(16, 16, &aom_sad16x16_sse2, -1),
1103 make_tuple(16, 8, &aom_sad16x8_sse2, -1),
1104 make_tuple(8, 16, &aom_sad8x16_sse2, -1),
1105 make_tuple(8, 8, &aom_sad8x8_sse2, -1),
1106 make_tuple(8, 4, &aom_sad8x4_sse2, -1),
1107 make_tuple(4, 8, &aom_sad4x8_sse2, -1),
1108 make_tuple(4, 4, &aom_sad4x4_sse2, -1),
Yaowu Xuf883b422016-08-30 14:01:10 -07001109 make_tuple(64, 64, &aom_highbd_sad64x64_sse2, 8),
1110 make_tuple(64, 32, &aom_highbd_sad64x32_sse2, 8),
1111 make_tuple(32, 64, &aom_highbd_sad32x64_sse2, 8),
1112 make_tuple(32, 32, &aom_highbd_sad32x32_sse2, 8),
1113 make_tuple(32, 16, &aom_highbd_sad32x16_sse2, 8),
1114 make_tuple(16, 32, &aom_highbd_sad16x32_sse2, 8),
1115 make_tuple(16, 16, &aom_highbd_sad16x16_sse2, 8),
1116 make_tuple(16, 8, &aom_highbd_sad16x8_sse2, 8),
1117 make_tuple(8, 16, &aom_highbd_sad8x16_sse2, 8),
1118 make_tuple(8, 8, &aom_highbd_sad8x8_sse2, 8),
1119 make_tuple(8, 4, &aom_highbd_sad8x4_sse2, 8),
1120 make_tuple(64, 64, &aom_highbd_sad64x64_sse2, 10),
1121 make_tuple(64, 32, &aom_highbd_sad64x32_sse2, 10),
1122 make_tuple(32, 64, &aom_highbd_sad32x64_sse2, 10),
1123 make_tuple(32, 32, &aom_highbd_sad32x32_sse2, 10),
1124 make_tuple(32, 16, &aom_highbd_sad32x16_sse2, 10),
1125 make_tuple(16, 32, &aom_highbd_sad16x32_sse2, 10),
1126 make_tuple(16, 16, &aom_highbd_sad16x16_sse2, 10),
1127 make_tuple(16, 8, &aom_highbd_sad16x8_sse2, 10),
1128 make_tuple(8, 16, &aom_highbd_sad8x16_sse2, 10),
1129 make_tuple(8, 8, &aom_highbd_sad8x8_sse2, 10),
1130 make_tuple(8, 4, &aom_highbd_sad8x4_sse2, 10),
1131 make_tuple(64, 64, &aom_highbd_sad64x64_sse2, 12),
1132 make_tuple(64, 32, &aom_highbd_sad64x32_sse2, 12),
1133 make_tuple(32, 64, &aom_highbd_sad32x64_sse2, 12),
1134 make_tuple(32, 32, &aom_highbd_sad32x32_sse2, 12),
1135 make_tuple(32, 16, &aom_highbd_sad32x16_sse2, 12),
1136 make_tuple(16, 32, &aom_highbd_sad16x32_sse2, 12),
1137 make_tuple(16, 16, &aom_highbd_sad16x16_sse2, 12),
1138 make_tuple(16, 8, &aom_highbd_sad16x8_sse2, 12),
1139 make_tuple(8, 16, &aom_highbd_sad8x16_sse2, 12),
1140 make_tuple(8, 8, &aom_highbd_sad8x8_sse2, 12),
1141 make_tuple(8, 4, &aom_highbd_sad8x4_sse2, 12),
Deb Mukherjeefc882922014-05-13 10:11:42 -07001142};
1143INSTANTIATE_TEST_CASE_P(SSE2, SADTest, ::testing::ValuesIn(sse2_tests));
Deb Mukherjeefc882922014-05-13 10:11:42 -07001144
Johannd5d92892015-04-17 16:11:38 -04001145const SadMxNAvgParam avg_sse2_tests[] = {
Yaowu Xuf883b422016-08-30 14:01:10 -07001146 make_tuple(128, 128, &aom_sad128x128_avg_sse2, -1),
1147 make_tuple(128, 64, &aom_sad128x64_avg_sse2, -1),
1148 make_tuple(64, 128, &aom_sad64x128_avg_sse2, -1),
Yaowu Xuf883b422016-08-30 14:01:10 -07001149 make_tuple(64, 64, &aom_sad64x64_avg_sse2, -1),
1150 make_tuple(64, 32, &aom_sad64x32_avg_sse2, -1),
1151 make_tuple(32, 64, &aom_sad32x64_avg_sse2, -1),
1152 make_tuple(32, 32, &aom_sad32x32_avg_sse2, -1),
1153 make_tuple(32, 16, &aom_sad32x16_avg_sse2, -1),
1154 make_tuple(16, 32, &aom_sad16x32_avg_sse2, -1),
1155 make_tuple(16, 16, &aom_sad16x16_avg_sse2, -1),
1156 make_tuple(16, 8, &aom_sad16x8_avg_sse2, -1),
1157 make_tuple(8, 16, &aom_sad8x16_avg_sse2, -1),
1158 make_tuple(8, 8, &aom_sad8x8_avg_sse2, -1),
1159 make_tuple(8, 4, &aom_sad8x4_avg_sse2, -1),
1160 make_tuple(4, 8, &aom_sad4x8_avg_sse2, -1),
1161 make_tuple(4, 4, &aom_sad4x4_avg_sse2, -1),
Yaowu Xuf883b422016-08-30 14:01:10 -07001162 make_tuple(64, 64, &aom_highbd_sad64x64_avg_sse2, 8),
1163 make_tuple(64, 32, &aom_highbd_sad64x32_avg_sse2, 8),
1164 make_tuple(32, 64, &aom_highbd_sad32x64_avg_sse2, 8),
1165 make_tuple(32, 32, &aom_highbd_sad32x32_avg_sse2, 8),
1166 make_tuple(32, 16, &aom_highbd_sad32x16_avg_sse2, 8),
1167 make_tuple(16, 32, &aom_highbd_sad16x32_avg_sse2, 8),
1168 make_tuple(16, 16, &aom_highbd_sad16x16_avg_sse2, 8),
1169 make_tuple(16, 8, &aom_highbd_sad16x8_avg_sse2, 8),
1170 make_tuple(8, 16, &aom_highbd_sad8x16_avg_sse2, 8),
1171 make_tuple(8, 8, &aom_highbd_sad8x8_avg_sse2, 8),
1172 make_tuple(8, 4, &aom_highbd_sad8x4_avg_sse2, 8),
1173 make_tuple(64, 64, &aom_highbd_sad64x64_avg_sse2, 10),
1174 make_tuple(64, 32, &aom_highbd_sad64x32_avg_sse2, 10),
1175 make_tuple(32, 64, &aom_highbd_sad32x64_avg_sse2, 10),
1176 make_tuple(32, 32, &aom_highbd_sad32x32_avg_sse2, 10),
1177 make_tuple(32, 16, &aom_highbd_sad32x16_avg_sse2, 10),
1178 make_tuple(16, 32, &aom_highbd_sad16x32_avg_sse2, 10),
1179 make_tuple(16, 16, &aom_highbd_sad16x16_avg_sse2, 10),
1180 make_tuple(16, 8, &aom_highbd_sad16x8_avg_sse2, 10),
1181 make_tuple(8, 16, &aom_highbd_sad8x16_avg_sse2, 10),
1182 make_tuple(8, 8, &aom_highbd_sad8x8_avg_sse2, 10),
1183 make_tuple(8, 4, &aom_highbd_sad8x4_avg_sse2, 10),
1184 make_tuple(64, 64, &aom_highbd_sad64x64_avg_sse2, 12),
1185 make_tuple(64, 32, &aom_highbd_sad64x32_avg_sse2, 12),
1186 make_tuple(32, 64, &aom_highbd_sad32x64_avg_sse2, 12),
1187 make_tuple(32, 32, &aom_highbd_sad32x32_avg_sse2, 12),
1188 make_tuple(32, 16, &aom_highbd_sad32x16_avg_sse2, 12),
1189 make_tuple(16, 32, &aom_highbd_sad16x32_avg_sse2, 12),
1190 make_tuple(16, 16, &aom_highbd_sad16x16_avg_sse2, 12),
1191 make_tuple(16, 8, &aom_highbd_sad16x8_avg_sse2, 12),
1192 make_tuple(8, 16, &aom_highbd_sad8x16_avg_sse2, 12),
1193 make_tuple(8, 8, &aom_highbd_sad8x8_avg_sse2, 12),
1194 make_tuple(8, 4, &aom_highbd_sad8x4_avg_sse2, 12),
Johannd5d92892015-04-17 16:11:38 -04001195};
1196INSTANTIATE_TEST_CASE_P(SSE2, SADavgTest, ::testing::ValuesIn(avg_sse2_tests));
1197
Johannd5d92892015-04-17 16:11:38 -04001198const SadMxNx4Param x4d_sse2_tests[] = {
Yaowu Xuf883b422016-08-30 14:01:10 -07001199 make_tuple(128, 128, &aom_sad128x128x4d_sse2, -1),
1200 make_tuple(128, 64, &aom_sad128x64x4d_sse2, -1),
1201 make_tuple(64, 128, &aom_sad64x128x4d_sse2, -1),
Yaowu Xuf883b422016-08-30 14:01:10 -07001202 make_tuple(64, 64, &aom_sad64x64x4d_sse2, -1),
1203 make_tuple(64, 32, &aom_sad64x32x4d_sse2, -1),
1204 make_tuple(32, 64, &aom_sad32x64x4d_sse2, -1),
1205 make_tuple(32, 32, &aom_sad32x32x4d_sse2, -1),
1206 make_tuple(32, 16, &aom_sad32x16x4d_sse2, -1),
1207 make_tuple(16, 32, &aom_sad16x32x4d_sse2, -1),
1208 make_tuple(16, 16, &aom_sad16x16x4d_sse2, -1),
1209 make_tuple(16, 8, &aom_sad16x8x4d_sse2, -1),
1210 make_tuple(8, 16, &aom_sad8x16x4d_sse2, -1),
1211 make_tuple(8, 8, &aom_sad8x8x4d_sse2, -1),
1212 make_tuple(8, 4, &aom_sad8x4x4d_sse2, -1),
1213 make_tuple(4, 8, &aom_sad4x8x4d_sse2, -1),
1214 make_tuple(4, 4, &aom_sad4x4x4d_sse2, -1),
Yaowu Xuf883b422016-08-30 14:01:10 -07001215 make_tuple(64, 64, &aom_highbd_sad64x64x4d_sse2, 8),
1216 make_tuple(64, 32, &aom_highbd_sad64x32x4d_sse2, 8),
1217 make_tuple(32, 64, &aom_highbd_sad32x64x4d_sse2, 8),
1218 make_tuple(32, 32, &aom_highbd_sad32x32x4d_sse2, 8),
1219 make_tuple(32, 16, &aom_highbd_sad32x16x4d_sse2, 8),
1220 make_tuple(16, 32, &aom_highbd_sad16x32x4d_sse2, 8),
1221 make_tuple(16, 16, &aom_highbd_sad16x16x4d_sse2, 8),
1222 make_tuple(16, 8, &aom_highbd_sad16x8x4d_sse2, 8),
1223 make_tuple(8, 16, &aom_highbd_sad8x16x4d_sse2, 8),
1224 make_tuple(8, 8, &aom_highbd_sad8x8x4d_sse2, 8),
1225 make_tuple(8, 4, &aom_highbd_sad8x4x4d_sse2, 8),
1226 make_tuple(4, 8, &aom_highbd_sad4x8x4d_sse2, 8),
1227 make_tuple(4, 4, &aom_highbd_sad4x4x4d_sse2, 8),
1228 make_tuple(64, 64, &aom_highbd_sad64x64x4d_sse2, 10),
1229 make_tuple(64, 32, &aom_highbd_sad64x32x4d_sse2, 10),
1230 make_tuple(32, 64, &aom_highbd_sad32x64x4d_sse2, 10),
1231 make_tuple(32, 32, &aom_highbd_sad32x32x4d_sse2, 10),
1232 make_tuple(32, 16, &aom_highbd_sad32x16x4d_sse2, 10),
1233 make_tuple(16, 32, &aom_highbd_sad16x32x4d_sse2, 10),
1234 make_tuple(16, 16, &aom_highbd_sad16x16x4d_sse2, 10),
1235 make_tuple(16, 8, &aom_highbd_sad16x8x4d_sse2, 10),
1236 make_tuple(8, 16, &aom_highbd_sad8x16x4d_sse2, 10),
1237 make_tuple(8, 8, &aom_highbd_sad8x8x4d_sse2, 10),
1238 make_tuple(8, 4, &aom_highbd_sad8x4x4d_sse2, 10),
1239 make_tuple(4, 8, &aom_highbd_sad4x8x4d_sse2, 10),
1240 make_tuple(4, 4, &aom_highbd_sad4x4x4d_sse2, 10),
1241 make_tuple(64, 64, &aom_highbd_sad64x64x4d_sse2, 12),
1242 make_tuple(64, 32, &aom_highbd_sad64x32x4d_sse2, 12),
1243 make_tuple(32, 64, &aom_highbd_sad32x64x4d_sse2, 12),
1244 make_tuple(32, 32, &aom_highbd_sad32x32x4d_sse2, 12),
1245 make_tuple(32, 16, &aom_highbd_sad32x16x4d_sse2, 12),
1246 make_tuple(16, 32, &aom_highbd_sad16x32x4d_sse2, 12),
1247 make_tuple(16, 16, &aom_highbd_sad16x16x4d_sse2, 12),
1248 make_tuple(16, 8, &aom_highbd_sad16x8x4d_sse2, 12),
1249 make_tuple(8, 16, &aom_highbd_sad8x16x4d_sse2, 12),
1250 make_tuple(8, 8, &aom_highbd_sad8x8x4d_sse2, 12),
1251 make_tuple(8, 4, &aom_highbd_sad8x4x4d_sse2, 12),
1252 make_tuple(4, 8, &aom_highbd_sad4x8x4d_sse2, 12),
1253 make_tuple(4, 4, &aom_highbd_sad4x4x4d_sse2, 12),
Johannd5d92892015-04-17 16:11:38 -04001254};
1255INSTANTIATE_TEST_CASE_P(SSE2, SADx4Test, ::testing::ValuesIn(x4d_sse2_tests));
Urvang Joshib8b8dad2018-05-08 19:23:30 -04001256#endif // HAVE_SSE2
Cheng Chena0367dc2017-11-16 19:20:42 -08001257
Urvang Joshib8b8dad2018-05-08 19:23:30 -04001258#if HAVE_SSSE3
1259// Note: These are named sse2, but part of ssse3 file and only built and linked
1260// when ssse3 is enabled.
Debargha Mukherjee0c96c112018-12-20 16:04:18 -08001261const DistWtdSadMxhParam dist_wtd_sad_sse2_tests[] = {
Cheng Chena0367dc2017-11-16 19:20:42 -08001262 make_tuple(4, 4, &aom_sad4xh_sse2, -1),
1263 make_tuple(4, 8, &aom_sad4xh_sse2, -1),
1264 make_tuple(8, 4, &aom_sad8xh_sse2, -1),
1265 make_tuple(8, 8, &aom_sad8xh_sse2, -1),
1266 make_tuple(8, 16, &aom_sad8xh_sse2, -1),
1267 make_tuple(16, 8, &aom_sad16xh_sse2, -1),
1268 make_tuple(16, 16, &aom_sad16xh_sse2, -1),
1269 make_tuple(16, 32, &aom_sad16xh_sse2, -1),
1270 make_tuple(32, 16, &aom_sad32xh_sse2, -1),
1271 make_tuple(32, 32, &aom_sad32xh_sse2, -1),
1272 make_tuple(32, 64, &aom_sad32xh_sse2, -1),
1273 make_tuple(64, 32, &aom_sad64xh_sse2, -1),
1274 make_tuple(64, 64, &aom_sad64xh_sse2, -1),
Cheng Chena0367dc2017-11-16 19:20:42 -08001275 make_tuple(128, 128, &aom_sad128xh_sse2, -1),
1276 make_tuple(128, 64, &aom_sad128xh_sse2, -1),
1277 make_tuple(64, 128, &aom_sad64xh_sse2, -1),
Cheng Chena0367dc2017-11-16 19:20:42 -08001278 make_tuple(4, 16, &aom_sad4xh_sse2, -1),
1279 make_tuple(16, 4, &aom_sad16xh_sse2, -1),
1280 make_tuple(8, 32, &aom_sad8xh_sse2, -1),
1281 make_tuple(32, 8, &aom_sad32xh_sse2, -1),
1282 make_tuple(16, 64, &aom_sad16xh_sse2, -1),
1283 make_tuple(64, 16, &aom_sad64xh_sse2, -1),
Cheng Chena0367dc2017-11-16 19:20:42 -08001284};
Debargha Mukherjee0c96c112018-12-20 16:04:18 -08001285INSTANTIATE_TEST_CASE_P(SSE2, DistWtdSADTest,
1286 ::testing::ValuesIn(dist_wtd_sad_sse2_tests));
Cheng Chena0367dc2017-11-16 19:20:42 -08001287
Urvang Joshib8b8dad2018-05-08 19:23:30 -04001288#endif // HAVE_SSSE3
John Koleszar1cfc86e2013-03-01 12:43:41 -08001289
1290#if HAVE_SSE3
Johannd5d92892015-04-17 16:11:38 -04001291// Only functions are x3, which do not have tests.
Deb Mukherjeefc882922014-05-13 10:11:42 -07001292#endif // HAVE_SSE3
John Koleszar6b653cb2013-02-28 17:03:02 -08001293
Johannfbea8972012-06-28 11:43:58 -07001294#if HAVE_SSSE3
Debargha Mukherjee0c96c112018-12-20 16:04:18 -08001295const DistWtdCompAvgParam dist_wtd_comp_avg_ssse3_tests[] = {
1296 make_tuple(128, 128, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
1297 make_tuple(128, 64, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
1298 make_tuple(64, 128, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
1299 make_tuple(64, 64, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
1300 make_tuple(64, 32, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
1301 make_tuple(32, 64, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
1302 make_tuple(32, 32, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
1303 make_tuple(32, 16, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
1304 make_tuple(16, 32, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
1305 make_tuple(16, 16, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
1306 make_tuple(16, 8, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
1307 make_tuple(8, 16, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
1308 make_tuple(8, 8, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
1309 make_tuple(8, 4, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
1310 make_tuple(4, 8, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
1311 make_tuple(4, 4, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
1312 make_tuple(16, 16, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
Cheng Chena0367dc2017-11-16 19:20:42 -08001313};
1314
Debargha Mukherjee0c96c112018-12-20 16:04:18 -08001315INSTANTIATE_TEST_CASE_P(SSSE3, DistWtdCompAvgTest,
1316 ::testing::ValuesIn(dist_wtd_comp_avg_ssse3_tests));
Cheng Chena0367dc2017-11-16 19:20:42 -08001317
Debargha Mukherjee0c96c112018-12-20 16:04:18 -08001318const DistWtdSadMxNAvgParam dist_wtd_avg_ssse3_tests[] = {
1319 make_tuple(128, 128, &aom_dist_wtd_sad128x128_avg_ssse3, -1),
1320 make_tuple(128, 64, &aom_dist_wtd_sad128x64_avg_ssse3, -1),
1321 make_tuple(64, 128, &aom_dist_wtd_sad64x128_avg_ssse3, -1),
1322 make_tuple(64, 64, &aom_dist_wtd_sad64x64_avg_ssse3, -1),
1323 make_tuple(64, 32, &aom_dist_wtd_sad64x32_avg_ssse3, -1),
1324 make_tuple(32, 64, &aom_dist_wtd_sad32x64_avg_ssse3, -1),
1325 make_tuple(32, 32, &aom_dist_wtd_sad32x32_avg_ssse3, -1),
1326 make_tuple(32, 16, &aom_dist_wtd_sad32x16_avg_ssse3, -1),
1327 make_tuple(16, 32, &aom_dist_wtd_sad16x32_avg_ssse3, -1),
1328 make_tuple(16, 16, &aom_dist_wtd_sad16x16_avg_ssse3, -1),
1329 make_tuple(16, 8, &aom_dist_wtd_sad16x8_avg_ssse3, -1),
1330 make_tuple(8, 16, &aom_dist_wtd_sad8x16_avg_ssse3, -1),
1331 make_tuple(8, 8, &aom_dist_wtd_sad8x8_avg_ssse3, -1),
1332 make_tuple(8, 4, &aom_dist_wtd_sad8x4_avg_ssse3, -1),
1333 make_tuple(4, 8, &aom_dist_wtd_sad4x8_avg_ssse3, -1),
1334 make_tuple(4, 4, &aom_dist_wtd_sad4x4_avg_ssse3, -1),
Cheng Chena0367dc2017-11-16 19:20:42 -08001335};
Debargha Mukherjee0c96c112018-12-20 16:04:18 -08001336INSTANTIATE_TEST_CASE_P(SSSE3, DistWtdSADavgTest,
1337 ::testing::ValuesIn(dist_wtd_avg_ssse3_tests));
Deb Mukherjeefc882922014-05-13 10:11:42 -07001338#endif // HAVE_SSSE3
Johannfbea8972012-06-28 11:43:58 -07001339
Johannd5d92892015-04-17 16:11:38 -04001340#if HAVE_SSE4_1
1341// Only functions are x8, which do not have tests.
1342#endif // HAVE_SSE4_1
James Zernd3ff0092014-06-08 18:25:37 -07001343
Johannd5d92892015-04-17 16:11:38 -04001344#if HAVE_AVX2
Johannd5d92892015-04-17 16:11:38 -04001345const SadMxNParam avx2_tests[] = {
Yi Luo1f496242016-11-09 13:39:51 -08001346 make_tuple(64, 128, &aom_sad64x128_avx2, -1),
1347 make_tuple(128, 64, &aom_sad128x64_avx2, -1),
1348 make_tuple(128, 128, &aom_sad128x128_avx2, -1),
Yaowu Xuf883b422016-08-30 14:01:10 -07001349 make_tuple(64, 64, &aom_sad64x64_avx2, -1),
1350 make_tuple(64, 32, &aom_sad64x32_avx2, -1),
1351 make_tuple(32, 64, &aom_sad32x64_avx2, -1),
1352 make_tuple(32, 32, &aom_sad32x32_avx2, -1),
1353 make_tuple(32, 16, &aom_sad32x16_avx2, -1),
Yi Luoe9832582016-11-29 19:38:12 -08001354 make_tuple(128, 128, &aom_highbd_sad128x128_avx2, 8),
1355 make_tuple(128, 128, &aom_highbd_sad128x128_avx2, 10),
1356 make_tuple(128, 128, &aom_highbd_sad128x128_avx2, 12),
1357 make_tuple(128, 64, &aom_highbd_sad128x64_avx2, 8),
1358 make_tuple(128, 64, &aom_highbd_sad128x64_avx2, 10),
1359 make_tuple(128, 64, &aom_highbd_sad128x64_avx2, 12),
1360 make_tuple(64, 128, &aom_highbd_sad64x128_avx2, 8),
1361 make_tuple(64, 128, &aom_highbd_sad64x128_avx2, 10),
1362 make_tuple(64, 128, &aom_highbd_sad64x128_avx2, 12),
Yi Luoe9832582016-11-29 19:38:12 -08001363 make_tuple(64, 64, &aom_highbd_sad64x64_avx2, 8),
1364 make_tuple(64, 64, &aom_highbd_sad64x64_avx2, 10),
1365 make_tuple(64, 64, &aom_highbd_sad64x64_avx2, 12),
1366 make_tuple(64, 32, &aom_highbd_sad64x32_avx2, 8),
1367 make_tuple(64, 32, &aom_highbd_sad64x32_avx2, 10),
1368 make_tuple(64, 32, &aom_highbd_sad64x32_avx2, 12),
1369 make_tuple(32, 64, &aom_highbd_sad32x64_avx2, 8),
1370 make_tuple(32, 64, &aom_highbd_sad32x64_avx2, 10),
1371 make_tuple(32, 64, &aom_highbd_sad32x64_avx2, 12),
1372 make_tuple(32, 32, &aom_highbd_sad32x32_avx2, 8),
1373 make_tuple(32, 32, &aom_highbd_sad32x32_avx2, 10),
1374 make_tuple(32, 32, &aom_highbd_sad32x32_avx2, 12),
1375 make_tuple(32, 16, &aom_highbd_sad32x16_avx2, 8),
1376 make_tuple(32, 16, &aom_highbd_sad32x16_avx2, 10),
1377 make_tuple(32, 16, &aom_highbd_sad32x16_avx2, 12),
1378 make_tuple(16, 32, &aom_highbd_sad16x32_avx2, 8),
1379 make_tuple(16, 32, &aom_highbd_sad16x32_avx2, 10),
1380 make_tuple(16, 32, &aom_highbd_sad16x32_avx2, 12),
1381 make_tuple(16, 16, &aom_highbd_sad16x16_avx2, 8),
1382 make_tuple(16, 16, &aom_highbd_sad16x16_avx2, 10),
1383 make_tuple(16, 16, &aom_highbd_sad16x16_avx2, 12),
1384 make_tuple(16, 8, &aom_highbd_sad16x8_avx2, 8),
1385 make_tuple(16, 8, &aom_highbd_sad16x8_avx2, 10),
1386 make_tuple(16, 8, &aom_highbd_sad16x8_avx2, 12),
Johannd5d92892015-04-17 16:11:38 -04001387};
1388INSTANTIATE_TEST_CASE_P(AVX2, SADTest, ::testing::ValuesIn(avx2_tests));
1389
Johannd5d92892015-04-17 16:11:38 -04001390const SadMxNAvgParam avg_avx2_tests[] = {
Yi Luo9e218742016-11-22 11:50:12 -08001391 make_tuple(64, 128, &aom_sad64x128_avg_avx2, -1),
1392 make_tuple(128, 64, &aom_sad128x64_avg_avx2, -1),
1393 make_tuple(128, 128, &aom_sad128x128_avg_avx2, -1),
Yaowu Xuf883b422016-08-30 14:01:10 -07001394 make_tuple(64, 64, &aom_sad64x64_avg_avx2, -1),
1395 make_tuple(64, 32, &aom_sad64x32_avg_avx2, -1),
1396 make_tuple(32, 64, &aom_sad32x64_avg_avx2, -1),
1397 make_tuple(32, 32, &aom_sad32x32_avg_avx2, -1),
1398 make_tuple(32, 16, &aom_sad32x16_avg_avx2, -1),
Yi Luoe9832582016-11-29 19:38:12 -08001399 make_tuple(128, 128, &aom_highbd_sad128x128_avg_avx2, 8),
1400 make_tuple(128, 128, &aom_highbd_sad128x128_avg_avx2, 10),
1401 make_tuple(128, 128, &aom_highbd_sad128x128_avg_avx2, 12),
1402 make_tuple(128, 64, &aom_highbd_sad128x64_avg_avx2, 8),
1403 make_tuple(128, 64, &aom_highbd_sad128x64_avg_avx2, 10),
1404 make_tuple(128, 64, &aom_highbd_sad128x64_avg_avx2, 12),
1405 make_tuple(64, 128, &aom_highbd_sad64x128_avg_avx2, 8),
1406 make_tuple(64, 128, &aom_highbd_sad64x128_avg_avx2, 10),
1407 make_tuple(64, 128, &aom_highbd_sad64x128_avg_avx2, 12),
Yi Luoe9832582016-11-29 19:38:12 -08001408 make_tuple(64, 64, &aom_highbd_sad64x64_avg_avx2, 8),
1409 make_tuple(64, 64, &aom_highbd_sad64x64_avg_avx2, 10),
1410 make_tuple(64, 64, &aom_highbd_sad64x64_avg_avx2, 12),
1411 make_tuple(64, 32, &aom_highbd_sad64x32_avg_avx2, 8),
1412 make_tuple(64, 32, &aom_highbd_sad64x32_avg_avx2, 10),
1413 make_tuple(64, 32, &aom_highbd_sad64x32_avg_avx2, 12),
1414 make_tuple(32, 64, &aom_highbd_sad32x64_avg_avx2, 8),
1415 make_tuple(32, 64, &aom_highbd_sad32x64_avg_avx2, 10),
1416 make_tuple(32, 64, &aom_highbd_sad32x64_avg_avx2, 12),
1417 make_tuple(32, 32, &aom_highbd_sad32x32_avg_avx2, 8),
1418 make_tuple(32, 32, &aom_highbd_sad32x32_avg_avx2, 10),
1419 make_tuple(32, 32, &aom_highbd_sad32x32_avg_avx2, 12),
1420 make_tuple(32, 16, &aom_highbd_sad32x16_avg_avx2, 8),
1421 make_tuple(32, 16, &aom_highbd_sad32x16_avg_avx2, 10),
1422 make_tuple(32, 16, &aom_highbd_sad32x16_avg_avx2, 12),
1423 make_tuple(16, 32, &aom_highbd_sad16x32_avg_avx2, 8),
1424 make_tuple(16, 32, &aom_highbd_sad16x32_avg_avx2, 10),
1425 make_tuple(16, 32, &aom_highbd_sad16x32_avg_avx2, 12),
1426 make_tuple(16, 16, &aom_highbd_sad16x16_avg_avx2, 8),
1427 make_tuple(16, 16, &aom_highbd_sad16x16_avg_avx2, 10),
1428 make_tuple(16, 16, &aom_highbd_sad16x16_avg_avx2, 12),
1429 make_tuple(16, 8, &aom_highbd_sad16x8_avg_avx2, 8),
1430 make_tuple(16, 8, &aom_highbd_sad16x8_avg_avx2, 10),
1431 make_tuple(16, 8, &aom_highbd_sad16x8_avg_avx2, 12),
Johannd5d92892015-04-17 16:11:38 -04001432};
1433INSTANTIATE_TEST_CASE_P(AVX2, SADavgTest, ::testing::ValuesIn(avg_avx2_tests));
1434
Johannd5d92892015-04-17 16:11:38 -04001435const SadMxNx4Param x4d_avx2_tests[] = {
Yi Luo9e218742016-11-22 11:50:12 -08001436 make_tuple(64, 128, &aom_sad64x128x4d_avx2, -1),
1437 make_tuple(128, 64, &aom_sad128x64x4d_avx2, -1),
1438 make_tuple(128, 128, &aom_sad128x128x4d_avx2, -1),
Yaowu Xuf883b422016-08-30 14:01:10 -07001439 make_tuple(64, 64, &aom_sad64x64x4d_avx2, -1),
Yi Luo9e218742016-11-22 11:50:12 -08001440 make_tuple(32, 64, &aom_sad32x64x4d_avx2, -1),
1441 make_tuple(64, 32, &aom_sad64x32x4d_avx2, -1),
Yaowu Xuf883b422016-08-30 14:01:10 -07001442 make_tuple(32, 32, &aom_sad32x32x4d_avx2, -1),
Yi Luoe9832582016-11-29 19:38:12 -08001443 make_tuple(128, 128, &aom_highbd_sad128x128x4d_avx2, 8),
1444 make_tuple(128, 128, &aom_highbd_sad128x128x4d_avx2, 10),
1445 make_tuple(128, 128, &aom_highbd_sad128x128x4d_avx2, 12),
1446 make_tuple(128, 64, &aom_highbd_sad128x64x4d_avx2, 8),
1447 make_tuple(128, 64, &aom_highbd_sad128x64x4d_avx2, 10),
1448 make_tuple(128, 64, &aom_highbd_sad128x64x4d_avx2, 12),
1449 make_tuple(64, 128, &aom_highbd_sad64x128x4d_avx2, 8),
1450 make_tuple(64, 128, &aom_highbd_sad64x128x4d_avx2, 10),
1451 make_tuple(64, 128, &aom_highbd_sad64x128x4d_avx2, 12),
Yi Luoe9832582016-11-29 19:38:12 -08001452 make_tuple(64, 64, &aom_highbd_sad64x64x4d_avx2, 8),
1453 make_tuple(64, 64, &aom_highbd_sad64x64x4d_avx2, 10),
1454 make_tuple(64, 64, &aom_highbd_sad64x64x4d_avx2, 12),
1455 make_tuple(64, 32, &aom_highbd_sad64x32x4d_avx2, 8),
1456 make_tuple(64, 32, &aom_highbd_sad64x32x4d_avx2, 10),
1457 make_tuple(64, 32, &aom_highbd_sad64x32x4d_avx2, 12),
1458 make_tuple(32, 64, &aom_highbd_sad32x64x4d_avx2, 8),
1459 make_tuple(32, 64, &aom_highbd_sad32x64x4d_avx2, 10),
1460 make_tuple(32, 64, &aom_highbd_sad32x64x4d_avx2, 12),
1461 make_tuple(32, 32, &aom_highbd_sad32x32x4d_avx2, 8),
1462 make_tuple(32, 32, &aom_highbd_sad32x32x4d_avx2, 10),
1463 make_tuple(32, 32, &aom_highbd_sad32x32x4d_avx2, 12),
1464 make_tuple(32, 16, &aom_highbd_sad32x16x4d_avx2, 8),
1465 make_tuple(32, 16, &aom_highbd_sad32x16x4d_avx2, 10),
1466 make_tuple(32, 16, &aom_highbd_sad32x16x4d_avx2, 12),
1467 make_tuple(16, 32, &aom_highbd_sad16x32x4d_avx2, 8),
1468 make_tuple(16, 32, &aom_highbd_sad16x32x4d_avx2, 10),
1469 make_tuple(16, 32, &aom_highbd_sad16x32x4d_avx2, 12),
1470 make_tuple(16, 16, &aom_highbd_sad16x16x4d_avx2, 8),
1471 make_tuple(16, 16, &aom_highbd_sad16x16x4d_avx2, 10),
1472 make_tuple(16, 16, &aom_highbd_sad16x16x4d_avx2, 12),
1473 make_tuple(16, 8, &aom_highbd_sad16x8x4d_avx2, 8),
1474 make_tuple(16, 8, &aom_highbd_sad16x8x4d_avx2, 10),
1475 make_tuple(16, 8, &aom_highbd_sad16x8x4d_avx2, 12),
Johannd5d92892015-04-17 16:11:38 -04001476};
1477INSTANTIATE_TEST_CASE_P(AVX2, SADx4Test, ::testing::ValuesIn(x4d_avx2_tests));
1478#endif // HAVE_AVX2
Frank Galligan54fa9562015-01-24 12:11:16 -08001479
Parag Salasakarbc3ec8e2015-07-01 11:19:42 +05301480//------------------------------------------------------------------------------
1481// MIPS functions
1482#if HAVE_MSA
Parag Salasakarbc3ec8e2015-07-01 11:19:42 +05301483const SadMxNParam msa_tests[] = {
Yaowu Xuf883b422016-08-30 14:01:10 -07001484 make_tuple(64, 64, &aom_sad64x64_msa, -1),
1485 make_tuple(64, 32, &aom_sad64x32_msa, -1),
1486 make_tuple(32, 64, &aom_sad32x64_msa, -1),
1487 make_tuple(32, 32, &aom_sad32x32_msa, -1),
1488 make_tuple(32, 16, &aom_sad32x16_msa, -1),
1489 make_tuple(16, 32, &aom_sad16x32_msa, -1),
1490 make_tuple(16, 16, &aom_sad16x16_msa, -1),
1491 make_tuple(16, 8, &aom_sad16x8_msa, -1),
1492 make_tuple(8, 16, &aom_sad8x16_msa, -1),
1493 make_tuple(8, 8, &aom_sad8x8_msa, -1),
1494 make_tuple(8, 4, &aom_sad8x4_msa, -1),
1495 make_tuple(4, 8, &aom_sad4x8_msa, -1),
1496 make_tuple(4, 4, &aom_sad4x4_msa, -1),
Parag Salasakarbc3ec8e2015-07-01 11:19:42 +05301497};
1498INSTANTIATE_TEST_CASE_P(MSA, SADTest, ::testing::ValuesIn(msa_tests));
1499
Parag Salasakarbc3ec8e2015-07-01 11:19:42 +05301500const SadMxNAvgParam avg_msa_tests[] = {
Yaowu Xuf883b422016-08-30 14:01:10 -07001501 make_tuple(64, 64, &aom_sad64x64_avg_msa, -1),
1502 make_tuple(64, 32, &aom_sad64x32_avg_msa, -1),
1503 make_tuple(32, 64, &aom_sad32x64_avg_msa, -1),
1504 make_tuple(32, 32, &aom_sad32x32_avg_msa, -1),
1505 make_tuple(32, 16, &aom_sad32x16_avg_msa, -1),
1506 make_tuple(16, 32, &aom_sad16x32_avg_msa, -1),
1507 make_tuple(16, 16, &aom_sad16x16_avg_msa, -1),
1508 make_tuple(16, 8, &aom_sad16x8_avg_msa, -1),
1509 make_tuple(8, 16, &aom_sad8x16_avg_msa, -1),
1510 make_tuple(8, 8, &aom_sad8x8_avg_msa, -1),
1511 make_tuple(8, 4, &aom_sad8x4_avg_msa, -1),
1512 make_tuple(4, 8, &aom_sad4x8_avg_msa, -1),
1513 make_tuple(4, 4, &aom_sad4x4_avg_msa, -1),
Parag Salasakarbc3ec8e2015-07-01 11:19:42 +05301514};
1515INSTANTIATE_TEST_CASE_P(MSA, SADavgTest, ::testing::ValuesIn(avg_msa_tests));
1516
Parag Salasakarbc3ec8e2015-07-01 11:19:42 +05301517const SadMxNx4Param x4d_msa_tests[] = {
Yaowu Xuf883b422016-08-30 14:01:10 -07001518 make_tuple(64, 64, &aom_sad64x64x4d_msa, -1),
1519 make_tuple(64, 32, &aom_sad64x32x4d_msa, -1),
1520 make_tuple(32, 64, &aom_sad32x64x4d_msa, -1),
1521 make_tuple(32, 32, &aom_sad32x32x4d_msa, -1),
1522 make_tuple(32, 16, &aom_sad32x16x4d_msa, -1),
1523 make_tuple(16, 32, &aom_sad16x32x4d_msa, -1),
1524 make_tuple(16, 16, &aom_sad16x16x4d_msa, -1),
1525 make_tuple(16, 8, &aom_sad16x8x4d_msa, -1),
1526 make_tuple(8, 16, &aom_sad8x16x4d_msa, -1),
1527 make_tuple(8, 8, &aom_sad8x8x4d_msa, -1),
1528 make_tuple(8, 4, &aom_sad8x4x4d_msa, -1),
1529 make_tuple(4, 8, &aom_sad4x8x4d_msa, -1),
1530 make_tuple(4, 4, &aom_sad4x4x4d_msa, -1),
Parag Salasakarbc3ec8e2015-07-01 11:19:42 +05301531};
1532INSTANTIATE_TEST_CASE_P(MSA, SADx4Test, ::testing::ValuesIn(x4d_msa_tests));
1533#endif // HAVE_MSA
1534
Johannfbea8972012-06-28 11:43:58 -07001535} // namespace