22 #ifndef AVFILTER_WINDOW_FUNC_H
23 #define AVFILTER_WINDOW_FUNC_H
37 #define WIN_FUNC_OPTION(win_func_opt_name, win_func_offset, flag, default_window_func) \
38 { win_func_opt_name, "set window function", win_func_offset, AV_OPT_TYPE_INT, {.i64 = default_window_func}, 0, NB_WFUNC-1, flag, "win_func" }, \
39 { "rect", "Rectangular", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_RECT}, 0, 0, flag, "win_func" }, \
40 { "bartlett", "Bartlett", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BARTLETT}, 0, 0, flag, "win_func" }, \
41 { "hann", "Hann", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_HANNING}, 0, 0, flag, "win_func" }, \
42 { "hanning", "Hanning", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_HANNING}, 0, 0, flag, "win_func" }, \
43 { "hamming", "Hamming", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_HAMMING}, 0, 0, flag, "win_func" }, \
44 { "blackman", "Blackman", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BLACKMAN}, 0, 0, flag, "win_func" }, \
45 { "welch", "Welch", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_WELCH}, 0, 0, flag, "win_func" }, \
46 { "flattop", "Flat-top", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_FLATTOP}, 0, 0, flag, "win_func" }, \
47 { "bharris", "Blackman-Harris", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BHARRIS}, 0, 0, flag, "win_func" }, \
48 { "bnuttall", "Blackman-Nuttall", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BNUTTALL}, 0, 0, flag, "win_func" }, \
49 { "bhann", "Bartlett-Hann", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BHANN}, 0, 0, flag, "win_func" }, \
50 { "sine", "Sine", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_SINE}, 0, 0, flag, "win_func" }, \
51 { "nuttall", "Nuttall", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_NUTTALL}, 0, 0, flag, "win_func" }, \
52 { "lanczos", "Lanczos", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_LANCZOS}, 0, 0, flag, "win_func" }, \
53 { "gauss", "Gauss", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_GAUSS}, 0, 0, flag, "win_func" }, \
54 { "tukey", "Tukey", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_TUKEY}, 0, 0, flag, "win_func" }, \
55 { "dolph", "Dolph-Chebyshev", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_DOLPH}, 0, 0, flag, "win_func" }, \
56 { "cauchy", "Cauchy", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_CAUCHY}, 0, 0, flag, "win_func" }, \
57 { "parzen", "Parzen", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_PARZEN}, 0, 0, flag, "win_func" }, \
58 { "poisson", "Poisson", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_POISSON}, 0, 0, flag, "win_func" }, \
59 { "bohman", "Bohman", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BOHMAN}, 0, 0, flag, "win_func" }, \
60 { "kaiser", "Kaiser", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_KAISER}, 0, 0, flag, "win_func" }
62 static inline double get_i0(
double x)
64 double y = 1.0, prev = 1.0,
i = 1.0;
66 while (
fabs(prev) > 1e-20) {
67 double summand = prev * x * x / (4 *
i *
i);
83 for (n = 0; n <
N; n++)
88 for (n = 0; n <
N; n++)
89 lut[n] = 1.-
fabs((n-(
N-1)/2.)/((
N-1)/2.));
93 for (n = 0; n <
N; n++)
94 lut[n] = .5*(1-cos(2*
M_PI*n/(
N-1)));
98 for (n = 0; n <
N; n++)
99 lut[n] = .54-.46*cos(2*
M_PI*n/(
N-1));
103 for (n = 0; n <
N; n++)
104 lut[n] = .42659-.49656*cos(2*
M_PI*n/(
N-1))+.076849*cos(4*
M_PI*n/(
N-1));
108 for (n = 0; n <
N; n++)
109 lut[n] = 1.-(n-(
N-1)/2.)/((
N-1)/2.)*(n-(
N-1)/2.)/((
N-1)/2.);
113 for (n = 0; n <
N; n++)
114 lut[n] = 1.-1.985844164102*cos( 2*
M_PI*n/(
N-1))+1.791176438506*cos( 4*
M_PI*n/(
N-1))-
115 1.282075284005*cos( 6*
M_PI*n/(
N-1))+0.667777530266*cos( 8*
M_PI*n/(
N-1))-
116 0.240160796576*cos(10*
M_PI*n/(
N-1))+0.056656381764*cos(12*
M_PI*n/(
N-1))-
117 0.008134974479*cos(14*
M_PI*n/(
N-1))+0.000624544650*cos(16*
M_PI*n/(
N-1))-
118 0.000019808998*cos(18*
M_PI*n/(
N-1))+0.000000132974*cos(20*
M_PI*n/(
N-1));
122 for (n = 0; n <
N; n++)
123 lut[n] = 0.35875-0.48829*cos(2*
M_PI*n/(
N-1))+0.14128*cos(4*
M_PI*n/(
N-1))-0.01168*cos(6*
M_PI*n/(
N-1));
127 for (n = 0; n <
N; n++)
128 lut[n] = 0.3635819-0.4891775*cos(2*
M_PI*n/(
N-1))+0.1365995*cos(4*
M_PI*n/(
N-1))-0.0106411*cos(6*
M_PI*n/(
N-1));
132 for (n = 0; n <
N; n++)
133 lut[n] = 0.62-0.48*
fabs(n/(
double)(
N-1)-.5)-0.38*cos(2*
M_PI*n/(
N-1));
137 for (n = 0; n <
N; n++)
138 lut[n] = sin(
M_PI*n/(
N-1));
142 for (n = 0; n <
N; n++)
143 lut[n] = 0.355768-0.487396*cos(2*
M_PI*n/(
N-1))+0.144232*cos(4*
M_PI*n/(
N-1))-0.012604*cos(6*
M_PI*n/(
N-1));
147 #define SINC(x) (!(x)) ? 1 : sin(M_PI * (x))/(M_PI * (x));
148 for (n = 0; n <
N; n++)
149 lut[n] =
SINC((2.*n)/(
N-1)-1);
153 #define SQR(x) ((x)*(x))
154 for (n = 0; n <
N; n++)
155 lut[n] =
exp(-0.5 *
SQR((n-(
N-1)/2)/(0.4*(
N-1)/2.
f)));
159 for (n = 0; n <
N; n++) {
163 lut[n] = 0.5 * (1 + cos((
M_PI*(
FFABS(n -
M) - 0.3 *
M))/((1 - 0.3) *
M)));
171 double b = cosh(7.6009022095419887 / (
N-1)), sum, t,
c, norm = 0;
173 for (
c = 1 - 1 / (
b*
b), n = (
N-1) / 2; n >= 0; --n) {
174 for (sum = !n,
b = t = j = 1; j <= n && sum != t;
b *= (n-j) * (1./j), ++j)
175 t = sum, sum += (
b *=
c * (
N - n - j) * (1./j));
176 sum /= (
N - 1 - n), norm = norm ? norm : sum, sum /= norm;
178 lut[
N - 1 - n] = sum;
183 for (n = 0; n <
N; n++) {
184 double x = 2 * ((n / (
double)(
N - 1)) - .5);
186 if (x <= -.5 || x >= .5) {
195 for (n = 0; n <
N; n++) {
196 double x = 2 * ((n / (
double)(
N - 1)) - .5);
198 if (x > 0.25 && x <= 0.5) {
199 lut[n] = -2 *
powf(-1 + 2 * x, 3);
200 }
else if (x >= -.5 && x < -.25) {
201 lut[n] = 2 *
powf(1 + 2 * x, 3);
202 }
else if (x >= -.25 && x < 0) {
203 lut[n] = 1 - 24 * x * x - 48 * x * x * x;
204 }
else if (x >= 0 && x <= .25) {
205 lut[n] = 1 - 24 * x * x + 48 * x * x * x;
213 for (n = 0; n <
N; n++) {
214 double x = 2 * ((n / (
double)(
N - 1)) - .5);
216 if (x >= 0 && x <= .5) {
218 }
else if (x < 0 && x >= -.5) {
227 for (n = 0; n <
N; n++) {
228 double x = 2 * ((n / (
double)(
N - 1))) - 1.;
235 for (n = 0; n <
N; n++) {
236 double x = 2.0 / (
double)(
N - 1);