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