[FFmpeg-devel] [PATCH] swscale/aarch64/output: Implement neon assembly for yuv2nv12cX_c()

Martin Storsjö martin at martin.st
Mon Jun 2 10:52:59 EEST 2025


On Mon, 2 Jun 2025, Harshitha Sarangu Suresh wrote:

> From 7260822a578130a713c1455cca6cdd06f1540db8 Mon Sep 17 00:00:00 2001
> From: Harshitha Suresh <harshitha at multicorewareinc.com>
> Date: Mon, 19 May 2025 22:37:20 +0530
> Subject: [PATCH] swscale/aarch64/output: Implement neon assembly for yuv2nv12cX_c()
>
> yuv2nv12cX_2_512_accurate_c:                          3508.8 ( 1.00x)
> yuv2nv12cX_2_512_accurate_neon:                        369.2 ( 9.50x)
> yuv2nv12cX_2_512_approximate_c:                       3499.0 ( 1.00x)
> yuv2nv12cX_2_512_approximate_neon:                     370.2 ( 9.45x)
> yuv2nv12cX_4_512_accurate_c:                          4683.0 ( 1.00x)
> yuv2nv12cX_4_512_accurate_neon:                        568.8 ( 8.23x)
> yuv2nv12cX_4_512_approximate_c:                       4682.6 ( 1.00x)
> yuv2nv12cX_4_512_approximate_neon:                     569.9 ( 8.22x)
> yuv2nv12cX_8_512_accurate_c:                          7243.0 ( 1.00x)
> yuv2nv12cX_8_512_accurate_neon:                        937.6 ( 7.72x)
> yuv2nv12cX_8_512_approximate_c:                       7235.9 ( 1.00x)
> yuv2nv12cX_8_512_approximate_neon:                     938.3 ( 7.71x)
> yuv2nv12cX_16_512_accurate_c:                        13749.7 ( 1.00x)
> yuv2nv12cX_16_512_accurate_neon:                      1708.1 ( 8.05x)
> yuv2nv12cX_16_512_approximate_c:                     13750.0 ( 1.00x)
> yuv2nv12cX_16_512_approximate_neon:                   1708.6 ( 8.05x)
> ---
> libswscale/aarch64/output.S  | 308 +++++++++++++++++++++++++++++++++++
> libswscale/aarch64/swscale.c |  18 ++
> 2 files changed, 326 insertions(+)
>
> diff --git a/libswscale/aarch64/output.S b/libswscale/aarch64/output.S
> index 190c438870..8eb89e8b54 100644
> --- a/libswscale/aarch64/output.S
> +++ b/libswscale/aarch64/output.S
> @@ -226,3 +226,311 @@ function ff_yuv2plane1_8_neon, export=1
>         b.gt            2b                              // loop until width consumed
>         ret
> endfunc
> +
> +// void ff_yuv2nv12cX_neon(enum AVPixelFormat dstFormat, const uint8_t *chrDither,
> +//                         const int16_t *chrFilter, int chrFilterSize,
> +//                         const int16_t **chrUSrc, const int16_t **chrVSrc,
> +//                         uint8_t *dest, int chrDstW)
> +
> +function ff_yuv2nv12cX_notswapped_neon, export=1
> +    // x0 - dstFormat (unused)
> +    // x1 - uint8_t *chrDither
> +    // x2 - int16_t *chrFilter
> +    // x3 - int chrFilterSize
> +    // x4 - int16_t **chrUSrc
> +    // x5 - int16_t **chrVSrc
> +    // x6 - uint8_t *dest
> +    // x7 - int chrDstW
> +
> +    // Load dither pattern and compute U and V dither vectors
> +    ld1     {v0.8b}, [x1]               // chrDither[0..7]
> +    ext     v1.8b, v0.8b, v0.8b, #3      // Rotate for V: (i+3)&7

Please adhere to the indentation of the existing code, don't make up your 
own.

This patchset causes a lot of fate tests to fail, and causes ffmpeg to 
crash in a number of tests while running fate. Please fix that.

In order to test the assembly in all relevant configurations before 
submitting, I have made a setup of github actions, which anybody can use. 
This also includes indentation checks for the assembly.

If you make a copy of my branch at 
https://github.com/mstorsjo/ffmpeg/commits/gha-aarch64, add your own 
changes on top, and push to a repo on github, it will run the tests in all 
the configurations.

// Martin



More information about the ffmpeg-devel mailing list