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_RESIZE_RESIZE_LINEAR_H | ||
6 | #define KLEIDICV_RESIZE_RESIZE_LINEAR_H | ||
7 | |||
8 | #include <algorithm> | ||
9 | #include <array> | ||
10 | |||
11 | #include "kleidicv/kleidicv.h" | ||
12 | |||
13 | namespace kleidicv { | ||
14 | |||
15 | 404 | inline bool resize_linear_u8_is_implemented(size_t src_width, size_t src_height, | |
16 | size_t dst_width, | ||
17 | size_t dst_height) { | ||
18 |
4/4✓ Branch 0 taken 396 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 392 times.
|
404 | if (src_width == 0 || src_height == 0) { |
19 | 12 | return true; | |
20 | } | ||
21 | 392 | const std::array<size_t, 2> implemented_ratios = {2, 4}; | |
22 | 784 | return std::any_of(implemented_ratios.begin(), implemented_ratios.end(), | |
23 | 948 | [&](size_t ratio) { | |
24 |
2/2✓ Branch 0 taken 180 times.
✓ Branch 1 taken 376 times.
|
932 | return src_width * ratio == dst_width && |
25 | 376 | src_height * ratio == dst_height; | |
26 | }); | ||
27 | 404 | } | |
28 | |||
29 | 532 | inline bool resize_linear_f32_is_implemented(size_t src_width, | |
30 | size_t src_height, | ||
31 | size_t dst_width, | ||
32 | size_t dst_height) { | ||
33 |
4/4✓ Branch 0 taken 524 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 520 times.
|
532 | if (src_width == 0 || src_height == 0) { |
34 | 12 | return true; | |
35 | } | ||
36 | 520 | const std::array<size_t, 3> implemented_ratios = {2, 4, 8}; | |
37 | 1040 | return std::any_of(implemented_ratios.begin(), implemented_ratios.end(), | |
38 | 1508 | [&](size_t ratio) { | |
39 |
2/2✓ Branch 0 taken 476 times.
✓ Branch 1 taken 512 times.
|
1500 | return src_width * ratio == dst_width && |
40 | 512 | src_height * ratio == dst_height; | |
41 | }); | ||
42 | 532 | } | |
43 | |||
44 | namespace neon { | ||
45 | kleidicv_error_t resize_linear_stripe_u8(const uint8_t *src, size_t src_stride, | ||
46 | size_t src_width, size_t src_height, | ||
47 | size_t y_begin, size_t y_end, | ||
48 | uint8_t *dst, size_t dst_stride, | ||
49 | size_t dst_width, size_t dst_height); | ||
50 | kleidicv_error_t resize_linear_stripe_f32(const float *src, size_t src_stride, | ||
51 | size_t src_width, size_t src_height, | ||
52 | size_t y_begin, size_t y_end, | ||
53 | float *dst, size_t dst_stride, | ||
54 | size_t dst_width, size_t dst_height); | ||
55 | } // namespace neon | ||
56 | |||
57 | namespace sve2 { | ||
58 | kleidicv_error_t resize_linear_stripe_u8(const uint8_t *src, size_t src_stride, | ||
59 | size_t src_width, size_t src_height, | ||
60 | size_t y_begin, size_t y_end, | ||
61 | uint8_t *dst, size_t dst_stride, | ||
62 | size_t dst_width, size_t dst_height); | ||
63 | kleidicv_error_t resize_linear_stripe_f32(const float *src, size_t src_stride, | ||
64 | size_t src_width, size_t src_height, | ||
65 | size_t y_begin, size_t y_end, | ||
66 | float *dst, size_t dst_stride, | ||
67 | size_t dst_width, size_t dst_height); | ||
68 | } // namespace sve2 | ||
69 | |||
70 | namespace sme { | ||
71 | kleidicv_error_t resize_linear_stripe_u8(const uint8_t *src, size_t src_stride, | ||
72 | size_t src_width, size_t src_height, | ||
73 | size_t y_begin, size_t y_end, | ||
74 | uint8_t *dst, size_t dst_stride, | ||
75 | size_t dst_width, size_t dst_height); | ||
76 | kleidicv_error_t resize_linear_stripe_f32(const float *src, size_t src_stride, | ||
77 | size_t src_width, size_t src_height, | ||
78 | size_t y_begin, size_t y_end, | ||
79 | float *dst, size_t dst_stride, | ||
80 | size_t dst_width, size_t dst_height); | ||
81 | } // namespace sme | ||
82 | |||
83 | } // namespace kleidicv | ||
84 | |||
85 | #ifdef __cplusplus | ||
86 | extern "C" { | ||
87 | #endif // __cplusplus | ||
88 | /// Internal - not part of the public API and its direct use is not supported. | ||
89 | /// It is used by the multithreaded function. | ||
90 | extern kleidicv_error_t (*kleidicv_resize_linear_stripe_u8)( | ||
91 | const uint8_t *src, size_t src_stride, size_t src_width, size_t src_height, | ||
92 | size_t y_begin, size_t y_end, uint8_t *dst, size_t dst_stride, | ||
93 | size_t dst_width, size_t dst_height); | ||
94 | |||
95 | /// Internal - not part of the public API and its direct use is not supported. | ||
96 | /// It is used by the multithreaded function. | ||
97 | extern kleidicv_error_t (*kleidicv_resize_linear_stripe_f32)( | ||
98 | const float *src, size_t src_stride, size_t src_width, size_t src_height, | ||
99 | size_t y_begin, size_t y_end, float *dst, size_t dst_stride, | ||
100 | size_t dst_width, size_t dst_height); | ||
101 | |||
102 | #ifdef __cplusplus | ||
103 | } // extern "C" | ||
104 | #endif // __cplusplus | ||
105 | |||
106 | #endif // KLEIDICV_RESIZE_RESIZE_H | ||
107 |