Yi Luo | 50a164a | 2016-03-08 14:10:24 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 The WebM project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include "third_party/googletest/src/include/gtest/gtest.h" |
| 12 | |
| 13 | #include "./vp10_rtcd.h" |
| 14 | #include "./vpx_dsp_rtcd.h" |
| 15 | |
| 16 | #include "test/acm_random.h" |
| 17 | #include "test/clear_system_state.h" |
| 18 | #include "test/register_state_check.h" |
| 19 | #include "test/transform_test_base.h" |
| 20 | #include "test/util.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame^] | 21 | #include "aom_ports/mem.h" |
Yi Luo | 50a164a | 2016-03-08 14:10:24 -0800 | [diff] [blame] | 22 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame^] | 23 | using libaom_test::ACMRandom; |
Yi Luo | 50a164a | 2016-03-08 14:10:24 -0800 | [diff] [blame] | 24 | |
| 25 | namespace { |
| 26 | typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride, |
| 27 | int tx_type); |
Yi Luo | 412ad22 | 2016-05-09 10:36:40 -0700 | [diff] [blame] | 28 | using std::tr1::tuple; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame^] | 29 | using libaom_test::FhtFunc; |
Yi Luo | 412ad22 | 2016-05-09 10:36:40 -0700 | [diff] [blame] | 30 | typedef tuple<FhtFunc, IhtFunc, int, vpx_bit_depth_t, int> Ht16x16Param; |
Yi Luo | 50a164a | 2016-03-08 14:10:24 -0800 | [diff] [blame] | 31 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 32 | void fht16x16_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) { |
Yi Luo | 50a164a | 2016-03-08 14:10:24 -0800 | [diff] [blame] | 33 | vp10_fht16x16_c(in, out, stride, tx_type); |
| 34 | } |
| 35 | |
Yi Luo | 412ad22 | 2016-05-09 10:36:40 -0700 | [diff] [blame] | 36 | #if CONFIG_VP9_HIGHBITDEPTH |
| 37 | typedef void (*IHbdHtFunc)(const tran_low_t *in, uint8_t *out, int stride, |
| 38 | int tx_type, int bd); |
| 39 | typedef void (*HbdHtFunc)(const int16_t *input, int32_t *output, int stride, |
| 40 | int tx_type, int bd); |
| 41 | |
| 42 | // Target optimized function, tx_type, bit depth |
| 43 | typedef tuple<HbdHtFunc, int, int> HighbdHt16x16Param; |
| 44 | |
| 45 | void highbd_fht16x16_ref(const int16_t *in, int32_t *out, int stride, |
| 46 | int tx_type, int bd) { |
| 47 | vp10_fwd_txfm2d_16x16_c(in, out, stride, tx_type, bd); |
| 48 | } |
| 49 | #endif // CONFIG_VP9_HIGHBITDEPTH |
| 50 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame^] | 51 | class VP10Trans16x16HT : public libaom_test::TransformTestBase, |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 52 | public ::testing::TestWithParam<Ht16x16Param> { |
Yi Luo | 50a164a | 2016-03-08 14:10:24 -0800 | [diff] [blame] | 53 | public: |
| 54 | virtual ~VP10Trans16x16HT() {} |
| 55 | |
| 56 | virtual void SetUp() { |
| 57 | fwd_txfm_ = GET_PARAM(0); |
| 58 | inv_txfm_ = GET_PARAM(1); |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 59 | tx_type_ = GET_PARAM(2); |
| 60 | pitch_ = 16; |
Yi Luo | 50a164a | 2016-03-08 14:10:24 -0800 | [diff] [blame] | 61 | fwd_txfm_ref = fht16x16_ref; |
| 62 | bit_depth_ = GET_PARAM(3); |
| 63 | mask_ = (1 << bit_depth_) - 1; |
| 64 | num_coeffs_ = GET_PARAM(4); |
| 65 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame^] | 66 | virtual void TearDown() { libaom_test::ClearSystemState(); } |
Yi Luo | 50a164a | 2016-03-08 14:10:24 -0800 | [diff] [blame] | 67 | |
| 68 | protected: |
| 69 | void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) { |
| 70 | fwd_txfm_(in, out, stride, tx_type_); |
| 71 | } |
| 72 | |
| 73 | void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) { |
| 74 | inv_txfm_(out, dst, stride, tx_type_); |
| 75 | } |
| 76 | |
| 77 | FhtFunc fwd_txfm_; |
| 78 | IhtFunc inv_txfm_; |
| 79 | }; |
| 80 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 81 | TEST_P(VP10Trans16x16HT, CoeffCheck) { RunCoeffCheck(); } |
Yi Luo | 50a164a | 2016-03-08 14:10:24 -0800 | [diff] [blame] | 82 | |
Yi Luo | 412ad22 | 2016-05-09 10:36:40 -0700 | [diff] [blame] | 83 | #if CONFIG_VP9_HIGHBITDEPTH |
| 84 | class VP10HighbdTrans16x16HT |
| 85 | : public ::testing::TestWithParam<HighbdHt16x16Param> { |
| 86 | public: |
| 87 | virtual ~VP10HighbdTrans16x16HT() {} |
Yi Luo | 770bf71 | 2016-03-25 16:48:19 -0700 | [diff] [blame] | 88 | |
Yi Luo | 412ad22 | 2016-05-09 10:36:40 -0700 | [diff] [blame] | 89 | virtual void SetUp() { |
| 90 | fwd_txfm_ = GET_PARAM(0); |
| 91 | fwd_txfm_ref_ = highbd_fht16x16_ref; |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 92 | tx_type_ = GET_PARAM(1); |
Yi Luo | 412ad22 | 2016-05-09 10:36:40 -0700 | [diff] [blame] | 93 | bit_depth_ = GET_PARAM(2); |
| 94 | mask_ = (1 << bit_depth_) - 1; |
| 95 | num_coeffs_ = 256; |
| 96 | |
| 97 | input_ = reinterpret_cast<int16_t *>( |
| 98 | vpx_memalign(16, sizeof(int16_t) * num_coeffs_)); |
| 99 | output_ = reinterpret_cast<int32_t *>( |
| 100 | vpx_memalign(16, sizeof(int32_t) * num_coeffs_)); |
| 101 | output_ref_ = reinterpret_cast<int32_t *>( |
| 102 | vpx_memalign(16, sizeof(int32_t) * num_coeffs_)); |
| 103 | } |
| 104 | |
| 105 | virtual void TearDown() { |
| 106 | vpx_free(input_); |
| 107 | vpx_free(output_); |
| 108 | vpx_free(output_ref_); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame^] | 109 | libaom_test::ClearSystemState(); |
Yi Luo | 412ad22 | 2016-05-09 10:36:40 -0700 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | protected: |
| 113 | void RunBitexactCheck(); |
| 114 | |
| 115 | private: |
| 116 | HbdHtFunc fwd_txfm_; |
| 117 | HbdHtFunc fwd_txfm_ref_; |
| 118 | int tx_type_; |
| 119 | int bit_depth_; |
| 120 | int mask_; |
| 121 | int num_coeffs_; |
| 122 | int16_t *input_; |
| 123 | int32_t *output_; |
| 124 | int32_t *output_ref_; |
| 125 | }; |
| 126 | |
| 127 | void VP10HighbdTrans16x16HT::RunBitexactCheck() { |
| 128 | ACMRandom rnd(ACMRandom::DeterministicSeed()); |
| 129 | int i, j; |
| 130 | const int stride = 16; |
Angie Chiang | 6f28581 | 2016-05-13 15:11:18 -0700 | [diff] [blame] | 131 | const int num_tests = 1000; |
Yi Luo | 412ad22 | 2016-05-09 10:36:40 -0700 | [diff] [blame] | 132 | |
| 133 | for (i = 0; i < num_tests; ++i) { |
| 134 | for (j = 0; j < num_coeffs_; ++j) { |
| 135 | input_[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_); |
Yi Luo | 770bf71 | 2016-03-25 16:48:19 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Yi Luo | 412ad22 | 2016-05-09 10:36:40 -0700 | [diff] [blame] | 138 | fwd_txfm_ref_(input_, output_ref_, stride, tx_type_, bit_depth_); |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 139 | ASM_REGISTER_STATE_CHECK( |
| 140 | fwd_txfm_(input_, output_, stride, tx_type_, bit_depth_)); |
Yi Luo | 770bf71 | 2016-03-25 16:48:19 -0700 | [diff] [blame] | 141 | |
Yi Luo | 412ad22 | 2016-05-09 10:36:40 -0700 | [diff] [blame] | 142 | for (j = 0; j < num_coeffs_; ++j) { |
| 143 | EXPECT_EQ(output_ref_[j], output_[j]) |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 144 | << "Not bit-exact result at index: " << j << " at test block: " << i; |
Yi Luo | 770bf71 | 2016-03-25 16:48:19 -0700 | [diff] [blame] | 145 | } |
Yi Luo | 412ad22 | 2016-05-09 10:36:40 -0700 | [diff] [blame] | 146 | } |
Yi Luo | 770bf71 | 2016-03-25 16:48:19 -0700 | [diff] [blame] | 147 | } |
Yi Luo | 412ad22 | 2016-05-09 10:36:40 -0700 | [diff] [blame] | 148 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 149 | TEST_P(VP10HighbdTrans16x16HT, HighbdCoeffCheck) { RunBitexactCheck(); } |
Yi Luo | 412ad22 | 2016-05-09 10:36:40 -0700 | [diff] [blame] | 150 | #endif // CONFIG_VP9_HIGHBITDEPTH |
Yi Luo | 770bf71 | 2016-03-25 16:48:19 -0700 | [diff] [blame] | 151 | |
Yi Luo | 50a164a | 2016-03-08 14:10:24 -0800 | [diff] [blame] | 152 | using std::tr1::make_tuple; |
| 153 | |
| 154 | #if HAVE_SSE2 |
Alex Converse | 2e520f2 | 2016-04-27 12:52:25 -0700 | [diff] [blame] | 155 | const Ht16x16Param kArrayHt16x16Param_sse2[] = { |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 156 | make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 0, VPX_BITS_8, |
| 157 | 256), |
| 158 | make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 1, VPX_BITS_8, |
| 159 | 256), |
| 160 | make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 2, VPX_BITS_8, |
| 161 | 256), |
| 162 | make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 3, VPX_BITS_8, |
| 163 | 256), |
Alex Converse | 2e520f2 | 2016-04-27 12:52:25 -0700 | [diff] [blame] | 164 | #if CONFIG_EXT_TX |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 165 | make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 4, VPX_BITS_8, |
| 166 | 256), |
| 167 | make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 5, VPX_BITS_8, |
| 168 | 256), |
| 169 | make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 6, VPX_BITS_8, |
| 170 | 256), |
| 171 | make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 7, VPX_BITS_8, |
| 172 | 256), |
| 173 | make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 8, VPX_BITS_8, |
| 174 | 256), |
| 175 | make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 10, VPX_BITS_8, |
| 176 | 256), |
| 177 | make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 11, VPX_BITS_8, |
| 178 | 256), |
| 179 | make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 12, VPX_BITS_8, |
| 180 | 256), |
| 181 | make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 13, VPX_BITS_8, |
| 182 | 256), |
| 183 | make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 14, VPX_BITS_8, |
| 184 | 256), |
| 185 | make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 15, VPX_BITS_8, |
| 186 | 256) |
Alex Converse | 2e520f2 | 2016-04-27 12:52:25 -0700 | [diff] [blame] | 187 | #endif // CONFIG_EXT_TX |
| 188 | }; |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 189 | INSTANTIATE_TEST_CASE_P(SSE2, VP10Trans16x16HT, |
| 190 | ::testing::ValuesIn(kArrayHt16x16Param_sse2)); |
Yi Luo | 50a164a | 2016-03-08 14:10:24 -0800 | [diff] [blame] | 191 | #endif // HAVE_SSE2 |
| 192 | |
Yi Luo | 412ad22 | 2016-05-09 10:36:40 -0700 | [diff] [blame] | 193 | #if HAVE_SSE4_1 && CONFIG_VP9_HIGHBITDEPTH |
| 194 | const HighbdHt16x16Param kArrayHBDHt16x16Param_sse4_1[] = { |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 195 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 0, 10), |
| 196 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 0, 12), |
| 197 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 1, 10), |
| 198 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 1, 12), |
| 199 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 2, 10), |
| 200 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 2, 12), |
| 201 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 3, 10), |
| 202 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 3, 12), |
Angie Chiang | 6f28581 | 2016-05-13 15:11:18 -0700 | [diff] [blame] | 203 | #if CONFIG_EXT_TX |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 204 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 4, 10), |
| 205 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 4, 12), |
| 206 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 5, 10), |
| 207 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 5, 12), |
| 208 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 6, 10), |
| 209 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 6, 12), |
| 210 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 7, 10), |
| 211 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 7, 12), |
| 212 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 8, 10), |
| 213 | make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 8, 12), |
Yi Luo | 1d30736 | 2016-05-17 16:41:02 -0700 | [diff] [blame] | 214 | #endif // CONFIG_EXT_TX |
Yi Luo | 412ad22 | 2016-05-09 10:36:40 -0700 | [diff] [blame] | 215 | }; |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 216 | INSTANTIATE_TEST_CASE_P(SSE4_1, VP10HighbdTrans16x16HT, |
| 217 | ::testing::ValuesIn(kArrayHBDHt16x16Param_sse4_1)); |
Yi Luo | 412ad22 | 2016-05-09 10:36:40 -0700 | [diff] [blame] | 218 | #endif // HAVE_SSE4_1 && CONFIG_VP9_HIGHBITDEPTH |
| 219 | |
Yi Luo | 50a164a | 2016-03-08 14:10:24 -0800 | [diff] [blame] | 220 | } // namespace |