--- This is still not benchmarked (written and verified with qemu).
I typically wrote an alternative implementation for stereo_interpolate[0] which needs to be compared with the current one: function ff_ps_stereo_interpolate_neon, export=1 ld1 {v0.4S}, [x2] ld1 {v1.4S}, [x3] 1: ld1 {v2.2S}, [x0] ld1 {v3.2S}, [x1] fadd v0.4S, v0.4S, v1.4S fmul v4.2S, v2.2S, v0.S[0] fmul v5.2S, v2.2S, v0.S[1] fmla v4.2S, v3.2S, v0.S[2] fmla v5.2S, v3.2S, v0.S[3] st1 {v4.2S}, [x0], #8 st1 {v5.2S}, [x1], #8 subs w4, w4, #1 b.gt 1b ret endfunc I don't know which is faster. For now, the current version follows the logic I used in stereo_interpolate[1] (the ipdopd one). It's doing less mult operations, but more shuffling. A 3rd alternative would be possible if it was possible to assume len % 2 was always true (allowing overreading and overwriting by one more entry basically). Currently, this is not the case. Speaking of ipdopd, the factors table and the ext may be clumsy. --- libavcodec/aacpsdsp.h | 1 + libavcodec/aacpsdsp_template.c | 2 + libavcodec/aarch64/Makefile | 2 + libavcodec/aarch64/aacpsdsp_init_aarch64.c | 44 +++++++++++++ libavcodec/aarch64/aacpsdsp_neon.S | 101 +++++++++++++++++++++++++++++ 5 files changed, 150 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 3049ce8b79..158160b246 100644 --- a/libavcodec/aacpsdsp_template.c +++ b/libavcodec/aacpsdsp_template.c @@ -222,6 +222,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..9c9e5db851 --- /dev/null +++ b/libavcodec/aarch64/aacpsdsp_init_aarch64.c @@ -0,0 +1,44 @@ +/* + * 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_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->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..82d641b730 --- /dev/null +++ b/libavcodec/aarch64/aacpsdsp_neon.S @@ -0,0 +1,101 @@ +/* + * 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] +1: + ld1 {v2.2S}, [x0] + ld1 {v3.2S}, [x1] + dup v2.2D, v2.D[0] + dup v3.2D, v3.D[0] + fadd v0.4S, v0.4S, v1.4S + zip1 v4.4S, v0.4S, v0.4S + zip2 v5.4S, v0.4S, v0.4S + 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 + +const ipdopd_factors, align=4 + .float -1.0, 1.0, -1.0, 1.0 +endconst + +function ff_ps_stereo_interpolate_ipdopd_neon, export=1 + movrel x5, ipdopd_factors + ld1 {v20.4S}, [x5] + ld1 {v0.4S,v1.4S}, [x2] + ld1 {v6.4S,v7.4S}, [x3] +1: + ld1 {v2.2S}, [x0] + ld1 {v3.2S}, [x1] + dup v2.2D, v2.D[0] + dup v3.2D, v3.D[0] + fadd v0.4S, v0.4S, v6.4S + fadd v1.4S, v1.4S, v7.4S + zip1 v16.4S, v0.4S, v0.4S + zip2 v17.4S, v0.4S, v0.4S + zip1 v18.4S, v1.4S, v1.4S + zip2 v19.4S, v1.4S, v1.4S + fmul v4.4S, v2.4S, v16.4S + fmla v4.4S, v3.4S, v17.4S + ext v2.16B, v2.16B, v2.16B, #4 + ext v3.16B, v3.16B, v3.16B, #4 + fmul v5.4S, v2.4S, v18.4S + fmla v5.4S, v3.4S, v19.4S + fmla v4.4S, v5.4S, v20.4S + st1 {v4.D}[0], [x0], #8 + st1 {v4.D}[1], [x1], #8 + subs w4, w4, #1 + b.gt 1b + ret +endfunc -- 2.13.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel