1 /*
2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3  *
4  * 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  */
11 
12 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
13 
14 #include "./aom_dsp_rtcd.h"
15 #include "./av1_rtcd.h"
16 
17 #include "aom_ports/mem.h"
18 #include "test/acm_random.h"
19 #include "test/clear_system_state.h"
20 #include "test/register_state_check.h"
21 #include "test/transform_test_base.h"
22 #include "test/util.h"
23 
24 using libaom_test::ACMRandom;
25 
26 namespace {
27 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
28                         const TxfmParam *txfm_param);
29 using std::tr1::tuple;
30 using libaom_test::FhtFunc;
31 typedef tuple<FhtFunc, IhtFunc, TX_TYPE, aom_bit_depth_t, int> Ht16x32Param;
32 
fht16x32_ref(const int16_t * in,tran_low_t * out,int stride,TxfmParam * txfm_param)33 void fht16x32_ref(const int16_t *in, tran_low_t *out, int stride,
34                   TxfmParam *txfm_param) {
35   av1_fht16x32_c(in, out, stride, txfm_param);
36 }
37 
iht16x32_ref(const tran_low_t * in,uint8_t * out,int stride,const TxfmParam * txfm_param)38 void iht16x32_ref(const tran_low_t *in, uint8_t *out, int stride,
39                   const TxfmParam *txfm_param) {
40   av1_iht16x32_512_add_c(in, out, stride, txfm_param);
41 }
42 
43 class AV1Trans16x32HT : public libaom_test::TransformTestBase,
44                         public ::testing::TestWithParam<Ht16x32Param> {
45  public:
~AV1Trans16x32HT()46   virtual ~AV1Trans16x32HT() {}
47 
SetUp()48   virtual void SetUp() {
49     fwd_txfm_ = GET_PARAM(0);
50     inv_txfm_ = GET_PARAM(1);
51     pitch_ = 16;
52     height_ = 32;
53     fwd_txfm_ref = fht16x32_ref;
54     inv_txfm_ref = iht16x32_ref;
55     bit_depth_ = GET_PARAM(3);
56     mask_ = (1 << bit_depth_) - 1;
57     num_coeffs_ = GET_PARAM(4);
58     txfm_param_.tx_type = GET_PARAM(2);
59   }
TearDown()60   virtual void TearDown() { libaom_test::ClearSystemState(); }
61 
62  protected:
RunFwdTxfm(const int16_t * in,tran_low_t * out,int stride)63   void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
64     fwd_txfm_(in, out, stride, &txfm_param_);
65   }
66 
RunInvTxfm(const tran_low_t * out,uint8_t * dst,int stride)67   void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
68     inv_txfm_(out, dst, stride, &txfm_param_);
69   }
70 
71   FhtFunc fwd_txfm_;
72   IhtFunc inv_txfm_;
73 };
74 
TEST_P(AV1Trans16x32HT,AccuracyCheck)75 TEST_P(AV1Trans16x32HT, AccuracyCheck) { RunAccuracyCheck(4, 0.2); }
TEST_P(AV1Trans16x32HT,CoeffCheck)76 TEST_P(AV1Trans16x32HT, CoeffCheck) { RunCoeffCheck(); }
TEST_P(AV1Trans16x32HT,MemCheck)77 TEST_P(AV1Trans16x32HT, MemCheck) { RunMemCheck(); }
TEST_P(AV1Trans16x32HT,InvCoeffCheck)78 TEST_P(AV1Trans16x32HT, InvCoeffCheck) { RunInvCoeffCheck(); }
TEST_P(AV1Trans16x32HT,InvAccuracyCheck)79 TEST_P(AV1Trans16x32HT, InvAccuracyCheck) { RunInvAccuracyCheck(4); }
80 
81 using std::tr1::make_tuple;
82 const Ht16x32Param kArrayHt16x32Param_c[] = {
83   make_tuple(&av1_fht16x32_c, &av1_iht16x32_512_add_c, DCT_DCT, AOM_BITS_8,
84              512),
85   make_tuple(&av1_fht16x32_c, &av1_iht16x32_512_add_c, ADST_DCT, AOM_BITS_8,
86              512),
87   make_tuple(&av1_fht16x32_c, &av1_iht16x32_512_add_c, DCT_ADST, AOM_BITS_8,
88              512),
89   make_tuple(&av1_fht16x32_c, &av1_iht16x32_512_add_c, ADST_ADST, AOM_BITS_8,
90              512),
91 #if CONFIG_EXT_TX
92   make_tuple(&av1_fht16x32_c, &av1_iht16x32_512_add_c, FLIPADST_DCT, AOM_BITS_8,
93              512),
94   make_tuple(&av1_fht16x32_c, &av1_iht16x32_512_add_c, DCT_FLIPADST, AOM_BITS_8,
95              512),
96   make_tuple(&av1_fht16x32_c, &av1_iht16x32_512_add_c, FLIPADST_FLIPADST,
97              AOM_BITS_8, 512),
98   make_tuple(&av1_fht16x32_c, &av1_iht16x32_512_add_c, ADST_FLIPADST,
99              AOM_BITS_8, 512),
100   make_tuple(&av1_fht16x32_c, &av1_iht16x32_512_add_c, FLIPADST_ADST,
101              AOM_BITS_8, 512),
102   make_tuple(&av1_fht16x32_c, &av1_iht16x32_512_add_c, IDTX, AOM_BITS_8, 512),
103   make_tuple(&av1_fht16x32_c, &av1_iht16x32_512_add_c, V_DCT, AOM_BITS_8, 512),
104   make_tuple(&av1_fht16x32_c, &av1_iht16x32_512_add_c, H_DCT, AOM_BITS_8, 512),
105   make_tuple(&av1_fht16x32_c, &av1_iht16x32_512_add_c, V_ADST, AOM_BITS_8, 512),
106   make_tuple(&av1_fht16x32_c, &av1_iht16x32_512_add_c, H_ADST, AOM_BITS_8, 512),
107   make_tuple(&av1_fht16x32_c, &av1_iht16x32_512_add_c, V_FLIPADST, AOM_BITS_8,
108              512),
109   make_tuple(&av1_fht16x32_c, &av1_iht16x32_512_add_c, H_FLIPADST, AOM_BITS_8,
110              512)
111 #endif  // CONFIG_EXT_TX
112 };
113 INSTANTIATE_TEST_CASE_P(C, AV1Trans16x32HT,
114                         ::testing::ValuesIn(kArrayHt16x32Param_c));
115 
116 #if HAVE_SSE2
117 const Ht16x32Param kArrayHt16x32Param_sse2[] = {
118   make_tuple(&av1_fht16x32_sse2, &av1_iht16x32_512_add_sse2, DCT_DCT,
119              AOM_BITS_8, 512),
120   make_tuple(&av1_fht16x32_sse2, &av1_iht16x32_512_add_sse2, ADST_DCT,
121              AOM_BITS_8, 512),
122   make_tuple(&av1_fht16x32_sse2, &av1_iht16x32_512_add_sse2, DCT_ADST,
123              AOM_BITS_8, 512),
124   make_tuple(&av1_fht16x32_sse2, &av1_iht16x32_512_add_sse2, ADST_ADST,
125              AOM_BITS_8, 512),
126 #if CONFIG_EXT_TX
127   make_tuple(&av1_fht16x32_sse2, &av1_iht16x32_512_add_sse2, FLIPADST_DCT,
128              AOM_BITS_8, 512),
129   make_tuple(&av1_fht16x32_sse2, &av1_iht16x32_512_add_sse2, DCT_FLIPADST,
130              AOM_BITS_8, 512),
131   make_tuple(&av1_fht16x32_sse2, &av1_iht16x32_512_add_sse2, FLIPADST_FLIPADST,
132              AOM_BITS_8, 512),
133   make_tuple(&av1_fht16x32_sse2, &av1_iht16x32_512_add_sse2, ADST_FLIPADST,
134              AOM_BITS_8, 512),
135   make_tuple(&av1_fht16x32_sse2, &av1_iht16x32_512_add_sse2, FLIPADST_ADST,
136              AOM_BITS_8, 512),
137   make_tuple(&av1_fht16x32_sse2, &av1_iht16x32_512_add_sse2, IDTX, AOM_BITS_8,
138              512),
139   make_tuple(&av1_fht16x32_sse2, &av1_iht16x32_512_add_sse2, V_DCT, AOM_BITS_8,
140              512),
141   make_tuple(&av1_fht16x32_sse2, &av1_iht16x32_512_add_sse2, H_DCT, AOM_BITS_8,
142              512),
143   make_tuple(&av1_fht16x32_sse2, &av1_iht16x32_512_add_sse2, V_ADST, AOM_BITS_8,
144              512),
145   make_tuple(&av1_fht16x32_sse2, &av1_iht16x32_512_add_sse2, H_ADST, AOM_BITS_8,
146              512),
147   make_tuple(&av1_fht16x32_sse2, &av1_iht16x32_512_add_sse2, V_FLIPADST,
148              AOM_BITS_8, 512),
149   make_tuple(&av1_fht16x32_sse2, &av1_iht16x32_512_add_sse2, H_FLIPADST,
150              AOM_BITS_8, 512)
151 #endif  // CONFIG_EXT_TX
152 };
153 INSTANTIATE_TEST_CASE_P(SSE2, AV1Trans16x32HT,
154                         ::testing::ValuesIn(kArrayHt16x32Param_sse2));
155 #endif  // HAVE_SSE2
156 
157 }  // namespace
158