[FFmpeg-cvslog] avfilter/window_func: add bohman window

Paul B Mahol git at videolan.org
Sat Oct 27 14:37:54 EEST 2018


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Oct 27 13:13:31 2018 +0200| [40ac622460284f4aad10a13b786d03d6c2cfa868] | committer: Paul B Mahol

avfilter/window_func: add bohman window

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=40ac622460284f4aad10a13b786d03d6c2cfa868
---

 doc/filters.texi               | 3 +++
 libavfilter/asrc_hilbert.c     | 1 +
 libavfilter/avf_showfreqs.c    | 1 +
 libavfilter/avf_showspectrum.c | 2 ++
 libavfilter/window_func.h      | 9 +++++++++
 5 files changed, 16 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 7811c25ddb..9c7cc2284b 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -20851,6 +20851,7 @@ It accepts the following values:
 @item cauchy
 @item parzen
 @item poisson
+ at item bohman
 @end table
 Default is @code{hanning}.
 
@@ -21009,6 +21010,7 @@ It accepts the following values:
 @item cauchy
 @item parzen
 @item poisson
+ at item bohman
 @end table
 
 Default value is @code{hann}.
@@ -21172,6 +21174,7 @@ It accepts the following values:
 @item cauchy
 @item parzen
 @item poisson
+ at item bohman
 @end table
 Default value is @code{hann}.
 
diff --git a/libavfilter/asrc_hilbert.c b/libavfilter/asrc_hilbert.c
index a3a395254f..a51c676c6f 100644
--- a/libavfilter/asrc_hilbert.c
+++ b/libavfilter/asrc_hilbert.c
@@ -67,6 +67,7 @@ static const AVOption hilbert_options[] = {
         { "cauchy",   "Cauchy",           0, AV_OPT_TYPE_CONST, {.i64=WFUNC_CAUCHY},   0, 0, FLAGS, "win_func" },
         { "parzen",   "Parzen",           0, AV_OPT_TYPE_CONST, {.i64=WFUNC_PARZEN},   0, 0, FLAGS, "win_func" },
         { "poisson",  "Poisson",          0, AV_OPT_TYPE_CONST, {.i64=WFUNC_POISSON},  0, 0, FLAGS, "win_func" },
+        { "bohman" ,  "Bohman",           0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BOHMAN},   0, 0, FLAGS, "win_func" },
     {NULL}
 };
 
diff --git a/libavfilter/avf_showfreqs.c b/libavfilter/avf_showfreqs.c
index 22f28ec387..ff6a762547 100644
--- a/libavfilter/avf_showfreqs.c
+++ b/libavfilter/avf_showfreqs.c
@@ -118,6 +118,7 @@ static const AVOption showfreqs_options[] = {
         { "cauchy",   "Cauchy",           0, AV_OPT_TYPE_CONST, {.i64=WFUNC_CAUCHY},   0, 0, FLAGS, "win_func" },
         { "parzen",   "Parzen",           0, AV_OPT_TYPE_CONST, {.i64=WFUNC_PARZEN},   0, 0, FLAGS, "win_func" },
         { "poisson",  "Poisson",          0, AV_OPT_TYPE_CONST, {.i64=WFUNC_POISSON},  0, 0, FLAGS, "win_func" },
+        { "bohman",   "Bohman",           0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BOHMAN} ,  0, 0, FLAGS, "win_func" },
     { "overlap",  "set window overlap", OFFSET(overlap), AV_OPT_TYPE_FLOAT, {.dbl=1.}, 0., 1., FLAGS },
     { "averaging", "set time averaging", OFFSET(avg), AV_OPT_TYPE_INT, {.i64=1}, 0, INT32_MAX, FLAGS },
     { "colors", "set channels colors", OFFSET(colors), AV_OPT_TYPE_STRING, {.str = "red|green|blue|yellow|orange|lime|pink|magenta|brown" }, 0, 0, FLAGS },
diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c
index 41693a0ce1..b278790071 100644
--- a/libavfilter/avf_showspectrum.c
+++ b/libavfilter/avf_showspectrum.c
@@ -152,6 +152,7 @@ static const AVOption showspectrum_options[] = {
         { "cauchy",   "Cauchy",           0, AV_OPT_TYPE_CONST, {.i64=WFUNC_CAUCHY},   0, 0, FLAGS, "win_func" },
         { "parzen",   "Parzen",           0, AV_OPT_TYPE_CONST, {.i64=WFUNC_PARZEN},   0, 0, FLAGS, "win_func" },
         { "poisson",  "Poisson",          0, AV_OPT_TYPE_CONST, {.i64=WFUNC_POISSON},  0, 0, FLAGS, "win_func" },
+        { "bohman",   "Bohman",           0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BOHMAN},   0, 0, FLAGS, "win_func" },
     { "orientation", "set orientation", OFFSET(orientation), AV_OPT_TYPE_INT, {.i64=VERTICAL}, 0, NB_ORIENTATIONS-1, FLAGS, "orientation" },
         { "vertical",   NULL, 0, AV_OPT_TYPE_CONST, {.i64=VERTICAL},   0, 0, FLAGS, "orientation" },
         { "horizontal", NULL, 0, AV_OPT_TYPE_CONST, {.i64=HORIZONTAL}, 0, 0, FLAGS, "orientation" },
@@ -1425,6 +1426,7 @@ static const AVOption showspectrumpic_options[] = {
         { "cauchy",   "Cauchy",           0, AV_OPT_TYPE_CONST, {.i64=WFUNC_CAUCHY},   0, 0, FLAGS, "win_func" },
         { "parzen",   "Parzen",           0, AV_OPT_TYPE_CONST, {.i64=WFUNC_PARZEN},   0, 0, FLAGS, "win_func" },
         { "poisson",  "Poisson",          0, AV_OPT_TYPE_CONST, {.i64=WFUNC_POISSON},  0, 0, FLAGS, "win_func" },
+        { "bohman",   "Bohman",           0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BOHMAN},   0, 0, FLAGS, "win_func" },
     { "orientation", "set orientation", OFFSET(orientation), AV_OPT_TYPE_INT, {.i64=VERTICAL}, 0, NB_ORIENTATIONS-1, FLAGS, "orientation" },
         { "vertical",   NULL, 0, AV_OPT_TYPE_CONST, {.i64=VERTICAL},   0, 0, FLAGS, "orientation" },
         { "horizontal", NULL, 0, AV_OPT_TYPE_CONST, {.i64=HORIZONTAL}, 0, 0, FLAGS, "orientation" },
diff --git a/libavfilter/window_func.h b/libavfilter/window_func.h
index a94482c937..1de8f1fbdb 100644
--- a/libavfilter/window_func.h
+++ b/libavfilter/window_func.h
@@ -30,6 +30,7 @@ enum WindowFunc     { WFUNC_RECT, WFUNC_HANNING, WFUNC_HAMMING, WFUNC_BLACKMAN,
                       WFUNC_BHARRIS, WFUNC_BNUTTALL, WFUNC_SINE, WFUNC_NUTTALL,
                       WFUNC_BHANN, WFUNC_LANCZOS, WFUNC_GAUSS, WFUNC_TUKEY,
                       WFUNC_DOLPH, WFUNC_CAUCHY, WFUNC_PARZEN, WFUNC_POISSON,
+                      WFUNC_BOHMAN,
                       NB_WFUNC };
 
 static inline void generate_window_func(float *lut, int N, int win_func,
@@ -182,6 +183,14 @@ static inline void generate_window_func(float *lut, int N, int win_func,
         }
         *overlap = 0.75;
         break;
+    case WFUNC_BOHMAN:
+        for (n = 0; n < N; n++) {
+            double x = 2 * ((n / (double)(N - 1))) - 1.;
+
+            lut[n] = (1 - fabs(x)) * cos(M_PI*fabs(x)) + 1./M_PI*sin(M_PI*fabs(x));
+        }
+        *overlap = 0.75;
+        break;
     default:
         av_assert0(0);
     }



More information about the ffmpeg-cvslog mailing list