| 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 | #include "kleidicv/conversions/rgb_to_yuv.h" | ||
| 6 | #include "kleidicv/dispatch.h" | ||
| 7 | #include "kleidicv/kleidicv.h" | ||
| 8 | |||
| 9 | #define KLEIDICV_DEFINE_C_API_WITH_SME2(name, partialname) \ | ||
| 10 | KLEIDICV_MULTIVERSION_C_API( \ | ||
| 11 | name, &kleidicv::neon::partialname, &kleidicv::sve2::partialname, \ | ||
| 12 | &kleidicv::sme::partialname, &kleidicv::sme2::partialname) | ||
| 13 | |||
| 14 | #define KLEIDICV_DEFINE_C_API_WITHOUT_SME2(name, partialname) \ | ||
| 15 | KLEIDICV_MULTIVERSION_C_API(name, &kleidicv::neon::partialname, \ | ||
| 16 | &kleidicv::sve2::partialname, \ | ||
| 17 | &kleidicv::sme::partialname, nullptr) | ||
| 18 | |||
| 19 |
6/6✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1 times.
|
10 | KLEIDICV_DEFINE_C_API_WITH_SME2(kleidicv_rgb_to_yuv444_u8, rgb_to_yuv444_u8); |
| 20 |
6/6✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1 times.
|
10 | KLEIDICV_DEFINE_C_API_WITH_SME2(kleidicv_rgb_to_yuv420p_stripe_u8, |
| 21 | rgb_to_yuv420p_stripe_u8); | ||
| 22 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
|
10 | KLEIDICV_DEFINE_C_API_WITHOUT_SME2(kleidicv_rgb_to_yuv422_u8, rgb_to_yuv422_u8); |
| 23 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
|
10 | KLEIDICV_DEFINE_C_API_WITHOUT_SME2(kleidicv_rgb_to_yuv420sp_stripe_u8, |
| 24 | rgb_to_yuv420sp_stripe_u8); | ||
| 25 | |||
| 26 | extern "C" { | ||
| 27 | |||
| 28 | 2465 | kleidicv_error_t kleidicv_rgb_to_yuv_u8( | |
| 29 | const uint8_t *src, size_t src_stride, uint8_t *dst, size_t dst_stride, | ||
| 30 | size_t width, size_t height, kleidicv_color_conversion_t color_format) { | ||
| 31 | // Extract the base format | ||
| 32 | 4930 | const size_t base_format = static_cast<size_t>( | |
| 33 | 2465 | color_format & KLEIDICV_COLOR_CONVERSION_YUV_FMT_MASK); | |
| 34 |
2/2✓ Branch 0 taken 940 times.
✓ Branch 1 taken 1525 times.
|
2465 | if (base_format == KLEIDICV_COLOR_CONVERSION_FMT_YUV444) { |
| 35 | 1880 | return kleidicv_rgb_to_yuv444_u8(src, src_stride, dst, dst_stride, width, | |
| 36 | 940 | height, color_format); | |
| 37 | } | ||
| 38 |
2/2✓ Branch 0 taken 320 times.
✓ Branch 1 taken 1205 times.
|
1525 | if (base_format == KLEIDICV_COLOR_CONVERSION_FMT_YUV422) { |
| 39 | 640 | return kleidicv_rgb_to_yuv422_u8(src, src_stride, dst, dst_stride, width, | |
| 40 | 320 | height, color_format); | |
| 41 | } | ||
| 42 | |||
| 43 | // YUV420 uses 2x2 chroma blocks spanning adjacent rows, so the stripe API | ||
| 44 | // provides each invocation with contiguous rows and the proper per-plane | ||
| 45 | // offsets for that slice. | ||
| 46 | 2410 | return kleidicv_rgb_to_yuv420p_stripe_u8( | |
| 47 | 1205 | src, src_stride, dst, dst_stride, width, height, color_format, 0, height); | |
| 48 | 2465 | } | |
| 49 | |||
| 50 | 1240 | kleidicv_error_t kleidicv_rgb_to_yuv_semiplanar_u8( | |
| 51 | const uint8_t *src, size_t src_stride, uint8_t *y_dst, size_t y_stride, | ||
| 52 | uint8_t *uv_dst, size_t uv_stride, size_t width, size_t height, | ||
| 53 | kleidicv_color_conversion_t color_format) { | ||
| 54 | 2480 | return kleidicv_rgb_to_yuv420sp_stripe_u8(src, src_stride, y_dst, y_stride, | |
| 55 | 1240 | uv_dst, uv_stride, width, height, | |
| 56 | 1240 | color_format, 0, height); | |
| 57 | } | ||
| 58 | |||
| 59 | } // extern "C" | ||
| 60 |