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 | |
| 12 | #include <math.h> |
| 13 | #include <stdio.h> |
| 14 | #include <stdlib.h> |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 15 | #include <vector> |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 16 | |
| 17 | #include "test/acm_random.h" |
| 18 | #include "test/util.h" |
| 19 | #include "test/av1_txfm_test.h" |
| 20 | #include "av1/common/av1_txfm.h" |
| 21 | #include "./av1_rtcd.h" |
| 22 | |
| 23 | using libaom_test::ACMRandom; |
Peng Bin | 58bd7ce | 2018-02-07 21:10:54 +0800 | [diff] [blame] | 24 | using libaom_test::FwdTxfm2dFunc; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 25 | using libaom_test::TYPE_TXFM; |
Johann | 123e8a6 | 2017-12-28 14:40:49 -0800 | [diff] [blame] | 26 | using libaom_test::bd; |
| 27 | using libaom_test::compute_avg_abs_error; |
| 28 | using libaom_test::input_base; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 29 | |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 30 | using std::vector; |
| 31 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 32 | namespace { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 33 | // tx_type_, tx_size_, max_error_, max_avg_error_ |
| 34 | typedef std::tr1::tuple<TX_TYPE, TX_SIZE, double, double> AV1FwdTxfm2dParam; |
| 35 | |
| 36 | class AV1FwdTxfm2d : public ::testing::TestWithParam<AV1FwdTxfm2dParam> { |
| 37 | public: |
| 38 | virtual void SetUp() { |
| 39 | tx_type_ = GET_PARAM(0); |
| 40 | tx_size_ = GET_PARAM(1); |
| 41 | max_error_ = GET_PARAM(2); |
| 42 | max_avg_error_ = GET_PARAM(3); |
| 43 | count_ = 500; |
Urvang Joshi | c502216 | 2017-11-21 15:57:42 -0800 | [diff] [blame] | 44 | TXFM_2D_FLIP_CFG fwd_txfm_flip_cfg; |
| 45 | av1_get_fwd_txfm_cfg(tx_type_, tx_size_, &fwd_txfm_flip_cfg); |
Urvang Joshi | ec6acb2 | 2017-12-13 18:54:51 -0800 | [diff] [blame] | 46 | amplify_factor_ = libaom_test::get_amplification_factor(tx_type_, tx_size_); |
Angie Chiang | 0c7b8d8 | 2018-01-23 19:20:44 -0800 | [diff] [blame] | 47 | tx_width_ = tx_size_wide[fwd_txfm_flip_cfg.tx_size]; |
| 48 | tx_height_ = tx_size_high[fwd_txfm_flip_cfg.tx_size]; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 49 | ud_flip_ = fwd_txfm_flip_cfg.ud_flip; |
| 50 | lr_flip_ = fwd_txfm_flip_cfg.lr_flip; |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 51 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 52 | fwd_txfm_ = libaom_test::fwd_txfm_func_ls[tx_size_]; |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 53 | txfm2d_size_ = tx_width_ * tx_height_; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 54 | input_ = reinterpret_cast<int16_t *>( |
| 55 | aom_memalign(16, sizeof(input_[0]) * txfm2d_size_)); |
| 56 | output_ = reinterpret_cast<int32_t *>( |
| 57 | aom_memalign(16, sizeof(output_[0]) * txfm2d_size_)); |
| 58 | ref_input_ = reinterpret_cast<double *>( |
| 59 | aom_memalign(16, sizeof(ref_input_[0]) * txfm2d_size_)); |
| 60 | ref_output_ = reinterpret_cast<double *>( |
| 61 | aom_memalign(16, sizeof(ref_output_[0]) * txfm2d_size_)); |
| 62 | } |
| 63 | |
| 64 | void RunFwdAccuracyCheck() { |
| 65 | ACMRandom rnd(ACMRandom::DeterministicSeed()); |
| 66 | double avg_abs_error = 0; |
| 67 | for (int ci = 0; ci < count_; ci++) { |
| 68 | for (int ni = 0; ni < txfm2d_size_; ++ni) { |
| 69 | input_[ni] = rnd.Rand16() % input_base; |
| 70 | ref_input_[ni] = static_cast<double>(input_[ni]); |
| 71 | output_[ni] = 0; |
| 72 | ref_output_[ni] = 0; |
| 73 | } |
| 74 | |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 75 | fwd_txfm_(input_, output_, tx_width_, tx_type_, bd); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 76 | |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 77 | if (lr_flip_ && ud_flip_) { |
| 78 | libaom_test::fliplrud(ref_input_, tx_width_, tx_height_, tx_width_); |
| 79 | } else if (lr_flip_) { |
| 80 | libaom_test::fliplr(ref_input_, tx_width_, tx_height_, tx_width_); |
| 81 | } else if (ud_flip_) { |
| 82 | libaom_test::flipud(ref_input_, tx_width_, tx_height_, tx_width_); |
| 83 | } |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 84 | |
Urvang Joshi | ec6acb2 | 2017-12-13 18:54:51 -0800 | [diff] [blame] | 85 | libaom_test::reference_hybrid_2d(ref_input_, ref_output_, tx_type_, |
| 86 | tx_size_); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 87 | |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 88 | double actual_max_error = 0; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 89 | for (int ni = 0; ni < txfm2d_size_; ++ni) { |
Urvang Joshi | ec6acb2 | 2017-12-13 18:54:51 -0800 | [diff] [blame] | 90 | ref_output_[ni] = round(ref_output_[ni]); |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 91 | const double this_error = |
| 92 | fabs(output_[ni] - ref_output_[ni]) / amplify_factor_; |
| 93 | actual_max_error = AOMMAX(actual_max_error, this_error); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 94 | } |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 95 | EXPECT_GE(max_error_, actual_max_error) |
| 96 | << "tx_size = " << tx_size_ << ", tx_type = " << tx_type_; |
| 97 | if (actual_max_error > max_error_) { // exit early. |
| 98 | break; |
| 99 | } |
| 100 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 101 | avg_abs_error += compute_avg_abs_error<int32_t, double>( |
| 102 | output_, ref_output_, txfm2d_size_); |
| 103 | } |
| 104 | |
| 105 | avg_abs_error /= amplify_factor_; |
| 106 | avg_abs_error /= count_; |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 107 | EXPECT_GE(max_avg_error_, avg_abs_error) |
| 108 | << "tx_size = " << tx_size_ << ", tx_type = " << tx_type_; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | virtual void TearDown() { |
| 112 | aom_free(input_); |
| 113 | aom_free(output_); |
| 114 | aom_free(ref_input_); |
| 115 | aom_free(ref_output_); |
| 116 | } |
| 117 | |
| 118 | private: |
| 119 | double max_error_; |
| 120 | double max_avg_error_; |
| 121 | int count_; |
| 122 | double amplify_factor_; |
| 123 | TX_TYPE tx_type_; |
| 124 | TX_SIZE tx_size_; |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 125 | int tx_width_; |
| 126 | int tx_height_; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 127 | int txfm2d_size_; |
Peng Bin | 58bd7ce | 2018-02-07 21:10:54 +0800 | [diff] [blame] | 128 | FwdTxfm2dFunc fwd_txfm_; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 129 | int16_t *input_; |
| 130 | int32_t *output_; |
| 131 | double *ref_input_; |
| 132 | double *ref_output_; |
| 133 | int ud_flip_; // flip upside down |
| 134 | int lr_flip_; // flip left to right |
| 135 | }; |
| 136 | |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 137 | vector<AV1FwdTxfm2dParam> GetTxfm2dParamList() { |
| 138 | vector<AV1FwdTxfm2dParam> param_list; |
Debargha Mukherjee | aa84f3e | 2018-01-04 12:45:10 -0800 | [diff] [blame] | 139 | for (int t = 0; t < TX_TYPES; ++t) { |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 140 | const TX_TYPE tx_type = static_cast<TX_TYPE>(t); |
Angie Chiang | 8251736 | 2018-01-17 17:31:54 -0800 | [diff] [blame] | 141 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_4X4, 3, 0.5)); |
Angie Chiang | a0d2759 | 2018-01-15 21:40:16 -0800 | [diff] [blame] | 142 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_8X8, 5, 0.5)); |
| 143 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_16X16, 11, 1.2)); |
| 144 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_32X32, 70, 6.1)); |
Yue Chen | c1d9aef | 2017-12-28 16:13:13 -0800 | [diff] [blame] | 145 | if (tx_type == DCT_DCT) { // Other types not supported by these tx sizes. |
Angie Chiang | a0d2759 | 2018-01-15 21:40:16 -0800 | [diff] [blame] | 146 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_64X64, 64, 3.4)); |
Yue Chen | c1d9aef | 2017-12-28 16:13:13 -0800 | [diff] [blame] | 147 | } |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 148 | |
Angie Chiang | c8d6c08 | 2018-02-06 14:26:55 -0800 | [diff] [blame] | 149 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_4X8, 3.9, 0.57)); |
| 150 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_8X4, 4.3, 0.68)); |
Angie Chiang | a87dc76 | 2018-02-06 17:16:48 -0800 | [diff] [blame] | 151 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_8X16, 12, 0.92)); |
Angie Chiang | c8d6c08 | 2018-02-06 14:26:55 -0800 | [diff] [blame] | 152 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_16X8, 12, 1.1)); |
| 153 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_16X32, 32, 4.1)); |
Angie Chiang | a87dc76 | 2018-02-06 17:16:48 -0800 | [diff] [blame] | 154 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_32X16, 46, 6)); |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 155 | |
Angie Chiang | 8251736 | 2018-01-17 17:31:54 -0800 | [diff] [blame] | 156 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_4X16, 5, 0.6)); |
| 157 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_16X4, 6, 0.9)); |
Angie Chiang | a0d2759 | 2018-01-15 21:40:16 -0800 | [diff] [blame] | 158 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_8X32, 21, 1.2)); |
| 159 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_32X8, 13, 1.7)); |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 160 | |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 161 | if (tx_type == DCT_DCT) { // Other types not supported by these tx sizes. |
Angie Chiang | c8d6c08 | 2018-02-06 14:26:55 -0800 | [diff] [blame] | 162 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_32X64, 136, 3.5)); |
| 163 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_64X32, 136, 5.7)); |
Angie Chiang | a0d2759 | 2018-01-15 21:40:16 -0800 | [diff] [blame] | 164 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_16X64, 30, 2.0)); |
| 165 | param_list.push_back(AV1FwdTxfm2dParam(tx_type, TX_64X16, 36, 4.7)); |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 166 | } |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 167 | } |
| 168 | return param_list; |
| 169 | } |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 170 | |
| 171 | INSTANTIATE_TEST_CASE_P(C, AV1FwdTxfm2d, |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 172 | ::testing::ValuesIn(GetTxfm2dParamList())); |
| 173 | |
| 174 | TEST_P(AV1FwdTxfm2d, RunFwdAccuracyCheck) { RunFwdAccuracyCheck(); } |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 175 | |
Angie Chiang | 9c7089a | 2017-08-08 16:21:11 -0700 | [diff] [blame] | 176 | TEST(AV1FwdTxfm2d, CfgTest) { |
| 177 | for (int bd_idx = 0; bd_idx < BD_NUM; ++bd_idx) { |
| 178 | int bd = libaom_test::bd_arr[bd_idx]; |
| 179 | int8_t low_range = libaom_test::low_range_arr[bd_idx]; |
| 180 | int8_t high_range = libaom_test::high_range_arr[bd_idx]; |
Urvang Joshi | 8871044 | 2017-12-11 16:41:26 -0800 | [diff] [blame] | 181 | for (int tx_size = 0; tx_size < TX_SIZES_ALL; ++tx_size) { |
Angie Chiang | 9c7089a | 2017-08-08 16:21:11 -0700 | [diff] [blame] | 182 | for (int tx_type = 0; tx_type < TX_TYPES; ++tx_type) { |
Urvang Joshi | 8871044 | 2017-12-11 16:41:26 -0800 | [diff] [blame] | 183 | if ((tx_size_wide[tx_size] == 64 || tx_size_high[tx_size] == 64) && |
Angie Chiang | a87dc76 | 2018-02-06 17:16:48 -0800 | [diff] [blame] | 184 | (tx_type != DCT_DCT && tx_type != IDTX && tx_type != V_DCT && |
| 185 | tx_type != H_DCT)) { |
Urvang Joshi | 8871044 | 2017-12-11 16:41:26 -0800 | [diff] [blame] | 186 | continue; |
| 187 | } |
Urvang Joshi | c502216 | 2017-11-21 15:57:42 -0800 | [diff] [blame] | 188 | TXFM_2D_FLIP_CFG cfg; |
| 189 | av1_get_fwd_txfm_cfg(static_cast<TX_TYPE>(tx_type), |
| 190 | static_cast<TX_SIZE>(tx_size), &cfg); |
Angie Chiang | 9c7089a | 2017-08-08 16:21:11 -0700 | [diff] [blame] | 191 | int8_t stage_range_col[MAX_TXFM_STAGE_NUM]; |
| 192 | int8_t stage_range_row[MAX_TXFM_STAGE_NUM]; |
| 193 | av1_gen_fwd_stage_range(stage_range_col, stage_range_row, &cfg, bd); |
Angie Chiang | 0c7b8d8 | 2018-01-23 19:20:44 -0800 | [diff] [blame] | 194 | libaom_test::txfm_stage_range_check(stage_range_col, cfg.stage_num_col, |
Angie Chiang | d4327bc | 2018-01-22 20:54:04 -0800 | [diff] [blame] | 195 | cfg.cos_bit_col, low_range, |
Angie Chiang | 9c7089a | 2017-08-08 16:21:11 -0700 | [diff] [blame] | 196 | high_range); |
Angie Chiang | 0c7b8d8 | 2018-01-23 19:20:44 -0800 | [diff] [blame] | 197 | libaom_test::txfm_stage_range_check(stage_range_row, cfg.stage_num_row, |
Angie Chiang | d4327bc | 2018-01-22 20:54:04 -0800 | [diff] [blame] | 198 | cfg.cos_bit_row, low_range, |
Angie Chiang | 9c7089a | 2017-08-08 16:21:11 -0700 | [diff] [blame] | 199 | high_range); |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | |
Angie Chiang | 057f0da | 2018-02-05 11:23:35 -0800 | [diff] [blame] | 205 | #if HAVE_SSE2 && defined(__SSE2__) |
| 206 | #include "av1/common/x86/av1_txfm_sse2.h" |
Peng Bin | 58bd7ce | 2018-02-07 21:10:54 +0800 | [diff] [blame] | 207 | FwdTxfm2dFunc fwd_func_sse2_list[TX_SIZES_ALL][2] = { |
Linfeng Zhang | 1c2be1f | 2018-02-12 16:05:19 -0800 | [diff] [blame] | 208 | { av1_fwd_txfm2d_4x4_c, av1_lowbd_fwd_txfm2d_4x4_sse2 }, // TX_4X4 |
Angie Chiang | 7d8b13e | 2018-02-07 22:55:45 -0800 | [diff] [blame] | 209 | { av1_fwd_txfm2d_8x8_c, av1_lowbd_fwd_txfm2d_8x8_sse2 }, // TX_8X8 |
| 210 | { av1_fwd_txfm2d_16x16_c, av1_lowbd_fwd_txfm2d_16x16_sse2 }, // TX_16X16 |
| 211 | { av1_fwd_txfm2d_32x32_c, av1_lowbd_fwd_txfm2d_32x32_sse2 }, // TX_32X32 |
Yaowu Xu | d3d4159 | 2018-02-14 13:26:52 -0800 | [diff] [blame] | 212 | { NULL, NULL }, // TX_64X64 |
| 213 | { av1_fwd_txfm2d_4x8_c, av1_lowbd_fwd_txfm2d_4x8_sse2 }, // TX_4X8 |
| 214 | { av1_fwd_txfm2d_8x4_c, av1_lowbd_fwd_txfm2d_8x4_sse2 }, // TX_8X4 |
| 215 | { av1_fwd_txfm2d_8x16_c, av1_lowbd_fwd_txfm2d_8x16_sse2 }, // TX_8X16 |
| 216 | { av1_fwd_txfm2d_16x8_c, av1_lowbd_fwd_txfm2d_16x8_sse2 }, // TX_16X8 |
Angie Chiang | 7d8b13e | 2018-02-07 22:55:45 -0800 | [diff] [blame] | 217 | { av1_fwd_txfm2d_16x32_c, av1_lowbd_fwd_txfm2d_16x32_sse2 }, // TX_16X32 |
| 218 | { av1_fwd_txfm2d_32x16_c, av1_lowbd_fwd_txfm2d_32x16_sse2 }, // TX_32X16 |
Yaowu Xu | d3d4159 | 2018-02-14 13:26:52 -0800 | [diff] [blame] | 219 | { NULL, NULL }, // TX_32X64 |
| 220 | { NULL, NULL }, // TX_64X32 |
Linfeng Zhang | 03a97b7 | 2018-02-13 18:11:00 -0800 | [diff] [blame] | 221 | { av1_fwd_txfm2d_4x16_c, av1_lowbd_fwd_txfm2d_4x16_sse2 }, // TX_4X16 |
| 222 | { av1_fwd_txfm2d_16x4_c, av1_lowbd_fwd_txfm2d_16x4_sse2 }, // TX_16X4 |
Yaowu Xu | d3d4159 | 2018-02-14 13:26:52 -0800 | [diff] [blame] | 223 | { av1_fwd_txfm2d_8x32_c, av1_lowbd_fwd_txfm2d_8x32_sse2 }, // TX_8X32 |
| 224 | { av1_fwd_txfm2d_32x8_c, av1_lowbd_fwd_txfm2d_32x8_sse2 }, // TX_32X8 |
| 225 | { NULL, NULL }, // TX_16X64 |
| 226 | { NULL, NULL }, // TX_64X16 |
Angie Chiang | 057f0da | 2018-02-05 11:23:35 -0800 | [diff] [blame] | 227 | }; |
| 228 | |
| 229 | TEST(av1_fwd_txfm2d_sse2, match) { |
| 230 | const int bd = 8; |
| 231 | for (int tx_size = TX_4X4; tx_size < TX_SIZES_ALL; ++tx_size) { |
Linfeng Zhang | c6b0186 | 2018-02-06 13:11:44 -0800 | [diff] [blame] | 232 | const int rows = tx_size_high[tx_size]; |
| 233 | const int cols = tx_size_wide[tx_size]; |
Angie Chiang | 057f0da | 2018-02-05 11:23:35 -0800 | [diff] [blame] | 234 | for (int tx_type = 0; tx_type < TX_TYPES; ++tx_type) { |
Linfeng Zhang | c6b0186 | 2018-02-06 13:11:44 -0800 | [diff] [blame] | 235 | if ((rows >= 32 || cols >= 32) && tx_type != DCT_DCT && tx_type != IDTX && |
| 236 | tx_type != V_DCT && tx_type != H_DCT) { |
| 237 | // No ADST for large size transforms. |
| 238 | continue; |
| 239 | } |
Peng Bin | 58bd7ce | 2018-02-07 21:10:54 +0800 | [diff] [blame] | 240 | FwdTxfm2dFunc ref_func = fwd_func_sse2_list[tx_size][0]; |
| 241 | FwdTxfm2dFunc target_func = fwd_func_sse2_list[tx_size][1]; |
Angie Chiang | 057f0da | 2018-02-05 11:23:35 -0800 | [diff] [blame] | 242 | if (ref_func != NULL && target_func != NULL) { |
Yaowu Xu | c3bb018 | 2018-02-07 07:56:41 -0800 | [diff] [blame] | 243 | DECLARE_ALIGNED(16, int16_t, input[64 * 64]) = { 0 }; |
| 244 | DECLARE_ALIGNED(16, int32_t, output[64 * 64]) = { 0 }; |
| 245 | DECLARE_ALIGNED(16, int32_t, ref_output[64 * 64]) = { 0 }; |
Angie Chiang | 057f0da | 2018-02-05 11:23:35 -0800 | [diff] [blame] | 246 | int input_stride = 64; |
| 247 | ACMRandom rnd(ACMRandom::DeterministicSeed()); |
Angie Chiang | 057f0da | 2018-02-05 11:23:35 -0800 | [diff] [blame] | 248 | for (int cnt = 0; cnt < 500; ++cnt) { |
| 249 | if (cnt == 0) { |
| 250 | for (int r = 0; r < rows; ++r) { |
| 251 | for (int c = 0; c < cols; ++c) { |
| 252 | input[r * input_stride + c] = (1 << bd) - 1; |
| 253 | } |
| 254 | } |
| 255 | } else { |
| 256 | for (int r = 0; r < rows; ++r) { |
| 257 | for (int c = 0; c < cols; ++c) { |
| 258 | input[r * input_stride + c] = rnd.Rand16() % (1 << bd); |
| 259 | } |
| 260 | } |
| 261 | } |
| 262 | ref_func(input, ref_output, input_stride, (TX_TYPE)tx_type, bd); |
| 263 | target_func(input, output, input_stride, (TX_TYPE)tx_type, bd); |
| 264 | for (int r = 0; r < rows; ++r) { |
| 265 | for (int c = 0; c < cols; ++c) { |
Linfeng Zhang | 43977f0 | 2018-02-05 18:04:20 -0800 | [diff] [blame] | 266 | ASSERT_EQ(ref_output[r * cols + c], output[r * cols + c]) |
Linfeng Zhang | 75c6be0 | 2018-02-06 12:48:33 -0800 | [diff] [blame] | 267 | << "[" << r << "," << c << "]" |
| 268 | << " tx_size: " << tx_size << " tx_type: " << tx_type; |
Angie Chiang | 057f0da | 2018-02-05 11:23:35 -0800 | [diff] [blame] | 269 | } |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | } |
| 274 | } |
| 275 | } |
| 276 | #endif // HAVE_SSE2 |
| 277 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 278 | } // namespace |