Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [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 |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [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. |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <math.h> |
| 13 | #include <stdlib.h> |
| 14 | #include <string.h> |
| 15 | |
Tom Finegan | 7a07ece | 2017-02-07 17:14:05 -0800 | [diff] [blame] | 16 | #include "third_party/googletest/src/googletest/include/gtest/gtest.h" |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 17 | #include "test/register_state_check.h" |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 18 | #include "test/function_equivalence_test.h" |
| 19 | |
Tom Finegan | 60e653d | 2018-05-22 11:34:58 -0700 | [diff] [blame] | 20 | #include "config/aom_config.h" |
Tom Finegan | 44702c8 | 2018-05-22 13:00:39 -0700 | [diff] [blame] | 21 | #include "config/aom_dsp_rtcd.h" |
| 22 | #include "config/av1_rtcd.h" |
Tom Finegan | 60e653d | 2018-05-22 11:34:58 -0700 | [diff] [blame] | 23 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 24 | #include "aom/aom_integer.h" |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 25 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 26 | #include "av1/common/enums.h" |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 27 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 28 | #include "aom_dsp/blend.h" |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 29 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 30 | using libaom_test::FunctionEquivalenceTest; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 31 | |
| 32 | namespace { |
| 33 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 34 | template <typename F, typename T> |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 35 | class BlendA64Mask1DTest : public FunctionEquivalenceTest<F> { |
| 36 | public: |
| 37 | static const int kIterations = 10000; |
| 38 | static const int kMaxWidth = MAX_SB_SIZE * 5; // * 5 to cover longer strides |
| 39 | static const int kMaxHeight = MAX_SB_SIZE; |
| 40 | static const int kBufSize = kMaxWidth * kMaxHeight; |
| 41 | static const int kMaxMaskWidth = 2 * MAX_SB_SIZE; |
| 42 | static const int kMaxMaskSize = kMaxMaskWidth; |
| 43 | |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 44 | virtual ~BlendA64Mask1DTest() {} |
| 45 | |
Geza Lore | a3f7ddc | 2016-07-12 15:26:36 +0100 | [diff] [blame] | 46 | virtual void Execute(const T *p_src0, const T *p_src1) = 0; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 47 | |
| 48 | void Common() { |
Sachin Kumar Garg | 6c5d4a3 | 2018-06-20 14:24:49 +0530 | [diff] [blame] | 49 | w_ = 2 << this->rng_(MAX_SB_SIZE_LOG2); |
| 50 | h_ = 2 << this->rng_(MAX_SB_SIZE_LOG2); |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 51 | |
Geza Lore | a3f7ddc | 2016-07-12 15:26:36 +0100 | [diff] [blame] | 52 | dst_offset_ = this->rng_(33); |
| 53 | dst_stride_ = this->rng_(kMaxWidth + 1 - w_) + w_; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 54 | |
Geza Lore | a3f7ddc | 2016-07-12 15:26:36 +0100 | [diff] [blame] | 55 | src0_offset_ = this->rng_(33); |
| 56 | src0_stride_ = this->rng_(kMaxWidth + 1 - w_) + w_; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 57 | |
Geza Lore | a3f7ddc | 2016-07-12 15:26:36 +0100 | [diff] [blame] | 58 | src1_offset_ = this->rng_(33); |
| 59 | src1_stride_ = this->rng_(kMaxWidth + 1 - w_) + w_; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 60 | |
| 61 | T *p_src0; |
| 62 | T *p_src1; |
| 63 | |
Geza Lore | a3f7ddc | 2016-07-12 15:26:36 +0100 | [diff] [blame] | 64 | switch (this->rng_(3)) { |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 65 | case 0: // Separate sources |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 66 | p_src0 = src0_; |
| 67 | p_src1 = src1_; |
| 68 | break; |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 69 | case 1: // src0 == dst |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 70 | p_src0 = dst_tst_; |
| 71 | src0_stride_ = dst_stride_; |
| 72 | src0_offset_ = dst_offset_; |
| 73 | p_src1 = src1_; |
| 74 | break; |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 75 | case 2: // src1 == dst |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 76 | p_src0 = src0_; |
| 77 | p_src1 = dst_tst_; |
| 78 | src1_stride_ = dst_stride_; |
| 79 | src1_offset_ = dst_offset_; |
| 80 | break; |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 81 | default: FAIL(); |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | Execute(p_src0, p_src1); |
| 85 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 86 | for (int r = 0; r < h_; ++r) { |
| 87 | for (int c = 0; c < w_; ++c) { |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 88 | ASSERT_EQ(dst_ref_[dst_offset_ + r * dst_stride_ + c], |
| 89 | dst_tst_[dst_offset_ + r * dst_stride_ + c]); |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 94 | T dst_ref_[kBufSize]; |
| 95 | T dst_tst_[kBufSize]; |
Pascal Massimino | 04ed7ad | 2016-08-29 09:09:09 +0200 | [diff] [blame] | 96 | uint32_t dst_stride_; |
| 97 | uint32_t dst_offset_; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 98 | |
| 99 | T src0_[kBufSize]; |
Pascal Massimino | 04ed7ad | 2016-08-29 09:09:09 +0200 | [diff] [blame] | 100 | uint32_t src0_stride_; |
| 101 | uint32_t src0_offset_; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 102 | |
| 103 | T src1_[kBufSize]; |
Pascal Massimino | 04ed7ad | 2016-08-29 09:09:09 +0200 | [diff] [blame] | 104 | uint32_t src1_stride_; |
| 105 | uint32_t src1_offset_; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 106 | |
| 107 | uint8_t mask_[kMaxMaskSize]; |
| 108 | |
| 109 | int w_; |
| 110 | int h_; |
| 111 | }; |
| 112 | |
| 113 | ////////////////////////////////////////////////////////////////////////////// |
| 114 | // 8 bit version |
| 115 | ////////////////////////////////////////////////////////////////////////////// |
| 116 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 117 | typedef void (*F8B)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, |
| 118 | uint32_t src0_stride, const uint8_t *src1, |
Scott LaVarnway | 589b7a1 | 2018-06-06 06:29:16 -0700 | [diff] [blame] | 119 | uint32_t src1_stride, const uint8_t *mask, int w, int h); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 120 | typedef libaom_test::FuncParam<F8B> TestFuncs; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 121 | |
| 122 | class BlendA64Mask1DTest8B : public BlendA64Mask1DTest<F8B, uint8_t> { |
| 123 | protected: |
Geza Lore | a3f7ddc | 2016-07-12 15:26:36 +0100 | [diff] [blame] | 124 | void Execute(const uint8_t *p_src0, const uint8_t *p_src1) { |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 125 | params_.ref_func(dst_ref_ + dst_offset_, dst_stride_, p_src0 + src0_offset_, |
| 126 | src0_stride_, p_src1 + src1_offset_, src1_stride_, mask_, |
Scott LaVarnway | 589b7a1 | 2018-06-06 06:29:16 -0700 | [diff] [blame] | 127 | w_, h_); |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 128 | ASM_REGISTER_STATE_CHECK(params_.tst_func( |
| 129 | dst_tst_ + dst_offset_, dst_stride_, p_src0 + src0_offset_, |
Scott LaVarnway | 589b7a1 | 2018-06-06 06:29:16 -0700 | [diff] [blame] | 130 | src0_stride_, p_src1 + src1_offset_, src1_stride_, mask_, w_, h_)); |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 131 | } |
| 132 | }; |
| 133 | |
| 134 | TEST_P(BlendA64Mask1DTest8B, RandomValues) { |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 135 | for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) { |
| 136 | for (int i = 0; i < kBufSize; ++i) { |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 137 | dst_ref_[i] = rng_.Rand8(); |
| 138 | dst_tst_[i] = rng_.Rand8(); |
| 139 | |
| 140 | src0_[i] = rng_.Rand8(); |
| 141 | src1_[i] = rng_.Rand8(); |
| 142 | } |
| 143 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 144 | for (int i = 0; i < kMaxMaskSize; ++i) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 145 | mask_[i] = rng_(AOM_BLEND_A64_MAX_ALPHA + 1); |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 146 | |
| 147 | Common(); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | TEST_P(BlendA64Mask1DTest8B, ExtremeValues) { |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 152 | for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) { |
| 153 | for (int i = 0; i < kBufSize; ++i) { |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 154 | dst_ref_[i] = rng_(2) + 254; |
| 155 | dst_tst_[i] = rng_(2) + 254; |
| 156 | src0_[i] = rng_(2) + 254; |
| 157 | src1_[i] = rng_(2) + 254; |
| 158 | } |
| 159 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 160 | for (int i = 0; i < kMaxMaskSize; ++i) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 161 | mask_[i] = rng_(2) + AOM_BLEND_A64_MAX_ALPHA - 1; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 162 | |
| 163 | Common(); |
| 164 | } |
| 165 | } |
| 166 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 167 | static void blend_a64_hmask_ref(uint8_t *dst, uint32_t dst_stride, |
| 168 | const uint8_t *src0, uint32_t src0_stride, |
| 169 | const uint8_t *src1, uint32_t src1_stride, |
Scott LaVarnway | 589b7a1 | 2018-06-06 06:29:16 -0700 | [diff] [blame] | 170 | const uint8_t *mask, int w, int h) { |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 171 | uint8_t mask2d[BlendA64Mask1DTest8B::kMaxMaskSize] |
| 172 | [BlendA64Mask1DTest8B::kMaxMaskSize]; |
| 173 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 174 | for (int row = 0; row < h; ++row) |
| 175 | for (int col = 0; col < w; ++col) mask2d[row][col] = mask[col]; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 176 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 177 | aom_blend_a64_mask_c(dst, dst_stride, src0, src0_stride, src1, src1_stride, |
Scott LaVarnway | 589b7a1 | 2018-06-06 06:29:16 -0700 | [diff] [blame] | 178 | &mask2d[0][0], BlendA64Mask1DTest8B::kMaxMaskSize, w, h, |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 179 | 0, 0); |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 180 | } |
| 181 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 182 | static void blend_a64_vmask_ref(uint8_t *dst, uint32_t dst_stride, |
| 183 | const uint8_t *src0, uint32_t src0_stride, |
| 184 | const uint8_t *src1, uint32_t src1_stride, |
Scott LaVarnway | 589b7a1 | 2018-06-06 06:29:16 -0700 | [diff] [blame] | 185 | const uint8_t *mask, int w, int h) { |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 186 | uint8_t mask2d[BlendA64Mask1DTest8B::kMaxMaskSize] |
| 187 | [BlendA64Mask1DTest8B::kMaxMaskSize]; |
| 188 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 189 | for (int row = 0; row < h; ++row) |
| 190 | for (int col = 0; col < w; ++col) mask2d[row][col] = mask[row]; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 191 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 192 | aom_blend_a64_mask_c(dst, dst_stride, src0, src0_stride, src1, src1_stride, |
Scott LaVarnway | 589b7a1 | 2018-06-06 06:29:16 -0700 | [diff] [blame] | 193 | &mask2d[0][0], BlendA64Mask1DTest8B::kMaxMaskSize, w, h, |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 194 | 0, 0); |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | INSTANTIATE_TEST_CASE_P( |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 198 | C, BlendA64Mask1DTest8B, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 199 | ::testing::Values(TestFuncs(blend_a64_hmask_ref, aom_blend_a64_hmask_c), |
| 200 | TestFuncs(blend_a64_vmask_ref, aom_blend_a64_vmask_c))); |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 201 | |
| 202 | #if HAVE_SSE4_1 |
| 203 | INSTANTIATE_TEST_CASE_P( |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 204 | SSE4_1, BlendA64Mask1DTest8B, |
| 205 | ::testing::Values( |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 206 | TestFuncs(blend_a64_hmask_ref, aom_blend_a64_hmask_sse4_1), |
| 207 | TestFuncs(blend_a64_vmask_ref, aom_blend_a64_vmask_sse4_1))); |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 208 | #endif // HAVE_SSE4_1 |
| 209 | |
Sachin Kumar Garg | 6c5d4a3 | 2018-06-20 14:24:49 +0530 | [diff] [blame] | 210 | #if HAVE_NEON |
| 211 | INSTANTIATE_TEST_CASE_P(NEON, BlendA64Mask1DTest8B, |
| 212 | ::testing::Values(TestFuncs(blend_a64_hmask_ref, |
| 213 | aom_blend_a64_hmask_neon), |
| 214 | TestFuncs(blend_a64_vmask_ref, |
| 215 | aom_blend_a64_vmask_neon))); |
| 216 | #endif // HAVE_NEON |
| 217 | |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 218 | ////////////////////////////////////////////////////////////////////////////// |
| 219 | // High bit-depth version |
| 220 | ////////////////////////////////////////////////////////////////////////////// |
| 221 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 222 | typedef void (*FHBD)(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, |
| 223 | uint32_t src0_stride, const uint8_t *src1, |
Scott LaVarnway | 589b7a1 | 2018-06-06 06:29:16 -0700 | [diff] [blame] | 224 | uint32_t src1_stride, const uint8_t *mask, int w, int h, |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 225 | int bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 226 | typedef libaom_test::FuncParam<FHBD> TestFuncsHBD; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 227 | |
| 228 | class BlendA64Mask1DTestHBD : public BlendA64Mask1DTest<FHBD, uint16_t> { |
| 229 | protected: |
Geza Lore | a3f7ddc | 2016-07-12 15:26:36 +0100 | [diff] [blame] | 230 | void Execute(const uint16_t *p_src0, const uint16_t *p_src1) { |
| 231 | params_.ref_func(CONVERT_TO_BYTEPTR(dst_ref_ + dst_offset_), dst_stride_, |
| 232 | CONVERT_TO_BYTEPTR(p_src0 + src0_offset_), src0_stride_, |
| 233 | CONVERT_TO_BYTEPTR(p_src1 + src1_offset_), src1_stride_, |
Scott LaVarnway | 589b7a1 | 2018-06-06 06:29:16 -0700 | [diff] [blame] | 234 | mask_, w_, h_, bit_depth_); |
Geza Lore | a3f7ddc | 2016-07-12 15:26:36 +0100 | [diff] [blame] | 235 | ASM_REGISTER_STATE_CHECK(params_.tst_func( |
| 236 | CONVERT_TO_BYTEPTR(dst_tst_ + dst_offset_), dst_stride_, |
| 237 | CONVERT_TO_BYTEPTR(p_src0 + src0_offset_), src0_stride_, |
Scott LaVarnway | 589b7a1 | 2018-06-06 06:29:16 -0700 | [diff] [blame] | 238 | CONVERT_TO_BYTEPTR(p_src1 + src1_offset_), src1_stride_, mask_, w_, h_, |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 239 | bit_depth_)); |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | int bit_depth_; |
| 243 | }; |
| 244 | |
| 245 | TEST_P(BlendA64Mask1DTestHBD, RandomValues) { |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 246 | for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) { |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 247 | switch (rng_(3)) { |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 248 | case 0: bit_depth_ = 8; break; |
| 249 | case 1: bit_depth_ = 10; break; |
| 250 | default: bit_depth_ = 12; break; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | const int hi = 1 << bit_depth_; |
| 254 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 255 | for (int i = 0; i < kBufSize; ++i) { |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 256 | dst_ref_[i] = rng_(hi); |
| 257 | dst_tst_[i] = rng_(hi); |
| 258 | src0_[i] = rng_(hi); |
| 259 | src1_[i] = rng_(hi); |
| 260 | } |
| 261 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 262 | for (int i = 0; i < kMaxMaskSize; ++i) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 263 | mask_[i] = rng_(AOM_BLEND_A64_MAX_ALPHA + 1); |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 264 | |
| 265 | Common(); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | TEST_P(BlendA64Mask1DTestHBD, ExtremeValues) { |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 270 | for (int iter = 0; iter < 1000 && !HasFatalFailure(); ++iter) { |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 271 | switch (rng_(3)) { |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 272 | case 0: bit_depth_ = 8; break; |
| 273 | case 1: bit_depth_ = 10; break; |
| 274 | default: bit_depth_ = 12; break; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | const int hi = 1 << bit_depth_; |
| 278 | const int lo = hi - 2; |
| 279 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 280 | for (int i = 0; i < kBufSize; ++i) { |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 281 | dst_ref_[i] = rng_(hi - lo) + lo; |
| 282 | dst_tst_[i] = rng_(hi - lo) + lo; |
| 283 | src0_[i] = rng_(hi - lo) + lo; |
| 284 | src1_[i] = rng_(hi - lo) + lo; |
| 285 | } |
| 286 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 287 | for (int i = 0; i < kMaxMaskSize; ++i) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 288 | mask_[i] = rng_(2) + AOM_BLEND_A64_MAX_ALPHA - 1; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 289 | |
| 290 | Common(); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | static void highbd_blend_a64_hmask_ref( |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 295 | uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, |
| 296 | uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, |
Scott LaVarnway | 589b7a1 | 2018-06-06 06:29:16 -0700 | [diff] [blame] | 297 | const uint8_t *mask, int w, int h, int bd) { |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 298 | uint8_t mask2d[BlendA64Mask1DTestHBD::kMaxMaskSize] |
| 299 | [BlendA64Mask1DTestHBD::kMaxMaskSize]; |
| 300 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 301 | for (int row = 0; row < h; ++row) |
| 302 | for (int col = 0; col < w; ++col) mask2d[row][col] = mask[col]; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 303 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 304 | aom_highbd_blend_a64_mask_c( |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 305 | dst, dst_stride, src0, src0_stride, src1, src1_stride, &mask2d[0][0], |
Scott LaVarnway | 589b7a1 | 2018-06-06 06:29:16 -0700 | [diff] [blame] | 306 | BlendA64Mask1DTestHBD::kMaxMaskSize, w, h, 0, 0, bd); |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | static void highbd_blend_a64_vmask_ref( |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 310 | uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, |
| 311 | uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, |
Scott LaVarnway | 589b7a1 | 2018-06-06 06:29:16 -0700 | [diff] [blame] | 312 | const uint8_t *mask, int w, int h, int bd) { |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 313 | uint8_t mask2d[BlendA64Mask1DTestHBD::kMaxMaskSize] |
| 314 | [BlendA64Mask1DTestHBD::kMaxMaskSize]; |
| 315 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 316 | for (int row = 0; row < h; ++row) |
| 317 | for (int col = 0; col < w; ++col) mask2d[row][col] = mask[row]; |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 318 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 319 | aom_highbd_blend_a64_mask_c( |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 320 | dst, dst_stride, src0, src0_stride, src1, src1_stride, &mask2d[0][0], |
Scott LaVarnway | 589b7a1 | 2018-06-06 06:29:16 -0700 | [diff] [blame] | 321 | BlendA64Mask1DTestHBD::kMaxMaskSize, w, h, 0, 0, bd); |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | INSTANTIATE_TEST_CASE_P( |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 325 | C, BlendA64Mask1DTestHBD, |
| 326 | ::testing::Values(TestFuncsHBD(highbd_blend_a64_hmask_ref, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 327 | aom_highbd_blend_a64_hmask_c), |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 328 | TestFuncsHBD(highbd_blend_a64_vmask_ref, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 329 | aom_highbd_blend_a64_vmask_c))); |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 330 | |
| 331 | #if HAVE_SSE4_1 |
| 332 | INSTANTIATE_TEST_CASE_P( |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 333 | SSE4_1, BlendA64Mask1DTestHBD, |
| 334 | ::testing::Values(TestFuncsHBD(highbd_blend_a64_hmask_ref, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 335 | aom_highbd_blend_a64_hmask_sse4_1), |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 336 | TestFuncsHBD(highbd_blend_a64_vmask_ref, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 337 | aom_highbd_blend_a64_vmask_sse4_1))); |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 338 | #endif // HAVE_SSE4_1 |
Geza Lore | bfa59b4 | 2016-07-11 12:43:47 +0100 | [diff] [blame] | 339 | } // namespace |