blob: 0a30f7f384a4257b431a49ae516c608658fabceb [file] [log] [blame]
Ronald S. Bultjec456b352012-12-07 14:45:05 -08001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Ronald S. Bultjec456b352012-12-07 14:45:05 -08003 *
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*/
Ronald S. Bultjec456b352012-12-07 14:45:05 -080011
12#include <math.h>
13#include <stdlib.h>
14#include <string.h>
15
Tom Finegan7a07ece2017-02-07 17:14:05 -080016#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
Ronald S. Bultjec456b352012-12-07 14:45:05 -080017
Yaowu Xuf883b422016-08-30 14:01:10 -070018#include "./av1_rtcd.h"
19#include "./aom_config.h"
20#include "./aom_dsp_rtcd.h"
Jingning Han097d59c2015-07-29 14:51:36 -070021#include "test/acm_random.h"
22#include "test/clear_system_state.h"
23#include "test/register_state_check.h"
24#include "test/util.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070025#include "av1/common/entropy.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"
29#include "aom_ports/msvc.h" // for round()
Ronald S. Bultjec456b352012-12-07 14:45:05 -080030
Yaowu Xuc27fc142016-08-22 16:08:15 -070031using libaom_test::ACMRandom;
Ronald S. Bultjec456b352012-12-07 14:45:05 -080032
33namespace {
Ronald S. Bultjec456b352012-12-07 14:45:05 -080034
Jingning Han4ad52a82013-09-03 11:57:34 -070035const int kNumCoeffs = 1024;
36const double kPi = 3.141592653589793238462643383279502884;
James Zerneb2f0002014-08-22 12:29:37 -070037void reference_32x32_dct_1d(const double in[32], double out[32]) {
Ronald S. Bultjec456b352012-12-07 14:45:05 -080038 const double kInvSqrt2 = 0.707106781186547524400844362104;
39 for (int k = 0; k < 32; k++) {
40 out[k] = 0.0;
41 for (int n = 0; n < 32; n++)
42 out[k] += in[n] * cos(kPi * (2 * n + 1) * k / 64.0);
clang-format3a826f12016-08-11 17:46:05 -070043 if (k == 0) out[k] = out[k] * kInvSqrt2;
Ronald S. Bultjec456b352012-12-07 14:45:05 -080044 }
45}
46
Jingning Han4ad52a82013-09-03 11:57:34 -070047void reference_32x32_dct_2d(const int16_t input[kNumCoeffs],
48 double output[kNumCoeffs]) {
Ronald S. Bultjec456b352012-12-07 14:45:05 -080049 // First transform columns
50 for (int i = 0; i < 32; ++i) {
51 double temp_in[32], temp_out[32];
clang-format3a826f12016-08-11 17:46:05 -070052 for (int j = 0; j < 32; ++j) temp_in[j] = input[j * 32 + i];
James Zerneb2f0002014-08-22 12:29:37 -070053 reference_32x32_dct_1d(temp_in, temp_out);
clang-format3a826f12016-08-11 17:46:05 -070054 for (int j = 0; j < 32; ++j) output[j * 32 + i] = temp_out[j];
Ronald S. Bultjec456b352012-12-07 14:45:05 -080055 }
56 // Then transform rows
57 for (int i = 0; i < 32; ++i) {
58 double temp_in[32], temp_out[32];
clang-format3a826f12016-08-11 17:46:05 -070059 for (int j = 0; j < 32; ++j) temp_in[j] = output[j + i * 32];
James Zerneb2f0002014-08-22 12:29:37 -070060 reference_32x32_dct_1d(temp_in, temp_out);
Ronald S. Bultjec456b352012-12-07 14:45:05 -080061 // Scale by some magic number
clang-format3a826f12016-08-11 17:46:05 -070062 for (int j = 0; j < 32; ++j) output[j + i * 32] = temp_out[j] / 4;
Ronald S. Bultjec456b352012-12-07 14:45:05 -080063 }
64}
65
Deb Mukherjee10783d42014-09-02 16:34:09 -070066typedef void (*FwdTxfmFunc)(const int16_t *in, tran_low_t *out, int stride);
67typedef void (*InvTxfmFunc)(const tran_low_t *in, uint8_t *out, int stride);
Ronald S. Bultjec456b352012-12-07 14:45:05 -080068
Yaowu Xuf883b422016-08-30 14:01:10 -070069typedef std::tr1::tuple<FwdTxfmFunc, InvTxfmFunc, int, aom_bit_depth_t>
Deb Mukherjee10783d42014-09-02 16:34:09 -070070 Trans32x32Param;
71
James Zernfd38e702014-07-16 18:54:31 -070072class Trans32x32Test : public ::testing::TestWithParam<Trans32x32Param> {
Jingning Han4ad52a82013-09-03 11:57:34 -070073 public:
74 virtual ~Trans32x32Test() {}
75 virtual void SetUp() {
76 fwd_txfm_ = GET_PARAM(0);
77 inv_txfm_ = GET_PARAM(1);
clang-format3a826f12016-08-11 17:46:05 -070078 version_ = GET_PARAM(2); // 0: high precision forward transform
79 // 1: low precision version for rd loop
Deb Mukherjee10783d42014-09-02 16:34:09 -070080 bit_depth_ = GET_PARAM(3);
81 mask_ = (1 << bit_depth_) - 1;
Jingning Han4ad52a82013-09-03 11:57:34 -070082 }
83
Yaowu Xuc27fc142016-08-22 16:08:15 -070084 virtual void TearDown() { libaom_test::ClearSystemState(); }
Jingning Han4ad52a82013-09-03 11:57:34 -070085
86 protected:
87 int version_;
Yaowu Xuf883b422016-08-30 14:01:10 -070088 aom_bit_depth_t bit_depth_;
Deb Mukherjee10783d42014-09-02 16:34:09 -070089 int mask_;
James Zernfd38e702014-07-16 18:54:31 -070090 FwdTxfmFunc fwd_txfm_;
91 InvTxfmFunc inv_txfm_;
Jingning Han4ad52a82013-09-03 11:57:34 -070092};
93
94TEST_P(Trans32x32Test, AccuracyCheck) {
95 ACMRandom rnd(ACMRandom::DeterministicSeed());
96 uint32_t max_error = 0;
97 int64_t total_error = 0;
Peter de Rivaz7e40a552014-10-24 08:48:02 +010098 const int count_test_block = 10000;
James Zernfd3658b2015-05-02 13:24:16 -070099 DECLARE_ALIGNED(16, int16_t, test_input_block[kNumCoeffs]);
100 DECLARE_ALIGNED(16, tran_low_t, test_temp_block[kNumCoeffs]);
101 DECLARE_ALIGNED(16, uint8_t, dst[kNumCoeffs]);
102 DECLARE_ALIGNED(16, uint8_t, src[kNumCoeffs]);
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200103#if CONFIG_HIGHBITDEPTH
James Zernfd3658b2015-05-02 13:24:16 -0700104 DECLARE_ALIGNED(16, uint16_t, dst16[kNumCoeffs]);
105 DECLARE_ALIGNED(16, uint16_t, src16[kNumCoeffs]);
Deb Mukherjee10783d42014-09-02 16:34:09 -0700106#endif
Jingning Han4ad52a82013-09-03 11:57:34 -0700107
108 for (int i = 0; i < count_test_block; ++i) {
Deb Mukherjee10783d42014-09-02 16:34:09 -0700109 // Initialize a test block with input range [-mask_, mask_].
Jingning Han4ad52a82013-09-03 11:57:34 -0700110 for (int j = 0; j < kNumCoeffs; ++j) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700111 if (bit_depth_ == AOM_BITS_8) {
Deb Mukherjee10783d42014-09-02 16:34:09 -0700112 src[j] = rnd.Rand8();
113 dst[j] = rnd.Rand8();
114 test_input_block[j] = src[j] - dst[j];
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200115#if CONFIG_HIGHBITDEPTH
Deb Mukherjee10783d42014-09-02 16:34:09 -0700116 } else {
117 src16[j] = rnd.Rand16() & mask_;
118 dst16[j] = rnd.Rand16() & mask_;
119 test_input_block[j] = src16[j] - dst16[j];
120#endif
121 }
Scott LaVarnway2cf0d4b2013-05-14 11:58:13 -0400122 }
Jingning Han4ad52a82013-09-03 11:57:34 -0700123
James Zern29e1b1a2014-07-09 21:02:02 -0700124 ASM_REGISTER_STATE_CHECK(fwd_txfm_(test_input_block, test_temp_block, 32));
Yaowu Xuf883b422016-08-30 14:01:10 -0700125 if (bit_depth_ == AOM_BITS_8) {
Deb Mukherjee10783d42014-09-02 16:34:09 -0700126 ASM_REGISTER_STATE_CHECK(inv_txfm_(test_temp_block, dst, 32));
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200127#if CONFIG_HIGHBITDEPTH
Deb Mukherjee10783d42014-09-02 16:34:09 -0700128 } else {
clang-format3a826f12016-08-11 17:46:05 -0700129 ASM_REGISTER_STATE_CHECK(
130 inv_txfm_(test_temp_block, CONVERT_TO_BYTEPTR(dst16), 32));
Deb Mukherjee10783d42014-09-02 16:34:09 -0700131#endif
132 }
Jingning Han4ad52a82013-09-03 11:57:34 -0700133
134 for (int j = 0; j < kNumCoeffs; ++j) {
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200135#if CONFIG_HIGHBITDEPTH
Yaowu Xu63827272016-05-31 16:54:58 -0700136 const int32_t diff =
Yaowu Xuf883b422016-08-30 14:01:10 -0700137 bit_depth_ == AOM_BITS_8 ? dst[j] - src[j] : dst16[j] - src16[j];
Deb Mukherjee10783d42014-09-02 16:34:09 -0700138#else
Yaowu Xu63827272016-05-31 16:54:58 -0700139 const int32_t diff = dst[j] - src[j];
Deb Mukherjee10783d42014-09-02 16:34:09 -0700140#endif
Jingning Han4ad52a82013-09-03 11:57:34 -0700141 const uint32_t error = diff * diff;
clang-format3a826f12016-08-11 17:46:05 -0700142 if (max_error < error) max_error = error;
Jingning Han4ad52a82013-09-03 11:57:34 -0700143 total_error += error;
144 }
145 }
146
147 if (version_ == 1) {
148 max_error /= 2;
149 total_error /= 45;
150 }
151
Deb Mukherjee10783d42014-09-02 16:34:09 -0700152 EXPECT_GE(1u << 2 * (bit_depth_ - 8), max_error)
Jingning Han4ad52a82013-09-03 11:57:34 -0700153 << "Error: 32x32 FDCT/IDCT has an individual round-trip error > 1";
154
Deb Mukherjee10783d42014-09-02 16:34:09 -0700155 EXPECT_GE(count_test_block << 2 * (bit_depth_ - 8), total_error)
Jingning Han4ad52a82013-09-03 11:57:34 -0700156 << "Error: 32x32 FDCT/IDCT has average round-trip error > 1 per block";
157}
158
159TEST_P(Trans32x32Test, CoeffCheck) {
160 ACMRandom rnd(ACMRandom::DeterministicSeed());
161 const int count_test_block = 1000;
162
James Zernfd3658b2015-05-02 13:24:16 -0700163 DECLARE_ALIGNED(16, int16_t, input_block[kNumCoeffs]);
164 DECLARE_ALIGNED(16, tran_low_t, output_ref_block[kNumCoeffs]);
165 DECLARE_ALIGNED(16, tran_low_t, output_block[kNumCoeffs]);
Jingning Han4ad52a82013-09-03 11:57:34 -0700166
167 for (int i = 0; i < count_test_block; ++i) {
168 for (int j = 0; j < kNumCoeffs; ++j)
Deb Mukherjee10783d42014-09-02 16:34:09 -0700169 input_block[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_);
Jingning Han4ad52a82013-09-03 11:57:34 -0700170
Dmitry Kovaleve05412f2013-10-17 13:02:28 -0700171 const int stride = 32;
Yaowu Xuf883b422016-08-30 14:01:10 -0700172 aom_fdct32x32_c(input_block, output_ref_block, stride);
James Zern29e1b1a2014-07-09 21:02:02 -0700173 ASM_REGISTER_STATE_CHECK(fwd_txfm_(input_block, output_block, stride));
Jingning Han4ad52a82013-09-03 11:57:34 -0700174
175 if (version_ == 0) {
176 for (int j = 0; j < kNumCoeffs; ++j)
177 EXPECT_EQ(output_block[j], output_ref_block[j])
178 << "Error: 32x32 FDCT versions have mismatched coefficients";
179 } else {
180 for (int j = 0; j < kNumCoeffs; ++j)
181 EXPECT_GE(6, abs(output_block[j] - output_ref_block[j]))
182 << "Error: 32x32 FDCT rd has mismatched coefficients";
183 }
184 }
185}
186
187TEST_P(Trans32x32Test, MemCheck) {
188 ACMRandom rnd(ACMRandom::DeterministicSeed());
189 const int count_test_block = 2000;
190
James Zernfd3658b2015-05-02 13:24:16 -0700191 DECLARE_ALIGNED(16, int16_t, input_extreme_block[kNumCoeffs]);
192 DECLARE_ALIGNED(16, tran_low_t, output_ref_block[kNumCoeffs]);
193 DECLARE_ALIGNED(16, tran_low_t, output_block[kNumCoeffs]);
Jingning Han4ad52a82013-09-03 11:57:34 -0700194
195 for (int i = 0; i < count_test_block; ++i) {
Deb Mukherjee10783d42014-09-02 16:34:09 -0700196 // Initialize a test block with input range [-mask_, mask_].
Jingning Han4ad52a82013-09-03 11:57:34 -0700197 for (int j = 0; j < kNumCoeffs; ++j) {
Deb Mukherjee10783d42014-09-02 16:34:09 -0700198 input_extreme_block[j] = rnd.Rand8() & 1 ? mask_ : -mask_;
Jingning Han4ad52a82013-09-03 11:57:34 -0700199 }
Jingning Han5c2696c2014-06-02 16:40:01 -0700200 if (i == 0) {
clang-format3a826f12016-08-11 17:46:05 -0700201 for (int j = 0; j < kNumCoeffs; ++j) input_extreme_block[j] = mask_;
Jingning Han5c2696c2014-06-02 16:40:01 -0700202 } else if (i == 1) {
clang-format3a826f12016-08-11 17:46:05 -0700203 for (int j = 0; j < kNumCoeffs; ++j) input_extreme_block[j] = -mask_;
Jingning Han5c2696c2014-06-02 16:40:01 -0700204 }
Jingning Han4ad52a82013-09-03 11:57:34 -0700205
Dmitry Kovaleve05412f2013-10-17 13:02:28 -0700206 const int stride = 32;
Yaowu Xuf883b422016-08-30 14:01:10 -0700207 aom_fdct32x32_c(input_extreme_block, output_ref_block, stride);
James Zern29e1b1a2014-07-09 21:02:02 -0700208 ASM_REGISTER_STATE_CHECK(
209 fwd_txfm_(input_extreme_block, output_block, stride));
Jingning Han4ad52a82013-09-03 11:57:34 -0700210
211 // The minimum quant value is 4.
212 for (int j = 0; j < kNumCoeffs; ++j) {
213 if (version_ == 0) {
214 EXPECT_EQ(output_block[j], output_ref_block[j])
215 << "Error: 32x32 FDCT versions have mismatched coefficients";
216 } else {
217 EXPECT_GE(6, abs(output_block[j] - output_ref_block[j]))
218 << "Error: 32x32 FDCT rd has mismatched coefficients";
219 }
Deb Mukherjee10783d42014-09-02 16:34:09 -0700220 EXPECT_GE(4 * DCT_MAX_VALUE << (bit_depth_ - 8), abs(output_ref_block[j]))
Jingning Han4ad52a82013-09-03 11:57:34 -0700221 << "Error: 32x32 FDCT C has coefficient larger than 4*DCT_MAX_VALUE";
Deb Mukherjee10783d42014-09-02 16:34:09 -0700222 EXPECT_GE(4 * DCT_MAX_VALUE << (bit_depth_ - 8), abs(output_block[j]))
Jingning Han4ad52a82013-09-03 11:57:34 -0700223 << "Error: 32x32 FDCT has coefficient larger than "
224 << "4*DCT_MAX_VALUE";
225 }
226 }
227}
228
229TEST_P(Trans32x32Test, InverseAccuracy) {
230 ACMRandom rnd(ACMRandom::DeterministicSeed());
231 const int count_test_block = 1000;
James Zernfd3658b2015-05-02 13:24:16 -0700232 DECLARE_ALIGNED(16, int16_t, in[kNumCoeffs]);
233 DECLARE_ALIGNED(16, tran_low_t, coeff[kNumCoeffs]);
234 DECLARE_ALIGNED(16, uint8_t, dst[kNumCoeffs]);
235 DECLARE_ALIGNED(16, uint8_t, src[kNumCoeffs]);
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200236#if CONFIG_HIGHBITDEPTH
James Zernfd3658b2015-05-02 13:24:16 -0700237 DECLARE_ALIGNED(16, uint16_t, dst16[kNumCoeffs]);
238 DECLARE_ALIGNED(16, uint16_t, src16[kNumCoeffs]);
Deb Mukherjee10783d42014-09-02 16:34:09 -0700239#endif
Jingning Han4ad52a82013-09-03 11:57:34 -0700240
241 for (int i = 0; i < count_test_block; ++i) {
242 double out_r[kNumCoeffs];
243
244 // Initialize a test block with input range [-255, 255]
245 for (int j = 0; j < kNumCoeffs; ++j) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700246 if (bit_depth_ == AOM_BITS_8) {
Deb Mukherjee10783d42014-09-02 16:34:09 -0700247 src[j] = rnd.Rand8();
248 dst[j] = rnd.Rand8();
249 in[j] = src[j] - dst[j];
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200250#if CONFIG_HIGHBITDEPTH
Deb Mukherjee10783d42014-09-02 16:34:09 -0700251 } else {
252 src16[j] = rnd.Rand16() & mask_;
253 dst16[j] = rnd.Rand16() & mask_;
254 in[j] = src16[j] - dst16[j];
255#endif
256 }
Jingning Han4ad52a82013-09-03 11:57:34 -0700257 }
Ronald S. Bultjec456b352012-12-07 14:45:05 -0800258
259 reference_32x32_dct_2d(in, out_r);
Jingning Han4ad52a82013-09-03 11:57:34 -0700260 for (int j = 0; j < kNumCoeffs; ++j)
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100261 coeff[j] = static_cast<tran_low_t>(round(out_r[j]));
Yaowu Xuf883b422016-08-30 14:01:10 -0700262 if (bit_depth_ == AOM_BITS_8) {
Deb Mukherjee10783d42014-09-02 16:34:09 -0700263 ASM_REGISTER_STATE_CHECK(inv_txfm_(coeff, dst, 32));
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200264#if CONFIG_HIGHBITDEPTH
Deb Mukherjee10783d42014-09-02 16:34:09 -0700265 } else {
266 ASM_REGISTER_STATE_CHECK(inv_txfm_(coeff, CONVERT_TO_BYTEPTR(dst16), 32));
267#endif
268 }
Jingning Han4ad52a82013-09-03 11:57:34 -0700269 for (int j = 0; j < kNumCoeffs; ++j) {
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200270#if CONFIG_HIGHBITDEPTH
Deb Mukherjee10783d42014-09-02 16:34:09 -0700271 const int diff =
Yaowu Xuf883b422016-08-30 14:01:10 -0700272 bit_depth_ == AOM_BITS_8 ? dst[j] - src[j] : dst16[j] - src16[j];
Deb Mukherjee10783d42014-09-02 16:34:09 -0700273#else
Scott LaVarnway2cf0d4b2013-05-14 11:58:13 -0400274 const int diff = dst[j] - src[j];
Deb Mukherjee10783d42014-09-02 16:34:09 -0700275#endif
Ronald S. Bultjec456b352012-12-07 14:45:05 -0800276 const int error = diff * diff;
clang-format3a826f12016-08-11 17:46:05 -0700277 EXPECT_GE(1, error) << "Error: 32x32 IDCT has error " << error
278 << " at index " << j;
Ronald S. Bultjec456b352012-12-07 14:45:05 -0800279 }
Ronald S. Bultjec456b352012-12-07 14:45:05 -0800280 }
281}
Paul Wilkins649be942013-02-11 12:35:28 +0000282
James Zern0269df42016-03-29 21:04:38 -0700283class PartialTrans32x32Test
284 : public ::testing::TestWithParam<
Yaowu Xuf883b422016-08-30 14:01:10 -0700285 std::tr1::tuple<FwdTxfmFunc, aom_bit_depth_t> > {
James Zern0269df42016-03-29 21:04:38 -0700286 public:
287 virtual ~PartialTrans32x32Test() {}
288 virtual void SetUp() {
289 fwd_txfm_ = GET_PARAM(0);
290 bit_depth_ = GET_PARAM(1);
291 }
292
Yaowu Xuc27fc142016-08-22 16:08:15 -0700293 virtual void TearDown() { libaom_test::ClearSystemState(); }
James Zern0269df42016-03-29 21:04:38 -0700294
295 protected:
Yaowu Xuf883b422016-08-30 14:01:10 -0700296 aom_bit_depth_t bit_depth_;
James Zern0269df42016-03-29 21:04:38 -0700297 FwdTxfmFunc fwd_txfm_;
298};
299
300TEST_P(PartialTrans32x32Test, Extremes) {
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200301#if CONFIG_HIGHBITDEPTH
James Zern0269df42016-03-29 21:04:38 -0700302 const int16_t maxval =
303 static_cast<int16_t>(clip_pixel_highbd(1 << 30, bit_depth_));
304#else
305 const int16_t maxval = 255;
306#endif
307 const int minval = -maxval;
308 DECLARE_ALIGNED(16, int16_t, input[kNumCoeffs]);
309 DECLARE_ALIGNED(16, tran_low_t, output[kNumCoeffs]);
310
311 for (int i = 0; i < kNumCoeffs; ++i) input[i] = maxval;
312 output[0] = 0;
313 ASM_REGISTER_STATE_CHECK(fwd_txfm_(input, output, 32));
314 EXPECT_EQ((maxval * kNumCoeffs) >> 3, output[0]);
315
316 for (int i = 0; i < kNumCoeffs; ++i) input[i] = minval;
317 output[0] = 0;
318 ASM_REGISTER_STATE_CHECK(fwd_txfm_(input, output, 32));
319 EXPECT_EQ((minval * kNumCoeffs) >> 3, output[0]);
320}
321
James Zernc98f8e02016-04-01 19:44:23 -0700322TEST_P(PartialTrans32x32Test, Random) {
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200323#if CONFIG_HIGHBITDEPTH
James Zernc98f8e02016-04-01 19:44:23 -0700324 const int16_t maxval =
325 static_cast<int16_t>(clip_pixel_highbd(1 << 30, bit_depth_));
326#else
327 const int16_t maxval = 255;
328#endif
329 DECLARE_ALIGNED(16, int16_t, input[kNumCoeffs]);
330 DECLARE_ALIGNED(16, tran_low_t, output[kNumCoeffs]);
331 ACMRandom rnd(ACMRandom::DeterministicSeed());
332
333 int sum = 0;
334 for (int i = 0; i < kNumCoeffs; ++i) {
335 const int val = (i & 1) ? -rnd(maxval + 1) : rnd(maxval + 1);
336 input[i] = val;
337 sum += val;
338 }
339 output[0] = 0;
340 ASM_REGISTER_STATE_CHECK(fwd_txfm_(input, output, 32));
341 EXPECT_EQ(sum >> 3, output[0]);
342}
343
Jingning Han4ad52a82013-09-03 11:57:34 -0700344using std::tr1::make_tuple;
Ronald S. Bultjec456b352012-12-07 14:45:05 -0800345
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200346#if CONFIG_HIGHBITDEPTH
Jingning Han4ad52a82013-09-03 11:57:34 -0700347INSTANTIATE_TEST_CASE_P(
348 C, Trans32x32Test,
Frederic Barbierc756e4d2017-04-25 17:26:28 +0200349 ::testing::Values(make_tuple(&aom_fdct32x32_c, &aom_idct32x32_1024_add_c, 0,
350 AOM_BITS_8),
351 make_tuple(&aom_fdct32x32_rd_c, &aom_idct32x32_1024_add_c,
352 1, AOM_BITS_8)));
Deb Mukherjee10783d42014-09-02 16:34:09 -0700353#else
354INSTANTIATE_TEST_CASE_P(
355 C, Trans32x32Test,
Yaowu Xuf883b422016-08-30 14:01:10 -0700356 ::testing::Values(make_tuple(&aom_fdct32x32_c, &aom_idct32x32_1024_add_c, 0,
357 AOM_BITS_8),
358 make_tuple(&aom_fdct32x32_rd_c, &aom_idct32x32_1024_add_c,
359 1, AOM_BITS_8)));
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200360#endif // CONFIG_HIGHBITDEPTH
Ronald S. Bultjec456b352012-12-07 14:45:05 -0800361
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200362#if HAVE_NEON && !CONFIG_HIGHBITDEPTH
James Zerna6effda2014-02-25 23:11:49 -0800363INSTANTIATE_TEST_CASE_P(
364 NEON, Trans32x32Test,
Yaowu Xuf883b422016-08-30 14:01:10 -0700365 ::testing::Values(make_tuple(&aom_fdct32x32_c, &aom_idct32x32_1024_add_neon,
366 0, AOM_BITS_8),
367 make_tuple(&aom_fdct32x32_rd_c,
368 &aom_idct32x32_1024_add_neon, 1, AOM_BITS_8)));
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200369#endif // HAVE_NEON && !CONFIG_HIGHBITDEPTH
James Zerna6effda2014-02-25 23:11:49 -0800370
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200371#if HAVE_SSE2 && !CONFIG_HIGHBITDEPTH
Jingning Han4ad52a82013-09-03 11:57:34 -0700372INSTANTIATE_TEST_CASE_P(
373 SSE2, Trans32x32Test,
Yaowu Xuf883b422016-08-30 14:01:10 -0700374 ::testing::Values(make_tuple(&aom_fdct32x32_sse2,
375 &aom_idct32x32_1024_add_sse2, 0, AOM_BITS_8),
376 make_tuple(&aom_fdct32x32_rd_sse2,
377 &aom_idct32x32_1024_add_sse2, 1, AOM_BITS_8)));
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200378#endif // HAVE_SSE2 && !CONFIG_HIGHBITDEPTH
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100379
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200380#if HAVE_SSE2 && CONFIG_HIGHBITDEPTH
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100381INSTANTIATE_TEST_CASE_P(
382 SSE2, Trans32x32Test,
Frederic Barbierc756e4d2017-04-25 17:26:28 +0200383 ::testing::Values(make_tuple(&aom_fdct32x32_sse2, &aom_idct32x32_1024_add_c,
384 0, AOM_BITS_8),
385 make_tuple(&aom_fdct32x32_rd_sse2,
386 &aom_idct32x32_1024_add_c, 1, AOM_BITS_8)));
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200387#endif // HAVE_SSE2 && CONFIG_HIGHBITDEPTH
levytamar828def7662013-11-21 12:31:10 -0700388
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200389#if HAVE_AVX2 && !CONFIG_HIGHBITDEPTH
levytamar828def7662013-11-21 12:31:10 -0700390INSTANTIATE_TEST_CASE_P(
391 AVX2, Trans32x32Test,
Yaowu Xuf883b422016-08-30 14:01:10 -0700392 ::testing::Values(make_tuple(&aom_fdct32x32_avx2,
393 &aom_idct32x32_1024_add_sse2, 0, AOM_BITS_8),
394 make_tuple(&aom_fdct32x32_rd_avx2,
395 &aom_idct32x32_1024_add_sse2, 1, AOM_BITS_8)));
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200396#endif // HAVE_AVX2 && !CONFIG_HIGHBITDEPTH
Parag Salasakar1601c132015-05-06 12:37:38 +0530397
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200398#if HAVE_AVX2 && CONFIG_HIGHBITDEPTH
Yi Luo0c552df2016-10-24 16:30:55 -0700399INSTANTIATE_TEST_CASE_P(
400 AVX2, Trans32x32Test,
401 ::testing::Values(make_tuple(&aom_fdct32x32_avx2,
402 &aom_idct32x32_1024_add_sse2, 0, AOM_BITS_8),
403 make_tuple(&aom_fdct32x32_rd_avx2,
404 &aom_idct32x32_1024_add_sse2, 1, AOM_BITS_8)));
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200405#endif // HAVE_AVX2 && CONFIG_HIGHBITDEPTH
Yi Luo0c552df2016-10-24 16:30:55 -0700406
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200407#if HAVE_MSA && !CONFIG_HIGHBITDEPTH
Parag Salasakar1601c132015-05-06 12:37:38 +0530408INSTANTIATE_TEST_CASE_P(
409 MSA, Trans32x32Test,
Yaowu Xuf883b422016-08-30 14:01:10 -0700410 ::testing::Values(make_tuple(&aom_fdct32x32_msa,
411 &aom_idct32x32_1024_add_msa, 0, AOM_BITS_8),
412 make_tuple(&aom_fdct32x32_rd_msa,
413 &aom_idct32x32_1024_add_msa, 1, AOM_BITS_8)));
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200414#endif // HAVE_MSA && !CONFIG_HIGHBITDEPTH
Ronald S. Bultjec456b352012-12-07 14:45:05 -0800415} // namespace