C908 h264_add_pixels4_clear_c: 96.0 h264_add_pixels4_clear_rvv_i64: 30.2
From 8b2838516915c27aa2831e797c2c41ad1d1bae1b Mon Sep 17 00:00:00 2001 From: sunyuechi <sunyue...@iscas.ac.cn> Date: Mon, 25 Dec 2023 00:06:28 +0800 Subject: [PATCH 2/3] lavc/h264dsp: R-V V h264_add_pixels4_clear
C908 h264_add_pixels4_clear_c: 96.0 h264_add_pixels4_clear_rvv_i64: 30.2 The number of vsets can be reduced, but that would lead to a change in the order of instructions, thus making it slower. --- libavcodec/h264dsp.c | 2 ++ libavcodec/h264dsp.h | 2 ++ libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/h264dsp_init.c | 41 ++++++++++++++++++++++++++++++++ libavcodec/riscv/h264dsp_rvv.S | 42 +++++++++++++++++++++++++++++++++ 5 files changed, 89 insertions(+) create mode 100644 libavcodec/riscv/h264dsp_init.c create mode 100644 libavcodec/riscv/h264dsp_rvv.S diff --git a/libavcodec/h264dsp.c b/libavcodec/h264dsp.c index 4d2ee10bab..1ba936be1c 100644 --- a/libavcodec/h264dsp.c +++ b/libavcodec/h264dsp.c @@ -158,6 +158,8 @@ av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, ff_h264dsp_init_arm(c, bit_depth, chroma_format_idc); #elif ARCH_PPC ff_h264dsp_init_ppc(c, bit_depth, chroma_format_idc); +#elif ARCH_RISCV + ff_h264dsp_init_riscv(c, bit_depth, chroma_format_idc); #elif ARCH_X86 ff_h264dsp_init_x86(c, bit_depth, chroma_format_idc); #elif ARCH_MIPS diff --git a/libavcodec/h264dsp.h b/libavcodec/h264dsp.h index e0880c4d88..d940343b4a 100644 --- a/libavcodec/h264dsp.h +++ b/libavcodec/h264dsp.h @@ -125,6 +125,8 @@ void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); +void ff_h264dsp_init_riscv(H264DSPContext *c, const int bit_depth, + const int chroma_format_idc); void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); void ff_h264dsp_init_mips(H264DSPContext *c, const int bit_depth, diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 35ad149326..7f253bba12 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -23,6 +23,8 @@ OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_init.o 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_H264DSP) += riscv/h264dsp_init.o +RVV-OBJS-$(CONFIG_H264DSP) += riscv/h264dsp_rvv.o OBJS-$(CONFIG_JPEG2000_DECODER) += riscv/jpeg2000dsp_init.o RVV-OBJS-$(CONFIG_JPEG2000_DECODER) += riscv/jpeg2000dsp_rvv.o OBJS-$(CONFIG_H264CHROMA) += riscv/h264_chroma_init_riscv.o diff --git a/libavcodec/riscv/h264dsp_init.c b/libavcodec/riscv/h264dsp_init.c new file mode 100644 index 0000000000..2538bc01a5 --- /dev/null +++ b/libavcodec/riscv/h264dsp_init.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 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 <stdint.h> + +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/riscv/cpu.h" +#include "libavcodec/h264dsp.h" + +void ff_h264_add_pixels4_clear_rvv(uint8_t *dst, int16_t *block, int stride); + +av_cold void ff_h264dsp_init_riscv(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVV_I64) { + if (bit_depth == 8) { + c->h264_add_pixels4_clear = ff_h264_add_pixels4_clear_rvv; + } + } +#endif +} diff --git a/libavcodec/riscv/h264dsp_rvv.S b/libavcodec/riscv/h264dsp_rvv.S new file mode 100644 index 0000000000..e6b943f57e --- /dev/null +++ b/libavcodec/riscv/h264dsp_rvv.S @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 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_h264_add_pixels4_clear_rvv, zve64x + vsetivli zero, 4, e8, mf4, ta, ma + vle64.v v24, (a1) + vsetivli zero, 4*4, e16, m2, ta, ma + li t0, 0xff + vand.vx v24, v24, t0 + addi a1, a1, 4*4*2 + vsetivli zero, 4, e8, mf4, ta, ma + vse64.v v0, (a1) + vsetivli zero, 4*4, e8, m1, ta, ma + vnclipu.wi v24, v24, 0 + vsetivli zero, 2, e8, mf8, ta, ma + vle64.v v8, (a0) + vsetivli zero, 4*4, e8, m1, ta, ma + vadd.vv v24, v24, v8 + vsetivli zero, 2, e8, mf8, ta, ma + vse64.v v24, (a0) + + ret +endfunc -- 2.43.0
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".