Browse code

avfilter/window_func: add dolph window

Paul B Mahol authored on 2016/08/16 21:30:43
Showing 5 changed files
... ...
@@ -16518,6 +16518,7 @@ It accepts the following values:
16518 16518
 @item lanczos
16519 16519
 @item gauss
16520 16520
 @item tukey
16521
+@item dolph
16521 16522
 @end table
16522 16523
 Default is @code{hanning}.
16523 16524
 
... ...
@@ -16665,6 +16666,7 @@ It accepts the following values:
16665 16665
 @item lanczos
16666 16666
 @item gauss
16667 16667
 @item tukey
16668
+@item dolph
16668 16669
 @end table
16669 16670
 
16670 16671
 Default value is @code{hann}.
... ...
@@ -16808,6 +16810,7 @@ It accepts the following values:
16808 16808
 @item lanczos
16809 16809
 @item gauss
16810 16810
 @item tukey
16811
+@item dolph
16811 16812
 @end table
16812 16813
 Default value is @code{hann}.
16813 16814
 
... ...
@@ -112,6 +112,7 @@ static const AVOption showfreqs_options[] = {
112 112
         { "lanczos",  "Lanczos",          0, AV_OPT_TYPE_CONST, {.i64=WFUNC_LANCZOS},  0, 0, FLAGS, "win_func" },
113 113
         { "gauss",    "Gauss",            0, AV_OPT_TYPE_CONST, {.i64=WFUNC_GAUSS},    0, 0, FLAGS, "win_func" },
114 114
         { "tukey",    "Tukey",            0, AV_OPT_TYPE_CONST, {.i64=WFUNC_TUKEY},    0, 0, FLAGS, "win_func" },
115
+        { "dolph",    "Dolph-Chebyshev",  0, AV_OPT_TYPE_CONST, {.i64=WFUNC_DOLPH},    0, 0, FLAGS, "win_func" },
115 116
     { "overlap",  "set window overlap", OFFSET(overlap), AV_OPT_TYPE_FLOAT, {.dbl=1.}, 0., 1., FLAGS },
116 117
     { "averaging", "set time averaging", OFFSET(avg), AV_OPT_TYPE_INT, {.i64=1}, 0, INT32_MAX, FLAGS },
117 118
     { "colors", "set channels colors", OFFSET(colors), AV_OPT_TYPE_STRING, {.str = "red|green|blue|yellow|orange|lime|pink|magenta|brown" }, 0, 0, FLAGS },
... ...
@@ -133,6 +133,7 @@ static const AVOption showspectrum_options[] = {
133 133
         { "lanczos",  "Lanczos",          0, AV_OPT_TYPE_CONST, {.i64=WFUNC_LANCZOS},  0, 0, FLAGS, "win_func" },
134 134
         { "gauss",    "Gauss",            0, AV_OPT_TYPE_CONST, {.i64=WFUNC_GAUSS},    0, 0, FLAGS, "win_func" },
135 135
         { "tukey",    "Tukey",            0, AV_OPT_TYPE_CONST, {.i64=WFUNC_TUKEY},    0, 0, FLAGS, "win_func" },
136
+        { "dolph",    "Dolph-Chebyshev",  0, AV_OPT_TYPE_CONST, {.i64=WFUNC_DOLPH},    0, 0, FLAGS, "win_func" },
136 137
     { "orientation", "set orientation", OFFSET(orientation), AV_OPT_TYPE_INT, {.i64=VERTICAL}, 0, NB_ORIENTATIONS-1, FLAGS, "orientation" },
137 138
         { "vertical",   NULL, 0, AV_OPT_TYPE_CONST, {.i64=VERTICAL},   0, 0, FLAGS, "orientation" },
138 139
         { "horizontal", NULL, 0, AV_OPT_TYPE_CONST, {.i64=HORIZONTAL}, 0, 0, FLAGS, "orientation" },
... ...
@@ -942,6 +943,7 @@ static const AVOption showspectrumpic_options[] = {
942 942
         { "lanczos",  "Lanczos",          0, AV_OPT_TYPE_CONST, {.i64=WFUNC_LANCZOS},  0, 0, FLAGS, "win_func" },
943 943
         { "gauss",    "Gauss",            0, AV_OPT_TYPE_CONST, {.i64=WFUNC_GAUSS},    0, 0, FLAGS, "win_func" },
944 944
         { "tukey",    "Tukey",            0, AV_OPT_TYPE_CONST, {.i64=WFUNC_TUKEY},    0, 0, FLAGS, "win_func" },
945
+        { "dolph",    "Dolph-Chebyshev",  0, AV_OPT_TYPE_CONST, {.i64=WFUNC_DOLPH},    0, 0, FLAGS, "win_func" },
945 946
     { "orientation", "set orientation", OFFSET(orientation), AV_OPT_TYPE_INT, {.i64=VERTICAL}, 0, NB_ORIENTATIONS-1, FLAGS, "orientation" },
946 947
         { "vertical",   NULL, 0, AV_OPT_TYPE_CONST, {.i64=VERTICAL},   0, 0, FLAGS, "orientation" },
947 948
         { "horizontal", NULL, 0, AV_OPT_TYPE_CONST, {.i64=HORIZONTAL}, 0, 0, FLAGS, "orientation" },
... ...
@@ -116,6 +116,18 @@ void ff_generate_window_func(float *lut, int N, int win_func, float *overlap)
116 116
         }
117 117
         *overlap = 0.33;
118 118
         break;
119
+    case WFUNC_DOLPH: {
120
+        double b = cosh(acosh(pow(10., 3)) / (N-1)), sum, t, c, norm = 0;
121
+        int j;
122
+        for (c = 1 - 1 / (b*b), n = (N-1) / 2; n >= 0; --n) {
123
+            for (sum = !n, b = t = j = 1; j <= n && sum != t; b *= (n-j) * (1./j), ++j)
124
+                t = sum, sum += (b *= c * (N - n - j) * (1./j));
125
+            sum /= (N - 1 - n), sum /= (norm = norm ? norm : sum);
126
+            lut[n] = sum;
127
+            lut[N - 1 - n] = sum;
128
+        }
129
+        *overlap = 0.5;}
130
+        break;
119 131
     default:
120 132
         av_assert0(0);
121 133
     }
... ...
@@ -25,7 +25,8 @@
25 25
 enum WindowFunc     { WFUNC_RECT, WFUNC_HANNING, WFUNC_HAMMING, WFUNC_BLACKMAN,
26 26
                       WFUNC_BARTLETT, WFUNC_WELCH, WFUNC_FLATTOP,
27 27
                       WFUNC_BHARRIS, WFUNC_BNUTTALL, WFUNC_SINE, WFUNC_NUTTALL,
28
-                      WFUNC_BHANN, WFUNC_LANCZOS, WFUNC_GAUSS, WFUNC_TUKEY, NB_WFUNC };
28
+                      WFUNC_BHANN, WFUNC_LANCZOS, WFUNC_GAUSS, WFUNC_TUKEY,
29
+                      WFUNC_DOLPH, NB_WFUNC };
29 30
 
30 31
 void ff_generate_window_func(float *lut, int N, int win_func, float *overlap);
31 32