FFmpeg
sbrdsp_init.c
Go to the documentation of this file.
1 /*
2  * Copyright © 2023 Rémi Denis-Courmont.
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "config.h"
22 #include "libavutil/attributes.h"
23 #include "libavutil/cpu.h"
24 #include "libavutil/riscv/cpu.h"
25 #include "libavcodec/sbrdsp.h"
26 
27 void ff_sbr_sum64x5_rvv(float *z);
28 float ff_sbr_sum_square_rvv(float (*x)[2], int n);
29 void ff_sbr_neg_odd_64_rvv(float *x);
30 void ff_sbr_autocorrelate_rvv(const float x[40][2], float phi[3][2][2]);
31 void ff_sbr_hf_gen_rvv(float (*X_high)[2], const float (*X_low)[2],
32  const float alpha0[2], const float alpha1[2],
33  float bw, int start, int end);
34 void ff_sbr_hf_g_filt_rvv(float (*Y)[2], const float (*X_high)[40][2],
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);
44 
46 {
47 #if HAVE_RVV
48  int flags = av_get_cpu_flags();
49 
50  if (flags & AV_CPU_FLAG_RVV_F32) {
52  c->sum64x5 = ff_sbr_sum64x5_rvv;
53  c->sum_square = ff_sbr_sum_square_rvv;
54  c->hf_gen = ff_sbr_hf_gen_rvv;
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;
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  }
64  }
65  c->autocorrelate = ff_sbr_autocorrelate_rvv;
66  }
67 #if __riscv_xlen >= 64
69  c->neg_odd_64 = ff_sbr_neg_odd_64_rvv;
70 #endif
71 #endif
72 }
ff_sbr_hf_apply_noise_1_rvv
void ff_sbr_hf_apply_noise_1_rvv(float(*Y)[2], const float *s, const float *f, int n, int kx, int max)
AV_CPU_FLAG_RVB_BASIC
#define AV_CPU_FLAG_RVB_BASIC
Basic bit-manipulations.
Definition: cpu.h:91
SBRDSPContext
Definition: sbrdsp.h:27
ff_sbr_autocorrelate_rvv
void ff_sbr_autocorrelate_rvv(const float x[40][2], float phi[3][2][2])
ff_sbrdsp_init_riscv
av_cold void ff_sbrdsp_init_riscv(SBRDSPContext *c)
Definition: sbrdsp_init.c:45
ff_sbr_sum64x5_rvv
void ff_sbr_sum64x5_rvv(float *z)
max
#define max(a, b)
Definition: cuda_runtime.h:33
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:103
AV_CPU_FLAG_RVV_F32
#define AV_CPU_FLAG_RVV_F32
Vectors of float's *‍/.
Definition: cpu.h:88
ff_sbr_hf_apply_noise_0_rvv
void ff_sbr_hf_apply_noise_0_rvv(float(*Y)[2], const float *s, const float *f, int n, int kx, int max)
av_cold
#define av_cold
Definition: attributes.h:90
s
#define s(width, name)
Definition: cbs_vp9.c:198
cpu.h
AV_CPU_FLAG_RVB_ADDR
#define AV_CPU_FLAG_RVB_ADDR
Address bit-manipulations.
Definition: cpu.h:92
ff_sbr_hf_apply_noise_2_rvv
void ff_sbr_hf_apply_noise_2_rvv(float(*Y)[2], const float *s, const float *f, int n, int kx, int max)
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
f
f
Definition: af_crystalizer.c:121
cpu.h
sbrdsp.h
ff_sbr_sum_square_rvv
float ff_sbr_sum_square_rvv(float(*x)[2], int n)
attributes.h
Y
#define Y
Definition: boxblur.h:37
ff_sbr_hf_apply_noise_3_rvv
void ff_sbr_hf_apply_noise_3_rvv(float(*Y)[2], const float *s, const float *f, int n, int kx, int max)
ff_sbr_hf_g_filt_rvv
void ff_sbr_hf_g_filt_rvv(float(*Y)[2], const float(*X_high)[40][2], const float *g_filt, int m_max, intptr_t ixh)
ff_sbr_hf_gen_rvv
void ff_sbr_hf_gen_rvv(float(*X_high)[2], const float(*X_low)[2], const float alpha0[2], const float alpha1[2], float bw, int start, int end)
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
ff_sbr_neg_odd_64_rvv
void ff_sbr_neg_odd_64_rvv(float *x)
AV_CPU_FLAG_RVV_I64
#define AV_CPU_FLAG_RVV_I64
Vectors of 64-bit int's *‍/.
Definition: cpu.h:89