23 static void vector_fmul_c(
float *dst,
const float *src0,
const float *src1,
27 for (i = 0; i <
len; i++)
28 dst[i] = src0[i] * src1[i];
35 for (i = 0; i <
len; i++)
36 dst[i] += src[i] * mul;
43 for (i = 0; i <
len; i++)
44 dst[i] = src[i] * mul;
51 for (i = 0; i <
len; i++)
52 dst[i] = src[i] * mul;
56 const float *src1,
const float *win,
int len)
64 for (i = -len, j = len - 1; i < 0; i++, j--) {
69 dst[i] = s0 * wj - s1 * wi;
70 dst[j] = s0 * wi + s1 * wj;
75 const float *src2,
int len){
78 for (i = 0; i <
len; i++)
79 dst[i] = src0[i] * src1[i] + src2[i];
83 const float *src1,
int len)
88 for (i = 0; i <
len; i++)
89 dst[i] = src0[i] * src1[-i];
97 for (i = 0; i <
len; i++) {
98 float t = v1[i] - v2[i];
109 for (i = 0; i <
len; i++)
147 #include "internal.h" 155 static void fill_float_array(
AVLFG *lfg,
float *
a,
int len)
158 double bmg[2], stddev = 10.0, mean = 0.0;
160 for (i = 0; i <
len; i += 2) {
162 a[i] = bmg[0] * stddev + mean;
163 a[i + 1] = bmg[1] * stddev + mean;
166 static int compare_floats(
const float *
a,
const float *
b,
int len,
170 for (i = 0; i <
len; i++) {
171 if (fabsf(
a[i] -
b[i]) > max_diff) {
173 i,
a[i],
b[i],
a[i] -
b[i]);
180 static void fill_double_array(
AVLFG *lfg,
double *
a,
int len)
183 double bmg[2], stddev = 10.0, mean = 0.0;
185 for (i = 0; i <
len; i += 2) {
187 a[i] = bmg[0] * stddev + mean;
188 a[i + 1] = bmg[1] * stddev + mean;
192 static int compare_doubles(
const double *
a,
const double *
b,
int len,
197 for (i = 0; i <
len; i++) {
198 if (fabs(
a[i] -
b[i]) > max_diff) {
200 i,
a[i],
b[i],
a[i] -
b[i]);
208 const float *v1,
const float *v2)
217 if (ret = compare_floats(cdst, odst, LEN, FLT_EPSILON))
223 #define ARBITRARY_FMAC_SCALAR_CONST 0.005 225 const float *v1,
const float *src0,
float scale)
231 memcpy(cdst, v1, LEN *
sizeof(*v1));
232 memcpy(odst, v1, LEN *
sizeof(*v1));
237 if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMAC_SCALAR_CONST))
244 const float *v1,
float scale)
253 if (ret = compare_floats(cdst, odst, LEN, FLT_EPSILON))
260 const double *v1,
double scale)
269 if (ret = compare_doubles(cdst, odst, LEN, DBL_EPSILON))
275 #define ARBITRARY_FMUL_WINDOW_CONST 0.008 277 const float *v1,
const float *v2,
const float *v3)
286 if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMUL_WINDOW_CONST))
292 #define ARBITRARY_FMUL_ADD_CONST 0.005 294 const float *v1,
const float *v2,
const float *v3)
303 if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMUL_ADD_CONST))
310 const float *v1,
const float *v2)
319 if (ret = compare_floats(cdst, odst, LEN, FLT_EPSILON))
326 const float *v1,
const float *v2)
334 memcpy(cv1, v1, LEN *
sizeof(*v1));
335 memcpy(cv2, v2, LEN *
sizeof(*v2));
336 memcpy(ov1, v1, LEN *
sizeof(*v1));
337 memcpy(ov2, v2, LEN *
sizeof(*v2));
342 if ((ret = compare_floats(cv1, ov1, LEN, FLT_EPSILON)) ||
343 (ret = compare_floats(cv2, ov2, LEN, FLT_EPSILON)))
349 #define ARBITRARY_SCALARPRODUCT_CONST 0.2 351 const float *v1,
const float *v2)
359 if (ret = compare_floats(&cprod, &oprod, 1, ARBITRARY_SCALARPRODUCT_CONST))
365 int main(
int argc,
char **argv)
378 if (argc > 2 && !strcmp(argv[1],
"-s"))
379 seed = strtoul(argv[2],
NULL, 10);
387 fill_float_array(&lfg, src0, LEN);
388 fill_float_array(&lfg, src1, LEN);
389 fill_float_array(&lfg, src2, LEN);
391 fill_double_array(&lfg, dbl_src0, LEN);
392 fill_double_array(&lfg, dbl_src1, LEN);
398 if (test_vector_fmul(&fdsp, &cdsp, src0, src1))
400 if (test_vector_fmac_scalar(&fdsp, &cdsp, src2, src0, src1[0]))
402 if (test_vector_fmul_scalar(&fdsp, &cdsp, src0, src1[0]))
404 if (test_vector_fmul_window(&fdsp, &cdsp, src0, src1, src2))
406 if (test_vector_fmul_add(&fdsp, &cdsp, src0, src1, src2))
408 if (test_vector_fmul_reverse(&fdsp, &cdsp, src0, src1))
410 if (test_butterflies_float(&fdsp, &cdsp, src0, src1))
412 if (test_scalarproduct_float(&fdsp, &cdsp, src0, src1))
414 if (test_vector_dmul_scalar(&fdsp, &cdsp, dbl_src0, dbl_src1[0]))
float(* scalarproduct_float)(const float *v1, const float *v2, int len)
Calculate the scalar product of two vectors of floats.
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
void av_set_cpu_flags_mask(int mask)
Set a mask on flags returned by av_get_cpu_flags().
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.
av_cold void ff_float_dsp_init_aarch64(AVFloatDSPContext *fdsp)
av_cold void ff_float_dsp_init_arm(AVFloatDSPContext *fdsp)
void(* vector_fmul)(float *dst, const float *src0, const float *src1, int len)
Calculate the product of two vectors of floats and store the result in a vector of floats...
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...
void(* vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len)
Overlap/add with window function.
void(* vector_dmul_scalar)(double *dst, const double *src, double mul, int len)
Multiply a vector of double by a scalar double.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_log(void *avcl, int level, const char *fmt,...)
int main(int argc, char **argv)
static void vector_fmul_add_c(float *dst, const float *src0, const float *src1, const float *src2, int len)
static void vector_dmul_scalar_c(double *dst, const double *src, double mul, int len)
#define AV_LOG_INFO
Standard information.
void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int strict)
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
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)
void(* vector_fmul_add)(float *dst, const float *src0, const float *src1, const float *src2, int len)
Calculate the product of two vectors of floats, add a third vector of floats and store the result in ...
static void butterflies_float_c(float *restrict v1, float *restrict v2, int len)
static void vector_fmac_scalar_c(float *dst, const float *src, float mul, int len)
void(* butterflies_float)(float *restrict v1, float *restrict v2, int len)
Calculate the sum and difference of two vectors of floats.
uint32_t av_get_random_seed(void)
Get random data.
static void vector_fmul_reverse_c(float *dst, const float *src0, const float *src1, int len)
void(* vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len)
Calculate the product of two vectors of floats, and store the result in a vector of floats...