1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker *
4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker */
11*77c1e3ccSAndroid Build Coastguard Worker
12*77c1e3ccSAndroid Build Coastguard Worker #include <tuple>
13*77c1e3ccSAndroid Build Coastguard Worker
14*77c1e3ccSAndroid Build Coastguard Worker #include "gtest/gtest.h"
15*77c1e3ccSAndroid Build Coastguard Worker
16*77c1e3ccSAndroid Build Coastguard Worker #include "config/av1_rtcd.h"
17*77c1e3ccSAndroid Build Coastguard Worker
18*77c1e3ccSAndroid Build Coastguard Worker #include "test/acm_random.h"
19*77c1e3ccSAndroid Build Coastguard Worker #include "test/av1_txfm_test.h"
20*77c1e3ccSAndroid Build Coastguard Worker #include "test/register_state_check.h"
21*77c1e3ccSAndroid Build Coastguard Worker #include "test/util.h"
22*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/enums.h"
23*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/scan.h"
24*77c1e3ccSAndroid Build Coastguard Worker #include "aom_dsp/aom_dsp_common.h"
25*77c1e3ccSAndroid Build Coastguard Worker #include "aom_ports/mem.h"
26*77c1e3ccSAndroid Build Coastguard Worker
27*77c1e3ccSAndroid Build Coastguard Worker namespace {
28*77c1e3ccSAndroid Build Coastguard Worker
29*77c1e3ccSAndroid Build Coastguard Worker using libaom_test::ACMRandom;
30*77c1e3ccSAndroid Build Coastguard Worker using std::tuple;
31*77c1e3ccSAndroid Build Coastguard Worker
32*77c1e3ccSAndroid Build Coastguard Worker typedef void (*HbdHtFunc)(const int16_t *input, int32_t *output, int stride,
33*77c1e3ccSAndroid Build Coastguard Worker TX_TYPE tx_type, int bd);
34*77c1e3ccSAndroid Build Coastguard Worker
35*77c1e3ccSAndroid Build Coastguard Worker typedef void (*IHbdHtFunc)(const int32_t *coeff, uint16_t *output, int stride,
36*77c1e3ccSAndroid Build Coastguard Worker TX_TYPE tx_type, int bd);
37*77c1e3ccSAndroid Build Coastguard Worker static const char *tx_type_name[] = {
38*77c1e3ccSAndroid Build Coastguard Worker "DCT_DCT",
39*77c1e3ccSAndroid Build Coastguard Worker "ADST_DCT",
40*77c1e3ccSAndroid Build Coastguard Worker "DCT_ADST",
41*77c1e3ccSAndroid Build Coastguard Worker "ADST_ADST",
42*77c1e3ccSAndroid Build Coastguard Worker "FLIPADST_DCT",
43*77c1e3ccSAndroid Build Coastguard Worker "DCT_FLIPADST",
44*77c1e3ccSAndroid Build Coastguard Worker "FLIPADST_FLIPADST",
45*77c1e3ccSAndroid Build Coastguard Worker "ADST_FLIPADST",
46*77c1e3ccSAndroid Build Coastguard Worker "FLIPADST_ADST",
47*77c1e3ccSAndroid Build Coastguard Worker "IDTX",
48*77c1e3ccSAndroid Build Coastguard Worker "V_DCT",
49*77c1e3ccSAndroid Build Coastguard Worker "H_DCT",
50*77c1e3ccSAndroid Build Coastguard Worker "V_ADST",
51*77c1e3ccSAndroid Build Coastguard Worker "H_ADST",
52*77c1e3ccSAndroid Build Coastguard Worker "V_FLIPADST",
53*77c1e3ccSAndroid Build Coastguard Worker "H_FLIPADST",
54*77c1e3ccSAndroid Build Coastguard Worker };
55*77c1e3ccSAndroid Build Coastguard Worker // Test parameter argument list:
56*77c1e3ccSAndroid Build Coastguard Worker // <transform reference function,
57*77c1e3ccSAndroid Build Coastguard Worker // optimized inverse transform function,
58*77c1e3ccSAndroid Build Coastguard Worker // inverse transform reference function,
59*77c1e3ccSAndroid Build Coastguard Worker // num_coeffs,
60*77c1e3ccSAndroid Build Coastguard Worker // tx_type,
61*77c1e3ccSAndroid Build Coastguard Worker // bit_depth>
62*77c1e3ccSAndroid Build Coastguard Worker typedef tuple<HbdHtFunc, IHbdHtFunc, IHbdHtFunc, int, TX_TYPE, int> IHbdHtParam;
63*77c1e3ccSAndroid Build Coastguard Worker
64*77c1e3ccSAndroid Build Coastguard Worker class AV1HighbdInvHTNxN : public ::testing::TestWithParam<IHbdHtParam> {
65*77c1e3ccSAndroid Build Coastguard Worker public:
66*77c1e3ccSAndroid Build Coastguard Worker ~AV1HighbdInvHTNxN() override = default;
67*77c1e3ccSAndroid Build Coastguard Worker
SetUp()68*77c1e3ccSAndroid Build Coastguard Worker void SetUp() override {
69*77c1e3ccSAndroid Build Coastguard Worker txfm_ref_ = GET_PARAM(0);
70*77c1e3ccSAndroid Build Coastguard Worker inv_txfm_ = GET_PARAM(1);
71*77c1e3ccSAndroid Build Coastguard Worker inv_txfm_ref_ = GET_PARAM(2);
72*77c1e3ccSAndroid Build Coastguard Worker num_coeffs_ = GET_PARAM(3);
73*77c1e3ccSAndroid Build Coastguard Worker tx_type_ = GET_PARAM(4);
74*77c1e3ccSAndroid Build Coastguard Worker bit_depth_ = GET_PARAM(5);
75*77c1e3ccSAndroid Build Coastguard Worker
76*77c1e3ccSAndroid Build Coastguard Worker input_ = reinterpret_cast<int16_t *>(
77*77c1e3ccSAndroid Build Coastguard Worker aom_memalign(16, sizeof(input_[0]) * num_coeffs_));
78*77c1e3ccSAndroid Build Coastguard Worker ASSERT_NE(input_, nullptr);
79*77c1e3ccSAndroid Build Coastguard Worker
80*77c1e3ccSAndroid Build Coastguard Worker // Note:
81*77c1e3ccSAndroid Build Coastguard Worker // Inverse transform input buffer is 32-byte aligned
82*77c1e3ccSAndroid Build Coastguard Worker // Refer to <root>/av1/encoder/context_tree.c, function,
83*77c1e3ccSAndroid Build Coastguard Worker // void alloc_mode_context().
84*77c1e3ccSAndroid Build Coastguard Worker coeffs_ = reinterpret_cast<int32_t *>(
85*77c1e3ccSAndroid Build Coastguard Worker aom_memalign(32, sizeof(coeffs_[0]) * num_coeffs_));
86*77c1e3ccSAndroid Build Coastguard Worker ASSERT_NE(coeffs_, nullptr);
87*77c1e3ccSAndroid Build Coastguard Worker output_ = reinterpret_cast<uint16_t *>(
88*77c1e3ccSAndroid Build Coastguard Worker aom_memalign(32, sizeof(output_[0]) * num_coeffs_));
89*77c1e3ccSAndroid Build Coastguard Worker ASSERT_NE(output_, nullptr);
90*77c1e3ccSAndroid Build Coastguard Worker output_ref_ = reinterpret_cast<uint16_t *>(
91*77c1e3ccSAndroid Build Coastguard Worker aom_memalign(32, sizeof(output_ref_[0]) * num_coeffs_));
92*77c1e3ccSAndroid Build Coastguard Worker ASSERT_NE(output_ref_, nullptr);
93*77c1e3ccSAndroid Build Coastguard Worker }
94*77c1e3ccSAndroid Build Coastguard Worker
TearDown()95*77c1e3ccSAndroid Build Coastguard Worker void TearDown() override {
96*77c1e3ccSAndroid Build Coastguard Worker aom_free(input_);
97*77c1e3ccSAndroid Build Coastguard Worker aom_free(coeffs_);
98*77c1e3ccSAndroid Build Coastguard Worker aom_free(output_);
99*77c1e3ccSAndroid Build Coastguard Worker aom_free(output_ref_);
100*77c1e3ccSAndroid Build Coastguard Worker }
101*77c1e3ccSAndroid Build Coastguard Worker
102*77c1e3ccSAndroid Build Coastguard Worker protected:
103*77c1e3ccSAndroid Build Coastguard Worker void RunBitexactCheck();
104*77c1e3ccSAndroid Build Coastguard Worker
105*77c1e3ccSAndroid Build Coastguard Worker private:
GetStride() const106*77c1e3ccSAndroid Build Coastguard Worker int GetStride() const {
107*77c1e3ccSAndroid Build Coastguard Worker if (16 == num_coeffs_) {
108*77c1e3ccSAndroid Build Coastguard Worker return 4;
109*77c1e3ccSAndroid Build Coastguard Worker } else if (64 == num_coeffs_) {
110*77c1e3ccSAndroid Build Coastguard Worker return 8;
111*77c1e3ccSAndroid Build Coastguard Worker } else if (256 == num_coeffs_) {
112*77c1e3ccSAndroid Build Coastguard Worker return 16;
113*77c1e3ccSAndroid Build Coastguard Worker } else if (1024 == num_coeffs_) {
114*77c1e3ccSAndroid Build Coastguard Worker return 32;
115*77c1e3ccSAndroid Build Coastguard Worker } else if (4096 == num_coeffs_) {
116*77c1e3ccSAndroid Build Coastguard Worker return 64;
117*77c1e3ccSAndroid Build Coastguard Worker } else {
118*77c1e3ccSAndroid Build Coastguard Worker return 0;
119*77c1e3ccSAndroid Build Coastguard Worker }
120*77c1e3ccSAndroid Build Coastguard Worker }
121*77c1e3ccSAndroid Build Coastguard Worker
122*77c1e3ccSAndroid Build Coastguard Worker HbdHtFunc txfm_ref_;
123*77c1e3ccSAndroid Build Coastguard Worker IHbdHtFunc inv_txfm_;
124*77c1e3ccSAndroid Build Coastguard Worker IHbdHtFunc inv_txfm_ref_;
125*77c1e3ccSAndroid Build Coastguard Worker int num_coeffs_;
126*77c1e3ccSAndroid Build Coastguard Worker TX_TYPE tx_type_;
127*77c1e3ccSAndroid Build Coastguard Worker int bit_depth_;
128*77c1e3ccSAndroid Build Coastguard Worker
129*77c1e3ccSAndroid Build Coastguard Worker int16_t *input_;
130*77c1e3ccSAndroid Build Coastguard Worker int32_t *coeffs_;
131*77c1e3ccSAndroid Build Coastguard Worker uint16_t *output_;
132*77c1e3ccSAndroid Build Coastguard Worker uint16_t *output_ref_;
133*77c1e3ccSAndroid Build Coastguard Worker };
134*77c1e3ccSAndroid Build Coastguard Worker GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AV1HighbdInvHTNxN);
135*77c1e3ccSAndroid Build Coastguard Worker
RunBitexactCheck()136*77c1e3ccSAndroid Build Coastguard Worker void AV1HighbdInvHTNxN::RunBitexactCheck() {
137*77c1e3ccSAndroid Build Coastguard Worker ACMRandom rnd(ACMRandom::DeterministicSeed());
138*77c1e3ccSAndroid Build Coastguard Worker const int stride = GetStride();
139*77c1e3ccSAndroid Build Coastguard Worker const int num_tests = 20000;
140*77c1e3ccSAndroid Build Coastguard Worker const uint16_t mask = (1 << bit_depth_) - 1;
141*77c1e3ccSAndroid Build Coastguard Worker
142*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < num_tests; ++i) {
143*77c1e3ccSAndroid Build Coastguard Worker for (int j = 0; j < num_coeffs_; ++j) {
144*77c1e3ccSAndroid Build Coastguard Worker input_[j] = (rnd.Rand16() & mask) - (rnd.Rand16() & mask);
145*77c1e3ccSAndroid Build Coastguard Worker output_ref_[j] = rnd.Rand16() & mask;
146*77c1e3ccSAndroid Build Coastguard Worker output_[j] = output_ref_[j];
147*77c1e3ccSAndroid Build Coastguard Worker }
148*77c1e3ccSAndroid Build Coastguard Worker
149*77c1e3ccSAndroid Build Coastguard Worker txfm_ref_(input_, coeffs_, stride, tx_type_, bit_depth_);
150*77c1e3ccSAndroid Build Coastguard Worker inv_txfm_ref_(coeffs_, output_ref_, stride, tx_type_, bit_depth_);
151*77c1e3ccSAndroid Build Coastguard Worker API_REGISTER_STATE_CHECK(
152*77c1e3ccSAndroid Build Coastguard Worker inv_txfm_(coeffs_, output_, stride, tx_type_, bit_depth_));
153*77c1e3ccSAndroid Build Coastguard Worker
154*77c1e3ccSAndroid Build Coastguard Worker for (int j = 0; j < num_coeffs_; ++j) {
155*77c1e3ccSAndroid Build Coastguard Worker EXPECT_EQ(output_ref_[j], output_[j])
156*77c1e3ccSAndroid Build Coastguard Worker << "Not bit-exact result at index: " << j << " At test block: " << i;
157*77c1e3ccSAndroid Build Coastguard Worker }
158*77c1e3ccSAndroid Build Coastguard Worker }
159*77c1e3ccSAndroid Build Coastguard Worker }
160*77c1e3ccSAndroid Build Coastguard Worker
TEST_P(AV1HighbdInvHTNxN,InvTransResultCheck)161*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1HighbdInvHTNxN, InvTransResultCheck) { RunBitexactCheck(); }
162*77c1e3ccSAndroid Build Coastguard Worker
163*77c1e3ccSAndroid Build Coastguard Worker using std::make_tuple;
164*77c1e3ccSAndroid Build Coastguard Worker
165*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE4_1
166*77c1e3ccSAndroid Build Coastguard Worker #define PARAM_LIST_4X4 \
167*77c1e3ccSAndroid Build Coastguard Worker &av1_fwd_txfm2d_4x4_c, &av1_inv_txfm2d_add_4x4_sse4_1, \
168*77c1e3ccSAndroid Build Coastguard Worker &av1_inv_txfm2d_add_4x4_c, 16
169*77c1e3ccSAndroid Build Coastguard Worker
170*77c1e3ccSAndroid Build Coastguard Worker const IHbdHtParam kArrayIhtParam[] = {
171*77c1e3ccSAndroid Build Coastguard Worker // 4x4
172*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, DCT_DCT, 10),
173*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, DCT_DCT, 12),
174*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, ADST_DCT, 10),
175*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, ADST_DCT, 12),
176*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, DCT_ADST, 10),
177*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, DCT_ADST, 12),
178*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, ADST_ADST, 10),
179*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, ADST_ADST, 12),
180*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, FLIPADST_DCT, 10),
181*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, FLIPADST_DCT, 12),
182*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, DCT_FLIPADST, 10),
183*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, DCT_FLIPADST, 12),
184*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, FLIPADST_FLIPADST, 10),
185*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, FLIPADST_FLIPADST, 12),
186*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, ADST_FLIPADST, 10),
187*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, ADST_FLIPADST, 12),
188*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, FLIPADST_ADST, 10),
189*77c1e3ccSAndroid Build Coastguard Worker make_tuple(PARAM_LIST_4X4, FLIPADST_ADST, 12),
190*77c1e3ccSAndroid Build Coastguard Worker };
191*77c1e3ccSAndroid Build Coastguard Worker
192*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSE4_1, AV1HighbdInvHTNxN,
193*77c1e3ccSAndroid Build Coastguard Worker ::testing::ValuesIn(kArrayIhtParam));
194*77c1e3ccSAndroid Build Coastguard Worker #endif // HAVE_SSE4_1
195*77c1e3ccSAndroid Build Coastguard Worker
196*77c1e3ccSAndroid Build Coastguard Worker typedef void (*HighbdInvTxfm2dFunc)(const int32_t *input, uint8_t *output,
197*77c1e3ccSAndroid Build Coastguard Worker int stride, const TxfmParam *txfm_param);
198*77c1e3ccSAndroid Build Coastguard Worker
199*77c1e3ccSAndroid Build Coastguard Worker typedef std::tuple<const HighbdInvTxfm2dFunc> AV1HighbdInvTxfm2dParam;
200*77c1e3ccSAndroid Build Coastguard Worker class AV1HighbdInvTxfm2d
201*77c1e3ccSAndroid Build Coastguard Worker : public ::testing::TestWithParam<AV1HighbdInvTxfm2dParam> {
202*77c1e3ccSAndroid Build Coastguard Worker public:
SetUp()203*77c1e3ccSAndroid Build Coastguard Worker void SetUp() override { target_func_ = GET_PARAM(0); }
204*77c1e3ccSAndroid Build Coastguard Worker void RunAV1InvTxfm2dTest(TX_TYPE tx_type, TX_SIZE tx_size, int run_times,
205*77c1e3ccSAndroid Build Coastguard Worker int bit_depth, int gt_int16 = 0);
206*77c1e3ccSAndroid Build Coastguard Worker
207*77c1e3ccSAndroid Build Coastguard Worker private:
208*77c1e3ccSAndroid Build Coastguard Worker HighbdInvTxfm2dFunc target_func_;
209*77c1e3ccSAndroid Build Coastguard Worker };
210*77c1e3ccSAndroid Build Coastguard Worker GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AV1HighbdInvTxfm2d);
211*77c1e3ccSAndroid Build Coastguard Worker
RunAV1InvTxfm2dTest(TX_TYPE tx_type_,TX_SIZE tx_size_,int run_times,int bit_depth_,int gt_int16)212*77c1e3ccSAndroid Build Coastguard Worker void AV1HighbdInvTxfm2d::RunAV1InvTxfm2dTest(TX_TYPE tx_type_, TX_SIZE tx_size_,
213*77c1e3ccSAndroid Build Coastguard Worker int run_times, int bit_depth_,
214*77c1e3ccSAndroid Build Coastguard Worker int gt_int16) {
215*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_REALTIME_ONLY
216*77c1e3ccSAndroid Build Coastguard Worker if (tx_size_ >= TX_4X16) {
217*77c1e3ccSAndroid Build Coastguard Worker return;
218*77c1e3ccSAndroid Build Coastguard Worker }
219*77c1e3ccSAndroid Build Coastguard Worker #endif
220*77c1e3ccSAndroid Build Coastguard Worker FwdTxfm2dFunc fwd_func_ = libaom_test::fwd_txfm_func_ls[tx_size_];
221*77c1e3ccSAndroid Build Coastguard Worker TxfmParam txfm_param;
222*77c1e3ccSAndroid Build Coastguard Worker const int BLK_WIDTH = 64;
223*77c1e3ccSAndroid Build Coastguard Worker const int BLK_SIZE = BLK_WIDTH * BLK_WIDTH;
224*77c1e3ccSAndroid Build Coastguard Worker DECLARE_ALIGNED(16, int16_t, input[BLK_SIZE]) = { 0 };
225*77c1e3ccSAndroid Build Coastguard Worker DECLARE_ALIGNED(32, int32_t, inv_input[BLK_SIZE]) = { 0 };
226*77c1e3ccSAndroid Build Coastguard Worker DECLARE_ALIGNED(32, uint16_t, output[BLK_SIZE]) = { 0 };
227*77c1e3ccSAndroid Build Coastguard Worker DECLARE_ALIGNED(32, uint16_t, ref_output[BLK_SIZE]) = { 0 };
228*77c1e3ccSAndroid Build Coastguard Worker int stride = BLK_WIDTH;
229*77c1e3ccSAndroid Build Coastguard Worker int rows = tx_size_high[tx_size_];
230*77c1e3ccSAndroid Build Coastguard Worker int cols = tx_size_wide[tx_size_];
231*77c1e3ccSAndroid Build Coastguard Worker const int rows_nonezero = AOMMIN(32, rows);
232*77c1e3ccSAndroid Build Coastguard Worker const int cols_nonezero = AOMMIN(32, cols);
233*77c1e3ccSAndroid Build Coastguard Worker const uint16_t mask = (1 << bit_depth_) - 1;
234*77c1e3ccSAndroid Build Coastguard Worker run_times /= (rows * cols);
235*77c1e3ccSAndroid Build Coastguard Worker run_times = AOMMAX(1, run_times);
236*77c1e3ccSAndroid Build Coastguard Worker const SCAN_ORDER *scan_order = get_default_scan(tx_size_, tx_type_);
237*77c1e3ccSAndroid Build Coastguard Worker const int16_t *scan = scan_order->scan;
238*77c1e3ccSAndroid Build Coastguard Worker const int16_t eobmax = rows_nonezero * cols_nonezero;
239*77c1e3ccSAndroid Build Coastguard Worker ACMRandom rnd(ACMRandom::DeterministicSeed());
240*77c1e3ccSAndroid Build Coastguard Worker int randTimes = run_times == 1 ? (eobmax) : 1;
241*77c1e3ccSAndroid Build Coastguard Worker
242*77c1e3ccSAndroid Build Coastguard Worker txfm_param.tx_type = tx_type_;
243*77c1e3ccSAndroid Build Coastguard Worker txfm_param.tx_size = tx_size_;
244*77c1e3ccSAndroid Build Coastguard Worker txfm_param.lossless = 0;
245*77c1e3ccSAndroid Build Coastguard Worker txfm_param.bd = bit_depth_;
246*77c1e3ccSAndroid Build Coastguard Worker txfm_param.is_hbd = 1;
247*77c1e3ccSAndroid Build Coastguard Worker txfm_param.tx_set_type = EXT_TX_SET_ALL16;
248*77c1e3ccSAndroid Build Coastguard Worker
249*77c1e3ccSAndroid Build Coastguard Worker for (int cnt = 0; cnt < randTimes; ++cnt) {
250*77c1e3ccSAndroid Build Coastguard Worker for (int r = 0; r < BLK_WIDTH; ++r) {
251*77c1e3ccSAndroid Build Coastguard Worker for (int c = 0; c < BLK_WIDTH; ++c) {
252*77c1e3ccSAndroid Build Coastguard Worker input[r * cols + c] = (rnd.Rand16() & mask) - (rnd.Rand16() & mask);
253*77c1e3ccSAndroid Build Coastguard Worker output[r * stride + c] = rnd.Rand16() & mask;
254*77c1e3ccSAndroid Build Coastguard Worker
255*77c1e3ccSAndroid Build Coastguard Worker ref_output[r * stride + c] = output[r * stride + c];
256*77c1e3ccSAndroid Build Coastguard Worker }
257*77c1e3ccSAndroid Build Coastguard Worker }
258*77c1e3ccSAndroid Build Coastguard Worker fwd_func_(input, inv_input, stride, tx_type_, bit_depth_);
259*77c1e3ccSAndroid Build Coastguard Worker
260*77c1e3ccSAndroid Build Coastguard Worker // produce eob input by setting high freq coeffs to zero
261*77c1e3ccSAndroid Build Coastguard Worker const int eob = AOMMIN(cnt + 1, eobmax);
262*77c1e3ccSAndroid Build Coastguard Worker for (int i = eob; i < eobmax; i++) {
263*77c1e3ccSAndroid Build Coastguard Worker inv_input[scan[i]] = 0;
264*77c1e3ccSAndroid Build Coastguard Worker }
265*77c1e3ccSAndroid Build Coastguard Worker txfm_param.eob = eob;
266*77c1e3ccSAndroid Build Coastguard Worker if (gt_int16) {
267*77c1e3ccSAndroid Build Coastguard Worker const uint16_t inv_input_mask =
268*77c1e3ccSAndroid Build Coastguard Worker static_cast<uint16_t>((1 << (bit_depth_ + 7)) - 1);
269*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < eob; i++) {
270*77c1e3ccSAndroid Build Coastguard Worker inv_input[scan[i]] = (rnd.Rand31() & inv_input_mask);
271*77c1e3ccSAndroid Build Coastguard Worker }
272*77c1e3ccSAndroid Build Coastguard Worker }
273*77c1e3ccSAndroid Build Coastguard Worker
274*77c1e3ccSAndroid Build Coastguard Worker aom_usec_timer ref_timer, test_timer;
275*77c1e3ccSAndroid Build Coastguard Worker aom_usec_timer_start(&ref_timer);
276*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < run_times; ++i) {
277*77c1e3ccSAndroid Build Coastguard Worker av1_highbd_inv_txfm_add_c(inv_input, CONVERT_TO_BYTEPTR(ref_output),
278*77c1e3ccSAndroid Build Coastguard Worker stride, &txfm_param);
279*77c1e3ccSAndroid Build Coastguard Worker }
280*77c1e3ccSAndroid Build Coastguard Worker aom_usec_timer_mark(&ref_timer);
281*77c1e3ccSAndroid Build Coastguard Worker const int elapsed_time_c =
282*77c1e3ccSAndroid Build Coastguard Worker static_cast<int>(aom_usec_timer_elapsed(&ref_timer));
283*77c1e3ccSAndroid Build Coastguard Worker
284*77c1e3ccSAndroid Build Coastguard Worker aom_usec_timer_start(&test_timer);
285*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < run_times; ++i) {
286*77c1e3ccSAndroid Build Coastguard Worker target_func_(inv_input, CONVERT_TO_BYTEPTR(output), stride, &txfm_param);
287*77c1e3ccSAndroid Build Coastguard Worker }
288*77c1e3ccSAndroid Build Coastguard Worker aom_usec_timer_mark(&test_timer);
289*77c1e3ccSAndroid Build Coastguard Worker const int elapsed_time_simd =
290*77c1e3ccSAndroid Build Coastguard Worker static_cast<int>(aom_usec_timer_elapsed(&test_timer));
291*77c1e3ccSAndroid Build Coastguard Worker if (run_times > 10) {
292*77c1e3ccSAndroid Build Coastguard Worker printf(
293*77c1e3ccSAndroid Build Coastguard Worker "txfm_size[%d] \t txfm_type[%d] \t c_time=%d \t simd_time=%d \t "
294*77c1e3ccSAndroid Build Coastguard Worker "gain=%d \n",
295*77c1e3ccSAndroid Build Coastguard Worker tx_size_, tx_type_, elapsed_time_c, elapsed_time_simd,
296*77c1e3ccSAndroid Build Coastguard Worker (elapsed_time_c / elapsed_time_simd));
297*77c1e3ccSAndroid Build Coastguard Worker } else {
298*77c1e3ccSAndroid Build Coastguard Worker for (int r = 0; r < rows; ++r) {
299*77c1e3ccSAndroid Build Coastguard Worker for (int c = 0; c < cols; ++c) {
300*77c1e3ccSAndroid Build Coastguard Worker ASSERT_EQ(ref_output[r * stride + c], output[r * stride + c])
301*77c1e3ccSAndroid Build Coastguard Worker << "[" << r << "," << c << "] " << cnt << " tx_size: " << cols
302*77c1e3ccSAndroid Build Coastguard Worker << "x" << rows << " bit_depth_: " << bit_depth_
303*77c1e3ccSAndroid Build Coastguard Worker << " tx_type: " << tx_type_name[tx_type_] << " eob " << eob;
304*77c1e3ccSAndroid Build Coastguard Worker }
305*77c1e3ccSAndroid Build Coastguard Worker }
306*77c1e3ccSAndroid Build Coastguard Worker }
307*77c1e3ccSAndroid Build Coastguard Worker }
308*77c1e3ccSAndroid Build Coastguard Worker }
309*77c1e3ccSAndroid Build Coastguard Worker
TEST_P(AV1HighbdInvTxfm2d,match)310*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1HighbdInvTxfm2d, match) {
311*77c1e3ccSAndroid Build Coastguard Worker int bitdepth_ar[3] = { 8, 10, 12 };
312*77c1e3ccSAndroid Build Coastguard Worker for (int k = 0; k < 3; ++k) {
313*77c1e3ccSAndroid Build Coastguard Worker int bd = bitdepth_ar[k];
314*77c1e3ccSAndroid Build Coastguard Worker for (int j = 0; j < (int)(TX_SIZES_ALL); ++j) {
315*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < (int)TX_TYPES; ++i) {
316*77c1e3ccSAndroid Build Coastguard Worker if (libaom_test::IsTxSizeTypeValid(static_cast<TX_SIZE>(j),
317*77c1e3ccSAndroid Build Coastguard Worker static_cast<TX_TYPE>(i))) {
318*77c1e3ccSAndroid Build Coastguard Worker RunAV1InvTxfm2dTest(static_cast<TX_TYPE>(i), static_cast<TX_SIZE>(j),
319*77c1e3ccSAndroid Build Coastguard Worker 1, bd);
320*77c1e3ccSAndroid Build Coastguard Worker }
321*77c1e3ccSAndroid Build Coastguard Worker }
322*77c1e3ccSAndroid Build Coastguard Worker }
323*77c1e3ccSAndroid Build Coastguard Worker }
324*77c1e3ccSAndroid Build Coastguard Worker }
325*77c1e3ccSAndroid Build Coastguard Worker
TEST_P(AV1HighbdInvTxfm2d,gt_int16)326*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1HighbdInvTxfm2d, gt_int16) {
327*77c1e3ccSAndroid Build Coastguard Worker int bitdepth_ar[3] = { 8, 10, 12 };
328*77c1e3ccSAndroid Build Coastguard Worker static const TX_TYPE types[] = {
329*77c1e3ccSAndroid Build Coastguard Worker DCT_DCT, ADST_DCT, FLIPADST_DCT, IDTX, V_DCT, H_DCT, H_ADST, H_FLIPADST
330*77c1e3ccSAndroid Build Coastguard Worker };
331*77c1e3ccSAndroid Build Coastguard Worker for (int k = 0; k < 3; ++k) {
332*77c1e3ccSAndroid Build Coastguard Worker int bd = bitdepth_ar[k];
333*77c1e3ccSAndroid Build Coastguard Worker for (int j = 0; j < (int)(TX_SIZES_ALL); ++j) {
334*77c1e3ccSAndroid Build Coastguard Worker const TX_SIZE sz = static_cast<TX_SIZE>(j);
335*77c1e3ccSAndroid Build Coastguard Worker for (uint8_t i = 0; i < sizeof(types) / sizeof(TX_TYPE); ++i) {
336*77c1e3ccSAndroid Build Coastguard Worker const TX_TYPE tp = types[i];
337*77c1e3ccSAndroid Build Coastguard Worker if (libaom_test::IsTxSizeTypeValid(sz, tp)) {
338*77c1e3ccSAndroid Build Coastguard Worker RunAV1InvTxfm2dTest(tp, sz, 1, bd, 1);
339*77c1e3ccSAndroid Build Coastguard Worker }
340*77c1e3ccSAndroid Build Coastguard Worker }
341*77c1e3ccSAndroid Build Coastguard Worker }
342*77c1e3ccSAndroid Build Coastguard Worker }
343*77c1e3ccSAndroid Build Coastguard Worker }
344*77c1e3ccSAndroid Build Coastguard Worker
TEST_P(AV1HighbdInvTxfm2d,DISABLED_Speed)345*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1HighbdInvTxfm2d, DISABLED_Speed) {
346*77c1e3ccSAndroid Build Coastguard Worker int bitdepth_ar[2] = { 10, 12 };
347*77c1e3ccSAndroid Build Coastguard Worker for (int k = 0; k < 2; ++k) {
348*77c1e3ccSAndroid Build Coastguard Worker int bd = bitdepth_ar[k];
349*77c1e3ccSAndroid Build Coastguard Worker for (int j = 0; j < (int)(TX_SIZES_ALL); ++j) {
350*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < (int)TX_TYPES; ++i) {
351*77c1e3ccSAndroid Build Coastguard Worker if (libaom_test::IsTxSizeTypeValid(static_cast<TX_SIZE>(j),
352*77c1e3ccSAndroid Build Coastguard Worker static_cast<TX_TYPE>(i))) {
353*77c1e3ccSAndroid Build Coastguard Worker RunAV1InvTxfm2dTest(static_cast<TX_TYPE>(i), static_cast<TX_SIZE>(j),
354*77c1e3ccSAndroid Build Coastguard Worker 1000000, bd);
355*77c1e3ccSAndroid Build Coastguard Worker }
356*77c1e3ccSAndroid Build Coastguard Worker }
357*77c1e3ccSAndroid Build Coastguard Worker }
358*77c1e3ccSAndroid Build Coastguard Worker }
359*77c1e3ccSAndroid Build Coastguard Worker }
360*77c1e3ccSAndroid Build Coastguard Worker
361*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE4_1
362*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSE4_1, AV1HighbdInvTxfm2d,
363*77c1e3ccSAndroid Build Coastguard Worker ::testing::Values(av1_highbd_inv_txfm_add_sse4_1));
364*77c1e3ccSAndroid Build Coastguard Worker #endif
365*77c1e3ccSAndroid Build Coastguard Worker
366*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
367*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(AVX2, AV1HighbdInvTxfm2d,
368*77c1e3ccSAndroid Build Coastguard Worker ::testing::Values(av1_highbd_inv_txfm_add_avx2));
369*77c1e3ccSAndroid Build Coastguard Worker #endif
370*77c1e3ccSAndroid Build Coastguard Worker
371*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
372*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, AV1HighbdInvTxfm2d,
373*77c1e3ccSAndroid Build Coastguard Worker ::testing::Values(av1_highbd_inv_txfm_add_neon));
374*77c1e3ccSAndroid Build Coastguard Worker #endif
375*77c1e3ccSAndroid Build Coastguard Worker
376*77c1e3ccSAndroid Build Coastguard Worker } // namespace
377