blob: bbfb7f1a2a5f6e131887340ec88823dc6af6f733 [file] [log] [blame]
Daniel Kang26641c72012-06-28 16:26:31 -07001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Daniel Kang26641c72012-06-28 16:26:31 -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.
10*/
Daniel Kang26641c72012-06-28 16:26:31 -070011
12#include <math.h>
13#include <stdlib.h>
14#include <string.h>
15
16#include "third_party/googletest/src/include/gtest/gtest.h"
Jingning Han097d59c2015-07-29 14:51:36 -070017
Yaowu Xuf883b422016-08-30 14:01:10 -070018#include "./av1_rtcd.h"
19#include "./aom_dsp_rtcd.h"
Jingning Han4bd17112013-09-16 16:01:50 -070020#include "test/acm_random.h"
Yaowu Xue494df12013-09-03 13:50:17 -070021#include "test/clear_system_state.h"
22#include "test/register_state_check.h"
Jingning Han4bd17112013-09-16 16:01:50 -070023#include "test/util.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070024#include "av1/common/entropy.h"
25#include "av1/common/scan.h"
Yaowu Xuf883b422016-08-30 14:01:10 -070026#include "aom/aom_codec.h"
27#include "aom/aom_integer.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070028#include "aom_ports/mem.h"
James Zern002ad402014-01-18 13:03:31 -080029
Yaowu Xuc27fc142016-08-22 16:08:15 -070030using libaom_test::ACMRandom;
James Zernc47d8682015-05-14 19:38:34 -070031
32namespace {
33
Deb Mukherjee10783d42014-09-02 16:34:09 -070034const int kNumCoeffs = 64;
35const double kPi = 3.141592653589793238462643383279502884;
James Zernc47d8682015-05-14 19:38:34 -070036
37const int kSignBiasMaxDiff255 = 1500;
38const int kSignBiasMaxDiff15 = 10000;
39
40typedef void (*FdctFunc)(const int16_t *in, tran_low_t *out, int stride);
41typedef void (*IdctFunc)(const tran_low_t *in, uint8_t *out, int stride);
42typedef void (*FhtFunc)(const int16_t *in, tran_low_t *out, int stride,
43 int tx_type);
44typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
45 int tx_type);
46
Yaowu Xuf883b422016-08-30 14:01:10 -070047typedef std::tr1::tuple<FdctFunc, IdctFunc, int, aom_bit_depth_t> Dct8x8Param;
48typedef std::tr1::tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t> Ht8x8Param;
49typedef std::tr1::tuple<IdctFunc, IdctFunc, int, aom_bit_depth_t> Idct8x8Param;
James Zernc47d8682015-05-14 19:38:34 -070050
James Zerncffef112016-02-11 18:27:00 -080051void reference_8x8_dct_1d(const double in[8], double out[8]) {
Deb Mukherjee10783d42014-09-02 16:34:09 -070052 const double kInvSqrt2 = 0.707106781186547524400844362104;
53 for (int k = 0; k < 8; k++) {
54 out[k] = 0.0;
55 for (int n = 0; n < 8; n++)
56 out[k] += in[n] * cos(kPi * (2 * n + 1) * k / 16.0);
clang-format3a826f12016-08-11 17:46:05 -070057 if (k == 0) out[k] = out[k] * kInvSqrt2;
Deb Mukherjee10783d42014-09-02 16:34:09 -070058 }
59}
60
61void reference_8x8_dct_2d(const int16_t input[kNumCoeffs],
62 double output[kNumCoeffs]) {
63 // First transform columns
64 for (int i = 0; i < 8; ++i) {
65 double temp_in[8], temp_out[8];
clang-format3a826f12016-08-11 17:46:05 -070066 for (int j = 0; j < 8; ++j) temp_in[j] = input[j * 8 + i];
James Zerncffef112016-02-11 18:27:00 -080067 reference_8x8_dct_1d(temp_in, temp_out);
clang-format3a826f12016-08-11 17:46:05 -070068 for (int j = 0; j < 8; ++j) output[j * 8 + i] = temp_out[j];
Deb Mukherjee10783d42014-09-02 16:34:09 -070069 }
70 // Then transform rows
71 for (int i = 0; i < 8; ++i) {
72 double temp_in[8], temp_out[8];
clang-format3a826f12016-08-11 17:46:05 -070073 for (int j = 0; j < 8; ++j) temp_in[j] = output[j + i * 8];
James Zerncffef112016-02-11 18:27:00 -080074 reference_8x8_dct_1d(temp_in, temp_out);
Deb Mukherjee10783d42014-09-02 16:34:09 -070075 // Scale by some magic number
clang-format3a826f12016-08-11 17:46:05 -070076 for (int j = 0; j < 8; ++j) output[j + i * 8] = temp_out[j] * 2;
Deb Mukherjee10783d42014-09-02 16:34:09 -070077 }
Daniel Kang26641c72012-06-28 16:26:31 -070078}
Daniel Kang26641c72012-06-28 16:26:31 -070079
James Zerncffef112016-02-11 18:27:00 -080080void fdct8x8_ref(const int16_t *in, tran_low_t *out, int stride,
81 int /*tx_type*/) {
Yaowu Xuf883b422016-08-30 14:01:10 -070082 aom_fdct8x8_c(in, out, stride);
Jingning Hanab362622013-06-21 11:45:47 -070083}
Jingning Han4bd17112013-09-16 16:01:50 -070084
Deb Mukherjee10783d42014-09-02 16:34:09 -070085void fht8x8_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
Yaowu Xuf883b422016-08-30 14:01:10 -070086 av1_fht8x8_c(in, out, stride, tx_type);
Jingning Hanab362622013-06-21 11:45:47 -070087}
Daniel Kang26641c72012-06-28 16:26:31 -070088
Yaowu Xuf883b422016-08-30 14:01:10 -070089#if CONFIG_AOM_HIGHBITDEPTH
Deb Mukherjee10783d42014-09-02 16:34:09 -070090void idct8x8_10(const tran_low_t *in, uint8_t *out, int stride) {
Yaowu Xuf883b422016-08-30 14:01:10 -070091 aom_highbd_idct8x8_64_add_c(in, out, stride, 10);
Deb Mukherjee10783d42014-09-02 16:34:09 -070092}
93
94void idct8x8_12(const tran_low_t *in, uint8_t *out, int stride) {
Yaowu Xuf883b422016-08-30 14:01:10 -070095 aom_highbd_idct8x8_64_add_c(in, out, stride, 12);
Deb Mukherjee10783d42014-09-02 16:34:09 -070096}
97
98void iht8x8_10(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
Yaowu Xuf883b422016-08-30 14:01:10 -070099 av1_highbd_iht8x8_64_add_c(in, out, stride, tx_type, 10);
Deb Mukherjee10783d42014-09-02 16:34:09 -0700100}
101
102void iht8x8_12(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700103 av1_highbd_iht8x8_64_add_c(in, out, stride, tx_type, 12);
Deb Mukherjee10783d42014-09-02 16:34:09 -0700104}
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100105
James Zernf74e04c2016-02-03 23:04:42 -0800106#if HAVE_SSE2
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100107void idct8x8_10_add_10_c(const tran_low_t *in, uint8_t *out, int stride) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700108 aom_highbd_idct8x8_10_add_c(in, out, stride, 10);
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100109}
110
111void idct8x8_10_add_12_c(const tran_low_t *in, uint8_t *out, int stride) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700112 aom_highbd_idct8x8_10_add_c(in, out, stride, 12);
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100113}
114
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100115void idct8x8_10_add_10_sse2(const tran_low_t *in, uint8_t *out, int stride) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700116 aom_highbd_idct8x8_10_add_sse2(in, out, stride, 10);
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100117}
118
119void idct8x8_10_add_12_sse2(const tran_low_t *in, uint8_t *out, int stride) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700120 aom_highbd_idct8x8_10_add_sse2(in, out, stride, 12);
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100121}
122
123void idct8x8_64_add_10_sse2(const tran_low_t *in, uint8_t *out, int stride) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700124 aom_highbd_idct8x8_64_add_sse2(in, out, stride, 10);
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100125}
126
127void idct8x8_64_add_12_sse2(const tran_low_t *in, uint8_t *out, int stride) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700128 aom_highbd_idct8x8_64_add_sse2(in, out, stride, 12);
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100129}
130#endif // HAVE_SSE2
Yaowu Xuf883b422016-08-30 14:01:10 -0700131#endif // CONFIG_AOM_HIGHBITDEPTH
Deb Mukherjee10783d42014-09-02 16:34:09 -0700132
Jingning Han4bd17112013-09-16 16:01:50 -0700133class FwdTrans8x8TestBase {
Jingning Hanab362622013-06-21 11:45:47 -0700134 public:
Jingning Han4bd17112013-09-16 16:01:50 -0700135 virtual ~FwdTrans8x8TestBase() {}
Jingning Hanab362622013-06-21 11:45:47 -0700136
137 protected:
Deb Mukherjee10783d42014-09-02 16:34:09 -0700138 virtual void RunFwdTxfm(int16_t *in, tran_low_t *out, int stride) = 0;
139 virtual void RunInvTxfm(tran_low_t *out, uint8_t *dst, int stride) = 0;
Jingning Hanab362622013-06-21 11:45:47 -0700140
Jingning Han4bd17112013-09-16 16:01:50 -0700141 void RunSignBiasCheck() {
142 ACMRandom rnd(ACMRandom::DeterministicSeed());
James Zernfd3658b2015-05-02 13:24:16 -0700143 DECLARE_ALIGNED(16, int16_t, test_input_block[64]);
144 DECLARE_ALIGNED(16, tran_low_t, test_output_block[64]);
Jingning Han4bd17112013-09-16 16:01:50 -0700145 int count_sign_block[64][2];
146 const int count_test_block = 100000;
Jingning Hanab362622013-06-21 11:45:47 -0700147
Jingning Han4bd17112013-09-16 16:01:50 -0700148 memset(count_sign_block, 0, sizeof(count_sign_block));
Daniel Kang26641c72012-06-28 16:26:31 -0700149
Jingning Han4bd17112013-09-16 16:01:50 -0700150 for (int i = 0; i < count_test_block; ++i) {
151 // Initialize a test block with input range [-255, 255].
152 for (int j = 0; j < 64; ++j)
Deb Mukherjee10783d42014-09-02 16:34:09 -0700153 test_input_block[j] = ((rnd.Rand16() >> (16 - bit_depth_)) & mask_) -
154 ((rnd.Rand16() >> (16 - bit_depth_)) & mask_);
James Zern29e1b1a2014-07-09 21:02:02 -0700155 ASM_REGISTER_STATE_CHECK(
Jingning Han4bd17112013-09-16 16:01:50 -0700156 RunFwdTxfm(test_input_block, test_output_block, pitch_));
Daniel Kang26641c72012-06-28 16:26:31 -0700157
Jingning Han4bd17112013-09-16 16:01:50 -0700158 for (int j = 0; j < 64; ++j) {
159 if (test_output_block[j] < 0)
160 ++count_sign_block[j][0];
161 else if (test_output_block[j] > 0)
162 ++count_sign_block[j][1];
163 }
164 }
Daniel Kang26641c72012-06-28 16:26:31 -0700165
166 for (int j = 0; j < 64; ++j) {
Jingning Han4bd17112013-09-16 16:01:50 -0700167 const int diff = abs(count_sign_block[j][0] - count_sign_block[j][1]);
Deb Mukherjee1fe643c2014-12-04 16:46:06 -0800168 const int max_diff = kSignBiasMaxDiff255;
Deb Mukherjee10783d42014-09-02 16:34:09 -0700169 EXPECT_LT(diff, max_diff << (bit_depth_ - 8))
Jingning Han4bd17112013-09-16 16:01:50 -0700170 << "Error: 8x8 FDCT/FHT has a sign bias > "
171 << 1. * max_diff / count_test_block * 100 << "%"
172 << " for input range [-255, 255] at index " << j
173 << " count0: " << count_sign_block[j][0]
clang-format3a826f12016-08-11 17:46:05 -0700174 << " count1: " << count_sign_block[j][1] << " diff: " << diff;
Jingning Han4bd17112013-09-16 16:01:50 -0700175 }
176
177 memset(count_sign_block, 0, sizeof(count_sign_block));
178
179 for (int i = 0; i < count_test_block; ++i) {
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100180 // Initialize a test block with input range [-mask_ / 16, mask_ / 16].
Jingning Han4bd17112013-09-16 16:01:50 -0700181 for (int j = 0; j < 64; ++j)
clang-format3a826f12016-08-11 17:46:05 -0700182 test_input_block[j] =
183 ((rnd.Rand16() & mask_) >> 4) - ((rnd.Rand16() & mask_) >> 4);
James Zern29e1b1a2014-07-09 21:02:02 -0700184 ASM_REGISTER_STATE_CHECK(
Jingning Han4bd17112013-09-16 16:01:50 -0700185 RunFwdTxfm(test_input_block, test_output_block, pitch_));
186
187 for (int j = 0; j < 64; ++j) {
188 if (test_output_block[j] < 0)
189 ++count_sign_block[j][0];
190 else if (test_output_block[j] > 0)
191 ++count_sign_block[j][1];
192 }
193 }
194
195 for (int j = 0; j < 64; ++j) {
196 const int diff = abs(count_sign_block[j][0] - count_sign_block[j][1]);
Deb Mukherjee1fe643c2014-12-04 16:46:06 -0800197 const int max_diff = kSignBiasMaxDiff15;
Deb Mukherjee10783d42014-09-02 16:34:09 -0700198 EXPECT_LT(diff, max_diff << (bit_depth_ - 8))
Deb Mukherjee1fe643c2014-12-04 16:46:06 -0800199 << "Error: 8x8 FDCT/FHT has a sign bias > "
Jingning Han4bd17112013-09-16 16:01:50 -0700200 << 1. * max_diff / count_test_block * 100 << "%"
201 << " for input range [-15, 15] at index " << j
202 << " count0: " << count_sign_block[j][0]
clang-format3a826f12016-08-11 17:46:05 -0700203 << " count1: " << count_sign_block[j][1] << " diff: " << diff;
Daniel Kang26641c72012-06-28 16:26:31 -0700204 }
205 }
206
Jingning Han4bd17112013-09-16 16:01:50 -0700207 void RunRoundTripErrorCheck() {
208 ACMRandom rnd(ACMRandom::DeterministicSeed());
209 int max_error = 0;
210 int total_error = 0;
211 const int count_test_block = 100000;
James Zernfd3658b2015-05-02 13:24:16 -0700212 DECLARE_ALIGNED(16, int16_t, test_input_block[64]);
213 DECLARE_ALIGNED(16, tran_low_t, test_temp_block[64]);
214 DECLARE_ALIGNED(16, uint8_t, dst[64]);
215 DECLARE_ALIGNED(16, uint8_t, src[64]);
Yaowu Xuf883b422016-08-30 14:01:10 -0700216#if CONFIG_AOM_HIGHBITDEPTH
James Zernfd3658b2015-05-02 13:24:16 -0700217 DECLARE_ALIGNED(16, uint16_t, dst16[64]);
218 DECLARE_ALIGNED(16, uint16_t, src16[64]);
Deb Mukherjee10783d42014-09-02 16:34:09 -0700219#endif
Daniel Kang26641c72012-06-28 16:26:31 -0700220
Jingning Han4bd17112013-09-16 16:01:50 -0700221 for (int i = 0; i < count_test_block; ++i) {
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100222 // Initialize a test block with input range [-mask_, mask_].
Jingning Han4bd17112013-09-16 16:01:50 -0700223 for (int j = 0; j < 64; ++j) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700224 if (bit_depth_ == AOM_BITS_8) {
Deb Mukherjee10783d42014-09-02 16:34:09 -0700225 src[j] = rnd.Rand8();
226 dst[j] = rnd.Rand8();
227 test_input_block[j] = src[j] - dst[j];
Yaowu Xuf883b422016-08-30 14:01:10 -0700228#if CONFIG_AOM_HIGHBITDEPTH
Deb Mukherjee10783d42014-09-02 16:34:09 -0700229 } else {
230 src16[j] = rnd.Rand16() & mask_;
231 dst16[j] = rnd.Rand16() & mask_;
232 test_input_block[j] = src16[j] - dst16[j];
233#endif
234 }
Jingning Han4bd17112013-09-16 16:01:50 -0700235 }
Daniel Kang26641c72012-06-28 16:26:31 -0700236
James Zern29e1b1a2014-07-09 21:02:02 -0700237 ASM_REGISTER_STATE_CHECK(
Jingning Han4bd17112013-09-16 16:01:50 -0700238 RunFwdTxfm(test_input_block, test_temp_block, pitch_));
239 for (int j = 0; j < 64; ++j) {
clang-format3a826f12016-08-11 17:46:05 -0700240 if (test_temp_block[j] > 0) {
241 test_temp_block[j] += 2;
242 test_temp_block[j] /= 4;
243 test_temp_block[j] *= 4;
244 } else {
245 test_temp_block[j] -= 2;
246 test_temp_block[j] /= 4;
247 test_temp_block[j] *= 4;
248 }
Jingning Han4bd17112013-09-16 16:01:50 -0700249 }
Yaowu Xuf883b422016-08-30 14:01:10 -0700250 if (bit_depth_ == AOM_BITS_8) {
clang-format3a826f12016-08-11 17:46:05 -0700251 ASM_REGISTER_STATE_CHECK(RunInvTxfm(test_temp_block, dst, pitch_));
Yaowu Xuf883b422016-08-30 14:01:10 -0700252#if CONFIG_AOM_HIGHBITDEPTH
Deb Mukherjee10783d42014-09-02 16:34:09 -0700253 } else {
254 ASM_REGISTER_STATE_CHECK(
255 RunInvTxfm(test_temp_block, CONVERT_TO_BYTEPTR(dst16), pitch_));
256#endif
257 }
Daniel Kang26641c72012-06-28 16:26:31 -0700258
Jingning Han4bd17112013-09-16 16:01:50 -0700259 for (int j = 0; j < 64; ++j) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700260#if CONFIG_AOM_HIGHBITDEPTH
Deb Mukherjee10783d42014-09-02 16:34:09 -0700261 const int diff =
Yaowu Xuf883b422016-08-30 14:01:10 -0700262 bit_depth_ == AOM_BITS_8 ? dst[j] - src[j] : dst16[j] - src16[j];
Deb Mukherjee10783d42014-09-02 16:34:09 -0700263#else
Jingning Han4bd17112013-09-16 16:01:50 -0700264 const int diff = dst[j] - src[j];
Deb Mukherjee10783d42014-09-02 16:34:09 -0700265#endif
Jingning Han4bd17112013-09-16 16:01:50 -0700266 const int error = diff * diff;
clang-format3a826f12016-08-11 17:46:05 -0700267 if (max_error < error) max_error = error;
Jingning Han4bd17112013-09-16 16:01:50 -0700268 total_error += error;
269 }
Daniel Kang26641c72012-06-28 16:26:31 -0700270 }
271
Deb Mukherjee10783d42014-09-02 16:34:09 -0700272 EXPECT_GE(1 << 2 * (bit_depth_ - 8), max_error)
clang-format3a826f12016-08-11 17:46:05 -0700273 << "Error: 8x8 FDCT/IDCT or FHT/IHT has an individual"
274 << " roundtrip error > 1";
Daniel Kang26641c72012-06-28 16:26:31 -0700275
clang-format3a826f12016-08-11 17:46:05 -0700276 EXPECT_GE((count_test_block << 2 * (bit_depth_ - 8)) / 5, total_error)
277 << "Error: 8x8 FDCT/IDCT or FHT/IHT has average roundtrip "
278 << "error > 1/5 per block";
Daniel Kang26641c72012-06-28 16:26:31 -0700279 }
Jingning Han4bd17112013-09-16 16:01:50 -0700280
281 void RunExtremalCheck() {
282 ACMRandom rnd(ACMRandom::DeterministicSeed());
283 int max_error = 0;
284 int total_error = 0;
Jingning Han5c2696c2014-06-02 16:40:01 -0700285 int total_coeff_error = 0;
Jingning Han4bd17112013-09-16 16:01:50 -0700286 const int count_test_block = 100000;
James Zernfd3658b2015-05-02 13:24:16 -0700287 DECLARE_ALIGNED(16, int16_t, test_input_block[64]);
288 DECLARE_ALIGNED(16, tran_low_t, test_temp_block[64]);
289 DECLARE_ALIGNED(16, tran_low_t, ref_temp_block[64]);
290 DECLARE_ALIGNED(16, uint8_t, dst[64]);
291 DECLARE_ALIGNED(16, uint8_t, src[64]);
Yaowu Xuf883b422016-08-30 14:01:10 -0700292#if CONFIG_AOM_HIGHBITDEPTH
James Zernfd3658b2015-05-02 13:24:16 -0700293 DECLARE_ALIGNED(16, uint16_t, dst16[64]);
294 DECLARE_ALIGNED(16, uint16_t, src16[64]);
Deb Mukherjee10783d42014-09-02 16:34:09 -0700295#endif
Jingning Han4bd17112013-09-16 16:01:50 -0700296
297 for (int i = 0; i < count_test_block; ++i) {
Deb Mukherjee10783d42014-09-02 16:34:09 -0700298 // Initialize a test block with input range [-mask_, mask_].
Jingning Han4bd17112013-09-16 16:01:50 -0700299 for (int j = 0; j < 64; ++j) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700300 if (bit_depth_ == AOM_BITS_8) {
Deb Mukherjee10783d42014-09-02 16:34:09 -0700301 if (i == 0) {
302 src[j] = 255;
303 dst[j] = 0;
304 } else if (i == 1) {
305 src[j] = 0;
306 dst[j] = 255;
307 } else {
308 src[j] = rnd.Rand8() % 2 ? 255 : 0;
309 dst[j] = rnd.Rand8() % 2 ? 255 : 0;
310 }
311 test_input_block[j] = src[j] - dst[j];
Yaowu Xuf883b422016-08-30 14:01:10 -0700312#if CONFIG_AOM_HIGHBITDEPTH
Jingning Han0343e302014-06-03 16:45:22 -0700313 } else {
Deb Mukherjee10783d42014-09-02 16:34:09 -0700314 if (i == 0) {
315 src16[j] = mask_;
316 dst16[j] = 0;
317 } else if (i == 1) {
318 src16[j] = 0;
319 dst16[j] = mask_;
320 } else {
321 src16[j] = rnd.Rand8() % 2 ? mask_ : 0;
322 dst16[j] = rnd.Rand8() % 2 ? mask_ : 0;
323 }
324 test_input_block[j] = src16[j] - dst16[j];
325#endif
Jingning Han5c2696c2014-06-02 16:40:01 -0700326 }
Jingning Han4bd17112013-09-16 16:01:50 -0700327 }
328
James Zern29e1b1a2014-07-09 21:02:02 -0700329 ASM_REGISTER_STATE_CHECK(
Jingning Han4bd17112013-09-16 16:01:50 -0700330 RunFwdTxfm(test_input_block, test_temp_block, pitch_));
James Zern29e1b1a2014-07-09 21:02:02 -0700331 ASM_REGISTER_STATE_CHECK(
Jingning Han5c2696c2014-06-02 16:40:01 -0700332 fwd_txfm_ref(test_input_block, ref_temp_block, pitch_, tx_type_));
Yaowu Xuf883b422016-08-30 14:01:10 -0700333 if (bit_depth_ == AOM_BITS_8) {
clang-format3a826f12016-08-11 17:46:05 -0700334 ASM_REGISTER_STATE_CHECK(RunInvTxfm(test_temp_block, dst, pitch_));
Yaowu Xuf883b422016-08-30 14:01:10 -0700335#if CONFIG_AOM_HIGHBITDEPTH
Deb Mukherjee10783d42014-09-02 16:34:09 -0700336 } else {
337 ASM_REGISTER_STATE_CHECK(
338 RunInvTxfm(test_temp_block, CONVERT_TO_BYTEPTR(dst16), pitch_));
339#endif
340 }
Jingning Han4bd17112013-09-16 16:01:50 -0700341
342 for (int j = 0; j < 64; ++j) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700343#if CONFIG_AOM_HIGHBITDEPTH
Deb Mukherjee10783d42014-09-02 16:34:09 -0700344 const int diff =
Yaowu Xuf883b422016-08-30 14:01:10 -0700345 bit_depth_ == AOM_BITS_8 ? dst[j] - src[j] : dst16[j] - src16[j];
Deb Mukherjee10783d42014-09-02 16:34:09 -0700346#else
Jingning Han4bd17112013-09-16 16:01:50 -0700347 const int diff = dst[j] - src[j];
Deb Mukherjee10783d42014-09-02 16:34:09 -0700348#endif
Jingning Han4bd17112013-09-16 16:01:50 -0700349 const int error = diff * diff;
clang-format3a826f12016-08-11 17:46:05 -0700350 if (max_error < error) max_error = error;
Jingning Han4bd17112013-09-16 16:01:50 -0700351 total_error += error;
Jingning Han5c2696c2014-06-02 16:40:01 -0700352
353 const int coeff_diff = test_temp_block[j] - ref_temp_block[j];
354 total_coeff_error += abs(coeff_diff);
Jingning Han4bd17112013-09-16 16:01:50 -0700355 }
356
Deb Mukherjee10783d42014-09-02 16:34:09 -0700357 EXPECT_GE(1 << 2 * (bit_depth_ - 8), max_error)
Jingning Han4bd17112013-09-16 16:01:50 -0700358 << "Error: Extremal 8x8 FDCT/IDCT or FHT/IHT has"
359 << "an individual roundtrip error > 1";
360
clang-format3a826f12016-08-11 17:46:05 -0700361 EXPECT_GE((count_test_block << 2 * (bit_depth_ - 8)) / 5, total_error)
Jingning Han4bd17112013-09-16 16:01:50 -0700362 << "Error: Extremal 8x8 FDCT/IDCT or FHT/IHT has average"
363 << " roundtrip error > 1/5 per block";
Jingning Han5c2696c2014-06-02 16:40:01 -0700364
365 EXPECT_EQ(0, total_coeff_error)
366 << "Error: Extremal 8x8 FDCT/FHT has"
367 << "overflow issues in the intermediate steps > 1";
Jingning Han4bd17112013-09-16 16:01:50 -0700368 }
369 }
370
Deb Mukherjee10783d42014-09-02 16:34:09 -0700371 void RunInvAccuracyCheck() {
372 ACMRandom rnd(ACMRandom::DeterministicSeed());
373 const int count_test_block = 1000;
James Zernfd3658b2015-05-02 13:24:16 -0700374 DECLARE_ALIGNED(16, int16_t, in[kNumCoeffs]);
375 DECLARE_ALIGNED(16, tran_low_t, coeff[kNumCoeffs]);
376 DECLARE_ALIGNED(16, uint8_t, dst[kNumCoeffs]);
377 DECLARE_ALIGNED(16, uint8_t, src[kNumCoeffs]);
Yaowu Xuf883b422016-08-30 14:01:10 -0700378#if CONFIG_AOM_HIGHBITDEPTH
James Zernfd3658b2015-05-02 13:24:16 -0700379 DECLARE_ALIGNED(16, uint16_t, src16[kNumCoeffs]);
380 DECLARE_ALIGNED(16, uint16_t, dst16[kNumCoeffs]);
Deb Mukherjee10783d42014-09-02 16:34:09 -0700381#endif
382
383 for (int i = 0; i < count_test_block; ++i) {
384 double out_r[kNumCoeffs];
385
386 // Initialize a test block with input range [-255, 255].
387 for (int j = 0; j < kNumCoeffs; ++j) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700388 if (bit_depth_ == AOM_BITS_8) {
Deb Mukherjee10783d42014-09-02 16:34:09 -0700389 src[j] = rnd.Rand8() % 2 ? 255 : 0;
390 dst[j] = src[j] > 0 ? 0 : 255;
391 in[j] = src[j] - dst[j];
Yaowu Xuf883b422016-08-30 14:01:10 -0700392#if CONFIG_AOM_HIGHBITDEPTH
Deb Mukherjee10783d42014-09-02 16:34:09 -0700393 } else {
394 src16[j] = rnd.Rand8() % 2 ? mask_ : 0;
395 dst16[j] = src16[j] > 0 ? 0 : mask_;
396 in[j] = src16[j] - dst16[j];
397#endif
398 }
399 }
400
401 reference_8x8_dct_2d(in, out_r);
402 for (int j = 0; j < kNumCoeffs; ++j)
Deb Mukherjee41e6ec42014-09-13 04:11:50 -0700403 coeff[j] = static_cast<tran_low_t>(round(out_r[j]));
Deb Mukherjee10783d42014-09-02 16:34:09 -0700404
Yaowu Xuf883b422016-08-30 14:01:10 -0700405 if (bit_depth_ == AOM_BITS_8) {
Deb Mukherjee10783d42014-09-02 16:34:09 -0700406 ASM_REGISTER_STATE_CHECK(RunInvTxfm(coeff, dst, pitch_));
Yaowu Xuf883b422016-08-30 14:01:10 -0700407#if CONFIG_AOM_HIGHBITDEPTH
Deb Mukherjee10783d42014-09-02 16:34:09 -0700408 } else {
clang-format3a826f12016-08-11 17:46:05 -0700409 ASM_REGISTER_STATE_CHECK(
410 RunInvTxfm(coeff, CONVERT_TO_BYTEPTR(dst16), pitch_));
Deb Mukherjee10783d42014-09-02 16:34:09 -0700411#endif
412 }
413
414 for (int j = 0; j < kNumCoeffs; ++j) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700415#if CONFIG_AOM_HIGHBITDEPTH
James Zern95d2dc82016-06-08 17:33:34 -0700416 const int diff =
Yaowu Xuf883b422016-08-30 14:01:10 -0700417 bit_depth_ == AOM_BITS_8 ? dst[j] - src[j] : dst16[j] - src16[j];
Deb Mukherjee10783d42014-09-02 16:34:09 -0700418#else
James Zern95d2dc82016-06-08 17:33:34 -0700419 const int diff = dst[j] - src[j];
Deb Mukherjee10783d42014-09-02 16:34:09 -0700420#endif
421 const uint32_t error = diff * diff;
422 EXPECT_GE(1u << 2 * (bit_depth_ - 8), error)
clang-format3a826f12016-08-11 17:46:05 -0700423 << "Error: 8x8 IDCT has error " << error << " at index " << j;
Deb Mukherjee10783d42014-09-02 16:34:09 -0700424 }
425 }
426 }
427
428 void RunFwdAccuracyCheck() {
429 ACMRandom rnd(ACMRandom::DeterministicSeed());
430 const int count_test_block = 1000;
James Zernfd3658b2015-05-02 13:24:16 -0700431 DECLARE_ALIGNED(16, int16_t, in[kNumCoeffs]);
432 DECLARE_ALIGNED(16, tran_low_t, coeff_r[kNumCoeffs]);
433 DECLARE_ALIGNED(16, tran_low_t, coeff[kNumCoeffs]);
Deb Mukherjee10783d42014-09-02 16:34:09 -0700434
435 for (int i = 0; i < count_test_block; ++i) {
436 double out_r[kNumCoeffs];
437
438 // Initialize a test block with input range [-mask_, mask_].
439 for (int j = 0; j < kNumCoeffs; ++j)
440 in[j] = rnd.Rand8() % 2 == 0 ? mask_ : -mask_;
441
442 RunFwdTxfm(in, coeff, pitch_);
443 reference_8x8_dct_2d(in, out_r);
444 for (int j = 0; j < kNumCoeffs; ++j)
Deb Mukherjee41e6ec42014-09-13 04:11:50 -0700445 coeff_r[j] = static_cast<tran_low_t>(round(out_r[j]));
Deb Mukherjee10783d42014-09-02 16:34:09 -0700446
447 for (int j = 0; j < kNumCoeffs; ++j) {
Yaowu Xu63827272016-05-31 16:54:58 -0700448 const int32_t diff = coeff[j] - coeff_r[j];
Deb Mukherjee10783d42014-09-02 16:34:09 -0700449 const uint32_t error = diff * diff;
450 EXPECT_GE(9u << 2 * (bit_depth_ - 8), error)
clang-format3a826f12016-08-11 17:46:05 -0700451 << "Error: 8x8 DCT has error " << error << " at index " << j;
Deb Mukherjee10783d42014-09-02 16:34:09 -0700452 }
453 }
454 }
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100455
clang-format3a826f12016-08-11 17:46:05 -0700456 void CompareInvReference(IdctFunc ref_txfm, int thresh) {
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100457 ACMRandom rnd(ACMRandom::DeterministicSeed());
458 const int count_test_block = 10000;
459 const int eob = 12;
James Zernfd3658b2015-05-02 13:24:16 -0700460 DECLARE_ALIGNED(16, tran_low_t, coeff[kNumCoeffs]);
461 DECLARE_ALIGNED(16, uint8_t, dst[kNumCoeffs]);
462 DECLARE_ALIGNED(16, uint8_t, ref[kNumCoeffs]);
Yaowu Xuf883b422016-08-30 14:01:10 -0700463#if CONFIG_AOM_HIGHBITDEPTH
James Zernfd3658b2015-05-02 13:24:16 -0700464 DECLARE_ALIGNED(16, uint16_t, dst16[kNumCoeffs]);
465 DECLARE_ALIGNED(16, uint16_t, ref16[kNumCoeffs]);
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100466#endif
Yaowu Xuf883b422016-08-30 14:01:10 -0700467 const int16_t *scan = av1_default_scan_orders[TX_8X8].scan;
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100468
469 for (int i = 0; i < count_test_block; ++i) {
470 for (int j = 0; j < kNumCoeffs; ++j) {
471 if (j < eob) {
472 // Random values less than the threshold, either positive or negative
clang-format3a826f12016-08-11 17:46:05 -0700473 coeff[scan[j]] = rnd(thresh) * (1 - 2 * (i % 2));
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100474 } else {
475 coeff[scan[j]] = 0;
476 }
Yaowu Xuf883b422016-08-30 14:01:10 -0700477 if (bit_depth_ == AOM_BITS_8) {
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100478 dst[j] = 0;
479 ref[j] = 0;
Yaowu Xuf883b422016-08-30 14:01:10 -0700480#if CONFIG_AOM_HIGHBITDEPTH
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100481 } else {
482 dst16[j] = 0;
483 ref16[j] = 0;
484#endif
485 }
486 }
Yaowu Xuf883b422016-08-30 14:01:10 -0700487 if (bit_depth_ == AOM_BITS_8) {
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100488 ref_txfm(coeff, ref, pitch_);
489 ASM_REGISTER_STATE_CHECK(RunInvTxfm(coeff, dst, pitch_));
Yaowu Xuf883b422016-08-30 14:01:10 -0700490#if CONFIG_AOM_HIGHBITDEPTH
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100491 } else {
492 ref_txfm(coeff, CONVERT_TO_BYTEPTR(ref16), pitch_);
clang-format3a826f12016-08-11 17:46:05 -0700493 ASM_REGISTER_STATE_CHECK(
494 RunInvTxfm(coeff, CONVERT_TO_BYTEPTR(dst16), pitch_));
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100495#endif
496 }
497
498 for (int j = 0; j < kNumCoeffs; ++j) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700499#if CONFIG_AOM_HIGHBITDEPTH
James Zern95d2dc82016-06-08 17:33:34 -0700500 const int diff =
Yaowu Xuf883b422016-08-30 14:01:10 -0700501 bit_depth_ == AOM_BITS_8 ? dst[j] - ref[j] : dst16[j] - ref16[j];
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100502#else
James Zern95d2dc82016-06-08 17:33:34 -0700503 const int diff = dst[j] - ref[j];
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100504#endif
505 const uint32_t error = diff * diff;
clang-format3a826f12016-08-11 17:46:05 -0700506 EXPECT_EQ(0u, error) << "Error: 8x8 IDCT has error " << error
507 << " at index " << j;
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100508 }
509 }
510 }
Jingning Han4bd17112013-09-16 16:01:50 -0700511 int pitch_;
512 int tx_type_;
James Zern54697d32014-07-16 18:56:22 -0700513 FhtFunc fwd_txfm_ref;
Yaowu Xuf883b422016-08-30 14:01:10 -0700514 aom_bit_depth_t bit_depth_;
Deb Mukherjee10783d42014-09-02 16:34:09 -0700515 int mask_;
Jingning Han4bd17112013-09-16 16:01:50 -0700516};
517
clang-format3a826f12016-08-11 17:46:05 -0700518class FwdTrans8x8DCT : public FwdTrans8x8TestBase,
519 public ::testing::TestWithParam<Dct8x8Param> {
Jingning Han4bd17112013-09-16 16:01:50 -0700520 public:
521 virtual ~FwdTrans8x8DCT() {}
522
523 virtual void SetUp() {
524 fwd_txfm_ = GET_PARAM(0);
525 inv_txfm_ = GET_PARAM(1);
clang-format3a826f12016-08-11 17:46:05 -0700526 tx_type_ = GET_PARAM(2);
527 pitch_ = 8;
Jingning Han4bd17112013-09-16 16:01:50 -0700528 fwd_txfm_ref = fdct8x8_ref;
Deb Mukherjee10783d42014-09-02 16:34:09 -0700529 bit_depth_ = GET_PARAM(3);
530 mask_ = (1 << bit_depth_) - 1;
Jingning Han4bd17112013-09-16 16:01:50 -0700531 }
532
Yaowu Xuc27fc142016-08-22 16:08:15 -0700533 virtual void TearDown() { libaom_test::ClearSystemState(); }
Jingning Han4bd17112013-09-16 16:01:50 -0700534
535 protected:
Deb Mukherjee10783d42014-09-02 16:34:09 -0700536 void RunFwdTxfm(int16_t *in, tran_low_t *out, int stride) {
Jingning Han4bd17112013-09-16 16:01:50 -0700537 fwd_txfm_(in, out, stride);
538 }
Deb Mukherjee10783d42014-09-02 16:34:09 -0700539 void RunInvTxfm(tran_low_t *out, uint8_t *dst, int stride) {
Dmitry Kovaleve5fa44c2013-10-18 12:20:26 -0700540 inv_txfm_(out, dst, stride);
Jingning Han4bd17112013-09-16 16:01:50 -0700541 }
542
James Zern54697d32014-07-16 18:56:22 -0700543 FdctFunc fwd_txfm_;
544 IdctFunc inv_txfm_;
Jingning Han4bd17112013-09-16 16:01:50 -0700545};
546
clang-format3a826f12016-08-11 17:46:05 -0700547TEST_P(FwdTrans8x8DCT, SignBiasCheck) { RunSignBiasCheck(); }
Daniel Kang26641c72012-06-28 16:26:31 -0700548
clang-format3a826f12016-08-11 17:46:05 -0700549TEST_P(FwdTrans8x8DCT, RoundTripErrorCheck) { RunRoundTripErrorCheck(); }
Jingning Han4bd17112013-09-16 16:01:50 -0700550
clang-format3a826f12016-08-11 17:46:05 -0700551TEST_P(FwdTrans8x8DCT, ExtremalCheck) { RunExtremalCheck(); }
Jingning Han4bd17112013-09-16 16:01:50 -0700552
clang-format3a826f12016-08-11 17:46:05 -0700553TEST_P(FwdTrans8x8DCT, FwdAccuracyCheck) { RunFwdAccuracyCheck(); }
Deb Mukherjee10783d42014-09-02 16:34:09 -0700554
clang-format3a826f12016-08-11 17:46:05 -0700555TEST_P(FwdTrans8x8DCT, InvAccuracyCheck) { RunInvAccuracyCheck(); }
Deb Mukherjee10783d42014-09-02 16:34:09 -0700556
clang-format3a826f12016-08-11 17:46:05 -0700557class FwdTrans8x8HT : public FwdTrans8x8TestBase,
558 public ::testing::TestWithParam<Ht8x8Param> {
Jingning Han4bd17112013-09-16 16:01:50 -0700559 public:
560 virtual ~FwdTrans8x8HT() {}
561
562 virtual void SetUp() {
563 fwd_txfm_ = GET_PARAM(0);
564 inv_txfm_ = GET_PARAM(1);
clang-format3a826f12016-08-11 17:46:05 -0700565 tx_type_ = GET_PARAM(2);
566 pitch_ = 8;
Jingning Han4bd17112013-09-16 16:01:50 -0700567 fwd_txfm_ref = fht8x8_ref;
Deb Mukherjee10783d42014-09-02 16:34:09 -0700568 bit_depth_ = GET_PARAM(3);
569 mask_ = (1 << bit_depth_) - 1;
Jingning Han4bd17112013-09-16 16:01:50 -0700570 }
571
Yaowu Xuc27fc142016-08-22 16:08:15 -0700572 virtual void TearDown() { libaom_test::ClearSystemState(); }
Jingning Han4bd17112013-09-16 16:01:50 -0700573
574 protected:
Deb Mukherjee10783d42014-09-02 16:34:09 -0700575 void RunFwdTxfm(int16_t *in, tran_low_t *out, int stride) {
Jingning Han4bd17112013-09-16 16:01:50 -0700576 fwd_txfm_(in, out, stride, tx_type_);
577 }
Deb Mukherjee10783d42014-09-02 16:34:09 -0700578 void RunInvTxfm(tran_low_t *out, uint8_t *dst, int stride) {
Jingning Han4bd17112013-09-16 16:01:50 -0700579 inv_txfm_(out, dst, stride, tx_type_);
580 }
581
James Zern54697d32014-07-16 18:56:22 -0700582 FhtFunc fwd_txfm_;
583 IhtFunc inv_txfm_;
Jingning Han4bd17112013-09-16 16:01:50 -0700584};
585
clang-format3a826f12016-08-11 17:46:05 -0700586TEST_P(FwdTrans8x8HT, SignBiasCheck) { RunSignBiasCheck(); }
Jingning Han4bd17112013-09-16 16:01:50 -0700587
clang-format3a826f12016-08-11 17:46:05 -0700588TEST_P(FwdTrans8x8HT, RoundTripErrorCheck) { RunRoundTripErrorCheck(); }
Jingning Han4bd17112013-09-16 16:01:50 -0700589
clang-format3a826f12016-08-11 17:46:05 -0700590TEST_P(FwdTrans8x8HT, ExtremalCheck) { RunExtremalCheck(); }
Jingning Han4bd17112013-09-16 16:01:50 -0700591
clang-format3a826f12016-08-11 17:46:05 -0700592class InvTrans8x8DCT : public FwdTrans8x8TestBase,
593 public ::testing::TestWithParam<Idct8x8Param> {
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100594 public:
595 virtual ~InvTrans8x8DCT() {}
596
597 virtual void SetUp() {
598 ref_txfm_ = GET_PARAM(0);
599 inv_txfm_ = GET_PARAM(1);
600 thresh_ = GET_PARAM(2);
601 pitch_ = 8;
602 bit_depth_ = GET_PARAM(3);
603 mask_ = (1 << bit_depth_) - 1;
604 }
605
Yaowu Xuc27fc142016-08-22 16:08:15 -0700606 virtual void TearDown() { libaom_test::ClearSystemState(); }
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100607
608 protected:
609 void RunInvTxfm(tran_low_t *out, uint8_t *dst, int stride) {
610 inv_txfm_(out, dst, stride);
611 }
James Zerncffef112016-02-11 18:27:00 -0800612 void RunFwdTxfm(int16_t * /*out*/, tran_low_t * /*dst*/, int /*stride*/) {}
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100613
614 IdctFunc ref_txfm_;
615 IdctFunc inv_txfm_;
616 int thresh_;
617};
618
619TEST_P(InvTrans8x8DCT, CompareReference) {
620 CompareInvReference(ref_txfm_, thresh_);
621}
622
Jingning Han4bd17112013-09-16 16:01:50 -0700623using std::tr1::make_tuple;
624
Yaowu Xuf883b422016-08-30 14:01:10 -0700625#if CONFIG_AOM_HIGHBITDEPTH
Jingning Han4bd17112013-09-16 16:01:50 -0700626INSTANTIATE_TEST_CASE_P(
627 C, FwdTrans8x8DCT,
628 ::testing::Values(
Yaowu Xuf883b422016-08-30 14:01:10 -0700629 make_tuple(&aom_fdct8x8_c, &aom_idct8x8_64_add_c, 0, AOM_BITS_8),
630 make_tuple(&aom_highbd_fdct8x8_c, &idct8x8_10, 0, AOM_BITS_10),
631 make_tuple(&aom_highbd_fdct8x8_c, &idct8x8_12, 0, AOM_BITS_12)));
Deb Mukherjee10783d42014-09-02 16:34:09 -0700632#else
clang-format3a826f12016-08-11 17:46:05 -0700633INSTANTIATE_TEST_CASE_P(C, FwdTrans8x8DCT,
Yaowu Xuf883b422016-08-30 14:01:10 -0700634 ::testing::Values(make_tuple(&aom_fdct8x8_c,
635 &aom_idct8x8_64_add_c, 0,
636 AOM_BITS_8)));
637#endif // CONFIG_AOM_HIGHBITDEPTH
Deb Mukherjee10783d42014-09-02 16:34:09 -0700638
Yaowu Xuf883b422016-08-30 14:01:10 -0700639#if CONFIG_AOM_HIGHBITDEPTH
Jingning Han4bd17112013-09-16 16:01:50 -0700640INSTANTIATE_TEST_CASE_P(
641 C, FwdTrans8x8HT,
642 ::testing::Values(
Yaowu Xuf883b422016-08-30 14:01:10 -0700643 make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_c, 0, AOM_BITS_8),
644 make_tuple(&av1_highbd_fht8x8_c, &iht8x8_10, 0, AOM_BITS_10),
645 make_tuple(&av1_highbd_fht8x8_c, &iht8x8_10, 1, AOM_BITS_10),
646 make_tuple(&av1_highbd_fht8x8_c, &iht8x8_10, 2, AOM_BITS_10),
647 make_tuple(&av1_highbd_fht8x8_c, &iht8x8_10, 3, AOM_BITS_10),
648 make_tuple(&av1_highbd_fht8x8_c, &iht8x8_12, 0, AOM_BITS_12),
649 make_tuple(&av1_highbd_fht8x8_c, &iht8x8_12, 1, AOM_BITS_12),
650 make_tuple(&av1_highbd_fht8x8_c, &iht8x8_12, 2, AOM_BITS_12),
651 make_tuple(&av1_highbd_fht8x8_c, &iht8x8_12, 3, AOM_BITS_12),
652 make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_c, 1, AOM_BITS_8),
653 make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_c, 2, AOM_BITS_8),
654 make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_c, 3, AOM_BITS_8)));
Deb Mukherjee10783d42014-09-02 16:34:09 -0700655#else
James Zern615230b2014-12-01 15:10:00 -0800656INSTANTIATE_TEST_CASE_P(
Deb Mukherjee10783d42014-09-02 16:34:09 -0700657 C, FwdTrans8x8HT,
658 ::testing::Values(
Yaowu Xuf883b422016-08-30 14:01:10 -0700659 make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_c, 0, AOM_BITS_8),
660 make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_c, 1, AOM_BITS_8),
661 make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_c, 2, AOM_BITS_8),
662 make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_c, 3, AOM_BITS_8)));
663#endif // CONFIG_AOM_HIGHBITDEPTH
Jingning Han4bd17112013-09-16 16:01:50 -0700664
Yaowu Xuf883b422016-08-30 14:01:10 -0700665#if HAVE_NEON_ASM && !CONFIG_AOM_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
clang-format3a826f12016-08-11 17:46:05 -0700666INSTANTIATE_TEST_CASE_P(NEON, FwdTrans8x8DCT,
Yaowu Xuf883b422016-08-30 14:01:10 -0700667 ::testing::Values(make_tuple(&aom_fdct8x8_neon,
668 &aom_idct8x8_64_add_neon,
669 0, AOM_BITS_8)));
670#endif // HAVE_NEON_ASM && !CONFIG_AOM_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
James Yu4f856cd2014-01-29 01:31:07 +0800671
Yaowu Xuf883b422016-08-30 14:01:10 -0700672#if HAVE_NEON && !CONFIG_AOM_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
James Zernc3331102014-02-25 23:11:49 -0800673INSTANTIATE_TEST_CASE_P(
Deb Mukherjee1fe643c2014-12-04 16:46:06 -0800674 NEON, FwdTrans8x8HT,
James Zernc3331102014-02-25 23:11:49 -0800675 ::testing::Values(
Yaowu Xuf883b422016-08-30 14:01:10 -0700676 make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_neon, 0, AOM_BITS_8),
677 make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_neon, 1, AOM_BITS_8),
678 make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_neon, 2, AOM_BITS_8),
679 make_tuple(&av1_fht8x8_c, &av1_iht8x8_64_add_neon, 3, AOM_BITS_8)));
680#endif // HAVE_NEON && !CONFIG_AOM_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
James Zernc3331102014-02-25 23:11:49 -0800681
Yaowu Xuf883b422016-08-30 14:01:10 -0700682#if HAVE_SSE2 && !CONFIG_AOM_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
clang-format3a826f12016-08-11 17:46:05 -0700683INSTANTIATE_TEST_CASE_P(SSE2, FwdTrans8x8DCT,
Yaowu Xuf883b422016-08-30 14:01:10 -0700684 ::testing::Values(make_tuple(&aom_fdct8x8_sse2,
685 &aom_idct8x8_64_add_sse2,
686 0, AOM_BITS_8)));
Jingning Han4bd17112013-09-16 16:01:50 -0700687INSTANTIATE_TEST_CASE_P(
688 SSE2, FwdTrans8x8HT,
689 ::testing::Values(
Yaowu Xuf883b422016-08-30 14:01:10 -0700690 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 0, AOM_BITS_8),
691 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 1, AOM_BITS_8),
692 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 2, AOM_BITS_8),
693 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 3, AOM_BITS_8)));
694#endif // HAVE_SSE2 && !CONFIG_AOM_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100695
Yaowu Xuf883b422016-08-30 14:01:10 -0700696#if HAVE_SSE2 && CONFIG_AOM_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100697INSTANTIATE_TEST_CASE_P(
698 SSE2, FwdTrans8x8DCT,
Yaowu Xuf883b422016-08-30 14:01:10 -0700699 ::testing::Values(make_tuple(&aom_fdct8x8_sse2, &aom_idct8x8_64_add_c, 0,
700 AOM_BITS_8),
701 make_tuple(&aom_highbd_fdct8x8_c, &idct8x8_64_add_10_sse2,
702 12, AOM_BITS_10),
703 make_tuple(&aom_highbd_fdct8x8_sse2,
704 &idct8x8_64_add_10_sse2, 12, AOM_BITS_10),
705 make_tuple(&aom_highbd_fdct8x8_c, &idct8x8_64_add_12_sse2,
706 12, AOM_BITS_12),
707 make_tuple(&aom_highbd_fdct8x8_sse2,
708 &idct8x8_64_add_12_sse2, 12, AOM_BITS_12)));
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100709
James Zern615230b2014-12-01 15:10:00 -0800710INSTANTIATE_TEST_CASE_P(
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100711 SSE2, FwdTrans8x8HT,
712 ::testing::Values(
Yaowu Xuf883b422016-08-30 14:01:10 -0700713 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_c, 0, AOM_BITS_8),
714 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_c, 1, AOM_BITS_8),
715 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_c, 2, AOM_BITS_8),
716 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_c, 3, AOM_BITS_8)));
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100717
718// Optimizations take effect at a threshold of 6201, so we use a value close to
719// that to test both branches.
720INSTANTIATE_TEST_CASE_P(
721 SSE2, InvTrans8x8DCT,
722 ::testing::Values(
clang-format3a826f12016-08-11 17:46:05 -0700723 make_tuple(&idct8x8_10_add_10_c, &idct8x8_10_add_10_sse2, 6225,
Yaowu Xuf883b422016-08-30 14:01:10 -0700724 AOM_BITS_10),
725 make_tuple(&idct8x8_10, &idct8x8_64_add_10_sse2, 6225, AOM_BITS_10),
clang-format3a826f12016-08-11 17:46:05 -0700726 make_tuple(&idct8x8_10_add_12_c, &idct8x8_10_add_12_sse2, 6225,
Yaowu Xuf883b422016-08-30 14:01:10 -0700727 AOM_BITS_12),
728 make_tuple(&idct8x8_12, &idct8x8_64_add_12_sse2, 6225, AOM_BITS_12)));
729#endif // HAVE_SSE2 && CONFIG_AOM_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
Jingning Hanb466ad52014-05-08 09:56:38 -0700730
David Barker0602edf2016-10-26 10:43:12 +0100731#if HAVE_SSSE3 && ARCH_X86_64 && !CONFIG_EMULATE_HARDWARE
clang-format3a826f12016-08-11 17:46:05 -0700732INSTANTIATE_TEST_CASE_P(SSSE3, FwdTrans8x8DCT,
Yaowu Xuf883b422016-08-30 14:01:10 -0700733 ::testing::Values(make_tuple(&aom_fdct8x8_ssse3,
734 &aom_idct8x8_64_add_ssse3,
735 0, AOM_BITS_8)));
Jingning Hanb466ad52014-05-08 09:56:38 -0700736#endif
Parag Salasakar7c5f00f2015-05-08 12:23:27 +0530737
Yaowu Xuf883b422016-08-30 14:01:10 -0700738#if HAVE_MSA && !CONFIG_AOM_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
clang-format3a826f12016-08-11 17:46:05 -0700739INSTANTIATE_TEST_CASE_P(MSA, FwdTrans8x8DCT,
Yaowu Xuf883b422016-08-30 14:01:10 -0700740 ::testing::Values(make_tuple(&aom_fdct8x8_msa,
741 &aom_idct8x8_64_add_msa, 0,
742 AOM_BITS_8)));
James Zern1c25b7f2016-08-13 10:58:54 -0700743#if !CONFIG_EXT_TX
Parag Salasakar7c5f00f2015-05-08 12:23:27 +0530744INSTANTIATE_TEST_CASE_P(
745 MSA, FwdTrans8x8HT,
746 ::testing::Values(
Yaowu Xuf883b422016-08-30 14:01:10 -0700747 make_tuple(&av1_fht8x8_msa, &av1_iht8x8_64_add_msa, 0, AOM_BITS_8),
748 make_tuple(&av1_fht8x8_msa, &av1_iht8x8_64_add_msa, 1, AOM_BITS_8),
749 make_tuple(&av1_fht8x8_msa, &av1_iht8x8_64_add_msa, 2, AOM_BITS_8),
750 make_tuple(&av1_fht8x8_msa, &av1_iht8x8_64_add_msa, 3, AOM_BITS_8)));
James Zern1c25b7f2016-08-13 10:58:54 -0700751#endif // !CONFIG_EXT_TX
Yaowu Xuf883b422016-08-30 14:01:10 -0700752#endif // HAVE_MSA && !CONFIG_AOM_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
Daniel Kang26641c72012-06-28 16:26:31 -0700753} // namespace