[FFmpeg-cvslog] avfilter/af_afftfilt: make selecting window size simpler

Paul B Mahol git at videolan.org
Wed Jul 10 17:08:11 EEST 2019


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Wed Jul 10 15:57:38 2019 +0200| [57a2688fe388dd3d9e12ac59fc289dc36c1ee283] | committer: Paul B Mahol

avfilter/af_afftfilt: make selecting window size simpler

Next step after this one will be adding support for more window sizes.

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

 doc/filters.texi          | 21 ++-------------------
 libavfilter/af_afftfilt.c | 18 +++---------------
 2 files changed, 5 insertions(+), 34 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index ccbffab6ae..60b9204245 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1124,25 +1124,8 @@ Return the value of imaginary part of frequency bin at location (@var{bin}, at var{
 @end table
 
 @item win_size
-Set window size.
-
-It accepts the following values:
- at table @samp
- at item w16
- at item w32
- at item w64
- at item w128
- at item w256
- at item w512
- at item w1024
- at item w2048
- at item w4096
- at item w8192
- at item w16384
- at item w32768
- at item w65536
- at end table
-Default is @code{w4096}
+Set window size. Allowed range is from 16 to 131072.
+Default is @code{4096}
 
 @item win_func
 Set window function. Default is @code{hann}.
diff --git a/libavfilter/af_afftfilt.c b/libavfilter/af_afftfilt.c
index 7992bc9352..86278ef35b 100644
--- a/libavfilter/af_afftfilt.c
+++ b/libavfilter/af_afftfilt.c
@@ -33,6 +33,7 @@ typedef struct AFFTFiltContext {
     const AVClass *class;
     char *real_str;
     char *img_str;
+    int fft_size;
     int fft_bits;
 
     FFTContext *fft, *ifft;
@@ -61,21 +62,7 @@ enum                                   { VAR_SAMPLE_RATE, VAR_BIN, VAR_NBBINS, V
 static const AVOption afftfilt_options[] = {
     { "real", "set channels real expressions",       OFFSET(real_str), AV_OPT_TYPE_STRING, {.str = "re" }, 0, 0, A },
     { "imag", "set channels imaginary expressions",  OFFSET(img_str),  AV_OPT_TYPE_STRING, {.str = "im" }, 0, 0, A },
-    { "win_size", "set window size", OFFSET(fft_bits), AV_OPT_TYPE_INT, {.i64=12}, 4, 17, A, "fft" },
-        { "w16",    0, 0, AV_OPT_TYPE_CONST, {.i64=4},  0, 0, A, "fft" },
-        { "w32",    0, 0, AV_OPT_TYPE_CONST, {.i64=5},  0, 0, A, "fft" },
-        { "w64",    0, 0, AV_OPT_TYPE_CONST, {.i64=6},  0, 0, A, "fft" },
-        { "w128",   0, 0, AV_OPT_TYPE_CONST, {.i64=7},  0, 0, A, "fft" },
-        { "w256",   0, 0, AV_OPT_TYPE_CONST, {.i64=8},  0, 0, A, "fft" },
-        { "w512",   0, 0, AV_OPT_TYPE_CONST, {.i64=9},  0, 0, A, "fft" },
-        { "w1024",  0, 0, AV_OPT_TYPE_CONST, {.i64=10}, 0, 0, A, "fft" },
-        { "w2048",  0, 0, AV_OPT_TYPE_CONST, {.i64=11}, 0, 0, A, "fft" },
-        { "w4096",  0, 0, AV_OPT_TYPE_CONST, {.i64=12}, 0, 0, A, "fft" },
-        { "w8192",  0, 0, AV_OPT_TYPE_CONST, {.i64=13}, 0, 0, A, "fft" },
-        { "w16384", 0, 0, AV_OPT_TYPE_CONST, {.i64=14}, 0, 0, A, "fft" },
-        { "w32768", 0, 0, AV_OPT_TYPE_CONST, {.i64=15}, 0, 0, A, "fft" },
-        { "w65536", 0, 0, AV_OPT_TYPE_CONST, {.i64=16}, 0, 0, A, "fft" },
-        { "w131072",0, 0, AV_OPT_TYPE_CONST, {.i64=17}, 0, 0, A, "fft" },
+    { "win_size", "set window size", OFFSET(fft_size), AV_OPT_TYPE_INT, {.i64=4096}, 16, 131072, A },
     { "win_func", "set window function", OFFSET(win_func), AV_OPT_TYPE_INT, {.i64 = WFUNC_HANNING}, 0, NB_WFUNC-1, A, "win_func" },
         { "rect",     "Rectangular",      0, AV_OPT_TYPE_CONST, {.i64=WFUNC_RECT},     0, 0, A, "win_func" },
         { "bartlett", "Bartlett",         0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BARTLETT}, 0, 0, A, "win_func" },
@@ -143,6 +130,7 @@ static int config_input(AVFilterLink *inlink)
     const char *last_expr = "1";
 
     s->pts  = AV_NOPTS_VALUE;
+    s->fft_bits = av_log2(s->fft_size);
     s->fft  = av_fft_init(s->fft_bits, 0);
     s->ifft = av_fft_init(s->fft_bits, 1);
     if (!s->fft || !s->ifft)



More information about the ffmpeg-cvslog mailing list