• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020, 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 <math.h>
13 #include <stdlib.h>
14 #include <string.h>
15 #include <tuple>
16 
17 #include "aom_dsp/aom_dsp_common.h"
18 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
19 
20 #include "config/av1_rtcd.h"
21 #include "config/aom_dsp_rtcd.h"
22 #include "test/acm_random.h"
23 #include "test/register_state_check.h"
24 #include "test/transform_test_base.h"
25 #include "test/util.h"
26 #include "av1/common/entropy.h"
27 #include "aom/aom_codec.h"
28 #include "aom/aom_integer.h"
29 #include "aom_ports/mem.h"
30 
31 using libaom_test::ACMRandom;
32 
33 namespace {
34 
35 template <typename OutputType>
36 using FdctFunc = void (*)(const int16_t *in, OutputType *out, int stride);
37 
38 template <typename OutputType>
39 using FhtFunc = void (*)(const int16_t *in, OutputType *out, int stride,
40                          TxfmParam *txfm_param);
41 
42 template <typename OutputType>
43 using Fdct4x4Param =
44     std::tuple<FdctFunc<OutputType>, FhtFunc<OutputType>, aom_bit_depth_t, int>;
45 
46 #if HAVE_NEON || HAVE_SSE2
fdct4x4_ref(const int16_t * in,tran_low_t * out,int stride,TxfmParam *)47 void fdct4x4_ref(const int16_t *in, tran_low_t *out, int stride,
48                  TxfmParam * /*txfm_param*/) {
49   aom_fdct4x4_c(in, out, stride);
50 }
51 
fdct4x4_lp_ref(const int16_t * in,int16_t * out,int stride,TxfmParam *)52 void fdct4x4_lp_ref(const int16_t *in, int16_t *out, int stride,
53                     TxfmParam * /*txfm_param*/) {
54   aom_fdct4x4_lp_c(in, out, stride);
55 }
56 #endif
57 
58 template <typename OutputType>
59 class Trans4x4FDCT : public libaom_test::TransformTestBase<OutputType>,
60                      public ::testing::TestWithParam<Fdct4x4Param<OutputType>> {
61  public:
~Trans4x4FDCT()62   virtual ~Trans4x4FDCT() {}
63 
64   using TxfmBaseOutType = libaom_test::TransformTestBase<OutputType>;
SetUp()65   virtual void SetUp() {
66     fwd_txfm_ = std::get<0>(this->GetParam());
67     TxfmBaseOutType::pitch_ = 4;
68     TxfmBaseOutType::height_ = 4;
69     TxfmBaseOutType::fwd_txfm_ref = std::get<1>(this->GetParam());
70     TxfmBaseOutType::bit_depth_ = std::get<2>(this->GetParam());
71     TxfmBaseOutType::mask_ = (1 << TxfmBaseOutType::bit_depth_) - 1;
72     TxfmBaseOutType::num_coeffs_ = std::get<3>(this->GetParam());
73   }
TearDown()74   virtual void TearDown() {}
75 
76  protected:
RunFwdTxfm(const int16_t * in,OutputType * out,int stride)77   void RunFwdTxfm(const int16_t *in, OutputType *out, int stride) {
78     fwd_txfm_(in, out, stride);
79   }
80 
RunInvTxfm(const OutputType * out,uint8_t * dst,int stride)81   void RunInvTxfm(const OutputType *out, uint8_t *dst, int stride) {
82     (void)out;
83     (void)dst;
84     (void)stride;
85   }
86 
87   FdctFunc<OutputType> fwd_txfm_;
88 };
89 
90 using Trans4x4FDCTTranLow = Trans4x4FDCT<tran_low_t>;
91 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(Trans4x4FDCTTranLow);
TEST_P(Trans4x4FDCTTranLow,CoeffCheck)92 TEST_P(Trans4x4FDCTTranLow, CoeffCheck) { RunCoeffCheck(); }
TEST_P(Trans4x4FDCTTranLow,MemCheck)93 TEST_P(Trans4x4FDCTTranLow, MemCheck) { RunMemCheck(); }
94 
95 using Trans4x4FDCTInt16 = Trans4x4FDCT<int16_t>;
96 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(Trans4x4FDCTInt16);
TEST_P(Trans4x4FDCTInt16,CoeffCheck)97 TEST_P(Trans4x4FDCTInt16, CoeffCheck) { RunCoeffCheck(); }
TEST_P(Trans4x4FDCTInt16,MemCheck)98 TEST_P(Trans4x4FDCTInt16, MemCheck) { RunMemCheck(); }
99 
100 using std::make_tuple;
101 
102 #if HAVE_NEON
103 INSTANTIATE_TEST_SUITE_P(NEON, Trans4x4FDCTTranLow,
104                          ::testing::Values(make_tuple(&aom_fdct4x4_neon,
105                                                       &fdct4x4_ref, AOM_BITS_8,
106                                                       16)));
107 
108 INSTANTIATE_TEST_SUITE_P(NEON, Trans4x4FDCTInt16,
109                          ::testing::Values(make_tuple(&aom_fdct4x4_lp_neon,
110                                                       &fdct4x4_lp_ref,
111                                                       AOM_BITS_8, 16)));
112 #endif
113 
114 #if HAVE_SSE2
115 INSTANTIATE_TEST_SUITE_P(SSE2, Trans4x4FDCTTranLow,
116                          ::testing::Values(make_tuple(&aom_fdct4x4_sse2,
117                                                       &fdct4x4_ref, AOM_BITS_8,
118                                                       16)));
119 
120 INSTANTIATE_TEST_SUITE_P(SSE2, Trans4x4FDCTInt16,
121                          ::testing::Values(make_tuple(&aom_fdct4x4_lp_sse2,
122                                                       &fdct4x4_lp_ref,
123                                                       AOM_BITS_8, 16)));
124 #endif
125 }  // namespace
126