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/avstring.h"
22 #include "libavfilter/internal.h"
23 #include "libavutil/common.h"
24 #include "libavutil/cpu.h"
25 #include "libavutil/opt.h"
26 #include "libavutil/eval.h"
27 #include "libavutil/tx.h"
28 #include "audio.h"
29 #include "filters.h"
30 #include "window_func.h"
31 
32 typedef struct AFFTFiltContext {
33  const AVClass *class;
34  char *real_str;
35  char *img_str;
36  int fft_size;
37 
43  int nb_exprs;
44  int channels;
48  int hop_size;
49  float overlap;
52  int win_func;
55 
56 static const char *const var_names[] = { "sr", "b", "nb", "ch", "chs", "pts", "re", "im", NULL };
58 
59 #define OFFSET(x) offsetof(AFFTFiltContext, x)
60 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
61 
62 static const AVOption afftfilt_options[] = {
63  { "real", "set channels real expressions", OFFSET(real_str), AV_OPT_TYPE_STRING, {.str = "re" }, 0, 0, A },
64  { "imag", "set channels imaginary expressions", OFFSET(img_str), AV_OPT_TYPE_STRING, {.str = "im" }, 0, 0, A },
65  { "win_size", "set window size", OFFSET(fft_size), AV_OPT_TYPE_INT, {.i64=4096}, 16, 131072, A },
66  WIN_FUNC_OPTION("win_func", OFFSET(win_func), A, WFUNC_HANNING),
67  { "overlap", "set window overlap", OFFSET(overlap), AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 1, A },
68  { NULL },
69 };
70 
71 AVFILTER_DEFINE_CLASS(afftfilt);
72 
73 static inline double getreal(void *priv, double x, double ch)
74 {
75  AFFTFiltContext *s = priv;
76  int ich, ix;
77 
78  ich = av_clip(ch, 0, s->nb_exprs - 1);
79  ix = av_clip(x, 0, s->window_size / 2);
80 
81  return s->fft_out[ich][ix].re;
82 }
83 
84 static inline double getimag(void *priv, double x, double ch)
85 {
86  AFFTFiltContext *s = priv;
87  int ich, ix;
88 
89  ich = av_clip(ch, 0, s->nb_exprs - 1);
90  ix = av_clip(x, 0, s->window_size / 2);
91 
92  return s->fft_out[ich][ix].im;
93 }
94 
95 static double realf(void *priv, double x, double ch) { return getreal(priv, x, ch); }
96 static double imagf(void *priv, double x, double ch) { return getimag(priv, x, ch); }
97 
98 static const char *const func2_names[] = { "real", "imag", NULL };
99 static double (*const func2[])(void *, double, double) = { realf, imagf, NULL };
100 
102 {
103  AVFilterContext *ctx = inlink->dst;
104  AFFTFiltContext *s = ctx->priv;
105  char *saveptr = NULL;
106  int ret = 0, ch;
107  float overlap, scale = 1.f;
108  char *args;
109  const char *last_expr = "1";
110  int buf_size;
111 
112  s->channels = inlink->ch_layout.nb_channels;
113  s->fft = av_calloc(s->channels, sizeof(*s->fft));
114  s->ifft = av_calloc(s->channels, sizeof(*s->ifft));
115  if (!s->fft || !s->ifft)
116  return AVERROR(ENOMEM);
117 
118  for (int ch = 0; ch < s->channels; ch++) {
119  ret = av_tx_init(&s->fft[ch], &s->tx_fn, AV_TX_FLOAT_FFT, 0, s->fft_size, &scale, 0);
120  if (ret < 0)
121  return ret;
122  }
123 
124  for (int ch = 0; ch < s->channels; ch++) {
125  ret = av_tx_init(&s->ifft[ch], &s->itx_fn, AV_TX_FLOAT_FFT, 1, s->fft_size, &scale, 0);
126  if (ret < 0)
127  return ret;
128  }
129 
130  s->window_size = s->fft_size;
131  buf_size = FFALIGN(s->window_size, av_cpu_max_align());
132 
133  s->fft_in = av_calloc(inlink->ch_layout.nb_channels, sizeof(*s->fft_in));
134  if (!s->fft_in)
135  return AVERROR(ENOMEM);
136 
137  s->fft_out = av_calloc(inlink->ch_layout.nb_channels, sizeof(*s->fft_out));
138  if (!s->fft_out)
139  return AVERROR(ENOMEM);
140 
141  s->fft_temp = av_calloc(inlink->ch_layout.nb_channels, sizeof(*s->fft_temp));
142  if (!s->fft_temp)
143  return AVERROR(ENOMEM);
144 
145  for (ch = 0; ch < inlink->ch_layout.nb_channels; ch++) {
146  s->fft_in[ch] = av_calloc(buf_size, sizeof(**s->fft_in));
147  if (!s->fft_in[ch])
148  return AVERROR(ENOMEM);
149 
150  s->fft_out[ch] = av_calloc(buf_size, sizeof(**s->fft_out));
151  if (!s->fft_out[ch])
152  return AVERROR(ENOMEM);
153 
154  s->fft_temp[ch] = av_calloc(buf_size, sizeof(**s->fft_temp));
155  if (!s->fft_temp[ch])
156  return AVERROR(ENOMEM);
157  }
158 
159  s->real = av_calloc(inlink->ch_layout.nb_channels, sizeof(*s->real));
160  if (!s->real)
161  return AVERROR(ENOMEM);
162 
163  s->imag = av_calloc(inlink->ch_layout.nb_channels, sizeof(*s->imag));
164  if (!s->imag)
165  return AVERROR(ENOMEM);
166 
167  args = av_strdup(s->real_str);
168  if (!args)
169  return AVERROR(ENOMEM);
170 
171  for (ch = 0; ch < inlink->ch_layout.nb_channels; ch++) {
172  char *arg = av_strtok(ch == 0 ? args : NULL, "|", &saveptr);
173 
174  ret = av_expr_parse(&s->real[ch], arg ? arg : last_expr, var_names,
175  NULL, NULL, func2_names, func2, 0, ctx);
176  if (ret < 0)
177  goto fail;
178  if (arg)
179  last_expr = arg;
180  s->nb_exprs++;
181  }
182 
183  av_freep(&args);
184 
185  args = av_strdup(s->img_str ? s->img_str : s->real_str);
186  if (!args)
187  return AVERROR(ENOMEM);
188 
189  saveptr = NULL;
190  last_expr = "1";
191  for (ch = 0; ch < inlink->ch_layout.nb_channels; ch++) {
192  char *arg = av_strtok(ch == 0 ? args : NULL, "|", &saveptr);
193 
194  ret = av_expr_parse(&s->imag[ch], arg ? arg : last_expr, var_names,
195  NULL, NULL, func2_names, func2, 0, ctx);
196  if (ret < 0)
197  goto fail;
198  if (arg)
199  last_expr = arg;
200  }
201 
202  av_freep(&args);
203 
204  s->window_func_lut = av_realloc_f(s->window_func_lut, s->window_size,
205  sizeof(*s->window_func_lut));
206  if (!s->window_func_lut)
207  return AVERROR(ENOMEM);
208  generate_window_func(s->window_func_lut, s->window_size, s->win_func, &overlap);
209  for (int i = 0; i < s->window_size; i++)
210  s->window_func_lut[i] = sqrtf(s->window_func_lut[i] / s->window_size);
211  if (s->overlap == 1)
212  s->overlap = overlap;
213 
214  s->hop_size = s->window_size * (1 - s->overlap);
215  if (s->hop_size <= 0)
216  return AVERROR(EINVAL);
217 
218  s->window = ff_get_audio_buffer(inlink, s->window_size * 2);
219  if (!s->window)
220  return AVERROR(ENOMEM);
221 
222  s->buffer = ff_get_audio_buffer(inlink, s->window_size * 2);
223  if (!s->buffer)
224  return AVERROR(ENOMEM);
225 
226 fail:
227  av_freep(&args);
228 
229  return ret;
230 }
231 
232 static int tx_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
233 {
234  AFFTFiltContext *s = ctx->priv;
235  const int channels = s->channels;
236  const int start = (channels * jobnr) / nb_jobs;
237  const int end = (channels * (jobnr+1)) / nb_jobs;
238 
239  for (int ch = start; ch < end; ch++) {
240  AVComplexFloat *fft_in = s->fft_in[ch];
241  AVComplexFloat *fft_out = s->fft_out[ch];
242 
243  s->tx_fn(s->fft[ch], fft_out, fft_in, sizeof(*fft_in));
244  }
245 
246  return 0;
247 }
248 
249 static int filter_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
250 {
251  AFFTFiltContext *s = ctx->priv;
252  const int window_size = s->window_size;
253  const float *window_lut = s->window_func_lut;
254  const float f = sqrtf(1.f - s->overlap);
255  const int channels = s->channels;
256  const int start = (channels * jobnr) / nb_jobs;
257  const int end = (channels * (jobnr+1)) / nb_jobs;
258  double values[VAR_VARS_NB];
259 
260  memcpy(values, arg, sizeof(values));
261 
262  for (int ch = start; ch < end; ch++) {
263  AVComplexFloat *fft_out = s->fft_out[ch];
264  AVComplexFloat *fft_temp = s->fft_temp[ch];
265  float *buf = (float *)s->buffer->extended_data[ch];
266 
267  values[VAR_CHANNEL] = ch;
268 
269  if (ctx->is_disabled) {
270  for (int n = 0; n < window_size; n++) {
271  fft_temp[n].re = fft_out[n].re;
272  fft_temp[n].im = fft_out[n].im;
273  }
274  } else {
275  for (int n = 0; n <= window_size / 2; n++) {
276  float fr, fi;
277 
278  values[VAR_BIN] = n;
279  values[VAR_REAL] = fft_out[n].re;
280  values[VAR_IMAG] = fft_out[n].im;
281 
282  fr = av_expr_eval(s->real[ch], values, s);
283  fi = av_expr_eval(s->imag[ch], values, s);
284 
285  fft_temp[n].re = fr;
286  fft_temp[n].im = fi;
287  }
288 
289  for (int n = window_size / 2 + 1, x = window_size / 2 - 1; n < window_size; n++, x--) {
290  fft_temp[n].re = fft_temp[x].re;
291  fft_temp[n].im = -fft_temp[x].im;
292  }
293  }
294 
295  s->itx_fn(s->ifft[ch], fft_out, fft_temp, sizeof(*fft_temp));
296 
297  memmove(buf, buf + s->hop_size, window_size * sizeof(float));
298  for (int i = 0; i < window_size; i++)
299  buf[i] += fft_out[i].re * window_lut[i] * f;
300  }
301 
302  return 0;
303 }
304 
306 {
307  AVFilterContext *ctx = inlink->dst;
308  AVFilterLink *outlink = ctx->outputs[0];
309  AFFTFiltContext *s = ctx->priv;
310  const int window_size = s->window_size;
311  const float *window_lut = s->window_func_lut;
312  double values[VAR_VARS_NB];
313  int ch, n, ret;
314  AVFrame *out;
315 
316  for (ch = 0; ch < inlink->ch_layout.nb_channels; ch++) {
317  const int offset = s->window_size - s->hop_size;
318  float *src = (float *)s->window->extended_data[ch];
319  AVComplexFloat *fft_in = s->fft_in[ch];
320 
321  memmove(src, &src[s->hop_size], offset * sizeof(float));
322  memcpy(&src[offset], in->extended_data[ch], in->nb_samples * sizeof(float));
323  memset(&src[offset + in->nb_samples], 0, (s->hop_size - in->nb_samples) * sizeof(float));
324 
325  for (n = 0; n < window_size; n++) {
326  fft_in[n].re = src[n] * window_lut[n];
327  fft_in[n].im = 0;
328  }
329  }
330 
331  values[VAR_PTS] = in->pts;
332  values[VAR_SAMPLE_RATE] = inlink->sample_rate;
333  values[VAR_NBBINS] = window_size / 2;
334  values[VAR_CHANNELS] = inlink->ch_layout.nb_channels;
335 
337  FFMIN(s->channels, ff_filter_get_nb_threads(ctx)));
338 
340  FFMIN(s->channels, ff_filter_get_nb_threads(ctx)));
341 
342  out = ff_get_audio_buffer(outlink, s->hop_size);
343  if (!out) {
344  ret = AVERROR(ENOMEM);
345  goto fail;
346  }
347 
349  out->nb_samples = in->nb_samples;
350 
351  for (ch = 0; ch < inlink->ch_layout.nb_channels; ch++) {
352  float *dst = (float *)out->extended_data[ch];
353  float *buf = (float *)s->buffer->extended_data[ch];
354 
355  memcpy(dst, buf, s->hop_size * sizeof(float));
356  }
357 
358  ret = ff_filter_frame(outlink, out);
359  if (ret < 0)
360  goto fail;
361 
362 fail:
363  av_frame_free(&in);
364  return ret < 0 ? ret : 0;
365 }
366 
368 {
369  AVFilterLink *inlink = ctx->inputs[0];
370  AVFilterLink *outlink = ctx->outputs[0];
371  AFFTFiltContext *s = ctx->priv;
372  AVFrame *in = NULL;
373  int ret = 0, status;
374  int64_t pts;
375 
377 
378  ret = ff_inlink_consume_samples(inlink, s->hop_size, s->hop_size, &in);
379  if (ret < 0)
380  return ret;
381 
382  if (ret > 0)
383  ret = filter_frame(inlink, in);
384  if (ret < 0)
385  return ret;
386 
388  ff_outlink_set_status(outlink, status, pts);
389  return 0;
390  }
391 
393 
394  return FFERROR_NOT_READY;
395 }
396 
398 {
399  AFFTFiltContext *s = ctx->priv;
400  int i;
401 
402 
403  for (i = 0; i < s->channels; i++) {
404  if (s->ifft)
405  av_tx_uninit(&s->ifft[i]);
406  if (s->fft)
407  av_tx_uninit(&s->fft[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 
416  av_freep(&s->fft);
417  av_freep(&s->ifft);
418  av_freep(&s->fft_in);
419  av_freep(&s->fft_out);
420  av_freep(&s->fft_temp);
421 
422  for (i = 0; i < s->nb_exprs; i++) {
423  av_expr_free(s->real[i]);
424  av_expr_free(s->imag[i]);
425  }
426 
427  av_freep(&s->real);
428  av_freep(&s->imag);
429  av_frame_free(&s->buffer);
430  av_frame_free(&s->window);
431  av_freep(&s->window_func_lut);
432 }
433 
434 static const AVFilterPad inputs[] = {
435  {
436  .name = "default",
437  .type = AVMEDIA_TYPE_AUDIO,
438  .config_props = config_input,
439  },
440 };
441 
442 static const AVFilterPad outputs[] = {
443  {
444  .name = "default",
445  .type = AVMEDIA_TYPE_AUDIO,
446  },
447 };
448 
450  .name = "afftfilt",
451  .description = NULL_IF_CONFIG_SMALL("Apply arbitrary expressions to samples in frequency domain."),
452  .priv_size = sizeof(AFFTFiltContext),
453  .priv_class = &afftfilt_class,
457  .activate = activate,
458  .uninit = uninit,
461 };
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:100
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
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:95
AFFTFiltContext::window_func_lut
float * window_func_lut
Definition: af_afftfilt.c:53
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:41
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:969
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
afftfilt_options
static const AVOption afftfilt_options[]
Definition: af_afftfilt.c:62
AVTXContext
Definition: tx_priv.h:228
FILTER_SINGLE_SAMPLEFMT
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
Definition: internal.h:187
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:99
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:330
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:437
AVOption
AVOption.
Definition: opt.h:251
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:37
AFFTFiltContext::window
AVFrame * window
Definition: af_afftfilt.c:50
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:165
tx_channel
static int tx_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: af_afftfilt.c:232
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:883
func2_names
static const char *const func2_names[]
Definition: af_afftfilt.c:98
AFFTFiltContext::buffer
AVFrame * buffer
Definition: af_afftfilt.c:51
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:442
AVComplexFloat::im
float im
Definition: tx.h:28
fail
#define fail()
Definition: checkasm.h:134
inputs
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:434
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1389
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:49
func2
static double(*const func2[])(void *, double, double)
Definition: af_afftfilt.c:99
av_cold
#define av_cold
Definition: attributes.h:90
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:127
AFFTFiltContext::imag
AVExpr ** imag
Definition: af_afftfilt.c:47
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:44
s
#define s(width, name)
Definition: cbs_vp9.c:256
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:179
filters.h
AV_TX_FLOAT_FFT
@ AV_TX_FLOAT_FFT
Standard complex to complex FFT with sample data type of AVComplexFloat, AVComplexDouble or AVComplex...
Definition: tx.h:47
ctx
AVFormatContext * ctx
Definition: movenc.c:48
channels
channels
Definition: aptx.h:31
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:43
AVExpr
Definition: eval.c:157
VAR_SAMPLE_RATE
@ VAR_SAMPLE_RATE
Definition: af_afftfilt.c:57
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:194
filter_channel
static int filter_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: af_afftfilt.c:249
arg
const char * arg
Definition: jacosubdec.c:67
if
if(ret)
Definition: filter_design.txt:179
AFFTFiltContext::img_str
char * img_str
Definition: af_afftfilt.c:35
av_realloc_f
#define av_realloc_f(p, o, n)
Definition: tableprint_vlc.h:32
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
ff_inlink_consume_samples
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
Definition: avfilter.c:1383
NULL
#define NULL
Definition: coverity.c:32
VAR_CHANNEL
@ VAR_CHANNEL
Definition: af_afftfilt.c:57
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:594
AFFTFiltContext::real
AVExpr ** real
Definition: af_afftfilt.c:46
var_names
static const char *const var_names[]
Definition: af_afftfilt.c:56
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_afftfilt.c:101
AFFTFiltContext::real_str
char * real_str
Definition: af_afftfilt.c:34
VAR_NBBINS
@ VAR_NBBINS
Definition: af_afftfilt.c:57
AFFTFiltContext::fft_size
int fft_size
Definition: af_afftfilt.c:36
sqrtf
static __device__ float sqrtf(float a)
Definition: cuda_runtime.h:184
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(afftfilt)
double
double
Definition: af_crystalizer.c:132
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:265
generate_window_func
static void generate_window_func(float *lut, int N, int win_func, float *overlap)
Definition: window_func.h:76
WFUNC_HANNING
@ WFUNC_HANNING
Definition: window_func.h:29
VAR_IMAG
@ VAR_IMAG
Definition: af_afftfilt.c:57
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: af_afftfilt.c:305
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:1318
VAR_PTS
@ VAR_PTS
Definition: af_afftfilt.c:57
VAR_CHANNELS
@ VAR_CHANNELS
Definition: af_afftfilt.c:57
VAR_BIN
@ VAR_BIN
Definition: af_afftfilt.c:57
VAR_REAL
@ VAR_REAL
Definition: af_afftfilt.c:57
AFFTFiltContext::ifft
AVTXContext ** ifft
Definition: af_afftfilt.c:38
eval.h
f
f
Definition: af_crystalizer.c:122
A
#define A
Definition: af_afftfilt.c:60
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:115
cpu.h
VAR_VARS_NB
@ VAR_VARS_NB
Definition: af_afftfilt.c:57
AVComplexFloat::re
float re
Definition: tx.h:28
getimag
static double getimag(void *priv, double x, double ch)
Definition: af_afftfilt.c:84
activate
static int activate(AVFilterContext *ctx)
Definition: af_afftfilt.c:367
AFFTFiltContext::fft_temp
AVComplexFloat ** fft_temp
Definition: af_afftfilt.c:42
AFFTFiltContext
Definition: af_afftfilt.c:32
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
FF_FILTER_FORWARD_WANTED
FF_FILTER_FORWARD_WANTED(outlink, inlink)
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:294
internal.h
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
AFFTFiltContext::fft_in
AVComplexFloat ** fft_in
Definition: af_afftfilt.c:40
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:410
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:391
common.h
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:777
AFFTFiltContext::tx_fn
av_tx_fn tx_fn
Definition: af_afftfilt.c:39
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
imagf
static double imagf(void *priv, double x, double ch)
Definition: af_afftfilt.c:96
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:55
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
AVFilter
Filter definition.
Definition: avfilter.h:161
ff_af_afftfilt
const AVFilter ff_af_afftfilt
Definition: af_afftfilt.c:449
ret
ret
Definition: filter_design.txt:187
AFFTFiltContext::window_size
int window_size
Definition: af_afftfilt.c:45
window_func.h
AFFTFiltContext::overlap
float overlap
Definition: af_afftfilt.c:49
AFFTFiltContext::fft
AVTXContext ** fft
Definition: af_afftfilt.c:38
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
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:392
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_afftfilt.c:397
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:270
realf
static double realf(void *priv, double x, double ch)
Definition: af_afftfilt.c:95
OFFSET
#define OFFSET(x)
Definition: af_afftfilt.c:59
audio.h
getreal
static double getreal(void *priv, double x, double ch)
Definition: af_afftfilt.c:73
AFFTFiltContext::hop_size
int hop_size
Definition: af_afftfilt.c:48
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:195
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
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:150
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
ff_filter_execute
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: internal.h:146
AFFTFiltContext::win_func
int win_func
Definition: af_afftfilt.c:52
AFFTFiltContext::itx_fn
av_tx_fn itx_fn
Definition: af_afftfilt.c:39
tx.h
re
float re
Definition: fft.c:79