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 849CB48DE9 for ; Tue, 27 Feb 2024 21:57:08 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 568CB68CAEE; Tue, 27 Feb 2024 23:57:06 +0200 (EET) Received: from mail8.parnet.fi (mail8.parnet.fi [77.234.108.134]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7CF1168C7EA for ; Tue, 27 Feb 2024 23:57:00 +0200 (EET) Received: from mail9.parnet.fi (mail9.parnet.fi [77.234.108.21]) by mail8.parnet.fi with ESMTP id 41RLuxp2018791-41RLuxp3018791 for ; Tue, 27 Feb 2024 23:56:59 +0200 Received: from cone.home.martin.st (host-97-144.parnet.fi [77.234.97.144]) by mail9.parnet.fi (Postfix) with ESMTPS id 4A7D8A14A7 for ; Tue, 27 Feb 2024 23:56:59 +0200 (EET) Date: Tue, 27 Feb 2024 23:56:57 +0200 (EET) From: =?ISO-8859-15?Q?Martin_Storsj=F6?= To: FFmpeg development discussions and patches In-Reply-To: <20240227113309.405627-1-jdek@itanimul.li> Message-ID: References: <20240227113309.405627-1-jdek@itanimul.li> MIME-Version: 1.0 X-FE-Policy-ID: 3:14:2:SYSTEM Subject: Re: [FFmpeg-devel] [PATCH v4] avcodec/aarch64/hevc: add luma deblock NEON 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 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 Tue, 27 Feb 2024, J. Dekker wrote: > Benched using single-threaded full decode on an Ampere Altra. > > Bpp Before After Speedup > 8 73,3s 65,2s 1.124x > 10 114,2s 104,0s 1.098x > 12 125,8s 115,7s 1.087x > > Signed-off-by: J. Dekker > --- > > Slightly improved 12bit version. > > libavcodec/aarch64/hevcdsp_deblock_neon.S | 417 ++++++++++++++++++++++ > libavcodec/aarch64/hevcdsp_init_aarch64.c | 18 + > 2 files changed, 435 insertions(+) > > diff --git a/libavcodec/aarch64/hevcdsp_deblock_neon.S b/libavcodec/aarch64/hevcdsp_deblock_neon.S > index 8227f65649..581056a91e 100644 > --- a/libavcodec/aarch64/hevcdsp_deblock_neon.S > +++ b/libavcodec/aarch64/hevcdsp_deblock_neon.S > @@ -181,3 +181,420 @@ hevc_h_loop_filter_chroma 12 > hevc_v_loop_filter_chroma 8 > hevc_v_loop_filter_chroma 10 > hevc_v_loop_filter_chroma 12 > + > +.macro hevc_loop_filter_luma_body bitdepth > +function hevc_loop_filter_luma_body_\bitdepth\()_neon, export=0 > +.if \bitdepth > 8 > + lsl w2, w2, #(\bitdepth - 8) // beta <<= BIT_DEPTH - 8 > +.else > + uxtl v0.8h, v0.8b > + uxtl v1.8h, v1.8b > + uxtl v2.8h, v2.8b > + uxtl v3.8h, v3.8b > + uxtl v4.8h, v4.8b > + uxtl v5.8h, v5.8b > + uxtl v6.8h, v6.8b > + uxtl v7.8h, v7.8b > +.endif > + ldr w7, [x3] // tc[0] > + ldr w8, [x3, #4] // tc[1] > + dup v18.4h, w7 > + dup v19.4h, w8 > + trn1 v18.2d, v18.2d, v19.2d > +.if \bitdepth > 8 > + shl v18.8h, v18.8h, #(\bitdepth - 8) > +.endif > + dup v27.8h, w2 // beta > + // tc25 > + shl v19.8h, v18.8h, #2 // * 4 > + add v19.8h, v19.8h, v18.8h // (tc * 5) > + srshr v19.8h, v19.8h, #1 // (tc * 5 + 1) >> 1 > + sshr v17.8h, v27.8h, #2 // beta2 > + > + ////// beta_2 check > + // dp0 = abs(P2 - 2 * P1 + P0) > + add v22.8h, v3.8h, v1.8h > + shl v23.8h, v2.8h, #1 > + sabd v30.8h, v22.8h, v23.8h > + // dq0 = abs(Q2 - 2 * Q1 + Q0) > + add v21.8h, v6.8h, v4.8h > + shl v26.8h, v5.8h, #1 > + sabd v31.8h, v21.8h, v26.8h > + // d0 = dp0 + dq0 > + add v20.8h, v30.8h, v31.8h > + shl v25.8h, v20.8h, #1 > + // (d0 << 1) < beta_2 > + cmgt v23.8h, v17.8h, v25.8h > + > + ////// beta check > + // d0 + d3 < beta > + mov x9, #0xFFFF00000000FFFF > + dup v24.2d, x9 > + and v25.16b, v24.16b, v20.16b > + addp v25.8h, v25.8h, v25.8h // 1+0 0+1 1+0 0+1 > + addp v25.4h, v25.4h, v25.4h // 1+0+0+1 1+0+0+1 > + cmgt v25.4h, v27.4h, v25.4h // lower/upper mask in h[0/1] > + mov w9, v25.s[0] I don't quite understand what this sequence does and/or how our data is laid out in our registers - we have d0 on input in v20, where's d3? An doesn't the "and" throw away half of the input elements here? I see some similar patterns with the masking and handling below as well - I get a feeling that I don't quite understand the algorithm here, and/or the data layout. > +.if \bitdepth > 8 > + ld1 {v0.8h}, [x0], x1 > + ld1 {v1.8h}, [x0], x1 > + ld1 {v2.8h}, [x0], x1 > + ld1 {v3.8h}, [x0], x1 > + ld1 {v4.8h}, [x0], x1 > + ld1 {v5.8h}, [x0], x1 > + ld1 {v6.8h}, [x0], x1 > + ld1 {v7.8h}, [x0] > + mov w14, #((1 << \bitdepth) - 1) For loads like these, we can generally save a bit by using two alternating registers for loading, with a double stride - see e.g. the vp9 loop filter implementations. But that's a micro optimization. Other than that, this mostly looks reasaonble. // 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".