1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
23
26
29
32
34 {
37
41
42 return 0;
43 }
44
46 {
50 const double sensitivity =
s->sensitivity;
53
56 } else {
61 }
63 }
64
65 for (
int ch = 0; ch <
out->ch_layout.nb_channels; ch++) {
67 double *dst = (
double *)
out->extended_data[ch];
68 double *coeffs = (
double *)
s->coeffs->extended_data[ch];
69 double low1 = coeffs[0];
70 double low2 = coeffs[1];
71 double inz = coeffs[2];
72
73 for (
int n = 0; n <
out->nb_samples; n++) {
74 double low1z = low1;
75 double low2z = low2;
76 double bandz = low2z - low1z;
77 double wd = wc + sensitivity *
fabs(bandz);
78 double g =
fmin(1., wd * (5.9948827 + wd * (-11.969296 + wd * 15.959062)));
79
80 low1 = low1z +
g * (0.5 * (
src[n] + inz) - low1z);
81 low2 = low2z +
g * (0.5 * (low1 + low1z) - low2z);
83 dst[n] =
ctx->is_disabled ?
src[n] : low2;
84 }
85
86 coeffs[0] = low1;
87 coeffs[1] = low2;
88 coeffs[2] = inz;
89 }
90
94 }
95
97 {
99
101 }
102
103 #define OFFSET(x) offsetof(AudioDynamicSmoothContext, x)
104 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
105
110 };
111
113
115 {
120 },
121 };
122
124 .
name =
"adynamicsmooth",
127 .priv_class = &adynamicsmooth_class,
134 };