KleidiCV Coverage Report


Directory: ./
File: kleidicv/src/filters/median_blur_api.cpp
Date: 2025-09-25 14:13:34
Exec Total Coverage
Lines: 94 94 100.0%
Functions: 16 16 100.0%
Branches: 47 48 97.9%

Line Branch Exec Source
1 // SPDX-FileCopyrightText: 2023 - 2025 Arm Limited and/or its affiliates <open-source-office@arm.com>
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 #include "kleidicv/dispatch.h"
6 #include "kleidicv/filters/median_blur.h"
7 #include "kleidicv/kleidicv.h"
8
9 #define KLEIDICV_DEFINE_C_API(name, type) \
10 KLEIDICV_MULTIVERSION_C_API( \
11 name, &kleidicv::neon::median_blur_sorting_network_stripe<type>, \
12 KLEIDICV_SVE2_IMPL_IF( \
13 kleidicv::sve2::median_blur_sorting_network_stripe<type>), \
14 &kleidicv::sme::median_blur_sorting_network_stripe<type>, nullptr)
15
16
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
8 KLEIDICV_DEFINE_C_API(kleidicv_median_blur_sorting_network_stripe_s8, int8_t);
17
18
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
8 KLEIDICV_DEFINE_C_API(kleidicv_median_blur_sorting_network_stripe_u8, uint8_t);
19
20
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
8 KLEIDICV_DEFINE_C_API(kleidicv_median_blur_sorting_network_stripe_u16,
21 uint16_t);
22
23
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
8 KLEIDICV_DEFINE_C_API(kleidicv_median_blur_sorting_network_stripe_s16, int16_t);
24
25
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
8 KLEIDICV_DEFINE_C_API(kleidicv_median_blur_sorting_network_stripe_u32,
26 uint32_t);
27
28
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
8 KLEIDICV_DEFINE_C_API(kleidicv_median_blur_sorting_network_stripe_s32, int32_t);
29
30
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
8 KLEIDICV_DEFINE_C_API(kleidicv_median_blur_sorting_network_stripe_f32, float);
31
32 8 KLEIDICV_MULTIVERSION_C_API(kleidicv_median_blur_small_hist_stripe_u8,
33 &kleidicv::neon::median_blur_small_hist_stripe_u8,
34 nullptr, nullptr, nullptr);
35
36 8 KLEIDICV_MULTIVERSION_C_API(kleidicv_median_blur_large_hist_stripe_u8,
37 &kleidicv::neon::median_blur_large_hist_stripe_u8,
38 nullptr, nullptr, nullptr);
39
40 extern "C" {
41
42 639 kleidicv_error_t kleidicv_median_blur_s8(const int8_t *src, size_t src_stride,
43 int8_t *dst, size_t dst_stride,
44 size_t width, size_t height,
45 size_t channels, size_t kernel_width,
46 size_t kernel_height,
47 kleidicv_border_type_t border_type) {
48 1278 auto [checks_result, fixed_border_type] =
49 639 kleidicv::median_blur_is_implemented(
50 639 src, src_stride, dst, dst_stride, width, height, channels,
51 639 kernel_width, kernel_height, border_type);
52
53
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 582 times.
639 if (checks_result != KLEIDICV_OK) {
54 57 return checks_result;
55 }
56
57 1164 return kleidicv_median_blur_sorting_network_stripe_s8(
58 582 src, src_stride, dst, dst_stride, width, height, 0, height, channels,
59 582 kernel_width, kernel_height, fixed_border_type);
60 639 }
61
62 1155 kleidicv_error_t kleidicv_median_blur_u8(const uint8_t *src, size_t src_stride,
63 uint8_t *dst, size_t dst_stride,
64 size_t width, size_t height,
65 size_t channels, size_t kernel_width,
66 size_t kernel_height,
67 kleidicv_border_type_t border_type) {
68 2310 auto [checks_result, fixed_border_type] =
69 1155 kleidicv::median_blur_is_implemented(
70 1155 src, src_stride, dst, dst_stride, width, height, channels,
71 1155 kernel_width, kernel_height, border_type);
72
73
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 813 times.
1155 if (checks_result != KLEIDICV_OK) {
74 342 return checks_result;
75 }
76
77
2/2
✓ Branch 0 taken 657 times.
✓ Branch 1 taken 156 times.
813 if (kernel_width <= 7) {
78 1314 return kleidicv_median_blur_sorting_network_stripe_u8(
79 657 src, src_stride, dst, dst_stride, width, height, 0, height, channels,
80 657 kernel_width, kernel_height, fixed_border_type);
81 }
82
83
3/4
✓ Branch 0 taken 156 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✓ Branch 3 taken 57 times.
156 if (kernel_width > 7 && kernel_width <= 15) {
84 114 return kleidicv_median_blur_small_hist_stripe_u8(
85 57 src, src_stride, dst, dst_stride, width, height, 0, height, channels,
86 57 kernel_width, kernel_height, fixed_border_type);
87 }
88
89 198 return kleidicv_median_blur_large_hist_stripe_u8(
90 99 src, src_stride, dst, dst_stride, width, height, 0, height, channels,
91 99 kernel_width, kernel_height, fixed_border_type);
92 1155 }
93
94 1014 kleidicv_error_t kleidicv_median_blur_s16(const int16_t *src, size_t src_stride,
95 int16_t *dst, size_t dst_stride,
96 size_t width, size_t height,
97 size_t channels, size_t kernel_width,
98 size_t kernel_height,
99 kleidicv_border_type_t border_type) {
100 2028 auto [checks_result, fixed_border_type] =
101 1014 kleidicv::median_blur_is_implemented(
102 1014 src, src_stride, dst, dst_stride, width, height, channels,
103 1014 kernel_width, kernel_height, border_type);
104
105
2/2
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 657 times.
1014 if (checks_result != KLEIDICV_OK) {
106 357 return checks_result;
107 }
108
109 1314 return kleidicv_median_blur_sorting_network_stripe_s16(
110 657 src, src_stride, dst, dst_stride, width, height, 0, height, channels,
111 657 kernel_width, kernel_height, fixed_border_type);
112 1014 }
113
114 1014 kleidicv_error_t kleidicv_median_blur_u16(
115 const uint16_t *src, size_t src_stride, uint16_t *dst, size_t dst_stride,
116 size_t width, size_t height, size_t channels, size_t kernel_width,
117 size_t kernel_height, kleidicv_border_type_t border_type) {
118 2028 auto [checks_result, fixed_border_type] =
119 1014 kleidicv::median_blur_is_implemented(
120 1014 src, src_stride, dst, dst_stride, width, height, channels,
121 1014 kernel_width, kernel_height, border_type);
122
123
2/2
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 657 times.
1014 if (checks_result != KLEIDICV_OK) {
124 357 return checks_result;
125 }
126
127 1314 return kleidicv_median_blur_sorting_network_stripe_u16(
128 657 src, src_stride, dst, dst_stride, width, height, 0, height, channels,
129 657 kernel_width, kernel_height, fixed_border_type);
130 1014 }
131
132 639 kleidicv_error_t kleidicv_median_blur_s32(const int32_t *src, size_t src_stride,
133 int32_t *dst, size_t dst_stride,
134 size_t width, size_t height,
135 size_t channels, size_t kernel_width,
136 size_t kernel_height,
137 kleidicv_border_type_t border_type) {
138 1278 auto [checks_result, fixed_border_type] =
139 639 kleidicv::median_blur_is_implemented(
140 639 src, src_stride, dst, dst_stride, width, height, channels,
141 639 kernel_width, kernel_height, border_type);
142
143
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 582 times.
639 if (checks_result != KLEIDICV_OK) {
144 57 return checks_result;
145 }
146
147 1164 return kleidicv_median_blur_sorting_network_stripe_s32(
148 582 src, src_stride, dst, dst_stride, width, height, 0, height, channels,
149 582 kernel_width, kernel_height, fixed_border_type);
150 639 }
151
152 639 kleidicv_error_t kleidicv_median_blur_u32(
153 const uint32_t *src, size_t src_stride, uint32_t *dst, size_t dst_stride,
154 size_t width, size_t height, size_t channels, size_t kernel_width,
155 size_t kernel_height, kleidicv_border_type_t border_type) {
156 1278 auto [checks_result, fixed_border_type] =
157 639 kleidicv::median_blur_is_implemented(
158 639 src, src_stride, dst, dst_stride, width, height, channels,
159 639 kernel_width, kernel_height, border_type);
160
161
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 582 times.
639 if (checks_result != KLEIDICV_OK) {
162 57 return checks_result;
163 }
164
165 1164 return kleidicv_median_blur_sorting_network_stripe_u32(
166 582 src, src_stride, dst, dst_stride, width, height, 0, height, channels,
167 582 kernel_width, kernel_height, fixed_border_type);
168 639 }
169
170 1014 kleidicv_error_t kleidicv_median_blur_f32(const float *src, size_t src_stride,
171 float *dst, size_t dst_stride,
172 size_t width, size_t height,
173 size_t channels, size_t kernel_width,
174 size_t kernel_height,
175 kleidicv_border_type_t border_type) {
176 2028 auto [checks_result, fixed_border_type] =
177 1014 kleidicv::median_blur_is_implemented(
178 1014 src, src_stride, dst, dst_stride, width, height, channels,
179 1014 kernel_width, kernel_height, border_type);
180
181
2/2
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 657 times.
1014 if (checks_result != KLEIDICV_OK) {
182 357 return checks_result;
183 }
184
185 1314 return kleidicv_median_blur_sorting_network_stripe_f32(
186 657 src, src_stride, dst, dst_stride, width, height, 0, height, channels,
187 657 kernel_width, kernel_height, fixed_border_type);
188 1014 }
189
190 } // extern "C"
191