KleidiCV Coverage Report


Directory: ./
File: kleidicv/include/kleidicv/transform/warp_perspective.h
Date: 2025-09-25 14:13:34
Exec Total Coverage
Lines: 7 7 100.0%
Functions: 1 1 100.0%
Branches: 8 8 100.0%

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_TRANSFORM_WARP_PERSPECTIVE_H
6 #define KLEIDICV_TRANSFORM_WARP_PERSPECTIVE_H
7
8 #include <limits>
9 #include <type_traits>
10
11 #include "kleidicv/ctypes.h"
12
13 extern "C" {
14 // For internal use only. See kleidicv_warp_perspective_u8 instead.
15 // Calculates a stripe of the `dst` image that is a transformed part of `src`.
16 // The stripe is defined by the range (y_begin, y_end].
17 KLEIDICV_API_DECLARATION(kleidicv_warp_perspective_stripe_u8,
18 const uint8_t *src, size_t src_stride,
19 size_t src_width, size_t src_height, uint8_t *dst,
20 size_t dst_stride, size_t dst_width, size_t dst_height,
21 size_t y_begin, size_t y_end,
22 const float transformation[9], size_t channels,
23 kleidicv_interpolation_type_t interpolation,
24 kleidicv_border_type_t border_type,
25 const uint8_t *border_value);
26 }
27 namespace kleidicv {
28
29 template <typename T>
30 405 inline bool warp_perspective_is_implemented(
31 size_t dst_width, size_t channels,
32 kleidicv_interpolation_type_t interpolation,
33 kleidicv_border_type_t border_type) KLEIDICV_STREAMING {
34 if constexpr (std::is_same<T, uint8_t>::value) {
35
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 9 times.
849 return (dst_width >= 8 &&
36
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 228 times.
396 (interpolation == KLEIDICV_INTERPOLATION_NEAREST ||
37
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 24 times.
168 interpolation == KLEIDICV_INTERPOLATION_LINEAR) &&
38
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 387 times.
420 (border_type == KLEIDICV_BORDER_TYPE_REPLICATE ||
39 33 border_type == KLEIDICV_BORDER_TYPE_CONSTANT) &&
40 387 channels == 1);
41 } else {
42 return false;
43 }
44 }
45
46 namespace neon {
47
48 template <typename T>
49 kleidicv_error_t warp_perspective_stripe(
50 const T *src, size_t src_stride, size_t src_width, size_t src_height,
51 T *dst, size_t dst_stride, size_t dst_width, size_t dst_height,
52 size_t y_begin, size_t y_end, const float transformation[9],
53 size_t channels, kleidicv_interpolation_type_t interpolation,
54 kleidicv_border_type_t border_type, const T *border_value);
55 } // namespace neon
56
57 namespace sve2 {
58
59 template <typename T>
60 kleidicv_error_t warp_perspective_stripe(
61 const T *src, size_t src_stride, size_t src_width, size_t src_height,
62 T *dst, size_t dst_stride, size_t dst_width, size_t dst_height,
63 size_t y_begin, size_t y_end, const float transformation[9],
64 size_t channels, kleidicv_interpolation_type_t interpolation,
65 kleidicv_border_type_t border_type, const T *border_value);
66 } // namespace sve2
67
68 } // namespace kleidicv
69
70 #endif // KLEIDICV_TRANSFORM_WARP_PERSPECTIVE_H
71