FFmpeg
float_dsp.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef AVUTIL_FLOAT_DSP_H
20 #define AVUTIL_FLOAT_DSP_H
21 
22 typedef struct AVFloatDSPContext {
23  /**
24  * Calculate the entry wise product of two vectors of floats and store the result in
25  * a vector of floats.
26  *
27  * @param dst output vector
28  * constraints: 32-byte aligned
29  * @param src0 first input vector
30  * constraints: 32-byte aligned
31  * @param src1 second input vector
32  * constraints: 32-byte aligned
33  * @param len number of elements in the input
34  * constraints: multiple of 16
35  */
36  void (*vector_fmul)(float *dst, const float *src0, const float *src1,
37  int len);
38 
39  /**
40  * Multiply a vector of floats by a scalar float and add to
41  * destination vector. Source and destination vectors must
42  * overlap exactly or not at all.
43  *
44  * @param dst result vector
45  * constraints: 32-byte aligned
46  * @param src input vector
47  * constraints: 32-byte aligned
48  * @param mul scalar value
49  * @param len length of vector
50  * constraints: multiple of 16
51  */
52  void (*vector_fmac_scalar)(float *dst, const float *src, float mul,
53  int len);
54 
55  /**
56  * Multiply a vector of doubles by a scalar double and add to
57  * destination vector. Source and destination vectors must
58  * overlap exactly or not at all.
59  *
60  * @param dst result vector
61  * constraints: 32-byte aligned
62  * @param src input vector
63  * constraints: 32-byte aligned
64  * @param mul scalar value
65  * @param len length of vector
66  * constraints: multiple of 16
67  */
68  void (*vector_dmac_scalar)(double *dst, const double *src, double mul,
69  int len);
70 
71  /**
72  * Multiply a vector of floats by a scalar float. Source and
73  * destination vectors must overlap exactly or not at all.
74  *
75  * @param dst result vector
76  * constraints: 16-byte aligned
77  * @param src input vector
78  * constraints: 16-byte aligned
79  * @param mul scalar value
80  * @param len length of vector
81  * constraints: multiple of 4
82  */
83  void (*vector_fmul_scalar)(float *dst, const float *src, float mul,
84  int len);
85 
86  /**
87  * Multiply a vector of double by a scalar double. Source and
88  * destination vectors must overlap exactly or not at all.
89  *
90  * @param dst result vector
91  * constraints: 32-byte aligned
92  * @param src input vector
93  * constraints: 32-byte aligned
94  * @param mul scalar value
95  * @param len length of vector
96  * constraints: multiple of 8
97  */
98  void (*vector_dmul_scalar)(double *dst, const double *src, double mul,
99  int len);
100 
101  /**
102  * Overlap/add with window function.
103  * Used primarily by MDCT-based audio codecs.
104  * Source and destination vectors must overlap exactly or not at all.
105  *
106  * @param dst result vector
107  * constraints: 16-byte aligned
108  * @param src0 first source vector
109  * constraints: 16-byte aligned
110  * @param src1 second source vector
111  * constraints: 16-byte aligned
112  * @param win half-window vector
113  * constraints: 16-byte aligned
114  * @param len length of vector
115  * constraints: multiple of 4
116  */
117  void (*vector_fmul_window)(float *dst, const float *src0,
118  const float *src1, const float *win, int len);
119 
120  /**
121  * Calculate the entry wise product of two vectors of floats, add a third vector of
122  * floats and store the result in a vector of floats.
123  *
124  * @param dst output vector
125  * constraints: 32-byte aligned
126  * @param src0 first input vector
127  * constraints: 32-byte aligned
128  * @param src1 second input vector
129  * constraints: 32-byte aligned
130  * @param src2 third input vector
131  * constraints: 32-byte aligned
132  * @param len number of elements in the input
133  * constraints: multiple of 16
134  */
135  void (*vector_fmul_add)(float *dst, const float *src0, const float *src1,
136  const float *src2, int len);
137 
138  /**
139  * Calculate the entry wise product of two vectors of floats, and store the result
140  * in a vector of floats. The second vector of floats is iterated over
141  * in reverse order.
142  *
143  * @param dst output vector
144  * constraints: 32-byte aligned
145  * @param src0 first input vector
146  * constraints: 32-byte aligned
147  * @param src1 second input vector
148  * constraints: 32-byte aligned
149  * @param len number of elements in the input
150  * constraints: multiple of 16
151  */
152  void (*vector_fmul_reverse)(float *dst, const float *src0,
153  const float *src1, int len);
154 
155  /**
156  * Calculate the sum and difference of two vectors of floats.
157  *
158  * @param v1 first input vector, sum output, 16-byte aligned
159  * @param v2 second input vector, difference output, 16-byte aligned
160  * @param len length of vectors, multiple of 4
161  */
162  void (*butterflies_float)(float *restrict v1, float *restrict v2, int len);
163 
164  /**
165  * Calculate the scalar product of two vectors of floats.
166  *
167  * @param v1 first vector, 16-byte aligned
168  * @param v2 second vector, 16-byte aligned
169  * @param len length of vectors, multiple of 4
170  *
171  * @return sum of elementwise products
172  */
173  float (*scalarproduct_float)(const float *v1, const float *v2, int len);
174 
175  /**
176  * Calculate the entry wise product of two vectors of doubles and store the result in
177  * a vector of doubles.
178  *
179  * @param dst output vector
180  * constraints: 32-byte aligned
181  * @param src0 first input vector
182  * constraints: 32-byte aligned
183  * @param src1 second input vector
184  * constraints: 32-byte aligned
185  * @param len number of elements in the input
186  * constraints: multiple of 16
187  */
188  void (*vector_dmul)(double *dst, const double *src0, const double *src1,
189  int len);
191 
192 /**
193  * Return the scalar product of two vectors.
194  *
195  * @param v1 first input vector
196  * @param v2 first input vector
197  * @param len number of elements
198  *
199  * @return sum of elementwise products
200  */
201 float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len);
202 
205 void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int strict);
209 
210 /**
211  * Allocate a float DSP context.
212  *
213  * @param strict setting to non-zero avoids using functions which may not be IEEE-754 compliant
214  */
216 
217 #endif /* AVUTIL_FLOAT_DSP_H */
AVFloatDSPContext::butterflies_float
void(* butterflies_float)(float *restrict v1, float *restrict v2, int len)
Calculate the sum and difference of two vectors of floats.
Definition: float_dsp.h:162
src1
const pixel * src1
Definition: h264pred_template.c:421
AVFloatDSPContext::vector_fmul_reverse
void(* vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len)
Calculate the entry wise product of two vectors of floats, and store the result in a vector of floats...
Definition: float_dsp.h:152
AVFloatDSPContext::vector_dmul
void(* vector_dmul)(double *dst, const double *src0, const double *src1, int len)
Calculate the entry wise product of two vectors of doubles and store the result in a vector of double...
Definition: float_dsp.h:188
avpriv_float_dsp_alloc
AVFloatDSPContext * avpriv_float_dsp_alloc(int strict)
Allocate a float DSP context.
Definition: float_dsp.c:135
win
static float win(SuperEqualizerContext *s, float n, int N)
Definition: af_superequalizer.c:119
ff_float_dsp_init_ppc
void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int strict)
Definition: float_dsp_init.c:29
avpriv_scalarproduct_float_c
float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len)
Return the scalar product of two vectors.
Definition: float_dsp.c:124
float
float
Definition: af_crystalizer.c:121
AVFloatDSPContext::scalarproduct_float
float(* scalarproduct_float)(const float *v1, const float *v2, int len)
Calculate the scalar product of two vectors of floats.
Definition: float_dsp.h:173
AVFloatDSPContext::vector_fmul_scalar
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
Definition: float_dsp.h:83
ff_float_dsp_init_arm
void ff_float_dsp_init_arm(AVFloatDSPContext *fdsp)
Definition: float_dsp_init_arm.c:24
ff_float_dsp_init_riscv
void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp)
Definition: float_dsp_init.c:50
AVFloatDSPContext::vector_fmul
void(* vector_fmul)(float *dst, const float *src0, const float *src1, int len)
Calculate the entry wise product of two vectors of floats and store the result in a vector of floats.
Definition: float_dsp.h:36
ff_float_dsp_init_mips
void ff_float_dsp_init_mips(AVFloatDSPContext *fdsp)
Definition: float_dsp_mips.c:346
AVFloatDSPContext
Definition: float_dsp.h:22
AVFloatDSPContext::vector_fmac_scalar
void(* vector_fmac_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float and add to destination vector.
Definition: float_dsp.h:52
src2
const pixel * src2
Definition: h264pred_template.c:422
ff_float_dsp_init_aarch64
void ff_float_dsp_init_aarch64(AVFloatDSPContext *fdsp)
Definition: float_dsp_init.c:54
AVFloatDSPContext::vector_fmul_add
void(* vector_fmul_add)(float *dst, const float *src0, const float *src1, const float *src2, int len)
Calculate the entry wise product of two vectors of floats, add a third vector of floats and store the...
Definition: float_dsp.h:135
len
int len
Definition: vorbis_enc_data.h:426
AVFloatDSPContext::vector_dmul_scalar
void(* vector_dmul_scalar)(double *dst, const double *src, double mul, int len)
Multiply a vector of double by a scalar double.
Definition: float_dsp.h:98
ff_float_dsp_init_x86
void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp)
Definition: float_dsp_init.c:78
src0
const pixel *const src0
Definition: h264pred_template.c:420
AVFloatDSPContext::vector_fmul_window
void(* vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len)
Overlap/add with window function.
Definition: float_dsp.h:117
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
AVFloatDSPContext::vector_dmac_scalar
void(* vector_dmac_scalar)(double *dst, const double *src, double mul, int len)
Multiply a vector of doubles by a scalar double and add to destination vector.
Definition: float_dsp.h:68