1 // Copyright 2021 The libgav1 Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "src/dsp/intra_edge.h"
16
17 #include <cstdint>
18 #include <cstdio>
19 #include <ostream>
20
21 #include "absl/strings/match.h"
22 #include "absl/strings/string_view.h"
23 #include "absl/time/clock.h"
24 #include "absl/time/time.h"
25 #include "gtest/gtest.h"
26 #include "src/dsp/dsp.h"
27 #include "src/utils/compiler_attributes.h"
28 #include "src/utils/constants.h"
29 #include "src/utils/cpu.h"
30 #include "tests/third_party/libvpx/acm_random.h"
31 #include "tests/utils.h"
32
33 namespace libgav1 {
34 namespace dsp {
35 namespace {
36
37 const char kIntraEdge[] = "IntraEdge";
38 const char kIntraEdgeFilterName[] = "Intra Edge Filter";
39 const char kIntraEdgeUpsamplerName[] = "Intra Edge Upsampler";
40
41 constexpr int kIntraEdgeBufferSize = 144; // see Tile::IntraPrediction.
42 constexpr int kIntraEdgeFilterTestMaxSize = 129;
43 constexpr int kIntraEdgeFilterTestFixedInput[kIntraEdgeFilterTestMaxSize] = {
44 159, 208, 54, 136, 205, 124, 125, 165, 164, 63, 171, 143, 210, 236, 253,
45 233, 139, 113, 66, 211, 133, 61, 91, 123, 187, 76, 110, 172, 61, 103,
46 239, 147, 247, 120, 18, 106, 180, 159, 208, 54, 136, 205, 124, 125, 165,
47 164, 63, 171, 143, 210, 236, 253, 233, 139, 113, 66, 211, 133, 61, 91,
48 123, 187, 76, 110, 172, 61, 103, 239, 147, 247, 120, 18, 106, 180, 159,
49 208, 54, 136, 205, 124, 125, 165, 164, 63, 171, 143, 210, 236, 253, 233,
50 139, 113, 66, 211, 133, 61, 91, 123, 187, 76, 110, 172, 61, 103, 239,
51 147, 247, 120, 18, 106, 180, 159, 208, 54, 136, 205, 124, 125, 165, 164,
52 63, 171, 143, 210, 236, 253, 233, 139, 113,
53 };
54 constexpr int kIntraEdgeUpsamplerTestFixedInput[] = {
55 208, 54, 136, 205, 124, 125, 165, 164, 63,
56 171, 143, 210, 236, 208, 54, 136, 205};
57
58 struct EdgeFilterParams {
59 int size;
60 int strength;
61 };
62
operator <<(std::ostream & os,const EdgeFilterParams & param)63 std::ostream& operator<<(std::ostream& os, const EdgeFilterParams& param) {
64 return os << "size: " << param.size << ", strength: " << param.strength;
65 }
66
67 // Each size is paired with strength 1, 2, and 3.
68 // In general, the size is expressible as 2^n+1, but all sizes up to 129 are
69 // permissible.
70 constexpr EdgeFilterParams kIntraEdgeFilterParamList[] = {
71 {1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {5, 1}, {5, 2},
72 {5, 3}, {9, 1}, {9, 2}, {9, 3}, {17, 1}, {17, 2}, {17, 3}, {33, 1},
73 {33, 2}, {33, 3}, {50, 1}, {50, 2}, {50, 3}, {55, 1}, {55, 2}, {55, 3},
74 {65, 1}, {65, 2}, {65, 3}, {129, 1}, {129, 2}, {129, 3}};
75
76 template <int bitdepth, typename Pixel>
77 class IntraEdgeFilterTest : public testing::TestWithParam<EdgeFilterParams> {
78 public:
79 static_assert(bitdepth >= kBitdepth8 && bitdepth <= LIBGAV1_MAX_BITDEPTH, "");
80 IntraEdgeFilterTest() = default;
81 IntraEdgeFilterTest(const IntraEdgeFilterTest&) = delete;
82 IntraEdgeFilterTest& operator=(const IntraEdgeFilterTest&) = delete;
83 ~IntraEdgeFilterTest() override = default;
84
85 protected:
SetUp()86 void SetUp() override {
87 test_utils::ResetDspTable(bitdepth);
88 IntraEdgeInit_C();
89
90 const Dsp* const dsp = GetDspTable(bitdepth);
91 ASSERT_NE(dsp, nullptr);
92 base_intra_edge_filter_ = dsp->intra_edge_filter;
93
94 const testing::TestInfo* const test_info =
95 testing::UnitTest::GetInstance()->current_test_info();
96 const absl::string_view test_case = test_info->test_suite_name();
97 if (absl::StartsWith(test_case, "C/")) {
98 base_intra_edge_filter_ = nullptr;
99 } else if (absl::StartsWith(test_case, "SSE41/")) {
100 if ((GetCpuInfo() & kSSE4_1) == 0) GTEST_SKIP() << "No SSE4.1 support!";
101 IntraEdgeInit_SSE4_1();
102 } else if (absl::StartsWith(test_case, "NEON/")) {
103 IntraEdgeInit_NEON();
104 } else {
105 FAIL() << "Unrecognized architecture prefix in test case name: "
106 << test_case;
107 }
108
109 #if LIBGAV1_MSAN
110 // Match the behavior of Tile::IntraPrediction to prevent warnings due to
111 // assembly code (safely) overreading to fill a register.
112 memset(buffer_, 0, sizeof(buffer_));
113 #endif // LIBGAV1_MSAN
114 cur_intra_edge_filter_ = dsp->intra_edge_filter;
115 }
116
117 void TestFixedValues(const char* digest);
118 void TestRandomValues(int num_runs);
119
120 Pixel buffer_[kIntraEdgeBufferSize];
121 Pixel base_buffer_[kIntraEdgeBufferSize];
122 int strength_ = GetParam().strength;
123 int size_ = GetParam().size;
124
125 IntraEdgeFilterFunc base_intra_edge_filter_;
126 IntraEdgeFilterFunc cur_intra_edge_filter_;
127 };
128
129 template <int bitdepth, typename Pixel>
TestFixedValues(const char * const digest)130 void IntraEdgeFilterTest<bitdepth, Pixel>::TestFixedValues(
131 const char* const digest) {
132 if (cur_intra_edge_filter_ == nullptr) return;
133 for (int i = 0; i < kIntraEdgeFilterTestMaxSize; ++i) {
134 buffer_[i] = kIntraEdgeFilterTestFixedInput[i];
135 }
136 const absl::Time start = absl::Now();
137 cur_intra_edge_filter_(buffer_, size_, strength_);
138 const absl::Duration elapsed_time = absl::Now() - start;
139 test_utils::CheckMd5Digest(kIntraEdge, kIntraEdgeFilterName, digest, buffer_,
140 kIntraEdgeFilterTestMaxSize * sizeof(buffer_[0]),
141 elapsed_time);
142 }
143
144 template <int bitdepth, typename Pixel>
TestRandomValues(int num_runs)145 void IntraEdgeFilterTest<bitdepth, Pixel>::TestRandomValues(int num_runs) {
146 if (base_intra_edge_filter_ == nullptr) return;
147 if (cur_intra_edge_filter_ == nullptr) return;
148 libvpx_test::ACMRandom rnd(libvpx_test::ACMRandom::DeterministicSeed());
149 absl::Duration elapsed_time;
150 absl::Duration base_elapsed_time;
151 memset(base_buffer_, 0, sizeof(base_buffer_));
152 memset(buffer_, 0, sizeof(buffer_));
153 for (int num_tests = 0; num_tests < num_runs; ++num_tests) {
154 for (int i = 0; i < size_; ++i) {
155 const Pixel val = rnd(1 << bitdepth);
156 buffer_[i] = val;
157 base_buffer_[i] = val;
158 }
159 const absl::Time base_start = absl::Now();
160 base_intra_edge_filter_(base_buffer_, size_, strength_);
161 base_elapsed_time += absl::Now() - base_start;
162 const absl::Time start = absl::Now();
163 cur_intra_edge_filter_(buffer_, size_, strength_);
164 elapsed_time += absl::Now() - start;
165 }
166 if (num_runs > 1) {
167 printf("Mode %s[%31s] Size %3d Strength %d C: %5d us SIMD: %5d us %2.2fx\n",
168 kIntraEdge, kIntraEdgeFilterName, size_, strength_,
169 static_cast<int>(absl::ToInt64Microseconds(base_elapsed_time)),
170 static_cast<int>(absl::ToInt64Microseconds(elapsed_time)),
171 absl::ToDoubleMicroseconds(base_elapsed_time) /
172 absl::ToDoubleMicroseconds(elapsed_time));
173 } else {
174 printf("Mode %s[%31s] Size %3d Strength %d\n", kIntraEdge,
175 kIntraEdgeFilterName, size_, strength_);
176 }
177 for (int i = 0; i < kIntraEdgeFilterTestMaxSize; ++i) {
178 EXPECT_EQ(buffer_[i], base_buffer_[i]) << "Mismatch in index: " << i;
179 }
180 }
181
182 using IntraEdgeFilterTest8bpp = IntraEdgeFilterTest<8, uint8_t>;
183
GetIntraEdgeFilterDigest8bpp(int strength,int size)184 const char* GetIntraEdgeFilterDigest8bpp(int strength, int size) {
185 static const char* const kDigestsSize1[3] = {
186 "f7f681cf7047602fafc7fb416ecf46e1", "f7f681cf7047602fafc7fb416ecf46e1",
187 "f7f681cf7047602fafc7fb416ecf46e1"};
188 static const char* const kDigestsSize2[3] = {
189 "cb24cc54900fb75d767f3de797451e43", "380c80c89e1e8cda81ee0d3d4b29b8b7",
190 "a7eb3dba95ff35c2df45a274afbc9772"};
191 static const char* const kDigestsSize5[3] = {
192 "23380cb37688d4c3a8f70a276be65eed", "ec1e23d5b996a527ed3d45c0d552bf22",
193 "d313523d3b7646fdbb873c61ffe7a51a"};
194 static const char* const kDigestsSize9[3] = {
195 "e79597e9d62893754fc77d80ca86329a", "f7644e9748984914100e7031c6432272",
196 "bdf4f16734c86338716fb436c196ecc6"};
197 static const char* const kDigestsSize17[3] = {
198 "13ad15c833e850348eecb9fea4f3cadb", "e5988a72391250c702a8192893df40dd",
199 "8f68603598638fa33203fe1233d273b1"};
200 static const char* const kDigestsSize33[3] = {
201 "51156da8f4d527e0c011040769987dbd", "eff17eaf73a7bb7fd4c921510ade9f67",
202 "aca87680e0649d0728091c92c6de8871"};
203 static const char* const kDigestsSize50[3] = {
204 "87c1d43751125f1ea4987517a90d378d", "942a9d056231683bdfc52346b6b032c2",
205 "16a9148daf0e5f69808b9f0caa1ef110"};
206 static const char* const kDigestsSize55[3] = {
207 "833480d74957fb0356dec5b09412eefa", "a307ef31f10affc3b7fb262d05f1b80a",
208 "0318b2fde088c472215fe155f3b48d36"};
209 static const char* const kDigestsSize65[3] = {
210 "5000dada34ed2e6692bb44a4398ddf53", "8da6c776d897064ecd4a1e84aae92dd3",
211 "d7c71db339c28d33119974987b2f9d85"};
212 static const char* const kDigestsSize129[3] = {
213 "bf174d8b45b8131404fd4a4686f8c117", "e81518d6d85eed2f1b18c59424561d6b",
214 "7306715602b0f5536771724a2f0a39bc"};
215
216 switch (size) {
217 case 1:
218 return kDigestsSize1[strength - 1];
219 case 2:
220 return kDigestsSize2[strength - 1];
221 case 5:
222 return kDigestsSize5[strength - 1];
223 case 9:
224 return kDigestsSize9[strength - 1];
225 case 17:
226 return kDigestsSize17[strength - 1];
227 case 33:
228 return kDigestsSize33[strength - 1];
229 case 50:
230 return kDigestsSize50[strength - 1];
231 case 55:
232 return kDigestsSize55[strength - 1];
233 case 65:
234 return kDigestsSize65[strength - 1];
235 case 129:
236 return kDigestsSize129[strength - 1];
237 default:
238 ADD_FAILURE() << "Unknown edge size: " << size;
239 return nullptr;
240 }
241 }
242
TEST_P(IntraEdgeFilterTest8bpp,Correctness)243 TEST_P(IntraEdgeFilterTest8bpp, Correctness) {
244 TestFixedValues(GetIntraEdgeFilterDigest8bpp(strength_, size_));
245 TestRandomValues(1);
246 }
247
TEST_P(IntraEdgeFilterTest8bpp,DISABLED_Speed)248 TEST_P(IntraEdgeFilterTest8bpp, DISABLED_Speed) { TestRandomValues(1e7); }
249
250 #if LIBGAV1_MAX_BITDEPTH >= 10
251 using IntraEdgeFilterTest10bpp = IntraEdgeFilterTest<10, uint16_t>;
252
GetIntraEdgeFilterDigest10bpp(int strength,int size)253 const char* GetIntraEdgeFilterDigest10bpp(int strength, int size) {
254 static const char* const kDigestsSize1[3] = {
255 "2d2088560e3ccb5b809c97f5299bb1c0", "2d2088560e3ccb5b809c97f5299bb1c0",
256 "2d2088560e3ccb5b809c97f5299bb1c0"};
257 static const char* const kDigestsSize2[3] = {
258 "db3e785852e98fba18a1fb531f68466c", "8caea330489bc6ed0f99fbf769f53181",
259 "bcdd1b21f3baf5f6f29caea9ef93fb0c"};
260 static const char* const kDigestsSize5[3] = {
261 "326f4193a62f5a959b86d95f5204608e", "4673e453203f75eae97ef44f43f098f2",
262 "48d516b06313683aca30e975ce6a3cad"};
263 static const char* const kDigestsSize9[3] = {
264 "79217575a32e36a51d9dd40621af9c2d", "ccec1c16bc09b28ad6513c5e4c48b6d2",
265 "bb61aa9c5fa720c667a053769e7b7d08"};
266 static const char* const kDigestsSize17[3] = {
267 "46d90e99ba46e89326a5fa547bcd9361", "824aee8950aecb356d5f4a91dbc90a7d",
268 "37d44d10a2545385af1da55f8c08564f"};
269 static const char* const kDigestsSize33[3] = {
270 "c95108e06eb2aef61ecb6839af306edd", "832c695460b4dd2b85c5f8726e4470d1",
271 "994902f549eefd83fbcbf7ecb7dc5cca"};
272 static const char* const kDigestsSize50[3] = {
273 "48119ef1436c3a4fe69d275bbaafedf8", "72c221c91c3df0a324ccbc9acea35f89",
274 "84e40aadcc416ef3f51cea3cc23b30c7"};
275 static const char* const kDigestsSize55[3] = {
276 "6b68e4e0b00c4eb38a6d0d83c0f34658", "43a919f928a80379df5c9e07c9d8000d",
277 "7c320d55b11f93185b811bdaa379f2db"};
278 static const char* const kDigestsSize65[3] = {
279 "c28de89cf9f3bc5a904647ab2c64caf7", "7ce63b1b28dce0624fc7586e8fb3ab8f",
280 "d06e6b88585f7f1a1f6af5bb59ee2180"};
281 static const char* const kDigestsSize129[3] = {
282 "79160902c5c85004382d5ffa549b43cc", "3b0df95c3ca7b0b559b79234cf434738",
283 "500786d8561effec283d4f3d13886f8c"};
284
285 switch (size) {
286 case 1:
287 return kDigestsSize1[strength - 1];
288 case 2:
289 return kDigestsSize2[strength - 1];
290 case 5:
291 return kDigestsSize5[strength - 1];
292 case 9:
293 return kDigestsSize9[strength - 1];
294 case 17:
295 return kDigestsSize17[strength - 1];
296 case 33:
297 return kDigestsSize33[strength - 1];
298 case 50:
299 return kDigestsSize50[strength - 1];
300 case 55:
301 return kDigestsSize55[strength - 1];
302 case 65:
303 return kDigestsSize65[strength - 1];
304 case 129:
305 return kDigestsSize129[strength - 1];
306 default:
307 ADD_FAILURE() << "Unknown edge size: " << size;
308 return nullptr;
309 }
310 }
311
TEST_P(IntraEdgeFilterTest10bpp,FixedInput)312 TEST_P(IntraEdgeFilterTest10bpp, FixedInput) {
313 TestFixedValues(GetIntraEdgeFilterDigest10bpp(strength_, size_));
314 TestRandomValues(1);
315 }
316
TEST_P(IntraEdgeFilterTest10bpp,DISABLED_Speed)317 TEST_P(IntraEdgeFilterTest10bpp, DISABLED_Speed) { TestRandomValues(1e7); }
318 #endif // LIBGAV1_MAX_BITDEPTH >= 10
319
320 #if LIBGAV1_MAX_BITDEPTH == 12
321 using IntraEdgeFilterTest12bpp = IntraEdgeFilterTest<12, uint16_t>;
322
GetIntraEdgeFilterDigest12bpp(int strength,int size)323 const char* GetIntraEdgeFilterDigest12bpp(int strength, int size) {
324 return GetIntraEdgeFilterDigest10bpp(strength, size);
325 }
326
TEST_P(IntraEdgeFilterTest12bpp,FixedInput)327 TEST_P(IntraEdgeFilterTest12bpp, FixedInput) {
328 TestFixedValues(GetIntraEdgeFilterDigest12bpp(strength_, size_));
329 TestRandomValues(1);
330 }
331
TEST_P(IntraEdgeFilterTest12bpp,DISABLED_Speed)332 TEST_P(IntraEdgeFilterTest12bpp, DISABLED_Speed) { TestRandomValues(1e7); }
333 #endif // LIBGAV1_MAX_BITDEPTH == 12
334
335 template <int bitdepth, typename Pixel>
336 class IntraEdgeUpsamplerTest : public testing::TestWithParam<int> {
337 public:
338 static_assert(bitdepth >= kBitdepth8 && bitdepth <= LIBGAV1_MAX_BITDEPTH, "");
339 IntraEdgeUpsamplerTest() = default;
340 IntraEdgeUpsamplerTest(const IntraEdgeUpsamplerTest&) = delete;
341 IntraEdgeUpsamplerTest& operator=(const IntraEdgeUpsamplerTest&) = delete;
342 ~IntraEdgeUpsamplerTest() override = default;
343
344 protected:
SetUp()345 void SetUp() override {
346 test_utils::ResetDspTable(bitdepth);
347 IntraEdgeInit_C();
348
349 const Dsp* const dsp = GetDspTable(bitdepth);
350 ASSERT_NE(dsp, nullptr);
351 base_intra_edge_upsampler_ = dsp->intra_edge_upsampler;
352 const testing::TestInfo* const test_info =
353 testing::UnitTest::GetInstance()->current_test_info();
354 const absl::string_view test_case = test_info->test_suite_name();
355 if (absl::StartsWith(test_case, "C/")) {
356 base_intra_edge_upsampler_ = nullptr;
357 } else if (absl::StartsWith(test_case, "SSE41/")) {
358 if ((GetCpuInfo() & kSSE4_1) == 0) GTEST_SKIP() << "No SSE4.1 support!";
359 IntraEdgeInit_SSE4_1();
360 } else if (absl::StartsWith(test_case, "NEON/")) {
361 IntraEdgeInit_NEON();
362 } else {
363 FAIL() << "Unrecognized architecture prefix in test case name: "
364 << test_case;
365 }
366 cur_intra_edge_upsampler_ = dsp->intra_edge_upsampler;
367 #if LIBGAV1_MSAN
368 // Match the behavior of Tile::IntraPrediction to prevent warnings due to
369 // assembly code (safely) overreading to fill a register.
370 memset(buffer_, 0, sizeof(buffer_));
371 #endif
372 }
373
374 void TestFixedValues(const char* digest);
375 void TestRandomValues(int num_runs);
376
377 Pixel buffer_[128];
378 Pixel base_buffer_[128];
379 int size_ = GetParam();
380
381 IntraEdgeUpsamplerFunc base_intra_edge_upsampler_;
382 IntraEdgeUpsamplerFunc cur_intra_edge_upsampler_;
383 };
384
385 template <int bitdepth, typename Pixel>
TestFixedValues(const char * const digest)386 void IntraEdgeUpsamplerTest<bitdepth, Pixel>::TestFixedValues(
387 const char* const digest) {
388 if (cur_intra_edge_upsampler_ == nullptr) return;
389 buffer_[0] = 0;
390 for (int i = 0; i < size_ + 1; ++i) {
391 buffer_[i + 1] = kIntraEdgeUpsamplerTestFixedInput[i];
392 }
393 const absl::Time start = absl::Now();
394 cur_intra_edge_upsampler_(buffer_ + 2, size_);
395 const absl::Duration elapsed_time = absl::Now() - start;
396 test_utils::CheckMd5Digest(kIntraEdge, kIntraEdgeUpsamplerName, digest,
397 buffer_, (size_ * 2 + 1) * sizeof(buffer_[0]),
398 elapsed_time);
399 }
400
401 template <int bitdepth, typename Pixel>
TestRandomValues(int num_runs)402 void IntraEdgeUpsamplerTest<bitdepth, Pixel>::TestRandomValues(int num_runs) {
403 if (base_intra_edge_upsampler_ == nullptr) return;
404 if (cur_intra_edge_upsampler_ == nullptr) return;
405 libvpx_test::ACMRandom rnd(libvpx_test::ACMRandom::DeterministicSeed());
406 absl::Duration base_elapsed_time;
407 absl::Duration elapsed_time;
408 for (int num_tests = 0; num_tests < num_runs; ++num_tests) {
409 // Populate what will be buffer[-2..size] when passed to the upsample
410 // function.
411 buffer_[0] = 0;
412 base_buffer_[0] = 0;
413 for (int i = 1; i < size_ + 2; ++i) {
414 const Pixel val = rnd(1 << bitdepth);
415 buffer_[i] = val;
416 base_buffer_[i] = val;
417 }
418 const absl::Time base_start = absl::Now();
419 base_intra_edge_upsampler_(base_buffer_ + 2, size_);
420 base_elapsed_time += absl::Now() - base_start;
421 const absl::Time start = absl::Now();
422 cur_intra_edge_upsampler_(buffer_ + 2, size_);
423 elapsed_time += absl::Now() - start;
424 }
425 if (num_runs > 1) {
426 printf("Mode %s[%31s] size %d C: %5d us SIMD: %5d us %2.2fx\n", kIntraEdge,
427 kIntraEdgeUpsamplerName, size_,
428 static_cast<int>(absl::ToInt64Microseconds(base_elapsed_time)),
429 static_cast<int>(absl::ToInt64Microseconds(elapsed_time)),
430 absl::ToDoubleMicroseconds(base_elapsed_time) /
431 absl::ToDoubleMicroseconds(elapsed_time));
432 } else {
433 printf("Mode %s[%31s]: size %d \n", kIntraEdge, kIntraEdgeUpsamplerName,
434 size_);
435 }
436
437 for (int i = 0; i < size_ * 2 + 1; ++i) {
438 EXPECT_EQ(buffer_[i], base_buffer_[i]) << "Mismatch in index: " << i;
439 }
440 }
441
442 using IntraEdgeUpsamplerTest8bpp = IntraEdgeUpsamplerTest<8, uint8_t>;
443
444 constexpr int kIntraEdgeUpsampleSizes[] = {4, 8, 12, 16};
445
GetIntraEdgeUpsampleDigest8bpp(int size)446 const char* GetIntraEdgeUpsampleDigest8bpp(int size) {
447 switch (size) {
448 case 4:
449 return "aa9002e03f8d15eb26bbee76f40bb923";
450 case 8:
451 return "cacfca86d65eff0d951eb21fc15f242a";
452 case 12:
453 return "0529e00a1fa80bc866fa7662ad2d7b9f";
454 case 16:
455 return "03e3b3e0ea438ea48ef05651c0a54986";
456 default:
457 ADD_FAILURE() << "Unknown upsample size: " << size;
458 return "";
459 }
460 }
461
TEST_P(IntraEdgeUpsamplerTest8bpp,Correctness)462 TEST_P(IntraEdgeUpsamplerTest8bpp, Correctness) {
463 TestFixedValues(GetIntraEdgeUpsampleDigest8bpp(size_));
464 TestRandomValues(1);
465 }
466
TEST_P(IntraEdgeUpsamplerTest8bpp,DISABLED_Speed)467 TEST_P(IntraEdgeUpsamplerTest8bpp, DISABLED_Speed) { TestRandomValues(5e7); }
468
469 #if LIBGAV1_MAX_BITDEPTH >= 10
470 using IntraEdgeUpsamplerTest10bpp = IntraEdgeUpsamplerTest<10, uint16_t>;
471
GetIntraEdgeUpsampleDigest10bpp(int size)472 const char* GetIntraEdgeUpsampleDigest10bpp(int size) {
473 switch (size) {
474 case 4:
475 return "341c6bb705a02bba65b34f92d8ca83cf";
476 case 8:
477 return "fdbe4b3b341921dcb0edf00dfc4d7667";
478 case 12:
479 return "ad69a491287495ec9973d4006d5ac461";
480 case 16:
481 return "04acf32e517d80ce4c4958e711b9b890";
482 default:
483 ADD_FAILURE() << "Unknown upsample size: " << size;
484 return "";
485 }
486 }
487
TEST_P(IntraEdgeUpsamplerTest10bpp,FixedInput)488 TEST_P(IntraEdgeUpsamplerTest10bpp, FixedInput) {
489 TestFixedValues(GetIntraEdgeUpsampleDigest10bpp(size_));
490 TestRandomValues(1);
491 }
492
TEST_P(IntraEdgeUpsamplerTest10bpp,DISABLED_Speed)493 TEST_P(IntraEdgeUpsamplerTest10bpp, DISABLED_Speed) { TestRandomValues(5e7); }
494 #endif // LIBGAV1_MAX_BITDEPTH >= 10
495
496 #if LIBGAV1_MAX_BITDEPTH == 12
497 using IntraEdgeUpsamplerTest12bpp = IntraEdgeUpsamplerTest<12, uint16_t>;
498
GetIntraEdgeUpsampleDigest12bpp(int size)499 const char* GetIntraEdgeUpsampleDigest12bpp(int size) {
500 return GetIntraEdgeUpsampleDigest10bpp(size);
501 }
502
TEST_P(IntraEdgeUpsamplerTest12bpp,FixedInput)503 TEST_P(IntraEdgeUpsamplerTest12bpp, FixedInput) {
504 TestFixedValues(GetIntraEdgeUpsampleDigest12bpp(size_));
505 TestRandomValues(1);
506 }
507
TEST_P(IntraEdgeUpsamplerTest12bpp,DISABLED_Speed)508 TEST_P(IntraEdgeUpsamplerTest12bpp, DISABLED_Speed) { TestRandomValues(5e7); }
509 #endif // LIBGAV1_MAX_BITDEPTH == 12
510
511 INSTANTIATE_TEST_SUITE_P(C, IntraEdgeFilterTest8bpp,
512 testing::ValuesIn(kIntraEdgeFilterParamList));
513 #if LIBGAV1_ENABLE_SSE4_1
514 INSTANTIATE_TEST_SUITE_P(SSE41, IntraEdgeFilterTest8bpp,
515 testing::ValuesIn(kIntraEdgeFilterParamList));
516 #endif
517 #if LIBGAV1_ENABLE_NEON
518 INSTANTIATE_TEST_SUITE_P(NEON, IntraEdgeFilterTest8bpp,
519 testing::ValuesIn(kIntraEdgeFilterParamList));
520 #endif
521 INSTANTIATE_TEST_SUITE_P(C, IntraEdgeUpsamplerTest8bpp,
522 testing::ValuesIn(kIntraEdgeUpsampleSizes));
523 #if LIBGAV1_ENABLE_SSE4_1
524 INSTANTIATE_TEST_SUITE_P(SSE41, IntraEdgeUpsamplerTest8bpp,
525 testing::ValuesIn(kIntraEdgeUpsampleSizes));
526 #endif
527 #if LIBGAV1_ENABLE_NEON
528 INSTANTIATE_TEST_SUITE_P(NEON, IntraEdgeUpsamplerTest8bpp,
529 testing::ValuesIn(kIntraEdgeUpsampleSizes));
530 #endif
531
532 #if LIBGAV1_MAX_BITDEPTH >= 10
533 INSTANTIATE_TEST_SUITE_P(C, IntraEdgeFilterTest10bpp,
534 testing::ValuesIn(kIntraEdgeFilterParamList));
535 INSTANTIATE_TEST_SUITE_P(C, IntraEdgeUpsamplerTest10bpp,
536 testing::ValuesIn(kIntraEdgeUpsampleSizes));
537
538 #if LIBGAV1_ENABLE_NEON
539 INSTANTIATE_TEST_SUITE_P(NEON, IntraEdgeFilterTest10bpp,
540 testing::ValuesIn(kIntraEdgeFilterParamList));
541 INSTANTIATE_TEST_SUITE_P(NEON, IntraEdgeUpsamplerTest10bpp,
542 testing::ValuesIn(kIntraEdgeUpsampleSizes));
543 #endif
544
545 #endif // LIBGAV1_MAX_BITDEPTH >= 10
546
547 #if LIBGAV1_MAX_BITDEPTH == 12
548 INSTANTIATE_TEST_SUITE_P(C, IntraEdgeFilterTest12bpp,
549 testing::ValuesIn(kIntraEdgeFilterParamList));
550 INSTANTIATE_TEST_SUITE_P(C, IntraEdgeUpsamplerTest12bpp,
551 testing::ValuesIn(kIntraEdgeUpsampleSizes));
552 #endif // LIBGAV1_MAX_BITDEPTH == 12
553
554 } // namespace
555 } // namespace dsp
556 } // namespace libgav1
557