This is restricted to 128-bit vectors as larger vector sizes could read past the end of the noise array. Support for future hardware with larger vector sizes is left for some other time. hf_apply_noise_0_c: 2319.7 hf_apply_noise_0_rvv_f32: 1229.0 hf_apply_noise_1_c: 2539.0 hf_apply_noise_1_rvv_f32: 1244.7 hf_apply_noise_2_c: 2319.7 hf_apply_noise_2_rvv_f32: 1232.7 hf_apply_noise_3_c: 2541.2 hf_apply_noise_3_rvv_f32: 1244.2
Showing the changes to libavcodec (2 of 2 files). Show all
Unified · Split
| @@ -21,6 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | #include "config.h" |
| 22 | 22 | #include "libavutil/attributes.h" |
| 23 | 23 | #include "libavutil/cpu.h" |
| 24 | +#include "libavutil/riscv/cpu.h" | |
| 24 | 25 | #include "libavcodec/sbrdsp.h" |
| 25 | 26 | |
| 26 | 27 | void ff_sbr_sum64x5_rvv(float *z); |
| @@ -32,6 +33,14 @@ void ff_sbr_hf_gen_rvv(float (*X_high)[2], const float (*X_low)[2], · 5 unmodified lines | ||
| 32 | 33 | float bw, int start, int end); |
| 33 | 34 | void ff_sbr_hf_g_filt_rvv(float (*Y)[2], const float (*X_high)[40][2], |
| 34 | 35 | const float *g_filt, int m_max, intptr_t ixh); |
| 36 | +void ff_sbr_hf_apply_noise_0_rvv(float (*Y)[2], const float *s, | |
| 37 | + const float *f, int n, int kx, int max); | |
| 38 | +void ff_sbr_hf_apply_noise_1_rvv(float (*Y)[2], const float *s, | |
| 39 | + const float *f, int n, int kx, int max); | |
| 40 | +void ff_sbr_hf_apply_noise_2_rvv(float (*Y)[2], const float *s, | |
| 41 | + const float *f, int n, int kx, int max); | |
| 42 | +void ff_sbr_hf_apply_noise_3_rvv(float (*Y)[2], const float *s, | |
| 43 | + const float *f, int n, int kx, int max); | |
| 35 | 44 | |
| 36 | 45 | av_cold void ff_sbrdsp_init_riscv(SBRDSPContext *c) |
| 37 | 46 | { |
| @@ -44,6 +53,14 @@ av_cold void ff_sbrdsp_init_riscv(SBRDSPContext *c) · 6 unmodified lines | ||
| 44 | 53 | c->sum_square = ff_sbr_sum_square_rvv; |
| 45 | 54 | c->hf_gen = ff_sbr_hf_gen_rvv; |
| 46 | 55 | c->hf_g_filt = ff_sbr_hf_g_filt_rvv; |
| 56 | + if (ff_get_rv_vlenb() <= 16) { | |
| 57 | + c->hf_apply_noise[0] = ff_sbr_hf_apply_noise_0_rvv; | |
| 58 | + c->hf_apply_noise[2] = ff_sbr_hf_apply_noise_2_rvv; | |
| 59 | + if (flags & AV_CPU_FLAG_RVB_BASIC) { | |
| 60 | + c->hf_apply_noise[1] = ff_sbr_hf_apply_noise_1_rvv; | |
| 61 | + c->hf_apply_noise[3] = ff_sbr_hf_apply_noise_3_rvv; | |
| 62 | + } | |
| 63 | + } | |
| 47 | 64 | } |
| 48 | 65 | c->autocorrelate = ff_sbr_autocorrelate_rvv; |
| 49 | 66 | } |
| @@ -243,3 +243,70 @@ func ff_sbr_hf_g_filt_rvv, zve32f · 242 unmodified lines | ||
| 243 | 243 | |
| 244 | 244 | ret |
| 245 | 245 | endfunc |
| 246 | + | |
| 247 | +.macro hf_apply_noise n | |
| 248 | + lla a6, ff_sbr_noise_table | |
| 249 | + fmv.s.x ft0, zero | |
| 250 | + addi a6, a6, 8 | |
| 251 | +1: | |
| 252 | +.if \n & 1 | |
| 253 | + min t0, t0, a5 // preserve parity of t0 for v4 sign injector | |
| 254 | + vsetvli zero, t0, e32, m4, ta, mu | |
| 255 | +.else | |
| 256 | + vsetvli t0, a5, e32, m4, ta, mu | |
| 257 | +.endif | |
| 258 | + sh3add t6, a3, a6 | |
| 259 | + vle32.v v8, (a1) // s_m | |
| 260 | + sub a5, a5, t0 | |
| 261 | + vle32.v v12, (a2) // q_filt | |
| 262 | + sh2add a1, t0, a1 | |
| 263 | + vmfeq.vf v0, v8, ft0 // s_m == 0.f | |
| 264 | + vlseg2e32.v v24, (t6) // ff_sbr_noise_table | |
| 265 | + sh2add a2, t0, a2 | |
| 266 | +.if \n == 2 | |
| 267 | + vfneg.v v8, v8 | |
| 268 | +.endif | |
| 269 | +.if \n & 1 | |
| 270 | + vfsgnjx.vv v8, v8, v4 // could equivalent use vxor.vv | |
| 271 | +.endif | |
| 272 | + add a3, t0, a3 | |
| 273 | + vlseg2e32.v v16, (a0) // Y | |
| 274 | + andi a3, a3, 0x1ff | |
| 275 | +.if \n & 1 | |
| 276 | + vfmul.vv v28, v12, v28 | |
| 277 | + vfmacc.vv v16, v12, v24, v0.t | |
| 278 | + vmerge.vvm v28, v8, v28, v0 | |
| 279 | + vfadd.vv v20, v20, v28 | |
| 280 | +.else | |
| 281 | + vfmul.vv v24, v12, v24 | |
| 282 | + vfmacc.vv v20, v12, v28, v0.t | |
| 283 | + vmerge.vvm v24, v8, v24, v0 | |
| 284 | + vfadd.vv v16, v16, v24 | |
| 285 | +.endif | |
| 286 | + vsseg2e32.v v16, (a0) | |
| 287 | + sh3add a0, t0, a0 | |
| 288 | + bnez a5, 1b | |
| 289 | + | |
| 290 | + ret | |
| 291 | +.endm | |
| 292 | + | |
| 293 | +func ff_sbr_hf_apply_noise_0_rvv, zve32f | |
| 294 | + hf_apply_noise 0 | |
| 295 | +endfunc | |
| 296 | + | |
| 297 | +func ff_sbr_hf_apply_noise_3_rvv, zve32f | |
| 298 | + not a4, a4 // invert parity of kx | |
| 299 | + // fall through | |
| 300 | +endfunc | |
| 301 | + | |
| 302 | +func ff_sbr_hf_apply_noise_1_rvv, zve32f | |
| 303 | + vsetvli t0, zero, e32, m4, ta, ma | |
| 304 | + vid.v v4 | |
| 305 | + vxor.vx v4, v4, a4 | |
| 306 | + vsll.vi v4, v4, 31 // v4[i] = (kx & 1) ? -0.f : +0.f | |
| 307 | + hf_apply_noise 1 | |
| 308 | +endfunc | |
| 309 | + | |
| 310 | +func ff_sbr_hf_apply_noise_2_rvv, zve32f | |
| 311 | + hf_apply_noise 2 | |
| 312 | +endfunc | |