From 54d784dfd5d0d04456164f250766a3620d42c8c2 Mon Sep 17 00:00:00 2001
From: sunyuechi <sunyuechi@iscas.ac.cn>
Date: Mon, 26 Feb 2024 14:42:17 +0800
Subject: [PATCH 1/3] lavc/vp9dsp: R-V V ipred vert
C908
vp9_vert_16x16_8bpp_c: 80.2
vp9_vert_16x16_8bpp_rvv_i32: 55.7
vp9_vert_32x32_8bpp_c: 308.2
vp9_vert_32x32_8bpp_rvv_i32: 141.7
---
libavcodec/riscv/Makefile | 2 ++
libavcodec/riscv/vp9dsp_init.c | 41 +++++++++++++++++++++++++++++
libavcodec/riscv/vp9dsp_rvv.S | 47 ++++++++++++++++++++++++++++++++++
libavcodec/vp9dsp.c | 2 ++
libavcodec/vp9dsp.h | 1 +
5 files changed, 93 insertions(+)
create mode 100644 libavcodec/riscv/vp9dsp_init.c
create mode 100644 libavcodec/riscv/vp9dsp_rvv.S
@@ -60,5 +60,7 @@ OBJS-$(CONFIG_VC1DSP) += riscv/vc1dsp_init.o
RVV-OBJS-$(CONFIG_VC1DSP) += riscv/vc1dsp_rvv.o
OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_init.o
RVV-OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_rvv.o
+OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9dsp_init.o
+RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9dsp_rvv.o
OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_init.o
RVV-OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_rvv.o
new file mode 100644
@@ -0,0 +1,41 @@
+/*
+ * 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 Lervvr 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
+ * Lervvr General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lervvr 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/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/riscv/cpu.h"
+#include "libavcodec/vp9dsp.h"
+
+void ff_vp9_ipred_v_32x32_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l, const uint8_t *a);
+void ff_vp9_ipred_v_16x16_rvv(uint8_t *dst, ptrdiff_t stride, const uint8_t *l, const uint8_t *a);
+
+av_cold void ff_vp9dsp_init_riscv(VP9DSPContext *dsp, int bpp, int bitexact)
+{
+ #if HAVE_RVV
+ int flags = av_get_cpu_flags();
+
+ if (flags & AV_CPU_FLAG_RVV_I32) {
+ if (bpp == 8) {
+ dsp->intra_pred[TX_32X32][VERT_PRED] = ff_vp9_ipred_v_32x32_rvv;
+ dsp->intra_pred[TX_16X16][VERT_PRED] = ff_vp9_ipred_v_16x16_rvv;
+ }
+ }
+ #endif
+}
new file mode 100644
@@ -0,0 +1,47 @@
+/*
+ * 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_vp9_ipred_v_32x32_rvv, zve32x
+ vsetivli zero, 8, e8, mf2, ta, ma
+ vle32.v v8, (a3)
+
+ .rept 31
+ vse32.v v8, (a0)
+ add a0, a0, a1
+ .endr
+ vse32.v v8, (a0)
+
+ ret
+endfunc
+
+func ff_vp9_ipred_v_16x16_rvv, zve32x
+ vsetivli zero, 4, e8, mf4, ta, ma
+ vle32.v v8, (a3)
+
+ .rept 15
+ vse32.v v8, (a0)
+ add a0, a0, a1
+ .endr
+ vse32.v v8, (a0)
+
+ ret
+endfunc
@@ -100,6 +100,8 @@ av_cold void ff_vp9dsp_init(VP9DSPContext *dsp, int bpp, int bitexact)
ff_vp9dsp_init_aarch64(dsp, bpp);
#elif ARCH_ARM
ff_vp9dsp_init_arm(dsp, bpp);
+#elif ARCH_RISCV
+ ff_vp9dsp_init_riscv(dsp, bpp, bitexact);
#elif ARCH_X86
ff_vp9dsp_init_x86(dsp, bpp, bitexact);
#elif ARCH_MIPS
@@ -131,6 +131,7 @@ void ff_vp9dsp_init_12(VP9DSPContext *dsp);
void ff_vp9dsp_init_aarch64(VP9DSPContext *dsp, int bpp);
void ff_vp9dsp_init_arm(VP9DSPContext *dsp, int bpp);
+void ff_vp9dsp_init_riscv(VP9DSPContext *dsp, int bpp, int bitexact);
void ff_vp9dsp_init_x86(VP9DSPContext *dsp, int bpp, int bitexact);
void ff_vp9dsp_init_mips(VP9DSPContext *dsp, int bpp);
void ff_vp9dsp_init_loongarch(VP9DSPContext *dsp, int bpp);
--
2.44.0