[FFmpeg-cvslog] avfilter/window_func: add cauchy, parzen and poisson window function

Paul B Mahol git at videolan.org
Tue Aug 16 19:09:59 EEST 2016


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Tue Aug 16 18:03:56 2016 +0200| [b438c2025c3e277bb506a3a7b8ec8a0d52ed3b07] | committer: Paul B Mahol

avfilter/window_func: add cauchy, parzen and poisson window function

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

 doc/filters.texi               |  9 +++++++++
 libavfilter/avf_showfreqs.c    |  3 +++
 libavfilter/avf_showspectrum.c |  6 ++++++
 libavfilter/window_func.c      | 44 ++++++++++++++++++++++++++++++++++++++++++
 libavfilter/window_func.h      |  3 ++-
 5 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 786a0ca..5c48ad7 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16519,6 +16519,9 @@ It accepts the following values:
 @item gauss
 @item tukey
 @item dolph
+ at item cauchy
+ at item parzen
+ at item poisson
 @end table
 Default is @code{hanning}.
 
@@ -16667,6 +16670,9 @@ It accepts the following values:
 @item gauss
 @item tukey
 @item dolph
+ at item cauchy
+ at item parzen
+ at item poisson
 @end table
 
 Default value is @code{hann}.
@@ -16811,6 +16817,9 @@ It accepts the following values:
 @item gauss
 @item tukey
 @item dolph
+ at item cauchy
+ at item parzen
+ at item poisson
 @end table
 Default value is @code{hann}.
 
diff --git a/libavfilter/avf_showfreqs.c b/libavfilter/avf_showfreqs.c
index 8cf8378..6f9d486 100644
--- a/libavfilter/avf_showfreqs.c
+++ b/libavfilter/avf_showfreqs.c
@@ -113,6 +113,9 @@ static const AVOption showfreqs_options[] = {
         { "gauss",    "Gauss",            0, AV_OPT_TYPE_CONST, {.i64=WFUNC_GAUSS},    0, 0, FLAGS, "win_func" },
         { "tukey",    "Tukey",            0, AV_OPT_TYPE_CONST, {.i64=WFUNC_TUKEY},    0, 0, FLAGS, "win_func" },
         { "dolph",    "Dolph-Chebyshev",  0, AV_OPT_TYPE_CONST, {.i64=WFUNC_DOLPH},    0, 0, FLAGS, "win_func" },
+        { "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" },
     { "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 b4cc51b..567ce5d 100644
--- a/libavfilter/avf_showspectrum.c
+++ b/libavfilter/avf_showspectrum.c
@@ -135,6 +135,9 @@ static const AVOption showspectrum_options[] = {
         { "gauss",    "Gauss",            0, AV_OPT_TYPE_CONST, {.i64=WFUNC_GAUSS},    0, 0, FLAGS, "win_func" },
         { "tukey",    "Tukey",            0, AV_OPT_TYPE_CONST, {.i64=WFUNC_TUKEY},    0, 0, FLAGS, "win_func" },
         { "dolph",    "Dolph-Chebyshev",  0, AV_OPT_TYPE_CONST, {.i64=WFUNC_DOLPH},    0, 0, FLAGS, "win_func" },
+        { "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" },
     { "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" },
@@ -967,6 +970,9 @@ static const AVOption showspectrumpic_options[] = {
         { "gauss",    "Gauss",            0, AV_OPT_TYPE_CONST, {.i64=WFUNC_GAUSS},    0, 0, FLAGS, "win_func" },
         { "tukey",    "Tukey",            0, AV_OPT_TYPE_CONST, {.i64=WFUNC_TUKEY},    0, 0, FLAGS, "win_func" },
         { "dolph",    "Dolph-Chebyshev",  0, AV_OPT_TYPE_CONST, {.i64=WFUNC_DOLPH},    0, 0, FLAGS, "win_func" },
+        { "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" },
     { "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.c b/libavfilter/window_func.c
index 1931c8e..fcdf6ea 100644
--- a/libavfilter/window_func.c
+++ b/libavfilter/window_func.c
@@ -128,6 +128,50 @@ void ff_generate_window_func(float *lut, int N, int win_func, float *overlap)
         }
         *overlap = 0.5;}
         break;
+    case WFUNC_CAUCHY:
+        for (n = 0; n < N; n++) {
+            double x = 2 * ((n / (double)(N - 1)) - .5);
+
+            if (x <= -.5 || x >= .5) {
+                lut[n] = 0;
+            } else {
+                lut[n] = FFMIN(1, fabs(1/(1+4*16*x*x)));
+            }
+        }
+        *overlap = 0.75;
+        break;
+    case WFUNC_PARZEN:
+        for (n = 0; n < N; n++) {
+            double x = 2 * ((n / (double)(N - 1)) - .5);
+
+            if (x > 0.25 && x <= 0.5) {
+                lut[n] = -2 * powf(-1 + 2 * x, 3);
+            } else if (x >= -.5 && x < -.25) {
+                lut[n] = 2 * powf(1 + 2 * x, 3);
+            } else if (x >= -.25 && x < 0) {
+                lut[n] = 1 - 24 * x * x - 48 * x * x * x;
+            } else if (x >= 0 && x <= .25) {
+                lut[n] = 1 - 24 * x * x + 48 * x * x * x;
+            } else {
+                lut[n] = 0;
+            }
+        }
+        *overlap = 0.75;
+        break;
+    case WFUNC_POISSON:
+        for (n = 0; n < N; n++) {
+            double x = 2 * ((n / (double)(N - 1)) - .5);
+
+            if (x >= 0 && x <= .5) {
+                lut[n] = exp(-6*x);
+            } else if (x < 0 && x >= -.5) {
+                lut[n] = exp(6*x);
+            } else {
+                lut[n] = 0;
+            }
+        }
+        *overlap = 0.75;
+        break;
     default:
         av_assert0(0);
     }
diff --git a/libavfilter/window_func.h b/libavfilter/window_func.h
index 760020f..4611498 100644
--- a/libavfilter/window_func.h
+++ b/libavfilter/window_func.h
@@ -26,7 +26,8 @@ enum WindowFunc     { WFUNC_RECT, WFUNC_HANNING, WFUNC_HAMMING, WFUNC_BLACKMAN,
                       WFUNC_BARTLETT, WFUNC_WELCH, WFUNC_FLATTOP,
                       WFUNC_BHARRIS, WFUNC_BNUTTALL, WFUNC_SINE, WFUNC_NUTTALL,
                       WFUNC_BHANN, WFUNC_LANCZOS, WFUNC_GAUSS, WFUNC_TUKEY,
-                      WFUNC_DOLPH, NB_WFUNC };
+                      WFUNC_DOLPH, WFUNC_CAUCHY, WFUNC_PARZEN, WFUNC_POISSON,
+                      NB_WFUNC };
 
 void ff_generate_window_func(float *lut, int N, int win_func, float *overlap);
 



More information about the ffmpeg-cvslog mailing list