| 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 | 505 | 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 495 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 490 times.
|
505 | if (src_width == 0 || src_height == 0) { |
| 19 | 15 | return true; | |
| 20 | } | ||
| 21 | 490 | const std::array<size_t, 2> implemented_ratios = {2, 4}; | |
| 22 | 980 | return std::any_of(implemented_ratios.begin(), implemented_ratios.end(), | |
| 23 | 1185 | [&](size_t ratio) { | |
| 24 |
2/2✓ Branch 0 taken 225 times.
✓ Branch 1 taken 470 times.
|
1165 | return src_width * ratio == dst_width && |
| 25 | 470 | src_height * ratio == dst_height; | |
| 26 | }); | ||
| 27 | 505 | } | |
| 28 | |||
| 29 | 665 | 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 655 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 650 times.
|
665 | if (src_width == 0 || src_height == 0) { |
| 34 | 15 | return true; | |
| 35 | } | ||
| 36 | 650 | const std::array<size_t, 3> implemented_ratios = {2, 4, 8}; | |
| 37 | 1300 | return std::any_of(implemented_ratios.begin(), implemented_ratios.end(), | |
| 38 | 1885 | [&](size_t ratio) { | |
| 39 |
2/2✓ Branch 0 taken 595 times.
✓ Branch 1 taken 640 times.
|
1875 | return src_width * ratio == dst_width && |
| 40 | 640 | src_height * ratio == dst_height; | |
| 41 | }); | ||
| 42 | 665 | } | |
| 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 |