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 | 1158 | 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 576 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 3 times.
|
2310 | return (src_stride / sizeof(T) <= std::numeric_limits<uint16_t>::max() && |
23 |
4/4✓ Branch 0 taken 567 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 567 times.
✓ Branch 3 taken 9 times.
|
1152 | dst_width >= 8 && |
24 |
4/4✓ Branch 0 taken 564 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 564 times.
✓ Branch 3 taken 3 times.
|
1134 | src_width <= std::numeric_limits<int16_t>::max() + 1 && |
25 |
4/4✓ Branch 0 taken 561 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 561 times.
✓ Branch 3 taken 3 times.
|
1128 | src_height <= std::numeric_limits<int16_t>::max() + 1 && |
26 |
4/4✓ Branch 0 taken 279 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 279 times.
✓ Branch 3 taken 282 times.
|
1122 | (border_type == KLEIDICV_BORDER_TYPE_REPLICATE || |
27 |
4/4✓ Branch 0 taken 6 times.
✓ Branch 1 taken 273 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 273 times.
|
558 | border_type == KLEIDICV_BORDER_TYPE_CONSTANT) && |
28 | 1110 | channels == 1); | |
29 | } else { | ||
30 | return false; | ||
31 | } | ||
32 | } | ||
33 | |||
34 | template <typename T> | ||
35 | 2262 | 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 | 6774 | return (src_stride / sizeof(T) <= | |
42 |
8/8✓ Branch 0 taken 1125 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1125 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 1125 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 1125 times.
✓ Branch 7 taken 6 times.
|
4524 | (std::numeric_limits<uint16_t>::max() / channels) && |
43 |
4/4✓ Branch 0 taken 1116 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 1116 times.
✓ Branch 3 taken 9 times.
|
2250 | dst_width >= 8 && |
44 |
4/4✓ Branch 0 taken 1113 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1113 times.
✓ Branch 3 taken 3 times.
|
2232 | src_width <= std::numeric_limits<int16_t>::max() + 1 && |
45 |
4/4✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1110 times.
✓ Branch 3 taken 3 times.
|
2226 | src_height <= std::numeric_limits<int16_t>::max() + 1 && |
46 |
4/4✓ Branch 0 taken 552 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 552 times.
✓ Branch 3 taken 558 times.
|
2220 | (border_type == KLEIDICV_BORDER_TYPE_REPLICATE || |
47 |
4/4✓ Branch 0 taken 6 times.
✓ Branch 1 taken 546 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 546 times.
|
1104 | border_type == KLEIDICV_BORDER_TYPE_CONSTANT) && |
48 |
4/4✓ Branch 0 taken 549 times.
✓ Branch 1 taken 555 times.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 555 times.
|
2208 | (channels == 1 || channels == 4)); |
49 | } else { | ||
50 | return false; | ||
51 | } | ||
52 | } | ||
53 | |||
54 | template <typename T> | ||
55 | 2424 | 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 1209 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1209 times.
✓ Branch 3 taken 3 times.
|
4842 | return (src_stride <= std::numeric_limits<uint32_t>::max() && |
62 |
8/8✓ Branch 0 taken 1206 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1200 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 1206 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 1200 times.
✓ Branch 7 taken 6 times.
|
2418 | dst_width >= 4 && src_width < (1ULL << 24) && |
63 |
8/8✓ Branch 0 taken 1194 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1191 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 1194 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 1191 times.
✓ Branch 7 taken 3 times.
|
2400 | src_height < (1ULL << 24) && dst_width < (1ULL << 24) && |
64 |
10/12✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1188 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1185 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 1188 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 1188 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1185 times.
✓ Branch 11 taken 3 times.
|
2382 | dst_height < (1ULL << 24) && src_width > 0 && src_height > 0 && |
65 |
4/4✓ Branch 0 taken 591 times.
✓ Branch 1 taken 594 times.
✓ Branch 2 taken 591 times.
✓ Branch 3 taken 594 times.
|
2370 | (border_type == KLEIDICV_BORDER_TYPE_REPLICATE || |
66 |
4/4✓ Branch 0 taken 9 times.
✓ Branch 1 taken 582 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 582 times.
|
1182 | border_type == KLEIDICV_BORDER_TYPE_CONSTANT) && |
67 |
4/4✓ Branch 0 taken 594 times.
✓ Branch 1 taken 582 times.
✓ Branch 2 taken 594 times.
✓ Branch 3 taken 582 times.
|
2352 | (channels == 1 || channels == 2) && |
68 |
4/4✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 1110 times.
✓ Branch 3 taken 66 times.
|
2352 | (interpolation == KLEIDICV_INTERPOLATION_LINEAR || |
69 | 132 | 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 |