Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Martin Storsjö" <martin@martin.st>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Zhao Zhili <zhilizhao@tencent.com>
Subject: Re: [FFmpeg-devel] [PATCH] swscale/aarch64: Add argb/abgr to yuv
Date: Tue, 18 Jun 2024 23:37:51 +0300 (EEST)
Message-ID: <b1976999-b7eb-2362-95a7-76d96ae3eb4e@martin.st> (raw)
In-Reply-To: <tencent_63E7C7EA9393191C570BAE2607D0ACA6E406@qq.com>

On Sun, 16 Jun 2024, Zhao Zhili wrote:

> From: Zhao Zhili <zhilizhao@tencent.com>
>
> Test on Apple M1 with kperf:
>
> abgr_to_uv_8_c: 19.4
> abgr_to_uv_8_neon: 29.9
> abgr_to_uv_128_c: 146.4
> abgr_to_uv_128_neon: 85.1
> abgr_to_uv_1080_c: 1162.6
> abgr_to_uv_1080_neon: 819.6
> abgr_to_uv_1920_c: 2063.6
> abgr_to_uv_1920_neon: 1435.1
> abgr_to_uv_half_8_c: 16.4
> abgr_to_uv_half_8_neon: 35.6
> abgr_to_uv_half_128_c: 108.6
> abgr_to_uv_half_128_neon: 75.4
> abgr_to_uv_half_1080_c: 883.4
> abgr_to_uv_half_1080_neon: 460.6
> abgr_to_uv_half_1920_c: 1553.6
> abgr_to_uv_half_1920_neon: 817.6
> abgr_to_y_8_c: 6.1
> abgr_to_y_8_neon: 40.6
> abgr_to_y_128_c: 99.9
> abgr_to_y_128_neon: 67.4
> abgr_to_y_1080_c: 735.9
> abgr_to_y_1080_neon: 534.6
> abgr_to_y_1920_c: 1279.4
> abgr_to_y_1920_neon: 932.6
>
> Disable vectorization in clang:
>
> abgr_to_uv_8_c: 20.9
> abgr_to_uv_8_neon: 44.1
> abgr_to_uv_128_c: 555.6
> abgr_to_uv_128_neon: 105.9
> abgr_to_uv_1080_c: 4773.1
> abgr_to_uv_1080_neon: 846.1
> abgr_to_uv_1920_c: 8499.9
> abgr_to_uv_1920_neon: 1436.6
> abgr_to_uv_half_8_c: 13.9
> abgr_to_uv_half_8_neon: 167.9
> abgr_to_uv_half_128_c: 338.9
> abgr_to_uv_half_128_neon: 60.6
> abgr_to_uv_half_1080_c: 2906.9
> abgr_to_uv_half_1080_neon: 466.1
> abgr_to_uv_half_1920_c: 5084.4
> abgr_to_uv_half_1920_neon: 832.9
> abgr_to_y_8_c: 9.6
> abgr_to_y_8_neon: 18.6
> abgr_to_y_128_c: 372.4
> abgr_to_y_128_neon: 61.4
> abgr_to_y_1080_c: 3168.9
> abgr_to_y_1080_neon: 513.9
> abgr_to_y_1920_c: 6187.6
> abgr_to_y_1920_neon: 918.9
> ---
> libswscale/aarch64/input.S   | 104 ++++++++++++++++++++++++++++-------
> libswscale/aarch64/swscale.c |  17 ++++++
> 2 files changed, 100 insertions(+), 21 deletions(-)
>
> diff --git a/libswscale/aarch64/input.S b/libswscale/aarch64/input.S
> index 37f1158504..b4e827dd50 100644
> --- a/libswscale/aarch64/input.S
> +++ b/libswscale/aarch64/input.S
> @@ -34,6 +34,16 @@
>         uxtl2           v24.8h, v18.16b            // v24: b
> .endm
>
> +.macro argb_to_yuv_load_rgb src
> +        ld4             { v16.16b, v17.16b, v18.16b, v19.16b }, [\src]
> +        uxtl            v21.8h, v19.8b             // v21: b
> +        uxtl2           v24.8h, v19.16b            // v24: b
> +        uxtl            v19.8h, v17.8b             // v19: r
> +        uxtl            v20.8h, v18.8b             // v20: g
> +        uxtl2           v22.8h, v17.16b            // v22: r
> +        uxtl2           v23.8h, v18.16b            // v23: g
> +.endm
> +
> .macro rgb_to_yuv_product r, g, b, dst1, dst2, dst, coef0, coef1, coef2, right_shift
>         mov             \dst1\().16b, v6.16b                    // dst1 = const_offset
>         mov             \dst2\().16b, v6.16b                    // dst2 = const_offset
> @@ -47,7 +57,7 @@
>         sqshrn2         \dst\().8h, \dst2\().4s, \right_shift   // dst_higher_half = dst2 >> right_shift
> .endm
>
> -.macro rgbToY bgr, element=3
> +.macro rgbToY bgr, element=3, alpha_first=0
>         cmp             w4, #0                  // check width > 0
>     .if \bgr
>         ldr             w12, [x5]               // w12: ry
> @@ -71,7 +81,11 @@
>         dup             v2.8h, w12
>         b.lt            2f
> 1:
> +    .if \alpha_first
> +        argb_to_yuv_load_rgb x1
> +    .else
>         rgb_to_yuv_load_rgb x1, \element
> +    .endif
>         rgb_to_yuv_product v19, v20, v21, v25, v26, v16, v0, v1, v2, #9
>         rgb_to_yuv_product v22, v23, v24, v27, v28, v17, v0, v1, v2, #9
>         sub             w4, w4, #16             // width -= 16
> @@ -85,9 +99,15 @@
>         b.ge            1b
>         cbz             x4, 3f
> 2:
> +    .if \alpha_first
> +        ldrb            w13, [x1, #1]               // w13: r
> +        ldrb            w14, [x1, #2]           // w14: g
> +        ldrb            w15, [x1, #3]           // w15: b
> +    .else
>         ldrb            w13, [x1]               // w13: r
>         ldrb            w14, [x1, #1]           // w14: g
>         ldrb            w15, [x1, #2]           // w15: b
> +    .endif
>
>         smaddl          x13, w13, w10, x9       // x13 = ry * r + const_offset
>         smaddl          x13, w14, w11, x13      // x13 += gy * g
> @@ -101,6 +121,14 @@
>         ret
> .endm
>
> +function ff_argb32ToY_neon, export=1
> +        rgbToY          bgr=0, element=4, alpha_first=1
> +endfunc
> +
> +function ff_abgr32ToY_neon, export=1
> +        rgbToY          bgr=1, element=4, alpha_first=1
> +endfunc
> +
> function ff_rgb24ToY_neon, export=1
>         rgbToY          bgr=0
> endfunc
> @@ -146,7 +174,21 @@ endfunc
>         dup             v6.4s, w9
> .endm
>
> -.macro rgbToUV_half bgr, element=3
> +.macro rgb_load_add_half    off_r1, off_r2, off_g1, off_g2, off_b1, off_b2
> +        ldrb            w2, [x3, \off_r1]      // w2: r1
> +        ldrb            w4, [x3, \off_r2]      // w4: r2

Keep # for the immediate constant

Otherwise this seems ok.

// Martin

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

      reply	other threads:[~2024-06-18 20:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-16 12:14 Zhao Zhili
2024-06-18 20:37 ` Martin Storsjö [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b1976999-b7eb-2362-95a7-76d96ae3eb4e@martin.st \
    --to=martin@martin.st \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=zhilizhao@tencent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git