fdct4x4_test.cc (4390B)
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 "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 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 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: 62 ~Trans4x4FDCT() override = default; 63 64 using TxfmBaseOutType = libaom_test::TransformTestBase<OutputType>; 65 void SetUp() override { 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 } 74 75 protected: 76 void RunFwdTxfm(const int16_t *in, OutputType *out, int stride) override { 77 fwd_txfm_(in, out, stride); 78 } 79 80 void RunInvTxfm(const OutputType *out, uint8_t *dst, int stride) override { 81 (void)out; 82 (void)dst; 83 (void)stride; 84 } 85 86 FdctFunc<OutputType> fwd_txfm_; 87 }; 88 89 using Trans4x4FDCTTranLow = Trans4x4FDCT<tran_low_t>; 90 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(Trans4x4FDCTTranLow); 91 TEST_P(Trans4x4FDCTTranLow, CoeffCheck) { RunCoeffCheck(); } 92 TEST_P(Trans4x4FDCTTranLow, MemCheck) { RunMemCheck(); } 93 94 using Trans4x4FDCTInt16 = Trans4x4FDCT<int16_t>; 95 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(Trans4x4FDCTInt16); 96 TEST_P(Trans4x4FDCTInt16, CoeffCheck) { RunCoeffCheck(); } 97 TEST_P(Trans4x4FDCTInt16, MemCheck) { RunMemCheck(); } 98 99 using std::make_tuple; 100 101 #if HAVE_NEON 102 INSTANTIATE_TEST_SUITE_P(NEON, Trans4x4FDCTTranLow, 103 ::testing::Values(make_tuple(&aom_fdct4x4_neon, 104 &fdct4x4_ref, AOM_BITS_8, 105 16))); 106 107 INSTANTIATE_TEST_SUITE_P(NEON, Trans4x4FDCTInt16, 108 ::testing::Values(make_tuple(&aom_fdct4x4_lp_neon, 109 &fdct4x4_lp_ref, 110 AOM_BITS_8, 16))); 111 #endif 112 113 #if HAVE_SSE2 114 INSTANTIATE_TEST_SUITE_P(SSE2, Trans4x4FDCTTranLow, 115 ::testing::Values(make_tuple(&aom_fdct4x4_sse2, 116 &fdct4x4_ref, AOM_BITS_8, 117 16))); 118 119 INSTANTIATE_TEST_SUITE_P(SSE2, Trans4x4FDCTInt16, 120 ::testing::Values(make_tuple(&aom_fdct4x4_lp_sse2, 121 &fdct4x4_lp_ref, 122 AOM_BITS_8, 16))); 123 #endif 124 } // namespace