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_OPTION("win_func", OFFSET(win_func), A, WFUNC_HANNING),
70  { "overlap", "set window overlap", OFFSET(overlap), AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 1, A },
71  { NULL },
72 };
73 
74 AVFILTER_DEFINE_CLASS(afftfilt);
75 
76 static inline double getreal(void *priv, double x, double ch)
77 {
78  AFFTFiltContext *s = priv;
79  int ich, ix;
80 
81  ich = av_clip(ch, 0, s->nb_exprs - 1);
82  ix = av_clip(x, 0, s->window_size / 2);
83 
84  return s->fft_out[ich][ix].re;
85 }
86 
87 static inline double getimag(void *priv, double x, double ch)
88 {
89  AFFTFiltContext *s = priv;
90  int ich, ix;
91 
92  ich = av_clip(ch, 0, s->nb_exprs - 1);
93  ix = av_clip(x, 0, s->window_size / 2);
94 
95  return s->fft_out[ich][ix].im;
96 }
97 
98 static double realf(void *priv, double x, double ch) { return getreal(priv, x, ch); }
99 static double imagf(void *priv, double x, double ch) { return getimag(priv, x, ch); }
100 
101 static const char *const func2_names[] = { "real", "imag", NULL };
102 static double (*const func2[])(void *, double, double) = { realf, imagf, NULL };
103 
105 {
106  AVFilterContext *ctx = inlink->dst;
107  AFFTFiltContext *s = ctx->priv;
108  char *saveptr = NULL;
109  int ret = 0, ch;
110  float overlap, scale;
111  char *args;
112  const char *last_expr = "1";
113  int buf_size;
114 
115  s->channels = inlink->channels;
116  s->pts = AV_NOPTS_VALUE;
117  ret = av_tx_init(&s->fft, &s->tx_fn, AV_TX_FLOAT_FFT, 0, s->fft_size, &scale, 0);
118  if (ret < 0)
119  return ret;
120 
121  ret = av_tx_init(&s->ifft, &s->itx_fn, AV_TX_FLOAT_FFT, 1, s->fft_size, &scale, 0);
122  if (ret < 0)
123  return ret;
124 
125  s->window_size = s->fft_size;
126  buf_size = FFALIGN(s->window_size, av_cpu_max_align());
127 
128  s->fft_in = av_calloc(inlink->channels, sizeof(*s->fft_in));
129  if (!s->fft_in)
130  return AVERROR(ENOMEM);
131 
132  s->fft_out = av_calloc(inlink->channels, sizeof(*s->fft_out));
133  if (!s->fft_out)
134  return AVERROR(ENOMEM);
135 
136  s->fft_temp = av_calloc(inlink->channels, sizeof(*s->fft_temp));
137  if (!s->fft_temp)
138  return AVERROR(ENOMEM);
139 
140  for (ch = 0; ch < inlink->channels; ch++) {
141  s->fft_in[ch] = av_calloc(buf_size, sizeof(**s->fft_in));
142  if (!s->fft_in[ch])
143  return AVERROR(ENOMEM);
144 
145  s->fft_out[ch] = av_calloc(buf_size, sizeof(**s->fft_out));
146  if (!s->fft_out[ch])
147  return AVERROR(ENOMEM);
148 
149  s->fft_temp[ch] = av_calloc(buf_size, sizeof(**s->fft_temp));
150  if (!s->fft_temp[ch])
151  return AVERROR(ENOMEM);
152  }
153 
154  s->real = av_calloc(inlink->channels, sizeof(*s->real));
155  if (!s->real)
156  return AVERROR(ENOMEM);
157 
158  s->imag = av_calloc(inlink->channels, sizeof(*s->imag));
159  if (!s->imag)
160  return AVERROR(ENOMEM);
161 
162  args = av_strdup(s->real_str);
163  if (!args)
164  return AVERROR(ENOMEM);
165 
166  for (ch = 0; ch < inlink->channels; ch++) {
167  char *arg = av_strtok(ch == 0 ? args : NULL, "|", &saveptr);
168 
169  ret = av_expr_parse(&s->real[ch], arg ? arg : last_expr, var_names,
170  NULL, NULL, func2_names, func2, 0, ctx);
171  if (ret < 0)
172  goto fail;
173  if (arg)
174  last_expr = arg;
175  s->nb_exprs++;
176  }
177 
178  av_freep(&args);
179 
180  args = av_strdup(s->img_str ? s->img_str : s->real_str);
181  if (!args)
182  return AVERROR(ENOMEM);
183 
184  saveptr = NULL;
185  last_expr = "1";
186  for (ch = 0; ch < inlink->channels; ch++) {
187  char *arg = av_strtok(ch == 0 ? args : NULL, "|", &saveptr);
188 
189  ret = av_expr_parse(&s->imag[ch], arg ? arg : last_expr, var_names,
190  NULL, NULL, func2_names, func2, 0, ctx);
191  if (ret < 0)
192  goto fail;
193  if (arg)
194  last_expr = arg;
195  }
196 
197  av_freep(&args);
198 
199  s->fifo = av_audio_fifo_alloc(inlink->format, inlink->channels, s->window_size);
200  if (!s->fifo)
201  return AVERROR(ENOMEM);
202 
203  s->window_func_lut = av_realloc_f(s->window_func_lut, s->window_size,
204  sizeof(*s->window_func_lut));
205  if (!s->window_func_lut)
206  return AVERROR(ENOMEM);
207  generate_window_func(s->window_func_lut, s->window_size, s->win_func, &overlap);
208  if (s->overlap == 1)
209  s->overlap = overlap;
210 
211  s->hop_size = s->window_size * (1 - s->overlap);
212  if (s->hop_size <= 0)
213  return AVERROR(EINVAL);
214 
215  s->buffer = ff_get_audio_buffer(inlink, s->window_size * 2);
216  if (!s->buffer)
217  return AVERROR(ENOMEM);
218 
219 fail:
220  av_freep(&args);
221 
222  return ret;
223 }
224 
226 {
227  AVFilterContext *ctx = inlink->dst;
228  AVFilterLink *outlink = ctx->outputs[0];
229  AFFTFiltContext *s = ctx->priv;
230  const int window_size = s->window_size;
231  const float f = 1. / (s->window_size / 2);
232  double values[VAR_VARS_NB];
233  AVFrame *out, *in = NULL;
234  int ch, n, ret, i;
235 
236  if (!in) {
237  in = ff_get_audio_buffer(outlink, window_size);
238  if (!in)
239  return AVERROR(ENOMEM);
240  }
241 
242  ret = av_audio_fifo_peek(s->fifo, (void **)in->extended_data, window_size);
243  if (ret < 0)
244  goto fail;
245 
246  for (ch = 0; ch < inlink->channels; ch++) {
247  const float *src = (float *)in->extended_data[ch];
248  AVComplexFloat *fft_in = s->fft_in[ch];
249 
250  for (n = 0; n < in->nb_samples; n++) {
251  fft_in[n].re = src[n] * s->window_func_lut[n];
252  fft_in[n].im = 0;
253  }
254 
255  for (; n < window_size; n++) {
256  fft_in[n].re = 0;
257  fft_in[n].im = 0;
258  }
259  }
260 
261  values[VAR_PTS] = s->pts;
262  values[VAR_SAMPLE_RATE] = inlink->sample_rate;
263  values[VAR_NBBINS] = window_size / 2;
264  values[VAR_CHANNELS] = inlink->channels;
265 
266  for (ch = 0; ch < inlink->channels; ch++) {
267  AVComplexFloat *fft_in = s->fft_in[ch];
268  AVComplexFloat *fft_out = s->fft_out[ch];
269 
270  s->tx_fn(s->fft, fft_out, fft_in, sizeof(float));
271  }
272 
273  for (ch = 0; ch < inlink->channels; ch++) {
274  AVComplexFloat *fft_out = s->fft_out[ch];
275  AVComplexFloat *fft_temp = s->fft_temp[ch];
276  float *buf = (float *)s->buffer->extended_data[ch];
277  int x;
278  values[VAR_CHANNEL] = ch;
279 
280  if (ctx->is_disabled) {
281  for (n = 0; n <= window_size / 2; n++) {
282  fft_temp[n].re = fft_out[n].re;
283  fft_temp[n].im = fft_out[n].im;
284  }
285  } else {
286  for (n = 0; n <= window_size / 2; n++) {
287  float fr, fi;
288 
289  values[VAR_BIN] = n;
290  values[VAR_REAL] = fft_out[n].re;
291  values[VAR_IMAG] = fft_out[n].im;
292 
293  fr = av_expr_eval(s->real[ch], values, s);
294  fi = av_expr_eval(s->imag[ch], values, s);
295 
296  fft_temp[n].re = fr;
297  fft_temp[n].im = fi;
298  }
299  }
300 
301  for (n = window_size / 2 + 1, x = window_size / 2 - 1; n < window_size; n++, x--) {
302  fft_temp[n].re = fft_temp[x].re;
303  fft_temp[n].im = -fft_temp[x].im;
304  }
305 
306  s->itx_fn(s->ifft, fft_out, fft_temp, sizeof(float));
307 
308  for (i = 0; i < window_size; i++) {
309  buf[i] += s->fft_out[ch][i].re * f;
310  }
311  }
312 
313  out = ff_get_audio_buffer(outlink, s->hop_size);
314  if (!out) {
315  ret = AVERROR(ENOMEM);
316  goto fail;
317  }
318 
319  out->pts = s->pts;
320  s->pts += av_rescale_q(s->hop_size, (AVRational){1, outlink->sample_rate}, outlink->time_base);
321 
322  for (ch = 0; ch < inlink->channels; ch++) {
323  float *dst = (float *)out->extended_data[ch];
324  float *buf = (float *)s->buffer->extended_data[ch];
325 
326  for (n = 0; n < s->hop_size; n++)
327  dst[n] = buf[n] * (1.f - s->overlap);
328  memmove(buf, buf + s->hop_size, window_size * 4);
329  }
330 
331  ret = ff_filter_frame(outlink, out);
332  if (ret < 0)
333  goto fail;
334 
335  av_audio_fifo_drain(s->fifo, s->hop_size);
336 
337 fail:
338  av_frame_free(&in);
339  return ret < 0 ? ret : 0;
340 }
341 
343 {
344  AVFilterLink *inlink = ctx->inputs[0];
345  AVFilterLink *outlink = ctx->outputs[0];
346  AFFTFiltContext *s = ctx->priv;
347  AVFrame *in = NULL;
348  int ret = 0, status;
349  int64_t pts;
350 
352 
353  if (!s->eof && av_audio_fifo_size(s->fifo) < s->window_size) {
355  if (ret < 0)
356  return ret;
357 
358  if (ret > 0) {
359  ret = av_audio_fifo_write(s->fifo, (void **)in->extended_data,
360  in->nb_samples);
361  if (ret >= 0 && s->pts == AV_NOPTS_VALUE)
362  s->pts = in->pts;
363 
364  av_frame_free(&in);
365  if (ret < 0)
366  return ret;
367  }
368  }
369 
370  if ((av_audio_fifo_size(s->fifo) >= s->window_size) ||
371  (av_audio_fifo_size(s->fifo) > 0 && s->eof)) {
373  if (av_audio_fifo_size(s->fifo) >= s->window_size)
374  ff_filter_set_ready(ctx, 100);
375  return ret;
376  }
377 
378  if (!s->eof && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
379  if (status == AVERROR_EOF) {
380  s->eof = 1;
381  if (av_audio_fifo_size(s->fifo) >= 0) {
382  ff_filter_set_ready(ctx, 100);
383  return 0;
384  }
385  }
386  }
387 
388  if (s->eof && av_audio_fifo_size(s->fifo) <= 0) {
389  ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
390  return 0;
391  }
392 
393  if (!s->eof)
395 
396  return FFERROR_NOT_READY;
397 }
398 
400 {
401  AFFTFiltContext *s = ctx->priv;
402  int i;
403 
404  av_tx_uninit(&s->fft);
405  av_tx_uninit(&s->ifft);
406 
407  for (i = 0; i < s->channels; i++) {
408  if (s->fft_in)
409  av_freep(&s->fft_in[i]);
410  if (s->fft_out)
411  av_freep(&s->fft_out[i]);
412  if (s->fft_temp)
413  av_freep(&s->fft_temp[i]);
414  }
415  av_freep(&s->fft_in);
416  av_freep(&s->fft_out);
417  av_freep(&s->fft_temp);
418 
419  for (i = 0; i < s->nb_exprs; i++) {
420  av_expr_free(s->real[i]);
421  av_expr_free(s->imag[i]);
422  }
423 
424  av_freep(&s->real);
425  av_freep(&s->imag);
426  av_frame_free(&s->buffer);
427  av_freep(&s->window_func_lut);
428 
429  av_audio_fifo_free(s->fifo);
430 }
431 
432 static const AVFilterPad inputs[] = {
433  {
434  .name = "default",
435  .type = AVMEDIA_TYPE_AUDIO,
436  .config_props = config_input,
437  },
438 };
439 
440 static const AVFilterPad outputs[] = {
441  {
442  .name = "default",
443  .type = AVMEDIA_TYPE_AUDIO,
444  },
445 };
446 
448  .name = "afftfilt",
449  .description = NULL_IF_CONFIG_SMALL("Apply arbitrary expressions to samples in frequency domain."),
450  .priv_size = sizeof(AFFTFiltContext),
451  .priv_class = &afftfilt_class,
455  .activate = activate,
456  .uninit = uninit,
458 };
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:1018
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
FILTER_SINGLE_SAMPLEFMT
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
Definition: internal.h:184
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
AVComplexFloat
Definition: tx.h:27
WIN_FUNC_OPTION
#define WIN_FUNC_OPTION(win_func_opt_name, win_func_offset, flag, default_window_func)
Definition: window_func.h:36
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
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:101
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:440
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:1417
AVComplexFloat::im
float im
Definition: tx.h:28
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:432
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1377
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
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:102
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
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
filters.h
AV_TX_FLOAT_FFT
@ AV_TX_FLOAT_FFT
Standard complex to complex FFT with sample data type AVComplexFloat.
Definition: tx.h:45
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
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:191
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:104
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
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:60
WFUNC_HANNING
@ WFUNC_HANNING
Definition: window_func.h:28
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:1371
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:225
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
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
getimag
static double getimag(void *priv, double x, double ch)
Definition: af_afftfilt.c:87
activate
static int activate(AVFilterContext *ctx)
Definition: af_afftfilt.c:342
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
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:99
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:447
ret
ret
Definition: filter_design.txt:187
AFFTFiltContext::window_size
int window_size
Definition: af_afftfilt.c:46
window_func.h
AFFTFiltContext::overlap
float overlap
Definition: af_afftfilt.c:52
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:386
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_afftfilt.c:399
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:279
realf
static double realf(void *priv, double x, double ch)
Definition: af_afftfilt.c:98
OFFSET
#define OFFSET(x)
Definition: af_afftfilt.c:62
audio.h
getreal
static double getreal(void *priv, double x, double ch)
Definition: af_afftfilt.c:76
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:192
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
AFFTFiltContext::win_func
int win_func
Definition: af_afftfilt.c:55
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:211
tx.h