FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vaf_spectrumsynth.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
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, 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 /**
22  * @file
23  * SpectrumSynth filter
24  * @todo support float pixel format
25  */
26 
27 #include "libavcodec/avfft.h"
28 #include "libavutil/avassert.h"
30 #include "libavutil/opt.h"
31 #include "libavutil/parseutils.h"
32 #include "avfilter.h"
33 #include "formats.h"
34 #include "audio.h"
35 #include "video.h"
36 #include "internal.h"
37 #include "window_func.h"
38 
42 
43 typedef struct SpectrumSynthContext {
44  const AVClass *class;
46  int channels;
47  int scale;
48  int sliding;
49  int win_func;
50  float overlap;
52 
54  FFTContext *fft; ///< Fast Fourier Transform context
55  int fft_bits; ///< number of bits (FFT window size = 1<<fft_bits)
56  FFTComplex **fft_data; ///< bins holder for each (displayed) channels
57  int win_size;
58  int size;
59  int nb_freq;
60  int hop_size;
61  int start, end;
62  int xpos;
63  int xend;
64  int64_t pts;
65  float factor;
67  float *window_func_lut; ///< Window function LUT
69 
70 #define OFFSET(x) offsetof(SpectrumSynthContext, x)
71 #define A AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
72 #define V AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
73 
74 static const AVOption spectrumsynth_options[] = {
75  { "sample_rate", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = 44100}, 15, INT_MAX, A },
76  { "channels", "set channels", OFFSET(channels), AV_OPT_TYPE_INT, {.i64 = 1}, 1, 8, A },
77  { "scale", "set input amplitude scale", OFFSET(scale), AV_OPT_TYPE_INT, {.i64 = LOG}, 0, NB_SCALES-1, V, "scale" },
78  { "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=LINEAR}, 0, 0, V, "scale" },
79  { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=LOG}, 0, 0, V, "scale" },
80  { "slide", "set input sliding mode", OFFSET(sliding), AV_OPT_TYPE_INT, {.i64 = FULLFRAME}, 0, NB_SLIDES-1, V, "slide" },
81  { "replace", "consume old columns with new", 0, AV_OPT_TYPE_CONST, {.i64=REPLACE}, 0, 0, V, "slide" },
82  { "scroll", "consume only most right column", 0, AV_OPT_TYPE_CONST, {.i64=SCROLL}, 0, 0, V, "slide" },
83  { "fullframe", "consume full frames", 0, AV_OPT_TYPE_CONST, {.i64=FULLFRAME}, 0, 0, V, "slide" },
84  { "rscroll", "consume only most left column", 0, AV_OPT_TYPE_CONST, {.i64=RSCROLL}, 0, 0, V, "slide" },
85  { "win_func", "set window function", OFFSET(win_func), AV_OPT_TYPE_INT, {.i64 = 0}, 0, NB_WFUNC-1, A, "win_func" },
86  { "rect", "Rectangular", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_RECT}, 0, 0, A, "win_func" },
87  { "bartlett", "Bartlett", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BARTLETT}, 0, 0, A, "win_func" },
88  { "hann", "Hann", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_HANNING}, 0, 0, A, "win_func" },
89  { "hanning", "Hanning", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_HANNING}, 0, 0, A, "win_func" },
90  { "hamming", "Hamming", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_HAMMING}, 0, 0, A, "win_func" },
91  { "sine", "Sine", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_SINE}, 0, 0, A, "win_func" },
92  { "overlap", "set window overlap", OFFSET(overlap), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 1, A },
93  { "orientation", "set orientation", OFFSET(orientation), AV_OPT_TYPE_INT, {.i64=VERTICAL}, 0, NB_ORIENTATIONS-1, V, "orientation" },
94  { "vertical", NULL, 0, AV_OPT_TYPE_CONST, {.i64=VERTICAL}, 0, 0, V, "orientation" },
95  { "horizontal", NULL, 0, AV_OPT_TYPE_CONST, {.i64=HORIZONTAL}, 0, 0, V, "orientation" },
96  { NULL }
97 };
98 
99 AVFILTER_DEFINE_CLASS(spectrumsynth);
100 
102 {
103  SpectrumSynthContext *s = ctx->priv;
106  AVFilterLink *magnitude = ctx->inputs[0];
107  AVFilterLink *phase = ctx->inputs[1];
108  AVFilterLink *outlink = ctx->outputs[0];
110  static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16,
113  int ret, sample_rates[] = { 48000, -1 };
114 
115  formats = ff_make_format_list(sample_fmts);
116  if ((ret = ff_formats_ref (formats, &outlink->in_formats )) < 0 ||
117  (ret = ff_add_channel_layout (&layout, FF_COUNT2LAYOUT(s->channels))) < 0 ||
118  (ret = ff_channel_layouts_ref (layout , &outlink->in_channel_layouts)) < 0)
119  return ret;
120 
121  sample_rates[0] = s->sample_rate;
122  formats = ff_make_format_list(sample_rates);
123  if (!formats)
124  return AVERROR(ENOMEM);
125  if ((ret = ff_formats_ref(formats, &outlink->in_samplerates)) < 0)
126  return ret;
127 
128  formats = ff_make_format_list(pix_fmts);
129  if (!formats)
130  return AVERROR(ENOMEM);
131  if ((ret = ff_formats_ref(formats, &magnitude->out_formats)) < 0)
132  return ret;
133 
134  formats = ff_make_format_list(pix_fmts);
135  if (!formats)
136  return AVERROR(ENOMEM);
137  if ((ret = ff_formats_ref(formats, &phase->out_formats)) < 0)
138  return ret;
139 
140  return 0;
141 }
142 
143 static int config_output(AVFilterLink *outlink)
144 {
145  AVFilterContext *ctx = outlink->src;
146  SpectrumSynthContext *s = ctx->priv;
147  int width = ctx->inputs[0]->w;
148  int height = ctx->inputs[0]->h;
149  AVRational time_base = ctx->inputs[0]->time_base;
150  AVRational frame_rate = ctx->inputs[0]->frame_rate;
151  int i, ch, fft_bits;
152  float factor, overlap;
153 
154  outlink->sample_rate = s->sample_rate;
155  outlink->time_base = (AVRational){1, s->sample_rate};
156 
157  if (width != ctx->inputs[1]->w ||
158  height != ctx->inputs[1]->h) {
159  av_log(ctx, AV_LOG_ERROR,
160  "Magnitude and Phase sizes differ (%dx%d vs %dx%d).\n",
161  width, height,
162  ctx->inputs[1]->w, ctx->inputs[1]->h);
163  return AVERROR_INVALIDDATA;
164  } else if (av_cmp_q(time_base, ctx->inputs[1]->time_base) != 0) {
165  av_log(ctx, AV_LOG_ERROR,
166  "Magnitude and Phase time bases differ (%d/%d vs %d/%d).\n",
167  time_base.num, time_base.den,
168  ctx->inputs[1]->time_base.num,
169  ctx->inputs[1]->time_base.den);
170  return AVERROR_INVALIDDATA;
171  } else if (av_cmp_q(frame_rate, ctx->inputs[1]->frame_rate) != 0) {
172  av_log(ctx, AV_LOG_ERROR,
173  "Magnitude and Phase framerates differ (%d/%d vs %d/%d).\n",
174  frame_rate.num, frame_rate.den,
175  ctx->inputs[1]->frame_rate.num,
176  ctx->inputs[1]->frame_rate.den);
177  return AVERROR_INVALIDDATA;
178  }
179 
180  s->size = s->orientation == VERTICAL ? height / s->channels : width / s->channels;
181  s->xend = s->orientation == VERTICAL ? width : height;
182 
183  for (fft_bits = 1; 1 << fft_bits < 2 * s->size; fft_bits++);
184 
185  s->win_size = 1 << fft_bits;
186  s->nb_freq = 1 << (fft_bits - 1);
187 
188  s->fft = av_fft_init(fft_bits, 1);
189  if (!s->fft) {
190  av_log(ctx, AV_LOG_ERROR, "Unable to create FFT context. "
191  "The window size might be too high.\n");
192  return AVERROR(EINVAL);
193  }
194  s->fft_data = av_calloc(s->channels, sizeof(*s->fft_data));
195  if (!s->fft_data)
196  return AVERROR(ENOMEM);
197  for (ch = 0; ch < s->channels; ch++) {
198  s->fft_data[ch] = av_calloc(s->win_size, sizeof(**s->fft_data));
199  if (!s->fft_data[ch])
200  return AVERROR(ENOMEM);
201  }
202 
203  s->buffer = ff_get_audio_buffer(outlink, s->win_size * 2);
204  if (!s->buffer)
205  return AVERROR(ENOMEM);
206 
207  /* pre-calc windowing function */
209  sizeof(*s->window_func_lut));
210  if (!s->window_func_lut)
211  return AVERROR(ENOMEM);
213  if (s->overlap == 1)
214  s->overlap = overlap;
215  s->hop_size = (1 - s->overlap) * s->win_size;
216  for (factor = 0, i = 0; i < s->win_size; i++) {
217  factor += s->window_func_lut[i] * s->window_func_lut[i];
218  }
219  s->factor = (factor / s->win_size) / FFMAX(1 / (1 - s->overlap) - 1, 1);
220 
221  return 0;
222 }
223 
224 static int request_frame(AVFilterLink *outlink)
225 {
226  AVFilterContext *ctx = outlink->src;
227  SpectrumSynthContext *s = ctx->priv;
228  int ret;
229 
230  if (!s->magnitude) {
231  ret = ff_request_frame(ctx->inputs[0]);
232  if (ret < 0)
233  return ret;
234  }
235  if (!s->phase) {
236  ret = ff_request_frame(ctx->inputs[1]);
237  if (ret < 0)
238  return ret;
239  }
240  return 0;
241 }
242 
244  int x, int y, int f, int ch)
245 {
246  const int m_linesize = s->magnitude->linesize[0];
247  const int p_linesize = s->phase->linesize[0];
248  const uint16_t *m = (uint16_t *)(s->magnitude->data[0] + y * m_linesize);
249  const uint16_t *p = (uint16_t *)(s->phase->data[0] + y * p_linesize);
250  float magnitude, phase;
251 
252  switch (s->scale) {
253  case LINEAR:
254  magnitude = m[x] / (double)UINT16_MAX;
255  break;
256  case LOG:
257  magnitude = ff_exp10(((m[x] / (double)UINT16_MAX) - 1.) * 6.);
258  break;
259  default:
260  av_assert0(0);
261  }
262  phase = ((p[x] / (double)UINT16_MAX) * 2. - 1.) * M_PI;
263 
264  s->fft_data[ch][f].re = magnitude * cos(phase);
265  s->fft_data[ch][f].im = magnitude * sin(phase);
266 }
267 
269  int x, int y, int f, int ch)
270 {
271  const int m_linesize = s->magnitude->linesize[0];
272  const int p_linesize = s->phase->linesize[0];
273  const uint8_t *m = (uint8_t *)(s->magnitude->data[0] + y * m_linesize);
274  const uint8_t *p = (uint8_t *)(s->phase->data[0] + y * p_linesize);
275  float magnitude, phase;
276 
277  switch (s->scale) {
278  case LINEAR:
279  magnitude = m[x] / (double)UINT8_MAX;
280  break;
281  case LOG:
282  magnitude = ff_exp10(((m[x] / (double)UINT8_MAX) - 1.) * 6.);
283  break;
284  default:
285  av_assert0(0);
286  }
287  phase = ((p[x] / (double)UINT8_MAX) * 2. - 1.) * M_PI;
288 
289  s->fft_data[ch][f].re = magnitude * cos(phase);
290  s->fft_data[ch][f].im = magnitude * sin(phase);
291 }
292 
293 static void read_fft_data(AVFilterContext *ctx, int x, int h, int ch)
294 {
295  SpectrumSynthContext *s = ctx->priv;
296  AVFilterLink *inlink = ctx->inputs[0];
297  int start = h * (s->channels - ch) - 1;
298  int end = h * (s->channels - ch - 1);
299  int y, f;
300 
301  switch (s->orientation) {
302  case VERTICAL:
303  switch (inlink->format) {
305  case AV_PIX_FMT_GRAY16:
306  for (y = start, f = 0; y >= end; y--, f++) {
307  read16_fft_bin(s, x, y, f, ch);
308  }
309  break;
310  case AV_PIX_FMT_YUVJ444P:
311  case AV_PIX_FMT_YUV444P:
312  case AV_PIX_FMT_GRAY8:
313  for (y = start, f = 0; y >= end; y--, f++) {
314  read8_fft_bin(s, x, y, f, ch);
315  }
316  break;
317  }
318  break;
319  case HORIZONTAL:
320  switch (inlink->format) {
322  case AV_PIX_FMT_GRAY16:
323  for (y = end, f = 0; y <= start; y++, f++) {
324  read16_fft_bin(s, y, x, f, ch);
325  }
326  break;
327  case AV_PIX_FMT_YUVJ444P:
328  case AV_PIX_FMT_YUV444P:
329  case AV_PIX_FMT_GRAY8:
330  for (y = end, f = 0; y <= start; y++, f++) {
331  read8_fft_bin(s, y, x, f, ch);
332  }
333  break;
334  }
335  break;
336  }
337 }
338 
339 static void synth_window(AVFilterContext *ctx, int x)
340 {
341  SpectrumSynthContext *s = ctx->priv;
342  const int h = s->size;
343  int nb = s->win_size;
344  int y, f, ch;
345 
346  for (ch = 0; ch < s->channels; ch++) {
347  read_fft_data(ctx, x, h, ch);
348 
349  for (y = h; y <= s->nb_freq; y++) {
350  s->fft_data[ch][y].re = 0;
351  s->fft_data[ch][y].im = 0;
352  }
353 
354  for (y = s->nb_freq + 1, f = s->nb_freq - 1; y < nb; y++, f--) {
355  s->fft_data[ch][y].re = s->fft_data[ch][f].re;
356  s->fft_data[ch][y].im = -s->fft_data[ch][f].im;
357  }
358 
359  av_fft_permute(s->fft, s->fft_data[ch]);
360  av_fft_calc(s->fft, s->fft_data[ch]);
361  }
362 }
363 
364 static int try_push_frame(AVFilterContext *ctx, int x)
365 {
366  SpectrumSynthContext *s = ctx->priv;
367  AVFilterLink *outlink = ctx->outputs[0];
368  const float factor = s->factor;
369  int ch, n, i, ret;
370  int start, end;
371  AVFrame *out;
372 
373  synth_window(ctx, x);
374 
375  for (ch = 0; ch < s->channels; ch++) {
376  float *buf = (float *)s->buffer->extended_data[ch];
377  int j, k;
378 
379  start = s->start;
380  end = s->end;
381  k = end;
382  for (i = 0, j = start; j < k && i < s->win_size; i++, j++) {
383  buf[j] += s->fft_data[ch][i].re;
384  }
385 
386  for (; i < s->win_size; i++, j++) {
387  buf[j] = s->fft_data[ch][i].re;
388  }
389 
390  start += s->hop_size;
391  end = j;
392 
393  if (start >= s->win_size) {
394  start -= s->win_size;
395  end -= s->win_size;
396 
397  if (ch == s->channels - 1) {
398  float *dst;
399  int c;
400 
401  out = ff_get_audio_buffer(outlink, s->win_size);
402  if (!out) {
404  av_frame_free(&s->phase);
405  return AVERROR(ENOMEM);
406  }
407 
408  out->pts = s->pts;
409  s->pts += s->win_size;
410  for (c = 0; c < s->channels; c++) {
411  dst = (float *)out->extended_data[c];
412  buf = (float *)s->buffer->extended_data[c];
413 
414  for (n = 0; n < s->win_size; n++) {
415  dst[n] = buf[n] * factor;
416  }
417  memmove(buf, buf + s->win_size, s->win_size * 4);
418  }
419 
420  ret = ff_filter_frame(outlink, out);
421  }
422  }
423  }
424 
425  s->start = start;
426  s->end = end;
427 
428  return 0;
429 }
430 
432 {
433  SpectrumSynthContext *s = ctx->priv;
434  int ret, x;
435 
436  if (!(s->magnitude && s->phase))
437  return 0;
438 
439  switch (s->sliding) {
440  case REPLACE:
441  ret = try_push_frame(ctx, s->xpos);
442  s->xpos++;
443  if (s->xpos >= s->xend)
444  s->xpos = 0;
445  break;
446  case SCROLL:
447  s->xpos = s->xend - 1;
448  ret = try_push_frame(ctx, s->xpos);
449  break;
450  case RSCROLL:
451  s->xpos = 0;
452  ret = try_push_frame(ctx, s->xpos);
453  break;
454  case FULLFRAME:
455  for (x = 0; x < s->xend; x++) {
456  ret = try_push_frame(ctx, x);
457  if (ret < 0)
458  break;
459  }
460  break;
461  default:
462  av_assert0(0);
463  }
464 
466  av_frame_free(&s->phase);
467  return ret;
468 }
469 
470 static int filter_frame_magnitude(AVFilterLink *inlink, AVFrame *magnitude)
471 {
472  AVFilterContext *ctx = inlink->dst;
473  SpectrumSynthContext *s = ctx->priv;
474 
475  s->magnitude = magnitude;
476  return try_push_frames(ctx);
477 }
478 
479 static int filter_frame_phase(AVFilterLink *inlink, AVFrame *phase)
480 {
481  AVFilterContext *ctx = inlink->dst;
482  SpectrumSynthContext *s = ctx->priv;
483 
484  s->phase = phase;
485  return try_push_frames(ctx);
486 }
487 
489 {
490  SpectrumSynthContext *s = ctx->priv;
491  int i;
492 
494  av_frame_free(&s->phase);
495  av_frame_free(&s->buffer);
496  av_fft_end(s->fft);
497  if (s->fft_data) {
498  for (i = 0; i < s->channels; i++)
499  av_freep(&s->fft_data[i]);
500  }
501  av_freep(&s->fft_data);
503 }
504 
506  {
507  .name = "magnitude",
508  .type = AVMEDIA_TYPE_VIDEO,
509  .filter_frame = filter_frame_magnitude,
510  .needs_fifo = 1,
511  },
512  {
513  .name = "phase",
514  .type = AVMEDIA_TYPE_VIDEO,
515  .filter_frame = filter_frame_phase,
516  .needs_fifo = 1,
517  },
518  { NULL }
519 };
520 
522  {
523  .name = "default",
524  .type = AVMEDIA_TYPE_AUDIO,
525  .config_props = config_output,
526  .request_frame = request_frame,
527  },
528  { NULL }
529 };
530 
532  .name = "spectrumsynth",
533  .description = NULL_IF_CONFIG_SMALL("Convert input spectrum videos to audio output."),
534  .uninit = uninit,
535  .query_formats = query_formats,
536  .priv_size = sizeof(SpectrumSynthContext),
537  .inputs = spectrumsynth_inputs,
538  .outputs = spectrumsynth_outputs,
539  .priv_class = &spectrumsynth_class,
540 };
float, planar
Definition: samplefmt.h:70
#define NULL
Definition: coverity.c:32
const char * s
Definition: avisynth_c.h:631
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
#define av_realloc_f(p, o, n)
This structure describes decoded (raw) audio or video data.
Definition: frame.h:181
AVOption.
Definition: opt.h:245
av_cold void av_fft_end(FFTContext *s)
Definition: avfft.c:48
AVFormatContext * ctx
Definition: movenc-test.c:48
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:68
Main libavfilter public API header.
AVFILTER_DEFINE_CLASS(spectrumsynth)
int num
numerator
Definition: rational.h:44
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
Definition: rational.h:66
FFTSample re
Definition: avfft.h:38
void av_fft_permute(FFTContext *s, FFTComplex *z)
Do the permutation needed BEFORE calling ff_fft_calc().
Definition: avfft.c:38
static enum AVSampleFormat formats[]
static const AVOption spectrumsynth_options[]
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
const char * name
Pad name.
Definition: internal.h:59
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:312
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:435
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1163
float * window_func_lut
Window function LUT.
FFTComplex ** fft_data
bins holder for each (displayed) channels
uint8_t
#define av_cold
Definition: attributes.h:82
AVOptions.
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
static int query_formats(AVFilterContext *ctx)
static const AVFilterPad spectrumsynth_outputs[]
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:262
static int try_push_frames(AVFilterContext *ctx)
static void read16_fft_bin(SpectrumSynthContext *s, int x, int y, int f, int ch)
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:343
#define av_log(a,...)
SlideMode
unsigned m
Definition: audioconvert.c:187
A filter pad used for either input or output.
Definition: internal.h:53
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
static void read8_fft_bin(SpectrumSynthContext *s, int x, int y, int f, int ch)
int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout)
Definition: formats.c:343
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:65
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:154
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
void * priv
private data for use by the filter
Definition: avfilter.h:319
static const AVFilterPad spectrumsynth_inputs[]
simple assert() macros that are a bit more flexible than ISO C assert().
#define V
static void read_fft_data(AVFilterContext *ctx, int x, int h, int ch)
FFTContext * av_fft_init(int nbits, int inverse)
Set up a complex FFT.
Definition: avfft.c:28
#define FFMAX(a, b)
Definition: common.h:94
static const int sample_rates[]
Definition: dcaenc.h:32
Definition: fft.h:88
FFTContext * fft
Fast Fourier Transform context.
audio channel layout utility functions
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:314
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:440
static int filter_frame_magnitude(AVFilterLink *inlink, AVFrame *magnitude)
int n
Definition: avisynth_c.h:547
MagnitudeScale
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:385
A list of supported channel layouts.
Definition: formats.h:85
FILE * out
Definition: movenc-test.c:54
static av_cold void uninit(AVFilterContext *ctx)
Orientation
sample_rate
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:375
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:59
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:209
FFT functions.
#define A
void * buf
Definition: avisynth_c.h:553
BYTE int const BYTE int int int height
Definition: avisynth_c.h:676
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:141
void ff_generate_window_func(float *lut, int N, int win_func, float *overlap)
Definition: window_func.c:26
rational number numerator/denominator
Definition: rational.h:43
int fft_bits
number of bits (FFT window size = 1<<fft_bits)
static const int factor[16]
Definition: vf_pp7.c:75
const char * name
Filter name.
Definition: avfilter.h:145
misc parsing utilities
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:316
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:262
void * av_calloc(size_t nmemb, size_t size)
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
Definition: mem.c:260
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:192
static int request_frame(AVFilterLink *outlink)
Y , 8bpp.
Definition: pixfmt.h:71
FFTSample im
Definition: avfft.h:38
static double c[64]
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:77
int den
denominator
Definition: rational.h:45
static int try_push_frame(AVFilterContext *ctx, int x)
AVFilter ff_vaf_spectrumsynth
A list of supported formats for one end of a filter link.
Definition: formats.h:64
uint64_t layout
An instance of a filter.
Definition: avfilter.h:304
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:701
#define av_freep(p)
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
Definition: internal.h:306
void INT64 start
Definition: avisynth_c.h:553
#define FF_COUNT2LAYOUT(c)
Encode a channel count as a channel layout.
Definition: formats.h:102
#define M_PI
Definition: mathematics.h:46
static int filter_frame_phase(AVFilterLink *inlink, AVFrame *phase)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:356
internal API functions
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:225
static int config_output(AVFilterLink *outlink)
static void synth_window(AVFilterContext *ctx, int x)
void av_fft_calc(FFTContext *s, FFTComplex *z)
Do a complex FFT with the parameters defined in av_fft_init().
Definition: avfft.c:43
AVPixelFormat
Pixel format.
Definition: pixfmt.h:61
for(j=16;j >0;--j)
#define OFFSET(x)
static int width