KleidiCV Coverage Report


Directory: ./
File: kleidicv/src/filters/median_blur_border_handling.h
Date: 2025-11-25 17:23:32
Exec Total Coverage
Lines: 26 26 100.0%
Functions: 1 1 100.0%
Branches: 14 14 100.0%

Line Branch Exec Source
1 // SPDX-FileCopyrightText: 2025 Arm Limited and/or its affiliates <open-source-office@arm.com>
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 #ifndef KLEIDICV_MEDIAN_BLUR_BORDER_HANDLING_H
6 #define KLEIDICV_MEDIAN_BLUR_BORDER_HANDLING_H
7
8 #include <algorithm>
9
10 #include "kleidicv/kleidicv.h"
11
12 namespace kleidicv::neon {
13
14 3283940 static ptrdiff_t get_physical_index(size_t index, size_t limit,
15 FixedBorderType border_type) {
16 3283940 int result = 0;
17 3283940 int signed_index = static_cast<int>(index);
18 3283940 int signed_limit = static_cast<int>(limit);
19
20
4/4
✓ Branch 0 taken 2691524 times.
✓ Branch 1 taken 592416 times.
✓ Branch 2 taken 368544 times.
✓ Branch 3 taken 2322980 times.
3283940 if (signed_index >= 0 && signed_index < signed_limit) {
21 2322980 return static_cast<ptrdiff_t>(index);
22 }
23
4/4
✓ Branch 0 taken 271392 times.
✓ Branch 1 taken 229856 times.
✓ Branch 2 taken 229856 times.
✓ Branch 3 taken 229856 times.
960960 switch (border_type) {
24 case FixedBorderType::REFLECT: {
25
2/2
✓ Branch 0 taken 88128 times.
✓ Branch 1 taken 141728 times.
229856 if (signed_index < 0) {
26 141728 result = -signed_index - 1;
27 141728 } else {
28 88128 result = 2 * signed_limit - signed_index - 1;
29 }
30 229856 break;
31 }
32
33 case FixedBorderType::WRAP: {
34
2/2
✓ Branch 0 taken 88128 times.
✓ Branch 1 taken 141728 times.
229856 if (signed_index < 0) {
35 141728 result = signed_limit + signed_index;
36 141728 } else {
37 88128 result = signed_index - signed_limit;
38 }
39 229856 break;
40 }
41
42 case FixedBorderType::REVERSE: {
43
2/2
✓ Branch 0 taken 88128 times.
✓ Branch 1 taken 141728 times.
229856 if (signed_index < 0) {
44 141728 result = std::min(-signed_index, signed_limit - 1);
45 141728 } else {
46 88128 result = 2 * signed_limit - signed_index - 2;
47 }
48 229856 break;
49 }
50 default: /* FixedBorderType::REPLICATE */ {
51 271392 result = std::clamp(signed_index, 0, signed_limit - 1);
52 271392 break;
53 }
54 }
55
56 960960 return static_cast<ptrdiff_t>(result);
57 3283940 }
58
59 } // namespace kleidicv::neon
60 #endif // KLEIDICV_MEDIAN_BLUR_BORDER_HANDLING_H
61