KleidiCV Coverage Report


Directory: ./
File: kleidicv/include/kleidicv/transform/remap.h
Date: 2025-11-25 17:23:32
Exec Total Coverage
Lines: 27 27 100.0%
Functions: 6 6 100.0%
Branches: 102 104 98.1%

Line Branch Exec Source
1 // SPDX-FileCopyrightText: 2024 - 2025 Arm Limited and/or its affiliates <open-source-office@arm.com>
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 #ifndef KLEIDICV_REMAP_REMAP_H
6 #define KLEIDICV_REMAP_REMAP_H
7
8 #include <limits>
9 #include <type_traits>
10
11 #include "kleidicv/ctypes.h"
12
13 namespace kleidicv {
14
15 template <typename T>
16 1544 inline bool remap_s16_is_implemented(size_t src_stride, size_t src_width,
17 size_t src_height, size_t dst_width,
18 kleidicv_border_type_t border_type,
19 size_t channels) KLEIDICV_STREAMING {
20 if constexpr (std::is_same<T, uint8_t>::value ||
21 std::is_same<T, uint16_t>::value) {
22
4/4
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 4 times.
3080 return (src_stride / sizeof(T) <= std::numeric_limits<uint16_t>::max() &&
23
4/4
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 756 times.
✓ Branch 3 taken 12 times.
1536 dst_width >= 8 &&
24
4/4
✓ Branch 0 taken 752 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 752 times.
✓ Branch 3 taken 4 times.
1512 src_width <= std::numeric_limits<int16_t>::max() + 1 &&
25
4/4
✓ Branch 0 taken 748 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 748 times.
✓ Branch 3 taken 4 times.
1504 src_height <= std::numeric_limits<int16_t>::max() + 1 &&
26
4/4
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 376 times.
✓ Branch 2 taken 372 times.
✓ Branch 3 taken 376 times.
1496 (border_type == KLEIDICV_BORDER_TYPE_REPLICATE ||
27
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 364 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 364 times.
744 border_type == KLEIDICV_BORDER_TYPE_CONSTANT) &&
28 1480 channels == 1);
29 } else {
30 return false;
31 }
32 }
33
34 template <typename T>
35 3016 inline bool remap_s16point5_is_implemented(size_t src_stride, size_t src_width,
36 size_t src_height, size_t dst_width,
37 kleidicv_border_type_t border_type,
38 size_t channels) KLEIDICV_STREAMING {
39 if constexpr (std::is_same<T, uint8_t>::value ||
40 std::is_same<T, uint16_t>::value) {
41 9032 return (src_stride / sizeof(T) <=
42
8/8
✓ Branch 0 taken 1500 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 1500 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 1500 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 1500 times.
✓ Branch 7 taken 8 times.
6032 (std::numeric_limits<uint16_t>::max() / channels) &&
43
4/4
✓ Branch 0 taken 1488 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1488 times.
✓ Branch 3 taken 12 times.
3000 dst_width >= 8 &&
44
4/4
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1484 times.
✓ Branch 3 taken 4 times.
2976 src_width <= std::numeric_limits<int16_t>::max() + 1 &&
45
4/4
✓ Branch 0 taken 1480 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1480 times.
✓ Branch 3 taken 4 times.
2968 src_height <= std::numeric_limits<int16_t>::max() + 1 &&
46
4/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 744 times.
✓ Branch 2 taken 736 times.
✓ Branch 3 taken 744 times.
2960 (border_type == KLEIDICV_BORDER_TYPE_REPLICATE ||
47
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 728 times.
1472 border_type == KLEIDICV_BORDER_TYPE_CONSTANT) &&
48
4/4
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 740 times.
✓ Branch 2 taken 732 times.
✓ Branch 3 taken 740 times.
2944 (channels == 1 || channels == 4));
49 } else {
50 return false;
51 }
52 }
53
54 template <typename T>
55 3232 inline bool remap_f32_is_implemented(
56 size_t src_stride, size_t src_width, size_t src_height, size_t dst_width,
57 size_t dst_height, kleidicv_border_type_t border_type, size_t channels,
58 kleidicv_interpolation_type_t interpolation) KLEIDICV_STREAMING {
59 if constexpr (std::is_same<T, uint8_t>::value ||
60 std::is_same<T, uint16_t>::value) {
61
4/4
✓ Branch 0 taken 1612 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1612 times.
✓ Branch 3 taken 4 times.
6456 return (src_stride <= std::numeric_limits<uint32_t>::max() &&
62
8/8
✓ Branch 0 taken 1608 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1600 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 1608 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1600 times.
✓ Branch 7 taken 8 times.
3224 dst_width >= 4 && src_width < (1ULL << 24) &&
63
8/8
✓ Branch 0 taken 1592 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 1588 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1592 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 1588 times.
✓ Branch 7 taken 4 times.
3200 src_height < (1ULL << 24) && dst_width < (1ULL << 24) &&
64
10/12
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1584 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1580 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1584 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 1584 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1580 times.
✓ Branch 11 taken 4 times.
3176 dst_height < (1ULL << 24) && src_width > 0 && src_height > 0 &&
65
4/4
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 792 times.
✓ Branch 2 taken 788 times.
✓ Branch 3 taken 792 times.
3160 (border_type == KLEIDICV_BORDER_TYPE_REPLICATE ||
66
4/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 776 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 776 times.
1576 border_type == KLEIDICV_BORDER_TYPE_CONSTANT) &&
67
4/4
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 776 times.
✓ Branch 2 taken 792 times.
✓ Branch 3 taken 776 times.
3136 (channels == 1 || channels == 2) &&
68
4/4
✓ Branch 0 taken 1480 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 1480 times.
✓ Branch 3 taken 88 times.
3136 (interpolation == KLEIDICV_INTERPOLATION_LINEAR ||
69 176 interpolation == KLEIDICV_INTERPOLATION_NEAREST));
70 } else {
71 return false;
72 }
73 }
74
75 // Constants for Remap16Point5
76 static const uint16_t REMAP16POINT5_FRAC_BITS = 5;
77 static const uint16_t REMAP16POINT5_FRAC_MAX = 1 << REMAP16POINT5_FRAC_BITS;
78 static const uint16_t REMAP16POINT5_FRAC_MAX_SQUARE =
79 REMAP16POINT5_FRAC_MAX * REMAP16POINT5_FRAC_MAX;
80
81 namespace neon {
82
83 template <typename T>
84 kleidicv_error_t remap_s16(const T *src, size_t src_stride, size_t src_width,
85 size_t src_height, T *dst, size_t dst_stride,
86 size_t dst_width, size_t dst_height, size_t channels,
87 const int16_t *mapxy, size_t mapxy_stride,
88 kleidicv_border_type_t border_type,
89 const T *border_value);
90
91 template <typename T>
92 kleidicv_error_t remap_s16point5(const T *src, size_t src_stride,
93 size_t src_width, size_t src_height, T *dst,
94 size_t dst_stride, size_t dst_width,
95 size_t dst_height, size_t channels,
96 const int16_t *mapxy, size_t mapxy_stride,
97 const uint16_t *mapfrac, size_t mapfrac_stride,
98 kleidicv_border_type_t border_type,
99 const T *border_value);
100
101 template <typename T>
102 kleidicv_error_t remap_f32(const T *src, size_t src_stride, size_t src_width,
103 size_t src_height, T *dst, size_t dst_stride,
104 size_t dst_width, size_t dst_height, size_t channels,
105 const float *mapx, size_t mapx_stride,
106 const float *mapy, size_t mapy_stride,
107 kleidicv_interpolation_type_t interpolation,
108 kleidicv_border_type_t border_type,
109 const T *border_value);
110
111 } // namespace neon
112
113 namespace sve2 {
114
115 template <typename T>
116 kleidicv_error_t remap_s16(const T *src, size_t src_stride, size_t src_width,
117 size_t src_height, T *dst, size_t dst_stride,
118 size_t dst_width, size_t dst_height, size_t channels,
119 const int16_t *mapxy, size_t mapxy_stride,
120 kleidicv_border_type_t border_type,
121 const T *border_value);
122
123 template <typename T>
124 kleidicv_error_t remap_s16point5(const T *src, size_t src_stride,
125 size_t src_width, size_t src_height, T *dst,
126 size_t dst_stride, size_t dst_width,
127 size_t dst_height, size_t channels,
128 const int16_t *mapxy, size_t mapxy_stride,
129 const uint16_t *mapfrac, size_t mapfrac_stride,
130 kleidicv_border_type_t border_type,
131 const T *border_value);
132
133 template <typename T>
134 kleidicv_error_t remap_f32(const T *src, size_t src_stride, size_t src_width,
135 size_t src_height, T *dst, size_t dst_stride,
136 size_t dst_width, size_t dst_height, size_t channels,
137 const float *mapx, size_t mapx_stride,
138 const float *mapy, size_t mapy_stride,
139 kleidicv_interpolation_type_t interpolation,
140 kleidicv_border_type_t border_type,
141 const T *border_value);
142 } // namespace sve2
143
144 } // namespace kleidicv
145
146 #endif // KLEIDICV_REMAP_REMAP_H
147