From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 96BC04ADFB for ; Mon, 24 Jun 2024 11:55:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 156D668D602; Mon, 24 Jun 2024 14:55:24 +0300 (EEST) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B73C468CDEA for ; Mon, 24 Jun 2024 14:55:17 +0300 (EEST) Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2eaafda3b5cso45377621fa.3 for ; Mon, 24 Jun 2024 04:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20230601.gappssmtp.com; s=20230601; t=1719230117; x=1719834917; darn=ffmpeg.org; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=rZclHIL0ycIIdaLb7Ee8nul1gRxPCn2FDW7GytpH1Ec=; b=wCus/PE/FV0yJIcZyP8aJerOFV6galGeob7HI6WJ3loNEtkbBneUBZs+1iTDEfU+Qe wH4O8FRuMPJXzLDqSEXBPxQpLMudrpPR5g1+CJUQmUb7bQ25lbRZhLz1gIes9LZRpC8L cBIfkYloLwDTrln7WPq0D8C7fJzKpoMHDn9xmieBPLJStvjqyZzLX19DCICmG8cUaFY7 tNVfj9YyXz35xGwVHJ5TsBY/6YgjDfXJNaR2S7N27MeiDEf1Oai6q17MGTZVkXZMzpxf RcyoM5not1uLCi3LNtowZdR3CqX4D6gmNcTv/A8BihUws7NNylQm2EPAunY7hBYnmADz IaWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719230117; x=1719834917; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rZclHIL0ycIIdaLb7Ee8nul1gRxPCn2FDW7GytpH1Ec=; b=uY7gO9Qp12NyEoWrj1NzSJFRNqxpiR/esExT9Ht+GMO3Sg/k/gu+1bYjTpWP5+u4vr 0H7Kk16xOCDxa2SpNg5v7Z6cOmVJBbf+D5wmqIcOqbRpRm6AXxVUhUtGZc4bJ0io8E29 SMhy9lzbr38/PNvH76CD+32+pg96A527VC6dUOATOk0V9XUpkwLc3ZnBlABvERCjRkH4 GrfxeUYZyslnnVJRqRu8xnw6m2zPixHBNDbrQ4rZPdrIqaYFHDM9ppd7i2WnDSlSgIhd DfR4qAdmBLyTwuEJz9lWe3snT2NJYM4lO1LYTCypPHepm0T59WdloNwSc8doWrtZumKM GxEw== X-Gm-Message-State: AOJu0YxHoCdd551tyHLscTL6VRn+TOCg4/SXBR4r1qC/7S9h1+pVYfW+ 5FNe0uWFi4oEDLzI+uCkSlepuxucfGcxZSuk0ixOz54KxbZNnK44ptvA9eAbrRIRIfsiMjHt5j9 duA== X-Google-Smtp-Source: AGHT+IEyDCmPaT9oBOoKa8XCvIfrLDak1NC0psOKJLzRkryRwnzVtA0Mf9TUDagouzsFL2sGhyFdNw== X-Received: by 2002:a2e:3814:0:b0:2ec:5469:9d4e with SMTP id 38308e7fff4ca-2ec594d00a9mr29888131fa.38.1719230116579; Mon, 24 Jun 2024 04:55:16 -0700 (PDT) Received: from tunnel335574-pt.tunnel.tserv24.sto1.ipv6.he.net (tunnel335574-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:11::2]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ec525bf38esm7680141fa.19.2024.06.24.04.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 04:55:16 -0700 (PDT) Date: Mon, 24 Jun 2024 14:55:15 +0300 (EEST) From: =?ISO-8859-15?Q?Martin_Storsj=F6?= To: FFmpeg development discussions and patches In-Reply-To: Message-ID: References: <20240624113701.94616-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v3 2/3] swscale/aarch64: Add bgra/rgba to yuv X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Zhao Zhili Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Mon, 24 Jun 2024, Zhao Zhili wrote: > From: Zhao Zhili > > Test on Apple M1 with kperf > : -O3 : -O3 -fno-vectorize > bgra_to_uv_8_c : 13.4 : 27.5 > bgra_to_uv_8_neon : 37.4 : 41.7 > bgra_to_uv_128_c : 155.9 : 550.2 > bgra_to_uv_128_neon : 91.7 : 92.7 > bgra_to_uv_1080_c : 1173.2 : 4558.2 > bgra_to_uv_1080_neon : 822.7 : 809.5 > bgra_to_uv_1920_c : 2078.2 : 8115.2 > bgra_to_uv_1920_neon : 1437.7 : 1438.7 > bgra_to_uv_half_8_c : 17.9 : 14.2 > bgra_to_uv_half_8_neon : 37.4 : 10.5 > bgra_to_uv_half_128_c : 103.9 : 326.0 > bgra_to_uv_half_128_neon : 73.9 : 68.7 > bgra_to_uv_half_1080_c : 850.2 : 3732.0 > bgra_to_uv_half_1080_neon : 484.2 : 490.0 > bgra_to_uv_half_1920_c : 1479.2 : 4942.7 > bgra_to_uv_half_1920_neon : 824.2 : 824.7 > bgra_to_y_8_c : 8.2 : 29.5 > bgra_to_y_8_neon : 18.2 : 32.7 > bgra_to_y_128_c : 101.4 : 361.5 > bgra_to_y_128_neon : 74.9 : 73.7 > bgra_to_y_1080_c : 739.4 : 3018.0 > bgra_to_y_1080_neon : 613.4 : 544.2 > bgra_to_y_1920_c : 1298.7 : 5326.0 > bgra_to_y_1920_neon : 918.7 : 934.2 > --- > libswscale/aarch64/input.S | 91 ++++++++++++++++++++++++++++++------ > libswscale/aarch64/swscale.c | 16 +++++++ > 2 files changed, 94 insertions(+), 13 deletions(-) > > diff --git a/libswscale/aarch64/input.S b/libswscale/aarch64/input.S > index 2cfec4cb6a..6d2c6034bb 100644 > --- a/libswscale/aarch64/input.S > +++ b/libswscale/aarch64/input.S > @@ -20,8 +20,12 @@ > > #include "libavutil/aarch64/asm.S" > > -.macro rgb_to_yuv_load_rgb src > +.macro rgb_to_yuv_load_rgb src, element=3 > + .if \element == 3 > ld3 { v16.16b, v17.16b, v18.16b }, [\src] > + .else > + ld4 { v16.16b, v17.16b, v18.16b, v19.16b }, [\src] > + .endif > uxtl v19.8h, v16.8b // v19: r > uxtl v20.8h, v17.8b // v20: g > uxtl v21.8h, v18.8b // v21: b > @@ -51,7 +55,8 @@ function ff_bgr24ToY_neon, export=1 > ret > endfunc > > -function ff_rgb24ToY_neon, export=1 > +.macro rgbToY_neon fmt, element > +function ff_\fmt\()ToY_neon, export=1 > cmp w4, #0 // check width > 0 > ldp w10, w11, [x5] // w10: ry, w11: gy > ldr w12, [x5, #8] // w12: by > @@ -67,11 +72,11 @@ function ff_rgb24ToY_neon, export=1 > dup v2.8h, w12 > b.lt 2f > 1: > - rgb_to_yuv_load_rgb x1 > + rgb_to_yuv_load_rgb x1, \element > 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 > - add x1, x1, #48 // src += 48 > + add x1, x1, #(16*\element) > cmp w4, #16 // width >= 16 ? > stp q16, q17, [x0], #32 // store to dst > b.ge 1b > @@ -86,12 +91,25 @@ function ff_rgb24ToY_neon, export=1 > smaddl x13, w15, w12, x13 // x13 += by * b > asr w13, w13, #9 // x13 >>= 9 > sub w4, w4, #1 // width-- > - add x1, x1, #3 // src += 3 > + add x1, x1, #\element > strh w13, [x0], #2 // store to dst > cbnz w4, 2b > 3: > ret > endfunc > +.endm > + > +rgbToY_neon fmt=rgb24, element=3 > + > +function ff_bgra32ToY_neon, export=1 > + cmp w4, #0 // check width > 0 > + ldp w12, w11, [x5] // w12: ry, w11: gy > + ldr w10, [x5, #8] // w10: by > + b.gt 4f > + ret > +endfunc > + > +rgbToY_neon fmt=rgba32, element=4 It is extremely obscure to jump to a local label (4f) that is defined by the following macro. I think this would be much more readable if you'd include the bgr(a) version in the macro, so the reference to 4f is near to the actual label it refers to. > .macro rgb_set_uv_coeff half > .if \half > @@ -120,7 +138,8 @@ function ff_bgr24ToUV_half_neon, export=1 > b 4f > endfunc > > -function ff_rgb24ToUV_half_neon, export=1 > +.macro rgbToUV_half_neon fmt, element > +function ff_\fmt\()ToUV_half_neon, export=1 > cmp w5, #0 // check width > 0 > b.le 3f > > @@ -132,7 +151,11 @@ function ff_rgb24ToUV_half_neon, export=1 > rgb_set_uv_coeff half=1 > b.lt 2f > 1: > + .if \element == 3 > ld3 { v16.16b, v17.16b, v18.16b }, [x3] > + .else > + ld4 { v16.16b, v17.16b, v18.16b, v19.16b }, [x3] > + .endif > uaddlp v19.8h, v16.16b // v19: r > uaddlp v20.8h, v17.16b // v20: g > uaddlp v21.8h, v18.16b // v21: b > @@ -140,7 +163,7 @@ function ff_rgb24ToUV_half_neon, export=1 > rgb_to_yuv_product v19, v20, v21, v22, v23, v16, v0, v1, v2, #10 > rgb_to_yuv_product v19, v20, v21, v24, v25, v17, v3, v4, v5, #10 > sub w5, w5, #8 // width -= 8 > - add x3, x3, #48 // src += 48 > + add x3, x3, #(16*\element) > cmp w5, #8 // width >= 8 ? > str q16, [x0], #16 // store dst_u > str q17, [x1], #16 // store dst_v > @@ -148,9 +171,10 @@ function ff_rgb24ToUV_half_neon, export=1 > cbz w5, 3f > 2: > ldrb w2, [x3] // w2: r1 > - ldrb w4, [x3, #3] // w4: r2 > + ldrb w4, [x3, #\element] // w4: r2 > add w2, w2, w4 // w2 = r1 + r2 > > + .if \element == 3 > ldrb w4, [x3, #1] // w4: g1 > ldrb w7, [x3, #4] // w7: g2 > add w4, w4, w7 // w4 = g1 + g2 > @@ -158,6 +182,15 @@ function ff_rgb24ToUV_half_neon, export=1 > ldrb w7, [x3, #2] // w7: b1 > ldrb w8, [x3, #5] // w8: b2 > add w7, w7, w8 // w7 = b1 + b2 > + .else > + ldrb w4, [x3, #1] // w4: g1 > + ldrb w7, [x3, #5] // w7: g2 > + add w4, w4, w7 // w4 = g1 + g2 > + > + ldrb w7, [x3, #2] // w7: b1 > + ldrb w8, [x3, #6] // w8: b2 > + add w7, w7, w8 // w7 = b1 + b2 > + .endif > > smaddl x8, w2, w10, x9 // dst_u = ru * r + const_offset > smaddl x8, w4, w11, x8 // dst_u += gu * g > @@ -170,12 +203,28 @@ function ff_rgb24ToUV_half_neon, export=1 > smaddl x8, w7, w15, x8 // dst_v += bv * b > asr x8, x8, #10 // dst_v >>= 10 > sub w5, w5, #1 > - add x3, x3, #6 // src += 6 > + ldrb w4, [x3, #1] // w4: g1 > + add x3, x3, #(2*\element) Is the new ldrb a typo/copypaste mistake here? // 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".