diff options
author | Rémi Denis-Courmont <remi@remlab.net> | 2023-10-28 16:54:37 +0300 |
---|---|---|
committer | Rémi Denis-Courmont <remi@remlab.net> | 2023-10-31 21:33:25 +0200 |
commit | 424c8ceb08b180b832e63d50cc363a197119ab7f (patch) | |
tree | fb2add6b9bdd87f9e68aca6cbe82244acd69e85c | |
parent | 7e1cdc69fbe5cc82203b6a772e14f6e5f88b4b7a (diff) | |
download | ffmpeg-424c8ceb08b180b832e63d50cc363a197119ab7f.tar.gz |
lavc/huffyuvdsp: R-V V add_int16
add_int16_128_c: 2390.5
add_int16_128_rvv_i32: 832.0
add_int16_rnd_width_c: 2390.2
add_int16_rnd_width_rvv_i32: 832.5
-rw-r--r-- | libavcodec/huffyuvdsp.c | 4 | ||||
-rw-r--r-- | libavcodec/huffyuvdsp.h | 2 | ||||
-rw-r--r-- | libavcodec/riscv/Makefile | 2 | ||||
-rw-r--r-- | libavcodec/riscv/huffyuvdsp_init.c | 37 | ||||
-rw-r--r-- | libavcodec/riscv/huffyuvdsp_rvv.S | 37 |
5 files changed, 81 insertions, 1 deletions
diff --git a/libavcodec/huffyuvdsp.c b/libavcodec/huffyuvdsp.c index fb98836cc4..80587dac85 100644 --- a/libavcodec/huffyuvdsp.c +++ b/libavcodec/huffyuvdsp.c @@ -87,7 +87,9 @@ av_cold void ff_huffyuvdsp_init(HuffYUVDSPContext *c, enum AVPixelFormat pix_fmt c->add_hfyu_median_pred_int16 = add_hfyu_median_pred_int16_c; c->add_hfyu_left_pred_bgr32 = add_hfyu_left_pred_bgr32_c; -#if ARCH_X86 +#if ARCH_RISCV + ff_huffyuvdsp_init_riscv(c, pix_fmt); +#elif ARCH_X86 ff_huffyuvdsp_init_x86(c, pix_fmt); #endif } diff --git a/libavcodec/huffyuvdsp.h b/libavcodec/huffyuvdsp.h index 90e50b5429..34bed58ef2 100644 --- a/libavcodec/huffyuvdsp.h +++ b/libavcodec/huffyuvdsp.h @@ -34,6 +34,8 @@ typedef struct HuffYUVDSPContext { } HuffYUVDSPContext; void ff_huffyuvdsp_init(HuffYUVDSPContext *c, enum AVPixelFormat pix_fmt); +void ff_huffyuvdsp_init_riscv(HuffYUVDSPContext *c, + enum AVPixelFormat pix_fmt); void ff_huffyuvdsp_init_x86(HuffYUVDSPContext *c, enum AVPixelFormat pix_fmt); #endif /* AVCODEC_HUFFYUVDSP_H */ diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 69d5980e65..9c31c901cf 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -18,6 +18,8 @@ OBJS-$(CONFIG_G722DSP) += riscv/g722dsp_init.o RVV-OBJS-$(CONFIG_G722DSP) += riscv/g722dsp_rvv.o OBJS-$(CONFIG_H264CHROMA) += riscv/h264_chroma_init_riscv.o RVV-OBJS-$(CONFIG_H264CHROMA) += riscv/h264_mc_chroma.o +OBJS-$(CONFIG_HUFFYUV_DECODER) += riscv/huffyuvdsp_init.o +RVV-OBJS-$(CONFIG_HUFFYUV_DECODER) += riscv/huffyuvdsp_rvv.o OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_init.o RVV-OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_rvv.o OBJS-$(CONFIG_OPUS_DECODER) += riscv/opusdsp_init.o diff --git a/libavcodec/riscv/huffyuvdsp_init.c b/libavcodec/riscv/huffyuvdsp_init.c new file mode 100644 index 0000000000..115b25881c --- /dev/null +++ b/libavcodec/riscv/huffyuvdsp_init.c @@ -0,0 +1,37 @@ +/* + * Copyright © 2023 Rémi Denis-Courmont. + * + * 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/huffyuvdsp.h" + +void ff_add_int16_rvv(uint16_t *dst, const uint16_t *src, unsigned m, int w); + +av_cold void ff_huffyuvdsp_init_riscv(HuffYUVDSPContext *c, + enum AVPixelFormat pix_fmt) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR)) + c->add_int16 = ff_add_int16_rvv; +#endif +} diff --git a/libavcodec/riscv/huffyuvdsp_rvv.S b/libavcodec/riscv/huffyuvdsp_rvv.S new file mode 100644 index 0000000000..f8926fdaea --- /dev/null +++ b/libavcodec/riscv/huffyuvdsp_rvv.S @@ -0,0 +1,37 @@ +/* + * Copyright © 2023 Rémi Denis-Courmont. + * + * 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_add_int16_rvv, zve32x +1: + vsetvli t0, a3, e16, m8, ta, ma + vle16.v v16, (a0) + sub a3, a3, t0 + vle16.v v24, (a1) + sh1add a1, t0, a1 + vadd.vv v16, v16, v24 + vand.vx v16, v16, a2 + vse16.v v16, (a0) + sh1add a0, t0, a0 + bnez a3, 1b + + ret +endfunc |