@@ -1,4 +1,5 @@
OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o \
riscv/audiodsp_rvf.o
+RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o
OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o \
riscv/pixblockdsp_rvi.o
@@ -18,16 +18,25 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "config.h"
+
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavcodec/audiodsp.h"
void ff_vector_clipf_rvf(float *dst, const float *src, int len, float min, float max);
+void ff_vector_clip_int32_rvv(int32_t *dst, const int32_t *src, int32_t min,
+ int32_t max, unsigned int len);
+
av_cold void ff_audiodsp_init_riscv(AudioDSPContext *c)
{
int flags = av_get_cpu_flags();
if (flags & AV_CPU_FLAG_RVF)
c->vector_clipf = ff_vector_clipf_rvf;
+#if HAVE_RVV
+ if (flags & AV_CPU_FLAG_RV_ZVE32X)
+ c->vector_clip_int32 = ff_vector_clip_int32_rvv;
+#endif
}
new file mode 100644
@@ -0,0 +1,37 @@
+/*
+ * Copyright © 2022 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_vector_clip_int32_rvv, zve32x
+1:
+ vsetvli t0, a4, e32, m1, ta, ma
+ vle32.v v8, (a1)
+ slli t1, t0, 2
+ vmax.vx v8, v8, a2
+ add a1, a1, t1
+ vmin.vx v8, v8, a3
+ sub a4, a4, t0
+ vse32.v v8, (a0)
+ add a0, a0, t1
+ bnez a4, 1b
+
+ ret
+endfunc
From: Rémi Denis-Courmont <remi@remlab.net> --- libavcodec/riscv/Makefile | 1 + libavcodec/riscv/audiodsp_init.c | 9 ++++++++ libavcodec/riscv/audiodsp_rvv.S | 37 ++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 libavcodec/riscv/audiodsp_rvv.S