[FFmpeg-devel] [PATCH 2/2] swscale/aarch64/rgb2rgb_neon: Implemented {yuyv, uyvy}toyuv{420, 422}
Martin Storsjö
martin at martin.st
Wed Feb 12 14:02:00 EET 2025
On Tue, 11 Feb 2025, Krzysztof Pyrkosz via ffmpeg-devel wrote:
> ---
> libswscale/aarch64/rgb2rgb.c | 16 ++
> libswscale/aarch64/rgb2rgb_neon.S | 262 ++++++++++++++++++++++++++++++
> 2 files changed, 278 insertions(+)
>
> diff --git a/libswscale/aarch64/rgb2rgb.c b/libswscale/aarch64/rgb2rgb.c
> index 7e1dba572d..f474228298 100644
> --- a/libswscale/aarch64/rgb2rgb.c
> +++ b/libswscale/aarch64/rgb2rgb.c
> @@ -67,6 +67,18 @@ void ff_shuffle_bytes_2013_neon(const uint8_t *src, uint8_t *dst, int src_size);
> void ff_shuffle_bytes_2130_neon(const uint8_t *src, uint8_t *dst, int src_size);
> void ff_shuffle_bytes_1203_neon(const uint8_t *src, uint8_t *dst, int src_size);
>
> +void ff_uyvytoyuv422_neon(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
> + const uint8_t *src, int width, int height,
> + int lumStride, int chromStride, int srcStride);
> +void ff_uyvytoyuv420_neon(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
> + const uint8_t *src, int width, int height,
> + int lumStride, int chromStride, int srcStride);
> +void ff_yuyvtoyuv420_neon(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
> + const uint8_t *src, int width, int height,
> + int lumStride, int chromStride, int srcStride);
> +void ff_yuyvtoyuv422_neon(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
> + const uint8_t *src, int width, int height,
> + int lumStride, int chromStride, int srcStride);
> av_cold void rgb2rgb_init_aarch64(void)
> {
> int cpu_flags = av_get_cpu_flags();
> @@ -84,5 +96,9 @@ av_cold void rgb2rgb_init_aarch64(void)
> shuffle_bytes_2013 = ff_shuffle_bytes_2013_neon;
> shuffle_bytes_2130 = ff_shuffle_bytes_2130_neon;
> shuffle_bytes_1203 = ff_shuffle_bytes_1203_neon;
> + uyvytoyuv422 = ff_uyvytoyuv422_neon;
> + uyvytoyuv420 = ff_uyvytoyuv420_neon;
> + yuyvtoyuv422 = ff_yuyvtoyuv422_neon;
> + yuyvtoyuv420 = ff_yuyvtoyuv420_neon;
> }
> }
> diff --git a/libswscale/aarch64/rgb2rgb_neon.S b/libswscale/aarch64/rgb2rgb_neon.S
> index 22ecdf7ac8..9002aa028f 100644
> --- a/libswscale/aarch64/rgb2rgb_neon.S
> +++ b/libswscale/aarch64/rgb2rgb_neon.S
> @@ -427,3 +427,265 @@ neon_shuf 2013
> neon_shuf 1203
> neon_shuf 2130
> neon_shuf 3210
> +
> +/*
> +v0-v7 - two consecutive lines
> +x0 - upper Y destination
> +x1 - U destination
> +x2 - V destination
> +x3 - upper src line
> +w5 - width/iteration counter - count of line pairs for yuv420, of single lines for 422
> +x6 - lum padding
> +x7 - chrom padding
> +x8 - src padding
> +w9 - number of bytes remaining in the tail
> +x10 - lower Y destination
> +w12 - tmp
> +x13 - lower src line
> +w14 - tmp
> +w17 - set to 1 if last line has to be handled separately (odd height)
> +*/
> +
> +// one fast path iteration processes 16 uyvy tuples
> +// is_line_tail is set to 1 when final 16 tuples are being processed
> +// skip_storing_chroma is set to 1 when final line is processed and the height is odd
> +.macro fastpath_iteration src_fmt, dst_fmt, is_line_tail, skip_storing_chroma
> + ld4 {v0.16b - v3.16b}, [x3], #64
> +.if ! \is_line_tail
> + subs w14, w14, #32
> +.endif
> +
> +.if ! \skip_storing_chroma
> +.if \dst_fmt == yuv420
This doesn't work as you want it to across all supported tools; .if
conditionals are meant for pure numerical comparisons, and yuv420 isn't a
numerical constant. In practice it does seem to work with binutils though,
but not with Clang (or with gas-preprocessor).
You can use .ifc for string comparisons, see
https://sourceware.org/binutils/docs/as/If.html for more references.
Also see
https://github.com/mstorsjo/FFmpeg/actions/runs/13282469154/job/37083639139
for the fallout from trying to build this patch with various tool setups.
Please do consider trying the aarch64 assembly testset from
https://github.com/mstorsjo/FFmpeg/commits/gha-aarch64 on your commits.
// Martin
More information about the ffmpeg-devel
mailing list