* [FFmpeg-devel] [PATCH 1/2] checkasm/mpegvideoencdsp: add pix_sum and pix_norm1 @ 2024-08-09 11:27 Ramiro Polla 2024-08-09 11:27 ` [FFmpeg-devel] [PATCH 2/2] avcodec/mpegvideoencdsp: add aarch64 " Ramiro Polla 0 siblings, 1 reply; 5+ messages in thread From: Ramiro Polla @ 2024-08-09 11:27 UTC (permalink / raw) To: ffmpeg-devel --- tests/checkasm/Makefile | 1 + tests/checkasm/checkasm.c | 3 ++ tests/checkasm/checkasm.h | 1 + tests/checkasm/mpegvideoencdsp.c | 77 ++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 tests/checkasm/mpegvideoencdsp.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 3a7670e24b..7da58c14c4 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -18,6 +18,7 @@ AVCODECOBJS-$(CONFIG_LLVIDDSP) += llviddsp.o AVCODECOBJS-$(CONFIG_LLVIDENCDSP) += llviddspenc.o AVCODECOBJS-$(CONFIG_LPC) += lpc.o AVCODECOBJS-$(CONFIG_ME_CMP) += motion.o +AVCODECOBJS-$(CONFIG_MPEGVIDEOENC) += mpegvideoencdsp.o AVCODECOBJS-$(CONFIG_VC1DSP) += vc1dsp.o AVCODECOBJS-$(CONFIG_VP8DSP) += vp8dsp.o AVCODECOBJS-$(CONFIG_VIDEODSP) += videodsp.o diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 58597d3888..0bba4fb295 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -170,6 +170,9 @@ static const struct { #if CONFIG_ME_CMP { "motion", checkasm_check_motion }, #endif + #if CONFIG_MPEGVIDEOENC + { "mpegvideoencdsp", checkasm_check_mpegvideoencdsp }, + #endif #if CONFIG_OPUS_DECODER { "opusdsp", checkasm_check_opusdsp }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 4d5f3e387e..ba7e8c1ea0 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -110,6 +110,7 @@ void checkasm_check_llviddsp(void); void checkasm_check_llviddspenc(void); void checkasm_check_lpc(void); void checkasm_check_motion(void); +void checkasm_check_mpegvideoencdsp(void); void checkasm_check_nlmeans(void); void checkasm_check_opusdsp(void); void checkasm_check_pixblockdsp(void); diff --git a/tests/checkasm/mpegvideoencdsp.c b/tests/checkasm/mpegvideoencdsp.c new file mode 100644 index 0000000000..00d21ba0ba --- /dev/null +++ b/tests/checkasm/mpegvideoencdsp.c @@ -0,0 +1,77 @@ +/* + * 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/mem.h" +#include "libavutil/mem_internal.h" + +#include "libavcodec/mpegvideoencdsp.h" + +#include "checkasm.h" + +static void check_pix_sum(MpegvideoEncDSPContext *c) +{ + LOCAL_ALIGNED_16(uint8_t, src, [16 * 16]); + + declare_func(int, const uint8_t *pix, int line_size); + + for (int i = 0; i < 16 * 16; i++) + src[i] = rnd(); + + if (check_func(c->pix_sum, "pix_sum")) { + int sum0, sum1; + sum0 = call_ref(src, 16); + sum1 = call_new(src, 16); + if (sum0 != sum1) + fail(); + bench_new(src, 16); + } +} + +static void check_pix_norm1(MpegvideoEncDSPContext *c) +{ + LOCAL_ALIGNED_16(uint8_t, src, [16 * 16]); + + declare_func(int, const uint8_t *pix, int line_size); + + for (int i = 0; i < 16 * 16; i++) + src[i] = rnd(); + + if (check_func(c->pix_norm1, "pix_norm1")) { + int sum0, sum1; + sum0 = call_ref(src, 16); + sum1 = call_new(src, 16); + if (sum0 != sum1) + fail(); + bench_new(src, 16); + } +} + +void checkasm_check_mpegvideoencdsp(void) +{ + AVCodecContext avctx = { + .bits_per_raw_sample = 8, + }; + MpegvideoEncDSPContext c = { 0 }; + + ff_mpegvideoencdsp_init(&c, &avctx); + + check_pix_sum(&c); + report("pix_sum"); + check_pix_norm1(&c); + report("pix_norm1"); +} -- 2.30.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 5+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avcodec/mpegvideoencdsp: add aarch64 pix_sum and pix_norm1 2024-08-09 11:27 [FFmpeg-devel] [PATCH 1/2] checkasm/mpegvideoencdsp: add pix_sum and pix_norm1 Ramiro Polla @ 2024-08-09 11:27 ` Ramiro Polla 2024-08-13 7:45 ` Rémi Denis-Courmont 0 siblings, 1 reply; 5+ messages in thread From: Ramiro Polla @ 2024-08-09 11:27 UTC (permalink / raw) To: ffmpeg-devel checkasm --bench for Raspberry Pi 5 Model B Rev 1.0: pix_norm1_c: 235.7 pix_norm1_neon: 40.7 pix_sum_c: 249.0 pix_sum_neon: 22.0 --- libavcodec/aarch64/Makefile | 2 + libavcodec/aarch64/mpegvideoencdsp_init.c | 39 +++++++++ libavcodec/aarch64/mpegvideoencdsp_neon.S | 102 ++++++++++++++++++++++ libavcodec/mpegvideoencdsp.c | 4 +- libavcodec/mpegvideoencdsp.h | 2 + 5 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 libavcodec/aarch64/mpegvideoencdsp_init.c create mode 100644 libavcodec/aarch64/mpegvideoencdsp_neon.S diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile index a3256bb1cc..de0653ebbc 100644 --- a/libavcodec/aarch64/Makefile +++ b/libavcodec/aarch64/Makefile @@ -10,6 +10,7 @@ OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_init_aarch64.o OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_init_aarch64.o OBJS-$(CONFIG_ME_CMP) += aarch64/me_cmp_init_aarch64.o OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_init.o +OBJS-$(CONFIG_MPEGVIDEOENC) += aarch64/mpegvideoencdsp_init.o OBJS-$(CONFIG_NEON_CLOBBER_TEST) += aarch64/neontest.o OBJS-$(CONFIG_PIXBLOCKDSP) += aarch64/pixblockdsp_init_aarch64.o OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp_init.o @@ -51,6 +52,7 @@ NEON-OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_neon.o \ aarch64/simple_idct_neon.o NEON-OBJS-$(CONFIG_ME_CMP) += aarch64/me_cmp_neon.o NEON-OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_neon.o +NEON-OBJS-$(CONFIG_MPEGVIDEOENC) += aarch64/mpegvideoencdsp_neon.o NEON-OBJS-$(CONFIG_PIXBLOCKDSP) += aarch64/pixblockdsp_neon.o NEON-OBJS-$(CONFIG_VC1DSP) += aarch64/vc1dsp_neon.o NEON-OBJS-$(CONFIG_VP8DSP) += aarch64/vp8dsp_neon.o diff --git a/libavcodec/aarch64/mpegvideoencdsp_init.c b/libavcodec/aarch64/mpegvideoencdsp_init.c new file mode 100644 index 0000000000..c014fac727 --- /dev/null +++ b/libavcodec/aarch64/mpegvideoencdsp_init.c @@ -0,0 +1,39 @@ +/* + * 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 <stddef.h> +#include <stdint.h> + +#include "libavutil/attributes.h" +#include "libavutil/aarch64/cpu.h" +#include "libavcodec/mpegvideoencdsp.h" +#include "config.h" + +int ff_pix_sum_neon(const uint8_t *pix, int line_size); +int ff_pix_norm1_neon(const uint8_t *pix, int line_size); + +av_cold void ff_mpegvideoencdsp_init_aarch64(MpegvideoEncDSPContext *c, + AVCodecContext *avctx) +{ + int cpu_flags = av_get_cpu_flags(); + + if (have_neon(cpu_flags)) { + c->pix_sum = ff_pix_sum_neon; + c->pix_norm1 = ff_pix_norm1_neon; + } +} diff --git a/libavcodec/aarch64/mpegvideoencdsp_neon.S b/libavcodec/aarch64/mpegvideoencdsp_neon.S new file mode 100644 index 0000000000..eb45afe005 --- /dev/null +++ b/libavcodec/aarch64/mpegvideoencdsp_neon.S @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2024 Ramiro Polla + * + * 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" + +.macro sum_line add_insn, postinc +.ifb \postinc + ld1 { v1.16b }, [x0] +.else + ld1 { v1.16b }, [x0], \postinc +.endif + \add_insn v0.8h, v1.16b +.endm + +function ff_pix_sum_neon, export=1 +// x0 const uint8_t *pix +// x1 int line_size + + uxtw x1, w1 + + sum_line uaddlp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp + + uaddlp v0.4s, v0.8h + uaddlv d0, v0.4s + fmov w0, s0 + + ret +endfunc + +.macro norm1_line add_insn, postinc +.ifb \postinc + ld1 { v2.16b }, [x0] +.else + ld1 { v2.16b }, [x0], \postinc +.endif + umull v0.8h, v2.8b, v2.8b + umull2 v1.8h, v2.16b, v2.16b + \add_insn v3.4s, v0.8h + \add_insn v4.4s, v1.8h +.endm + +function ff_pix_norm1_neon, export=1 +// x0 const uint8_t *pix +// x1 int line_size + + uxtw x1, w1 + + norm1_line uaddlp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp + + add v0.4s, v3.4s, v4.4s + uaddlv d0, v0.4s + fmov w0, s0 + + ret +endfunc diff --git a/libavcodec/mpegvideoencdsp.c b/libavcodec/mpegvideoencdsp.c index 997d048663..a96f0b6436 100644 --- a/libavcodec/mpegvideoencdsp.c +++ b/libavcodec/mpegvideoencdsp.c @@ -245,7 +245,9 @@ av_cold void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c, c->draw_edges = draw_edges_8_c; -#if ARCH_ARM +#if ARCH_AARCH64 + ff_mpegvideoencdsp_init_aarch64(c, avctx); +#elif ARCH_ARM ff_mpegvideoencdsp_init_arm(c, avctx); #elif ARCH_PPC ff_mpegvideoencdsp_init_ppc(c, avctx); diff --git a/libavcodec/mpegvideoencdsp.h b/libavcodec/mpegvideoencdsp.h index 95084679d9..63dbd39603 100644 --- a/libavcodec/mpegvideoencdsp.h +++ b/libavcodec/mpegvideoencdsp.h @@ -46,6 +46,8 @@ typedef struct MpegvideoEncDSPContext { void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c, AVCodecContext *avctx); +void ff_mpegvideoencdsp_init_aarch64(MpegvideoEncDSPContext *c, + AVCodecContext *avctx); void ff_mpegvideoencdsp_init_arm(MpegvideoEncDSPContext *c, AVCodecContext *avctx); void ff_mpegvideoencdsp_init_ppc(MpegvideoEncDSPContext *c, -- 2.30.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/mpegvideoencdsp: add aarch64 pix_sum and pix_norm1 2024-08-09 11:27 ` [FFmpeg-devel] [PATCH 2/2] avcodec/mpegvideoencdsp: add aarch64 " Ramiro Polla @ 2024-08-13 7:45 ` Rémi Denis-Courmont 2024-08-13 7:46 ` Rémi Denis-Courmont 0 siblings, 1 reply; 5+ messages in thread From: Rémi Denis-Courmont @ 2024-08-13 7:45 UTC (permalink / raw) To: FFmpeg development discussions and patches Le 9 août 2024 14:27:27 GMT+03:00, Ramiro Polla <ramiro.polla@gmail.com> a écrit : >checkasm --bench for Raspberry Pi 5 Model B Rev 1.0: >pix_norm1_c: 235.7 >pix_norm1_neon: 40.7 >pix_sum_c: 249.0 >pix_sum_neon: 22.0 >--- > libavcodec/aarch64/Makefile | 2 + > libavcodec/aarch64/mpegvideoencdsp_init.c | 39 +++++++++ > libavcodec/aarch64/mpegvideoencdsp_neon.S | 102 ++++++++++++++++++++++ > libavcodec/mpegvideoencdsp.c | 4 +- > libavcodec/mpegvideoencdsp.h | 2 + > 5 files changed, 148 insertions(+), 1 deletion(-) > create mode 100644 libavcodec/aarch64/mpegvideoencdsp_init.c > create mode 100644 libavcodec/aarch64/mpegvideoencdsp_neon.S > >diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile >index a3256bb1cc..de0653ebbc 100644 >--- a/libavcodec/aarch64/Makefile >+++ b/libavcodec/aarch64/Makefile >@@ -10,6 +10,7 @@ OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_init_aarch64.o > OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_init_aarch64.o > OBJS-$(CONFIG_ME_CMP) += aarch64/me_cmp_init_aarch64.o > OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_init.o >+OBJS-$(CONFIG_MPEGVIDEOENC) += aarch64/mpegvideoencdsp_init.o > OBJS-$(CONFIG_NEON_CLOBBER_TEST) += aarch64/neontest.o > OBJS-$(CONFIG_PIXBLOCKDSP) += aarch64/pixblockdsp_init_aarch64.o > OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp_init.o >@@ -51,6 +52,7 @@ NEON-OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_neon.o \ > aarch64/simple_idct_neon.o > NEON-OBJS-$(CONFIG_ME_CMP) += aarch64/me_cmp_neon.o > NEON-OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_neon.o >+NEON-OBJS-$(CONFIG_MPEGVIDEOENC) += aarch64/mpegvideoencdsp_neon.o > NEON-OBJS-$(CONFIG_PIXBLOCKDSP) += aarch64/pixblockdsp_neon.o > NEON-OBJS-$(CONFIG_VC1DSP) += aarch64/vc1dsp_neon.o > NEON-OBJS-$(CONFIG_VP8DSP) += aarch64/vp8dsp_neon.o >diff --git a/libavcodec/aarch64/mpegvideoencdsp_init.c b/libavcodec/aarch64/mpegvideoencdsp_init.c >new file mode 100644 >index 0000000000..c014fac727 >--- /dev/null >+++ b/libavcodec/aarch64/mpegvideoencdsp_init.c >@@ -0,0 +1,39 @@ >+/* >+ * 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 <stddef.h> >+#include <stdint.h> >+ >+#include "libavutil/attributes.h" >+#include "libavutil/aarch64/cpu.h" >+#include "libavcodec/mpegvideoencdsp.h" >+#include "config.h" >+ >+int ff_pix_sum_neon(const uint8_t *pix, int line_size); >+int ff_pix_norm1_neon(const uint8_t *pix, int line_size); >+ >+av_cold void ff_mpegvideoencdsp_init_aarch64(MpegvideoEncDSPContext *c, >+ AVCodecContext *avctx) >+{ >+ int cpu_flags = av_get_cpu_flags(); >+ >+ if (have_neon(cpu_flags)) { >+ c->pix_sum = ff_pix_sum_neon; >+ c->pix_norm1 = ff_pix_norm1_neon; >+ } >+} >diff --git a/libavcodec/aarch64/mpegvideoencdsp_neon.S b/libavcodec/aarch64/mpegvideoencdsp_neon.S >new file mode 100644 >index 0000000000..eb45afe005 >--- /dev/null >+++ b/libavcodec/aarch64/mpegvideoencdsp_neon.S >@@ -0,0 +1,102 @@ >+/* >+ * Copyright (c) 2024 Ramiro Polla >+ * >+ * 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" >+ >+.macro sum_line add_insn, postinc >+.ifb \postinc >+ ld1 { v1.16b }, [x0] >+.else >+ ld1 { v1.16b }, [x0], \postinc >+.endif >+ \add_insn v0.8h, v1.16b >+.endm >+ >+function ff_pix_sum_neon, export=1 >+// x0 const uint8_t *pix >+// x1 int line_size >+ >+ uxtw x1, w1 >+ >+ sum_line uaddlp, x1 >+ sum_line uadalp, x1 >+ sum_line uadalp, x1 >+ sum_line uadalp, x1 >+ sum_line uadalp, x1 >+ sum_line uadalp, x1 >+ sum_line uadalp, x1 >+ sum_line uadalp, x1 >+ sum_line uadalp, x1 >+ sum_line uadalp, x1 >+ sum_line uadalp, x1 >+ sum_line uadalp, x1 >+ sum_line uadalp, x1 >+ sum_line uadalp, x1 >+ sum_line uadalp, x1 >+ sum_line uadalp >+ >+ uaddlp v0.4s, v0.8h >+ uaddlv d0, v0.4s >+ fmov w0, s0 >+ >+ ret >+endfunc >+ >+.macro norm1_line add_insn, postinc >+.ifb \postinc >+ ld1 { v2.16b }, [x0] >+.else >+ ld1 { v2.16b }, [x0], \postinc >+.endif >+ umull v0.8h, v2.8b, v2.8b >+ umull2 v1.8h, v2.16b, v2.16b >+ \add_insn v3.4s, v0.8h >+ \add_insn v4.4s, v1.8h >+.endm Wher available, I expect that USDOT would be faster here. Can be added separately later so not a blocking issue though. >+ >+function ff_pix_norm1_neon, export=1 >+// x0 const uint8_t *pix >+// x1 int line_size >+ >+ uxtw x1, w1 >+ >+ norm1_line uaddlp, x1 >+ norm1_line uadalp, x1 >+ norm1_line uadalp, x1 >+ norm1_line uadalp, x1 >+ norm1_line uadalp, x1 >+ norm1_line uadalp, x1 >+ norm1_line uadalp, x1 >+ norm1_line uadalp, x1 >+ norm1_line uadalp, x1 >+ norm1_line uadalp, x1 >+ norm1_line uadalp, x1 >+ norm1_line uadalp, x1 >+ norm1_line uadalp, x1 >+ norm1_line uadalp, x1 >+ norm1_line uadalp, x1 >+ norm1_line uadalp >+ >+ add v0.4s, v3.4s, v4.4s >+ uaddlv d0, v0.4s >+ fmov w0, s0 >+ >+ ret >+endfunc >diff --git a/libavcodec/mpegvideoencdsp.c b/libavcodec/mpegvideoencdsp.c >index 997d048663..a96f0b6436 100644 >--- a/libavcodec/mpegvideoencdsp.c >+++ b/libavcodec/mpegvideoencdsp.c >@@ -245,7 +245,9 @@ av_cold void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c, > > c->draw_edges = draw_edges_8_c; > >-#if ARCH_ARM >+#if ARCH_AARCH64 >+ ff_mpegvideoencdsp_init_aarch64(c, avctx); >+#elif ARCH_ARM > ff_mpegvideoencdsp_init_arm(c, avctx); > #elif ARCH_PPC > ff_mpegvideoencdsp_init_ppc(c, avctx); >diff --git a/libavcodec/mpegvideoencdsp.h b/libavcodec/mpegvideoencdsp.h >index 95084679d9..63dbd39603 100644 >--- a/libavcodec/mpegvideoencdsp.h >+++ b/libavcodec/mpegvideoencdsp.h >@@ -46,6 +46,8 @@ typedef struct MpegvideoEncDSPContext { > > void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c, > AVCodecContext *avctx); >+void ff_mpegvideoencdsp_init_aarch64(MpegvideoEncDSPContext *c, >+ AVCodecContext *avctx); > void ff_mpegvideoencdsp_init_arm(MpegvideoEncDSPContext *c, > AVCodecContext *avctx); > void ff_mpegvideoencdsp_init_ppc(MpegvideoEncDSPContext *c, _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/mpegvideoencdsp: add aarch64 pix_sum and pix_norm1 2024-08-13 7:45 ` Rémi Denis-Courmont @ 2024-08-13 7:46 ` Rémi Denis-Courmont 2024-08-15 14:58 ` Ramiro Polla 0 siblings, 1 reply; 5+ messages in thread From: Rémi Denis-Courmont @ 2024-08-13 7:46 UTC (permalink / raw) To: FFmpeg development discussions and patches Le 13 août 2024 10:45:15 GMT+03:00, "Rémi Denis-Courmont" <remi@remlab.net> a écrit : > > >Le 9 août 2024 14:27:27 GMT+03:00, Ramiro Polla <ramiro.polla@gmail.com> a écrit : >>checkasm --bench for Raspberry Pi 5 Model B Rev 1.0: >>pix_norm1_c: 235.7 >>pix_norm1_neon: 40.7 >>pix_sum_c: 249.0 >>pix_sum_neon: 22.0 >>--- >> libavcodec/aarch64/Makefile | 2 + >> libavcodec/aarch64/mpegvideoencdsp_init.c | 39 +++++++++ >> libavcodec/aarch64/mpegvideoencdsp_neon.S | 102 ++++++++++++++++++++++ >> libavcodec/mpegvideoencdsp.c | 4 +- >> libavcodec/mpegvideoencdsp.h | 2 + >> 5 files changed, 148 insertions(+), 1 deletion(-) >> create mode 100644 libavcodec/aarch64/mpegvideoencdsp_init.c >> create mode 100644 libavcodec/aarch64/mpegvideoencdsp_neon.S >> >>diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile >>index a3256bb1cc..de0653ebbc 100644 >>--- a/libavcodec/aarch64/Makefile >>+++ b/libavcodec/aarch64/Makefile >>@@ -10,6 +10,7 @@ OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_init_aarch64.o >> OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_init_aarch64.o >> OBJS-$(CONFIG_ME_CMP) += aarch64/me_cmp_init_aarch64.o >> OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_init.o >>+OBJS-$(CONFIG_MPEGVIDEOENC) += aarch64/mpegvideoencdsp_init.o >> OBJS-$(CONFIG_NEON_CLOBBER_TEST) += aarch64/neontest.o >> OBJS-$(CONFIG_PIXBLOCKDSP) += aarch64/pixblockdsp_init_aarch64.o >> OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp_init.o >>@@ -51,6 +52,7 @@ NEON-OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_neon.o \ >> aarch64/simple_idct_neon.o >> NEON-OBJS-$(CONFIG_ME_CMP) += aarch64/me_cmp_neon.o >> NEON-OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_neon.o >>+NEON-OBJS-$(CONFIG_MPEGVIDEOENC) += aarch64/mpegvideoencdsp_neon.o >> NEON-OBJS-$(CONFIG_PIXBLOCKDSP) += aarch64/pixblockdsp_neon.o >> NEON-OBJS-$(CONFIG_VC1DSP) += aarch64/vc1dsp_neon.o >> NEON-OBJS-$(CONFIG_VP8DSP) += aarch64/vp8dsp_neon.o >>diff --git a/libavcodec/aarch64/mpegvideoencdsp_init.c b/libavcodec/aarch64/mpegvideoencdsp_init.c >>new file mode 100644 >>index 0000000000..c014fac727 >>--- /dev/null >>+++ b/libavcodec/aarch64/mpegvideoencdsp_init.c >>@@ -0,0 +1,39 @@ >>+/* >>+ * 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 <stddef.h> >>+#include <stdint.h> >>+ >>+#include "libavutil/attributes.h" >>+#include "libavutil/aarch64/cpu.h" >>+#include "libavcodec/mpegvideoencdsp.h" >>+#include "config.h" >>+ >>+int ff_pix_sum_neon(const uint8_t *pix, int line_size); >>+int ff_pix_norm1_neon(const uint8_t *pix, int line_size); >>+ >>+av_cold void ff_mpegvideoencdsp_init_aarch64(MpegvideoEncDSPContext *c, >>+ AVCodecContext *avctx) >>+{ >>+ int cpu_flags = av_get_cpu_flags(); >>+ >>+ if (have_neon(cpu_flags)) { >>+ c->pix_sum = ff_pix_sum_neon; >>+ c->pix_norm1 = ff_pix_norm1_neon; >>+ } >>+} >>diff --git a/libavcodec/aarch64/mpegvideoencdsp_neon.S b/libavcodec/aarch64/mpegvideoencdsp_neon.S >>new file mode 100644 >>index 0000000000..eb45afe005 >>--- /dev/null >>+++ b/libavcodec/aarch64/mpegvideoencdsp_neon.S >>@@ -0,0 +1,102 @@ >>+/* >>+ * Copyright (c) 2024 Ramiro Polla >>+ * >>+ * 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" >>+ >>+.macro sum_line add_insn, postinc >>+.ifb \postinc >>+ ld1 { v1.16b }, [x0] >>+.else >>+ ld1 { v1.16b }, [x0], \postinc >>+.endif >>+ \add_insn v0.8h, v1.16b >>+.endm >>+ >>+function ff_pix_sum_neon, export=1 >>+// x0 const uint8_t *pix >>+// x1 int line_size >>+ >>+ uxtw x1, w1 >>+ >>+ sum_line uaddlp, x1 >>+ sum_line uadalp, x1 >>+ sum_line uadalp, x1 >>+ sum_line uadalp, x1 >>+ sum_line uadalp, x1 >>+ sum_line uadalp, x1 >>+ sum_line uadalp, x1 >>+ sum_line uadalp, x1 >>+ sum_line uadalp, x1 >>+ sum_line uadalp, x1 >>+ sum_line uadalp, x1 >>+ sum_line uadalp, x1 >>+ sum_line uadalp, x1 >>+ sum_line uadalp, x1 >>+ sum_line uadalp, x1 >>+ sum_line uadalp >>+ >>+ uaddlp v0.4s, v0.8h >>+ uaddlv d0, v0.4s >>+ fmov w0, s0 >>+ >>+ ret >>+endfunc >>+ >>+.macro norm1_line add_insn, postinc >>+.ifb \postinc >>+ ld1 { v2.16b }, [x0] >>+.else >>+ ld1 { v2.16b }, [x0], \postinc >>+.endif >>+ umull v0.8h, v2.8b, v2.8b >>+ umull2 v1.8h, v2.16b, v2.16b >>+ \add_insn v3.4s, v0.8h >>+ \add_insn v4.4s, v1.8h >>+.endm > >Wher available, I expect that USDOT would be faster here. Can be added separately later so not a blocking issue though. s/USDOT/UDOT/ _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/mpegvideoencdsp: add aarch64 pix_sum and pix_norm1 2024-08-13 7:46 ` Rémi Denis-Courmont @ 2024-08-15 14:58 ` Ramiro Polla 0 siblings, 0 replies; 5+ messages in thread From: Ramiro Polla @ 2024-08-15 14:58 UTC (permalink / raw) To: FFmpeg development discussions and patches On Tue, Aug 13, 2024 at 9:46 AM Rémi Denis-Courmont <remi@remlab.net> wrote: > Le 13 août 2024 10:45:15 GMT+03:00, "Rémi Denis-Courmont" <remi@remlab.net> a écrit : > >Le 9 août 2024 14:27:27 GMT+03:00, Ramiro Polla <ramiro.polla@gmail.com> a écrit : > >>checkasm --bench for Raspberry Pi 5 Model B Rev 1.0: > >>pix_norm1_c: 235.7 > >>pix_norm1_neon: 40.7 > >>pix_sum_c: 249.0 > >>pix_sum_neon: 22.0 > >>--- > >> libavcodec/aarch64/Makefile | 2 + > >> libavcodec/aarch64/mpegvideoencdsp_init.c | 39 +++++++++ > >> libavcodec/aarch64/mpegvideoencdsp_neon.S | 102 ++++++++++++++++++++++ > >> libavcodec/mpegvideoencdsp.c | 4 +- > >> libavcodec/mpegvideoencdsp.h | 2 + > >> 5 files changed, 148 insertions(+), 1 deletion(-) > >> create mode 100644 libavcodec/aarch64/mpegvideoencdsp_init.c > >> create mode 100644 libavcodec/aarch64/mpegvideoencdsp_neon.S > >> > >>diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile > >>index a3256bb1cc..de0653ebbc 100644 > >>--- a/libavcodec/aarch64/Makefile > >>+++ b/libavcodec/aarch64/Makefile > >>@@ -10,6 +10,7 @@ OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_init_aarch64.o > >> OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_init_aarch64.o > >> OBJS-$(CONFIG_ME_CMP) += aarch64/me_cmp_init_aarch64.o > >> OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_init.o > >>+OBJS-$(CONFIG_MPEGVIDEOENC) += aarch64/mpegvideoencdsp_init.o > >> OBJS-$(CONFIG_NEON_CLOBBER_TEST) += aarch64/neontest.o > >> OBJS-$(CONFIG_PIXBLOCKDSP) += aarch64/pixblockdsp_init_aarch64.o > >> OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp_init.o > >>@@ -51,6 +52,7 @@ NEON-OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_neon.o \ > >> aarch64/simple_idct_neon.o > >> NEON-OBJS-$(CONFIG_ME_CMP) += aarch64/me_cmp_neon.o > >> NEON-OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_neon.o > >>+NEON-OBJS-$(CONFIG_MPEGVIDEOENC) += aarch64/mpegvideoencdsp_neon.o > >> NEON-OBJS-$(CONFIG_PIXBLOCKDSP) += aarch64/pixblockdsp_neon.o > >> NEON-OBJS-$(CONFIG_VC1DSP) += aarch64/vc1dsp_neon.o > >> NEON-OBJS-$(CONFIG_VP8DSP) += aarch64/vp8dsp_neon.o > >>diff --git a/libavcodec/aarch64/mpegvideoencdsp_init.c b/libavcodec/aarch64/mpegvideoencdsp_init.c > >>new file mode 100644 > >>index 0000000000..c014fac727 > >>--- /dev/null > >>+++ b/libavcodec/aarch64/mpegvideoencdsp_init.c > >>@@ -0,0 +1,39 @@ > >>+/* > >>+ * 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 <stddef.h> > >>+#include <stdint.h> > >>+ > >>+#include "libavutil/attributes.h" > >>+#include "libavutil/aarch64/cpu.h" > >>+#include "libavcodec/mpegvideoencdsp.h" > >>+#include "config.h" > >>+ > >>+int ff_pix_sum_neon(const uint8_t *pix, int line_size); > >>+int ff_pix_norm1_neon(const uint8_t *pix, int line_size); > >>+ > >>+av_cold void ff_mpegvideoencdsp_init_aarch64(MpegvideoEncDSPContext *c, > >>+ AVCodecContext *avctx) > >>+{ > >>+ int cpu_flags = av_get_cpu_flags(); > >>+ > >>+ if (have_neon(cpu_flags)) { > >>+ c->pix_sum = ff_pix_sum_neon; > >>+ c->pix_norm1 = ff_pix_norm1_neon; > >>+ } > >>+} > >>diff --git a/libavcodec/aarch64/mpegvideoencdsp_neon.S b/libavcodec/aarch64/mpegvideoencdsp_neon.S > >>new file mode 100644 > >>index 0000000000..eb45afe005 > >>--- /dev/null > >>+++ b/libavcodec/aarch64/mpegvideoencdsp_neon.S > >>@@ -0,0 +1,102 @@ > >>+/* > >>+ * Copyright (c) 2024 Ramiro Polla > >>+ * > >>+ * 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" > >>+ > >>+.macro sum_line add_insn, postinc > >>+.ifb \postinc > >>+ ld1 { v1.16b }, [x0] > >>+.else > >>+ ld1 { v1.16b }, [x0], \postinc > >>+.endif > >>+ \add_insn v0.8h, v1.16b > >>+.endm > >>+ > >>+function ff_pix_sum_neon, export=1 > >>+// x0 const uint8_t *pix > >>+// x1 int line_size > >>+ > >>+ uxtw x1, w1 > >>+ > >>+ sum_line uaddlp, x1 > >>+ sum_line uadalp, x1 > >>+ sum_line uadalp, x1 > >>+ sum_line uadalp, x1 > >>+ sum_line uadalp, x1 > >>+ sum_line uadalp, x1 > >>+ sum_line uadalp, x1 > >>+ sum_line uadalp, x1 > >>+ sum_line uadalp, x1 > >>+ sum_line uadalp, x1 > >>+ sum_line uadalp, x1 > >>+ sum_line uadalp, x1 > >>+ sum_line uadalp, x1 > >>+ sum_line uadalp, x1 > >>+ sum_line uadalp, x1 > >>+ sum_line uadalp > >>+ > >>+ uaddlp v0.4s, v0.8h > >>+ uaddlv d0, v0.4s > >>+ fmov w0, s0 > >>+ > >>+ ret > >>+endfunc > >>+ > >>+.macro norm1_line add_insn, postinc > >>+.ifb \postinc > >>+ ld1 { v2.16b }, [x0] > >>+.else > >>+ ld1 { v2.16b }, [x0], \postinc > >>+.endif > >>+ umull v0.8h, v2.8b, v2.8b > >>+ umull2 v1.8h, v2.16b, v2.16b > >>+ \add_insn v3.4s, v0.8h > >>+ \add_insn v4.4s, v1.8h > >>+.endm > > > >Wher available, I expect that USDOT would be faster here. Can be added separately later so not a blocking issue though. > > s/USDOT/UDOT/ Good idea. I'll send a patch for dotprod once this gets merged. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-08-15 14:58 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-08-09 11:27 [FFmpeg-devel] [PATCH 1/2] checkasm/mpegvideoencdsp: add pix_sum and pix_norm1 Ramiro Polla 2024-08-09 11:27 ` [FFmpeg-devel] [PATCH 2/2] avcodec/mpegvideoencdsp: add aarch64 " Ramiro Polla 2024-08-13 7:45 ` Rémi Denis-Courmont 2024-08-13 7:46 ` Rémi Denis-Courmont 2024-08-15 14:58 ` Ramiro Polla
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git