From patchwork Wed Nov 17 04:56:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J. Dekker" X-Patchwork-Id: 31454 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp211581iob; Tue, 16 Nov 2021 20:56:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzC2zA6/SHiufTz3Mo2tBSy5Awt9Uch+hBj0ULNKXo3RmIu7kXNhcfDbjkR8fPnUi3z5paQ X-Received: by 2002:a17:907:2da1:: with SMTP id gt33mr17484873ejc.378.1637125019254; Tue, 16 Nov 2021 20:56:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637125019; cv=none; d=google.com; s=arc-20160816; b=p3y5BRbhjhzv35ot/g8TmPPeCLpNYv9m4PqDxobIi/B3c6I2dByltbi+4K41c2N8OQ x/mu7/4p8POebEE2VEfxuCJLMsHZvCCKJRCO1ebyYRJrwtI4N70wtjo2JixT8YQpUhep Bjnn58Qd99TkWANd5IoW+dZPNbncd2F1RclL7U6v+pKUu3gPu21MWvfk6s9hRPKK4Dak biFLil9lm+eIjiQoui2EatSxFrengCcNSqlGWOLjYWCoOPQvl/9M1Wrb8P54nGfLb0zf 8hYiM7N4wP+iA7Jd/1lOwByNye1EwaZ5bfgb5O8klbxGudQgHZJEdLoTjgT1K90sj6XY gTUg== 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:dkim-signature:dkim-signature:delivered-to; bh=NGlHR4DoGOVSfE+TPueFGfez23VFvzpInj+NMPkNLl8=; b=kD3qOkI+PDewmoyNucQsi//2vzhPcZIOyAUv8NeaBPHuLFRV8i8Ri2R7+fNunMxDiz SXVtgTVtmwAPoaECU6PigMhZ/TSRMrS8Q2de2mt1LbisAzw0Aih3flH21J7tK8Kmz5T/ VHa5/6CFysZVHfxBgSD8wwNRfbeKLXbcwtkT6c4QNywv/CkOTthMFJTZSo1XEIg97k0I GMB80groDmZMI3Gje41g5tLMvtO5UpF31sv61Xcu4ffIFOsfBCFMcPn7kzCJs4mvlczr hZ0EZolLZT/KlZF660k0h19VySKwYd/fvi9hDi7ELttFYnR94+CKSoYWkqoGRwHoAL7t 5enA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@itanimul.li header.s=fm3 header.b=H19l2qro; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm1 header.b=MeR7Nu2g; 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 qf26si51815506ejc.28.2021.11.16.20.56.58; Tue, 16 Nov 2021 20:56:59 -0800 (PST) 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=H19l2qro; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm1 header.b=MeR7Nu2g; 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 D9E0068AD5F; Wed, 17 Nov 2021 06:56:29 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 249B968A5F8 for ; Wed, 17 Nov 2021 06:56:22 +0200 (EET) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id A26513201A3C for ; Tue, 16 Nov 2021 23:56:20 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 16 Nov 2021 23:56:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=itanimul.li; h= from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=A+xKUy/xd9nsA I2IVEP+OflHc03TIqdIXjiGOD5Kmao=; b=H19l2qroZsohNJAPY+kaY0U4+4Sfx IwqALWIdbqJYeOVk+yTuNfzUGMDGvWe0ygJvy6kyuAENB4XFLuLlOQEG6yq/nhU8 +3FxPAeaTCizj3o2qjsGuXwlEPMXRZh+cboMFYxM8XMJMun/AGhyCSTwiS3GJHQj oX6Qj8ihU/3cXKD1BTSS4gzbclBPS6rTQOc8vXH3TfXmvM8AFGGhOpW1D3olNf+2 c+K036noqJHRiKO4WLAuXe4hqKB0RMCzUnnLIrVPzHawspPhnOmm0JzJd4BOflFc /hitG1PFjrU4YGVRKyzYgLdSlLR0D8gg+D+TQdMNLEI2tJL4V91WJUqlw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=A+xKUy/xd9nsAI2IVEP+OflHc03TIqdIXjiGOD5Kmao=; b=MeR7Nu2g qAbSJe7XZaz1AzZ/eV1WKjixPzkkVailJGlfBDIYC+VWDDEQkhAcGQgJ+x3cSB68 ft3GzWYdahCxUrekHGJ2m8hLKuKKzHT/drTEoHQHH8SV7LlStTZUDC0aNHaNqVxZ /CZuERqLtVRQlxHkaaokO76N7Z/EbT8qq52R22HYwCUWwSOLyK3kullJBXSvCjKS 9PlQv5NPc78pdQiFDeEaQzbPaCjQAwH9bbmsR4IFAhkVbZUnyP7dwOaR8NLpwEuZ goI0Ls9GQ2qbHs66mtEKHt3EDyZJXKHVou6GnoTYFZvFaNM6+u+Yf4799mAhDWRp jDmrbpIw1xvZog== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrfeefgdejhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpedflfdrucffvghkkhgvrhdfuceojhguvghksehithgrnhhimhhu lhdrlhhiqeenucggtffrrghtthgvrhhnpefhvdefjeffgefffeeifeevgfehueduleehhf ffvedttdfhheduiedtteefheeiteenucffohhmrghinhepnhgvohhnrdhssgenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjuggvkhesihhtrg hnihhmuhhlrdhlih X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 16 Nov 2021 23:56:19 -0500 (EST) From: "J. Dekker" To: ffmpeg-devel@ffmpeg.org Date: Wed, 17 Nov 2021 05:56:11 +0100 Message-Id: <20211117045614.55251-3-jdek@itanimul.li> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20211117045614.55251-1-jdek@itanimul.li> References: <20211117045614.55251-1-jdek@itanimul.li> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/6] lavc/aarch64: add hevc sao edge 16x16 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: 5zkp2P4HJxtS --bench on AWS Graviton: hevc_sao_edge_16x16_8_c: 1857.0 hevc_sao_edge_16x16_8_neon: 211.0 hevc_sao_edge_32x32_8_c: 7802.2 hevc_sao_edge_32x32_8_neon: 808.2 hevc_sao_edge_48x48_8_c: 16764.2 hevc_sao_edge_48x48_8_neon: 1796.5 hevc_sao_edge_64x64_8_c: 32647.5 hevc_sao_edge_64x64_8_neon: 3118.5 Signed-off-by: J. Dekker --- libavcodec/aarch64/hevcdsp_init_aarch64.c | 8 ++- libavcodec/aarch64/hevcdsp_sao_neon.S | 65 +++++++++++++++++++++++ 2 files changed, 71 insertions(+), 2 deletions(-) Used inline shift for ldr & escheduled uxtl/uxtl2 before zip/zip2. diff --git a/libavcodec/aarch64/hevcdsp_init_aarch64.c b/libavcodec/aarch64/hevcdsp_init_aarch64.c index c785e46f79..747ff0412d 100644 --- a/libavcodec/aarch64/hevcdsp_init_aarch64.c +++ b/libavcodec/aarch64/hevcdsp_init_aarch64.c @@ -57,8 +57,8 @@ void ff_hevc_sao_band_filter_8x8_8_neon(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst, ptrdiff_t stride_src, int16_t *sao_offset_val, int sao_left_class, int width, int height); - - +void ff_hevc_sao_edge_filter_16x16_8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride_dst, + int16_t *sao_offset_val, int eo, int width, int height); av_cold void ff_hevc_dsp_init_aarch64(HEVCDSPContext *c, const int bit_depth) { @@ -76,6 +76,10 @@ av_cold void ff_hevc_dsp_init_aarch64(HEVCDSPContext *c, const int bit_depth) c->idct_dc[2] = ff_hevc_idct_16x16_dc_8_neon; c->idct_dc[3] = ff_hevc_idct_32x32_dc_8_neon; c->sao_band_filter[0] = ff_hevc_sao_band_filter_8x8_8_neon; + c->sao_edge_filter[1] = + c->sao_edge_filter[2] = + c->sao_edge_filter[3] = + c->sao_edge_filter[4] = ff_hevc_sao_edge_filter_16x16_8_neon; } if (bit_depth == 10) { c->add_residual[0] = ff_hevc_add_residual_4x4_10_neon; diff --git a/libavcodec/aarch64/hevcdsp_sao_neon.S b/libavcodec/aarch64/hevcdsp_sao_neon.S index f9fed8345b..f1b9ced93f 100644 --- a/libavcodec/aarch64/hevcdsp_sao_neon.S +++ b/libavcodec/aarch64/hevcdsp_sao_neon.S @@ -85,3 +85,68 @@ function ff_hevc_sao_band_filter_8x8_8_neon, export=1 bne 1b ret endfunc + +// ASSUMES STRIDE_SRC = 192 +.Lsao_edge_pos: +.word 1 // horizontal +.word 192 // vertical +.word 192 + 1 // 45 degree +.word 192 - 1 // 135 degree + +// ff_hevc_sao_edge_filter_16x16_8_neon(char *dst, char *src, ptrdiff stride_dst, +// int16 *sao_offset_val, int eo, int width, int height) +function ff_hevc_sao_edge_filter_16x16_8_neon, export=1 + adr x7, .Lsao_edge_pos + ld1 {v3.8h}, [x3] // load sao_offset_val + sxtw x5, w5 + ldr w4, [x7, w4, uxtw #2] // stride_src + mov v3.h[7], v3.h[0] // reorder to [1,2,0,3,4] + mov v3.h[0], v3.h[1] + mov v3.h[1], v3.h[2] + mov v3.h[2], v3.h[7] + // split 16bit values into two tables + uzp2 v1.16b, v3.16b, v3.16b // sao_offset_val -> upper + uzp1 v0.16b, v3.16b, v3.16b // sao_offset_val -> lower + movi v2.16b, #2 + mov x15, #192 + // strides between end of line and next src/dst + sub x15, x15, x5 // stride_src - width + sub x16, x2, x5 // stride_dst - width + mov x11, x1 // copy base src +1: // new line + mov x14, x5 // copy width + sub x12, x11, x4 // src_a (prev) = src - sao_edge_pos + add x13, x11, x4 // src_b (next) = src + sao_edge_pos +2: // process 16 bytes + ld1 {v3.16b}, [x11], #16 // load src + ld1 {v4.16b}, [x12], #16 // load src_a (prev) + ld1 {v5.16b}, [x13], #16 // load src_b (next) + cmhi v16.16b, v4.16b, v3.16b // (prev > cur) + cmhi v17.16b, v3.16b, v4.16b // (cur > prev) + cmhi v18.16b, v5.16b, v3.16b // (next > cur) + cmhi v19.16b, v3.16b, v5.16b // (cur > next) + sub v20.16b, v16.16b, v17.16b // diff0 = CMP(cur, prev) = (cur > prev) - (cur < prev) + sub v21.16b, v18.16b, v19.16b // diff1 = CMP(cur, next) = (cur > next) - (cur < next) + add v20.16b, v20.16b, v21.16b // diff = diff0 + diff1 + add v20.16b, v20.16b, v2.16b // offset_val = diff + 2 + tbl v16.16b, {v0.16b}, v20.16b + tbl v17.16b, {v1.16b}, v20.16b + uxtl v20.8h, v3.8b // src[0:7] + uxtl2 v21.8h, v3.16b // src[7:15] + zip1 v18.16b, v16.16b, v17.16b // sao_offset_val lower -> + zip2 v19.16b, v16.16b, v17.16b // sao_offset_val upper -> + sqadd v20.8h, v18.8h, v20.8h // + sao_offset_val + sqadd v21.8h, v19.8h, v21.8h + sqxtun v3.8b, v20.8h + sqxtun2 v3.16b, v21.8h + st1 {v3.16b}, [x0], #16 + subs x14, x14, #16 // filtered 16 bytes + b.ne 2b // do we have width to filter? + // no width to filter, setup next line + add x11, x11, x15 // stride src to next line + add x0, x0, x16 // stride dst to next line + subs w6, w6, #1 // filtered line + b.ne 1b // do we have lines to process? + // no lines to filter + ret +endfunc