KleidiCV Coverage Report


Directory: ./
File: kleidicv/include/kleidicv/transform/remap.h
Date: 2026-01-20 20:58:59
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 1832 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 912 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 912 times.
✓ Branch 3 taken 4 times.
3656 return (src_stride / sizeof(T) <= std::numeric_limits<uint16_t>::max() &&
23
4/4
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 900 times.
✓ Branch 3 taken 12 times.
1824 dst_width >= 8 &&
24
4/4
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 896 times.
✓ Branch 3 taken 4 times.
1800 src_width <= std::numeric_limits<int16_t>::max() + 1 &&
25
4/4
✓ Branch 0 taken 892 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 892 times.
✓ Branch 3 taken 4 times.
1792 src_height <= std::numeric_limits<int16_t>::max() + 1 &&
26
4/4
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 448 times.
✓ Branch 2 taken 444 times.
✓ Branch 3 taken 448 times.
1784 (border_type == KLEIDICV_BORDER_TYPE_REPLICATE ||
27
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 436 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 436 times.
888 border_type == KLEIDICV_BORDER_TYPE_CONSTANT) &&
28 1768 channels == 1);
29 } else {
30 return false;
31 }
32 }
33
34 template <typename T>
35 3592 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 10760 return (src_stride / sizeof(T) <=
42
8/8
✓ Branch 0 taken 1788 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 1788 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 1788 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 1788 times.
✓ Branch 7 taken 8 times.
7184 (std::numeric_limits<uint16_t>::max() / channels) &&
43
4/4
✓ Branch 0 taken 1776 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1776 times.
✓ Branch 3 taken 12 times.
3576 dst_width >= 8 &&
44
4/4
✓ Branch 0 taken 1772 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1772 times.
✓ Branch 3 taken 4 times.
3552 src_width <= std::numeric_limits<int16_t>::max() + 1 &&
45
4/4
✓ Branch 0 taken 1768 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 4 times.
3544 src_height <= std::numeric_limits<int16_t>::max() + 1 &&
46
4/4
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 888 times.
✓ Branch 2 taken 880 times.
✓ Branch 3 taken 888 times.
3536 (border_type == KLEIDICV_BORDER_TYPE_REPLICATE ||
47
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 872 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 872 times.
1760 border_type == KLEIDICV_BORDER_TYPE_CONSTANT) &&
48
4/4
✓ Branch 0 taken 876 times.
✓ Branch 1 taken 884 times.
✓ Branch 2 taken 876 times.
✓ Branch 3 taken 884 times.
3520 (channels == 1 || channels == 4));
49 } else {
50 return false;
51 }
52 }
53
54 template <typename T>
55 3808 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 1900 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1900 times.
✓ Branch 3 taken 4 times.
7608 return (src_stride <= std::numeric_limits<uint32_t>::max() &&
62
8/8
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1888 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 1896 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1888 times.
✓ Branch 7 taken 8 times.
3800 dst_width >= 4 && src_width < (1ULL << 24) &&
63
8/8
✓ Branch 0 taken 1880 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 1876 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1880 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 1876 times.
✓ Branch 7 taken 4 times.
3776 src_height < (1ULL << 24) && dst_width < (1ULL << 24) &&
64
10/12
✓ Branch 0 taken 1872 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1872 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1868 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1872 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 1872 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1868 times.
✓ Branch 11 taken 4 times.
3752 dst_height < (1ULL << 24) && src_width > 0 && src_height > 0 &&
65
4/4
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 936 times.
✓ Branch 2 taken 932 times.
✓ Branch 3 taken 936 times.
3736 (border_type == KLEIDICV_BORDER_TYPE_REPLICATE ||
66
4/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 920 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 920 times.
1864 border_type == KLEIDICV_BORDER_TYPE_CONSTANT) &&
67
4/4
✓ Branch 0 taken 936 times.
✓ Branch 1 taken 920 times.
✓ Branch 2 taken 936 times.
✓ Branch 3 taken 920 times.
3712 (channels == 1 || channels == 2) &&
68
4/4
✓ Branch 0 taken 1768 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 88 times.
3712 (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