aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorsunyuechi <sunyuechi@iscas.ac.cn>2024-02-01 15:12:49 +0800
committerRémi Denis-Courmont <remi@remlab.net>2024-02-12 22:00:03 +0200
commit0748d2bbc79a77abb7ea49cdc3ef55ac2605eaa0 (patch)
tree0b267ace1602d79c3ab2013e6ca6374cf93efd1f /libavcodec
parent7bf1b9b35769b37684dd2f18a54f01d852a540c8 (diff)
downloadffmpeg-0748d2bbc79a77abb7ea49cdc3ef55ac2605eaa0.tar.gz
lavc/blockdsp: R-V V clear_block
C908: blockdsp.clear_block_c: 47.2 blockdsp.clear_block_rvv_i64: 28.5 Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/blockdsp.c2
-rw-r--r--libavcodec/blockdsp.h1
-rw-r--r--libavcodec/riscv/Makefile2
-rw-r--r--libavcodec/riscv/blockdsp_init.c39
-rw-r--r--libavcodec/riscv/blockdsp_rvv.S29
5 files changed, 73 insertions, 0 deletions
diff --git a/libavcodec/blockdsp.c b/libavcodec/blockdsp.c
index 98f06c5d16..79a8814262 100644
--- a/libavcodec/blockdsp.c
+++ b/libavcodec/blockdsp.c
@@ -69,6 +69,8 @@ av_cold void ff_blockdsp_init(BlockDSPContext *c)
ff_blockdsp_init_arm(c);
#elif ARCH_PPC
ff_blockdsp_init_ppc(c);
+#elif ARCH_RISCV
+ ff_blockdsp_init_riscv(c);
#elif ARCH_X86
ff_blockdsp_init_x86(c);
#elif ARCH_MIPS
diff --git a/libavcodec/blockdsp.h b/libavcodec/blockdsp.h
index d853adada2..6d751d797b 100644
--- a/libavcodec/blockdsp.h
+++ b/libavcodec/blockdsp.h
@@ -41,6 +41,7 @@ void ff_blockdsp_init(BlockDSPContext *c);
void ff_blockdsp_init_alpha(BlockDSPContext *c);
void ff_blockdsp_init_arm(BlockDSPContext *c);
void ff_blockdsp_init_ppc(BlockDSPContext *c);
+void ff_blockdsp_init_riscv(BlockDSPContext *c);
void ff_blockdsp_init_x86(BlockDSPContext *c);
void ff_blockdsp_init_mips(BlockDSPContext *c);
diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
index fe604a1156..a8d509a9fb 100644
--- a/libavcodec/riscv/Makefile
+++ b/libavcodec/riscv/Makefile
@@ -10,6 +10,8 @@ RVV-OBJS-$(CONFIG_ALAC_DECODER) += riscv/alacdsp_rvv.o
OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o
RV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvf.o
RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o
+OBJS-$(CONFIG_BLOCKDSP) += riscv/blockdsp_init.o
+RVV-OBJS-$(CONFIG_BLOCKDSP) += riscv/blockdsp_rvv.o
OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o
RV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvb.o
RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.o
diff --git a/libavcodec/riscv/blockdsp_init.c b/libavcodec/riscv/blockdsp_init.c
new file mode 100644
index 0000000000..5370418687
--- /dev/null
+++ b/libavcodec/riscv/blockdsp_init.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences (ISCAS).
+ *
+ * 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/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/riscv/cpu.h"
+#include "libavcodec/blockdsp.h"
+
+void ff_clear_block_rvv(int16_t *block);
+
+av_cold void ff_blockdsp_init_riscv(BlockDSPContext *c)
+{
+#if HAVE_RVV
+ int flags = av_get_cpu_flags();
+
+ if (flags & AV_CPU_FLAG_RVV_I64 && ff_get_rv_vlenb() >= 16) {
+ c->clear_block = ff_clear_block_rvv;
+ }
+#endif
+}
diff --git a/libavcodec/riscv/blockdsp_rvv.S b/libavcodec/riscv/blockdsp_rvv.S
new file mode 100644
index 0000000000..e85697613a
--- /dev/null
+++ b/libavcodec/riscv/blockdsp_rvv.S
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences (ISCAS).
+ *
+ * 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_clear_block_rvv, zve64x
+ vsetivli zero, 16, e64, m8, ta, ma
+ vmv.v.i v0, 0
+ vse64.v v0, (a0)
+
+ ret
+endfunc