Line | Branch | Exec | Source |
---|---|---|---|
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); | ||
34 | } AudioFIRDSPContext; | ||
35 | |||
36 | void ff_afir_init_riscv(AudioFIRDSPContext *s); | ||
37 | void ff_afir_init_x86(AudioFIRDSPContext *s); | ||
38 | |||
39 | 3 | static void fcmul_add_c(float *sum, const float *t, const float *c, ptrdiff_t len) | |
40 | { | ||
41 | int n; | ||
42 | |||
43 |
2/2✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
|
771 | for (n = 0; n < len; n++) { |
44 | 768 | const float cre = c[2 * n ]; | |
45 | 768 | const float cim = c[2 * n + 1]; | |
46 | 768 | const float tre = t[2 * n ]; | |
47 | 768 | const float tim = t[2 * n + 1]; | |
48 | |||
49 | 768 | sum[2 * n ] += tre * cre - tim * cim; | |
50 | 768 | sum[2 * n + 1] += tre * cim + tim * cre; | |
51 | } | ||
52 | |||
53 | 3 | sum[2 * n] += t[2 * n] * c[2 * n]; | |
54 | 3 | } | |
55 | |||
56 | 2 | static void dcmul_add_c(double *sum, const double *t, const double *c, ptrdiff_t len) | |
57 | { | ||
58 | int n; | ||
59 | |||
60 |
2/2✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2 times.
|
514 | for (n = 0; n < len; n++) { |
61 | 512 | const double cre = c[2 * n ]; | |
62 | 512 | const double cim = c[2 * n + 1]; | |
63 | 512 | const double tre = t[2 * n ]; | |
64 | 512 | const double tim = t[2 * n + 1]; | |
65 | |||
66 | 512 | sum[2 * n ] += tre * cre - tim * cim; | |
67 | 512 | sum[2 * n + 1] += tre * cim + tim * cre; | |
68 | } | ||
69 | |||
70 | 2 | sum[2 * n] += t[2 * n] * c[2 * n]; | |
71 | 2 | } | |
72 | |||
73 | 13 | static av_unused void ff_afir_init(AudioFIRDSPContext *dsp) | |
74 | { | ||
75 | 13 | dsp->fcmul_add = fcmul_add_c; | |
76 | 13 | dsp->dcmul_add = dcmul_add_c; | |
77 | |||
78 | #if ARCH_RISCV | ||
79 | ff_afir_init_riscv(dsp); | ||
80 | #elif ARCH_X86 | ||
81 | 13 | ff_afir_init_x86(dsp); | |
82 | #endif | ||
83 | 13 | } | |
84 | |||
85 | #endif /* AVFILTER_AFIRDSP_H */ | ||
86 |