From patchwork Thu Jun 22 10:30:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgQsWTc2No?= X-Patchwork-Id: 4078 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.22.4 with SMTP id 4csp2307534vsw; Thu, 22 Jun 2017 03:31:49 -0700 (PDT) X-Received: by 10.28.32.131 with SMTP id g125mr1222491wmg.49.1498127509696; Thu, 22 Jun 2017 03:31:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498127509; cv=none; d=google.com; s=arc-20160816; b=NhjPKp8Uvoq97J1CuCR4tMlvV4fY0a6q1q0SqMperAIU6YmriPR5f5zJQntyQmcxsb j6mMaBSsushhr34pi/XcVDj+/ah772xCowKjOAcC6ilA/L1NXwVNiIlMk/px5QtKm0pz Niyrr1ZBi5Pp2bQViqW78pUwN1BGm/UGKj7JGamEePo4XcW3IDA0044H4CEMLfnZh5e6 t+PfyXO257tUUq3pUQEv9LrRzhj/QHFhbmu33QQaTWNDfQLvaxo5vq/av3XfgeBo6UmK Xv3tSWjGq3sguYRLM7iDiALsab0ee3ylNt7gRIv8TjbsI+l4DGwKNvKD0NSyEsfOi5lD kgoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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:delivered-to:arc-authentication-results; bh=bBNml7L0AShD7osoccgUtXeVf3t/Q4Sx9xiWTjchFrU=; b=D0IixxE+oQXjGZa8ulqWB0iVNmTugPQs2X7QE4xLmWHaR6f+k/ENfFMnfRQAn9xhee sjD5ir52+htw6CEAViAF5evLC9ODAm0WPu8fn9jkrd8WGDCUHPZnDHOV4EVxyk1KFjre LdKURr15xXHNIxU+Ez++94xOF+7Z3G0ZW7+34/KbAFa6NPWoxhEKKfPQClpUUamGQ1d+ 5Hat5jxt5rj3ME0dpL7ZcszFOQH0Amd1zUpNOYC5NPZRkjy9rDynceR1z6tcXRNAjufn ZhHzn3N9Km5jYs09s9Bnz/FIN2rnMHNmhLizmZXTGiPhCMrYs4cjPsSgIm+fJgTq9C9a D6BQ== ARC-Authentication-Results: i=1; mx.google.com; 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 88si1046239wrj.35.2017.06.22.03.31.49; Thu, 22 Jun 2017 03:31:49 -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; 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 5B47168A417; Thu, 22 Jun 2017 13:31:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from golem.pkh.me (LStLambert-657-1-117-164.w92-154.abo.wanadoo.fr [92.154.28.164]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2C10968A3E6 for ; Thu, 22 Jun 2017 13:31:10 +0300 (EEST) Received: from localhost (golem.pkh.me [local]) by golem.pkh.me (OpenSMTPD) with ESMTPA id 1b9bbb57; Thu, 22 Jun 2017 10:30:59 +0000 (UTC) From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Jun 2017 12:30:57 +0200 Message-Id: <20170622103058.6855-4-u@pkh.me> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170622103058.6855-1-u@pkh.me> References: <20170622103058.6855-1-u@pkh.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/5] lavc/aarch64: add a few SIMD functions for AAC PS X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Clément Bœsch ☭ tests/checkasm/checkasm --bench --test=aacpsdsp checkasm: using random seed 3318985180 MMX implied by specified flags MMX implied by specified flags NEON: - aacpsdsp.add_squares [OK] - aacpsdsp.mul_pair_single [OK] - aacpsdsp.hybrid_analysis [OK] - aacpsdsp.stereo_interpolate [OK] checkasm: all 5 tests passed nop: 10.0 ps_add_squares_c: 63221.2 ps_add_squares_neon: 22311.7 ps_hybrid_analysis_c: 2466.6 ps_hybrid_analysis_neon: 1521.9 ps_mul_pair_single_c: 68592.0 ps_mul_pair_single_neon: 17426.6 ps_stereo_interpolate_c: 72344.3 ps_stereo_interpolate_neon: 72308.8 ps_stereo_interpolate_ipdopd_c: 117415.2 ps_stereo_interpolate_ipdopd_neon: 113386.3 --- libavcodec/aacpsdsp.h | 1 + libavcodec/aacpsdsp_template.c | 2 + libavcodec/aarch64/Makefile | 2 + libavcodec/aarch64/aacpsdsp_init_aarch64.c | 48 ++++++++++ libavcodec/aarch64/aacpsdsp_neon.S | 149 +++++++++++++++++++++++++++++ 5 files changed, 202 insertions(+) create mode 100644 libavcodec/aarch64/aacpsdsp_init_aarch64.c create mode 100644 libavcodec/aarch64/aacpsdsp_neon.S diff --git a/libavcodec/aacpsdsp.h b/libavcodec/aacpsdsp.h index ad9bbb81bd..3714a08052 100644 --- a/libavcodec/aacpsdsp.h +++ b/libavcodec/aacpsdsp.h @@ -51,6 +51,7 @@ typedef struct PSDSPContext { void AAC_RENAME(ff_psdsp_init)(PSDSPContext *s); void ff_psdsp_init_arm(PSDSPContext *s); +void ff_psdsp_init_aarch64(PSDSPContext *s); void ff_psdsp_init_mips(PSDSPContext *s); void ff_psdsp_init_x86(PSDSPContext *s); diff --git a/libavcodec/aacpsdsp_template.c b/libavcodec/aacpsdsp_template.c index 4f193604bc..e639afa449 100644 --- a/libavcodec/aacpsdsp_template.c +++ b/libavcodec/aacpsdsp_template.c @@ -223,6 +223,8 @@ av_cold void AAC_RENAME(ff_psdsp_init)(PSDSPContext *s) #if !USE_FIXED if (ARCH_ARM) ff_psdsp_init_arm(s); + if (ARCH_AARCH64) + ff_psdsp_init_aarch64(s); if (ARCH_MIPS) ff_psdsp_init_mips(s); if (ARCH_X86) diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile index 104bc67802..d440b1b18a 100644 --- a/libavcodec/aarch64/Makefile +++ b/libavcodec/aarch64/Makefile @@ -11,6 +11,7 @@ OBJS-$(CONFIG_NEON_CLOBBER_TEST) += aarch64/neontest.o OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp_init.o # decoders/encoders +OBJS-$(CONFIG_AAC_DECODER) += aarch64/aacpsdsp_init_aarch64.o OBJS-$(CONFIG_DCA_DECODER) += aarch64/synth_filter_init.o OBJS-$(CONFIG_RV40_DECODER) += aarch64/rv40dsp_init_aarch64.o OBJS-$(CONFIG_VC1DSP) += aarch64/vc1dsp_init_aarch64.o @@ -42,6 +43,7 @@ NEON-OBJS-$(CONFIG_MDCT) += aarch64/mdct_neon.o NEON-OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_neon.o # decoders/encoders +NEON-OBJS-$(CONFIG_AAC_DECODER) += aarch64/aacpsdsp_neon.o NEON-OBJS-$(CONFIG_DCA_DECODER) += aarch64/synth_filter_neon.o NEON-OBJS-$(CONFIG_VORBIS_DECODER) += aarch64/vorbisdsp_neon.o NEON-OBJS-$(CONFIG_VP9_DECODER) += aarch64/vp9itxfm_16bpp_neon.o \ diff --git a/libavcodec/aarch64/aacpsdsp_init_aarch64.c b/libavcodec/aarch64/aacpsdsp_init_aarch64.c new file mode 100644 index 0000000000..c15094c45c --- /dev/null +++ b/libavcodec/aarch64/aacpsdsp_init_aarch64.c @@ -0,0 +1,48 @@ +/* + * 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 "config.h" + +#include "libavutil/aarch64/cpu.h" +#include "libavcodec/aacpsdsp.h" + +void ff_ps_add_squares_neon(float *dst, const float (*src)[2], int n); +void ff_ps_mul_pair_single_neon(float (*dst)[2], float (*src0)[2], + float *src1, int n); +void ff_ps_hybrid_analysis_neon(float (*out)[2], float (*in)[2], + const float (*filter)[8][2], + int stride, int n); +void ff_ps_stereo_interpolate_neon(float (*l)[2], float (*r)[2], + float h[2][4], float h_step[2][4], + int len); +void ff_ps_stereo_interpolate_ipdopd_neon(float (*l)[2], float (*r)[2], + float h[2][4], float h_step[2][4], + int len); + +av_cold void ff_psdsp_init_aarch64(PSDSPContext *s) +{ + int cpu_flags = av_get_cpu_flags(); + + if (have_neon(cpu_flags)) { + s->add_squares = ff_ps_add_squares_neon; + s->mul_pair_single = ff_ps_mul_pair_single_neon; + s->hybrid_analysis = ff_ps_hybrid_analysis_neon; + s->stereo_interpolate[0] = ff_ps_stereo_interpolate_neon; + s->stereo_interpolate[1] = ff_ps_stereo_interpolate_ipdopd_neon; + } +} diff --git a/libavcodec/aarch64/aacpsdsp_neon.S b/libavcodec/aarch64/aacpsdsp_neon.S new file mode 100644 index 0000000000..6662971199 --- /dev/null +++ b/libavcodec/aarch64/aacpsdsp_neon.S @@ -0,0 +1,149 @@ +/* + * 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" + +function ff_ps_add_squares_neon, export=1 +1: ld1 {v0.4S,v1.4S}, [x1], #32 + fmul v0.4S, v0.4S, v0.4S + fmul v1.4S, v1.4S, v1.4S + faddp v2.4S, v0.4S, v1.4S + ld1 {v3.4S}, [x0] + fadd v3.4S, v3.4S, v2.4S + st1 {v3.4S}, [x0], #16 + subs w2, w2, #4 + b.gt 1b + ret +endfunc + +function ff_ps_mul_pair_single_neon, export=1 +1: ld1 {v0.4S,v1.4S}, [x1], #32 + ld1 {v2.4S}, [x2], #16 + zip1 v3.4S, v2.4S, v2.4S + zip2 v4.4S, v2.4S, v2.4S + fmul v0.4S, v0.4S, v3.4S + fmul v1.4S, v1.4S, v4.4S + st1 {v0.4S,v1.4S}, [x0], #32 + subs w3, w3, #4 + b.gt 1b + ret +endfunc + +function ff_ps_stereo_interpolate_neon, export=1 + ld1 {v0.4S}, [x2] + ld1 {v1.4S}, [x3] + zip1 v4.4S, v0.4S, v0.4S + zip2 v5.4S, v0.4S, v0.4S + zip1 v6.4S, v1.4S, v1.4S + zip2 v7.4S, v1.4S, v1.4S +1: ld1 {v2.2S}, [x0] + ld1 {v3.2S}, [x1] + fadd v4.4S, v4.4S, v6.4S + fadd v5.4S, v5.4S, v7.4S + mov v2.D[1], v2.D[0] + mov v3.D[1], v3.D[0] + fmul v2.4S, v2.4S, v4.4S + fmla v2.4S, v3.4S, v5.4S + st1 {v2.D}[0], [x0], #8 + st1 {v2.D}[1], [x1], #8 + subs w4, w4, #1 + b.gt 1b + ret +endfunc + +function ff_ps_stereo_interpolate_ipdopd_neon, export=1 + ld1 {v0.4S,v1.4S}, [x2] + ld1 {v6.4S,v7.4S}, [x3] + fneg v2.4S, v1.4S + fneg v3.4S, v7.4S + zip1 v16.4S, v0.4S, v0.4S + zip2 v17.4S, v0.4S, v0.4S + zip1 v18.4S, v2.4S, v1.4S + zip2 v19.4S, v2.4S, v1.4S + zip1 v20.4S, v6.4S, v6.4S + zip2 v21.4S, v6.4S, v6.4S + zip1 v22.4S, v3.4S, v7.4S + zip2 v23.4S, v3.4S, v7.4S +1: ld1 {v2.2S}, [x0] + ld1 {v3.2S}, [x1] + fadd v16.4S, v16.4S, v20.4S + fadd v17.4S, v17.4S, v21.4S + mov v2.D[1], v2.D[0] + mov v3.D[1], v3.D[0] + fmul v4.4S, v2.4S, v16.4S + fmla v4.4S, v3.4S, v17.4S + fadd v18.4S, v18.4S, v22.4S + fadd v19.4S, v19.4S, v23.4S + ext v2.16B, v2.16B, v2.16B, #4 + ext v3.16B, v3.16B, v3.16B, #4 + fmla v4.4S, v2.4S, v18.4S + fmla v4.4S, v3.4S, v19.4S + st1 {v4.D}[0], [x0], #8 + st1 {v4.D}[1], [x1], #8 + subs w4, w4, #1 + b.gt 1b + ret +endfunc + +function ff_ps_hybrid_analysis_neon, export=1 + sxtw x3, w3 + lsl x3, x3, #3 + ld2 {v0.4S,v1.4S}, [x1], #32 + ld2 {v2.2S,v3.2S}, [x1], #16 + ld1 {v24.2S}, [x1], #8 + ld2 {v4.2S,v5.2S}, [x1], #16 + ld2 {v6.4S,v7.4S}, [x1] + rev64 v6.4S, v6.4S + rev64 v7.4S, v7.4S + ext v6.16B, v6.16B, v6.16B, #8 + ext v7.16B, v7.16B, v7.16B, #8 + rev64 v4.2S, v4.2S + rev64 v5.2S, v5.2S + mov v2.D[1], v3.D[0] + mov v4.D[1], v5.D[0] + mov v5.D[1], v2.D[0] + mov v3.D[1], v4.D[0] + fadd v16.4S, v0.4S, v6.4S + fadd v17.4S, v1.4S, v7.4S + fsub v18.4S, v1.4S, v7.4S + fsub v19.4S, v0.4S, v6.4S + fadd v22.4S, v2.4S, v4.4S + fsub v23.4S, v5.4S, v3.4S + trn1 v20.2D, v22.2D, v23.2D // {re4+re8, re5+re7, im8-im4, im7-im5} + trn2 v21.2D, v22.2D, v23.2D // {im4+im8, im5+im7, re4-re8, re5-re7} +1: ld2 {v2.4S,v3.4S}, [x2], #32 + ld2 {v4.2S,v5.2S}, [x2], #16 + ld1 {v6.2S}, [x2], #8 + add x2, x2, #8 + mov v4.D[1], v5.D[0] + mov v6.S[1], v6.S[0] + fmul v6.2S, v6.2S, v24.2S + fmul v0.4S, v2.4S, v16.4S + fmul v1.4S, v2.4S, v17.4S + fmls v0.4S, v3.4S, v18.4S + fmla v1.4S, v3.4S, v19.4S + fmla v0.4S, v4.4S, v20.4S + fmla v1.4S, v4.4S, v21.4S + faddp v0.4S, v0.4S, v1.4S + faddp v0.4S, v0.4S, v0.4S + fadd v0.2S, v0.2S, v6.2S + st1 {v0.2S}, [x0], x3 + subs w4, w4, #1 + b.gt 1b + ret +endfunc