[FFmpeg-cvslog] lavc/g722dsp: add RISC-V V DSP function

Rémi Denis-Courmont git at videolan.org
Thu Aug 24 21:07:24 EEST 2023


ffmpeg | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Aug 15 20:54:37 2023 +0300| [9bc5676e405e0154d76ad8d01424f43f3cbd81d5] | committer: Rémi Denis-Courmont

lavc/g722dsp: add RISC-V V DSP function

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9bc5676e405e0154d76ad8d01424f43f3cbd81d5
---

 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(+)

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



More information about the ffmpeg-cvslog mailing list