lavc/audiodsp: RISC-V V vector_clip_int32

This commit is contained in:
Rémi Denis-Courmont 2022-09-26 17:52:40 +03:00 committed by Lynne
parent c1bb19e263
commit 27da9514c3
3 changed files with 46 additions and 0 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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