| 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 2 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
|
10 | KLEIDICV_DEFINE_C_API(kleidicv_median_blur_sorting_network_stripe_s8, int8_t); |
| 17 | |||
| 18 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
|
10 | KLEIDICV_DEFINE_C_API(kleidicv_median_blur_sorting_network_stripe_u8, uint8_t); |
| 19 | |||
| 20 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
|
10 | KLEIDICV_DEFINE_C_API(kleidicv_median_blur_sorting_network_stripe_u16, |
| 21 | uint16_t); | ||
| 22 | |||
| 23 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
|
10 | KLEIDICV_DEFINE_C_API(kleidicv_median_blur_sorting_network_stripe_s16, int16_t); |
| 24 | |||
| 25 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
|
10 | KLEIDICV_DEFINE_C_API(kleidicv_median_blur_sorting_network_stripe_u32, |
| 26 | uint32_t); | ||
| 27 | |||
| 28 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
|
10 | KLEIDICV_DEFINE_C_API(kleidicv_median_blur_sorting_network_stripe_s32, int32_t); |
| 29 | |||
| 30 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
|
10 | KLEIDICV_DEFINE_C_API(kleidicv_median_blur_sorting_network_stripe_f32, float); |
| 31 | |||
| 32 | 10 | 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 | 10 | 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 | 852 | 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 | 1704 | auto [checks_result, fixed_border_type] = | |
| 49 | 852 | kleidicv::median_blur_is_implemented( | |
| 50 | 852 | src, src_stride, dst, dst_stride, width, height, channels, | |
| 51 | 852 | kernel_width, kernel_height, border_type); | |
| 52 | |||
| 53 |
2/2✓ Branch 0 taken 76 times.
✓ Branch 1 taken 776 times.
|
852 | if (checks_result != KLEIDICV_OK) { |
| 54 | 76 | return checks_result; | |
| 55 | } | ||
| 56 | |||
| 57 | 1552 | return kleidicv_median_blur_sorting_network_stripe_s8( | |
| 58 | 776 | src, src_stride, dst, dst_stride, width, height, 0, height, channels, | |
| 59 | 776 | kernel_width, kernel_height, fixed_border_type); | |
| 60 | 852 | } | |
| 61 | |||
| 62 | 1540 | 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 | 3080 | auto [checks_result, fixed_border_type] = | |
| 69 | 1540 | kleidicv::median_blur_is_implemented( | |
| 70 | 1540 | src, src_stride, dst, dst_stride, width, height, channels, | |
| 71 | 1540 | kernel_width, kernel_height, border_type); | |
| 72 | |||
| 73 |
2/2✓ Branch 0 taken 456 times.
✓ Branch 1 taken 1084 times.
|
1540 | if (checks_result != KLEIDICV_OK) { |
| 74 | 456 | return checks_result; | |
| 75 | } | ||
| 76 | |||
| 77 |
2/2✓ Branch 0 taken 876 times.
✓ Branch 1 taken 208 times.
|
1084 | if (kernel_width <= 7) { |
| 78 | 1752 | return kleidicv_median_blur_sorting_network_stripe_u8( | |
| 79 | 876 | src, src_stride, dst, dst_stride, width, height, 0, height, channels, | |
| 80 | 876 | kernel_width, kernel_height, fixed_border_type); | |
| 81 | } | ||
| 82 | |||
| 83 |
3/4✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 76 times.
|
208 | if (kernel_width > 7 && kernel_width <= 15) { |
| 84 | 152 | return kleidicv_median_blur_small_hist_stripe_u8( | |
| 85 | 76 | src, src_stride, dst, dst_stride, width, height, 0, height, channels, | |
| 86 | 76 | kernel_width, kernel_height, fixed_border_type); | |
| 87 | } | ||
| 88 | |||
| 89 | 264 | return kleidicv_median_blur_large_hist_stripe_u8( | |
| 90 | 132 | src, src_stride, dst, dst_stride, width, height, 0, height, channels, | |
| 91 | 132 | kernel_width, kernel_height, fixed_border_type); | |
| 92 | 1540 | } | |
| 93 | |||
| 94 | 1352 | 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 | 2704 | auto [checks_result, fixed_border_type] = | |
| 101 | 1352 | kleidicv::median_blur_is_implemented( | |
| 102 | 1352 | src, src_stride, dst, dst_stride, width, height, channels, | |
| 103 | 1352 | kernel_width, kernel_height, border_type); | |
| 104 | |||
| 105 |
2/2✓ Branch 0 taken 476 times.
✓ Branch 1 taken 876 times.
|
1352 | if (checks_result != KLEIDICV_OK) { |
| 106 | 476 | return checks_result; | |
| 107 | } | ||
| 108 | |||
| 109 | 1752 | return kleidicv_median_blur_sorting_network_stripe_s16( | |
| 110 | 876 | src, src_stride, dst, dst_stride, width, height, 0, height, channels, | |
| 111 | 876 | kernel_width, kernel_height, fixed_border_type); | |
| 112 | 1352 | } | |
| 113 | |||
| 114 | 1352 | 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 | 2704 | auto [checks_result, fixed_border_type] = | |
| 119 | 1352 | kleidicv::median_blur_is_implemented( | |
| 120 | 1352 | src, src_stride, dst, dst_stride, width, height, channels, | |
| 121 | 1352 | kernel_width, kernel_height, border_type); | |
| 122 | |||
| 123 |
2/2✓ Branch 0 taken 476 times.
✓ Branch 1 taken 876 times.
|
1352 | if (checks_result != KLEIDICV_OK) { |
| 124 | 476 | return checks_result; | |
| 125 | } | ||
| 126 | |||
| 127 | 1752 | return kleidicv_median_blur_sorting_network_stripe_u16( | |
| 128 | 876 | src, src_stride, dst, dst_stride, width, height, 0, height, channels, | |
| 129 | 876 | kernel_width, kernel_height, fixed_border_type); | |
| 130 | 1352 | } | |
| 131 | |||
| 132 | 852 | 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 | 1704 | auto [checks_result, fixed_border_type] = | |
| 139 | 852 | kleidicv::median_blur_is_implemented( | |
| 140 | 852 | src, src_stride, dst, dst_stride, width, height, channels, | |
| 141 | 852 | kernel_width, kernel_height, border_type); | |
| 142 | |||
| 143 |
2/2✓ Branch 0 taken 76 times.
✓ Branch 1 taken 776 times.
|
852 | if (checks_result != KLEIDICV_OK) { |
| 144 | 76 | return checks_result; | |
| 145 | } | ||
| 146 | |||
| 147 | 1552 | return kleidicv_median_blur_sorting_network_stripe_s32( | |
| 148 | 776 | src, src_stride, dst, dst_stride, width, height, 0, height, channels, | |
| 149 | 776 | kernel_width, kernel_height, fixed_border_type); | |
| 150 | 852 | } | |
| 151 | |||
| 152 | 852 | 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 | 1704 | auto [checks_result, fixed_border_type] = | |
| 157 | 852 | kleidicv::median_blur_is_implemented( | |
| 158 | 852 | src, src_stride, dst, dst_stride, width, height, channels, | |
| 159 | 852 | kernel_width, kernel_height, border_type); | |
| 160 | |||
| 161 |
2/2✓ Branch 0 taken 76 times.
✓ Branch 1 taken 776 times.
|
852 | if (checks_result != KLEIDICV_OK) { |
| 162 | 76 | return checks_result; | |
| 163 | } | ||
| 164 | |||
| 165 | 1552 | return kleidicv_median_blur_sorting_network_stripe_u32( | |
| 166 | 776 | src, src_stride, dst, dst_stride, width, height, 0, height, channels, | |
| 167 | 776 | kernel_width, kernel_height, fixed_border_type); | |
| 168 | 852 | } | |
| 169 | |||
| 170 | 1352 | 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 | 2704 | auto [checks_result, fixed_border_type] = | |
| 177 | 1352 | kleidicv::median_blur_is_implemented( | |
| 178 | 1352 | src, src_stride, dst, dst_stride, width, height, channels, | |
| 179 | 1352 | kernel_width, kernel_height, border_type); | |
| 180 | |||
| 181 |
2/2✓ Branch 0 taken 476 times.
✓ Branch 1 taken 876 times.
|
1352 | if (checks_result != KLEIDICV_OK) { |
| 182 | 476 | return checks_result; | |
| 183 | } | ||
| 184 | |||
| 185 | 1752 | return kleidicv_median_blur_sorting_network_stripe_f32( | |
| 186 | 876 | src, src_stride, dst, dst_stride, width, height, 0, height, channels, | |
| 187 | 876 | kernel_width, kernel_height, fixed_border_type); | |
| 188 | 1352 | } | |
| 189 | |||
| 190 | } // extern "C" | ||
| 191 |