Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | bde4ac8 | 2016-11-28 15:26:06 -0800 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | bde4ac8 | 2016-11-28 15:26:06 -0800 | [diff] [blame] | 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. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
Tom Finegan | 7a07ece | 2017-02-07 17:14:05 -0800 | [diff] [blame] | 12 | #include "third_party/googletest/src/googletest/include/gtest/gtest.h" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 13 | |
| 14 | #include "./av1_rtcd.h" |
| 15 | #include "./aom_dsp_rtcd.h" |
| 16 | |
| 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 | #include "aom_ports/mem.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 | int tx_type); |
| 29 | using std::tr1::tuple; |
| 30 | using libaom_test::FhtFunc; |
| 31 | typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht16x16Param; |
| 32 | |
| 33 | void fht16x16_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) { |
| 34 | av1_fht16x16_c(in, out, stride, tx_type); |
| 35 | } |
| 36 | |
Yi Luo | 7317200 | 2016-10-28 10:52:04 -0700 | [diff] [blame] | 37 | void iht16x16_ref(const tran_low_t *in, uint8_t *dest, int stride, |
| 38 | int tx_type) { |
| 39 | av1_iht16x16_256_add_c(in, dest, stride, tx_type); |
| 40 | } |
| 41 | |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 42 | #if CONFIG_HIGHBITDEPTH |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 43 | typedef void (*IHbdHtFunc)(const tran_low_t *in, uint8_t *out, int stride, |
| 44 | int tx_type, int bd); |
| 45 | typedef void (*HbdHtFunc)(const int16_t *input, int32_t *output, int stride, |
| 46 | int tx_type, int bd); |
| 47 | |
| 48 | // Target optimized function, tx_type, bit depth |
| 49 | typedef tuple<HbdHtFunc, int, int> HighbdHt16x16Param; |
| 50 | |
| 51 | void highbd_fht16x16_ref(const int16_t *in, int32_t *out, int stride, |
| 52 | int tx_type, int bd) { |
| 53 | av1_fwd_txfm2d_16x16_c(in, out, stride, tx_type, bd); |
| 54 | } |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 55 | #endif // CONFIG_HIGHBITDEPTH |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 56 | |
| 57 | class AV1Trans16x16HT : public libaom_test::TransformTestBase, |
| 58 | public ::testing::TestWithParam<Ht16x16Param> { |
| 59 | public: |
| 60 | virtual ~AV1Trans16x16HT() {} |
| 61 | |
| 62 | virtual void SetUp() { |
| 63 | fwd_txfm_ = GET_PARAM(0); |
| 64 | inv_txfm_ = GET_PARAM(1); |
| 65 | tx_type_ = GET_PARAM(2); |
| 66 | pitch_ = 16; |
David Barker | 7825022 | 2016-10-13 15:10:14 +0100 | [diff] [blame] | 67 | height_ = 16; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 68 | fwd_txfm_ref = fht16x16_ref; |
Yi Luo | 7317200 | 2016-10-28 10:52:04 -0700 | [diff] [blame] | 69 | inv_txfm_ref = iht16x16_ref; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 70 | bit_depth_ = GET_PARAM(3); |
| 71 | mask_ = (1 << bit_depth_) - 1; |
| 72 | num_coeffs_ = GET_PARAM(4); |
| 73 | } |
| 74 | virtual void TearDown() { libaom_test::ClearSystemState(); } |
| 75 | |
| 76 | protected: |
| 77 | void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) { |
| 78 | fwd_txfm_(in, out, stride, tx_type_); |
| 79 | } |
| 80 | |
| 81 | void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) { |
| 82 | inv_txfm_(out, dst, stride, tx_type_); |
| 83 | } |
| 84 | |
| 85 | FhtFunc fwd_txfm_; |
| 86 | IhtFunc inv_txfm_; |
| 87 | }; |
| 88 | |
Yi Luo | 8245b9a | 2016-11-17 14:56:43 -0800 | [diff] [blame] | 89 | TEST_P(AV1Trans16x16HT, MemCheck) { RunMemCheck(); } |
Angie Chiang | e6aece8 | 2017-01-09 17:27:56 -0800 | [diff] [blame] | 90 | TEST_P(AV1Trans16x16HT, AccuracyCheck) { RunAccuracyCheck(1, 0.001); } |
Yi Luo | 8245b9a | 2016-11-17 14:56:43 -0800 | [diff] [blame] | 91 | TEST_P(AV1Trans16x16HT, InvAccuracyCheck) { RunInvAccuracyCheck(1); } |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 92 | TEST_P(AV1Trans16x16HT, CoeffCheck) { RunCoeffCheck(); } |
Yi Luo | 7317200 | 2016-10-28 10:52:04 -0700 | [diff] [blame] | 93 | TEST_P(AV1Trans16x16HT, InvCoeffCheck) { RunInvCoeffCheck(); } |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 94 | |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 95 | #if CONFIG_HIGHBITDEPTH |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 96 | class AV1HighbdTrans16x16HT |
| 97 | : public ::testing::TestWithParam<HighbdHt16x16Param> { |
| 98 | public: |
| 99 | virtual ~AV1HighbdTrans16x16HT() {} |
| 100 | |
| 101 | virtual void SetUp() { |
| 102 | fwd_txfm_ = GET_PARAM(0); |
| 103 | fwd_txfm_ref_ = highbd_fht16x16_ref; |
| 104 | tx_type_ = GET_PARAM(1); |
| 105 | bit_depth_ = GET_PARAM(2); |
| 106 | mask_ = (1 << bit_depth_) - 1; |
| 107 | num_coeffs_ = 256; |
| 108 | |
| 109 | input_ = reinterpret_cast<int16_t *>( |
Yi Luo | e8e8cd8 | 2016-09-21 10:45:01 -0700 | [diff] [blame] | 110 | aom_memalign(32, sizeof(int16_t) * num_coeffs_)); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 111 | output_ = reinterpret_cast<int32_t *>( |
Yi Luo | e8e8cd8 | 2016-09-21 10:45:01 -0700 | [diff] [blame] | 112 | aom_memalign(32, sizeof(int32_t) * num_coeffs_)); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 113 | output_ref_ = reinterpret_cast<int32_t *>( |
Yi Luo | e8e8cd8 | 2016-09-21 10:45:01 -0700 | [diff] [blame] | 114 | aom_memalign(32, sizeof(int32_t) * num_coeffs_)); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | virtual void TearDown() { |
| 118 | aom_free(input_); |
| 119 | aom_free(output_); |
| 120 | aom_free(output_ref_); |
| 121 | libaom_test::ClearSystemState(); |
| 122 | } |
| 123 | |
| 124 | protected: |
| 125 | void RunBitexactCheck(); |
| 126 | |
| 127 | private: |
| 128 | HbdHtFunc fwd_txfm_; |
| 129 | HbdHtFunc fwd_txfm_ref_; |
| 130 | int tx_type_; |
| 131 | int bit_depth_; |
| 132 | int mask_; |
| 133 | int num_coeffs_; |
| 134 | int16_t *input_; |
| 135 | int32_t *output_; |
| 136 | int32_t *output_ref_; |
| 137 | }; |
| 138 | |
| 139 | void AV1HighbdTrans16x16HT::RunBitexactCheck() { |
| 140 | ACMRandom rnd(ACMRandom::DeterministicSeed()); |
| 141 | int i, j; |
| 142 | const int stride = 16; |
| 143 | const int num_tests = 1000; |
| 144 | |
| 145 | for (i = 0; i < num_tests; ++i) { |
| 146 | for (j = 0; j < num_coeffs_; ++j) { |
| 147 | input_[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_); |
| 148 | } |
| 149 | |
| 150 | fwd_txfm_ref_(input_, output_ref_, stride, tx_type_, bit_depth_); |
| 151 | ASM_REGISTER_STATE_CHECK( |
| 152 | fwd_txfm_(input_, output_, stride, tx_type_, bit_depth_)); |
| 153 | |
| 154 | for (j = 0; j < num_coeffs_; ++j) { |
| 155 | EXPECT_EQ(output_ref_[j], output_[j]) |
| 156 | << "Not bit-exact result at index: " << j << " at test block: " << i; |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | TEST_P(AV1HighbdTrans16x16HT, HighbdCoeffCheck) { RunBitexactCheck(); } |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 162 | #endif // CONFIG_HIGHBITDEPTH |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 163 | |
| 164 | using std::tr1::make_tuple; |
| 165 | |
Sebastien Alaiwan | c6a48a2 | 2017-04-20 10:12:43 +0200 | [diff] [blame] | 166 | #if HAVE_SSE2 |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 167 | const Ht16x16Param kArrayHt16x16Param_sse2[] = { |
| 168 | make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 0, AOM_BITS_8, |
| 169 | 256), |
| 170 | make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 1, AOM_BITS_8, |
| 171 | 256), |
| 172 | make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 2, AOM_BITS_8, |
| 173 | 256), |
| 174 | make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 3, AOM_BITS_8, |
| 175 | 256), |
| 176 | #if CONFIG_EXT_TX |
| 177 | make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 4, AOM_BITS_8, |
| 178 | 256), |
| 179 | make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 5, AOM_BITS_8, |
| 180 | 256), |
| 181 | make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 6, AOM_BITS_8, |
| 182 | 256), |
| 183 | make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 7, AOM_BITS_8, |
| 184 | 256), |
| 185 | make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 8, AOM_BITS_8, |
| 186 | 256), |
Yi Luo | 13d2aee | 2017-03-29 17:48:13 -0700 | [diff] [blame] | 187 | make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 9, AOM_BITS_8, |
| 188 | 256), |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 189 | make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 10, AOM_BITS_8, |
| 190 | 256), |
| 191 | make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 11, AOM_BITS_8, |
| 192 | 256), |
| 193 | make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 12, AOM_BITS_8, |
| 194 | 256), |
| 195 | make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 13, AOM_BITS_8, |
| 196 | 256), |
| 197 | make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 14, AOM_BITS_8, |
| 198 | 256), |
| 199 | make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 15, AOM_BITS_8, |
| 200 | 256) |
| 201 | #endif // CONFIG_EXT_TX |
| 202 | }; |
| 203 | INSTANTIATE_TEST_CASE_P(SSE2, AV1Trans16x16HT, |
| 204 | ::testing::ValuesIn(kArrayHt16x16Param_sse2)); |
Sebastien Alaiwan | c6a48a2 | 2017-04-20 10:12:43 +0200 | [diff] [blame] | 205 | #endif // HAVE_SSE2 |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 206 | |
Sebastien Alaiwan | c6a48a2 | 2017-04-20 10:12:43 +0200 | [diff] [blame] | 207 | #if HAVE_AVX2 |
Yi Luo | e8e8cd8 | 2016-09-21 10:45:01 -0700 | [diff] [blame] | 208 | const Ht16x16Param kArrayHt16x16Param_avx2[] = { |
Tom Finegan | 29ba675 | 2017-01-31 16:30:55 -0800 | [diff] [blame] | 209 | make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 0, AOM_BITS_8, |
| 210 | 256), |
| 211 | make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 1, AOM_BITS_8, |
| 212 | 256), |
| 213 | make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 2, AOM_BITS_8, |
| 214 | 256), |
| 215 | make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 3, AOM_BITS_8, |
| 216 | 256), |
Yi Luo | e8e8cd8 | 2016-09-21 10:45:01 -0700 | [diff] [blame] | 217 | #if CONFIG_EXT_TX |
Tom Finegan | 29ba675 | 2017-01-31 16:30:55 -0800 | [diff] [blame] | 218 | make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 4, AOM_BITS_8, |
Yi Luo | 7317200 | 2016-10-28 10:52:04 -0700 | [diff] [blame] | 219 | 256), |
Tom Finegan | 29ba675 | 2017-01-31 16:30:55 -0800 | [diff] [blame] | 220 | make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 5, AOM_BITS_8, |
Yi Luo | 7317200 | 2016-10-28 10:52:04 -0700 | [diff] [blame] | 221 | 256), |
Tom Finegan | 29ba675 | 2017-01-31 16:30:55 -0800 | [diff] [blame] | 222 | make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 6, AOM_BITS_8, |
Yi Luo | 7317200 | 2016-10-28 10:52:04 -0700 | [diff] [blame] | 223 | 256), |
Tom Finegan | 29ba675 | 2017-01-31 16:30:55 -0800 | [diff] [blame] | 224 | make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 7, AOM_BITS_8, |
Yi Luo | 7317200 | 2016-10-28 10:52:04 -0700 | [diff] [blame] | 225 | 256), |
Tom Finegan | 29ba675 | 2017-01-31 16:30:55 -0800 | [diff] [blame] | 226 | make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 8, AOM_BITS_8, |
Yi Luo | 7317200 | 2016-10-28 10:52:04 -0700 | [diff] [blame] | 227 | 256), |
Yi Luo | 13d2aee | 2017-03-29 17:48:13 -0700 | [diff] [blame] | 228 | make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 9, AOM_BITS_8, |
| 229 | 256), |
Tom Finegan | 29ba675 | 2017-01-31 16:30:55 -0800 | [diff] [blame] | 230 | make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 10, AOM_BITS_8, |
| 231 | 256), |
| 232 | make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 11, AOM_BITS_8, |
| 233 | 256), |
| 234 | make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 12, AOM_BITS_8, |
| 235 | 256), |
| 236 | make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 13, AOM_BITS_8, |
| 237 | 256), |
| 238 | make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 14, AOM_BITS_8, |
| 239 | 256), |
| 240 | make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 15, AOM_BITS_8, |
| 241 | 256) |
Yi Luo | e8e8cd8 | 2016-09-21 10:45:01 -0700 | [diff] [blame] | 242 | #endif // CONFIG_EXT_TX |
| 243 | }; |
| 244 | INSTANTIATE_TEST_CASE_P(AVX2, AV1Trans16x16HT, |
| 245 | ::testing::ValuesIn(kArrayHt16x16Param_avx2)); |
Sebastien Alaiwan | c6a48a2 | 2017-04-20 10:12:43 +0200 | [diff] [blame] | 246 | #endif // HAVE_AVX2 |
Yi Luo | e8e8cd8 | 2016-09-21 10:45:01 -0700 | [diff] [blame] | 247 | |
Sebastien Alaiwan | c6a48a2 | 2017-04-20 10:12:43 +0200 | [diff] [blame] | 248 | #if HAVE_SSE4_1 && CONFIG_HIGHBITDEPTH |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 249 | const HighbdHt16x16Param kArrayHBDHt16x16Param_sse4_1[] = { |
| 250 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 0, 10), |
| 251 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 0, 12), |
| 252 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 1, 10), |
| 253 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 1, 12), |
| 254 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 2, 10), |
| 255 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 2, 12), |
| 256 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 3, 10), |
| 257 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 3, 12), |
| 258 | #if CONFIG_EXT_TX |
| 259 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 4, 10), |
| 260 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 4, 12), |
| 261 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 5, 10), |
| 262 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 5, 12), |
| 263 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 6, 10), |
| 264 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 6, 12), |
| 265 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 7, 10), |
| 266 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 7, 12), |
| 267 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 8, 10), |
| 268 | make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 8, 12), |
| 269 | #endif // CONFIG_EXT_TX |
| 270 | }; |
| 271 | INSTANTIATE_TEST_CASE_P(SSE4_1, AV1HighbdTrans16x16HT, |
| 272 | ::testing::ValuesIn(kArrayHBDHt16x16Param_sse4_1)); |
Sebastien Alaiwan | c6a48a2 | 2017-04-20 10:12:43 +0200 | [diff] [blame] | 273 | #endif // HAVE_SSE4_1 && CONFIG_HIGHBITDEPTH |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 274 | |
| 275 | } // namespace |