KleidiCV Coverage Report


Directory: ./
File: kleidicv/src/filters/median_blur_border_handling.h
Date: 2026-01-20 20:58:59
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 3351848 static ptrdiff_t get_physical_index(size_t index, size_t limit,
15 FixedBorderType border_type) {
16 3351848 int result = 0;
17 3351848 int signed_index = static_cast<int>(index);
18 3351848 int signed_limit = static_cast<int>(limit);
19
20
4/4
✓ Branch 0 taken 2755004 times.
✓ Branch 1 taken 596844 times.
✓ Branch 2 taken 372972 times.
✓ Branch 3 taken 2382032 times.
3351848 if (signed_index >= 0 && signed_index < signed_limit) {
21 2382032 return static_cast<ptrdiff_t>(index);
22 }
23
4/4
✓ Branch 0 taken 280248 times.
✓ Branch 1 taken 229856 times.
✓ Branch 2 taken 229856 times.
✓ Branch 3 taken 229856 times.
969816 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 280248 result = std::clamp(signed_index, 0, signed_limit - 1);
52 280248 break;
53 }
54 }
55
56 969816 return static_cast<ptrdiff_t>(result);
57 3351848 }
58
59 } // namespace kleidicv::neon
60 #endif // KLEIDICV_MEDIAN_BLUR_BORDER_HANDLING_H
61