From patchwork Tue Mar 21 18:35:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J. Dekker" X-Patchwork-Id: 40774 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:d046:b0:cd:afd7:272c with SMTP id hv6csp2817977pzb; Tue, 21 Mar 2023 11:36:16 -0700 (PDT) X-Google-Smtp-Source: AK7set9m/to6QbhN2Wenpm6HTIoF4IaNBcnvf8zUa7g7+TFHkijRVLLUVY5f8T7P/TPiZlIEXP3o X-Received: by 2002:a17:907:9895:b0:921:5e7b:1c27 with SMTP id ja21-20020a170907989500b009215e7b1c27mr4251460ejc.24.1679423776611; Tue, 21 Mar 2023 11:36:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679423776; cv=none; d=google.com; s=arc-20160816; b=Q2B2K3/2VFQZFbk+kBzscmcUAeAXuJGSdfL6eFwrbdn2glO/u9N45I3Gts1QszYnZY ek0sVm71v9UKPXPQyHr11N19r6xht1lHWDyQ8IwXSwNRiWKv5Y/8igV401SpEFXw8HuN spdiKKHdQDZRTpmSBgyRoOejWRSGxn3zFVCic9Jx1O9kuleHh488oozAAGPOWv0kvQv7 5h03MWhByJlasWZG5ceFhXiaGSi766/MJvhM6XYId/lYCVxB6AtQCg9zrm228GWcI1L1 NrwW00RQnLivy086Oc5niXJxa9xfu/JrnhX5DrHqOEstRlCW6fsnpNCNloy4c1xbxpLk gQGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:feedback-id:dkim-signature:dkim-signature:delivered-to; bh=6cCsqgbzFwoMd8dKObW9Gv3pnvupCPLXhpDnQUSK/5M=; b=V8o6ABY3Mz96OJuEV+T5LhNCQZNqv27pucYFUWlUkrHPhKDW7rQ429Lxh0414HSP9Z w39t4OaC2ZSOlEGKNDuIsBxcTj0obA3/JcGmRxkUunnpOsovOK/ggvH7koOApRCXp7dy QuBIEX5WZjllbMflyX38hoRdMvXKycIGD31Z+ETAAddQPWjlugCLtT+bjeQrEMnYgQgQ 6QQy94nV68WEgyZxNrTtekw2oz703gIuZV7jxl9yK6OpHPQeFrnSqpTtOpi5grse8Ic3 DDMUO4xP0oBStKVT8OMIwYaHGQZlNAXe0AJRrhvhxRj0eHTyELUV+OL+gcmH9lHjM2c4 1Rag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@itanimul.li header.s=fm3 header.b=cJetZ6Sz; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm2 header.b=Dnb1ttE8; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id xd12-20020a170907078c00b0093239cf2704si13865845ejb.213.2023.03.21.11.36.15; Tue, 21 Mar 2023 11:36:16 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@itanimul.li header.s=fm3 header.b=cJetZ6Sz; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm2 header.b=Dnb1ttE8; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 66FAF68C533; Tue, 21 Mar 2023 20:36:03 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D77C668C1BA for ; Tue, 21 Mar 2023 20:35:55 +0200 (EET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 7E9FB5C004D for ; Tue, 21 Mar 2023 14:35:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 21 Mar 2023 14:35:53 -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=1679423753; x= 1679510153; bh=hncDtLc7EunHfGaNYwrVlCFgKSz5WQ8hnrYVsZwDbj8=; b=c JetZ6SzFAE2i1CsYDW1VG30YNS1oVp3Bd6KGArTKMTPvS0Y9VcMeaN/GjjzQCF/n uQ3Xv4Vn88guH4yqLGKduF0eJIw4R9wxwQr4R9xRUcjYrMlN3U6pgw6P37OWi+yx xWLhxTvHMXdNOEe6IDwtWIcKfGu8ImmohQ7KZwHnNON1jb5TPT46luZN8h2zUopE 9gKuSRQI/ruH3zQWt0R11N3A2RXvdi0MTuCKtc4GExiPz6uHhk0G7B7fIOxvkIfR 4bqqCHAwDeFkf3GGs33qjg2VwFz3iIpVO6GH2T81Tku+udfUXBUKEm2c8Dqvgaav Mi6GApKUH6YOxjqgdpe3A== 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=1679423753; x=1679510153; bh=h ncDtLc7EunHfGaNYwrVlCFgKSz5WQ8hnrYVsZwDbj8=; b=Dnb1ttE8I9NtxbjUf OEqcL2ortP7bCeudvneeBMNYwrOrYNe5EoxRDqI2pXvm/1/DgHq9I5gnA3rNUOJq 6pHDEd10uYzKccVqpI4ko1rQHysmBR8eFfcdpu/2yQD7KrbhJKtBMat31hLV4iH9 CpyYfJ7AHi8ac4Ooy6HY+mg/D484da7Z1GW6VqU3isD4GCrSFf/hk0Q8xBH36ZMO JES0QLshmepBRKpVO/OuBFOk4MR4xlar1Lyf6WbApz+FQ5n4Adux6nDfLZp7Gx4A /vMciBbErA8KKF925pwtGw6UIWJ8ThOT+FEC7iweJXdQW9+UqMjSuM1s1A9b5QEe IyUVw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdegtddguddufecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedflfdrucffvghkkhgvrhdfuceojhguvghksehithgrnhhi mhhulhdrlhhiqeenucggtffrrghtthgvrhhnpefhvdefjeffgefffeeifeevgfehuedule ehhfffvedttdfhheduiedtteefheeiteenucffohhmrghinhepnhgvohhnrdhssgenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjuggvkhesih htrghnihhmuhhlrdhlih X-ME-Proxy: Feedback-ID: i84994747:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 21 Mar 2023 14:35:52 -0400 (EDT) From: "J. Dekker" To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 Mar 2023 19:35:48 +0100 Message-Id: <20230321183548.81720-2-jdek@itanimul.li> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20230321183548.81720-1-jdek@itanimul.li> References: <20230321183548.81720-1-jdek@itanimul.li> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/2] lavc/aarch64: add hevc deblock chroma 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ghkZwe9hCIVa Signed-off-by: J. Dekker --- Implements comments from Martin, split body into its own function, interleaved stores, however `.elif' is not valid on macOS so left that out. libavcodec/aarch64/Makefile | 3 +- libavcodec/aarch64/hevcdsp_deblock_neon.S | 187 ++++++++++++++++++++++ libavcodec/aarch64/hevcdsp_init_aarch64.c | 18 +++ 3 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 libavcodec/aarch64/hevcdsp_deblock_neon.S diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile index 02fb51c3ab..216191640c 100644 --- a/libavcodec/aarch64/Makefile +++ b/libavcodec/aarch64/Makefile @@ -65,7 +65,8 @@ 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_qpel_neon.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..0f0e829fb5 --- /dev/null +++ b/libavcodec/aarch64/hevcdsp_deblock_neon.S @@ -0,0 +1,187 @@ +/* -*-arm64-*- + * vim: syntax=arm64asm + * + * Copyright (c) 2014 Seppo Tomperi + * Copyright (c) 2023 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 + mov x4, x30 + 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 + +function hevc_loop_filter_chroma_body_8_neon, export=0 + hevc_loop_filter_chroma_body 8 + ret +endfunc + +function hevc_loop_filter_chroma_body_10_neon, export=0 +hevc_loop_filter_chroma_body_12_neon: + hevc_loop_filter_chroma_body 10 + ret +endfunc + +// 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); + +.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.8b}, [x0] +.endif + sub x0, x0, x1, lsl #1 + bl hevc_loop_filter_chroma_body_\bitdepth\()_neon +.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 x4 +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 + add x3, x0, x1 + lsl x1, x1, #1 + ld1 {v20.8h}, [x0], x1 + ld1 {v21.8h}, [x3], x1 + ld1 {v0.8h}, [x0], x1 + ld1 {v1.8h}, [x3], x1 + ld1 {v2.8h}, [x0], x1 + ld1 {v3.8h}, [x3], x1 + ld1 {v22.8h}, [x0], x1 + ld1 {v23.8h}, [x3], x1 + transpose_8x8H v20, v21, v0, v1, v2, v3, v22, v23, v24, v25 +.else + sub x0, x0, #4 + add x3, x0, x1 + lsl x1, x1, #1 + ld1 {v20.8b}, [x0], x1 + ld1 {v21.8b}, [x3], x1 + ld1 {v0.8b}, [x0], x1 + ld1 {v1.8b}, [x3], x1 + ld1 {v2.8b}, [x0], x1 + ld1 {v3.8b}, [x3], x1 + ld1 {v22.8b}, [x0], x1 + ld1 {v23.8b}, [x3], x1 + transpose_8x8B v20, v21, v0, v1, v2, v3, v22, v23, v24, v25 +.endif + sub x0, x0, x1, lsl #2 + sub x3, x3, x1, lsl #2 + bl hevc_loop_filter_chroma_body_\bitdepth\()_neon +.if \bitdepth > 8 + transpose_8x8H v20, v21, v0, v1, v2, v3, v22, v23, v24, v25 + st1 {v20.8h}, [x0], x1 + st1 {v21.8h}, [x3], x1 + st1 {v0.8h}, [x0], x1 + st1 {v1.8h}, [x3], x1 + st1 {v2.8h}, [x0], x1 + st1 {v3.8h}, [x3], x1 + st1 {v22.8h}, [x0], x1 + st1 {v23.8h}, [x3] +.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}, [x3], x1 + st1 {v0.8b}, [x0], x1 + st1 {v1.8b}, [x3], x1 + st1 {v2.8b}, [x0], x1 + st1 {v3.8b}, [x3], x1 + st1 {v22.8b}, [x0], x1 + st1 {v23.8b}, [x3] +.endif +1: ret x4 +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 1deefca0a2..a923bae35c 100644 --- a/libavcodec/aarch64/hevcdsp_init_aarch64.c +++ b/libavcodec/aarch64/hevcdsp_init_aarch64.c @@ -25,6 +25,18 @@ #include "libavutil/aarch64/cpu.h" #include "libavcodec/hevcdsp.h" +void ff_hevc_v_loop_filter_chroma_8_neon(uint8_t *_pix, ptrdiff_t _stride, + const int *_tc, const uint8_t *_no_p, const uint8_t *_no_q); +void ff_hevc_v_loop_filter_chroma_10_neon(uint8_t *_pix, ptrdiff_t _stride, + const int *_tc, const uint8_t *_no_p, const uint8_t *_no_q); +void ff_hevc_v_loop_filter_chroma_12_neon(uint8_t *_pix, ptrdiff_t _stride, + const int *_tc, const uint8_t *_no_p, const uint8_t *_no_q); +void ff_hevc_h_loop_filter_chroma_8_neon(uint8_t *_pix, ptrdiff_t _stride, + const int *_tc, const uint8_t *_no_p, const uint8_t *_no_q); +void ff_hevc_h_loop_filter_chroma_10_neon(uint8_t *_pix, ptrdiff_t _stride, + const int *_tc, const uint8_t *_no_p, const uint8_t *_no_q); +void ff_hevc_h_loop_filter_chroma_12_neon(uint8_t *_pix, ptrdiff_t _stride, + const int *_tc, const uint8_t *_no_p, const uint8_t *_no_q); void ff_hevc_add_residual_4x4_8_neon(uint8_t *_dst, const int16_t *coeffs, ptrdiff_t stride); void ff_hevc_add_residual_4x4_10_neon(uint8_t *_dst, const int16_t *coeffs, @@ -117,6 +129,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; @@ -167,6 +181,8 @@ av_cold void ff_hevc_dsp_init_aarch64(HEVCDSPContext *c, const int bit_depth) c->put_hevc_qpel_bi[9][0][1] = ff_hevc_put_hevc_qpel_bi_h16_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; @@ -180,6 +196,8 @@ av_cold void ff_hevc_dsp_init_aarch64(HEVCDSPContext *c, const int bit_depth) 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; c->add_residual[0] = ff_hevc_add_residual_4x4_12_neon; c->add_residual[1] = ff_hevc_add_residual_8x8_12_neon; c->add_residual[2] = ff_hevc_add_residual_16x16_12_neon;