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 4B653403D5 for ; Thu, 23 Jun 2022 11:45:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 85C0768B61E; Thu, 23 Jun 2022 14:45:03 +0300 (EEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A4B9668B5F7 for ; Thu, 23 Jun 2022 14:44:57 +0300 (EEST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id E01E95C005F for ; Thu, 23 Jun 2022 07:44:55 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 23 Jun 2022 07:44:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=itanimul.li; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1655984695; x= 1656071095; bh=G4GZtWR4syjzvXgmr4RPK7XNP5nrJcdJReTt1yYE9Wg=; b=B v70h7gJyuLXlp1gctHiRdqO0SUNhVsGcYInWJcN0nEyDLysR2AUuG/h9j27plQcT P7Y4wMR5Z3L2Ov1ye8K3uw2doJsT3/GHYrxyWgqEDdXHPpLoKUpY0J5N3Y87xGFX aadVpl356he7PdhibcDEmC5ZXjyiS6kc+t3q1UESIExVetP51ReLR9ejRpJGy0GT BeneLujCu1HUAuZhOx/4oXsG+YrMCWLrgimfvUzgOE32pqhwulCcYtjTE3aAuAC0 5b+UsJASB9wSUL/AezMkcI23MA4kp2bT9Peib2aimQoMgxmdSlXh5RXyl4VT5y7t krhoWhw8TfFZV05OEhTpA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1655984695; x=1656071095; bh=G 4GZtWR4syjzvXgmr4RPK7XNP5nrJcdJReTt1yYE9Wg=; b=j4QwxWjX6Nllo0yOx OD0BHhMNVPtIsnHA5y716bj1TkSsAQ+136O++j1xST/Cqkq7cKmZdwfNCZQxD874 vumSIjaRTUtRrAjG9cyhEGeyVgQvRcJ/E3r6LKKDpVN3d5BhlKQCbgTulgOHQDw3 gkkV2pZ7+M747hICC+eQq1tJJ5EJbtG1Dbnsm6LSt8bWdKZOsl0ujdhVXXSycyi9 75CouufU9ZL5Z9Bdj/beeniCzy/abDVZs/ztHExgpW+0AxnwGBQPaQ8thkgrEXWO SyoiqshWQMjFAmvYPGI/qx5omtNA0kE/V/6VN70jfMsiSx4WHMHh8MjwSvhEOizm PyqMg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudefjedggeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffokfgjfhggtgfgsehtqh hmtdertddtnecuhfhrohhmpedflfdrucffvghkkhgvrhdfuceojhguvghksehithgrnhhi mhhulhdrlhhiqeenucggtffrrghtthgvrhhnpeduueefhfekvdefheevgeeftdekleelgf ejleeiveeuieeutdehueevleegudeuteenucffohhmrghinhepnhgvohhnrdhssgenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjuggvkhesih htrghnihhmuhhlrdhlih X-ME-Proxy: Feedback-ID: i84994747:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Thu, 23 Jun 2022 07:44:54 -0400 (EDT) From: "J. Dekker" To: ffmpeg-devel@ffmpeg.org Date: Thu, 23 Jun 2022 13:44:53 +0200 X-Mailer: MailMate Trial (1.14r5852) Message-ID: <62682B71-C36F-4775-BE4D-17F29F2A986F@itanimul.li> In-Reply-To: <20220623105247.19580-1-jdek@itanimul.li> References: <20220623105247.19580-1-jdek@itanimul.li> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH] lavc/aarch64: add hevc chroma loop filter 8-12bit 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 23 Jun 2022, at 12:52, J. Dekker wrote: > Signed-off-by: J. Dekker > --- > libavcodec/aarch64/Makefile | 3 +- > libavcodec/aarch64/hevcdsp_deblock_neon.S | 168 ++++++++++++++++++++++ > libavcodec/aarch64/hevcdsp_init_aarch64.c | 14 ++ > 3 files changed, 184 insertions(+), 1 deletion(-) > create mode 100644 libavcodec/aarch64/hevcdsp_deblock_neon.S > > Passes FATE, I never completed the checkasm for loop_filter, working on > that currently alongside the luma loop filter. This asm can also go > into hevcdsp_sao_neon.S if you would prefer not creating an extra file > for it. > > diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile > index c8935f205e..66bd8b596c 100644 > --- a/libavcodec/aarch64/Makefile > +++ b/libavcodec/aarch64/Makefile > @@ -63,6 +63,7 @@ NEON-OBJS-$(CONFIG_VP9_DECODER) += aarch64/vp9itxfm_16bpp_neon.o \ > aarch64/vp9lpf_neon.o \ > aarch64/vp9mc_16bpp_neon.o \ > aarch64/vp9mc_neon.o > -NEON-OBJS-$(CONFIG_HEVC_DECODER) += aarch64/hevcdsp_idct_neon.o \ > +NEON-OBJS-$(CONFIG_HEVC_DECODER) += aarch64/hevcdsp_deblock_neon.o \ > + aarch64/hevcdsp_idct_neon.o \ > aarch64/hevcdsp_init_aarch64.o \ > aarch64/hevcdsp_sao_neon.o > diff --git a/libavcodec/aarch64/hevcdsp_deblock_neon.S b/libavcodec/aarch64/hevcdsp_deblock_neon.S > new file mode 100644 > index 0000000000..d21ad0a54f > --- /dev/null > +++ b/libavcodec/aarch64/hevcdsp_deblock_neon.S > @@ -0,0 +1,168 @@ > +/* -*-arm64-*- > + * vim: syntax=arm64asm > + * > + * Copyright (c) 2014 Seppo Tomperi > + * Copyright (c) 2022 J. Dekker > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > + > +#include "libavutil/aarch64/asm.S" > +#include "neon.S" > + > +.macro hevc_loop_filter_chroma_start bitdepth > + ldr w14, [x2] > + ldr w15, [x2, #4] > +.if \bitdepth > 8 > + lsl w14, w14, #(\bitdepth - 8) > + lsl w15, w15, #(\bitdepth - 8) > +.endif > + adds w2, w14, w15 > + b.eq 1f > + dup v16.4h, w14 > + dup v17.4h, w15 > + trn1 v16.2d, v16.2d, v17.2d > +.if \bitdepth == 10 > + mvni v19.8h, #0xFC, lsl #8 // movi #0x03FF > +.endif > +.if \bitdepth == 12 > + mvni v19.8h, #0xF0, lsl #8 // movi #0x0FFF > +.endif > +.if \bitdepth > 8 > + movi v18.8h, #0 > +.endif > + neg v17.8h, v16.8h > +.endm > + > +.macro hevc_loop_filter_chroma_body bitdepth > +.if \bitdepth <= 8 > + uxtl v0.8h, v0.8b // p1 > + uxtl v1.8h, v1.8b // p0 > + uxtl v2.8h, v2.8b // q0 > + uxtl v3.8h, v3.8b // q1 > +.endif > + sub v5.8h, v2.8h, v1.8h // q0 - p0 > + sub v6.8h, v0.8h, v3.8h // p1 - q1 > + shl v5.8h, v5.8h, #2 > + add v5.8h, v6.8h, v5.8h > + srshr v5.8h, v5.8h, #3 > + smin v5.8h, v5.8h, v16.8h > + smax v5.8h, v5.8h, v17.8h > + sqadd v1.8h, v1.8h, v5.8h // p0 + delta > + sqsub v2.8h, v2.8h, v5.8h // q0 - delta > +.if \bitdepth <= 8 > + sqxtun v1.8b, v1.8h > + sqxtun v2.8b, v2.8h > +.else > + smin v1.8h, v1.8h, v19.8h > + smin v2.8h, v2.8h, v19.8h > + smax v1.8h, v1.8h, v18.8h > + smax v2.8h, v2.8h, v18.8h > +.endif > +.endm > + > +.macro hevc_h_loop_filter_chroma bitdepth > +function ff_hevc_h_loop_filter_chroma_\bitdepth\()_neon, export=1 > + hevc_loop_filter_chroma_start \bitdepth > + sub x0, x0, x1, lsl #1 > +.if \bitdepth > 8 > + ld1 {v0.8h}, [x0], x1 > + ld1 {v1.8h}, [x0], x1 > + ld1 {v2.8h}, [x0], x1 > + ld1 {v3.8h}, [x0] > +.else > + ld1 {v0.8b}, [x0], x1 > + ld1 {v1.8b}, [x0], x1 > + ld1 {v2.8b}, [x0], x1 > + ld1 {v3.8h}, [x0] > +.endif > + hevc_loop_filter_chroma_body \bitdepth > + sub x0, x0, x1, lsl #1 > +.if \bitdepth > 8 > + st1 {v1.8h}, [x0], x1 > + st1 {v2.8h}, [x0] > +.else > + st1 {v1.8b}, [x0], x1 > + st1 {v2.8b}, [x0] > +.endif > +1: ret > +endfunc > +.endm > + > +.macro hevc_v_loop_filter_chroma bitdepth > +function ff_hevc_v_loop_filter_chroma_\bitdepth\()_neon, export=1 > + hevc_loop_filter_chroma_start \bitdepth > +.if \bitdepth > 8 > + sub x0, x0, #8 > + ld1 {v20.8h}, [x0], x1 > + ld1 {v21.8h}, [x0], x1 > + ld1 {v0.8h}, [x0], x1 > + ld1 {v1.8h}, [x0], x1 > + ld1 {v2.8h}, [x0], x1 > + ld1 {v3.8h}, [x0], x1 > + ld1 {v22.8h}, [x0], x1 > + ld1 {v23.8h}, [x0], x1 > + transpose_8x8H v20, v21, v0, v1, v2, v3, v22, v23, v24, v25 > +.else > + sub x0, x0, #4 > + ld1 {v20.8b}, [x0], x1 > + ld1 {v21.8b}, [x0], x1 > + ld1 {v0.8b}, [x0], x1 > + ld1 {v1.8b}, [x0], x1 > + ld1 {v2.8b}, [x0], x1 > + ld1 {v3.8b}, [x0], x1 > + ld1 {v22.8b}, [x0], x1 > + ld1 {v23.8b}, [x0], x1 > + transpose_8x8B v20, v21, v0, v1, v2, v3, v22, v23, v24, v25 > +.endif > + hevc_loop_filter_chroma_body \bitdepth > + sub x0, x0, x1, lsl #3 > +.if \bitdepth > 8 > + transpose_8x8H v20, v21, v0, v1, v2, v3, v22, v23, v24, v25 > + st1 {v20.8h}, [x0], x1 > + st1 {v21.8h}, [x0], x1 > + st1 {v0.8h}, [x0], x1 > + st1 {v1.8h}, [x0], x1 > + st1 {v2.8h}, [x0], x1 > + st1 {v3.8h}, [x0], x1 > + st1 {v22.8h}, [x0], x1 > + st1 {v23.8h}, [x0] > +.else > + xtn v0.8b, v0.8h // restore > + xtn v3.8b, v3.8h > + transpose_8x8B v20, v21, v0, v1, v2, v3, v22, v23, v24, v25 > + st1 {v20.8b}, [x0], x1 > + st1 {v21.8b}, [x0], x1 > + st1 {v0.8b}, [x0], x1 > + st1 {v1.8b}, [x0], x1 > + st1 {v2.8b}, [x0], x1 > + st1 {v3.8b}, [x0], x1 > + st1 {v22.8b}, [x0], x1 > + st1 {v23.8b}, [x0] > +.endif > +1: ret > +endfunc > +.endm > + > +hevc_h_loop_filter_chroma 8 > +hevc_h_loop_filter_chroma 10 > +hevc_h_loop_filter_chroma 12 > + > +hevc_v_loop_filter_chroma 8 > +hevc_v_loop_filter_chroma 10 > +hevc_v_loop_filter_chroma 12 > diff --git a/libavcodec/aarch64/hevcdsp_init_aarch64.c b/libavcodec/aarch64/hevcdsp_init_aarch64.c > index 2002530266..3502edb77a 100644 > --- a/libavcodec/aarch64/hevcdsp_init_aarch64.c > +++ b/libavcodec/aarch64/hevcdsp_init_aarch64.c > @@ -25,6 +25,12 @@ > #include "libavutil/aarch64/cpu.h" > #include "libavcodec/hevcdsp.h" > > +void ff_hevc_v_loop_filter_chroma_8_neon(uint8_t *_pix, ptrdiff_t _stride, int *_tc, uint8_t *_no_p, uint8_t *_no_q); > +void ff_hevc_v_loop_filter_chroma_10_neon(uint8_t *_pix, ptrdiff_t _stride, int *_tc, uint8_t *_no_p, uint8_t *_no_q); > +void ff_hevc_v_loop_filter_chroma_12_neon(uint8_t *_pix, ptrdiff_t _stride, int *_tc, uint8_t *_no_p, uint8_t *_no_q); > +void ff_hevc_h_loop_filter_chroma_8_neon(uint8_t *_pix, ptrdiff_t _stride, int *_tc, uint8_t *_no_p, uint8_t *_no_q); > +void ff_hevc_h_loop_filter_chroma_10_neon(uint8_t *_pix, ptrdiff_t _stride, int *_tc, uint8_t *_no_p, uint8_t *_no_q); > +void ff_hevc_h_loop_filter_chroma_12_neon(uint8_t *_pix, ptrdiff_t _stride, int *_tc, uint8_t *_no_p, uint8_t *_no_q); > void ff_hevc_add_residual_4x4_8_neon(uint8_t *_dst, int16_t *coeffs, > ptrdiff_t stride); > void ff_hevc_add_residual_4x4_10_neon(uint8_t *_dst, int16_t *coeffs, > @@ -67,6 +73,8 @@ av_cold void ff_hevc_dsp_init_aarch64(HEVCDSPContext *c, const int bit_depth) > if (!have_neon(av_get_cpu_flags())) return; > > if (bit_depth == 8) { > + c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_8_neon; > + c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_8_neon; > c->add_residual[0] = ff_hevc_add_residual_4x4_8_neon; > c->add_residual[1] = ff_hevc_add_residual_8x8_8_neon; > c->add_residual[2] = ff_hevc_add_residual_16x16_8_neon; > @@ -89,6 +97,8 @@ av_cold void ff_hevc_dsp_init_aarch64(HEVCDSPContext *c, const int bit_depth) > c->sao_edge_filter[4] = ff_hevc_sao_edge_filter_16x16_8_neon; > } > if (bit_depth == 10) { > + c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_10_neon; > + c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_10_neon; > c->add_residual[0] = ff_hevc_add_residual_4x4_10_neon; > c->add_residual[1] = ff_hevc_add_residual_8x8_10_neon; > c->add_residual[2] = ff_hevc_add_residual_16x16_10_neon; > @@ -100,4 +110,8 @@ av_cold void ff_hevc_dsp_init_aarch64(HEVCDSPContext *c, const int bit_depth) > c->idct_dc[2] = ff_hevc_idct_16x16_dc_10_neon; > c->idct_dc[3] = ff_hevc_idct_32x32_dc_10_neon; > } > + if (bit_depth == 12) { > + c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_12_neon; > + c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_12_neon; > + } > } Self-review for this patch since I just thought of some things I could change: Stores/loads can be interleaved in both filters and for the vertical filter maybe I don't need to write the full 8b/8h. Other than that maybe some slightly scheduling improvements? -- J. Dekker _______________________________________________ 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".