History

avfilter/avf_showfreqs: make selecting window size simpler

The previous solution was very bad.

Paul B Mahol committed 7 years ago

Commit 74d4fd01 parent 57a26882 files · +5 −32Browse files

Unified · Split

2 files
  1. doc/filters.texi +2 −18
  2. libavfilter/avf_showfreqs.c +3 −14
doc/filters.texi+2−18
@@ -22346,25 +22346,9 @@ Reverse logarithmic scale. · 22345 unmodified lines
2234622346 Default is @code{lin}.
2234722347
2234822348 @item win_size
22349−Set window size.
22349+Set window size. Allowed range is from 16 to 65536.
2235022350
22351−It accepts the following values:
22352−@table @samp
22353−@item w16
22354−@item w32
22355−@item w64
22356−@item w128
22357−@item w256
22358−@item w512
22359−@item w1024
22360−@item w2048
22361−@item w4096
22362−@item w8192
22363−@item w16384
22364−@item w32768
22365−@item w65536
22366−@end table
22367−Default is @code{w2048}
22351+Default is @code{2048}
2236822352
2236922353 @item win_func
2237022354 Set windowing function.
libavfilter/avf_showfreqs.c+3−14
@@ -46,6 +46,7 @@ typedef struct ShowFreqsContext { · 45 unmodified lines
4646 int w, h;
4747 int mode;
4848 int cmode;
49+ int fft_size;
4950 int fft_bits;
5051 int ascale, fscale;
5152 int avg;
@@ -85,20 +86,7 @@ static const AVOption showfreqs_options[] = { · 33 unmodified lines
8586 { "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=FS_LINEAR}, 0, 0, FLAGS, "fscale" },
8687 { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=FS_LOG}, 0, 0, FLAGS, "fscale" },
8788 { "rlog", "reverse logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=FS_RLOG}, 0, 0, FLAGS, "fscale" },
88− { "win_size", "set window size", OFFSET(fft_bits), AV_OPT_TYPE_INT, {.i64=11}, 4, 16, FLAGS, "fft" },
89− { "w16", 0, 0, AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, FLAGS, "fft" },
90− { "w32", 0, 0, AV_OPT_TYPE_CONST, {.i64=5}, 0, 0, FLAGS, "fft" },
91− { "w64", 0, 0, AV_OPT_TYPE_CONST, {.i64=6}, 0, 0, FLAGS, "fft" },
92− { "w128", 0, 0, AV_OPT_TYPE_CONST, {.i64=7}, 0, 0, FLAGS, "fft" },
93− { "w256", 0, 0, AV_OPT_TYPE_CONST, {.i64=8}, 0, 0, FLAGS, "fft" },
94− { "w512", 0, 0, AV_OPT_TYPE_CONST, {.i64=9}, 0, 0, FLAGS, "fft" },
95− { "w1024", 0, 0, AV_OPT_TYPE_CONST, {.i64=10}, 0, 0, FLAGS, "fft" },
96− { "w2048", 0, 0, AV_OPT_TYPE_CONST, {.i64=11}, 0, 0, FLAGS, "fft" },
97− { "w4096", 0, 0, AV_OPT_TYPE_CONST, {.i64=12}, 0, 0, FLAGS, "fft" },
98− { "w8192", 0, 0, AV_OPT_TYPE_CONST, {.i64=13}, 0, 0, FLAGS, "fft" },
99− { "w16384", 0, 0, AV_OPT_TYPE_CONST, {.i64=14}, 0, 0, FLAGS, "fft" },
100− { "w32768", 0, 0, AV_OPT_TYPE_CONST, {.i64=15}, 0, 0, FLAGS, "fft" },
101− { "w65536", 0, 0, AV_OPT_TYPE_CONST, {.i64=16}, 0, 0, FLAGS, "fft" },
89+ { "win_size", "set window size", OFFSET(fft_size), AV_OPT_TYPE_INT, {.i64=2048}, 16, 65536, FLAGS },
10290 { "win_func", "set window function", OFFSET(win_func), AV_OPT_TYPE_INT, {.i64=WFUNC_HANNING}, 0, NB_WFUNC-1, FLAGS, "win_func" },
10391 { "rect", "Rectangular", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_RECT}, 0, 0, FLAGS, "win_func" },
10492 { "bartlett", "Bartlett", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BARTLETT}, 0, 0, FLAGS, "win_func" },
@@ -180,6 +168,7 @@ static int config_output(AVFilterLink *outlink) · 75 unmodified lines
180168 float overlap;
181169 int i;
182170
171+ s->fft_bits = av_log2(s->fft_size);
183172 s->nb_freq = 1 << (s->fft_bits - 1);
184173 s->win_size = s->nb_freq << 1;
185174 av_audio_fifo_free(s->fifo);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t