FFmpeg
af_afftfilt.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Paul B Mahol
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published
8  * by the Free Software Foundation; either version 2.1 of the License,
9  * or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/audio_fifo.h"
22 #include "libavutil/avstring.h"
23 #include "libavfilter/internal.h"
24 #include "libavutil/common.h"
25 #include "libavutil/cpu.h"
26 #include "libavutil/opt.h"
27 #include "libavutil/eval.h"
28 #include "libavutil/tx.h"
29 #include "audio.h"
30 #include "filters.h"
31 #include "window_func.h"
32 
33 typedef struct AFFTFiltContext {
34  const AVClass *class;
35  char *real_str;
36  char *img_str;
37  int fft_size;
38 
44  int nb_exprs;
45  int channels;
50  int64_t pts;
51  int hop_size;
52  float overlap;
54  int eof;
55  int win_func;
58 
59 static const char *const var_names[] = { "sr", "b", "nb", "ch", "chs", "pts", "re", "im", NULL };
61 
62 #define OFFSET(x) offsetof(AFFTFiltContext, x)
63 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
64 
65 static const AVOption afftfilt_options[] = {
66  { "real", "set channels real expressions", OFFSET(real_str), AV_OPT_TYPE_STRING, {.str = "re" }, 0, 0, A },
67  { "imag", "set channels imaginary expressions", OFFSET(img_str), AV_OPT_TYPE_STRING, {.str = "im" }, 0, 0, A },
68  { "win_size", "set window size", OFFSET(fft_size), AV_OPT_TYPE_INT, {.i64=4096}, 16, 131072, A },
69  { "win_func", "set window function", OFFSET(win_func), AV_OPT_TYPE_INT, {.i64 = WFUNC_HANNING}, 0, NB_WFUNC-1, A, "win_func" },
70  { "rect", "Rectangular", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_RECT}, 0, 0, A, "win_func" },
71  { "bartlett", "Bartlett", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BARTLETT}, 0, 0, A, "win_func" },
72  { "hann", "Hann", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_HANNING}, 0, 0, A, "win_func" },
73  { "hanning", "Hanning", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_HANNING}, 0, 0, A, "win_func" },
74  { "hamming", "Hamming", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_HAMMING}, 0, 0, A, "win_func" },
75  { "blackman", "Blackman", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BLACKMAN}, 0, 0, A, "win_func" },
76  { "welch", "Welch", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_WELCH}, 0, 0, A, "win_func" },
77  { "flattop", "Flat-top", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_FLATTOP}, 0, 0, A, "win_func" },
78  { "bharris", "Blackman-Harris", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BHARRIS}, 0, 0, A, "win_func" },
79  { "bnuttall", "Blackman-Nuttall", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BNUTTALL}, 0, 0, A, "win_func" },
80  { "bhann", "Bartlett-Hann", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BHANN}, 0, 0, A, "win_func" },
81  { "sine", "Sine", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_SINE}, 0, 0, A, "win_func" },
82  { "nuttall", "Nuttall", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_NUTTALL}, 0, 0, A, "win_func" },
83  { "lanczos", "Lanczos", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_LANCZOS}, 0, 0, A, "win_func" },
84  { "gauss", "Gauss", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_GAUSS}, 0, 0, A, "win_func" },
85  { "tukey", "Tukey", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_TUKEY}, 0, 0, A, "win_func" },
86  { "dolph", "Dolph-Chebyshev", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_DOLPH}, 0, 0, A, "win_func" },
87  { "cauchy", "Cauchy", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_CAUCHY}, 0, 0, A, "win_func" },
88  { "parzen", "Parzen", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_PARZEN}, 0, 0, A, "win_func" },
89  { "poisson", "Poisson", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_POISSON}, 0, 0, A, "win_func" },
90  { "bohman", "Bohman", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BOHMAN}, 0, 0, A, "win_func" },
91  { "overlap", "set window overlap", OFFSET(overlap), AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 1, A },
92  { NULL },
93 };
94 
95 AVFILTER_DEFINE_CLASS(afftfilt);
96 
97 static inline double getreal(void *priv, double x, double ch)
98 {
99  AFFTFiltContext *s = priv;
100  int ich, ix;
101 
102  ich = av_clip(ch, 0, s->nb_exprs - 1);
103  ix = av_clip(x, 0, s->window_size / 2);
104 
105  return s->fft_out[ich][ix].re;
106 }
107 
108 static inline double getimag(void *priv, double x, double ch)
109 {
110  AFFTFiltContext *s = priv;
111  int ich, ix;
112 
113  ich = av_clip(ch, 0, s->nb_exprs - 1);
114  ix = av_clip(x, 0, s->window_size / 2);
115 
116  return s->fft_out[ich][ix].im;
117 }
118 
119 static double realf(void *priv, double x, double ch) { return getreal(priv, x, ch); }
120 static double imagf(void *priv, double x, double ch) { return getimag(priv, x, ch); }
121 
122 static const char *const func2_names[] = { "real", "imag", NULL };
123 static double (*const func2[])(void *, double, double) = { realf, imagf, NULL };
124 
126 {
127  AVFilterContext *ctx = inlink->dst;
128  AFFTFiltContext *s = ctx->priv;
129  char *saveptr = NULL;
130  int ret = 0, ch;
131  float overlap, scale;
132  char *args;
133  const char *last_expr = "1";
134  int buf_size;
135 
136  s->channels = inlink->channels;
137  s->pts = AV_NOPTS_VALUE;
138  ret = av_tx_init(&s->fft, &s->tx_fn, AV_TX_FLOAT_FFT, 0, s->fft_size, &scale, 0);
139  if (ret < 0)
140  return ret;
141 
142  ret = av_tx_init(&s->ifft, &s->itx_fn, AV_TX_FLOAT_FFT, 1, s->fft_size, &scale, 0);
143  if (ret < 0)
144  return ret;
145 
146  s->window_size = s->fft_size;
147  buf_size = FFALIGN(s->window_size, av_cpu_max_align());
148 
149  s->fft_in = av_calloc(inlink->channels, sizeof(*s->fft_in));
150  if (!s->fft_in)
151  return AVERROR(ENOMEM);
152 
153  s->fft_out = av_calloc(inlink->channels, sizeof(*s->fft_out));
154  if (!s->fft_out)
155  return AVERROR(ENOMEM);
156 
157  s->fft_temp = av_calloc(inlink->channels, sizeof(*s->fft_temp));
158  if (!s->fft_temp)
159  return AVERROR(ENOMEM);
160 
161  for (ch = 0; ch < inlink->channels; ch++) {
162  s->fft_in[ch] = av_calloc(buf_size, sizeof(**s->fft_in));
163  if (!s->fft_in[ch])
164  return AVERROR(ENOMEM);
165 
166  s->fft_out[ch] = av_calloc(buf_size, sizeof(**s->fft_out));
167  if (!s->fft_out[ch])
168  return AVERROR(ENOMEM);
169 
170  s->fft_temp[ch] = av_calloc(buf_size, sizeof(**s->fft_temp));
171  if (!s->fft_temp[ch])
172  return AVERROR(ENOMEM);
173  }
174 
175  s->real = av_calloc(inlink->channels, sizeof(*s->real));
176  if (!s->real)
177  return AVERROR(ENOMEM);
178 
179  s->imag = av_calloc(inlink->channels, sizeof(*s->imag));
180  if (!s->imag)
181  return AVERROR(ENOMEM);
182 
183  args = av_strdup(s->real_str);
184  if (!args)
185  return AVERROR(ENOMEM);
186 
187  for (ch = 0; ch < inlink->channels; ch++) {
188  char *arg = av_strtok(ch == 0 ? args : NULL, "|", &saveptr);
189 
190  ret = av_expr_parse(&s->real[ch], arg ? arg : last_expr, var_names,
191  NULL, NULL, func2_names, func2, 0, ctx);
192  if (ret < 0)
193  goto fail;
194  if (arg)
195  last_expr = arg;
196  s->nb_exprs++;
197  }
198 
199  av_freep(&args);
200 
201  args = av_strdup(s->img_str ? s->img_str : s->real_str);
202  if (!args)
203  return AVERROR(ENOMEM);
204 
205  saveptr = NULL;
206  last_expr = "1";
207  for (ch = 0; ch < inlink->channels; ch++) {
208  char *arg = av_strtok(ch == 0 ? args : NULL, "|", &saveptr);
209 
210  ret = av_expr_parse(&s->imag[ch], arg ? arg : last_expr, var_names,
211  NULL, NULL, func2_names, func2, 0, ctx);
212  if (ret < 0)
213  goto fail;
214  if (arg)
215  last_expr = arg;
216  }
217 
218  av_freep(&args);
219 
220  s->fifo = av_audio_fifo_alloc(inlink->format, inlink->channels, s->window_size);
221  if (!s->fifo)
222  return AVERROR(ENOMEM);
223 
224  s->window_func_lut = av_realloc_f(s->window_func_lut, s->window_size,
225  sizeof(*s->window_func_lut));
226  if (!s->window_func_lut)
227  return AVERROR(ENOMEM);
228  generate_window_func(s->window_func_lut, s->window_size, s->win_func, &overlap);
229  if (s->overlap == 1)
230  s->overlap = overlap;
231 
232  s->hop_size = s->window_size * (1 - s->overlap);
233  if (s->hop_size <= 0)
234  return AVERROR(EINVAL);
235 
236  s->buffer = ff_get_audio_buffer(inlink, s->window_size * 2);
237  if (!s->buffer)
238  return AVERROR(ENOMEM);
239 
240 fail:
241  av_freep(&args);
242 
243  return ret;
244 }
245 
247 {
248  AVFilterContext *ctx = inlink->dst;
249  AVFilterLink *outlink = ctx->outputs[0];
250  AFFTFiltContext *s = ctx->priv;
251  const int window_size = s->window_size;
252  const float f = 1. / (s->window_size / 2);
253  double values[VAR_VARS_NB];
254  AVFrame *out, *in = NULL;
255  int ch, n, ret, i;
256 
257  if (!in) {
258  in = ff_get_audio_buffer(outlink, window_size);
259  if (!in)
260  return AVERROR(ENOMEM);
261  }
262 
263  ret = av_audio_fifo_peek(s->fifo, (void **)in->extended_data, window_size);
264  if (ret < 0)
265  goto fail;
266 
267  for (ch = 0; ch < inlink->channels; ch++) {
268  const float *src = (float *)in->extended_data[ch];
269  AVComplexFloat *fft_in = s->fft_in[ch];
270 
271  for (n = 0; n < in->nb_samples; n++) {
272  fft_in[n].re = src[n] * s->window_func_lut[n];
273  fft_in[n].im = 0;
274  }
275 
276  for (; n < window_size; n++) {
277  fft_in[n].re = 0;
278  fft_in[n].im = 0;
279  }
280  }
281 
282  values[VAR_PTS] = s->pts;
283  values[VAR_SAMPLE_RATE] = inlink->sample_rate;
284  values[VAR_NBBINS] = window_size / 2;
285  values[VAR_CHANNELS] = inlink->channels;
286 
287  for (ch = 0; ch < inlink->channels; ch++) {
288  AVComplexFloat *fft_in = s->fft_in[ch];
289  AVComplexFloat *fft_out = s->fft_out[ch];
290 
291  s->tx_fn(s->fft, fft_out, fft_in, sizeof(float));
292  }
293 
294  for (ch = 0; ch < inlink->channels; ch++) {
295  AVComplexFloat *fft_out = s->fft_out[ch];
296  AVComplexFloat *fft_temp = s->fft_temp[ch];
297  float *buf = (float *)s->buffer->extended_data[ch];
298  int x;
299  values[VAR_CHANNEL] = ch;
300 
301  if (ctx->is_disabled) {
302  for (n = 0; n <= window_size / 2; n++) {
303  fft_temp[n].re = fft_out[n].re;
304  fft_temp[n].im = fft_out[n].im;
305  }
306  } else {
307  for (n = 0; n <= window_size / 2; n++) {
308  float fr, fi;
309 
310  values[VAR_BIN] = n;
311  values[VAR_REAL] = fft_out[n].re;
312  values[VAR_IMAG] = fft_out[n].im;
313 
314  fr = av_expr_eval(s->real[ch], values, s);
315  fi = av_expr_eval(s->imag[ch], values, s);
316 
317  fft_temp[n].re = fr;
318  fft_temp[n].im = fi;
319  }
320  }
321 
322  for (n = window_size / 2 + 1, x = window_size / 2 - 1; n < window_size; n++, x--) {
323  fft_temp[n].re = fft_temp[x].re;
324  fft_temp[n].im = -fft_temp[x].im;
325  }
326 
327  s->itx_fn(s->ifft, fft_out, fft_temp, sizeof(float));
328 
329  for (i = 0; i < window_size; i++) {
330  buf[i] += s->fft_out[ch][i].re * f;
331  }
332  }
333 
334  out = ff_get_audio_buffer(outlink, s->hop_size);
335  if (!out) {
336  ret = AVERROR(ENOMEM);
337  goto fail;
338  }
339 
340  out->pts = s->pts;
341  s->pts += av_rescale_q(s->hop_size, (AVRational){1, outlink->sample_rate}, outlink->time_base);
342 
343  for (ch = 0; ch < inlink->channels; ch++) {
344  float *dst = (float *)out->extended_data[ch];
345  float *buf = (float *)s->buffer->extended_data[ch];
346 
347  for (n = 0; n < s->hop_size; n++)
348  dst[n] = buf[n] * (1.f - s->overlap);
349  memmove(buf, buf + s->hop_size, window_size * 4);
350  }
351 
352  ret = ff_filter_frame(outlink, out);
353  if (ret < 0)
354  goto fail;
355 
356  av_audio_fifo_drain(s->fifo, s->hop_size);
357 
358 fail:
359  av_frame_free(&in);
360  return ret < 0 ? ret : 0;
361 }
362 
364 {
365  AVFilterLink *inlink = ctx->inputs[0];
366  AVFilterLink *outlink = ctx->outputs[0];
367  AFFTFiltContext *s = ctx->priv;
368  AVFrame *in = NULL;
369  int ret = 0, status;
370  int64_t pts;
371 
373 
374  if (!s->eof && av_audio_fifo_size(s->fifo) < s->window_size) {
376  if (ret < 0)
377  return ret;
378 
379  if (ret > 0) {
380  ret = av_audio_fifo_write(s->fifo, (void **)in->extended_data,
381  in->nb_samples);
382  if (ret >= 0 && s->pts == AV_NOPTS_VALUE)
383  s->pts = in->pts;
384 
385  av_frame_free(&in);
386  if (ret < 0)
387  return ret;
388  }
389  }
390 
391  if ((av_audio_fifo_size(s->fifo) >= s->window_size) ||
392  (av_audio_fifo_size(s->fifo) > 0 && s->eof)) {
394  if (av_audio_fifo_size(s->fifo) >= s->window_size)
395  ff_filter_set_ready(ctx, 100);
396  return ret;
397  }
398 
399  if (!s->eof && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
400  if (status == AVERROR_EOF) {
401  s->eof = 1;
402  if (av_audio_fifo_size(s->fifo) >= 0) {
403  ff_filter_set_ready(ctx, 100);
404  return 0;
405  }
406  }
407  }
408 
409  if (s->eof && av_audio_fifo_size(s->fifo) <= 0) {
410  ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
411  return 0;
412  }
413 
414  if (!s->eof)
416 
417  return FFERROR_NOT_READY;
418 }
419 
421 {
422  static const enum AVSampleFormat sample_fmts[] = {
425  };
427  if (ret < 0)
428  return ret;
429 
431  if (ret < 0)
432  return ret;
433 
435 }
436 
438 {
439  AFFTFiltContext *s = ctx->priv;
440  int i;
441 
442  av_tx_uninit(&s->fft);
443  av_tx_uninit(&s->ifft);
444 
445  for (i = 0; i < s->channels; i++) {
446  if (s->fft_in)
447  av_freep(&s->fft_in[i]);
448  if (s->fft_out)
449  av_freep(&s->fft_out[i]);
450  if (s->fft_temp)
451  av_freep(&s->fft_temp[i]);
452  }
453  av_freep(&s->fft_in);
454  av_freep(&s->fft_out);
455  av_freep(&s->fft_temp);
456 
457  for (i = 0; i < s->nb_exprs; i++) {
458  av_expr_free(s->real[i]);
459  av_expr_free(s->imag[i]);
460  }
461 
462  av_freep(&s->real);
463  av_freep(&s->imag);
464  av_frame_free(&s->buffer);
465  av_freep(&s->window_func_lut);
466 
467  av_audio_fifo_free(s->fifo);
468 }
469 
470 static const AVFilterPad inputs[] = {
471  {
472  .name = "default",
473  .type = AVMEDIA_TYPE_AUDIO,
474  .config_props = config_input,
475  },
476 };
477 
478 static const AVFilterPad outputs[] = {
479  {
480  .name = "default",
481  .type = AVMEDIA_TYPE_AUDIO,
482  },
483 };
484 
486  .name = "afftfilt",
487  .description = NULL_IF_CONFIG_SMALL("Apply arbitrary expressions to samples in frequency domain."),
488  .priv_size = sizeof(AFFTFiltContext),
489  .priv_class = &afftfilt_class,
492  .activate = activate,
493  .query_formats = query_formats,
494  .uninit = uninit,
496 };
av_audio_fifo_free
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
Definition: audio_fifo.c:45
ff_get_audio_buffer
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:88
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:69
status
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
av_clip
#define av_clip
Definition: common.h:96
AFFTFiltContext::window_func_lut
float * window_func_lut
Definition: af_afftfilt.c:56
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
AFFTFiltContext::fft_out
AVComplexFloat ** fft_out
Definition: af_afftfilt.c:42
out
FILE * out
Definition: movenc.c:54
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1019
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:948
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
afftfilt_options
static const AVOption afftfilt_options[]
Definition: af_afftfilt.c:65
AVTXContext
Definition: tx_priv.h:110
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:112
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:303
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:396
AVOption
AVOption.
Definition: opt.h:247
VAR_CHANNELS
@ VAR_CHANNELS
Definition: af_afftfilt.c:60
AFFTFiltContext::fft
AVTXContext * fft
Definition: af_afftfilt.c:39
ff_set_common_all_samplerates
int ff_set_common_all_samplerates(AVFilterContext *ctx)
Equivalent to ff_set_common_samplerates(ctx, ff_all_samplerates())
Definition: formats.c:682
AVComplexFloat
Definition: tx.h:27
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:153
FF_FILTER_FORWARD_STATUS_BACK
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
Definition: filters.h:199
WFUNC_FLATTOP
@ WFUNC_FLATTOP
Definition: window_func.h:29
av_tx_init
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
Definition: tx.c:228
func2_names
static const char *const func2_names[]
Definition: af_afftfilt.c:122
AFFTFiltContext::buffer
AVFrame * buffer
Definition: af_afftfilt.c:53
av_expr_parse
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
Definition: eval.c:685
outputs
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:478
ff_inlink_consume_frame
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Definition: avfilter.c:1418
WFUNC_BLACKMAN
@ WFUNC_BLACKMAN
Definition: af_firequalizer.c:37
AVComplexFloat::im
float im
Definition: tx.h:28
WFUNC_PARZEN
@ WFUNC_PARZEN
Definition: window_func.h:32
AVAudioFifo
Context for an Audio FIFO Buffer.
Definition: audio_fifo.c:34
VAR_VARS_NB
@ VAR_VARS_NB
Definition: af_afftfilt.c:60
av_audio_fifo_drain
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples)
Drain data from an AVAudioFifo.
Definition: audio_fifo.c:201
fail
#define fail()
Definition: checkasm.h:127
inputs
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:470
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1376
pts
static int64_t pts
Definition: transcode_aac.c:653
av_expr_free
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition: eval.c:336
WFUNC_BHANN
@ WFUNC_BHANN
Definition: window_func.h:31
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
func2
static double(*const func2[])(void *, double, double)
Definition: af_afftfilt.c:123
WFUNC_DOLPH
@ WFUNC_DOLPH
Definition: window_func.h:32
av_cold
#define av_cold
Definition: attributes.h:90
AFFTFiltContext::pts
int64_t pts
Definition: af_afftfilt.c:50
av_tx_fn
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
Definition: tx.h:102
AFFTFiltContext::imag
AVExpr ** imag
Definition: af_afftfilt.c:48
VAR_REAL
@ VAR_REAL
Definition: af_afftfilt.c:60
WFUNC_NUTTALL
@ WFUNC_NUTTALL
Definition: af_firequalizer.c:40
ff_outlink_set_status
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
Definition: filters.h:189
AFFTFiltContext::channels
int channels
Definition: af_afftfilt.c:45
s
#define s(width, name)
Definition: cbs_vp9.c:257
av_audio_fifo_write
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples)
Write data to an AVAudioFifo.
Definition: audio_fifo.c:112
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
av_strtok
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
Definition: avstring.c:186
ff_set_common_formats_from_list
int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts)
Equivalent to ff_set_common_formats(ctx, ff_make_format_list(fmts))
Definition: formats.c:698
WFUNC_LANCZOS
@ WFUNC_LANCZOS
Definition: window_func.h:31
filters.h
AV_TX_FLOAT_FFT
@ AV_TX_FLOAT_FFT
Standard complex to complex FFT with sample data type AVComplexFloat.
Definition: tx.h:45
WFUNC_RECT
@ WFUNC_RECT
Definition: window_func.h:28
ctx
AVFormatContext * ctx
Definition: movenc.c:48
av_expr_eval
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:766
WFUNC_BHARRIS
@ WFUNC_BHARRIS
Definition: af_firequalizer.c:42
AFFTFiltContext::nb_exprs
int nb_exprs
Definition: af_afftfilt.c:44
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:141
AVExpr
Definition: eval.c:157
f
#define f(width, name)
Definition: cbs_vp9.c:255
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:152
arg
const char * arg
Definition: jacosubdec.c:67
if
if(ret)
Definition: filter_design.txt:179
AFFTFiltContext::ifft
AVTXContext * ifft
Definition: af_afftfilt.c:39
AFFTFiltContext::img_str
char * img_str
Definition: af_afftfilt.c:36
av_realloc_f
#define av_realloc_f(p, o, n)
Definition: tableprint_vlc.h:33
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
AFFTFiltContext::real
AVExpr ** real
Definition: af_afftfilt.c:47
var_names
static const char *const var_names[]
Definition: af_afftfilt.c:59
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_afftfilt.c:125
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AFFTFiltContext::real_str
char * real_str
Definition: af_afftfilt.c:35
av_audio_fifo_alloc
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
Definition: audio_fifo.c:59
WFUNC_HAMMING
@ WFUNC_HAMMING
Definition: af_firequalizer.c:36
src
#define src
Definition: vp8dsp.c:255
AFFTFiltContext::fft_size
int fft_size
Definition: af_afftfilt.c:37
VAR_SAMPLE_RATE
@ VAR_SAMPLE_RATE
Definition: af_afftfilt.c:60
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(afftfilt)
av_cpu_max_align
size_t av_cpu_max_align(void)
Get the maximum data alignment that may be required by FFmpeg.
Definition: cpu.c:244
generate_window_func
static void generate_window_func(float *lut, int N, int win_func, float *overlap)
Definition: window_func.h:36
WFUNC_HANNING
@ WFUNC_HANNING
Definition: window_func.h:28
WFUNC_BARTLETT
@ WFUNC_BARTLETT
Definition: window_func.h:29
WFUNC_BOHMAN
@ WFUNC_BOHMAN
Definition: window_func.h:33
ff_set_common_all_channel_counts
int ff_set_common_all_channel_counts(AVFilterContext *ctx)
Equivalent to ff_set_common_channel_layouts(ctx, ff_all_channel_counts())
Definition: formats.c:664
VAR_CHANNEL
@ VAR_CHANNEL
Definition: af_afftfilt.c:60
ff_inlink_acknowledge_status
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
Definition: avfilter.c:1372
VAR_IMAG
@ VAR_IMAG
Definition: af_afftfilt.c:60
for
for(j=16;j >0;--j)
Definition: h264pred_template.c:469
filter_frame
static int filter_frame(AVFilterLink *inlink)
Definition: af_afftfilt.c:246
eval.h
A
#define A
Definition: af_afftfilt.c:63
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
cpu.h
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
AVComplexFloat::re
float re
Definition: tx.h:28
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
AFFTFiltContext::fifo
AVAudioFifo * fifo
Definition: af_afftfilt.c:49
WFUNC_TUKEY
@ WFUNC_TUKEY
Definition: af_firequalizer.c:43
getimag
static double getimag(void *priv, double x, double ch)
Definition: af_afftfilt.c:108
activate
static int activate(AVFilterContext *ctx)
Definition: af_afftfilt.c:363
AFFTFiltContext::fft_temp
AVComplexFloat ** fft_temp
Definition: af_afftfilt.c:43
AFFTFiltContext
Definition: af_afftfilt.c:33
FF_FILTER_FORWARD_WANTED
FF_FILTER_FORWARD_WANTED(outlink, inlink)
av_audio_fifo_size
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
Definition: audio_fifo.c:228
av_tx_uninit
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets ctx to NULL, does nothing when ctx == NULL.
Definition: tx.c:213
internal.h
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:227
AFFTFiltContext::fft_in
AVComplexFloat ** fft_in
Definition: af_afftfilt.c:41
AFFTFiltContext::eof
int eof
Definition: af_afftfilt.c:54
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:369
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:350
common.h
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
AFFTFiltContext::tx_fn
av_tx_fn tx_fn
Definition: af_afftfilt.c:40
audio_fifo.h
imagf
static double imagf(void *priv, double x, double ch)
Definition: af_afftfilt.c:120
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:271
AVFilter
Filter definition.
Definition: avfilter.h:149
ff_af_afftfilt
const AVFilter ff_af_afftfilt
Definition: af_afftfilt.c:485
ret
ret
Definition: filter_design.txt:187
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: af_afftfilt.c:420
AFFTFiltContext::window_size
int window_size
Definition: af_afftfilt.c:46
window_func.h
NB_WFUNC
@ NB_WFUNC
Definition: af_firequalizer.c:44
AFFTFiltContext::overlap
float overlap
Definition: af_afftfilt.c:52
WFUNC_SINE
@ WFUNC_SINE
Definition: window_func.h:30
WFUNC_CAUCHY
@ WFUNC_CAUCHY
Definition: window_func.h:32
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
values
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return values
Definition: filter_design.txt:263
AVFilterContext
An instance of a filter.
Definition: avfilter.h:346
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_afftfilt.c:437
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:279
WFUNC_GAUSS
@ WFUNC_GAUSS
Definition: window_func.h:31
realf
static double realf(void *priv, double x, double ch)
Definition: af_afftfilt.c:119
OFFSET
#define OFFSET(x)
Definition: af_afftfilt.c:62
WFUNC_BNUTTALL
@ WFUNC_BNUTTALL
Definition: af_firequalizer.c:41
audio.h
WFUNC_POISSON
@ WFUNC_POISSON
Definition: window_func.h:32
getreal
static double getreal(void *priv, double x, double ch)
Definition: af_afftfilt.c:97
AFFTFiltContext::hop_size
int hop_size
Definition: af_afftfilt.c:51
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:153
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
VAR_PTS
@ VAR_PTS
Definition: af_afftfilt.c:60
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:138
VAR_BIN
@ VAR_BIN
Definition: af_afftfilt.c:60
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:228
VAR_NBBINS
@ VAR_NBBINS
Definition: af_afftfilt.c:60
av_audio_fifo_peek
int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples)
Peek data from an AVAudioFifo.
Definition: audio_fifo.c:138
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
AFFTFiltContext::win_func
int win_func
Definition: af_afftfilt.c:55
WFUNC_WELCH
@ WFUNC_WELCH
Definition: window_func.h:29
AFFTFiltContext::itx_fn
av_tx_fn itx_fn
Definition: af_afftfilt.c:40
ff_filter_set_ready
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
Definition: avfilter.c:212
tx.h