Commit 57a2688f authored by Paul B Mahol's avatar Paul B Mahol

avfilter/af_afftfilt: make selecting window size simpler

Next step after this one will be adding support for more window sizes.
parent b1febda0
......@@ -1124,25 +1124,8 @@ Return the value of imaginary part of frequency bin at location (@var{bin},@var{
@end table
@item win_size
Set window size.
It accepts the following values:
@table @samp
@item w16
@item w32
@item w64
@item w128
@item w256
@item w512
@item w1024
@item w2048
@item w4096
@item w8192
@item w16384
@item w32768
@item w65536
@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}.
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment