diff options
author | Rémi Denis-Courmont <remi@remlab.net> | 2022-09-26 17:52:40 +0300 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2022-09-27 13:19:52 +0200 |
commit | 27da9514c3a7b506e3c3e0ada5dee67566c5aadf (patch) | |
tree | 410ce5f347080e6c42dc836b3f4206e3d3135cc7 | |
parent | c1bb19e263e14887ad286c16352edbaa39be4f66 (diff) | |
download | ffmpeg-27da9514c3a7b506e3c3e0ada5dee67566c5aadf.tar.gz |
lavc/audiodsp: RISC-V V vector_clip_int32
-rw-r--r-- | libavcodec/riscv/Makefile | 1 | ||||
-rw-r--r-- | libavcodec/riscv/audiodsp_init.c | 9 | ||||
-rw-r--r-- | libavcodec/riscv/audiodsp_rvv.S | 36 |
3 files changed, 46 insertions, 0 deletions
diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index da07f1fe96..99541b075e 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -1,4 +1,5 @@ OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o \ riscv/audiodsp_rvf.o +RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o \ riscv/pixblockdsp_rvi.o diff --git a/libavcodec/riscv/audiodsp_init.c b/libavcodec/riscv/audiodsp_init.c index c5842815d6..ac06848a82 100644 --- a/libavcodec/riscv/audiodsp_init.c +++ b/libavcodec/riscv/audiodsp_init.c @@ -18,16 +18,25 @@ * 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/audiodsp.h" void ff_vector_clipf_rvf(float *dst, const float *src, int len, float min, float max); +void ff_vector_clip_int32_rvv(int32_t *dst, const int32_t *src, int32_t min, + int32_t max, unsigned int len); + av_cold void ff_audiodsp_init_riscv(AudioDSPContext *c) { int flags = av_get_cpu_flags(); if (flags & AV_CPU_FLAG_RVF) c->vector_clipf = ff_vector_clipf_rvf; +#if HAVE_RVV + if (flags & AV_CPU_FLAG_RVV_I32) + c->vector_clip_int32 = ff_vector_clip_int32_rvv; +#endif } diff --git a/libavcodec/riscv/audiodsp_rvv.S b/libavcodec/riscv/audiodsp_rvv.S new file mode 100644 index 0000000000..49546ee3c4 --- /dev/null +++ b/libavcodec/riscv/audiodsp_rvv.S @@ -0,0 +1,36 @@ +/* + * Copyright © 2022 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_vector_clip_int32_rvv, zve32x +1: + vsetvli t0, a4, e32, m1, ta, ma + vle32.v v8, (a1) + sub a4, a4, t0 + vmax.vx v8, v8, a2 + sh2add a1, t0, a1 + vmin.vx v8, v8, a3 + vse32.v v8, (a0) + sh2add a0, t0, a0 + bnez a4, 1b + + ret +endfunc |