Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [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. |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include "third_party/googletest/src/include/gtest/gtest.h" |
| 13 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 14 | #include "./av1_rtcd.h" |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 15 | #include "test/acm_random.h" |
| 16 | #include "test/clear_system_state.h" |
| 17 | #include "test/register_state_check.h" |
| 18 | #include "test/util.h" |
| 19 | |
| 20 | namespace { |
| 21 | |
| 22 | using std::tr1::tuple; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 23 | using libaom_test::ACMRandom; |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 24 | |
Angie Chiang | b2ff17f | 2017-01-11 17:30:20 -0800 | [diff] [blame] | 25 | typedef void (*ConvInit)(); |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 26 | typedef void (*conv_filter_t)(const uint8_t *, int, uint8_t *, int, int, int, |
Angie Chiang | 674bffd | 2017-01-11 16:15:55 -0800 | [diff] [blame] | 27 | const InterpFilterParams, const int, int, |
| 28 | ConvolveParams *); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 29 | #if CONFIG_AOM_HIGHBITDEPTH |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 30 | typedef void (*hbd_conv_filter_t)(const uint16_t *, int, uint16_t *, int, int, |
| 31 | int, const InterpFilterParams, const int, int, |
| 32 | int, int); |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 33 | #endif |
| 34 | |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 35 | // Test parameter list: |
Yi Luo | 81ad953 | 2016-06-21 12:17:39 -0700 | [diff] [blame] | 36 | // <convolve_horiz_func, convolve_vert_func, |
| 37 | // <width, height>, filter_params, subpel_x_q4, avg> |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 38 | typedef tuple<int, int> BlockDimension; |
Angie Chiang | b2ff17f | 2017-01-11 17:30:20 -0800 | [diff] [blame] | 39 | typedef tuple<ConvInit, conv_filter_t, conv_filter_t, BlockDimension, |
| 40 | InterpFilter, int, int> |
clang-format | 67948d3 | 2016-09-07 22:40:40 -0700 | [diff] [blame] | 41 | ConvParams; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 42 | #if CONFIG_AOM_HIGHBITDEPTH |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 43 | // Test parameter list: |
| 44 | // <convolve_horiz_func, convolve_vert_func, |
| 45 | // <width, height>, filter_params, subpel_x_q4, avg, bit_dpeth> |
| 46 | typedef tuple<hbd_conv_filter_t, hbd_conv_filter_t, BlockDimension, |
clang-format | 67948d3 | 2016-09-07 22:40:40 -0700 | [diff] [blame] | 47 | InterpFilter, int, int, int> |
| 48 | HbdConvParams; |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 49 | #endif |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 50 | |
| 51 | // Note: |
| 52 | // src_ and src_ref_ have special boundary requirement |
| 53 | // dst_ and dst_ref_ don't |
| 54 | const size_t maxWidth = 256; |
| 55 | const size_t maxHeight = 256; |
| 56 | const size_t maxBlockSize = maxWidth * maxHeight; |
| 57 | const int horizOffset = 32; |
| 58 | const int vertiOffset = 32; |
| 59 | const int stride = 128; |
| 60 | const int x_step_q4 = 16; |
| 61 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 62 | class AV1ConvolveOptimzTest : public ::testing::TestWithParam<ConvParams> { |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 63 | public: |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 64 | virtual ~AV1ConvolveOptimzTest() {} |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 65 | virtual void SetUp() { |
Angie Chiang | b2ff17f | 2017-01-11 17:30:20 -0800 | [diff] [blame] | 66 | ConvInit conv_init = GET_PARAM(0); |
| 67 | conv_init(); |
| 68 | conv_horiz_ = GET_PARAM(1); |
| 69 | conv_vert_ = GET_PARAM(2); |
| 70 | BlockDimension block = GET_PARAM(3); |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 71 | width_ = std::tr1::get<0>(block); |
| 72 | height_ = std::tr1::get<1>(block); |
Angie Chiang | b2ff17f | 2017-01-11 17:30:20 -0800 | [diff] [blame] | 73 | filter_ = GET_PARAM(4); |
| 74 | subpel_ = GET_PARAM(5); |
Angie Chiang | 9f45bc4 | 2017-01-13 16:27:54 -0800 | [diff] [blame] | 75 | int ref = GET_PARAM(6); |
| 76 | conv_params_ = get_conv_params(ref); |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 77 | |
| 78 | alloc_ = new uint8_t[maxBlockSize * 4]; |
| 79 | src_ = alloc_ + (vertiOffset * maxWidth); |
| 80 | src_ += horizOffset; |
| 81 | src_ref_ = src_ + maxBlockSize; |
| 82 | |
| 83 | dst_ = alloc_ + 2 * maxBlockSize; |
| 84 | dst_ref_ = alloc_ + 3 * maxBlockSize; |
| 85 | } |
| 86 | |
| 87 | virtual void TearDown() { |
| 88 | delete[] alloc_; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 89 | libaom_test::ClearSystemState(); |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | protected: |
| 93 | void RunHorizFilterBitExactCheck(); |
Yi Luo | 81ad953 | 2016-06-21 12:17:39 -0700 | [diff] [blame] | 94 | void RunVertFilterBitExactCheck(); |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 95 | |
| 96 | private: |
Urvang Joshi | d71a231 | 2016-07-14 12:33:48 -0700 | [diff] [blame] | 97 | void PrepFilterBuffer(); |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 98 | void DiffFilterBuffer(); |
Yi Luo | 81ad953 | 2016-06-21 12:17:39 -0700 | [diff] [blame] | 99 | conv_filter_t conv_horiz_; |
| 100 | conv_filter_t conv_vert_; |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 101 | uint8_t *alloc_; |
| 102 | uint8_t *src_; |
| 103 | uint8_t *dst_; |
| 104 | uint8_t *src_ref_; |
| 105 | uint8_t *dst_ref_; |
| 106 | int width_; |
| 107 | int height_; |
| 108 | int filter_; |
| 109 | int subpel_; |
Angie Chiang | 674bffd | 2017-01-11 16:15:55 -0800 | [diff] [blame] | 110 | ConvolveParams conv_params_; |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 111 | }; |
| 112 | |
Urvang Joshi | d71a231 | 2016-07-14 12:33:48 -0700 | [diff] [blame] | 113 | void AV1ConvolveOptimzTest::PrepFilterBuffer() { |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 114 | int r, c; |
| 115 | ACMRandom rnd(ACMRandom::DeterministicSeed()); |
| 116 | |
Yi Luo | 81ad953 | 2016-06-21 12:17:39 -0700 | [diff] [blame] | 117 | memset(alloc_, 0, 4 * maxBlockSize * sizeof(alloc_[0])); |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 118 | |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 119 | uint8_t *src_ptr = src_; |
| 120 | uint8_t *dst_ptr = dst_; |
| 121 | uint8_t *src_ref_ptr = src_ref_; |
| 122 | uint8_t *dst_ref_ptr = dst_ref_; |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 123 | |
| 124 | for (r = 0; r < height_; ++r) { |
| 125 | for (c = 0; c < width_; ++c) { |
| 126 | src_ptr[c] = rnd.Rand8(); |
| 127 | src_ref_ptr[c] = src_ptr[c]; |
| 128 | dst_ptr[c] = rnd.Rand8(); |
| 129 | dst_ref_ptr[c] = dst_ptr[c]; |
| 130 | } |
| 131 | src_ptr += stride; |
| 132 | src_ref_ptr += stride; |
| 133 | dst_ptr += stride; |
| 134 | dst_ref_ptr += stride; |
| 135 | } |
| 136 | } |
| 137 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 138 | void AV1ConvolveOptimzTest::DiffFilterBuffer() { |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 139 | int r, c; |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 140 | const uint8_t *dst_ptr = dst_; |
| 141 | const uint8_t *dst_ref_ptr = dst_ref_; |
| 142 | for (r = 0; r < height_; ++r) { |
| 143 | for (c = 0; c < width_; ++c) { |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 144 | EXPECT_EQ((uint8_t)dst_ref_ptr[c], (uint8_t)dst_ptr[c]) |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 145 | << "Error at row: " << r << " col: " << c << " " |
| 146 | << "w = " << width_ << " " |
| 147 | << "h = " << height_ << " " |
| 148 | << "filter group index = " << filter_ << " " |
| 149 | << "filter index = " << subpel_; |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 150 | } |
| 151 | dst_ptr += stride; |
| 152 | dst_ref_ptr += stride; |
| 153 | } |
| 154 | } |
| 155 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 156 | void AV1ConvolveOptimzTest::RunHorizFilterBitExactCheck() { |
Urvang Joshi | d71a231 | 2016-07-14 12:33:48 -0700 | [diff] [blame] | 157 | PrepFilterBuffer(); |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 158 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 159 | InterpFilterParams filter_params = av1_get_interp_filter_params(filter_); |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 160 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 161 | av1_convolve_horiz_c(src_ref_, stride, dst_ref_, stride, width_, height_, |
Angie Chiang | 674bffd | 2017-01-11 16:15:55 -0800 | [diff] [blame] | 162 | filter_params, subpel_, x_step_q4, &conv_params_); |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 163 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 164 | conv_horiz_(src_, stride, dst_, stride, width_, height_, filter_params, |
Angie Chiang | 674bffd | 2017-01-11 16:15:55 -0800 | [diff] [blame] | 165 | subpel_, x_step_q4, &conv_params_); |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 166 | |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 167 | DiffFilterBuffer(); |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 168 | |
| 169 | // Note: |
| 170 | // Here we need calculate a height which is different from the specified one |
| 171 | // and test again. |
| 172 | int intermediate_height = |
| 173 | (((height_ - 1) * 16 + subpel_) >> SUBPEL_BITS) + filter_params.taps; |
Urvang Joshi | d71a231 | 2016-07-14 12:33:48 -0700 | [diff] [blame] | 174 | PrepFilterBuffer(); |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 175 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 176 | av1_convolve_horiz_c(src_ref_, stride, dst_ref_, stride, width_, |
| 177 | intermediate_height, filter_params, subpel_, x_step_q4, |
Angie Chiang | 674bffd | 2017-01-11 16:15:55 -0800 | [diff] [blame] | 178 | &conv_params_); |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 179 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 180 | conv_horiz_(src_, stride, dst_, stride, width_, intermediate_height, |
Angie Chiang | 674bffd | 2017-01-11 16:15:55 -0800 | [diff] [blame] | 181 | filter_params, subpel_, x_step_q4, &conv_params_); |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 182 | |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 183 | DiffFilterBuffer(); |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 184 | } |
| 185 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 186 | void AV1ConvolveOptimzTest::RunVertFilterBitExactCheck() { |
Urvang Joshi | d71a231 | 2016-07-14 12:33:48 -0700 | [diff] [blame] | 187 | PrepFilterBuffer(); |
Yi Luo | 81ad953 | 2016-06-21 12:17:39 -0700 | [diff] [blame] | 188 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 189 | InterpFilterParams filter_params = av1_get_interp_filter_params(filter_); |
Yi Luo | 81ad953 | 2016-06-21 12:17:39 -0700 | [diff] [blame] | 190 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 191 | av1_convolve_vert_c(src_ref_, stride, dst_ref_, stride, width_, height_, |
Angie Chiang | 674bffd | 2017-01-11 16:15:55 -0800 | [diff] [blame] | 192 | filter_params, subpel_, x_step_q4, &conv_params_); |
Yi Luo | 81ad953 | 2016-06-21 12:17:39 -0700 | [diff] [blame] | 193 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 194 | conv_vert_(src_, stride, dst_, stride, width_, height_, filter_params, |
Angie Chiang | 674bffd | 2017-01-11 16:15:55 -0800 | [diff] [blame] | 195 | subpel_, x_step_q4, &conv_params_); |
Yi Luo | 81ad953 | 2016-06-21 12:17:39 -0700 | [diff] [blame] | 196 | |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 197 | DiffFilterBuffer(); |
Yi Luo | 81ad953 | 2016-06-21 12:17:39 -0700 | [diff] [blame] | 198 | } |
| 199 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 200 | TEST_P(AV1ConvolveOptimzTest, HorizBitExactCheck) { |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 201 | RunHorizFilterBitExactCheck(); |
| 202 | } |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 203 | TEST_P(AV1ConvolveOptimzTest, VerticalBitExactCheck) { |
Yi Luo | 81ad953 | 2016-06-21 12:17:39 -0700 | [diff] [blame] | 204 | RunVertFilterBitExactCheck(); |
| 205 | } |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 206 | |
| 207 | using std::tr1::make_tuple; |
| 208 | |
Angie Chiang | 1733f6b | 2017-01-05 09:52:20 -0800 | [diff] [blame] | 209 | #if (HAVE_SSSE3 || HAVE_SSE4_1) && CONFIG_DUAL_FILTER |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 210 | const BlockDimension kBlockDim[] = { |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 211 | make_tuple(2, 2), make_tuple(2, 4), make_tuple(4, 4), |
| 212 | make_tuple(4, 8), make_tuple(8, 4), make_tuple(8, 8), |
| 213 | make_tuple(8, 16), make_tuple(16, 8), make_tuple(16, 16), |
| 214 | make_tuple(16, 32), make_tuple(32, 16), make_tuple(32, 32), |
| 215 | make_tuple(32, 64), make_tuple(64, 32), make_tuple(64, 64), |
| 216 | make_tuple(64, 128), make_tuple(128, 64), make_tuple(128, 128), |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 217 | }; |
Sarah Parker | 9576374 | 2016-06-28 17:13:03 -0700 | [diff] [blame] | 218 | |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 219 | // 10/12-tap filters |
James Zern | 7b9407a | 2016-05-18 23:48:05 -0700 | [diff] [blame] | 220 | const InterpFilter kFilter[] = { 6, 4, 2 }; |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 221 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 222 | const int kSubpelQ4[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 223 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 224 | const int kAvg[] = { 0, 1 }; |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 225 | #endif |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 226 | |
Angie Chiang | 1733f6b | 2017-01-05 09:52:20 -0800 | [diff] [blame] | 227 | #if HAVE_SSSE3 && CONFIG_DUAL_FILTER |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 228 | INSTANTIATE_TEST_CASE_P( |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 229 | SSSE3, AV1ConvolveOptimzTest, |
Angie Chiang | b2ff17f | 2017-01-11 17:30:20 -0800 | [diff] [blame] | 230 | ::testing::Combine(::testing::Values(av1_convolve_init_ssse3), |
| 231 | ::testing::Values(av1_convolve_horiz_ssse3), |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 232 | ::testing::Values(av1_convolve_vert_ssse3), |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 233 | ::testing::ValuesIn(kBlockDim), |
| 234 | ::testing::ValuesIn(kFilter), |
| 235 | ::testing::ValuesIn(kSubpelQ4), |
| 236 | ::testing::ValuesIn(kAvg))); |
Angie Chiang | 1733f6b | 2017-01-05 09:52:20 -0800 | [diff] [blame] | 237 | #endif // HAVE_SSSE3 && CONFIG_DUAL_FILTER |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 238 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 239 | #if CONFIG_AOM_HIGHBITDEPTH |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 240 | typedef ::testing::TestWithParam<HbdConvParams> TestWithHbdConvParams; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 241 | class AV1HbdConvolveOptimzTest : public TestWithHbdConvParams { |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 242 | public: |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 243 | virtual ~AV1HbdConvolveOptimzTest() {} |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 244 | virtual void SetUp() { |
| 245 | conv_horiz_ = GET_PARAM(0); |
| 246 | conv_vert_ = GET_PARAM(1); |
| 247 | BlockDimension block = GET_PARAM(2); |
| 248 | width_ = std::tr1::get<0>(block); |
| 249 | height_ = std::tr1::get<1>(block); |
| 250 | filter_ = GET_PARAM(3); |
| 251 | subpel_ = GET_PARAM(4); |
| 252 | avg_ = GET_PARAM(5); |
| 253 | bit_depth_ = GET_PARAM(6); |
| 254 | |
| 255 | alloc_ = new uint16_t[maxBlockSize * 4]; |
| 256 | src_ = alloc_ + (vertiOffset * maxWidth); |
| 257 | src_ += horizOffset; |
| 258 | src_ref_ = src_ + maxBlockSize; |
| 259 | |
| 260 | dst_ = alloc_ + 2 * maxBlockSize; |
| 261 | dst_ref_ = alloc_ + 3 * maxBlockSize; |
| 262 | } |
| 263 | |
| 264 | virtual void TearDown() { |
| 265 | delete[] alloc_; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 266 | libaom_test::ClearSystemState(); |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | protected: |
| 270 | void RunHorizFilterBitExactCheck(); |
| 271 | void RunVertFilterBitExactCheck(); |
| 272 | |
| 273 | private: |
Urvang Joshi | d71a231 | 2016-07-14 12:33:48 -0700 | [diff] [blame] | 274 | void PrepFilterBuffer(); |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 275 | void DiffFilterBuffer(); |
| 276 | hbd_conv_filter_t conv_horiz_; |
| 277 | hbd_conv_filter_t conv_vert_; |
| 278 | uint16_t *alloc_; |
| 279 | uint16_t *src_; |
| 280 | uint16_t *dst_; |
| 281 | uint16_t *src_ref_; |
| 282 | uint16_t *dst_ref_; |
| 283 | int width_; |
| 284 | int height_; |
| 285 | int filter_; |
| 286 | int subpel_; |
| 287 | int avg_; |
| 288 | int bit_depth_; |
| 289 | }; |
| 290 | |
Urvang Joshi | d71a231 | 2016-07-14 12:33:48 -0700 | [diff] [blame] | 291 | void AV1HbdConvolveOptimzTest::PrepFilterBuffer() { |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 292 | int r, c; |
| 293 | ACMRandom rnd(ACMRandom::DeterministicSeed()); |
| 294 | |
| 295 | memset(alloc_, 0, 4 * maxBlockSize * sizeof(alloc_[0])); |
| 296 | |
| 297 | uint16_t *src_ptr = src_; |
| 298 | uint16_t *dst_ptr = dst_; |
| 299 | uint16_t *dst_ref_ptr = dst_ref_; |
| 300 | uint16_t hbd_mask = (1 << bit_depth_) - 1; |
| 301 | |
| 302 | for (r = 0; r < height_; ++r) { |
| 303 | for (c = 0; c < width_; ++c) { |
| 304 | src_ptr[c] = rnd.Rand16() & hbd_mask; |
| 305 | dst_ptr[c] = rnd.Rand16() & hbd_mask; |
| 306 | dst_ref_ptr[c] = dst_ptr[c]; |
| 307 | } |
| 308 | src_ptr += stride; |
| 309 | dst_ptr += stride; |
| 310 | dst_ref_ptr += stride; |
| 311 | } |
| 312 | } |
| 313 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 314 | void AV1HbdConvolveOptimzTest::DiffFilterBuffer() { |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 315 | int r, c; |
| 316 | const uint16_t *dst_ptr = dst_; |
| 317 | const uint16_t *dst_ref_ptr = dst_ref_; |
| 318 | for (r = 0; r < height_; ++r) { |
| 319 | for (c = 0; c < width_; ++c) { |
| 320 | EXPECT_EQ((uint16_t)dst_ref_ptr[c], (uint16_t)dst_ptr[c]) |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 321 | << "Error at row: " << r << " col: " << c << " " |
| 322 | << "w = " << width_ << " " |
| 323 | << "h = " << height_ << " " |
| 324 | << "filter group index = " << filter_ << " " |
| 325 | << "filter index = " << subpel_ << " " |
| 326 | << "bit depth = " << bit_depth_; |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 327 | } |
| 328 | dst_ptr += stride; |
| 329 | dst_ref_ptr += stride; |
| 330 | } |
| 331 | } |
| 332 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 333 | void AV1HbdConvolveOptimzTest::RunHorizFilterBitExactCheck() { |
Urvang Joshi | d71a231 | 2016-07-14 12:33:48 -0700 | [diff] [blame] | 334 | PrepFilterBuffer(); |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 335 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 336 | InterpFilterParams filter_params = av1_get_interp_filter_params(filter_); |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 337 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 338 | av1_highbd_convolve_horiz_c(src_, stride, dst_ref_, stride, width_, height_, |
| 339 | filter_params, subpel_, x_step_q4, avg_, |
| 340 | bit_depth_); |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 341 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 342 | conv_horiz_(src_, stride, dst_, stride, width_, height_, filter_params, |
| 343 | subpel_, x_step_q4, avg_, bit_depth_); |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 344 | |
| 345 | DiffFilterBuffer(); |
| 346 | |
| 347 | // Note: |
| 348 | // Here we need calculate a height which is different from the specified one |
| 349 | // and test again. |
| 350 | int intermediate_height = |
| 351 | (((height_ - 1) * 16 + subpel_) >> SUBPEL_BITS) + filter_params.taps; |
Urvang Joshi | d71a231 | 2016-07-14 12:33:48 -0700 | [diff] [blame] | 352 | PrepFilterBuffer(); |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 353 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 354 | av1_highbd_convolve_horiz_c(src_, stride, dst_ref_, stride, width_, |
| 355 | intermediate_height, filter_params, subpel_, |
| 356 | x_step_q4, avg_, bit_depth_); |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 357 | |
| 358 | conv_horiz_(src_, stride, dst_, stride, width_, intermediate_height, |
| 359 | filter_params, subpel_, x_step_q4, avg_, bit_depth_); |
| 360 | |
| 361 | DiffFilterBuffer(); |
| 362 | } |
| 363 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 364 | void AV1HbdConvolveOptimzTest::RunVertFilterBitExactCheck() { |
Urvang Joshi | d71a231 | 2016-07-14 12:33:48 -0700 | [diff] [blame] | 365 | PrepFilterBuffer(); |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 366 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 367 | InterpFilterParams filter_params = av1_get_interp_filter_params(filter_); |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 368 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 369 | av1_highbd_convolve_vert_c(src_, stride, dst_ref_, stride, width_, height_, |
| 370 | filter_params, subpel_, x_step_q4, avg_, |
| 371 | bit_depth_); |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 372 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 373 | conv_vert_(src_, stride, dst_, stride, width_, height_, filter_params, |
| 374 | subpel_, x_step_q4, avg_, bit_depth_); |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 375 | |
| 376 | DiffFilterBuffer(); |
| 377 | } |
| 378 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 379 | TEST_P(AV1HbdConvolveOptimzTest, HorizBitExactCheck) { |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 380 | RunHorizFilterBitExactCheck(); |
| 381 | } |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 382 | TEST_P(AV1HbdConvolveOptimzTest, VertBitExactCheck) { |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 383 | RunVertFilterBitExactCheck(); |
| 384 | } |
| 385 | |
Angie Chiang | 1733f6b | 2017-01-05 09:52:20 -0800 | [diff] [blame] | 386 | #if HAVE_SSE4_1 && CONFIG_DUAL_FILTER |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 387 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 388 | const int kBitdepth[] = { 10, 12 }; |
Yi Luo | 8cacca7 | 2016-07-08 15:41:59 -0700 | [diff] [blame] | 389 | |
| 390 | INSTANTIATE_TEST_CASE_P( |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 391 | SSE4_1, AV1HbdConvolveOptimzTest, |
| 392 | ::testing::Combine(::testing::Values(av1_highbd_convolve_horiz_sse4_1), |
| 393 | ::testing::Values(av1_highbd_convolve_vert_sse4_1), |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 394 | ::testing::ValuesIn(kBlockDim), |
| 395 | ::testing::ValuesIn(kFilter), |
| 396 | ::testing::ValuesIn(kSubpelQ4), |
| 397 | ::testing::ValuesIn(kAvg), |
| 398 | ::testing::ValuesIn(kBitdepth))); |
Angie Chiang | 1733f6b | 2017-01-05 09:52:20 -0800 | [diff] [blame] | 399 | #endif // HAVE_SSE4_1 && CONFIG_DUAL_FILTER |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 400 | #endif // CONFIG_AOM_HIGHBITDEPTH |
Yi Luo | 229690a | 2016-06-13 17:01:17 -0700 | [diff] [blame] | 401 | } // namespace |