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_autocorrelate_rvv(const float x[40][2], float phi[3][2][2]);
30 void ff_sbr_hf_gen_rvv(float (*X_high)[2], const float (*X_low)[2],
31  const float alpha0[2], const float alpha1[2],
32  float bw, int start, int end);
33 void ff_sbr_hf_g_filt_rvv(float (*Y)[2], const float (*X_high)[40][2],
34  const float *g_filt, int m_max, intptr_t ixh);
35 void ff_sbr_hf_apply_noise_0_rvv(float (*Y)[2], const float *s,
36  const float *f, int n, int kx, int max);
37 void ff_sbr_hf_apply_noise_1_rvv(float (*Y)[2], const float *s,
38  const float *f, int n, int kx, int max);
39 void ff_sbr_hf_apply_noise_2_rvv(float (*Y)[2], const float *s,
40  const float *f, int n, int kx, int max);
41 void ff_sbr_hf_apply_noise_3_rvv(float (*Y)[2], const float *s,
42  const float *f, int n, int kx, int max);
43 
45 {
46 #if HAVE_RVV
47  int flags = av_get_cpu_flags();
48 
49  if (flags & AV_CPU_FLAG_RVV_F32) {
50  if (flags & AV_CPU_FLAG_RVB) {
51  c->sum64x5 = ff_sbr_sum64x5_rvv;
52  c->sum_square = ff_sbr_sum_square_rvv;
53  c->hf_gen = ff_sbr_hf_gen_rvv;
54  c->hf_g_filt = ff_sbr_hf_g_filt_rvv;
55  if (ff_get_rv_vlenb() <= 32) {
56  c->hf_apply_noise[0] = ff_sbr_hf_apply_noise_0_rvv;
57  c->hf_apply_noise[2] = ff_sbr_hf_apply_noise_2_rvv;
58  c->hf_apply_noise[1] = ff_sbr_hf_apply_noise_1_rvv;
59  c->hf_apply_noise[3] = ff_sbr_hf_apply_noise_3_rvv;
60  }
61  }
62  c->autocorrelate = ff_sbr_autocorrelate_rvv;
63  }
64 #endif
65 }
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)
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:44
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:109
AV_CPU_FLAG_RVB
#define AV_CPU_FLAG_RVB
B (bit manipulations)
Definition: cpu.h:102
AV_CPU_FLAG_RVV_F32
#define AV_CPU_FLAG_RVV_F32
Vectors of float's *‍/.
Definition: cpu.h:93
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
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:122
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