KleidiCV Coverage Report


Directory: ./
File: kleidicv/src/filters/median_blur_border_handling.h
Date: 2025-09-25 14:13:34
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 2462955 static ptrdiff_t get_physical_index(size_t index, size_t limit,
15 FixedBorderType border_type) {
16 2462955 int result = 0;
17 2462955 int signed_index = static_cast<int>(index);
18 2462955 int signed_limit = static_cast<int>(limit);
19
20
4/4
✓ Branch 0 taken 2018643 times.
✓ Branch 1 taken 444312 times.
✓ Branch 2 taken 276408 times.
✓ Branch 3 taken 1742235 times.
2462955 if (signed_index >= 0 && signed_index < signed_limit) {
21 1742235 return static_cast<ptrdiff_t>(index);
22 }
23
4/4
✓ Branch 0 taken 203544 times.
✓ Branch 1 taken 172392 times.
✓ Branch 2 taken 172392 times.
✓ Branch 3 taken 172392 times.
720720 switch (border_type) {
24 case FixedBorderType::REFLECT: {
25
2/2
✓ Branch 0 taken 66096 times.
✓ Branch 1 taken 106296 times.
172392 if (signed_index < 0) {
26 106296 result = -signed_index - 1;
27 106296 } else {
28 66096 result = 2 * signed_limit - signed_index - 1;
29 }
30 172392 break;
31 }
32
33 case FixedBorderType::WRAP: {
34
2/2
✓ Branch 0 taken 66096 times.
✓ Branch 1 taken 106296 times.
172392 if (signed_index < 0) {
35 106296 result = signed_limit + signed_index;
36 106296 } else {
37 66096 result = signed_index - signed_limit;
38 }
39 172392 break;
40 }
41
42 case FixedBorderType::REVERSE: {
43
2/2
✓ Branch 0 taken 66096 times.
✓ Branch 1 taken 106296 times.
172392 if (signed_index < 0) {
44 106296 result = std::min(-signed_index, signed_limit - 1);
45 106296 } else {
46 66096 result = 2 * signed_limit - signed_index - 2;
47 }
48 172392 break;
49 }
50 default: /* FixedBorderType::REPLICATE */ {
51 203544 result = std::clamp(signed_index, 0, signed_limit - 1);
52 203544 break;
53 }
54 }
55
56 720720 return static_cast<ptrdiff_t>(result);
57 2462955 }
58
59 } // namespace kleidicv::neon
60 #endif // KLEIDICV_MEDIAN_BLUR_BORDER_HANDLING_H
61