From: "Rémi Denis-Courmont" <remi@remlab.net> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] lavc/g722dsp: add RISC-V V DSP function Date: Tue, 15 Aug 2023 21:41:40 +0300 Message-ID: <20230815184140.63736-1-remi@remlab.net> (raw) --- libavcodec/g722dsp.c | 2 + libavcodec/g722dsp.h | 1 + libavcodec/riscv/Makefile | 2 + libavcodec/riscv/g722dsp_init.c | 40 ++++++++++++++++++++ libavcodec/riscv/g722dsp_rvv.S | 66 +++++++++++++++++++++++++++++++++ 5 files changed, 111 insertions(+) create mode 100644 libavcodec/riscv/g722dsp_init.c create mode 100644 libavcodec/riscv/g722dsp_rvv.S diff --git a/libavcodec/g722dsp.c b/libavcodec/g722dsp.c index c770bfbdff..302283688f 100644 --- a/libavcodec/g722dsp.c +++ b/libavcodec/g722dsp.c @@ -71,6 +71,8 @@ av_cold void ff_g722dsp_init(G722DSPContext *c) #if ARCH_ARM ff_g722dsp_init_arm(c); +#elif ARCH_RISCV + ff_g722dsp_init_riscv(c); #elif ARCH_X86 ff_g722dsp_init_x86(c); #endif diff --git a/libavcodec/g722dsp.h b/libavcodec/g722dsp.h index c956a1e161..1aa7078a29 100644 --- a/libavcodec/g722dsp.h +++ b/libavcodec/g722dsp.h @@ -29,6 +29,7 @@ typedef struct G722DSPContext { void ff_g722dsp_init(G722DSPContext *c); void ff_g722dsp_init_arm(G722DSPContext *c); +void ff_g722dsp_init_riscv(G722DSPContext *c); void ff_g722dsp_init_x86(G722DSPContext *c); #endif /* AVCODEC_G722DSP_H */ diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index ee17a521fd..77bba7f784 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -10,6 +10,8 @@ OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o \ RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.o OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_init.o RVV-OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_rvv.o +OBJS-$(CONFIG_G722DSP) += riscv/g722dsp_init.o +RVV-OBJS-$(CONFIG_G722DSP) += riscv/g722dsp_rvv.o OBJS-$(CONFIG_H264CHROMA) += riscv/h264_chroma_init_riscv.o RVV-OBJS-$(CONFIG_H264CHROMA) += riscv/h264_mc_chroma.o OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_init.o diff --git a/libavcodec/riscv/g722dsp_init.c b/libavcodec/riscv/g722dsp_init.c new file mode 100644 index 0000000000..77e29bfb56 --- /dev/null +++ b/libavcodec/riscv/g722dsp_init.c @@ -0,0 +1,40 @@ +/* + * Copyright © 2023 Rémi Denis-Courmont. + * + * 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 <stdint.h> + +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/riscv/cpu.h" +#include "libavcodec/g722dsp.h" + +extern void ff_g722_apply_qmf_rvv(const int16_t *prev_samples, int xout[2]); + +av_cold void ff_g722dsp_init_riscv(G722DSPContext *dsp) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if ((flags & AV_CPU_FLAG_RVV_I32) && ff_get_rv_vlenb() >= 16) + dsp->apply_qmf = ff_g722_apply_qmf_rvv; +#endif +} diff --git a/libavcodec/riscv/g722dsp_rvv.S b/libavcodec/riscv/g722dsp_rvv.S new file mode 100644 index 0000000000..350be8dc1f --- /dev/null +++ b/libavcodec/riscv/g722dsp_rvv.S @@ -0,0 +1,66 @@ +/* + * Copyright © 2023 Rémi Denis-Courmont. + * + * 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/riscv/asm.S" + +func ff_g722_apply_qmf_rvv, zve32x + lla t0, qmf_coeffs + vsetivli zero, 12, e16, m2, ta, ma + vlseg2e16.v v28, (a0) + vlseg2e16.v v24, (t0) + vwmul.vv v16, v28, v24 + vwmul.vv v20, v30, v26 + vsetivli zero, 12, e32, m4, ta, ma + vmv.s.x v10, zero + vredsum.vs v8, v16, v10 + vredsum.vs v9, v20, v10 + vmv.x.s t0, v8 + vmv.x.s t1, v9 + sw t0, 4(a1) + sw t1, 0(a1) + ret +endfunc + +const qmf_coeffs, align=2 + .short 3 + .short -11 + .short -11 + .short 53 + .short 12 + .short -156 + .short 32 + .short 362 + .short -210 + .short -805 + .short 951 + .short 3876 + .short 3876 + .short 951 + .short -805 + .short -210 + .short 362 + .short 32 + .short -156 + .short 12 + .short 53 + .short -11 + .short -11 + .short 3 +endconst -- 2.40.1 _______________________________________________ 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".
reply other threads:[~2023-08-15 18:41 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230815184140.63736-1-remi@remlab.net \ --to=remi@remlab.net \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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