KleidiCV Coverage Report


Directory: ./
File: kleidicv/src/resize/resize_linear_generic_neon.cpp
Date: 2026-03-05 15:57:40
Exec Total Coverage
Lines: 26 26 100.0%
Functions: 6 6 100.0%
Branches: 39 40 97.5%

Line Branch Exec Source
1 // SPDX-FileCopyrightText: 2026 Arm Limited and/or its affiliates <open-source-office@arm.com>
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 #include <cstddef>
6 #include <cstdint>
7 #include <cstdlib>
8 #include <variant>
9
10 #include "kleidicv/ctypes.h"
11 #include "kleidicv/resize/resize_linear.h"
12 #include "resize_linear_generic_u8_neon.h"
13
14 namespace kleidicv::neon {
15
16 // ratio: number of vectors to load and resize to 1 vector
17 // supported ratio values: 2 and 3
18 // supported channel counts: 1, 2 and 3
19 template <ptrdiff_t kRatio, ptrdiff_t kChannels>
20 313 kleidicv_error_t kleidicv_resize_generic_stripe_u8(
21 const uint8_t *src, size_t src_stride, size_t src_width, size_t src_height,
22 size_t y_begin, size_t y_end, uint8_t *dst, // NOLINT
23 size_t dst_stride, size_t dst_width, size_t dst_height) {
24 313 resize_linear_generic_u8::RowInterpolationConstantsGenerator<kRatio,
25 kChannels>
26 313 generator{src_width, dst_width};
27
28 313 auto row_interpolation_constants_variant = generator();
29
30
36/36
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 54 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 54 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 54 times.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 43 times.
✓ Branch 14 taken 2 times.
✓ Branch 15 taken 43 times.
✓ Branch 16 taken 2 times.
✓ Branch 17 taken 43 times.
✓ Branch 18 taken 2 times.
✓ Branch 19 taken 48 times.
✓ Branch 20 taken 2 times.
✓ Branch 21 taken 48 times.
✓ Branch 22 taken 2 times.
✓ Branch 23 taken 48 times.
✓ Branch 24 taken 2 times.
✓ Branch 25 taken 54 times.
✓ Branch 26 taken 2 times.
✓ Branch 27 taken 54 times.
✓ Branch 28 taken 2 times.
✓ Branch 29 taken 54 times.
✓ Branch 30 taken 2 times.
✓ Branch 31 taken 54 times.
✓ Branch 32 taken 2 times.
✓ Branch 33 taken 54 times.
✓ Branch 34 taken 2 times.
✓ Branch 35 taken 54 times.
638 if (auto *err =
31 313 std::get_if<kleidicv_error_t>(&row_interpolation_constants_variant)) {
32 12 return *err;
33 }
34 602 auto &row_interpolation_constants =
35 301 *std::get_if<resize_linear_generic_u8::RowInterpolationConstants>(
36 &row_interpolation_constants_variant);
37
38 if constexpr (kChannels == 3) {
39 194 double inverz_scale =
40 97 static_cast<double>(src_width) / static_cast<double>(dst_width);
41
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 46 times.
97 if ((kRatio == 2 && inverz_scale >= 1.8) ||
42 54 (kRatio == 3 && inverz_scale >= 2.8)) {
43 // Rightmost lanes of b and d vectors need to be set by scalar code, as
44 // the table lookup overindexes the src registers
45 8 resize_linear_generic_u8::ResizeGenericU8Operation<kRatio, kChannels,
46 true>
47 16 operation(src, src_stride, src_height, y_begin, y_end, dst,
48 8 dst_stride, dst_height);
49 8 operation.process_rows(row_interpolation_constants);
50 8 return KLEIDICV_OK;
51 8 }
52 97 }
53
54 293 resize_linear_generic_u8::ResizeGenericU8Operation<kRatio, kChannels>
55 586 operation(src, src_stride, src_height, y_begin, y_end, dst, dst_stride,
56 293 dst_height);
57 293 operation.process_rows(row_interpolation_constants);
58
59 293 return KLEIDICV_OK;
60 313 }
61
62 #define KLEIDICV_INSTANTIATE_TEMPLATE(ratio, channels) \
63 template kleidicv_error_t \
64 kleidicv_resize_generic_stripe_u8<ratio, channels>( \
65 const uint8_t *src, size_t src_stride, size_t src_width, \
66 size_t src_height, size_t y_begin, size_t y_end, uint8_t *dst, \
67 size_t dst_stride, size_t dst_width, size_t dst_height)
68
69 KLEIDICV_INSTANTIATE_TEMPLATE(2L, 1L);
70 KLEIDICV_INSTANTIATE_TEMPLATE(2L, 2L);
71 KLEIDICV_INSTANTIATE_TEMPLATE(2L, 3L);
72 KLEIDICV_INSTANTIATE_TEMPLATE(3L, 1L);
73 KLEIDICV_INSTANTIATE_TEMPLATE(3L, 2L);
74 KLEIDICV_INSTANTIATE_TEMPLATE(3L, 3L);
75
76 } // namespace kleidicv::neon
77