From eaac50d41b3398ef39d1026a7d84480860a1c41e Mon Sep 17 00:00:00 2001
From: sunyuechi <sunyuechi@iscas.ac.cn>
Date: Tue, 16 Jan 2024 23:55:33 +0800
Subject: [PATCH 1/3] lavc/h264pred: R-V V pred16x16_vertical_8
C908
pred16x16_vertical_8_c: 1.5
pred16x16_vertical_8_rvv_i32: 1.0
---
libavcodec/h264pred.c | 2 ++
libavcodec/h264pred.h | 2 ++
libavcodec/riscv/Makefile | 2 ++
libavcodec/riscv/h264pred_init.c | 42 ++++++++++++++++++++++++++++++++
libavcodec/riscv/h264pred_rvv.S | 35 ++++++++++++++++++++++++++
5 files changed, 83 insertions(+)
create mode 100644 libavcodec/riscv/h264pred_init.c
create mode 100644 libavcodec/riscv/h264pred_rvv.S
@@ -592,6 +592,8 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id,
ff_h264_pred_init_aarch64(h, codec_id, bit_depth, chroma_format_idc);
#elif ARCH_ARM
ff_h264_pred_init_arm(h, codec_id, bit_depth, chroma_format_idc);
+#elif ARCH_RISCV
+ ff_h264_pred_init_riscv(h, codec_id, bit_depth, chroma_format_idc);
#elif ARCH_X86
ff_h264_pred_init_x86(h, codec_id, bit_depth, chroma_format_idc);
#elif ARCH_MIPS
@@ -120,6 +120,8 @@ void ff_h264_pred_init_aarch64(H264PredContext *h, int codec_id,
const int chroma_format_idc);
void ff_h264_pred_init_arm(H264PredContext *h, int codec_id,
const int bit_depth, const int chroma_format_idc);
+void ff_h264_pred_init_riscv(H264PredContext *h, int codec_id,
+ const int bit_depth, const int chroma_format_idc);
void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
const int bit_depth, const int chroma_format_idc);
void ff_h264_pred_init_mips(H264PredContext *h, int codec_id,
@@ -22,6 +22,8 @@ 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_JPEG2000_DECODER) += riscv/jpeg2000dsp_init.o
+RVV-OBJS-$(CONFIG_H264PRED) += riscv/h264pred_rvv.o
+OBJS-$(CONFIG_H264PRED) += riscv/h264pred_init.o
RVV-OBJS-$(CONFIG_JPEG2000_DECODER) += riscv/jpeg2000dsp_rvv.o
OBJS-$(CONFIG_H264CHROMA) += riscv/h264_chroma_init_riscv.o
RVV-OBJS-$(CONFIG_H264CHROMA) += riscv/h264_mc_chroma.o
new file mode 100644
@@ -0,0 +1,42 @@
+/*
+ * 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 "libavcodec/h264pred.h"
+
+void ff_pred16x16_vertical_8_rvv(uint8_t *src, ptrdiff_t stride);
+
+av_cold void ff_h264_pred_init_riscv(H264PredContext *h, int codec_id,
+ const int bit_depth,
+ const int chroma_format_idc)
+{
+ if (bit_depth == 8) {
+ #if HAVE_RVV
+ int flags = av_get_cpu_flags();
+
+ if (flags & AV_CPU_FLAG_RVV_I32) {
+ h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_8_rvv;
+ }
+ #endif
+ }
+}
new file mode 100644
@@ -0,0 +1,35 @@
+/*
+ * 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_pred16x16_vertical_8_rvv, zve32x
+ vsetivli zero, 4, e8, mf4, ta, ma
+ sub a0, a0, a1
+ vle32.v v0, (a0)
+ li t1, 16
+1:
+ add a0, a0, a1
+ addi t1, t1, -1
+ vse32.v v0, (a0)
+ bnez t1, 1b
+
+ ret
+endfunc
--
2.43.0