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