Re: [FFmpeg-devel] [PATCH] lavc/aarch64: add sbrdsp neon implementation

2017-06-13 Thread Matthieu Bouron
On Fri, Jun 02, 2017 at 01:59:00PM +0200, Matthieu Bouron wrote:
> ---
> 
> Hello,
> 
> The following patch adds an aarch64 neon implementation of the sbrdsp (tested
> on an Odroid-C2). It hasn't been benchmarked yet and it lacks the
> hf_apply_noise{0,1,2,3} functions (which will be added later).

New patch attached adding the missing hf_apply_noise{0,1,2,3} functions.

Here are the performance results on an Odroid-C2:

sbr_apply_noise_0_c: 1690.6
sbr_apply_noise_0_neon: 1498.4
sbr_apply_noise_1_c: 1689.4
sbr_apply_noise_1_neon: 1504.2
sbr_apply_noise_2_c: 1690.2
sbr_apply_noise_2_neon: 1498.4
sbr_apply_noise_3_c: 1694.8
sbr_apply_noise_3_neon: 1504.0
sbr_autocorrelate_c: 644.0
sbr_autocorrelate_neon: 420.0
sbr_deint_bfly_c: 1107.6
sbr_deint_bfly_neon: 291.6
sbr_deint_neg_c: 210.4
sbr_deint_neg_neon: 107.4
sbr_filt_c: 2118.2
sbr_filt_neon: 1219.5
sbr_gen_c: 6071.2
sbr_gen_neon: 3251.2
sbr_neg_odd_64_c: 70.0
sbr_neg_odd_64_neon: 64.7
sbr_post_shuffle_c: 163.0
sbr_post_shuffle_neon: 107.7
sbr_pre_shuffle_c: 120.5
sbr_pre_shuffle_neon: 110.7
sbr_sum64x5_c: 1361.6
sbr_sum64x5_neon: 435.4

-- 
Matthieu B.
>From 51d950fe739fd90217d561c84d81aed2c6ed8713 Mon Sep 17 00:00:00 2001
From: Matthieu Bouron 
Date: Tue, 23 May 2017 14:29:35 +
Subject: [PATCH] lavc/aarch64: add sbrdsp neon implementation

---
 libavcodec/aarch64/Makefile  |   2 +
 libavcodec/aarch64/sbrdsp_init_aarch64.c |  71 +++
 libavcodec/aarch64/sbrdsp_neon.S | 329 +++
 libavcodec/sbrdsp.h  |   1 +
 libavcodec/sbrdsp_template.c |   2 +
 5 files changed, 405 insertions(+)
 create mode 100644 libavcodec/aarch64/sbrdsp_init_aarch64.c
 create mode 100644 libavcodec/aarch64/sbrdsp_neon.S

diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
index 104bc67802..116c343e42 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/sbrdsp_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
@@ -27,6 +28,7 @@ ARMV8-OBJS-$(CONFIG_VIDEODSP)   += aarch64/videodsp.o
 # NEON optimizations
 
 # subsystems
+NEON-OBJS-$(CONFIG_AAC_DECODER) += aarch64/sbrdsp_neon.o
 NEON-OBJS-$(CONFIG_FFT) += aarch64/fft_neon.o
 NEON-OBJS-$(CONFIG_FMTCONVERT)  += aarch64/fmtconvert_neon.o
 NEON-OBJS-$(CONFIG_H264CHROMA)  += aarch64/h264cmc_neon.o
