diff mbox series

[FFmpeg-devel,3/3] lavc/ac3dsp: R-V V min_exponents

Message ID 20240501064008.16802-1-remi@remlab.net
State Accepted
Commit 38f67a32b3831c8dd0b34db888c16d4a7af9091c
Headers show
Series [FFmpeg-devel,1/2] lavc/ac3dsp: R-V V sum_square_butterfly_int32 | expand

Commit Message

RĂ©mi Denis-Courmont May 1, 2024, 6:40 a.m. UTC
T-Head C908:
ac3_exponent_min_reuse0_c:         7.5
ac3_exponent_min_reuse0_rvv_i32:   7.5
ac3_exponent_min_reuse1_c:      1820.7
ac3_exponent_min_reuse1_rvv_i32: 102.5
ac3_exponent_min_reuse2_c:      3088.5
ac3_exponent_min_reuse2_rvv_i32: 138.7
ac3_exponent_min_reuse3_c:      5073.7
ac3_exponent_min_reuse3_rvv_i32: 174.7
ac3_exponent_min_reuse4_c:      4624.2
ac3_exponent_min_reuse4_rvv_i32: 204.2
ac3_exponent_min_reuse5_c:      5138.7
ac3_exponent_min_reuse5_rvv_i32: 238.0
---
 libavcodec/riscv/ac3dsp_init.c |  4 ++++
 libavcodec/riscv/ac3dsp_rvv.S  | 22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/riscv/ac3dsp_init.c b/libavcodec/riscv/ac3dsp_init.c
index e120aa2dce..c7c375273d 100644
--- a/libavcodec/riscv/ac3dsp_init.c
+++ b/libavcodec/riscv/ac3dsp_init.c
@@ -26,6 +26,7 @@ 
 #include "libavutil/cpu.h"
 #include "libavcodec/ac3dsp.h"
 
+void ff_ac3_exponent_min_rvv(uint8_t *exp, int, int);
 void ff_extract_exponents_rvb(uint8_t *exp, int32_t *coef, int nb_coefs);
 void ff_float_to_fixed24_rvv(int32_t *dst, const float *src, size_t len);
 void ff_sum_square_butterfly_int32_rvv(int64_t *, const int32_t *,
@@ -38,6 +39,9 @@  av_cold void ff_ac3dsp_init_riscv(AC3DSPContext *c)
 #if HAVE_RV
     int flags = av_get_cpu_flags();
 
+    if (flags & AV_CPU_FLAG_RVV_I32)
+        c->ac3_exponent_min = ff_ac3_exponent_min_rvv;
+
     if (flags & AV_CPU_FLAG_RVB_ADDR) {
         if (flags & AV_CPU_FLAG_RVB_BASIC)
             c->extract_exponents = ff_extract_exponents_rvb;
diff --git a/libavcodec/riscv/ac3dsp_rvv.S b/libavcodec/riscv/ac3dsp_rvv.S
index 397e000ab0..1b5f67a9ec 100644
--- a/libavcodec/riscv/ac3dsp_rvv.S
+++ b/libavcodec/riscv/ac3dsp_rvv.S
@@ -21,6 +21,28 @@ 
 #include "config.h"
 #include "libavutil/riscv/asm.S"
 
+func ff_ac3_exponent_min_rvv, zve32x
+        beqz     a1, 3f
+1:
+        vsetvli  t2, a2, e8, m8, ta, ma
+        vle8.v   v8, (a0)
+        addi     t0, a0, 256
+        sub      a2, a2, t2
+        mv       t1, a1
+2:
+        vle8.v   v16, (t0)
+        addi     t1, t1, -1
+        vminu.vv v8, v8, v16
+        addi     t0, t0, 256
+        bnez     t1, 2b
+
+        vse8.v   v8, (a0)
+        add      a0, a0, t2
+        bnez     a2, 1b
+3:
+        ret
+endfunc
+
 func ff_float_to_fixed24_rvv, zve32f
         li            t1, 1 << 24
         fcvt.s.w      f0, t1