diff mbox series

[FFmpeg-devel,1/2] lavc/blockdsp: R-V V clear_block

Message ID CAEa-L+uycY+wN_fm=RA2m6-TopVmX_8eathY0LCtkaC4f=VmYg@mail.gmail.com
State New
Headers show
Series [FFmpeg-devel,1/2] lavc/blockdsp: R-V V clear_block | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

flow gg Feb. 1, 2024, 8:42 a.m. UTC

diff mbox series

Patch

From d545f5ccc1c5923cb38c25b18ca750ef0ee529f4 Mon Sep 17 00:00:00 2001
From: sunyuechi <sunyuechi@iscas.ac.cn>
Date: Thu, 1 Feb 2024 15:12:49 +0800
Subject: [PATCH 1/2] lavc/blockdsp: R-V V clear_block

C908:
blockdsp.clear_block_c: 47.2
blockdsp.clear_block_rvv_i64: 28.5
---
 libavcodec/blockdsp.c            |  2 ++
 libavcodec/blockdsp.h            |  1 +
 libavcodec/riscv/Makefile        |  2 ++
 libavcodec/riscv/blockdsp_init.c | 39 ++++++++++++++++++++++++++++++++
 libavcodec/riscv/blockdsp_rvv.S  | 29 ++++++++++++++++++++++++
 5 files changed, 73 insertions(+)
 create mode 100644 libavcodec/riscv/blockdsp_init.c
 create mode 100644 libavcodec/riscv/blockdsp_rvv.S

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 ffe6631cf2..579a716487 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
-- 
2.43.0