diff --git a/libavcodec/aarch64/sbrdsp_init_aarch64.c b/libavcodec/aarch64/sbrdsp_init_aarch64.c
new file mode 100644
index 00..998bdb8095
--- /dev/null
+++ b/libavcodec/aarch64/sbrdsp_init_aarch64.c
@@ -0,0 +1,71 @@
+/*
+ *
+ * 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 "libavutil/attributes.h"
+#include "libavcodec/sbrdsp.h"
+
+void ff_sbr_sum64x5_neon(float *z);
+float ff_sbr_sum_square_neon(float (*x)[2], int n);
+void ff_sbr_neg_odd_64_neon(float *x);
+void ff_sbr_qmf_pre_shuffle_neon(float *z);
+void ff_sbr_qmf_post_shuffle_neon(float W[32][2], const float *z);
+void ff_sbr_qmf_deint_neg_neon(float *v, const float *src);
+void ff_sbr_qmf_deint_bfly_neon(float *v, const float *src0, const float *src1);
+void ff_sbr_hf_g_filt_neon(float (*Y)[2], const float (*X_high)[40][2],
+   const float *g_filt, int m_max, intptr_t ixh);
+void ff_sbr_hf_gen_neon(float (*X_high)[2], const float (*X_low)[2],
+const float alpha0[2], const float alpha1[2],
+float bw, int start, int end);
+void ff_sbr_autocorrelate_neon(const float x[40][2], float phi[3][2][2]);
+void ff_sbr_hf_apply_noise_0_neon(float Y[64][2], const float *s_m,
+  const float *q_filt, int noise,
+  int kx, int m_max);
+void ff_sbr_hf_apply_noise_1_neon(float Y[64][2], const 

[FFmpeg-devel] [PATCH] lavc/aarch64: add sbrdsp neon implementation

2017-06-02 Thread Matthieu Bouron
---

Hello,

The following patch adds an aarch64 neon implementation of the sbrdsp (tested
on an Odroid-C2). It hasn't been benchmarked yet and it lacks the
hf_apply_noise{0,1,2,3} functions (which will be added later).

---
 libavcodec/aarch64/Makefile  |   2 +
 libavcodec/aarch64/sbrdsp_init_aarch64.c |  55 +++
 libavcodec/aarch64/sbrdsp_neon.S | 258 +++
 libavcodec/sbrdsp.h  |   1 +
 libavcodec/sbrdsp_template.c |   2 +
 5 files changed, 318 insertions(+)
 create mode 100644 libavcodec/aarch64/sbrdsp_init_aarch64.c
 create mode 100644 libavcodec/aarch64/sbrdsp_neon.S

diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
index 104bc67802..116c343e42 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/sbrdsp_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
@@ -27,6 +28,7 @@ ARMV8-OBJS-$(CONFIG_VIDEODSP)   += aarch64/videodsp.o
 # NEON optimizations
 
 # subsystems
+NEON-OBJS-$(CONFIG_AAC_DECODER) += aarch64/sbrdsp_neon.o
 NEON-OBJS-$(CONFIG_FFT) += aarch64/fft_neon.o
 NEON-OBJS-$(CONFIG_FMTCONVERT)  += aarch64/fmtconvert_neon.o
 NEON-OBJS-$(CONFIG_H264CHROMA)  += aarch64/h264cmc_neon.o
diff --git a/libavcodec/aarch64/sbrdsp_init_aarch64.c 
b/libavcodec/aarch64/sbrdsp_init_aarch64.c
new file mode 100644
index 00..21aaf869fe
--- /dev/null
+++ b/libavcodec/aarch64/sbrdsp_init_aarch64.c
@@ -0,0 +1,55 @@
+/*
+ *
+ * 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 "libavutil/attributes.h"
+#include "libavcodec/sbrdsp.h"
+
+void ff_sbr_sum64x5_neon(float *z);
+float ff_sbr_sum_square_neon(float (*x)[2], int n);
+void ff_sbr_neg_odd_64_neon(float *x);
+void ff_sbr_qmf_pre_shuffle_neon(float *z);
+void ff_sbr_qmf_post_shuffle_neon(float W[32][2], const float *z);
+void ff_sbr_qmf_deint_neg_neon(float *v, const float *src);
+void ff_sbr_qmf_deint_bfly_neon(float *v, const float *src0, const float 
*src1);
+void ff_sbr_hf_g_filt_neon(float (*Y)[2], const float (*X_high)[40][2],
+   const float *g_filt, int m_max, intptr_t ixh);
+void ff_sbr_hf_gen_neon(float (*X_high)[2], const float (*X_low)[2],
+const float alpha0[2], const float alpha1[2],
+float bw, int start, int end);
+void ff_sbr_autocorrelate_neon(const float x[40][2], float phi[3][2][2]);
+
+av_cold void ff_sbrdsp_init_aarch64(SBRDSPContext *s)
+{
+int cpu_flags = av_get_cpu_flags();
+
+if (have_neon(cpu_flags)) {
+s->sum64x5 = ff_sbr_sum64x5_neon;
+s->sum_square = ff_sbr_sum_square_neon;
+s->neg_odd_64 = ff_sbr_neg_odd_64_neon;
+s->qmf_pre_shuffle = ff_sbr_qmf_pre_shuffle_neon;
+s->qmf_post_shuffle = ff_sbr_qmf_post_shuffle_neon;
+s->qmf_deint_neg = ff_sbr_qmf_deint_neg_neon;
+s->qmf_deint_bfly = ff_sbr_qmf_deint_bfly_neon;
+s->hf_g_filt = ff_sbr_hf_g_filt_neon;
+s->hf_gen = ff_sbr_hf_gen_neon;
+s->autocorrelate = ff_sbr_autocorrelate_neon;
+}
+}
diff --git a/libavcodec/aarch64/sbrdsp_neon.S b/libavcodec/aarch64/sbrdsp_neon.S
new file mode 100644
index 00..8f638e93c7
--- /dev/null
+++ b/libavcodec/aarch64/sbrdsp_neon.S
@@ -0,0 +1,258 @@
+/*
+ * Copyright (c) 2017 Matthieu Bouron 
+ *
+ * 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