diff mbox series

[FFmpeg-devel,21/31] lavc/audiodsp: RISC-V V vector_clipf

Message ID 20220926145251.56351-21-remi@remlab.net
State Accepted
Commit f127a5d29d7aee99cb4dd4d576d375c678b3c388
Headers show
Series initial RISC-V CPU extensions | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Rémi Denis-Courmont Sept. 26, 2022, 2:52 p.m. UTC
From: Rémi Denis-Courmont <remi@remlab.net>

---
 libavcodec/riscv/audiodsp_init.c |  3 +++
 libavcodec/riscv/audiodsp_rvv.S  | 17 +++++++++++++++++
 2 files changed, 20 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/riscv/audiodsp_init.c b/libavcodec/riscv/audiodsp_init.c
index ac06848a82..9c9265531d 100644
--- a/libavcodec/riscv/audiodsp_init.c
+++ b/libavcodec/riscv/audiodsp_init.c
@@ -28,6 +28,7 @@  void ff_vector_clipf_rvf(float *dst, const float *src, int len, float min, float
 
 void ff_vector_clip_int32_rvv(int32_t *dst, const int32_t *src, int32_t min,
                               int32_t max, unsigned int len);
+void ff_vector_clipf_rvv(float *dst, const float *src, int len, float min, float max);
 
 av_cold void ff_audiodsp_init_riscv(AudioDSPContext *c)
 {
@@ -38,5 +39,7 @@  av_cold void ff_audiodsp_init_riscv(AudioDSPContext *c)
 #if HAVE_RVV
     if (flags & AV_CPU_FLAG_RVV_I32)
         c->vector_clip_int32 = ff_vector_clip_int32_rvv;
+    if (flags & AV_CPU_FLAG_RVV_F32)
+        c->vector_clipf = ff_vector_clipf_rvv;
 #endif
 }
diff --git a/libavcodec/riscv/audiodsp_rvv.S b/libavcodec/riscv/audiodsp_rvv.S
index 49546ee3c4..427b424cb9 100644
--- a/libavcodec/riscv/audiodsp_rvv.S
+++ b/libavcodec/riscv/audiodsp_rvv.S
@@ -34,3 +34,20 @@  func ff_vector_clip_int32_rvv, zve32x
 
         ret
 endfunc
+
+func ff_vector_clipf_rvv, zve32f
+NOHWF   fmv.w.x  fa0, a3
+NOHWF   fmv.w.x  fa1, a4
+1:
+        vsetvli  t0, a2, e32, m1, ta, ma
+        vle32.v  v8, (a1)
+        sub      a2, a2, t0
+        vfmax.vf v8, v8, fa0
+        sh2add   a1, t0, a1
+        vfmin.vf v8, v8, fa1
+        vse32.v  v8, (a0)
+        sh2add   a0, t0, a0
+        bnez     a2, 1b
+
+        ret
+endfunc