You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

501 lines
18KB

  1. /*
  2. * Copyright (c) 2015 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. #include <math.h>
  21. #include "libavcodec/avfft.h"
  22. #include "libavutil/audio_fifo.h"
  23. #include "libavutil/avassert.h"
  24. #include "libavutil/avstring.h"
  25. #include "libavutil/channel_layout.h"
  26. #include "libavutil/intreadwrite.h"
  27. #include "libavutil/opt.h"
  28. #include "libavutil/parseutils.h"
  29. #include "audio.h"
  30. #include "video.h"
  31. #include "avfilter.h"
  32. #include "internal.h"
  33. #include "window_func.h"
  34. enum DisplayMode { LINE, BAR, DOT, NB_MODES };
  35. enum ChannelMode { COMBINED, SEPARATE, NB_CMODES };
  36. enum FrequencyScale { FS_LINEAR, FS_LOG, FS_RLOG, NB_FSCALES };
  37. enum AmplitudeScale { AS_LINEAR, AS_SQRT, AS_CBRT, AS_LOG, NB_ASCALES };
  38. typedef struct ShowFreqsContext {
  39. const AVClass *class;
  40. int w, h;
  41. int mode;
  42. int cmode;
  43. int fft_bits;
  44. int ascale, fscale;
  45. int avg;
  46. int win_func;
  47. FFTContext *fft;
  48. FFTComplex **fft_data;
  49. float **avg_data;
  50. float *window_func_lut;
  51. float overlap;
  52. int skip_samples;
  53. int nb_channels;
  54. int nb_freq;
  55. int win_size;
  56. float scale;
  57. char *colors;
  58. AVAudioFifo *fifo;
  59. int64_t pts;
  60. } ShowFreqsContext;
  61. #define OFFSET(x) offsetof(ShowFreqsContext, x)
  62. #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
  63. static const AVOption showfreqs_options[] = {
  64. { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "1024x512"}, 0, 0, FLAGS },
  65. { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "1024x512"}, 0, 0, FLAGS },
  66. { "mode", "set display mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=BAR}, 0, NB_MODES-1, FLAGS, "mode" },
  67. { "line", "show lines", 0, AV_OPT_TYPE_CONST, {.i64=LINE}, 0, 0, FLAGS, "mode" },
  68. { "bar", "show bars", 0, AV_OPT_TYPE_CONST, {.i64=BAR}, 0, 0, FLAGS, "mode" },
  69. { "dot", "show dots", 0, AV_OPT_TYPE_CONST, {.i64=DOT}, 0, 0, FLAGS, "mode" },
  70. { "ascale", "set amplitude scale", OFFSET(ascale), AV_OPT_TYPE_INT, {.i64=AS_LOG}, 0, NB_ASCALES-1, FLAGS, "ascale" },
  71. { "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=AS_LINEAR}, 0, 0, FLAGS, "ascale" },
  72. { "sqrt", "square root", 0, AV_OPT_TYPE_CONST, {.i64=AS_SQRT}, 0, 0, FLAGS, "ascale" },
  73. { "cbrt", "cubic root", 0, AV_OPT_TYPE_CONST, {.i64=AS_CBRT}, 0, 0, FLAGS, "ascale" },
  74. { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=AS_LOG}, 0, 0, FLAGS, "ascale" },
  75. { "fscale", "set frequency scale", OFFSET(fscale), AV_OPT_TYPE_INT, {.i64=FS_LINEAR}, 0, NB_FSCALES-1, FLAGS, "fscale" },
  76. { "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=FS_LINEAR}, 0, 0, FLAGS, "fscale" },
  77. { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=FS_LOG}, 0, 0, FLAGS, "fscale" },
  78. { "rlog", "reverse logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=FS_RLOG}, 0, 0, FLAGS, "fscale" },
  79. { "win_size", "set window size", OFFSET(fft_bits), AV_OPT_TYPE_INT, {.i64=11}, 4, 16, FLAGS, "fft" },
  80. { "w16", 0, 0, AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, FLAGS, "fft" },
  81. { "w32", 0, 0, AV_OPT_TYPE_CONST, {.i64=5}, 0, 0, FLAGS, "fft" },
  82. { "w64", 0, 0, AV_OPT_TYPE_CONST, {.i64=6}, 0, 0, FLAGS, "fft" },
  83. { "w128", 0, 0, AV_OPT_TYPE_CONST, {.i64=7}, 0, 0, FLAGS, "fft" },
  84. { "w256", 0, 0, AV_OPT_TYPE_CONST, {.i64=8}, 0, 0, FLAGS, "fft" },
  85. { "w512", 0, 0, AV_OPT_TYPE_CONST, {.i64=9}, 0, 0, FLAGS, "fft" },
  86. { "w1024", 0, 0, AV_OPT_TYPE_CONST, {.i64=10}, 0, 0, FLAGS, "fft" },
  87. { "w2048", 0, 0, AV_OPT_TYPE_CONST, {.i64=11}, 0, 0, FLAGS, "fft" },
  88. { "w4096", 0, 0, AV_OPT_TYPE_CONST, {.i64=12}, 0, 0, FLAGS, "fft" },
  89. { "w8192", 0, 0, AV_OPT_TYPE_CONST, {.i64=13}, 0, 0, FLAGS, "fft" },
  90. { "w16384", 0, 0, AV_OPT_TYPE_CONST, {.i64=14}, 0, 0, FLAGS, "fft" },
  91. { "w32768", 0, 0, AV_OPT_TYPE_CONST, {.i64=15}, 0, 0, FLAGS, "fft" },
  92. { "w65536", 0, 0, AV_OPT_TYPE_CONST, {.i64=16}, 0, 0, FLAGS, "fft" },
  93. { "win_func", "set window function", OFFSET(win_func), AV_OPT_TYPE_INT, {.i64=WFUNC_HANNING}, 0, NB_WFUNC-1, FLAGS, "win_func" },
  94. { "rect", "Rectangular", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_RECT}, 0, 0, FLAGS, "win_func" },
  95. { "bartlett", "Bartlett", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BARTLETT}, 0, 0, FLAGS, "win_func" },
  96. { "hanning", "Hanning", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_HANNING}, 0, 0, FLAGS, "win_func" },
  97. { "hamming", "Hamming", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_HAMMING}, 0, 0, FLAGS, "win_func" },
  98. { "blackman", "Blackman", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BLACKMAN}, 0, 0, FLAGS, "win_func" },
  99. { "welch", "Welch", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_WELCH}, 0, 0, FLAGS, "win_func" },
  100. { "flattop", "Flat-top", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_FLATTOP}, 0, 0, FLAGS, "win_func" },
  101. { "bharris", "Blackman-Harris", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BHARRIS}, 0, 0, FLAGS, "win_func" },
  102. { "bnuttall", "Blackman-Nuttall", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BNUTTALL}, 0, 0, FLAGS, "win_func" },
  103. { "bhann", "Bartlett-Hann", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BHANN}, 0, 0, FLAGS, "win_func" },
  104. { "sine", "Sine", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_SINE}, 0, 0, FLAGS, "win_func" },
  105. { "nuttall", "Nuttall", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_NUTTALL}, 0, 0, FLAGS, "win_func" },
  106. { "lanczos", "Lanczos", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_LANCZOS}, 0, 0, FLAGS, "win_func" },
  107. { "gauss", "Gauss", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_GAUSS}, 0, 0, FLAGS, "win_func" },
  108. { "tukey", "Tukey", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_TUKEY}, 0, 0, FLAGS, "win_func" },
  109. { "overlap", "set window overlap", OFFSET(overlap), AV_OPT_TYPE_FLOAT, {.dbl=1.}, 0., 1., FLAGS },
  110. { "averaging", "set time averaging", OFFSET(avg), AV_OPT_TYPE_INT, {.i64=1}, 0, INT32_MAX, FLAGS },
  111. { "colors", "set channels colors", OFFSET(colors), AV_OPT_TYPE_STRING, {.str = "red|green|blue|yellow|orange|lime|pink|magenta|brown" }, 0, 0, FLAGS },
  112. { "cmode", "set channel mode", OFFSET(cmode), AV_OPT_TYPE_INT, {.i64=COMBINED}, 0, NB_CMODES-1, FLAGS, "cmode" },
  113. { "combined", "show all channels in same window", 0, AV_OPT_TYPE_CONST, {.i64=COMBINED}, 0, 0, FLAGS, "cmode" },
  114. { "separate", "show each channel in own window", 0, AV_OPT_TYPE_CONST, {.i64=SEPARATE}, 0, 0, FLAGS, "cmode" },
  115. { NULL }
  116. };
  117. AVFILTER_DEFINE_CLASS(showfreqs);
  118. static int query_formats(AVFilterContext *ctx)
  119. {
  120. AVFilterFormats *formats = NULL;
  121. AVFilterChannelLayouts *layouts = NULL;
  122. AVFilterLink *inlink = ctx->inputs[0];
  123. AVFilterLink *outlink = ctx->outputs[0];
  124. static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE };
  125. static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE };
  126. int ret;
  127. /* set input audio formats */
  128. formats = ff_make_format_list(sample_fmts);
  129. if ((ret = ff_formats_ref(formats, &inlink->out_formats)) < 0)
  130. return ret;
  131. layouts = ff_all_channel_layouts();
  132. if ((ret = ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts)) < 0)
  133. return ret;
  134. formats = ff_all_samplerates();
  135. if ((ret = ff_formats_ref(formats, &inlink->out_samplerates)) < 0)
  136. return ret;
  137. /* set output video format */
  138. formats = ff_make_format_list(pix_fmts);
  139. if ((ret = ff_formats_ref(formats, &outlink->in_formats)) < 0)
  140. return ret;
  141. return 0;
  142. }
  143. static int config_output(AVFilterLink *outlink)
  144. {
  145. AVFilterContext *ctx = outlink->src;
  146. AVFilterLink *inlink = ctx->inputs[0];
  147. ShowFreqsContext *s = ctx->priv;
  148. float overlap;
  149. int i;
  150. s->nb_freq = 1 << (s->fft_bits - 1);
  151. s->win_size = s->nb_freq << 1;
  152. av_audio_fifo_free(s->fifo);
  153. av_fft_end(s->fft);
  154. s->fft = av_fft_init(s->fft_bits, 0);
  155. if (!s->fft) {
  156. av_log(ctx, AV_LOG_ERROR, "Unable to create FFT context. "
  157. "The window size might be too high.\n");
  158. return AVERROR(ENOMEM);
  159. }
  160. /* FFT buffers: x2 for each (display) channel buffer.
  161. * Note: we use free and malloc instead of a realloc-like function to
  162. * make sure the buffer is aligned in memory for the FFT functions. */
  163. for (i = 0; i < s->nb_channels; i++) {
  164. av_freep(&s->fft_data[i]);
  165. av_freep(&s->avg_data[i]);
  166. }
  167. av_freep(&s->fft_data);
  168. av_freep(&s->avg_data);
  169. s->nb_channels = inlink->channels;
  170. s->fft_data = av_calloc(s->nb_channels, sizeof(*s->fft_data));
  171. if (!s->fft_data)
  172. return AVERROR(ENOMEM);
  173. s->avg_data = av_calloc(s->nb_channels, sizeof(*s->avg_data));
  174. if (!s->fft_data)
  175. return AVERROR(ENOMEM);
  176. for (i = 0; i < s->nb_channels; i++) {
  177. s->fft_data[i] = av_calloc(s->win_size, sizeof(**s->fft_data));
  178. s->avg_data[i] = av_calloc(s->nb_freq, sizeof(**s->avg_data));
  179. if (!s->fft_data[i] || !s->avg_data[i])
  180. return AVERROR(ENOMEM);
  181. }
  182. /* pre-calc windowing function */
  183. s->window_func_lut = av_realloc_f(s->window_func_lut, s->win_size,
  184. sizeof(*s->window_func_lut));
  185. if (!s->window_func_lut)
  186. return AVERROR(ENOMEM);
  187. ff_generate_window_func(s->window_func_lut, s->win_size, s->win_func, &overlap);
  188. if (s->overlap == 1.)
  189. s->overlap = overlap;
  190. s->skip_samples = (1. - s->overlap) * s->win_size;
  191. if (s->skip_samples < 1) {
  192. av_log(ctx, AV_LOG_ERROR, "overlap %f too big\n", s->overlap);
  193. return AVERROR(EINVAL);
  194. }
  195. for (s->scale = 0, i = 0; i < s->win_size; i++) {
  196. s->scale += s->window_func_lut[i] * s->window_func_lut[i];
  197. }
  198. outlink->frame_rate = av_make_q(inlink->sample_rate, s->win_size * (1.-s->overlap));
  199. outlink->sample_aspect_ratio = (AVRational){1,1};
  200. outlink->w = s->w;
  201. outlink->h = s->h;
  202. s->fifo = av_audio_fifo_alloc(inlink->format, inlink->channels, s->win_size);
  203. if (!s->fifo)
  204. return AVERROR(ENOMEM);
  205. return 0;
  206. }
  207. static inline void draw_dot(AVFrame *out, int x, int y, uint8_t fg[4])
  208. {
  209. uint32_t color = AV_RL32(out->data[0] + y * out->linesize[0] + x * 4);
  210. if ((color & 0xffffff) != 0)
  211. AV_WL32(out->data[0] + y * out->linesize[0] + x * 4, AV_RL32(fg) | color);
  212. else
  213. AV_WL32(out->data[0] + y * out->linesize[0] + x * 4, AV_RL32(fg));
  214. }
  215. static int get_sx(ShowFreqsContext *s, int f)
  216. {
  217. switch (s->fscale) {
  218. case FS_LINEAR:
  219. return (s->w/(float)s->nb_freq)*f;
  220. case FS_LOG:
  221. return s->w-pow(s->w, (s->nb_freq-f-1)/(s->nb_freq-1.));
  222. case FS_RLOG:
  223. return pow(s->w, f/(s->nb_freq-1.));
  224. }
  225. return 0;
  226. }
  227. static float get_bsize(ShowFreqsContext *s, int f)
  228. {
  229. switch (s->fscale) {
  230. case FS_LINEAR:
  231. return s->w/(float)s->nb_freq;
  232. case FS_LOG:
  233. return pow(s->w, (s->nb_freq-f-1)/(s->nb_freq-1.))-
  234. pow(s->w, (s->nb_freq-f-2)/(s->nb_freq-1.));
  235. case FS_RLOG:
  236. return pow(s->w, (f+1)/(s->nb_freq-1.))-
  237. pow(s->w, f /(s->nb_freq-1.));
  238. }
  239. return 1.;
  240. }
  241. static inline void plot_freq(ShowFreqsContext *s, int ch,
  242. double a, int f, uint8_t fg[4], int *prev_y,
  243. AVFrame *out, AVFilterLink *outlink)
  244. {
  245. const int w = s->w;
  246. const float avg = s->avg_data[ch][f];
  247. const float bsize = get_bsize(s, f);
  248. const int sx = get_sx(s, f);
  249. int end = outlink->h;
  250. int x, y, i;
  251. switch(s->ascale) {
  252. case AS_SQRT:
  253. a = 1.0 - sqrt(a);
  254. break;
  255. case AS_CBRT:
  256. a = 1.0 - cbrt(a);
  257. break;
  258. case AS_LOG:
  259. a = log(av_clipd(a, 1e-6, 1)) / log(1e-6);
  260. break;
  261. case AS_LINEAR:
  262. a = 1.0 - a;
  263. break;
  264. }
  265. switch (s->cmode) {
  266. case COMBINED:
  267. y = a * outlink->h - 1;
  268. break;
  269. case SEPARATE:
  270. end = (outlink->h / s->nb_channels) * (ch + 1);
  271. y = (outlink->h / s->nb_channels) * ch + a * (outlink->h / s->nb_channels) - 1;
  272. break;
  273. }
  274. if (y < 0)
  275. return;
  276. switch (s->avg) {
  277. case 0:
  278. y = s->avg_data[ch][f] = !outlink->frame_count ? y : FFMIN(avg, y);
  279. break;
  280. case 1:
  281. break;
  282. default:
  283. s->avg_data[ch][f] = avg + y * (y - avg) / (FFMIN(outlink->frame_count + 1, s->avg) * y);
  284. y = s->avg_data[ch][f];
  285. break;
  286. }
  287. switch(s->mode) {
  288. case LINE:
  289. if (*prev_y == -1) {
  290. *prev_y = y;
  291. }
  292. if (y <= *prev_y) {
  293. for (x = sx + 1; x < sx + bsize && x < w; x++)
  294. draw_dot(out, x, y, fg);
  295. for (i = y; i <= *prev_y; i++)
  296. draw_dot(out, sx, i, fg);
  297. } else {
  298. for (i = *prev_y; i <= y; i++)
  299. draw_dot(out, sx, i, fg);
  300. for (x = sx + 1; x < sx + bsize && x < w; x++)
  301. draw_dot(out, x, i - 1, fg);
  302. }
  303. *prev_y = y;
  304. break;
  305. case BAR:
  306. for (x = sx; x < sx + bsize && x < w; x++)
  307. for (i = y; i < end; i++)
  308. draw_dot(out, x, i, fg);
  309. break;
  310. case DOT:
  311. for (x = sx; x < sx + bsize && x < w; x++)
  312. draw_dot(out, x, y, fg);
  313. break;
  314. }
  315. }
  316. static int plot_freqs(AVFilterLink *inlink, AVFrame *in)
  317. {
  318. AVFilterContext *ctx = inlink->dst;
  319. AVFilterLink *outlink = ctx->outputs[0];
  320. ShowFreqsContext *s = ctx->priv;
  321. const int win_size = s->win_size;
  322. char *colors, *color, *saveptr = NULL;
  323. AVFrame *out;
  324. int ch, n;
  325. out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
  326. if (!out)
  327. return AVERROR(ENOMEM);
  328. for (n = 0; n < outlink->h; n++)
  329. memset(out->data[0] + out->linesize[0] * n, 0, outlink->w * 4);
  330. /* fill FFT input with the number of samples available */
  331. for (ch = 0; ch < s->nb_channels; ch++) {
  332. const float *p = (float *)in->extended_data[ch];
  333. for (n = 0; n < in->nb_samples; n++) {
  334. s->fft_data[ch][n].re = p[n] * s->window_func_lut[n];
  335. s->fft_data[ch][n].im = 0;
  336. }
  337. for (; n < win_size; n++) {
  338. s->fft_data[ch][n].re = 0;
  339. s->fft_data[ch][n].im = 0;
  340. }
  341. }
  342. /* run FFT on each samples set */
  343. for (ch = 0; ch < s->nb_channels; ch++) {
  344. av_fft_permute(s->fft, s->fft_data[ch]);
  345. av_fft_calc(s->fft, s->fft_data[ch]);
  346. }
  347. #define RE(x, ch) s->fft_data[ch][x].re
  348. #define IM(x, ch) s->fft_data[ch][x].im
  349. #define M(a, b) (sqrt((a) * (a) + (b) * (b)))
  350. colors = av_strdup(s->colors);
  351. if (!colors) {
  352. av_frame_free(&out);
  353. return AVERROR(ENOMEM);
  354. }
  355. for (ch = 0; ch < s->nb_channels; ch++) {
  356. uint8_t fg[4] = { 0xff, 0xff, 0xff, 0xff };
  357. int prev_y = -1, f;
  358. double a;
  359. color = av_strtok(ch == 0 ? colors : NULL, " |", &saveptr);
  360. if (color)
  361. av_parse_color(fg, color, -1, ctx);
  362. a = av_clipd(M(RE(0, ch), 0) / s->scale, 0, 1);
  363. plot_freq(s, ch, a, 0, fg, &prev_y, out, outlink);
  364. for (f = 1; f < s->nb_freq; f++) {
  365. a = av_clipd(M(RE(f, ch), IM(f, ch)) / s->scale, 0, 1);
  366. plot_freq(s, ch, a, f, fg, &prev_y, out, outlink);
  367. }
  368. }
  369. av_free(colors);
  370. out->pts = in->pts;
  371. return ff_filter_frame(outlink, out);
  372. }
  373. static int filter_frame(AVFilterLink *inlink, AVFrame *in)
  374. {
  375. AVFilterContext *ctx = inlink->dst;
  376. ShowFreqsContext *s = ctx->priv;
  377. AVFrame *fin = NULL;
  378. int ret = 0;
  379. av_audio_fifo_write(s->fifo, (void **)in->extended_data, in->nb_samples);
  380. while (av_audio_fifo_size(s->fifo) >= s->win_size) {
  381. fin = ff_get_audio_buffer(inlink, s->win_size);
  382. if (!fin) {
  383. ret = AVERROR(ENOMEM);
  384. goto fail;
  385. }
  386. fin->pts = s->pts;
  387. s->pts += s->skip_samples;
  388. ret = av_audio_fifo_peek(s->fifo, (void **)fin->extended_data, s->win_size);
  389. if (ret < 0)
  390. goto fail;
  391. ret = plot_freqs(inlink, fin);
  392. av_frame_free(&fin);
  393. av_audio_fifo_drain(s->fifo, s->skip_samples);
  394. if (ret < 0)
  395. goto fail;
  396. }
  397. fail:
  398. av_frame_free(&fin);
  399. av_frame_free(&in);
  400. return ret;
  401. }
  402. static av_cold void uninit(AVFilterContext *ctx)
  403. {
  404. ShowFreqsContext *s = ctx->priv;
  405. int i;
  406. av_fft_end(s->fft);
  407. for (i = 0; i < s->nb_channels; i++) {
  408. if (s->fft_data)
  409. av_freep(&s->fft_data[i]);
  410. if (s->avg_data)
  411. av_freep(&s->avg_data[i]);
  412. }
  413. av_freep(&s->fft_data);
  414. av_freep(&s->avg_data);
  415. av_freep(&s->window_func_lut);
  416. av_audio_fifo_free(s->fifo);
  417. }
  418. static const AVFilterPad showfreqs_inputs[] = {
  419. {
  420. .name = "default",
  421. .type = AVMEDIA_TYPE_AUDIO,
  422. .filter_frame = filter_frame,
  423. },
  424. { NULL }
  425. };
  426. static const AVFilterPad showfreqs_outputs[] = {
  427. {
  428. .name = "default",
  429. .type = AVMEDIA_TYPE_VIDEO,
  430. .config_props = config_output,
  431. },
  432. { NULL }
  433. };
  434. AVFilter ff_avf_showfreqs = {
  435. .name = "showfreqs",
  436. .description = NULL_IF_CONFIG_SMALL("Convert input audio to a frequencies video output."),
  437. .uninit = uninit,
  438. .query_formats = query_formats,
  439. .priv_size = sizeof(ShowFreqsContext),
  440. .inputs = showfreqs_inputs,
  441. .outputs = showfreqs_outputs,
  442. .priv_class = &showfreqs_class,
  443. };