diff mbox series

[FFmpeg-devel] lavc/ac3dsp: R-V Zbb ac3_exponent_min

Message ID 20240503180800.49703-1-remi@remlab.net
State Accepted
Commit 9e77188cba63920f51801fbbc1f7be4a995def7a
Headers show
Series [FFmpeg-devel] lavc/ac3dsp: R-V Zbb ac3_exponent_min | expand

Commit Message

RĂ©mi Denis-Courmont May 3, 2024, 6:08 p.m. UTC
SiFive U74:
ac3_exponent_min_reuse0_c:       10.0
ac3_exponent_min_reuse0_rvb_b:    8.0
ac3_exponent_min_reuse1_c:     2924.7
ac3_exponent_min_reuse1_rvb_b: 1803.0
ac3_exponent_min_reuse2_c:     5043.0
ac3_exponent_min_reuse2_rvb_b: 2827.5
ac3_exponent_min_reuse3_c:     7028.7
ac3_exponent_min_reuse3_rvb_b: 3872.0
ac3_exponent_min_reuse4_c:     8824.2
ac3_exponent_min_reuse4_rvb_b: 5122.2
ac3_exponent_min_reuse5_c:    10487.5
ac3_exponent_min_reuse5_rvb_b: 6412.2
---
 libavcodec/riscv/ac3dsp_init.c |  3 +++
 libavcodec/riscv/ac3dsp_rvb.S  | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/riscv/ac3dsp_init.c b/libavcodec/riscv/ac3dsp_init.c
index c7c375273d..8cfa69055a 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_rvb(uint8_t *exp, int, int);
 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);
@@ -39,6 +40,8 @@  av_cold void ff_ac3dsp_init_riscv(AC3DSPContext *c)
 #if HAVE_RV
     int flags = av_get_cpu_flags();
 
+    if (flags & AV_CPU_FLAG_RVB_BASIC)
+        c->ac3_exponent_min = ff_ac3_exponent_min_rvb;
     if (flags & AV_CPU_FLAG_RVV_I32)
         c->ac3_exponent_min = ff_ac3_exponent_min_rvv;
 
diff --git a/libavcodec/riscv/ac3dsp_rvb.S b/libavcodec/riscv/ac3dsp_rvb.S
index 48f8bb101e..0ca56466e1 100644
--- a/libavcodec/riscv/ac3dsp_rvb.S
+++ b/libavcodec/riscv/ac3dsp_rvb.S
@@ -21,6 +21,27 @@ 
 #include "config.h"
 #include "libavutil/riscv/asm.S"
 
+func ff_ac3_exponent_min_rvb, zbb
+        beqz    a1, 3f
+1:
+        addi    a2, a2, -1
+        lb      t3, (a0)
+        addi    t0, a0, 256
+        mv      t1, a1
+2:
+        lb      t4, (t0)
+        addi    t1, t1, -1
+        addi    t0, t0, 256
+        minu    t3, t3, t4
+        bnez    t1, 2b
+
+        sb      t3, (a0)
+        addi    a0, a0, 1
+        bnez    a2, 1b
+3:
+        ret
+endfunc
+
 func ff_extract_exponents_rvb, zbb
 1:
         lw       t0, (a1)