[FFmpeg-cvslog] avfilter/avf_showfreqs: add lanczos and gauss windowing functions

Paul B Mahol git at videolan.org
Tue Sep 15 11:32:57 CEST 2015


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Tue Sep 15 09:13:53 2015 +0000| [f2b1df735ed0baa26353abe2dade67e9dc09a922] | committer: Paul B Mahol

avfilter/avf_showfreqs: add lanczos and gauss windowing functions

Signed-off-by: Paul B Mahol <onemda at gmail.com>

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

 libavfilter/avf_showfreqs.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/libavfilter/avf_showfreqs.c b/libavfilter/avf_showfreqs.c
index c00e4d8..5dfa2df 100644
--- a/libavfilter/avf_showfreqs.c
+++ b/libavfilter/avf_showfreqs.c
@@ -39,7 +39,7 @@ enum AmplitudeScale { AS_LINEAR, AS_SQRT, AS_CBRT, AS_LOG, NB_ASCALES };
 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, NB_WFUNC };
+                      WFUNC_BHANN, WFUNC_LANCZOS, WFUNC_GAUSS, NB_WFUNC };
 
 typedef struct ShowFreqsContext {
     const AVClass *class;
@@ -110,6 +110,8 @@ static const AVOption showfreqs_options[] = {
         { "bhann",    "Bartlett-Hann",    0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BHANN},    0, 0, FLAGS, "win_func" },
         { "sine",     "Sine",             0, AV_OPT_TYPE_CONST, {.i64=WFUNC_SINE},     0, 0, FLAGS, "win_func" },
         { "nuttall",  "Nuttall",          0, AV_OPT_TYPE_CONST, {.i64=WFUNC_NUTTALL},  0, 0, FLAGS, "win_func" },
+        { "lanczos",  "Lanczos",          0, AV_OPT_TYPE_CONST, {.i64=WFUNC_LANCZOS},  0, 0, FLAGS, "win_func" },
+        { "gauss",    "Gauss",            0, AV_OPT_TYPE_CONST, {.i64=WFUNC_GAUSS},    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 },
@@ -221,6 +223,17 @@ static void generate_window_func(float *lut, int N, int win_func, float *overlap
             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));
         *overlap = 0.663;
         break;
+    case WFUNC_LANCZOS:
+#define SINC(x) (!(x)) ? 1 : sin(M_PI * (x))/(M_PI * (x));
+        for (n = 0; n < N; n++)
+            lut[n] = SINC((2.*n)/(N-1)-1);
+        *overlap = 0.75;
+        break;
+    case WFUNC_GAUSS:
+        for (n = 0; n < N; n++)
+            lut[n] = pow(M_E,-0.5*pow((n-(N-1)/2)/(0.4*(N-1)/2.f),2));
+        *overlap = 0.75;
+        break;
     default:
         av_assert0(0);
     }



More information about the ffmpeg-cvslog mailing list