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;
108  char *args;
109  const char *last_expr = "1";
110  int buf_size;
111 
112  s->channels = inlink->ch_layout.nb_channels;
113  ret = av_tx_init(&s->fft, &s->tx_fn, AV_TX_FLOAT_FFT, 0, s->fft_size, &scale, 0);
114  if (ret < 0)
115  return ret;
116 
117  ret = av_tx_init(&s->ifft, &s->itx_fn, AV_TX_FLOAT_FFT, 1, s->fft_size, &scale, 0);
118  if (ret < 0)
119  return ret;
120 
121  s->window_size = s->fft_size;
122  buf_size = FFALIGN(s->window_size, av_cpu_max_align());
123 
124  s->fft_in = av_calloc(inlink->ch_layout.nb_channels, sizeof(*s->fft_in));
125  if (!s->fft_in)
126  return AVERROR(ENOMEM);
127 
128  s->fft_out = av_calloc(inlink->ch_layout.nb_channels, sizeof(*s->fft_out));
129  if (!s->fft_out)
130  return AVERROR(ENOMEM);
131 
132  s->fft_temp = av_calloc(inlink->ch_layout.nb_channels, sizeof(*s->fft_temp));
133  if (!s->fft_temp)
134  return AVERROR(ENOMEM);
135 
136  for (ch = 0; ch < inlink->ch_layout.nb_channels; ch++) {
137  s->fft_in[ch] = av_calloc(buf_size, sizeof(**s->fft_in));
138  if (!s->fft_in[ch])
139  return AVERROR(ENOMEM);
140 
141  s->fft_out[ch] = av_calloc(buf_size, sizeof(**s->fft_out));
142  if (!s->fft_out[ch])
143  return AVERROR(ENOMEM);
144 
145  s->fft_temp[ch] = av_calloc(buf_size, sizeof(**s->fft_temp));
146  if (!s->fft_temp[ch])
147  return AVERROR(ENOMEM);
148  }
149 
150  s->real = av_calloc(inlink->ch_layout.nb_channels, sizeof(*s->real));
151  if (!s->real)
152  return AVERROR(ENOMEM);
153 
154  s->imag = av_calloc(inlink->ch_layout.nb_channels, sizeof(*s->imag));
155  if (!s->imag)
156  return AVERROR(ENOMEM);
157 
158  args = av_strdup(s->real_str);
159  if (!args)
160  return AVERROR(ENOMEM);
161 
162  for (ch = 0; ch < inlink->ch_layout.nb_channels; ch++) {
163  char *arg = av_strtok(ch == 0 ? args : NULL, "|", &saveptr);
164 
165  ret = av_expr_parse(&s->real[ch], arg ? arg : last_expr, var_names,
166  NULL, NULL, func2_names, func2, 0, ctx);
167  if (ret < 0)
168  goto fail;
169  if (arg)
170  last_expr = arg;
171  s->nb_exprs++;
172  }
173 
174  av_freep(&args);
175 
176  args = av_strdup(s->img_str ? s->img_str : s->real_str);
177  if (!args)
178  return AVERROR(ENOMEM);
179 
180  saveptr = NULL;
181  last_expr = "1";
182  for (ch = 0; ch < inlink->ch_layout.nb_channels; ch++) {
183  char *arg = av_strtok(ch == 0 ? args : NULL, "|", &saveptr);
184 
185  ret = av_expr_parse(&s->imag[ch], arg ? arg : last_expr, var_names,
186  NULL, NULL, func2_names, func2, 0, ctx);
187  if (ret < 0)
188  goto fail;
189  if (arg)
190  last_expr = arg;
191  }
192 
193  av_freep(&args);
194 
195  s->window_func_lut = av_realloc_f(s->window_func_lut, s->window_size,
196  sizeof(*s->window_func_lut));
197  if (!s->window_func_lut)
198  return AVERROR(ENOMEM);
199  generate_window_func(s->window_func_lut, s->window_size, s->win_func, &overlap);
200  for (int i = 0; i < s->window_size; i++)
201  s->window_func_lut[i] = sqrtf(s->window_func_lut[i] / s->window_size);
202  if (s->overlap == 1)
203  s->overlap = overlap;
204 
205  s->hop_size = s->window_size * (1 - s->overlap);
206  if (s->hop_size <= 0)
207  return AVERROR(EINVAL);
208 
209  s->window = ff_get_audio_buffer(inlink, s->window_size * 2);
210  if (!s->window)
211  return AVERROR(ENOMEM);
212 
213  s->buffer = ff_get_audio_buffer(inlink, s->window_size * 2);
214  if (!s->buffer)
215  return AVERROR(ENOMEM);
216 
217 fail:
218  av_freep(&args);
219 
220  return ret;
221 }
222 
224 {
225  AVFilterContext *ctx = inlink->dst;
226  AVFilterLink *outlink = ctx->outputs[0];
227  AFFTFiltContext *s = ctx->priv;
228  const int window_size = s->window_size;
229  const float *window_lut = s->window_func_lut;
230  const float f = sqrtf(1.f - s->overlap);
231  double values[VAR_VARS_NB];
232  int ch, n, ret, i;
233  AVFrame *out;
234 
235  for (ch = 0; ch < inlink->ch_layout.nb_channels; ch++) {
236  const int offset = s->window_size - s->hop_size;
237  float *src = (float *)s->window->extended_data[ch];
238  AVComplexFloat *fft_in = s->fft_in[ch];
239 
240  memmove(src, &src[s->hop_size], offset * sizeof(float));
241  memcpy(&src[offset], in->extended_data[ch], in->nb_samples * sizeof(float));
242  memset(&src[offset + in->nb_samples], 0, (s->hop_size - in->nb_samples) * sizeof(float));
243 
244  for (n = 0; n < window_size; n++) {
245  fft_in[n].re = src[n] * window_lut[n];
246  fft_in[n].im = 0;
247  }
248  }
249 
250  values[VAR_PTS] = in->pts;
251  values[VAR_SAMPLE_RATE] = inlink->sample_rate;
252  values[VAR_NBBINS] = window_size / 2;
253  values[VAR_CHANNELS] = inlink->ch_layout.nb_channels;
254 
255  for (ch = 0; ch < inlink->ch_layout.nb_channels; ch++) {
256  AVComplexFloat *fft_in = s->fft_in[ch];
257  AVComplexFloat *fft_out = s->fft_out[ch];
258 
259  s->tx_fn(s->fft, fft_out, fft_in, sizeof(float));
260  }
261 
262  for (ch = 0; ch < inlink->ch_layout.nb_channels; 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  int x;
267  values[VAR_CHANNEL] = ch;
268 
269  if (ctx->is_disabled) {
270  for (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 (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 (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, fft_out, fft_temp, sizeof(float));
296 
297  memmove(buf, buf + s->hop_size, window_size * sizeof(float));
298  for (i = 0; i < window_size; i++) {
299  buf[i] += fft_out[i].re * window_lut[i] * f;
300  }
301  }
302 
303  out = ff_get_audio_buffer(outlink, s->hop_size);
304  if (!out) {
305  ret = AVERROR(ENOMEM);
306  goto fail;
307  }
308 
309  out->pts = in->pts;
310  out->nb_samples = in->nb_samples;
311 
312  for (ch = 0; ch < inlink->ch_layout.nb_channels; ch++) {
313  float *dst = (float *)out->extended_data[ch];
314  float *buf = (float *)s->buffer->extended_data[ch];
315 
316  memcpy(dst, buf, s->hop_size * sizeof(float));
317  }
318 
319  ret = ff_filter_frame(outlink, out);
320  if (ret < 0)
321  goto fail;
322 
323 fail:
324  av_frame_free(&in);
325  return ret < 0 ? ret : 0;
326 }
327 
329 {
330  AVFilterLink *inlink = ctx->inputs[0];
331  AVFilterLink *outlink = ctx->outputs[0];
332  AFFTFiltContext *s = ctx->priv;
333  AVFrame *in = NULL;
334  int ret = 0, status;
335  int64_t pts;
336 
338 
339  ret = ff_inlink_consume_samples(inlink, s->hop_size, s->hop_size, &in);
340  if (ret < 0)
341  return ret;
342 
343  if (ret > 0)
344  ret = filter_frame(inlink, in);
345  if (ret < 0)
346  return ret;
347 
349  ff_outlink_set_status(outlink, status, pts);
350  return 0;
351  }
352 
354 
355  return FFERROR_NOT_READY;
356 }
357 
359 {
360  AFFTFiltContext *s = ctx->priv;
361  int i;
362 
363  av_tx_uninit(&s->fft);
364  av_tx_uninit(&s->ifft);
365 
366  for (i = 0; i < s->channels; i++) {
367  if (s->fft_in)
368  av_freep(&s->fft_in[i]);
369  if (s->fft_out)
370  av_freep(&s->fft_out[i]);
371  if (s->fft_temp)
372  av_freep(&s->fft_temp[i]);
373  }
374  av_freep(&s->fft_in);
375  av_freep(&s->fft_out);
376  av_freep(&s->fft_temp);
377 
378  for (i = 0; i < s->nb_exprs; i++) {
379  av_expr_free(s->real[i]);
380  av_expr_free(s->imag[i]);
381  }
382 
383  av_freep(&s->real);
384  av_freep(&s->imag);
385  av_frame_free(&s->buffer);
386  av_frame_free(&s->window);
387  av_freep(&s->window_func_lut);
388 }
389 
390 static const AVFilterPad inputs[] = {
391  {
392  .name = "default",
393  .type = AVMEDIA_TYPE_AUDIO,
394  .config_props = config_input,
395  },
396 };
397 
398 static const AVFilterPad outputs[] = {
399  {
400  .name = "default",
401  .type = AVMEDIA_TYPE_AUDIO,
402  },
403 };
404 
406  .name = "afftfilt",
407  .description = NULL_IF_CONFIG_SMALL("Apply arbitrary expressions to samples in frequency domain."),
408  .priv_size = sizeof(AFFTFiltContext),
409  .priv_class = &afftfilt_class,
413  .activate = activate,
414  .uninit = uninit,
416 };
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
VAR_CHANNEL
@ VAR_CHANNEL
Definition: af_afftfilt.c:57
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
VAR_CHANNELS
@ VAR_CHANNELS
Definition: af_afftfilt.c:57
VAR_BIN
@ VAR_BIN
Definition: af_afftfilt.c:57
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:999
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:201
FILTER_SINGLE_SAMPLEFMT
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
Definition: internal.h:183
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:111
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:325
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:432
AVOption
AVOption.
Definition: opt.h:251
AFFTFiltContext::fft
AVTXContext * fft
Definition: af_afftfilt.c:38
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:175
VAR_REAL
@ VAR_REAL
Definition: af_afftfilt.c:57
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:638
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:398
AVComplexFloat::im
float im
Definition: tx.h:28
fail
#define fail()
Definition: checkasm.h:130
inputs
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:390
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1388
pts
static int64_t pts
Definition: transcode_aac.c:654
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:111
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
VAR_VARS_NB
@ VAR_VARS_NB
Definition: af_afftfilt.c:57
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:189
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
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
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
arg
const char * arg
Definition: jacosubdec.c:67
if
if(ret)
Definition: filter_design.txt:179
AFFTFiltContext::ifft
AVTXContext * ifft
Definition: af_afftfilt.c:38
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:1413
NULL
#define NULL
Definition: coverity.c:32
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
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:253
generate_window_func
static void generate_window_func(float *lut, int N, int win_func, float *overlap)
Definition: window_func.h:61
WFUNC_HANNING
@ WFUNC_HANNING
Definition: window_func.h:29
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: af_afftfilt.c:223
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:1348
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:116
cpu.h
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:328
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:251
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:405
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
VAR_SAMPLE_RATE
@ VAR_SAMPLE_RATE
Definition: af_afftfilt.c:57
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:386
common.h
AFFTFiltContext::tx_fn
av_tx_fn tx_fn
Definition: af_afftfilt.c:39
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:272
AVFilter
Filter definition.
Definition: avfilter.h:171
ff_af_afftfilt
const AVFilter ff_af_afftfilt
Definition: af_afftfilt.c:405
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
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
VAR_IMAG
@ VAR_IMAG
Definition: af_afftfilt.c:57
VAR_PTS
@ VAR_PTS
Definition: af_afftfilt.c:57
AVFilterContext
An instance of a filter.
Definition: avfilter.h:408
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_afftfilt.c:358
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:280
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:191
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:160
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
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