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++)
165 #include "internal.h"
172 static void fill_float_array(
AVLFG *lfg,
float *
a,
int len)
175 double bmg[2], stddev = 10.0, mean = 0.0;
177 for (i = 0; i <
len; i += 2) {
179 a[i] = bmg[0] * stddev + mean;
180 a[i + 1] = bmg[1] * stddev + mean;
183 static int compare_floats(
const float *a,
const float *
b,
int len,
187 for (i = 0; i <
len; i++) {
188 if (fabsf(a[i] - b[i]) > max_diff) {
190 i, a[i], b[i], a[i] - b[i]);
197 static void fill_double_array(
AVLFG *lfg,
double *a,
int len)
200 double bmg[2], stddev = 10.0, mean = 0.0;
202 for (i = 0; i <
len; i += 2) {
204 a[i] = bmg[0] * stddev + mean;
205 a[i + 1] = bmg[1] * stddev + mean;
209 static int compare_doubles(
const double *a,
const double *b,
int len,
214 for (i = 0; i <
len; i++) {
215 if (fabs(a[i] - b[i]) > max_diff) {
217 i, a[i], b[i], a[i] - b[i]);
225 const float *v1,
const float *v2)
234 if (ret = compare_floats(cdst, odst,
LEN, FLT_EPSILON))
240 #define ARBITRARY_FMAC_SCALAR_CONST 0.005
242 const float *v1,
const float *
src0,
float scale)
248 memcpy(cdst, v1,
LEN *
sizeof(*v1));
249 memcpy(odst, v1,
LEN *
sizeof(*v1));
254 if (ret = compare_floats(cdst, odst,
LEN, ARBITRARY_FMAC_SCALAR_CONST))
261 const float *v1,
float scale)
270 if (ret = compare_floats(cdst, odst,
LEN, FLT_EPSILON))
277 const double *v1,
double scale)
286 if (ret = compare_doubles(cdst, odst,
LEN, DBL_EPSILON))
292 #define ARBITRARY_FMUL_WINDOW_CONST 0.008
294 const float *v1,
const float *v2,
const float *v3)
303 if (ret = compare_floats(cdst, odst,
LEN, ARBITRARY_FMUL_WINDOW_CONST))
309 #define ARBITRARY_FMUL_ADD_CONST 0.005
311 const float *v1,
const float *v2,
const float *v3)
320 if (ret = compare_floats(cdst, odst,
LEN, ARBITRARY_FMUL_ADD_CONST))
327 const float *v1,
const float *v2)
336 if (ret = compare_floats(cdst, odst,
LEN, FLT_EPSILON))
343 const float *v1,
const float *v2)
351 memcpy(cv1, v1,
LEN *
sizeof(*v1));
352 memcpy(cv2, v2,
LEN *
sizeof(*v2));
353 memcpy(ov1, v1,
LEN *
sizeof(*v1));
354 memcpy(ov2, v2,
LEN *
sizeof(*v2));
359 if ((ret = compare_floats(cv1, ov1,
LEN, FLT_EPSILON)) ||
360 (ret = compare_floats(cv2, ov2,
LEN, FLT_EPSILON)))
366 #define ARBITRARY_SCALARPRODUCT_CONST 0.2
368 const float *v1,
const float *v2)
376 if (ret = compare_floats(&cprod, &oprod, 1, ARBITRARY_SCALARPRODUCT_CONST))
382 int main(
int argc,
char **argv)
384 int ret = 0, seeded = 0;
425 if (!fdsp || !cdsp) {
432 fill_float_array(&lfg, src0,
LEN);
433 fill_float_array(&lfg,
src1,
LEN);
434 fill_float_array(&lfg, src2,
LEN);
436 fill_double_array(&lfg, dbl_src0,
LEN);
437 fill_double_array(&lfg, dbl_src1,
LEN);
439 if (test_vector_fmul(fdsp, cdsp, src0,
src1))
441 if (test_vector_fmac_scalar(fdsp, cdsp, src2, src0,
src1[0]))
443 if (test_vector_fmul_scalar(fdsp, cdsp, src0,
src1[0]))
445 if (test_vector_fmul_window(fdsp, cdsp, src0,
src1, src2))
447 if (test_vector_fmul_add(fdsp, cdsp, src0,
src1, src2))
449 if (test_vector_fmul_reverse(fdsp, cdsp, src0,
src1))
451 if (test_butterflies_float(fdsp, cdsp, src0,
src1))
453 if (test_scalarproduct_float(fdsp, cdsp, src0,
src1))
455 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)
static av_cold int end(AVCodecContext *avctx)
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.
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)