FFmpeg
af_afirdsp.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Paul B Mahol
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 #ifndef AVFILTER_AFIRDSP_H
22 #define AVFILTER_AFIRDSP_H
23 
24 #include <stddef.h>
25 
26 #include "config.h"
27 #include "libavutil/attributes.h"
28 
29 typedef struct AudioFIRDSPContext {
30  void (*fcmul_add)(float *sum, const float *t, const float *c,
31  ptrdiff_t len);
32  void (*dcmul_add)(double *sum, const double *t, const double *c,
33  ptrdiff_t len);
35 
37 
38 static void fcmul_add_c(float *sum, const float *t, const float *c, ptrdiff_t len)
39 {
40  int n;
41 
42  for (n = 0; n < len; n++) {
43  const float cre = c[2 * n ];
44  const float cim = c[2 * n + 1];
45  const float tre = t[2 * n ];
46  const float tim = t[2 * n + 1];
47 
48  sum[2 * n ] += tre * cre - tim * cim;
49  sum[2 * n + 1] += tre * cim + tim * cre;
50  }
51 
52  sum[2 * n] += t[2 * n] * c[2 * n];
53 }
54 
55 static void dcmul_add_c(double *sum, const double *t, const double *c, ptrdiff_t len)
56 {
57  int n;
58 
59  for (n = 0; n < len; n++) {
60  const double cre = c[2 * n ];
61  const double cim = c[2 * n + 1];
62  const double tre = t[2 * n ];
63  const double tim = t[2 * n + 1];
64 
65  sum[2 * n ] += tre * cre - tim * cim;
66  sum[2 * n + 1] += tre * cim + tim * cre;
67  }
68 
69  sum[2 * n] += t[2 * n] * c[2 * n];
70 }
71 
73 {
74  dsp->fcmul_add = fcmul_add_c;
75  dsp->dcmul_add = dcmul_add_c;
76 
77 #if ARCH_X86
78  ff_afir_init_x86(dsp);
79 #endif
80 }
81 
82 #endif /* AVFILTER_AFIRDSP_H */
av_unused
#define av_unused
Definition: attributes.h:131
AudioFIRDSPContext::fcmul_add
void(* fcmul_add)(float *sum, const float *t, const float *c, ptrdiff_t len)
Definition: af_afirdsp.h:30
fcmul_add_c
static void fcmul_add_c(float *sum, const float *t, const float *c, ptrdiff_t len)
Definition: af_afirdsp.h:38
dcmul_add_c
static void dcmul_add_c(double *sum, const double *t, const double *c, ptrdiff_t len)
Definition: af_afirdsp.h:55
ff_afir_init
static av_unused void ff_afir_init(AudioFIRDSPContext *dsp)
Definition: af_afirdsp.h:72
s
#define s(width, name)
Definition: cbs_vp9.c:256
ff_afir_init_x86
void ff_afir_init_x86(AudioFIRDSPContext *s)
Definition: af_afir_init.c:30
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
AudioFIRDSPContext
Definition: af_afirdsp.h:29
attributes.h
AudioFIRDSPContext::dcmul_add
void(* dcmul_add)(double *sum, const double *t, const double *c, ptrdiff_t len)
Definition: af_afirdsp.h:32
len
int len
Definition: vorbis_enc_data.h:426