31 for (i = 0; i <
len; i++)
32 dst[i] = src0[i] * src1[i];
39 for (i = 0; i <
len; i++)
40 dst[i] += src[i] * mul;
47 for (i = 0; i <
len; i++)
48 dst[i] = src[i] * mul;
55 for (i = 0; i <
len; i++)
56 dst[i] = src[i] * mul;
60 const float *
src1,
const float *win,
int len)
68 for (i = -len, j = len - 1; i < 0; i++, j--) {
73 dst[i] = s0 * wj - s1 * wi;
74 dst[j] = s0 * wi + s1 * wj;
79 const float *src2,
int len){
82 for (i = 0; i <
len; i++)
83 dst[i] = src0[i] * src1[i] + src2[i];
92 for (i = 0; i <
len; i++)
93 dst[i] = src0[i] * src1[-i];
101 for (i = 0; i <
len; i++) {
102 float t = v1[i] - v2[i];
113 for (i = 0; i <
len; i++)
168 #include "internal.h"
175 static void fill_float_array(
AVLFG *lfg,
float *
a,
int len)
178 double bmg[2], stddev = 10.0, mean = 0.0;
180 for (i = 0; i <
len; i += 2) {
182 a[i] = bmg[0] * stddev + mean;
183 a[i + 1] = bmg[1] * stddev + mean;
186 static int compare_floats(
const float *a,
const float *
b,
int len,
190 for (i = 0; i <
len; i++) {
191 if (fabsf(a[i] - b[i]) > max_diff) {
193 i, a[i], b[i], a[i] - b[i]);
200 static void fill_double_array(
AVLFG *lfg,
double *a,
int len)
203 double bmg[2], stddev = 10.0, mean = 0.0;
205 for (i = 0; i <
len; i += 2) {
207 a[i] = bmg[0] * stddev + mean;
208 a[i + 1] = bmg[1] * stddev + mean;
212 static int compare_doubles(
const double *a,
const double *b,
int len,
217 for (i = 0; i <
len; i++) {
218 if (fabs(a[i] - b[i]) > max_diff) {
220 i, a[i], b[i], a[i] - b[i]);
228 const float *v1,
const float *v2)
237 if (ret = compare_floats(cdst, odst,
LEN, FLT_EPSILON))
243 #define ARBITRARY_FMAC_SCALAR_CONST 0.005
245 const float *v1,
const float *
src0,
float scale)
251 memcpy(cdst, v1,
LEN *
sizeof(*v1));
252 memcpy(odst, v1,
LEN *
sizeof(*v1));
257 if (ret = compare_floats(cdst, odst,
LEN, ARBITRARY_FMAC_SCALAR_CONST))
264 const float *v1,
float scale)
273 if (ret = compare_floats(cdst, odst,
LEN, FLT_EPSILON))
280 const double *v1,
double scale)
289 if (ret = compare_doubles(cdst, odst,
LEN, DBL_EPSILON))
295 #define ARBITRARY_FMUL_WINDOW_CONST 0.008
297 const float *v1,
const float *v2,
const float *v3)
306 if (ret = compare_floats(cdst, odst,
LEN, ARBITRARY_FMUL_WINDOW_CONST))
312 #define ARBITRARY_FMUL_ADD_CONST 0.005
314 const float *v1,
const float *v2,
const float *v3)
323 if (ret = compare_floats(cdst, odst,
LEN, ARBITRARY_FMUL_ADD_CONST))
330 const float *v1,
const float *v2)
339 if (ret = compare_floats(cdst, odst,
LEN, FLT_EPSILON))
346 const float *v1,
const float *v2)
354 memcpy(cv1, v1,
LEN *
sizeof(*v1));
355 memcpy(cv2, v2,
LEN *
sizeof(*v2));
356 memcpy(ov1, v1,
LEN *
sizeof(*v1));
357 memcpy(ov2, v2,
LEN *
sizeof(*v2));
362 if ((ret = compare_floats(cv1, ov1,
LEN, FLT_EPSILON)) ||
363 (ret = compare_floats(cv2, ov2,
LEN, FLT_EPSILON)))
369 #define ARBITRARY_SCALARPRODUCT_CONST 0.2
371 const float *v1,
const float *v2)
379 if (ret = compare_floats(&cprod, &oprod, 1, ARBITRARY_SCALARPRODUCT_CONST))
385 int main(
int argc,
char **argv)
387 int ret = 0, seeded = 0;
426 fill_float_array(&lfg, src0,
LEN);
427 fill_float_array(&lfg,
src1,
LEN);
428 fill_float_array(&lfg, src2,
LEN);
430 fill_double_array(&lfg, dbl_src0,
LEN);
431 fill_double_array(&lfg, dbl_src1,
LEN);
437 if (test_vector_fmul(&fdsp, &cdsp, src0,
src1))
439 if (test_vector_fmac_scalar(&fdsp, &cdsp, src2, src0,
src1[0]))
441 if (test_vector_fmul_scalar(&fdsp, &cdsp, src0,
src1[0]))
443 if (test_vector_fmul_window(&fdsp, &cdsp, src0,
src1, src2))
445 if (test_vector_fmul_add(&fdsp, &cdsp, src0,
src1, src2))
447 if (test_vector_fmul_reverse(&fdsp, &cdsp, src0,
src1))
449 if (test_butterflies_float(&fdsp, &cdsp, src0,
src1))
451 if (test_scalarproduct_float(&fdsp, &cdsp, src0,
src1))
453 if (test_vector_dmul_scalar(&fdsp, &cdsp, dbl_src0, dbl_src1[0]))
void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp)
static void vector_fmul_scalar_c(float *dst, const float *src, float mul, int len)
memory handling functions
float(* scalarproduct_float)(const float *v1, const float *v2, int len)
Calculate the scalar product of two vectors of floats.
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...
void ff_float_dsp_init_mips(AVFloatDSPContext *fdsp)
Macro definitions for various function/variable attributes.
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.
float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len)
Return the scalar product of two vectors.
void(* vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len)
Overlap/add with window function.
av_cold void ff_float_dsp_init_aarch64(AVFloatDSPContext *fdsp)
av_cold void ff_float_dsp_init_arm(AVFloatDSPContext *fdsp)
static void butterflies_float_c(float *av_restrict v1, float *av_restrict v2, int len)
void av_bmg_get(AVLFG *lfg, double out[2])
Get the next two numbers generated by a Box-Muller Gaussian generator using the random numbers issued...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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...
void(* butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len)
Calculate the sum and difference of two vectors of floats.
static void vector_fmul_add_c(float *dst, const float *src0, const float *src1, const float *src2, int len)
void(* vector_dmul_scalar)(double *dst, const double *src, double mul, int len)
Multiply a vector of double by a scalar double.
int av_parse_cpu_caps(unsigned *flags, const char *s)
Parse CPU caps from a string and update the given AV_CPU_* flags based on that.
static void vector_dmul_scalar_c(double *dst, const double *src, double mul, int len)
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
#define AV_LOG_INFO
Standard information.
void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int strict)
static int getopt(int argc, char *argv[], char *opts)
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...
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
Initialize a float DSP context.
static void vector_fmul_window_c(float *dst, const float *src0, const float *src1, const float *win, int len)
common internal and external API header
#define LOCAL_ALIGNED(a, t, v,...)
static void vector_fmul_c(float *dst, const float *src0, const float *src1, int len)
static void vector_fmac_scalar_c(float *dst, const float *src, float mul, int len)
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
void av_force_cpu_flags(int arg)
Disables cpu detection and forces the specified flags.
int main(int argc, char **argv)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static void vector_fmul_reverse_c(float *dst, const float *src0, const float *src1, int len)