From patchwork Sat Jan 18 14:35:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 17408 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 9C64D44A870 for ; Sat, 18 Jan 2020 16:35:21 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7C6F66880D6; Sat, 18 Jan 2020 16:35:21 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from qq.com (out203-205-251-82.mail.qq.com [203.205.251.82]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0C179680AE2 for ; Sat, 18 Jan 2020 16:35:14 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1579358110; bh=B7Hz3PZWmjyaOGZ0x71T3Itnoxuy3yeyCvFhYh6o82M=; h=From:To:Cc:Subject:Date; b=Nrk0mna6w5/ifEP3ALrrXiim0TnHwHYyK1AJrT9jKIlIYaQWdlsk+lGAZaYDNSSvf lo/9GSngmUZG2+kEUPWH1yhOpqvP7qO9luXRO0jkl5MXkiMT9HQhjokrSVh0DhiSMI dsJfIp+jthLc7MN8yh5n0lbq0RbgKcyUx3Q9rXIA= Received: from localhost.localdomain ([27.38.252.253]) by newxmesmtplogicsvrszb1.qq.com (NewEsmtp) with SMTP id 8C9B2A3D; Sat, 18 Jan 2020 22:35:09 +0800 X-QQ-mid: xmsmtpt1579358109try63w695 X-QQ-XMAILINFO: N75rVQEf3LF1EtjT66jTBK1KNGQzB5myG3o/YtcLb51iapggdb/D+Vpjw/nzmN jJy7gc736WQ6MyM4TQQ39hUYD7mge6GFsU/+73cQxZ3FzjZYY2N3HT3pEtJt0LA0SevnpP331NMj ESbPnHzVhpJAD+SZ5u0Q0Nyd/UsW73N/Zj3Qkm6WfbEEdU97+tMxyjlf2N0F8iFRfdp3ou9ipmtF 32NY1mqCZId8Tou7a4wfI/quHqW+4kUs06VcyAg7glQEAXBQ7TvwYOwyvovcheQ2snaFMJCr2YWs pvvXWlzCynTdjVLd62rKUjb+N3HP2fMBaYZifHlJuOnHFpRRX6KdmUJ09dpW76O/FRnA3zTRsRrm BQiNXI93P1JlT/qeQjuHUKn0hJdYoQcyegG005MdWHsamzQ6bOAzZYJYCVOIDFDdw+7UZ600YOmx mAWiFSsw/zBNd+KobfGx974Usalr1BkMtrTS4fKvNZkaoKEW2uUElsy1SKLTherOg3QTConBNHAx CfJus2JpKDwedLy6Lau+R6NyPkDmIRwh79Ru99Fo3pQ6msVGwievdxAfiTj+BXTl40O2BXsrbVQC hCUBpCxlYIdE2av0dILe5Ae+uc From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 Jan 2020 22:35:07 +0800 Message-Id: <20200118143507.70195-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avfilter/af_afir: add AArch64 SIMD for fcmul_add 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: Zhao Zhili Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" ./ffmpeg -threads 1 -f lavfi -i anoisesrc -f lavfi -t 30 -i anoisesrc -t 600 -lavfi afir -benchmark -f null - Test results on Snapdragon 845: Without SIMD: size=N/A time=00:10:00.00 bitrate=N/A speed=32.2x bench: utime=21.900s stime=1.000s rtime=18.607s bench: maxrss=46708kB With SIMD: size=N/A time=00:10:00.00 bitrate=N/A speed=46.6x bench: utime=16.150s stime=1.040s rtime=12.867s bench: maxrss=46608kB Test results on HiSilicon Kirin 970: Without SIMD: size=N/A time=00:10:00.00 bitrate=N/A speed=20.7x bench: utime=32.292s stime=1.032s rtime=28.963s bench: maxrss=42412kB With SIMD: size=N/A time=00:10:00.00 bitrate=N/A speed=27.6x bench: utime=24.964s stime=0.952s rtime=21.703s bench: maxrss=42368kB --- libavfilter/aarch64/Makefile | 2 ++ libavfilter/aarch64/af_afir_init.c | 31 +++++++++++++++++++++ libavfilter/aarch64/af_afir_neon.S | 43 ++++++++++++++++++++++++++++++ libavfilter/af_afir.c | 2 ++ libavfilter/af_afir.h | 1 + 5 files changed, 79 insertions(+) create mode 100644 libavfilter/aarch64/af_afir_init.c create mode 100644 libavfilter/aarch64/af_afir_neon.S diff --git a/libavfilter/aarch64/Makefile b/libavfilter/aarch64/Makefile index b58daa3a3f..f52d7a4842 100644 --- a/libavfilter/aarch64/Makefile +++ b/libavfilter/aarch64/Makefile @@ -1,3 +1,5 @@ +OBJS-$(CONFIG_NLMEANS_FILTER) += aarch64/af_afir_init.o OBJS-$(CONFIG_NLMEANS_FILTER) += aarch64/vf_nlmeans_init.o +NEON-OBJS-$(CONFIG_NLMEANS_FILTER) += aarch64/af_afir_neon.o NEON-OBJS-$(CONFIG_NLMEANS_FILTER) += aarch64/vf_nlmeans_neon.o diff --git a/libavfilter/aarch64/af_afir_init.c b/libavfilter/aarch64/af_afir_init.c new file mode 100644 index 0000000000..db06536380 --- /dev/null +++ b/libavfilter/aarch64/af_afir_init.c @@ -0,0 +1,31 @@ +/* + * 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/cpu.h" +#include "libavfilter/af_afir.h" + +void ff_fcmul_add_neon(float *sum, const float *t, const float *c, + ptrdiff_t len); + +av_cold void ff_afir_init_aarch64(AudioFIRDSPContext *s) +{ + int cpu_flags = av_get_cpu_flags(); + + if (have_neon(cpu_flags)) + s->fcmul_add = ff_fcmul_add_neon; +} diff --git a/libavfilter/aarch64/af_afir_neon.S b/libavfilter/aarch64/af_afir_neon.S new file mode 100644 index 0000000000..60583f9591 --- /dev/null +++ b/libavfilter/aarch64/af_afir_neon.S @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020 Zhao Zhili + * + * 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" + +// void ff_fcmul_add_neon(float *sum, const float *t, const float *c, ptrdiff_t len); +function ff_fcmul_add_neon, export=1 +1: + ld2 {v0.4S, v1.4S}, [x1], #32 // load t + ld2 {v2.4S, v3.4S}, [x2], #32 // load c + ld2 {v4.4S, v5.4S}, [x0] // load sum + fmla v4.4S, v0.4S, v2.4S + fmls v4.4S, v1.4S, v3.4S + fmla v5.4S, v0.4S, v3.4S + fmla v5.4S, v1.4S, v2.4S + st2 {v4.4S, v5.4S}, [x0], #32 // store sum + subs x3, x3, #4 + b.ne 1b + ldr s0, [x1] // load t + ldr s1, [x2] // load c + ldr s2, [x0] // load sum + fmul s0, s0, s1 + fadd s2, s2, s0 + str s2, [x0] // store sum + ret +endfunc diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c index 7c7e8458d4..25dddc8c6b 100644 --- a/libavfilter/af_afir.c +++ b/libavfilter/af_afir.c @@ -829,6 +829,8 @@ void ff_afir_init(AudioFIRDSPContext *dsp) if (ARCH_X86) ff_afir_init_x86(dsp); + if (ARCH_AARCH64) + ff_afir_init_aarch64(dsp); } static av_cold int init(AVFilterContext *ctx) diff --git a/libavfilter/af_afir.h b/libavfilter/af_afir.h index 4f44675848..d5f32f50a4 100644 --- a/libavfilter/af_afir.h +++ b/libavfilter/af_afir.h @@ -101,6 +101,7 @@ typedef struct AudioFIRContext { } AudioFIRContext; void ff_afir_init(AudioFIRDSPContext *s); +void ff_afir_init_aarch64(AudioFIRDSPContext *s); void ff_afir_init_x86(AudioFIRDSPContext *s); #endif /* AVFILTER_AFIR_H */