FFmpeg
Loading...
Searching...
No Matches
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 "libavutil/mem.h"
28#include "libavutil/tx.h"
29#include "libavutil/avassert.h"
30#include "libavutil/cpu.h"
31#include "libavutil/ffmath.h"
32#include "libavutil/opt.h"
33#include "avfilter.h"
34#include "formats.h"
35#include "audio.h"
36#include "filters.h"
37#include "window_func.h"
38
42
43typedef struct SpectrumSynthContext {
44 const AVClass *class;
47 int scale;
50 float overlap;
52
54 AVTXContext *fft; ///< Fast Fourier Transform context
56 AVComplexFloat **fft_in; ///< bins holder for each (displayed) channels
57 AVComplexFloat **fft_out; ///< bins holder for each (displayed) channels
59 int size;
62 int start, end;
63 int xpos;
64 int xend;
66 float factor;
68 float *window_func_lut; ///< Window function LUT
70
71#define OFFSET(x) offsetof(SpectrumSynthContext, x)
72#define A AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
73#define V AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
74
76 { "sample_rate", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = 44100}, 15, INT_MAX, A },
77 { "channels", "set channels", OFFSET(channels), AV_OPT_TYPE_INT, {.i64 = 1}, 1, 8, A },
78 { "scale", "set input amplitude scale", OFFSET(scale), AV_OPT_TYPE_INT, {.i64 = LOG}, 0, NB_SCALES-1, V, .unit = "scale" },
79 { "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=LINEAR}, 0, 0, V, .unit = "scale" },
80 { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=LOG}, 0, 0, V, .unit = "scale" },
81 { "slide", "set input sliding mode", OFFSET(sliding), AV_OPT_TYPE_INT, {.i64 = FULLFRAME}, 0, NB_SLIDES-1, V, .unit = "slide" },
82 { "replace", "consume old columns with new", 0, AV_OPT_TYPE_CONST, {.i64=REPLACE}, 0, 0, V, .unit = "slide" },
83 { "scroll", "consume only most right column", 0, AV_OPT_TYPE_CONST, {.i64=SCROLL}, 0, 0, V, .unit = "slide" },
84 { "fullframe", "consume full frames", 0, AV_OPT_TYPE_CONST, {.i64=FULLFRAME}, 0, 0, V, .unit = "slide" },
85 { "rscroll", "consume only most left column", 0, AV_OPT_TYPE_CONST, {.i64=RSCROLL}, 0, 0, V, .unit = "slide" },
86 WIN_FUNC_OPTION("win_func", OFFSET(win_func), A, 0),
87 { "overlap", "set window overlap", OFFSET(overlap), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 1, A },
88 { "orientation", "set orientation", OFFSET(orientation), AV_OPT_TYPE_INT, {.i64=VERTICAL}, 0, NB_ORIENTATIONS-1, V, .unit = "orientation" },
89 { "vertical", NULL, 0, AV_OPT_TYPE_CONST, {.i64=VERTICAL}, 0, 0, V, .unit = "orientation" },
90 { "horizontal", NULL, 0, AV_OPT_TYPE_CONST, {.i64=HORIZONTAL}, 0, 0, V, .unit = "orientation" },
91 { NULL }
92};
93
94AVFILTER_DEFINE_CLASS(spectrumsynth);
95
96enum {
98 PHASE = 1,
99};
100
102 AVFilterFormatsConfig **cfg_in,
103 AVFilterFormatsConfig **cfg_out)
104{
105 const SpectrumSynthContext *s = ctx->priv;
112 int ret, sample_rates[] = { 48000, -1 };
113
115 if ((ret = ff_formats_ref (formats, &cfg_out[0]->formats )) < 0 ||
116 (ret = ff_add_channel_layout (&layout, &FF_COUNT2LAYOUT(s->channels))) < 0 ||
117 (ret = ff_channel_layouts_ref (layout , &cfg_out[0]->channel_layouts)) < 0)
118 return ret;
119
120 sample_rates[0] = s->sample_rate;
122 if (!formats)
123 return AVERROR(ENOMEM);
124 if ((ret = ff_formats_ref(formats, &cfg_out[0]->samplerates)) < 0)
125 return ret;
126
128 if (!formats)
129 return AVERROR(ENOMEM);
130 if ((ret = ff_formats_ref(formats, &cfg_in[MAGNITUDE]->formats)) < 0 ||
131 (ret = ff_formats_ref(formats, &cfg_in[PHASE]->formats)) < 0)
132 return ret;
133
134 return 0;
135}
136
137static int config_output(AVFilterLink *outlink)
138{
139 AVFilterContext *ctx = outlink->src;
140 SpectrumSynthContext *s = ctx->priv;
141 FilterLink *inl0 = ff_filter_link(ctx->inputs[0]);
142 FilterLink *inl1 = ff_filter_link(ctx->inputs[1]);
143 int width = ctx->inputs[0]->w;
144 int height = ctx->inputs[0]->h;
145 AVRational time_base = ctx->inputs[0]->time_base;
146 AVRational frame_rate = inl0->frame_rate;
147 float factor, overlap;
148 int i, ch, ret;
149
150 outlink->sample_rate = s->sample_rate;
151 outlink->time_base = (AVRational){1, s->sample_rate};
152
153 if (width != ctx->inputs[1]->w ||
154 height != ctx->inputs[1]->h) {
156 "Magnitude and Phase sizes differ (%dx%d vs %dx%d).\n",
157 width, height,
158 ctx->inputs[1]->w, ctx->inputs[1]->h);
159 return AVERROR_INVALIDDATA;
160 } else if (av_cmp_q(time_base, ctx->inputs[1]->time_base) != 0) {
162 "Magnitude and Phase time bases differ (%d/%d vs %d/%d).\n",
163 time_base.num, time_base.den,
164 ctx->inputs[1]->time_base.num,
165 ctx->inputs[1]->time_base.den);
166 return AVERROR_INVALIDDATA;
167 } else if (av_cmp_q(frame_rate, inl1->frame_rate) != 0) {
169 "Magnitude and Phase framerates differ (%d/%d vs %d/%d).\n",
170 frame_rate.num, frame_rate.den,
171 inl1->frame_rate.num,
172 inl1->frame_rate.den);
173 return AVERROR_INVALIDDATA;
174 }
175
176 s->size = s->orientation == VERTICAL ? height / s->channels : width / s->channels;
177 s->xend = s->orientation == VERTICAL ? width : height;
178
179 s->win_size = s->size * 2;
180 s->nb_freq = s->size;
181
182 ret = av_tx_init(&s->fft, &s->tx_fn, AV_TX_FLOAT_FFT, 1, s->win_size, NULL, 0);
183 if (ret < 0) {
184 av_log(ctx, AV_LOG_ERROR, "Unable to create FFT context. "
185 "The window size might be too high.\n");
186 return ret;
187 }
188
189 s->fft_in = av_calloc(s->channels, sizeof(*s->fft_in));
190 if (!s->fft_in)
191 return AVERROR(ENOMEM);
192 s->fft_out = av_calloc(s->channels, sizeof(*s->fft_out));
193 if (!s->fft_out)
194 return AVERROR(ENOMEM);
195
196 for (ch = 0; ch < s->channels; ch++) {
197 s->fft_in[ch] = av_calloc(FFALIGN(s->win_size, av_cpu_max_align()), sizeof(**s->fft_in));
198 if (!s->fft_in[ch])
199 return AVERROR(ENOMEM);
200
201 s->fft_out[ch] = av_calloc(FFALIGN(s->win_size, av_cpu_max_align()), sizeof(**s->fft_out));
202 if (!s->fft_out[ch])
203 return AVERROR(ENOMEM);
204 }
205
206 s->buffer = ff_get_audio_buffer(outlink, s->win_size * 2);
207 if (!s->buffer)
208 return AVERROR(ENOMEM);
209
210 /* pre-calc windowing function */
211 s->window_func_lut = av_realloc_f(s->window_func_lut, s->win_size,
212 sizeof(*s->window_func_lut));
213 if (!s->window_func_lut)
214 return AVERROR(ENOMEM);
215 generate_window_func(s->window_func_lut, s->win_size, s->win_func, &overlap);
216 if (s->overlap == 1)
217 s->overlap = overlap;
218 s->hop_size = (1 - s->overlap) * s->win_size;
219 for (factor = 0, i = 0; i < s->win_size; i++) {
220 factor += s->window_func_lut[i] * s->window_func_lut[i];
221 }
222 s->factor = (factor / s->win_size) / FFMAX(1 / (1 - s->overlap) - 1, 1);
223
224 return 0;
225}
226
228 int x, int y, int f, int ch)
229{
230 const int m_linesize = s->magnitude->linesize[0];
231 const int p_linesize = s->phase->linesize[0];
232 const uint16_t *m = (uint16_t *)(s->magnitude->data[0] + y * m_linesize);
233 const uint16_t *p = (uint16_t *)(s->phase->data[0] + y * p_linesize);
234 float magnitude, phase;
235
236 switch (s->scale) {
237 case LINEAR:
238 magnitude = m[x] / (double)UINT16_MAX;
239 break;
240 case LOG:
241 magnitude = ff_exp10(((m[x] / (double)UINT16_MAX) - 1.) * 6.);
242 break;
243 default:
244 av_assert0(0);
245 }
246 phase = ((p[x] / (double)UINT16_MAX) * 2. - 1.) * M_PI;
247
248 s->fft_in[ch][f].re = magnitude * cos(phase);
249 s->fft_in[ch][f].im = magnitude * sin(phase);
250}
251
253 int x, int y, int f, int ch)
254{
255 const int m_linesize = s->magnitude->linesize[0];
256 const int p_linesize = s->phase->linesize[0];
257 const uint8_t *m = (uint8_t *)(s->magnitude->data[0] + y * m_linesize);
258 const uint8_t *p = (uint8_t *)(s->phase->data[0] + y * p_linesize);
259 float magnitude, phase;
260
261 switch (s->scale) {
262 case LINEAR:
263 magnitude = m[x] / (double)UINT8_MAX;
264 break;
265 case LOG:
266 magnitude = ff_exp10(((m[x] / (double)UINT8_MAX) - 1.) * 6.);
267 break;
268 default:
269 av_assert0(0);
270 }
271 phase = ((p[x] / (double)UINT8_MAX) * 2. - 1.) * M_PI;
272
273 s->fft_in[ch][f].re = magnitude * cos(phase);
274 s->fft_in[ch][f].im = magnitude * sin(phase);
275}
276
277static void read_fft_data(AVFilterContext *ctx, int x, int h, int ch)
278{
279 SpectrumSynthContext *s = ctx->priv;
280 AVFilterLink *inlink = ctx->inputs[0];
281 int start = h * (s->channels - ch) - 1;
282 int end = h * (s->channels - ch - 1);
283 int y, f;
284
285 switch (s->orientation) {
286 case VERTICAL:
287 switch (inlink->format) {
290 for (y = start, f = 0; y >= end; y--, f++) {
291 read16_fft_bin(s, x, y, f, ch);
292 }
293 break;
296 case AV_PIX_FMT_GRAY8:
297 for (y = start, f = 0; y >= end; y--, f++) {
298 read8_fft_bin(s, x, y, f, ch);
299 }
300 break;
301 }
302 break;
303 case HORIZONTAL:
304 switch (inlink->format) {
307 for (y = end, f = 0; y <= start; y++, f++) {
308 read16_fft_bin(s, y, x, f, ch);
309 }
310 break;
313 case AV_PIX_FMT_GRAY8:
314 for (y = end, f = 0; y <= start; y++, f++) {
315 read8_fft_bin(s, y, x, f, ch);
316 }
317 break;
318 }
319 break;
320 }
321}
322
323static void synth_window(AVFilterContext *ctx, int x)
324{
325 SpectrumSynthContext *s = ctx->priv;
326 const int h = s->size;
327 int nb = s->win_size;
328 int y, f, ch;
329
330 for (ch = 0; ch < s->channels; ch++) {
331 read_fft_data(ctx, x, h, ch);
332
333 for (y = h; y <= s->nb_freq; y++) {
334 s->fft_in[ch][y].re = 0;
335 s->fft_in[ch][y].im = 0;
336 }
337
338 for (y = s->nb_freq + 1, f = s->nb_freq - 1; y < nb; y++, f--) {
339 s->fft_in[ch][y].re = s->fft_in[ch][f].re;
340 s->fft_in[ch][y].im = -s->fft_in[ch][f].im;
341 }
342
343 s->tx_fn(s->fft, s->fft_out[ch], s->fft_in[ch], sizeof(AVComplexFloat));
344 }
345}
346
348{
349 SpectrumSynthContext *s = ctx->priv;
350 AVFilterLink *outlink = ctx->outputs[0];
351 const float factor = s->factor;
352 int ch, n, i, ret;
353 int start, end;
354 AVFrame *out;
355
356 synth_window(ctx, x);
357
358 for (ch = 0; ch < s->channels; ch++) {
359 float *buf = (float *)s->buffer->extended_data[ch];
360 int j, k;
361
362 start = s->start;
363 end = s->end;
364 k = end;
365 for (i = 0, j = start; j < k && i < s->win_size; i++, j++) {
366 buf[j] += s->fft_out[ch][i].re;
367 }
368
369 for (; i < s->win_size; i++, j++) {
370 buf[j] = s->fft_out[ch][i].re;
371 }
372
373 start += s->hop_size;
374 end = j;
375
376 if (start >= s->win_size) {
377 start -= s->win_size;
378 end -= s->win_size;
379
380 if (ch == s->channels - 1) {
381 float *dst;
382 int c;
383
384 out = ff_get_audio_buffer(outlink, s->win_size);
385 if (!out) {
386 av_frame_free(&s->magnitude);
387 av_frame_free(&s->phase);
388 return AVERROR(ENOMEM);
389 }
390
391 out->pts = s->pts;
392 s->pts += s->win_size;
393 for (c = 0; c < s->channels; c++) {
394 dst = (float *)out->extended_data[c];
395 buf = (float *)s->buffer->extended_data[c];
396
397 for (n = 0; n < s->win_size; n++) {
398 dst[n] = buf[n] * factor;
399 }
400 memmove(buf, buf + s->win_size, s->win_size * 4);
401 }
402
403 ret = ff_filter_frame(outlink, out);
404 if (ret < 0)
405 return ret;
406 }
407 }
408 }
409
410 s->start = start;
411 s->end = end;
412
413 return 0;
414}
415
417{
418 SpectrumSynthContext *s = ctx->priv;
419 int ret, x;
420
421 if (!(s->magnitude && s->phase))
422 return 0;
423
424 switch (s->sliding) {
425 case REPLACE:
426 ret = try_push_frame(ctx, s->xpos);
427 s->xpos++;
428 if (s->xpos >= s->xend)
429 s->xpos = 0;
430 break;
431 case SCROLL:
432 s->xpos = s->xend - 1;
433 ret = try_push_frame(ctx, s->xpos);
434 break;
435 case RSCROLL:
436 s->xpos = 0;
437 ret = try_push_frame(ctx, s->xpos);
438 break;
439 case FULLFRAME:
440 for (x = 0; x < s->xend; x++) {
441 ret = try_push_frame(ctx, x);
442 if (ret < 0)
443 break;
444 }
445 break;
446 default:
447 av_assert0(0);
448 }
449
450 av_frame_free(&s->magnitude);
451 av_frame_free(&s->phase);
452 return ret;
453}
454
456{
457 SpectrumSynthContext *s = ctx->priv;
458 AVFrame **staging[2] = { &s->magnitude, &s->phase };
459 int64_t pts;
460 int i, ret;
461
463
464 for (i = 0; i < 2; i++) {
465 if (*staging[i])
466 continue;
467 ret = ff_inlink_consume_frame(ctx->inputs[i], staging[i]);
468 if (ret < 0)
469 return ret;
470 if (ret) {
472 return try_push_frames(ctx);
473 }
474 }
475
476 for (i = 0; i < 2; i++) {
477 if (ff_inlink_acknowledge_status(ctx->inputs[i], &ret, &pts)) {
478 ff_outlink_set_status(ctx->outputs[0], ret, pts);
479 ff_inlink_set_status(ctx->inputs[1 - i], ret);
480 return 0;
481 }
482 }
483
484 if (ff_outlink_frame_wanted(ctx->outputs[0])) {
485 for (i = 0; i < 2; i++) {
486 if (!*staging[i])
487 ff_inlink_request_frame(ctx->inputs[i]);
488 }
489 }
490
491 return FFERROR_NOT_READY;
492}
493
495{
496 SpectrumSynthContext *s = ctx->priv;
497 int i;
498
499 av_frame_free(&s->magnitude);
500 av_frame_free(&s->phase);
501 av_frame_free(&s->buffer);
502
503 av_tx_uninit(&s->fft);
504
505 if (s->fft_in) {
506 for (i = 0; i < s->channels; i++)
507 av_freep(&s->fft_in[i]);
508 }
509 if (s->fft_out) {
510 for (i = 0; i < s->channels; i++)
511 av_freep(&s->fft_out[i]);
512 }
513 av_freep(&s->fft_in);
514 av_freep(&s->fft_out);
515 av_freep(&s->window_func_lut);
516}
517
519 {
520 .name = "magnitude",
521 .type = AVMEDIA_TYPE_VIDEO,
522 },
523 {
524 .name = "phase",
525 .type = AVMEDIA_TYPE_VIDEO,
526 },
527};
528
530 {
531 .name = "default",
532 .type = AVMEDIA_TYPE_AUDIO,
533 .config_props = config_output,
534 },
535};
536
538 .p.name = "spectrumsynth",
539 .p.description = NULL_IF_CONFIG_SMALL("Convert input spectrum videos to audio output."),
540 .p.priv_class = &spectrumsynth_class,
541 .uninit = uninit,
542 .activate = activate,
543 .priv_size = sizeof(SpectrumSynthContext),
547};
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static enum AVSampleFormat sample_fmts[]
Definition adpcmenc.c:933
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
const FFFilter ff_vaf_spectrumsynth
static FILE * out
static AVFormatContext * ctx
channels
Definition aptx.h:31
#define A(x)
Definition vpx_arith.h:28
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition audio.c:74
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:42
#define V
Definition avdct.c:32
SlideMode
@ SCROLL
@ REPLACE
@ NB_SLIDES
@ NB_SCALES
#define MAGNITUDE(y, ch)
#define PHASE(y, ch)
@ FULLFRAME
@ RSCROLL
Orientation
@ VERTICAL
@ HORIZONTAL
@ NB_ORIENTATIONS
void ff_inlink_set_status(AVFilterLink *link, int status)
Set the status on an input link.
Definition avfilter.c:1632
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:1467
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1068
int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
Definition avfilter.c:1690
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
Definition avfilter.c:229
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:1520
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition avfilter.c:1623
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define f(width, name)
Definition cbs_vp8.c:236
#define s(width, name)
Definition cbs_vp9.c:198
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
static const uint16_t channel_layouts[7]
Definition dca_lbr.c:112
static const int sample_rates[]
Definition dcaenc.h: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
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add ref as a new reference to formats.
Definition formats.c:756
int ff_add_channel_layout(AVFilterChannelLayouts **l, const AVChannelLayout *channel_layout)
Definition formats.c:588
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition formats.c:751
av_warn_unused_result AVFilterFormats * ff_make_sample_format_list(const enum AVSampleFormat *fmts)
Create a list of supported sample formats.
#define FF_COUNT2LAYOUT(c)
Encode a channel count as a channel layout.
Definition formats.h:102
av_warn_unused_result AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
av_warn_unused_result AVFilterFormats * ff_make_pixel_format_list(const enum AVPixelFormat *fmts)
Create a list of supported pixel formats.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition opt.h:270
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR(e)
Definition error.h:45
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
Definition rational.h:89
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
AVSampleFormat
Audio sample formats.
Definition samplefmt.h:55
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition samplefmt.h:66
@ AV_SAMPLE_FMT_NONE
Definition samplefmt.h:56
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition intra.c:278
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
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:629
#define FFERROR_NOT_READY
Filters implementation helper functions and internal structures.
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:652
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition filters.h:199
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:478
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:241
static const int factor[16]
Definition vf_pp7.c:98
#define av_cold
Definition attributes.h:117
size_t av_cpu_max_align(void)
Get the maximum data alignment that may be required by FFmpeg.
Definition cpu.c:287
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
#define FFMAX(a, b)
Definition macros.h:47
#define FFALIGN(x, a)
Definition macros.h:78
#define M_PI
Definition mathematics.h:67
uint64_t layout
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:264
Memory handling functions.
AVOptions.
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ 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:87
#define AV_PIX_FMT_GRAY16
Definition pixfmt.h:528
#define AV_PIX_FMT_YUV444P16
Definition pixfmt.h:558
formats
Definition signature.h:47
Describe the class of an AVClass context structure.
Definition log.h:76
A list of supported channel layouts.
Definition formats.h:85
An instance of a filter.
Definition avfilter.h:273
Lists of formats / etc.
Definition avfilter.h:120
A list of supported formats for one end of a filter link.
Definition formats.h:64
A filter pad used for either input or output.
Definition filters.h:40
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
AVOption.
Definition opt.h:428
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
float * window_func_lut
Window function LUT.
AVTXContext * fft
Fast Fourier Transform context.
AVComplexFloat ** fft_in
bins holder for each (displayed) channels
AVComplexFloat ** fft_out
bins holder for each (displayed) channels
#define av_realloc_f(p, o, n)
#define av_freep(p)
#define av_log(a,...)
#define LOG(...)
Definition internal.h:126
#define height
Definition dsp.h:89
#define width
Definition dsp.h:89
static int64_t pts
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
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
@ AV_TX_FLOAT_FFT
Standard complex to complex FFT with sample data type of AVComplexFloat, AVComplexDouble or AVComplex...
Definition tx.h:47
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
static void synth_window(AVFilterContext *ctx, int x)
static int try_push_frame(AVFilterContext *ctx, int x)
MagnitudeScale
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[]
static void read16_fft_bin(SpectrumSynthContext *s, int x, int y, int f, int ch)
static void read_fft_data(AVFilterContext *ctx, int x, int h, int ch)
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int activate(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
#define OFFSET(x)
static int config_output(AVFilterLink *outlink)
static const AVFilterPad spectrumsynth_outputs[]
#define LINEAR
static double c[64]
#define WIN_FUNC_OPTION(win_func_opt_name, win_func_offset, flag, default_window_func)
Definition window_func.h:37
static void generate_window_func(float *lut, int N, int win_func, float *overlap)
Definition window_func.h:63