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