Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -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 |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -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. |
| 10 | */ |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 11 | |
| 12 | #include <string> |
| 13 | |
Tom Finegan | 7a07ece | 2017-02-07 17:14:05 -0800 | [diff] [blame] | 14 | #include "third_party/googletest/src/googletest/include/gtest/gtest.h" |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 15 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 16 | #include "./aom_config.h" |
| 17 | #include "./aom_dsp_rtcd.h" |
Jingning Han | 097d59c | 2015-07-29 14:51:36 -0700 | [diff] [blame] | 18 | #include "test/acm_random.h" |
| 19 | #include "test/clear_system_state.h" |
| 20 | #include "test/register_state_check.h" |
| 21 | #include "test/util.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 22 | #include "av1/common/blockd.h" |
| 23 | #include "av1/common/pred_common.h" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 24 | #include "aom_mem/aom_mem.h" |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 25 | |
| 26 | namespace { |
| 27 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 28 | using libaom_test::ACMRandom; |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 29 | |
| 30 | const int count_test_block = 100000; |
| 31 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 32 | typedef void (*IntraPred)(uint16_t *dst, ptrdiff_t stride, |
| 33 | const uint16_t *above, const uint16_t *left, int bps); |
Johann | 2967bf3 | 2016-06-22 16:08:10 -0700 | [diff] [blame] | 34 | |
| 35 | struct IntraPredFunc { |
| 36 | IntraPredFunc(IntraPred pred = NULL, IntraPred ref = NULL, |
| 37 | int block_size_value = 0, int bit_depth_value = 0) |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 38 | : pred_fn(pred), ref_fn(ref), block_size(block_size_value), |
| 39 | bit_depth(bit_depth_value) {} |
Johann | 2967bf3 | 2016-06-22 16:08:10 -0700 | [diff] [blame] | 40 | |
| 41 | IntraPred pred_fn; |
| 42 | IntraPred ref_fn; |
| 43 | int block_size; |
| 44 | int bit_depth; |
| 45 | }; |
| 46 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 47 | class AV1IntraPredTest : public ::testing::TestWithParam<IntraPredFunc> { |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 48 | public: |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 49 | void RunTest(uint16_t *left_col, uint16_t *above_data, uint16_t *dst, |
| 50 | uint16_t *ref_dst) { |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 51 | ACMRandom rnd(ACMRandom::DeterministicSeed()); |
Johann | 2967bf3 | 2016-06-22 16:08:10 -0700 | [diff] [blame] | 52 | const int block_size = params_.block_size; |
| 53 | above_row_ = above_data + 16; |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 54 | left_col_ = left_col; |
| 55 | dst_ = dst; |
| 56 | ref_dst_ = ref_dst; |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 57 | int error_count = 0; |
| 58 | for (int i = 0; i < count_test_block; ++i) { |
| 59 | // Fill edges with random data, try first with saturated values. |
Johann | 2967bf3 | 2016-06-22 16:08:10 -0700 | [diff] [blame] | 60 | for (int x = -1; x <= block_size * 2; x++) { |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 61 | if (i == 0) { |
| 62 | above_row_[x] = mask_; |
| 63 | } else { |
| 64 | above_row_[x] = rnd.Rand16() & mask_; |
| 65 | } |
| 66 | } |
Johann | 2967bf3 | 2016-06-22 16:08:10 -0700 | [diff] [blame] | 67 | for (int y = 0; y < block_size; y++) { |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 68 | if (i == 0) { |
| 69 | left_col_[y] = mask_; |
| 70 | } else { |
| 71 | left_col_[y] = rnd.Rand16() & mask_; |
| 72 | } |
| 73 | } |
James Zern | cffef11 | 2016-02-11 18:27:00 -0800 | [diff] [blame] | 74 | Predict(); |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 75 | CheckPrediction(i, &error_count); |
| 76 | } |
| 77 | ASSERT_EQ(0, error_count); |
| 78 | } |
| 79 | |
Johann | 2967bf3 | 2016-06-22 16:08:10 -0700 | [diff] [blame] | 80 | protected: |
| 81 | virtual void SetUp() { |
| 82 | params_ = GetParam(); |
| 83 | stride_ = params_.block_size * 3; |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 84 | mask_ = (1 << params_.bit_depth) - 1; |
Johann | 2967bf3 | 2016-06-22 16:08:10 -0700 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | void Predict() { |
| 88 | const int bit_depth = params_.bit_depth; |
| 89 | params_.ref_fn(ref_dst_, stride_, above_row_, left_col_, bit_depth); |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 90 | ASM_REGISTER_STATE_CHECK( |
| 91 | params_.pred_fn(dst_, stride_, above_row_, left_col_, bit_depth)); |
Johann | 2967bf3 | 2016-06-22 16:08:10 -0700 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | void CheckPrediction(int test_case_number, int *error_count) const { |
| 95 | // For each pixel ensure that the calculated value is the same as reference. |
| 96 | const int block_size = params_.block_size; |
| 97 | for (int y = 0; y < block_size; y++) { |
| 98 | for (int x = 0; x < block_size; x++) { |
| 99 | *error_count += ref_dst_[x + y * stride_] != dst_[x + y * stride_]; |
| 100 | if (*error_count == 1) { |
| 101 | ASSERT_EQ(ref_dst_[x + y * stride_], dst_[x + y * stride_]) |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 102 | << " Failed on Test Case Number " << test_case_number; |
Johann | 2967bf3 | 2016-06-22 16:08:10 -0700 | [diff] [blame] | 103 | } |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 108 | uint16_t *above_row_; |
| 109 | uint16_t *left_col_; |
| 110 | uint16_t *dst_; |
| 111 | uint16_t *ref_dst_; |
| 112 | ptrdiff_t stride_; |
| 113 | int mask_; |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 114 | |
Johann | 2967bf3 | 2016-06-22 16:08:10 -0700 | [diff] [blame] | 115 | IntraPredFunc params_; |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 116 | }; |
| 117 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 118 | TEST_P(AV1IntraPredTest, IntraPredTests) { |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 119 | // max block size is 32 |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 120 | DECLARE_ALIGNED(16, uint16_t, left_col[2 * 32]); |
| 121 | DECLARE_ALIGNED(16, uint16_t, above_data[2 * 32 + 32]); |
James Zern | fd3658b | 2015-05-02 13:24:16 -0700 | [diff] [blame] | 122 | DECLARE_ALIGNED(16, uint16_t, dst[3 * 32 * 32]); |
| 123 | DECLARE_ALIGNED(16, uint16_t, ref_dst[3 * 32 * 32]); |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 124 | RunTest(left_col, above_data, dst, ref_dst); |
| 125 | } |
| 126 | |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 127 | #if HAVE_SSE2 |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 128 | #if CONFIG_HIGHBITDEPTH |
Yaowu Xu | 1659191 | 2017-05-03 08:58:12 -0700 | [diff] [blame] | 129 | const IntraPredFunc IntraPredTestVector8[] = { |
| 130 | IntraPredFunc(&aom_highbd_dc_predictor_32x32_sse2, |
| 131 | &aom_highbd_dc_predictor_32x32_c, 32, 8), |
Urvang Joshi | 340593e | 2016-09-01 12:03:20 -0700 | [diff] [blame] | 132 | #if !CONFIG_ALT_INTRA |
Yaowu Xu | 1659191 | 2017-05-03 08:58:12 -0700 | [diff] [blame] | 133 | IntraPredFunc(&aom_highbd_tm_predictor_16x16_sse2, |
| 134 | &aom_highbd_tm_predictor_16x16_c, 16, 8), |
| 135 | IntraPredFunc(&aom_highbd_tm_predictor_32x32_sse2, |
| 136 | &aom_highbd_tm_predictor_32x32_c, 32, 8), |
Urvang Joshi | 340593e | 2016-09-01 12:03:20 -0700 | [diff] [blame] | 137 | #endif // !CONFIG_ALT_INTRA |
| 138 | |
Yaowu Xu | 1659191 | 2017-05-03 08:58:12 -0700 | [diff] [blame] | 139 | IntraPredFunc(&aom_highbd_dc_predictor_4x4_sse2, |
| 140 | &aom_highbd_dc_predictor_4x4_c, 4, 8), |
| 141 | IntraPredFunc(&aom_highbd_dc_predictor_8x8_sse2, |
| 142 | &aom_highbd_dc_predictor_8x8_c, 8, 8), |
| 143 | IntraPredFunc(&aom_highbd_dc_predictor_16x16_sse2, |
| 144 | &aom_highbd_dc_predictor_16x16_c, 16, 8), |
| 145 | IntraPredFunc(&aom_highbd_v_predictor_4x4_sse2, &aom_highbd_v_predictor_4x4_c, |
| 146 | 4, 8), |
| 147 | IntraPredFunc(&aom_highbd_v_predictor_8x8_sse2, &aom_highbd_v_predictor_8x8_c, |
| 148 | 8, 8), |
| 149 | IntraPredFunc(&aom_highbd_v_predictor_16x16_sse2, |
| 150 | &aom_highbd_v_predictor_16x16_c, 16, 8), |
| 151 | IntraPredFunc(&aom_highbd_v_predictor_32x32_sse2, |
| 152 | &aom_highbd_v_predictor_32x32_c, 32, 8) |
Urvang Joshi | 340593e | 2016-09-01 12:03:20 -0700 | [diff] [blame] | 153 | #if !CONFIG_ALT_INTRA |
Yaowu Xu | 1659191 | 2017-05-03 08:58:12 -0700 | [diff] [blame] | 154 | , |
| 155 | IntraPredFunc(&aom_highbd_tm_predictor_4x4_sse2, |
| 156 | &aom_highbd_tm_predictor_4x4_c, 4, 8), |
| 157 | IntraPredFunc(&aom_highbd_tm_predictor_8x8_sse2, |
| 158 | &aom_highbd_tm_predictor_8x8_c, 8, 8) |
Urvang Joshi | 340593e | 2016-09-01 12:03:20 -0700 | [diff] [blame] | 159 | #endif // !CONFIG_ALT_INTRA |
Yaowu Xu | 1659191 | 2017-05-03 08:58:12 -0700 | [diff] [blame] | 160 | }; |
Johann | 1c967f1 | 2015-06-29 17:04:58 -0700 | [diff] [blame] | 161 | |
Yaowu Xu | 1659191 | 2017-05-03 08:58:12 -0700 | [diff] [blame] | 162 | INSTANTIATE_TEST_CASE_P(SSE2_TO_C_8, AV1IntraPredTest, |
| 163 | ::testing::ValuesIn(IntraPredTestVector8)); |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 164 | |
Yaowu Xu | 1659191 | 2017-05-03 08:58:12 -0700 | [diff] [blame] | 165 | const IntraPredFunc IntraPredTestVector10[] = { |
| 166 | IntraPredFunc(&aom_highbd_dc_predictor_32x32_sse2, |
| 167 | &aom_highbd_dc_predictor_32x32_c, 32, 10), |
Urvang Joshi | 340593e | 2016-09-01 12:03:20 -0700 | [diff] [blame] | 168 | #if !CONFIG_ALT_INTRA |
Yaowu Xu | 1659191 | 2017-05-03 08:58:12 -0700 | [diff] [blame] | 169 | IntraPredFunc(&aom_highbd_tm_predictor_16x16_sse2, |
| 170 | &aom_highbd_tm_predictor_16x16_c, 16, 10), |
| 171 | IntraPredFunc(&aom_highbd_tm_predictor_32x32_sse2, |
| 172 | &aom_highbd_tm_predictor_32x32_c, 32, 10), |
Urvang Joshi | 340593e | 2016-09-01 12:03:20 -0700 | [diff] [blame] | 173 | #endif // !CONFIG_ALT_INTRA |
Yaowu Xu | 1659191 | 2017-05-03 08:58:12 -0700 | [diff] [blame] | 174 | IntraPredFunc(&aom_highbd_dc_predictor_4x4_sse2, |
| 175 | &aom_highbd_dc_predictor_4x4_c, 4, 10), |
| 176 | IntraPredFunc(&aom_highbd_dc_predictor_8x8_sse2, |
| 177 | &aom_highbd_dc_predictor_8x8_c, 8, 10), |
| 178 | IntraPredFunc(&aom_highbd_dc_predictor_16x16_sse2, |
| 179 | &aom_highbd_dc_predictor_16x16_c, 16, 10), |
| 180 | IntraPredFunc(&aom_highbd_v_predictor_4x4_sse2, &aom_highbd_v_predictor_4x4_c, |
| 181 | 4, 10), |
| 182 | IntraPredFunc(&aom_highbd_v_predictor_8x8_sse2, &aom_highbd_v_predictor_8x8_c, |
| 183 | 8, 10), |
| 184 | IntraPredFunc(&aom_highbd_v_predictor_16x16_sse2, |
| 185 | &aom_highbd_v_predictor_16x16_c, 16, 10), |
| 186 | IntraPredFunc(&aom_highbd_v_predictor_32x32_sse2, |
| 187 | &aom_highbd_v_predictor_32x32_c, 32, 10) |
Urvang Joshi | 340593e | 2016-09-01 12:03:20 -0700 | [diff] [blame] | 188 | #if !CONFIG_ALT_INTRA |
Yaowu Xu | 1659191 | 2017-05-03 08:58:12 -0700 | [diff] [blame] | 189 | , |
| 190 | IntraPredFunc(&aom_highbd_tm_predictor_4x4_sse2, |
| 191 | &aom_highbd_tm_predictor_4x4_c, 4, 10), |
| 192 | IntraPredFunc(&aom_highbd_tm_predictor_8x8_sse2, |
| 193 | &aom_highbd_tm_predictor_8x8_c, 8, 10) |
Urvang Joshi | 340593e | 2016-09-01 12:03:20 -0700 | [diff] [blame] | 194 | #endif // !CONFIG_ALT_INTRA |
Yaowu Xu | 1659191 | 2017-05-03 08:58:12 -0700 | [diff] [blame] | 195 | }; |
| 196 | |
| 197 | INSTANTIATE_TEST_CASE_P(SSE2_TO_C_10, AV1IntraPredTest, |
| 198 | ::testing::ValuesIn(IntraPredTestVector10)); |
| 199 | |
| 200 | const IntraPredFunc IntraPredTestVector12[] = { |
| 201 | IntraPredFunc(&aom_highbd_dc_predictor_32x32_sse2, |
| 202 | &aom_highbd_dc_predictor_32x32_c, 32, 12), |
| 203 | #if !CONFIG_ALT_INTRA |
| 204 | IntraPredFunc(&aom_highbd_tm_predictor_16x16_sse2, |
| 205 | &aom_highbd_tm_predictor_16x16_c, 16, 12), |
| 206 | IntraPredFunc(&aom_highbd_tm_predictor_32x32_sse2, |
| 207 | &aom_highbd_tm_predictor_32x32_c, 32, 12), |
| 208 | #endif // !CONFIG_ALT_INTRA |
| 209 | IntraPredFunc(&aom_highbd_dc_predictor_4x4_sse2, |
| 210 | &aom_highbd_dc_predictor_4x4_c, 4, 12), |
| 211 | IntraPredFunc(&aom_highbd_dc_predictor_8x8_sse2, |
| 212 | &aom_highbd_dc_predictor_8x8_c, 8, 12), |
| 213 | IntraPredFunc(&aom_highbd_dc_predictor_16x16_sse2, |
| 214 | &aom_highbd_dc_predictor_16x16_c, 16, 12), |
| 215 | IntraPredFunc(&aom_highbd_v_predictor_4x4_sse2, &aom_highbd_v_predictor_4x4_c, |
| 216 | 4, 12), |
| 217 | IntraPredFunc(&aom_highbd_v_predictor_8x8_sse2, &aom_highbd_v_predictor_8x8_c, |
| 218 | 8, 12), |
| 219 | IntraPredFunc(&aom_highbd_v_predictor_16x16_sse2, |
| 220 | &aom_highbd_v_predictor_16x16_c, 16, 12), |
| 221 | IntraPredFunc(&aom_highbd_v_predictor_32x32_sse2, |
| 222 | &aom_highbd_v_predictor_32x32_c, 32, 12) |
| 223 | #if !CONFIG_ALT_INTRA |
| 224 | , |
| 225 | IntraPredFunc(&aom_highbd_tm_predictor_4x4_sse2, |
| 226 | &aom_highbd_tm_predictor_4x4_c, 4, 12), |
| 227 | IntraPredFunc(&aom_highbd_tm_predictor_8x8_sse2, |
| 228 | &aom_highbd_tm_predictor_8x8_c, 8, 12) |
| 229 | #endif // !CONFIG_ALT_INTRA |
| 230 | }; |
| 231 | |
| 232 | INSTANTIATE_TEST_CASE_P(SSE2_TO_C_12, AV1IntraPredTest, |
| 233 | ::testing::ValuesIn(IntraPredTestVector12)); |
Jian Zhou | 26a6ce4 | 2015-12-22 16:51:57 -0800 | [diff] [blame] | 234 | |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 235 | #endif // CONFIG_HIGHBITDEPTH |
Deb Mukherjee | 81a8138 | 2014-09-15 12:59:19 -0700 | [diff] [blame] | 236 | #endif // HAVE_SSE2 |
| 237 | } // namespace |