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