summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2016-08-16 18:03:56 +0200
committerPaul B Mahol <onemda@gmail.com>2016-08-16 18:09:50 +0200
commitb438c2025c3e277bb506a3a7b8ec8a0d52ed3b07 (patch)
tree95525f498f466d69af642f42b1494101c39bbb67 /libavfilter
parent46bfc1562f187e3c04ea1b9baa1a1d0580530485 (diff)
avfilter/window_func: add cauchy, parzen and poisson window function
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/avf_showfreqs.c3
-rw-r--r--libavfilter/avf_showspectrum.c6
-rw-r--r--libavfilter/window_func.c44
-rw-r--r--libavfilter/window_func.h3
4 files changed, 55 insertions, 1 deletions
diff --git a/libavfilter/avf_showfreqs.c b/libavfilter/avf_showfreqs.c
index 8cf8378ad4..6f9d486d13 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 b4cc51b652..567ce5d483 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 1931c8ea65..fcdf6ea30e 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 760020fc7f..4611498d47 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);