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