blob: 63f160131a32b816b0e30d16563624b36044c05d [file] [log] [blame]
Daniel Kang58156f12012-06-26 18:11:33 -07001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Daniel Kang58156f12012-06-26 18:11:33 -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 */
Daniel Kang58156f12012-06-26 18:11:33 -070011
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"
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 Han30d4c5e2013-11-12 12:47:32 -080020#include "test/acm_random.h"
21#include "test/clear_system_state.h"
22#include "test/register_state_check.h"
Yi Luo267f73a2016-02-29 09:53:42 -080023#include "test/transform_test_base.h"
Jingning Han30d4c5e2013-11-12 12:47:32 -080024#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"
James Zern002ad402014-01-18 13:03:31 -080029
Yaowu Xuc27fc142016-08-22 16:08:15 -070030using libaom_test::ACMRandom;
Daniel Kang26641c72012-06-28 16:26:31 -070031
Daniel Kang58156f12012-06-26 18:11:33 -070032namespace {
Deb Mukherjee10783d42014-09-02 16:34:09 -070033typedef void (*FdctFunc)(const int16_t *in, tran_low_t *out, int stride);
34typedef void (*IdctFunc)(const tran_low_t *in, uint8_t *out, int stride);
Deb Mukherjee10783d42014-09-02 16:34:09 -070035typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
Lester Lu27319b62017-07-10 16:57:15 -070036 const TxfmParam *txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -070037using libaom_test::FhtFunc;
Jingning Han30d4c5e2013-11-12 12:47:32 -080038
Urvang Joshi2283d372017-10-02 17:16:45 -070039typedef std::tr1::tuple<FdctFunc, IdctFunc, TX_TYPE, aom_bit_depth_t, int>
clang-format3a826f12016-08-11 17:46:05 -070040 Dct4x4Param;
Urvang Joshi2283d372017-10-02 17:16:45 -070041typedef std::tr1::tuple<FhtFunc, IhtFunc, TX_TYPE, aom_bit_depth_t, int>
42 Ht4x4Param;
Joshua Litt51490e52013-11-18 17:07:55 -080043
Deb Mukherjee10783d42014-09-02 16:34:09 -070044void fdct4x4_ref(const int16_t *in, tran_low_t *out, int stride,
Lester Lu27319b62017-07-10 16:57:15 -070045 TxfmParam * /*txfm_param*/) {
Yaowu Xuf883b422016-08-30 14:01:10 -070046 aom_fdct4x4_c(in, out, stride);
Jingning Han362809d2013-06-18 10:46:33 -070047}
Jingning Han30d4c5e2013-11-12 12:47:32 -080048
Lester Lud8b1ddc2017-07-06 16:13:29 -070049void fht4x4_ref(const int16_t *in, tran_low_t *out, int stride,
Lester Lu27319b62017-07-10 16:57:15 -070050 TxfmParam *txfm_param) {
51 av1_fht4x4_c(in, out, stride, txfm_param);
Jingning Han362809d2013-06-18 10:46:33 -070052}
Daniel Kang58156f12012-06-26 18:11:33 -070053
Deb Mukherjee10783d42014-09-02 16:34:09 -070054void fwht4x4_ref(const int16_t *in, tran_low_t *out, int stride,
Lester Lu27319b62017-07-10 16:57:15 -070055 TxfmParam * /*txfm_param*/) {
Yaowu Xuf883b422016-08-30 14:01:10 -070056 av1_fwht4x4_c(in, out, stride);
Alex Converse9f9f87c2014-05-05 13:50:12 -070057}
58
Lester Lud8b1ddc2017-07-06 16:13:29 -070059void fht4x4_10(const int16_t *in, tran_low_t *out, int stride,
Lester Lu27319b62017-07-10 16:57:15 -070060 TxfmParam *txfm_param) {
61 av1_fwd_txfm2d_4x4_c(in, out, stride, txfm_param->tx_type, 10);
Sarah Parker31c66502017-05-19 16:51:07 -070062}
63
Lester Lud8b1ddc2017-07-06 16:13:29 -070064void fht4x4_12(const int16_t *in, tran_low_t *out, int stride,
Lester Lu27319b62017-07-10 16:57:15 -070065 TxfmParam *txfm_param) {
66 av1_fwd_txfm2d_4x4_c(in, out, stride, txfm_param->tx_type, 12);
Sarah Parker31c66502017-05-19 16:51:07 -070067}
68
Lester Lud8b1ddc2017-07-06 16:13:29 -070069void iht4x4_10(const tran_low_t *in, uint8_t *out, int stride,
Lester Lu27319b62017-07-10 16:57:15 -070070 const TxfmParam *txfm_param) {
Lester Lud8b1ddc2017-07-06 16:13:29 -070071 av1_inv_txfm2d_add_4x4_c(in, CONVERT_TO_SHORTPTR(out), stride,
Lester Lu27319b62017-07-10 16:57:15 -070072 txfm_param->tx_type, 10);
Deb Mukherjee10783d42014-09-02 16:34:09 -070073}
74
Lester Lud8b1ddc2017-07-06 16:13:29 -070075void iht4x4_12(const tran_low_t *in, uint8_t *out, int stride,
Lester Lu27319b62017-07-10 16:57:15 -070076 const TxfmParam *txfm_param) {
Lester Lud8b1ddc2017-07-06 16:13:29 -070077 av1_inv_txfm2d_add_4x4_c(in, CONVERT_TO_SHORTPTR(out), stride,
Lester Lu27319b62017-07-10 16:57:15 -070078 txfm_param->tx_type, 12);
Deb Mukherjee10783d42014-09-02 16:34:09 -070079}
80
81void iwht4x4_10(const tran_low_t *in, uint8_t *out, int stride) {
Yaowu Xuf883b422016-08-30 14:01:10 -070082 aom_highbd_iwht4x4_16_add_c(in, out, stride, 10);
Deb Mukherjee10783d42014-09-02 16:34:09 -070083}
84
85void iwht4x4_12(const tran_low_t *in, uint8_t *out, int stride) {
Yaowu Xuf883b422016-08-30 14:01:10 -070086 aom_highbd_iwht4x4_16_add_c(in, out, stride, 12);
Deb Mukherjee10783d42014-09-02 16:34:09 -070087}
Deb Mukherjee10783d42014-09-02 16:34:09 -070088
Yaowu Xuc27fc142016-08-22 16:08:15 -070089class Trans4x4DCT : public libaom_test::TransformTestBase,
clang-format3a826f12016-08-11 17:46:05 -070090 public ::testing::TestWithParam<Dct4x4Param> {
Jingning Han30d4c5e2013-11-12 12:47:32 -080091 public:
92 virtual ~Trans4x4DCT() {}
Daniel Kang58156f12012-06-26 18:11:33 -070093
Jingning Han30d4c5e2013-11-12 12:47:32 -080094 virtual void SetUp() {
95 fwd_txfm_ = GET_PARAM(0);
96 inv_txfm_ = GET_PARAM(1);
clang-format3a826f12016-08-11 17:46:05 -070097 pitch_ = 4;
David Barker78250222016-10-13 15:10:14 +010098 height_ = 4;
Jingning Han30d4c5e2013-11-12 12:47:32 -080099 fwd_txfm_ref = fdct4x4_ref;
Deb Mukherjee10783d42014-09-02 16:34:09 -0700100 bit_depth_ = GET_PARAM(3);
101 mask_ = (1 << bit_depth_) - 1;
Yi Luo267f73a2016-02-29 09:53:42 -0800102 num_coeffs_ = GET_PARAM(4);
Lester Lu27319b62017-07-10 16:57:15 -0700103 txfm_param_.tx_type = GET_PARAM(2);
Jingning Han30d4c5e2013-11-12 12:47:32 -0800104 }
Yaowu Xuc27fc142016-08-22 16:08:15 -0700105 virtual void TearDown() { libaom_test::ClearSystemState(); }
Daniel Kang58156f12012-06-26 18:11:33 -0700106
Jingning Han30d4c5e2013-11-12 12:47:32 -0800107 protected:
Deb Mukherjee10783d42014-09-02 16:34:09 -0700108 void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
Jingning Han30d4c5e2013-11-12 12:47:32 -0800109 fwd_txfm_(in, out, stride);
110 }
Deb Mukherjee10783d42014-09-02 16:34:09 -0700111 void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
Jingning Han30d4c5e2013-11-12 12:47:32 -0800112 inv_txfm_(out, dst, stride);
Daniel Kang58156f12012-06-26 18:11:33 -0700113 }
114
James Zernb8b3dd92014-07-16 18:55:40 -0700115 FdctFunc fwd_txfm_;
116 IdctFunc inv_txfm_;
Jingning Han30d4c5e2013-11-12 12:47:32 -0800117};
Daniel Kang58156f12012-06-26 18:11:33 -0700118
Angie Chiange6aece82017-01-09 17:27:56 -0800119TEST_P(Trans4x4DCT, AccuracyCheck) { RunAccuracyCheck(0, 0.00001); }
Daniel Kang58156f12012-06-26 18:11:33 -0700120
clang-format3a826f12016-08-11 17:46:05 -0700121TEST_P(Trans4x4DCT, CoeffCheck) { RunCoeffCheck(); }
Daniel Kang58156f12012-06-26 18:11:33 -0700122
clang-format3a826f12016-08-11 17:46:05 -0700123TEST_P(Trans4x4DCT, MemCheck) { RunMemCheck(); }
Jingning Han30d4c5e2013-11-12 12:47:32 -0800124
clang-format3a826f12016-08-11 17:46:05 -0700125TEST_P(Trans4x4DCT, InvAccuracyCheck) { RunInvAccuracyCheck(1); }
Jingning Han30d4c5e2013-11-12 12:47:32 -0800126
Yaowu Xuc27fc142016-08-22 16:08:15 -0700127class Trans4x4HT : public libaom_test::TransformTestBase,
clang-format3a826f12016-08-11 17:46:05 -0700128 public ::testing::TestWithParam<Ht4x4Param> {
Jingning Han30d4c5e2013-11-12 12:47:32 -0800129 public:
130 virtual ~Trans4x4HT() {}
131
132 virtual void SetUp() {
133 fwd_txfm_ = GET_PARAM(0);
134 inv_txfm_ = GET_PARAM(1);
clang-format3a826f12016-08-11 17:46:05 -0700135 pitch_ = 4;
David Barker78250222016-10-13 15:10:14 +0100136 height_ = 4;
Jingning Han30d4c5e2013-11-12 12:47:32 -0800137 fwd_txfm_ref = fht4x4_ref;
Deb Mukherjee10783d42014-09-02 16:34:09 -0700138 bit_depth_ = GET_PARAM(3);
139 mask_ = (1 << bit_depth_) - 1;
Yi Luo267f73a2016-02-29 09:53:42 -0800140 num_coeffs_ = GET_PARAM(4);
Lester Lu27319b62017-07-10 16:57:15 -0700141 txfm_param_.tx_type = GET_PARAM(2);
Sarah Parker31c66502017-05-19 16:51:07 -0700142 switch (bit_depth_) {
143 case AOM_BITS_10: fwd_txfm_ref = fht4x4_10; break;
144 case AOM_BITS_12: fwd_txfm_ref = fht4x4_12; break;
145 default: fwd_txfm_ref = fht4x4_ref; break;
146 }
Jingning Han30d4c5e2013-11-12 12:47:32 -0800147 }
Yaowu Xuc27fc142016-08-22 16:08:15 -0700148 virtual void TearDown() { libaom_test::ClearSystemState(); }
Jingning Han30d4c5e2013-11-12 12:47:32 -0800149
150 protected:
Deb Mukherjee10783d42014-09-02 16:34:09 -0700151 void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
Lester Lu27319b62017-07-10 16:57:15 -0700152 fwd_txfm_(in, out, stride, &txfm_param_);
Jingning Han30d4c5e2013-11-12 12:47:32 -0800153 }
154
Deb Mukherjee10783d42014-09-02 16:34:09 -0700155 void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
Lester Lu27319b62017-07-10 16:57:15 -0700156 inv_txfm_(out, dst, stride, &txfm_param_);
Jingning Han30d4c5e2013-11-12 12:47:32 -0800157 }
158
James Zernb8b3dd92014-07-16 18:55:40 -0700159 FhtFunc fwd_txfm_;
160 IhtFunc inv_txfm_;
Jingning Han30d4c5e2013-11-12 12:47:32 -0800161};
162
Yi Luo8f315b12017-01-13 12:29:48 -0800163TEST_P(Trans4x4HT, AccuracyCheck) { RunAccuracyCheck(1, 0.005); }
Jingning Han30d4c5e2013-11-12 12:47:32 -0800164
clang-format3a826f12016-08-11 17:46:05 -0700165TEST_P(Trans4x4HT, CoeffCheck) { RunCoeffCheck(); }
Jingning Han30d4c5e2013-11-12 12:47:32 -0800166
clang-format3a826f12016-08-11 17:46:05 -0700167TEST_P(Trans4x4HT, MemCheck) { RunMemCheck(); }
Jingning Han30d4c5e2013-11-12 12:47:32 -0800168
clang-format3a826f12016-08-11 17:46:05 -0700169TEST_P(Trans4x4HT, InvAccuracyCheck) { RunInvAccuracyCheck(1); }
Jingning Han30d4c5e2013-11-12 12:47:32 -0800170
Yaowu Xuc27fc142016-08-22 16:08:15 -0700171class Trans4x4WHT : public libaom_test::TransformTestBase,
clang-format3a826f12016-08-11 17:46:05 -0700172 public ::testing::TestWithParam<Dct4x4Param> {
Alex Converse9f9f87c2014-05-05 13:50:12 -0700173 public:
174 virtual ~Trans4x4WHT() {}
175
176 virtual void SetUp() {
177 fwd_txfm_ = GET_PARAM(0);
178 inv_txfm_ = GET_PARAM(1);
clang-format3a826f12016-08-11 17:46:05 -0700179 pitch_ = 4;
David Barker78250222016-10-13 15:10:14 +0100180 height_ = 4;
Alex Converse9f9f87c2014-05-05 13:50:12 -0700181 fwd_txfm_ref = fwht4x4_ref;
Deb Mukherjee10783d42014-09-02 16:34:09 -0700182 bit_depth_ = GET_PARAM(3);
183 mask_ = (1 << bit_depth_) - 1;
Yi Luo267f73a2016-02-29 09:53:42 -0800184 num_coeffs_ = GET_PARAM(4);
Alex Converse9f9f87c2014-05-05 13:50:12 -0700185 }
Yaowu Xuc27fc142016-08-22 16:08:15 -0700186 virtual void TearDown() { libaom_test::ClearSystemState(); }
Alex Converse9f9f87c2014-05-05 13:50:12 -0700187
188 protected:
Deb Mukherjee10783d42014-09-02 16:34:09 -0700189 void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
Alex Converse9f9f87c2014-05-05 13:50:12 -0700190 fwd_txfm_(in, out, stride);
191 }
Deb Mukherjee10783d42014-09-02 16:34:09 -0700192 void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
Alex Converse9f9f87c2014-05-05 13:50:12 -0700193 inv_txfm_(out, dst, stride);
194 }
195
James Zernb8b3dd92014-07-16 18:55:40 -0700196 FdctFunc fwd_txfm_;
197 IdctFunc inv_txfm_;
Alex Converse9f9f87c2014-05-05 13:50:12 -0700198};
199
Angie Chiange6aece82017-01-09 17:27:56 -0800200TEST_P(Trans4x4WHT, AccuracyCheck) { RunAccuracyCheck(0, 0.00001); }
Alex Converse9f9f87c2014-05-05 13:50:12 -0700201
clang-format3a826f12016-08-11 17:46:05 -0700202TEST_P(Trans4x4WHT, CoeffCheck) { RunCoeffCheck(); }
Alex Converse9f9f87c2014-05-05 13:50:12 -0700203
clang-format3a826f12016-08-11 17:46:05 -0700204TEST_P(Trans4x4WHT, MemCheck) { RunMemCheck(); }
Alex Converse9f9f87c2014-05-05 13:50:12 -0700205
clang-format3a826f12016-08-11 17:46:05 -0700206TEST_P(Trans4x4WHT, InvAccuracyCheck) { RunInvAccuracyCheck(0); }
Jingning Han30d4c5e2013-11-12 12:47:32 -0800207using std::tr1::make_tuple;
208
clang-format3a826f12016-08-11 17:46:05 -0700209INSTANTIATE_TEST_CASE_P(C, Trans4x4DCT,
Yaowu Xuf883b422016-08-30 14:01:10 -0700210 ::testing::Values(make_tuple(&aom_fdct4x4_c,
Urvang Joshi2283d372017-10-02 17:16:45 -0700211 &aom_idct4x4_16_add_c,
212 DCT_DCT, AOM_BITS_8, 16)));
Deb Mukherjee10783d42014-09-02 16:34:09 -0700213
Jingning Han30d4c5e2013-11-12 12:47:32 -0800214INSTANTIATE_TEST_CASE_P(
Sarah Parker31c66502017-05-19 16:51:07 -0700215 DISABLED_C, Trans4x4HT,
Urvang Joshi2283d372017-10-02 17:16:45 -0700216 ::testing::Values(
217 make_tuple(&fht4x4_12, &iht4x4_12, DCT_DCT, AOM_BITS_12, 16),
218 make_tuple(&fht4x4_12, &iht4x4_12, ADST_DCT, AOM_BITS_12, 16),
219 make_tuple(&fht4x4_12, &iht4x4_12, DCT_ADST, AOM_BITS_12, 16),
220 make_tuple(&fht4x4_12, &iht4x4_12, ADST_ADST, AOM_BITS_12, 16)));
Sarah Parker31c66502017-05-19 16:51:07 -0700221
222INSTANTIATE_TEST_CASE_P(
Jingning Han30d4c5e2013-11-12 12:47:32 -0800223 C, Trans4x4HT,
224 ::testing::Values(
Urvang Joshi2283d372017-10-02 17:16:45 -0700225 make_tuple(&fht4x4_10, &iht4x4_10, DCT_DCT, AOM_BITS_10, 16),
226 make_tuple(&fht4x4_10, &iht4x4_10, ADST_DCT, AOM_BITS_10, 16),
227 make_tuple(&fht4x4_10, &iht4x4_10, DCT_ADST, AOM_BITS_10, 16),
228 make_tuple(&fht4x4_10, &iht4x4_10, ADST_ADST, AOM_BITS_10, 16),
229 make_tuple(&av1_fht4x4_c, &av1_iht4x4_16_add_c, DCT_DCT, AOM_BITS_8,
230 16),
231 make_tuple(&av1_fht4x4_c, &av1_iht4x4_16_add_c, ADST_DCT, AOM_BITS_8,
232 16),
233 make_tuple(&av1_fht4x4_c, &av1_iht4x4_16_add_c, DCT_ADST, AOM_BITS_8,
234 16),
235 make_tuple(&av1_fht4x4_c, &av1_iht4x4_16_add_c, ADST_ADST, AOM_BITS_8,
236 16)));
Deb Mukherjee10783d42014-09-02 16:34:09 -0700237
Alex Converse9f9f87c2014-05-05 13:50:12 -0700238INSTANTIATE_TEST_CASE_P(
239 C, Trans4x4WHT,
Urvang Joshi2283d372017-10-02 17:16:45 -0700240 ::testing::Values(make_tuple(&av1_highbd_fwht4x4_c, &iwht4x4_10, DCT_DCT,
241 AOM_BITS_10, 16),
242 make_tuple(&av1_highbd_fwht4x4_c, &iwht4x4_12, DCT_DCT,
243 AOM_BITS_12, 16),
244 make_tuple(&av1_fwht4x4_c, &aom_iwht4x4_16_add_c, DCT_DCT,
245 AOM_BITS_8, 16)));
James Zern08c31802014-02-25 23:11:49 -0800246
Sebastien Alaiwan58596362018-01-26 10:11:35 +0100247#if HAVE_SSE2
Alex Conversed8426d62015-07-13 11:12:45 -0700248INSTANTIATE_TEST_CASE_P(
249 SSE2, Trans4x4WHT,
Urvang Joshi2283d372017-10-02 17:16:45 -0700250 ::testing::Values(make_tuple(&av1_fwht4x4_c, &aom_iwht4x4_16_add_c, DCT_DCT,
Yaowu Xuf883b422016-08-30 14:01:10 -0700251 AOM_BITS_8, 16),
Urvang Joshi2283d372017-10-02 17:16:45 -0700252 make_tuple(&av1_fwht4x4_c, &aom_iwht4x4_16_add_sse2,
253 DCT_DCT, AOM_BITS_8, 16)));
Alex Conversed8426d62015-07-13 11:12:45 -0700254#endif
255
Sebastien Alaiwan58596362018-01-26 10:11:35 +0100256#if HAVE_SSE2
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100257INSTANTIATE_TEST_CASE_P(
Peter de Rivaz7e40a552014-10-24 08:48:02 +0100258 SSE2, Trans4x4HT,
Urvang Joshi2283d372017-10-02 17:16:45 -0700259 ::testing::Values(make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_c,
260 DCT_DCT, AOM_BITS_8, 16),
261 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_c,
262 ADST_DCT, AOM_BITS_8, 16),
263 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_c,
264 DCT_ADST, AOM_BITS_8, 16),
265 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_c,
266 ADST_ADST, AOM_BITS_8, 16)));
Sebastien Alaiwan58596362018-01-26 10:11:35 +0100267#endif // HAVE_SSE2
Parag Salasakar54a6f732015-06-02 12:16:28 +0530268
Daniel Kang58156f12012-06-26 18:11:33 -0700269} // namespace