FFmpeg
avf_showcqt.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015 Muhammad Faiz <mfcc64@gmail.com>
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 #include "config.h"
22 #include "libavutil/mem.h"
23 #include "libavutil/tx.h"
25 #include "libavutil/opt.h"
27 #include "libavutil/eval.h"
28 #include "libavutil/pixdesc.h"
29 #include "libavutil/time.h"
30 #include "audio.h"
31 #include "avfilter.h"
32 #include "filters.h"
33 #include "formats.h"
34 #include "lavfutils.h"
35 #include "lswsutils.h"
36 #include "video.h"
37 
38 #if CONFIG_LIBFREETYPE
39 #include <ft2build.h>
40 #include FT_FREETYPE_H
41 #endif
42 
43 #if CONFIG_LIBFONTCONFIG
44 #include <fontconfig/fontconfig.h>
45 #endif
46 
47 #include "avf_showcqt.h"
48 
49 #define BASEFREQ 20.01523126408007475
50 #define ENDFREQ 20495.59681441799654
51 #define TLENGTH "384*tc/(384+tc*f)"
52 #define TLENGTH_MIN 0.001
53 #define VOLUME_MAX 100.0
54 #define FONTCOLOR "st(0, (midi(f)-59.5)/12);" \
55  "st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));" \
56  "r(1-ld(1)) + b(ld(1))"
57 #define CSCHEME "1|0.5|0|0|0.5|1"
58 
59 #define OFFSET(x) offsetof(ShowCQTContext, x)
60 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
61 
62 static const AVOption showcqt_options[] = {
63  { "size", "set video size", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, { .str = "1920x1080" }, 0, 0, FLAGS },
64  { "s", "set video size", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, { .str = "1920x1080" }, 0, 0, FLAGS },
65  { "fps", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, { .str = "25" }, 1, 1000, FLAGS },
66  { "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, { .str = "25" }, 1, 1000, FLAGS },
67  { "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, { .str = "25" }, 1, 1000, FLAGS },
68  { "bar_h", "set bargraph height", OFFSET(bar_h), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
69  { "axis_h", "set axis height", OFFSET(axis_h), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
70  { "sono_h", "set sonogram height", OFFSET(sono_h), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
71  { "fullhd", "set fullhd size", OFFSET(fullhd), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
72  { "sono_v", "set sonogram volume", OFFSET(sono_v), AV_OPT_TYPE_STRING, { .str = "16" }, 0, 0, FLAGS },
73  { "volume", "set sonogram volume", OFFSET(sono_v), AV_OPT_TYPE_STRING, { .str = "16" }, 0, 0, FLAGS },
74  { "bar_v", "set bargraph volume", OFFSET(bar_v), AV_OPT_TYPE_STRING, { .str = "sono_v" }, 0, 0, FLAGS },
75  { "volume2", "set bargraph volume", OFFSET(bar_v), AV_OPT_TYPE_STRING, { .str = "sono_v" }, 0, 0, FLAGS },
76  { "sono_g", "set sonogram gamma", OFFSET(sono_g), AV_OPT_TYPE_FLOAT, { .dbl = 3.0 }, 1.0, 7.0, FLAGS },
77  { "gamma", "set sonogram gamma", OFFSET(sono_g), AV_OPT_TYPE_FLOAT, { .dbl = 3.0 }, 1.0, 7.0, FLAGS },
78  { "bar_g", "set bargraph gamma", OFFSET(bar_g), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 1.0, 7.0, FLAGS },
79  { "gamma2", "set bargraph gamma", OFFSET(bar_g), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 1.0, 7.0, FLAGS },
80  { "bar_t", "set bar transparency", OFFSET(bar_t), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 0.0, 1.0, FLAGS },
81  { "timeclamp", "set timeclamp", OFFSET(timeclamp), AV_OPT_TYPE_DOUBLE, { .dbl = 0.17 }, 0.002, 1.0, FLAGS },
82  { "tc", "set timeclamp", OFFSET(timeclamp), AV_OPT_TYPE_DOUBLE, { .dbl = 0.17 }, 0.002, 1.0, FLAGS },
83  { "attack", "set attack time", OFFSET(attack), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, 0.0, 1.0, FLAGS },
84  { "basefreq", "set base frequency", OFFSET(basefreq), AV_OPT_TYPE_DOUBLE, { .dbl = BASEFREQ }, 10.0, 100000.0, FLAGS },
85  { "endfreq", "set end frequency", OFFSET(endfreq), AV_OPT_TYPE_DOUBLE, { .dbl = ENDFREQ }, 10.0, 100000.0, FLAGS },
86  { "coeffclamp", "set coeffclamp", OFFSET(coeffclamp), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 0.1, 10.0, FLAGS },
87  { "tlength", "set tlength", OFFSET(tlength), AV_OPT_TYPE_STRING, { .str = TLENGTH }, 0, 0, FLAGS },
88  { "count", "set transform count", OFFSET(count), AV_OPT_TYPE_INT, { .i64 = 6 }, 1, 30, FLAGS },
89  { "fcount", "set frequency count", OFFSET(fcount), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 10, FLAGS },
90  { "fontfile", "set axis font file", OFFSET(fontfile), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
91  { "font", "set axis font", OFFSET(font), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
92  { "fontcolor", "set font color", OFFSET(fontcolor), AV_OPT_TYPE_STRING, { .str = FONTCOLOR }, 0, 0, FLAGS },
93  { "axisfile", "set axis image", OFFSET(axisfile), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
94  { "axis", "draw axis", OFFSET(axis), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
95  { "text", "draw axis", OFFSET(axis), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
96  { "csp", "set color space", OFFSET(csp), AV_OPT_TYPE_INT, { .i64 = AVCOL_SPC_UNSPECIFIED }, 0, INT_MAX, FLAGS, .unit = "csp" },
97  { "unspecified", "unspecified", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_SPC_UNSPECIFIED }, 0, 0, FLAGS, .unit = "csp" },
98  { "bt709", "bt709", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_SPC_BT709 }, 0, 0, FLAGS, .unit = "csp" },
99  { "fcc", "fcc", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_SPC_FCC }, 0, 0, FLAGS, .unit = "csp" },
100  { "bt470bg", "bt470bg", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_SPC_BT470BG }, 0, 0, FLAGS, .unit = "csp" },
101  { "smpte170m", "smpte170m", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_SPC_SMPTE170M }, 0, 0, FLAGS, .unit = "csp" },
102  { "smpte240m", "smpte240m", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_SPC_SMPTE240M }, 0, 0, FLAGS, .unit = "csp" },
103  { "bt2020ncl", "bt2020ncl", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_SPC_BT2020_NCL }, 0, 0, FLAGS, .unit = "csp" },
104  { "cscheme", "set color scheme", OFFSET(cscheme), AV_OPT_TYPE_STRING, { .str = CSCHEME }, 0, 0, FLAGS },
105  { NULL }
106 };
107 
108 AVFILTER_DEFINE_CLASS(showcqt);
109 
111 {
112  int k;
113  int level = AV_LOG_DEBUG;
114  int64_t plot_time;
115 
116  if (s->fft_time)
117  av_log(s->ctx, level, "fft_time = %16.3f s.\n", s->fft_time * 1e-6);
118  if (s->cqt_time)
119  av_log(s->ctx, level, "cqt_time = %16.3f s.\n", s->cqt_time * 1e-6);
120  if (s->process_cqt_time)
121  av_log(s->ctx, level, "process_cqt_time = %16.3f s.\n", s->process_cqt_time * 1e-6);
122  if (s->update_sono_time)
123  av_log(s->ctx, level, "update_sono_time = %16.3f s.\n", s->update_sono_time * 1e-6);
124  if (s->alloc_time)
125  av_log(s->ctx, level, "alloc_time = %16.3f s.\n", s->alloc_time * 1e-6);
126  if (s->bar_time)
127  av_log(s->ctx, level, "bar_time = %16.3f s.\n", s->bar_time * 1e-6);
128  if (s->axis_time)
129  av_log(s->ctx, level, "axis_time = %16.3f s.\n", s->axis_time * 1e-6);
130  if (s->sono_time)
131  av_log(s->ctx, level, "sono_time = %16.3f s.\n", s->sono_time * 1e-6);
132 
133  plot_time = s->fft_time + s->cqt_time + s->process_cqt_time + s->update_sono_time
134  + s->alloc_time + s->bar_time + s->axis_time + s->sono_time;
135  if (plot_time)
136  av_log(s->ctx, level, "plot_time = %16.3f s.\n", plot_time * 1e-6);
137 
138  s->fft_time = s->cqt_time = s->process_cqt_time = s->update_sono_time
139  = s->alloc_time = s->bar_time = s->axis_time = s->sono_time = 0;
140  /* axis_frame may be non reference counted frame */
141  if (s->axis_frame && !s->axis_frame->buf[0]) {
142  av_freep(s->axis_frame->data);
143  for (k = 0; k < 4; k++)
144  s->axis_frame->data[k] = NULL;
145  }
146 
147  av_frame_free(&s->axis_frame);
148  av_frame_free(&s->sono_frame);
149  av_tx_uninit(&s->fft_ctx);
150  if (s->coeffs)
151  for (k = 0; k < s->cqt_len; k++)
152  av_freep(&s->coeffs[k].val);
153  av_freep(&s->coeffs);
154  av_freep(&s->fft_data);
155  av_freep(&s->fft_input);
156  av_freep(&s->fft_result);
157  av_freep(&s->cqt_result);
158  av_freep(&s->attack_data);
159  av_freep(&s->c_buf);
160  av_freep(&s->h_buf);
161  av_freep(&s->rcp_h_buf);
162  av_freep(&s->freq);
163  av_freep(&s->sono_v_buf);
164  av_freep(&s->bar_v_buf);
165 }
166 
167 static double *create_freq_table(double base, double end, int n)
168 {
169  double log_base, log_end;
170  double rcp_n = 1.0 / n;
171  double *freq;
172  int x;
173 
174  freq = av_malloc_array(n, sizeof(*freq));
175  if (!freq)
176  return NULL;
177 
178  log_base = log(base);
179  log_end = log(end);
180  for (x = 0; x < n; x++) {
181  double log_freq = log_base + (x + 0.5) * (log_end - log_base) * rcp_n;
182  freq[x] = exp(log_freq);
183  }
184  return freq;
185 }
186 
187 static double clip_with_log(void *log_ctx, const char *name,
188  double val, double min, double max,
189  double nan_replace, int idx)
190 {
191  int level = AV_LOG_WARNING;
192  if (isnan(val)) {
193  av_log(log_ctx, level, "[%d] %s is nan, setting it to %g.\n",
194  idx, name, nan_replace);
195  val = nan_replace;
196  } else if (val < min) {
197  av_log(log_ctx, level, "[%d] %s is too low (%g), setting it to %g.\n",
198  idx, name, val, min);
199  val = min;
200  } else if (val > max) {
201  av_log(log_ctx, level, "[%d] %s it too high (%g), setting it to %g.\n",
202  idx, name, val, max);
203  val = max;
204  }
205  return val;
206 }
207 
208 static double a_weighting(void *p, double f)
209 {
210  double ret = 12200.0*12200.0 * (f*f*f*f);
211  ret /= (f*f + 20.6*20.6) * (f*f + 12200.0*12200.0) *
212  sqrt((f*f + 107.7*107.7) * (f*f + 737.9*737.9));
213  return ret;
214 }
215 
216 static double b_weighting(void *p, double f)
217 {
218  double ret = 12200.0*12200.0 * (f*f*f);
219  ret /= (f*f + 20.6*20.6) * (f*f + 12200.0*12200.0) * sqrt(f*f + 158.5*158.5);
220  return ret;
221 }
222 
223 static double c_weighting(void *p, double f)
224 {
225  double ret = 12200.0*12200.0 * (f*f);
226  ret /= (f*f + 20.6*20.6) * (f*f + 12200.0*12200.0);
227  return ret;
228 }
229 
231 {
232  const char *func_names[] = { "a_weighting", "b_weighting", "c_weighting", NULL };
233  const char *sono_names[] = { "timeclamp", "tc", "frequency", "freq", "f", "bar_v", NULL };
234  const char *bar_names[] = { "timeclamp", "tc", "frequency", "freq", "f", "sono_v", NULL };
235  double (*funcs[])(void *, double) = { a_weighting, b_weighting, c_weighting };
236  AVExpr *sono = NULL, *bar = NULL;
237  int x, ret = AVERROR(ENOMEM);
238 
239  s->sono_v_buf = av_malloc_array(s->cqt_len, sizeof(*s->sono_v_buf));
240  s->bar_v_buf = av_malloc_array(s->cqt_len, sizeof(*s->bar_v_buf));
241  if (!s->sono_v_buf || !s->bar_v_buf)
242  goto error;
243 
244  if ((ret = av_expr_parse(&sono, s->sono_v, sono_names, func_names, funcs, NULL, NULL, 0, s->ctx)) < 0)
245  goto error;
246 
247  if ((ret = av_expr_parse(&bar, s->bar_v, bar_names, func_names, funcs, NULL, NULL, 0, s->ctx)) < 0)
248  goto error;
249 
250  for (x = 0; x < s->cqt_len; x++) {
251  double vars[] = { s->timeclamp, s->timeclamp, s->freq[x], s->freq[x], s->freq[x], 0.0 };
252  double vol = clip_with_log(s->ctx, "sono_v", av_expr_eval(sono, vars, NULL), 0.0, VOLUME_MAX, 0.0, x);
253  vars[5] = vol;
254  vol = clip_with_log(s->ctx, "bar_v", av_expr_eval(bar, vars, NULL), 0.0, VOLUME_MAX, 0.0, x);
255  s->bar_v_buf[x] = vol * vol;
256  vars[5] = vol;
257  vol = clip_with_log(s->ctx, "sono_v", av_expr_eval(sono, vars, NULL), 0.0, VOLUME_MAX, 0.0, x);
258  s->sono_v_buf[x] = vol * vol;
259  }
260  av_expr_free(sono);
261  av_expr_free(bar);
262  return 0;
263 
264 error:
265  av_freep(&s->sono_v_buf);
266  av_freep(&s->bar_v_buf);
267  av_expr_free(sono);
268  av_expr_free(bar);
269  return ret;
270 }
271 
272 static void cqt_calc(AVComplexFloat *dst, const AVComplexFloat *src, const Coeffs *coeffs,
273  int len, int fft_len)
274 {
275  int k, x, i, j;
276  for (k = 0; k < len; k++) {
277  AVComplexFloat l, r, a = {0,0}, b = {0,0};
278 
279  for (x = 0; x < coeffs[k].len; x++) {
280  float u = coeffs[k].val[x];
281  i = coeffs[k].start + x;
282  j = fft_len - i;
283  a.re += u * src[i].re;
284  a.im += u * src[i].im;
285  b.re += u * src[j].re;
286  b.im += u * src[j].im;
287  }
288 
289  /* separate left and right, (and multiply by 2.0) */
290  l.re = a.re + b.re;
291  l.im = a.im - b.im;
292  r.re = b.im + a.im;
293  r.im = b.re - a.re;
294  dst[k].re = l.re * l.re + l.im * l.im;
295  dst[k].im = r.re * r.re + r.im * r.im;
296  }
297 }
298 
300 {
301  const char *var_names[] = { "timeclamp", "tc", "frequency", "freq", "f", NULL };
302  AVExpr *expr = NULL;
303  int rate = s->ctx->inputs[0]->sample_rate;
304  int nb_cqt_coeffs = 0;
305  int k, x, ret;
306 
307  if ((ret = av_expr_parse(&expr, s->tlength, var_names, NULL, NULL, NULL, NULL, 0, s->ctx)) < 0)
308  goto error;
309 
310  ret = AVERROR(ENOMEM);
311  if (!(s->coeffs = av_calloc(s->cqt_len, sizeof(*s->coeffs))))
312  goto error;
313 
314  for (k = 0; k < s->cqt_len; k++) {
315  double vars[] = { s->timeclamp, s->timeclamp, s->freq[k], s->freq[k], s->freq[k] };
316  double flen, center, tlength;
317  int start, end, m = k;
318 
319  if (s->freq[k] > 0.5 * rate)
320  continue;
321  tlength = clip_with_log(s->ctx, "tlength", av_expr_eval(expr, vars, NULL),
322  TLENGTH_MIN, s->timeclamp, s->timeclamp, k);
323 
324  flen = 8.0 * s->fft_len / (tlength * rate);
325  center = s->freq[k] * s->fft_len / rate;
326  start = FFMAX(0, ceil(center - 0.5 * flen));
327  end = FFMIN(s->fft_len, floor(center + 0.5 * flen));
328 
329  s->coeffs[m].start = start & ~(s->cqt_align - 1);
330  s->coeffs[m].len = (end | (s->cqt_align - 1)) + 1 - s->coeffs[m].start;
331  nb_cqt_coeffs += s->coeffs[m].len;
332  if (!(s->coeffs[m].val = av_calloc(s->coeffs[m].len, sizeof(*s->coeffs[m].val))))
333  goto error;
334 
335  for (x = start; x <= end; x++) {
336  int sign = (x & 1) ? (-1) : 1;
337  double y = 2.0 * M_PI * (x - center) * (1.0 / flen);
338  /* nuttall window */
339  double w = 0.355768 + 0.487396 * cos(y) + 0.144232 * cos(2*y) + 0.012604 * cos(3*y);
340  w *= sign * (1.0 / s->fft_len);
341  s->coeffs[m].val[x - s->coeffs[m].start] = w;
342  }
343 
344  if (s->permute_coeffs)
345  s->permute_coeffs(s->coeffs[m].val, s->coeffs[m].len);
346  }
347 
348  av_expr_free(expr);
349  av_log(s->ctx, AV_LOG_VERBOSE, "nb_cqt_coeffs = %d.\n", nb_cqt_coeffs);
350  return 0;
351 
352 error:
353  av_expr_free(expr);
354  if (s->coeffs)
355  for (k = 0; k < s->cqt_len; k++)
356  av_freep(&s->coeffs[k].val);
357  av_freep(&s->coeffs);
358  return ret;
359 }
360 
362 {
363  AVFrame *out;
364  out = av_frame_alloc();
365  if (!out)
366  return NULL;
367  out->format = format;
368  out->width = w;
369  out->height = h;
370  if (av_frame_get_buffer(out, 0) < 0) {
371  av_frame_free(&out);
372  return NULL;
373  }
375  memset(out->data[0], 0, out->linesize[0] * h);
376  } else {
377  int hh = (format == AV_PIX_FMT_YUV420P || format == AV_PIX_FMT_YUVA420P) ? h / 2 : h;
378  memset(out->data[0], 16, out->linesize[0] * h);
379  memset(out->data[1], 128, out->linesize[1] * hh);
380  memset(out->data[2], 128, out->linesize[2] * hh);
381  if (out->data[3])
382  memset(out->data[3], 0, out->linesize[3] * h);
383  }
384  return out;
385 }
386 
388 {
389  switch (format) {
390  case AV_PIX_FMT_RGB24: format = AV_PIX_FMT_RGBA; break;
391  case AV_PIX_FMT_YUV444P:
392  case AV_PIX_FMT_YUV422P:
394  }
395  return format;
396 }
397 
399 {
400  if (!(s->axis_frame = alloc_frame_empty(convert_axis_pixel_format(s->format), s->width, s->axis_h)))
401  return AVERROR(ENOMEM);
402  return 0;
403 }
404 
406 {
407  AVFrame *tmp_frame;
408  int ret = ff_load_image(&tmp_frame, s->axisfile, s->ctx);
409  if (ret < 0)
410  return ret;
411 
412  ret = AVERROR(ENOMEM);
413  if (!(s->axis_frame = av_frame_alloc()))
414  goto error;
415 
416  ret = ff_scale_image(s->axis_frame->data, s->axis_frame->linesize, s->width, s->axis_h,
417  convert_axis_pixel_format(s->format),
418  tmp_frame->data, tmp_frame->linesize, tmp_frame->width, tmp_frame->height,
419  tmp_frame->format, s->ctx);
420  if (ret < 0) {
421  av_frame_free(&s->axis_frame);
422  goto error;
423  }
424 
425  s->axis_frame->width = s->width;
426  s->axis_frame->height = s->axis_h;
427  s->axis_frame->format = convert_axis_pixel_format(s->format);
428 
429  ret = 0;
430 error:
431  av_frame_free(&tmp_frame);
432  return ret;
433 }
434 
435 static double midi(void *p, double f)
436 {
437  return log2(f/440.0) * 12.0 + 69.0;
438 }
439 
440 static double r_func(void *p, double x)
441 {
442  x = av_clipd(x, 0.0, 1.0);
443  return lrint(x*255.0) << 16;
444 }
445 
446 static double g_func(void *p, double x)
447 {
448  x = av_clipd(x, 0.0, 1.0);
449  return lrint(x*255.0) << 8;
450 }
451 
452 static double b_func(void *p, double x)
453 {
454  x = av_clipd(x, 0.0, 1.0);
455  return lrint(x*255.0);
456 }
457 
459 {
460  const char *var_names[] = { "timeclamp", "tc", "frequency", "freq", "f", NULL };
461  const char *func_names[] = { "midi", "r", "g", "b", NULL };
462  double (*funcs[])(void *, double) = { midi, r_func, g_func, b_func };
463  AVExpr *expr = NULL;
464  double *freq = NULL;
465  int x, xs, y, ret;
466  int width = half ? 1920/2 : 1920, height = half ? 16 : 32;
467  int step = half ? 2 : 1;
468 
469  if (s->basefreq != (double) BASEFREQ || s->endfreq != (double) ENDFREQ) {
470  av_log(s->ctx, AV_LOG_WARNING, "font axis rendering is not implemented in non-default frequency range,"
471  " please use axisfile option instead.\n");
472  return AVERROR(EINVAL);
473  }
474 
475  if (s->cqt_len == 1920)
476  freq = s->freq;
477  else if (!(freq = create_freq_table(s->basefreq, s->endfreq, 1920)))
478  return AVERROR(ENOMEM);
479 
480  if ((ret = av_expr_parse(&expr, s->fontcolor, var_names, func_names, funcs, NULL, NULL, 0, s->ctx)) < 0) {
481  if (freq != s->freq)
482  av_freep(&freq);
483  return ret;
484  }
485 
486  for (x = 0, xs = 0; x < width; x++, xs += step) {
487  double vars[] = { s->timeclamp, s->timeclamp, freq[xs], freq[xs], freq[xs] };
488  int color = (int) av_expr_eval(expr, vars, NULL);
489  uint8_t r = (color >> 16) & 0xFF, g = (color >> 8) & 0xFF, b = color & 0xFF;
490  uint8_t *data = tmp->data[0];
491  int linesize = tmp->linesize[0];
492  for (y = 0; y < height; y++) {
493  data[linesize * y + 4 * x] = r;
494  data[linesize * y + 4 * x + 1] = g;
495  data[linesize * y + 4 * x + 2] = b;
496  }
497  }
498 
499  av_expr_free(expr);
500  if (freq != s->freq)
501  av_freep(&freq);
502  return 0;
503 }
504 
505 static int render_freetype(ShowCQTContext *s, AVFrame *tmp, char *fontfile)
506 {
507 #if CONFIG_LIBFREETYPE
508  const char *str = "EF G A BC D ";
509  uint8_t *data = tmp->data[0];
510  int linesize = tmp->linesize[0];
511  FT_Library lib = NULL;
512  FT_Face face = NULL;
513  int font_width = 16, font_height = 32;
514  int font_repeat = font_width * 12;
515  int linear_hori_advance = font_width * 65536;
516  int non_monospace_warning = 0;
517  int x;
518 
519  if (!fontfile)
520  return AVERROR(EINVAL);
521 
522  if (FT_Init_FreeType(&lib))
523  goto fail;
524 
525  if (FT_New_Face(lib, fontfile, 0, &face))
526  goto fail;
527 
528  if (FT_Set_Char_Size(face, 16*64, 0, 0, 0))
529  goto fail;
530 
531  if (FT_Load_Char(face, 'A', FT_LOAD_RENDER))
532  goto fail;
533 
534  if (FT_Set_Char_Size(face, 16*64 * linear_hori_advance / face->glyph->linearHoriAdvance, 0, 0, 0))
535  goto fail;
536 
537  for (x = 0; x < 12; x++) {
538  int sx, sy, rx, bx, by, dx, dy;
539 
540  if (str[x] == ' ')
541  continue;
542 
543  if (FT_Load_Char(face, str[x], FT_LOAD_RENDER))
544  goto fail;
545 
546  if (face->glyph->advance.x != font_width*64 && !non_monospace_warning) {
547  av_log(s->ctx, AV_LOG_WARNING, "font is not monospace.\n");
548  non_monospace_warning = 1;
549  }
550 
551  sy = font_height - 8 - face->glyph->bitmap_top;
552  for (rx = 0; rx < 10; rx++) {
553  sx = rx * font_repeat + x * font_width + face->glyph->bitmap_left;
554  for (by = 0; by < face->glyph->bitmap.rows; by++) {
555  dy = by + sy;
556  if (dy < 0)
557  continue;
558  if (dy >= font_height)
559  break;
560 
561  for (bx = 0; bx < face->glyph->bitmap.width; bx++) {
562  dx = bx + sx;
563  if (dx < 0)
564  continue;
565  if (dx >= 1920)
566  break;
567  data[dy*linesize+4*dx+3] = face->glyph->bitmap.buffer[by*face->glyph->bitmap.width+bx];
568  }
569  }
570  }
571  }
572 
573  FT_Done_Face(face);
574  FT_Done_FreeType(lib);
575  return 0;
576 
577 fail:
578  av_log(s->ctx, AV_LOG_WARNING, "error while loading freetype font.\n");
579  FT_Done_Face(face);
580  FT_Done_FreeType(lib);
581  return AVERROR(EINVAL);
582 #else
583  if (fontfile)
584  av_log(s->ctx, AV_LOG_WARNING, "freetype is not available, ignoring fontfile option.\n");
585  return AVERROR(EINVAL);
586 #endif
587 }
588 
589 static int render_fontconfig(ShowCQTContext *s, AVFrame *tmp, char* font)
590 {
591 #if CONFIG_LIBFONTCONFIG
592  FcConfig *fontconfig;
593  FcPattern *pat, *best;
594  FcResult result = FcResultMatch;
595  char *filename;
596  int i, ret;
597 
598  if (!font)
599  return AVERROR(EINVAL);
600 
601  for (i = 0; font[i]; i++) {
602  if (font[i] == '|')
603  font[i] = ':';
604  }
605 
606  if (!(fontconfig = FcInitLoadConfigAndFonts())) {
607  av_log(s->ctx, AV_LOG_ERROR, "impossible to init fontconfig.\n");
608  return AVERROR_UNKNOWN;
609  }
610 
611  if (!(pat = FcNameParse((uint8_t *)font))) {
612  av_log(s->ctx, AV_LOG_ERROR, "could not parse fontconfig pat.\n");
613  FcConfigDestroy(fontconfig);
614  return AVERROR(EINVAL);
615  }
616 
617  FcDefaultSubstitute(pat);
618 
619  if (!FcConfigSubstitute(fontconfig, pat, FcMatchPattern)) {
620  av_log(s->ctx, AV_LOG_ERROR, "could not substitute fontconfig options.\n");
621  FcPatternDestroy(pat);
622  FcConfigDestroy(fontconfig);
623  return AVERROR(ENOMEM);
624  }
625 
626  best = FcFontMatch(fontconfig, pat, &result);
627  FcPatternDestroy(pat);
628 
629  ret = AVERROR(EINVAL);
630  if (!best || result != FcResultMatch) {
631  av_log(s->ctx, AV_LOG_ERROR, "cannot find a valid font for %s.\n", font);
632  goto fail;
633  }
634 
635  if (FcPatternGetString(best, FC_FILE, 0, (FcChar8 **)&filename) != FcResultMatch) {
636  av_log(s->ctx, AV_LOG_ERROR, "no file path for %s\n", font);
637  goto fail;
638  }
639 
640  ret = render_freetype(s, tmp, filename);
641 
642 fail:
643  FcPatternDestroy(best);
644  FcConfigDestroy(fontconfig);
645  return ret;
646 #else
647  if (font)
648  av_log(s->ctx, AV_LOG_WARNING, "fontconfig is not available, ignoring font option.\n");
649  return AVERROR(EINVAL);
650 #endif
651 }
652 
654 {
655  const char *str = "EF G A BC D ";
656  const uint8_t *vga16_font = avpriv_vga16_font_get();
657  int x, u, v, mask;
658  uint8_t *data = tmp->data[0];
659  int linesize = tmp->linesize[0];
660  int width = 1920/2, height = 16;
661 
662  for (x = 0; x < width; x += width/10) {
663  uint8_t *startptr = data + 4 * x;
664  for (u = 0; u < 12; u++) {
665  for (v = 0; v < height; v++) {
666  uint8_t *p = startptr + v * linesize + height/2 * 4 * u;
667  for (mask = 0x80; mask; mask >>= 1, p += 4) {
668  if (mask & vga16_font[str[u] * 16 + v])
669  p[3] = 255;
670  else
671  p[3] = 0;
672  }
673  }
674  }
675  }
676 
677  return 0;
678 }
679 
681 {
682  AVFrame *tmp = NULL;
683  int ret = AVERROR(ENOMEM);
684  int width = 1920, height = 32;
685  int default_font = 0;
686 
688  goto fail;
689 
690  if (!(s->axis_frame = av_frame_alloc()))
691  goto fail;
692 
693  if (render_freetype(s, tmp, s->fontfile) < 0 &&
694  render_fontconfig(s, tmp, s->font) < 0 &&
695  (default_font = 1, ret = render_default_font(tmp)) < 0)
696  goto fail;
697 
698  if (default_font)
699  width /= 2, height /= 2;
700 
701  if ((ret = init_axis_color(s, tmp, default_font)) < 0)
702  goto fail;
703 
704  if ((ret = ff_scale_image(s->axis_frame->data, s->axis_frame->linesize, s->width, s->axis_h,
705  convert_axis_pixel_format(s->format), tmp->data, tmp->linesize,
706  width, height, AV_PIX_FMT_RGBA, s->ctx)) < 0)
707  goto fail;
708 
709  av_frame_free(&tmp);
710  s->axis_frame->width = s->width;
711  s->axis_frame->height = s->axis_h;
712  s->axis_frame->format = convert_axis_pixel_format(s->format);
713  return 0;
714 
715 fail:
716  av_frame_free(&tmp);
717  av_frame_free(&s->axis_frame);
718  return ret;
719 }
720 
721 static float calculate_gamma(float v, float g)
722 {
723  if (g == 1.0f)
724  return v;
725  if (g == 2.0f)
726  return sqrtf(v);
727  if (g == 3.0f)
728  return cbrtf(v);
729  if (g == 4.0f)
730  return sqrtf(sqrtf(v));
731  return expf(logf(v) / g);
732 }
733 
734 static void rgb_from_cqt(ColorFloat *c, const AVComplexFloat *v, float g, int len, float cscheme[6])
735 {
736  int x;
737  for (x = 0; x < len; x++) {
738  c[x].rgb.r = 255.0f * calculate_gamma(FFMIN(1.0f, cscheme[0] * v[x].re + cscheme[3] * v[x].im), g);
739  c[x].rgb.g = 255.0f * calculate_gamma(FFMIN(1.0f, cscheme[1] * v[x].re + cscheme[4] * v[x].im), g);
740  c[x].rgb.b = 255.0f * calculate_gamma(FFMIN(1.0f, cscheme[2] * v[x].re + cscheme[5] * v[x].im), g);
741  }
742 }
743 
744 static void yuv_from_cqt(ColorFloat *c, const AVComplexFloat *v, float gamma, int len, float cm[3][3], float cscheme[6])
745 {
746  int x;
747  for (x = 0; x < len; x++) {
748  float r, g, b;
749  r = calculate_gamma(FFMIN(1.0f, cscheme[0] * v[x].re + cscheme[3] * v[x].im), gamma);
750  g = calculate_gamma(FFMIN(1.0f, cscheme[1] * v[x].re + cscheme[4] * v[x].im), gamma);
751  b = calculate_gamma(FFMIN(1.0f, cscheme[2] * v[x].re + cscheme[5] * v[x].im), gamma);
752  c[x].yuv.y = cm[0][0] * r + cm[0][1] * g + cm[0][2] * b;
753  c[x].yuv.u = cm[1][0] * r + cm[1][1] * g + cm[1][2] * b;
754  c[x].yuv.v = cm[2][0] * r + cm[2][1] * g + cm[2][2] * b;
755  }
756 }
757 
758 static void draw_bar_rgb(AVFrame *out, const float *h, const float *rcp_h,
759  const ColorFloat *c, int bar_h, float bar_t)
760 {
761  int x, y, w = out->width;
762  float mul, ht, rcp_bar_h = 1.0f / bar_h, rcp_bar_t = 1.0f / bar_t;
763  uint8_t *v = out->data[0], *lp;
764  int ls = out->linesize[0];
765 
766  for (y = 0; y < bar_h; y++) {
767  ht = (bar_h - y) * rcp_bar_h;
768  lp = v + y * ls;
769  for (x = 0; x < w; x++) {
770  if (h[x] <= ht) {
771  *lp++ = 0;
772  *lp++ = 0;
773  *lp++ = 0;
774  } else {
775  mul = (h[x] - ht) * rcp_h[x];
776  mul = (mul < bar_t) ? (mul * rcp_bar_t) : 1.0f;
777  *lp++ = lrintf(mul * c[x].rgb.r);
778  *lp++ = lrintf(mul * c[x].rgb.g);
779  *lp++ = lrintf(mul * c[x].rgb.b);
780  }
781  }
782  }
783 }
784 
785 #define DRAW_BAR_WITH_CHROMA(x) \
786 do { \
787  if (h[x] <= ht) { \
788  *lpy++ = 16; \
789  *lpu++ = 128; \
790  *lpv++ = 128; \
791  } else { \
792  mul = (h[x] - ht) * rcp_h[x]; \
793  mul = (mul < bar_t) ? (mul * rcp_bar_t) : 1.0f; \
794  *lpy++ = lrintf(mul * c[x].yuv.y + 16.0f); \
795  *lpu++ = lrintf(mul * c[x].yuv.u + 128.0f); \
796  *lpv++ = lrintf(mul * c[x].yuv.v + 128.0f); \
797  } \
798 } while (0)
799 
800 #define DRAW_BAR_WITHOUT_CHROMA(x) \
801 do { \
802  if (h[x] <= ht) { \
803  *lpy++ = 16; \
804  } else { \
805  mul = (h[x] - ht) * rcp_h[x]; \
806  mul = (mul < bar_t) ? (mul * rcp_bar_t) : 1.0f; \
807  *lpy++ = lrintf(mul * c[x].yuv.y + 16.0f); \
808  } \
809 } while (0)
810 
811 static void draw_bar_yuv(AVFrame *out, const float *h, const float *rcp_h,
812  const ColorFloat *c, int bar_h, float bar_t)
813 {
814  int x, y, yh, w = out->width;
815  float mul, ht, rcp_bar_h = 1.0f / bar_h, rcp_bar_t = 1.0f / bar_t;
816  uint8_t *vy = out->data[0], *vu = out->data[1], *vv = out->data[2];
817  uint8_t *lpy, *lpu, *lpv;
818  int lsy = out->linesize[0], lsu = out->linesize[1], lsv = out->linesize[2];
819  int fmt = out->format;
820 
821  for (y = 0; y < bar_h; y += 2) {
822  yh = (fmt == AV_PIX_FMT_YUV420P) ? y / 2 : y;
823  ht = (bar_h - y) * rcp_bar_h;
824  lpy = vy + y * lsy;
825  lpu = vu + yh * lsu;
826  lpv = vv + yh * lsv;
827  if (fmt == AV_PIX_FMT_YUV444P) {
828  for (x = 0; x < w; x += 2) {
831  }
832  } else {
833  for (x = 0; x < w; x += 2) {
836  }
837  }
838 
839  ht = (bar_h - (y+1)) * rcp_bar_h;
840  lpy = vy + (y+1) * lsy;
841  lpu = vu + (y+1) * lsu;
842  lpv = vv + (y+1) * lsv;
843  if (fmt == AV_PIX_FMT_YUV444P) {
844  for (x = 0; x < w; x += 2) {
847  }
848  } else if (fmt == AV_PIX_FMT_YUV422P) {
849  for (x = 0; x < w; x += 2) {
852  }
853  } else {
854  for (x = 0; x < w; x += 2) {
857  }
858  }
859  }
860 }
861 
862 static void draw_axis_rgb(AVFrame *out, AVFrame *axis, const ColorFloat *c, int off)
863 {
864  int x, y, w = axis->width, h = axis->height;
865  float a, rcp_255 = 1.0f / 255.0f;
866  uint8_t *lp, *lpa;
867 
868  for (y = 0; y < h; y++) {
869  lp = out->data[0] + (off + y) * out->linesize[0];
870  lpa = axis->data[0] + y * axis->linesize[0];
871  for (x = 0; x < w; x++) {
872  if (!lpa[3]) {
873  *lp++ = lrintf(c[x].rgb.r);
874  *lp++ = lrintf(c[x].rgb.g);
875  *lp++ = lrintf(c[x].rgb.b);
876  } else if (lpa[3] == 255) {
877  *lp++ = lpa[0];
878  *lp++ = lpa[1];
879  *lp++ = lpa[2];
880  } else {
881  a = rcp_255 * lpa[3];
882  *lp++ = lrintf(a * lpa[0] + (1.0f - a) * c[x].rgb.r);
883  *lp++ = lrintf(a * lpa[1] + (1.0f - a) * c[x].rgb.g);
884  *lp++ = lrintf(a * lpa[2] + (1.0f - a) * c[x].rgb.b);
885  }
886  lpa += 4;
887  }
888  }
889 }
890 
891 #define BLEND_WITH_CHROMA(c) \
892 do { \
893  if (!*lpaa) { \
894  *lpy = lrintf(c.yuv.y + 16.0f); \
895  *lpu = lrintf(c.yuv.u + 128.0f); \
896  *lpv = lrintf(c.yuv.v + 128.0f); \
897  } else if (255 == *lpaa) { \
898  *lpy = *lpay; \
899  *lpu = *lpau; \
900  *lpv = *lpav; \
901  } else { \
902  float a = (1.0f/255.0f) * (*lpaa); \
903  *lpy = lrintf(a * (*lpay) + (1.0f - a) * (c.yuv.y + 16.0f)); \
904  *lpu = lrintf(a * (*lpau) + (1.0f - a) * (c.yuv.u + 128.0f)); \
905  *lpv = lrintf(a * (*lpav) + (1.0f - a) * (c.yuv.v + 128.0f)); \
906  } \
907  lpy++; lpu++; lpv++; \
908  lpay++; lpau++; lpav++; lpaa++; \
909 } while (0)
910 
911 #define BLEND_WITHOUT_CHROMA(c, alpha_inc) \
912 do { \
913  if (!*lpaa) { \
914  *lpy = lrintf(c.yuv.y + 16.0f); \
915  } else if (255 == *lpaa) { \
916  *lpy = *lpay; \
917  } else { \
918  float a = (1.0f/255.0f) * (*lpaa); \
919  *lpy = lrintf(a * (*lpay) + (1.0f - a) * (c.yuv.y + 16.0f)); \
920  } \
921  lpy++; \
922  lpay++; lpaa += alpha_inc; \
923 } while (0)
924 
925 #define BLEND_CHROMA2(c) \
926 do { \
927  if (!lpaa[0] && !lpaa[1]) { \
928  *lpu = lrintf(c.yuv.u + 128.0f); \
929  *lpv = lrintf(c.yuv.v + 128.0f); \
930  } else if (255 == lpaa[0] && 255 == lpaa[1]) { \
931  *lpu = *lpau; *lpv = *lpav; \
932  } else { \
933  float a0 = (0.5f/255.0f) * lpaa[0]; \
934  float a1 = (0.5f/255.0f) * lpaa[1]; \
935  float b = 1.0f - a0 - a1; \
936  *lpu = lrintf(a0 * lpau[0] + a1 * lpau[1] + b * (c.yuv.u + 128.0f)); \
937  *lpv = lrintf(a0 * lpav[0] + a1 * lpav[1] + b * (c.yuv.v + 128.0f)); \
938  } \
939  lpau += 2; lpav += 2; lpaa++; lpu++; lpv++; \
940 } while (0)
941 
942 #define BLEND_CHROMA2x2(c) \
943 do { \
944  if (!lpaa[0] && !lpaa[1] && !lpaa[lsaa] && !lpaa[lsaa+1]) { \
945  *lpu = lrintf(c.yuv.u + 128.0f); \
946  *lpv = lrintf(c.yuv.v + 128.0f); \
947  } else if (255 == lpaa[0] && 255 == lpaa[1] && \
948  255 == lpaa[lsaa] && 255 == lpaa[lsaa+1]) { \
949  *lpu = *lpau; *lpv = *lpav; \
950  } else { \
951  float a0 = (0.25f/255.0f) * lpaa[0]; \
952  float a1 = (0.25f/255.0f) * lpaa[1]; \
953  float a2 = (0.25f/255.0f) * lpaa[lsaa]; \
954  float a3 = (0.25f/255.0f) * lpaa[lsaa+1]; \
955  float b = 1.0f - a0 - a1 - a2 - a3; \
956  *lpu = lrintf(a0 * lpau[0] + a1 * lpau[1] + a2 * lpau[lsau] + a3 * lpau[lsau+1] \
957  + b * (c.yuv.u + 128.0f)); \
958  *lpv = lrintf(a0 * lpav[0] + a1 * lpav[1] + a2 * lpav[lsav] + a3 * lpav[lsav+1] \
959  + b * (c.yuv.v + 128.0f)); \
960  } \
961  lpau += 2; lpav += 2; lpaa++; lpu++; lpv++; \
962 } while (0)
963 
964 static void draw_axis_yuv(AVFrame *out, AVFrame *axis, const ColorFloat *c, int off)
965 {
966  int fmt = out->format, x, y, yh, w = axis->width, h = axis->height;
967  int offh = (fmt == AV_PIX_FMT_YUV420P) ? off / 2 : off;
968  uint8_t *vy = out->data[0], *vu = out->data[1], *vv = out->data[2];
969  uint8_t *vay = axis->data[0], *vau = axis->data[1], *vav = axis->data[2], *vaa = axis->data[3];
970  int lsy = out->linesize[0], lsu = out->linesize[1], lsv = out->linesize[2];
971  int lsay = axis->linesize[0], lsau = axis->linesize[1], lsav = axis->linesize[2], lsaa = axis->linesize[3];
972  uint8_t *lpy, *lpu, *lpv, *lpay, *lpau, *lpav, *lpaa;
973 
974  for (y = 0; y < h; y += 2) {
975  yh = (fmt == AV_PIX_FMT_YUV420P) ? y / 2 : y;
976  lpy = vy + (off + y) * lsy;
977  lpu = vu + (offh + yh) * lsu;
978  lpv = vv + (offh + yh) * lsv;
979  lpay = vay + y * lsay;
980  lpau = vau + y * lsau;
981  lpav = vav + y * lsav;
982  lpaa = vaa + y * lsaa;
983  if (fmt == AV_PIX_FMT_YUV444P) {
984  for (x = 0; x < w; x += 2) {
985  BLEND_WITH_CHROMA(c[x]);
986  BLEND_WITH_CHROMA(c[x+1]);
987  }
988  } else if (fmt == AV_PIX_FMT_YUV422P) {
989  for (x = 0; x < w; x += 2) {
990  BLEND_WITHOUT_CHROMA(c[x], 0);
991  BLEND_CHROMA2(c[x]);
992  BLEND_WITHOUT_CHROMA(c[x+1], 1);
993  }
994  } else {
995  for (x = 0; x < w; x += 2) {
996  BLEND_WITHOUT_CHROMA(c[x], 0);
997  BLEND_CHROMA2x2(c[x]);
998  BLEND_WITHOUT_CHROMA(c[x+1], 1);
999  }
1000  }
1001 
1002  lpy = vy + (off + y + 1) * lsy;
1003  lpu = vu + (off + y + 1) * lsu;
1004  lpv = vv + (off + y + 1) * lsv;
1005  lpay = vay + (y + 1) * lsay;
1006  lpau = vau + (y + 1) * lsau;
1007  lpav = vav + (y + 1) * lsav;
1008  lpaa = vaa + (y + 1) * lsaa;
1009  if (fmt == AV_PIX_FMT_YUV444P) {
1010  for (x = 0; x < w; x += 2) {
1011  BLEND_WITH_CHROMA(c[x]);
1012  BLEND_WITH_CHROMA(c[x+1]);
1013  }
1014  } else if (fmt == AV_PIX_FMT_YUV422P) {
1015  for (x = 0; x < w; x += 2) {
1016  BLEND_WITHOUT_CHROMA(c[x], 0);
1017  BLEND_CHROMA2(c[x]);
1018  BLEND_WITHOUT_CHROMA(c[x+1], 1);
1019  }
1020  } else {
1021  for (x = 0; x < w; x += 2) {
1022  BLEND_WITHOUT_CHROMA(c[x], 1);
1023  BLEND_WITHOUT_CHROMA(c[x+1], 1);
1024  }
1025  }
1026  }
1027 }
1028 
1029 static void draw_sono(AVFrame *out, AVFrame *sono, int off, int idx)
1030 {
1031  int fmt = out->format, h = sono->height;
1032  int nb_planes = (fmt == AV_PIX_FMT_RGB24) ? 1 : 3;
1033  int offh = (fmt == AV_PIX_FMT_YUV420P) ? off / 2 : off;
1034  int inc = (fmt == AV_PIX_FMT_YUV420P) ? 2 : 1;
1035  ptrdiff_t ls;
1036  int i, y, yh;
1037 
1038  ls = FFABS(FFMIN(out->linesize[0], sono->linesize[0]));
1039  for (y = 0; y < h; y++) {
1040  memcpy(out->data[0] + (off + y) * out->linesize[0],
1041  sono->data[0] + (idx + y) % h * sono->linesize[0], ls);
1042  }
1043 
1044  for (i = 1; i < nb_planes; i++) {
1045  ls = FFABS(FFMIN(out->linesize[i], sono->linesize[i]));
1046  for (y = 0; y < h; y += inc) {
1047  yh = (fmt == AV_PIX_FMT_YUV420P) ? y / 2 : y;
1048  memcpy(out->data[i] + (offh + yh) * out->linesize[i],
1049  sono->data[i] + (idx + y) % h * sono->linesize[i], ls);
1050  }
1051  }
1052 }
1053 
1054 static void update_sono_rgb(AVFrame *sono, const ColorFloat *c, int idx)
1055 {
1056  int x, w = sono->width;
1057  uint8_t *lp = sono->data[0] + idx * sono->linesize[0];
1058 
1059  for (x = 0; x < w; x++) {
1060  *lp++ = lrintf(c[x].rgb.r);
1061  *lp++ = lrintf(c[x].rgb.g);
1062  *lp++ = lrintf(c[x].rgb.b);
1063  }
1064 }
1065 
1066 static void update_sono_yuv(AVFrame *sono, const ColorFloat *c, int idx)
1067 {
1068  int x, fmt = sono->format, w = sono->width;
1069  uint8_t *lpy = sono->data[0] + idx * sono->linesize[0];
1070  uint8_t *lpu = sono->data[1] + idx * sono->linesize[1];
1071  uint8_t *lpv = sono->data[2] + idx * sono->linesize[2];
1072 
1073  for (x = 0; x < w; x += 2) {
1074  *lpy++ = lrintf(c[x].yuv.y + 16.0f);
1075  *lpu++ = lrintf(c[x].yuv.u + 128.0f);
1076  *lpv++ = lrintf(c[x].yuv.v + 128.0f);
1077  *lpy++ = lrintf(c[x+1].yuv.y + 16.0f);
1078  if (fmt == AV_PIX_FMT_YUV444P) {
1079  *lpu++ = lrintf(c[x+1].yuv.u + 128.0f);
1080  *lpv++ = lrintf(c[x+1].yuv.v + 128.0f);
1081  }
1082  }
1083 }
1084 
1086 {
1087  int x, i;
1088  if (!s->sono_count) {
1089  for (x = 0; x < s->cqt_len; x++) {
1090  s->h_buf[x] = s->bar_v_buf[x] * 0.5f * (s->cqt_result[x].re + s->cqt_result[x].im);
1091  }
1092  if (s->fcount > 1) {
1093  float rcp_fcount = 1.0f / s->fcount;
1094  for (x = 0; x < s->width; x++) {
1095  float h = 0.0f;
1096  for (i = 0; i < s->fcount; i++)
1097  h += s->h_buf[s->fcount * x + i];
1098  s->h_buf[x] = rcp_fcount * h;
1099  }
1100  }
1101  for (x = 0; x < s->width; x++) {
1102  s->h_buf[x] = calculate_gamma(s->h_buf[x], s->bar_g);
1103  s->rcp_h_buf[x] = 1.0f / (s->h_buf[x] + 0.0001f);
1104  }
1105  }
1106 
1107  for (x = 0; x < s->cqt_len; x++) {
1108  s->cqt_result[x].re *= s->sono_v_buf[x];
1109  s->cqt_result[x].im *= s->sono_v_buf[x];
1110  }
1111 
1112  if (s->fcount > 1) {
1113  float rcp_fcount = 1.0f / s->fcount;
1114  for (x = 0; x < s->width; x++) {
1115  AVComplexFloat result = {0.0f, 0.0f};
1116  for (i = 0; i < s->fcount; i++) {
1117  result.re += s->cqt_result[s->fcount * x + i].re;
1118  result.im += s->cqt_result[s->fcount * x + i].im;
1119  }
1120  s->cqt_result[x].re = rcp_fcount * result.re;
1121  s->cqt_result[x].im = rcp_fcount * result.im;
1122  }
1123  }
1124 
1125  if (s->format == AV_PIX_FMT_RGB24)
1126  rgb_from_cqt(s->c_buf, s->cqt_result, s->sono_g, s->width, s->cscheme_v);
1127  else
1128  yuv_from_cqt(s->c_buf, s->cqt_result, s->sono_g, s->width, s->cmatrix, s->cscheme_v);
1129 }
1130 
1131 static int plot_cqt(AVFilterContext *ctx, AVFrame **frameout)
1132 {
1133  AVFilterLink *outlink = ctx->outputs[0];
1134  ShowCQTContext *s = ctx->priv;
1135  int64_t last_time, cur_time;
1136 
1137 #define UPDATE_TIME(t) \
1138  cur_time = av_gettime_relative(); \
1139  t += cur_time - last_time; \
1140  last_time = cur_time
1141 
1142  last_time = av_gettime_relative();
1143 
1144  memcpy(s->fft_input, s->fft_data, s->fft_len * sizeof(*s->fft_data));
1145  if (s->attack_data) {
1146  int k;
1147  for (k = 0; k < s->remaining_fill_max; k++) {
1148  s->fft_input[s->fft_len/2+k].re *= s->attack_data[k];
1149  s->fft_input[s->fft_len/2+k].im *= s->attack_data[k];
1150  }
1151  }
1152 
1153  s->tx_fn(s->fft_ctx, s->fft_result, s->fft_input, sizeof(AVComplexFloat));
1154  UPDATE_TIME(s->fft_time);
1155 
1156  s->cqt_calc(s->cqt_result, s->fft_result, s->coeffs, s->cqt_len, s->fft_len);
1157  UPDATE_TIME(s->cqt_time);
1158 
1159  process_cqt(s);
1160  UPDATE_TIME(s->process_cqt_time);
1161 
1162  if (s->sono_h) {
1163  s->update_sono(s->sono_frame, s->c_buf, s->sono_idx);
1164  UPDATE_TIME(s->update_sono_time);
1165  }
1166 
1167  if (!s->sono_count) {
1168  AVFrame *out = *frameout = ff_get_video_buffer(outlink, outlink->w, outlink->h);
1169  if (!out)
1170  return AVERROR(ENOMEM);
1171  out->sample_aspect_ratio = av_make_q(1, 1);
1172  out->color_range = AVCOL_RANGE_MPEG;
1173  out->colorspace = s->csp;
1174  UPDATE_TIME(s->alloc_time);
1175 
1176  if (s->bar_h) {
1177  s->draw_bar(out, s->h_buf, s->rcp_h_buf, s->c_buf, s->bar_h, s->bar_t);
1178  UPDATE_TIME(s->bar_time);
1179  }
1180 
1181  if (s->axis_h) {
1182  s->draw_axis(out, s->axis_frame, s->c_buf, s->bar_h);
1183  UPDATE_TIME(s->axis_time);
1184  }
1185 
1186  if (s->sono_h) {
1187  s->draw_sono(out, s->sono_frame, s->bar_h + s->axis_h, s->sono_idx);
1188  UPDATE_TIME(s->sono_time);
1189  }
1190  }
1191  s->sono_count = (s->sono_count + 1) % s->count;
1192  if (s->sono_h)
1193  s->sono_idx = (s->sono_idx + s->sono_h - 1) % s->sono_h;
1194  return 0;
1195 }
1196 
1198 {
1199  double kr, kg, kb;
1200 
1201  /* from vf_colorspace.c */
1202  switch (s->csp) {
1203  default:
1204  av_log(s->ctx, AV_LOG_WARNING, "unsupported colorspace, setting it to unspecified.\n");
1205  s->csp = AVCOL_SPC_UNSPECIFIED;
1206  case AVCOL_SPC_UNSPECIFIED:
1207  case AVCOL_SPC_BT470BG:
1208  case AVCOL_SPC_SMPTE170M:
1209  kr = 0.299; kb = 0.114; break;
1210  case AVCOL_SPC_BT709:
1211  kr = 0.2126; kb = 0.0722; break;
1212  case AVCOL_SPC_FCC:
1213  kr = 0.30; kb = 0.11; break;
1214  case AVCOL_SPC_SMPTE240M:
1215  kr = 0.212; kb = 0.087; break;
1216  case AVCOL_SPC_BT2020_NCL:
1217  kr = 0.2627; kb = 0.0593; break;
1218  }
1219 
1220  kg = 1.0 - kr - kb;
1221  s->cmatrix[0][0] = 219.0 * kr;
1222  s->cmatrix[0][1] = 219.0 * kg;
1223  s->cmatrix[0][2] = 219.0 * kb;
1224  s->cmatrix[1][0] = -112.0 * kr / (1.0 - kb);
1225  s->cmatrix[1][1] = -112.0 * kg / (1.0 - kb);
1226  s->cmatrix[1][2] = 112.0;
1227  s->cmatrix[2][0] = 112.0;
1228  s->cmatrix[2][1] = -112.0 * kg / (1.0 - kr);
1229  s->cmatrix[2][2] = -112.0 * kb / (1.0 - kr);
1230 }
1231 
1233 {
1234  char tail[2];
1235  int k;
1236 
1237  if (sscanf(s->cscheme, " %f | %f | %f | %f | %f | %f %1s", &s->cscheme_v[0],
1238  &s->cscheme_v[1], &s->cscheme_v[2], &s->cscheme_v[3], &s->cscheme_v[4],
1239  &s->cscheme_v[5], tail) != 6)
1240  goto fail;
1241 
1242  for (k = 0; k < 6; k++)
1243  if (isnan(s->cscheme_v[k]) || s->cscheme_v[k] < 0.0f || s->cscheme_v[k] > 1.0f)
1244  goto fail;
1245 
1246  return 0;
1247 
1248 fail:
1249  av_log(s->ctx, AV_LOG_ERROR, "invalid cscheme.\n");
1250  return AVERROR(EINVAL);
1251 }
1252 
1253 /* main filter control */
1255 {
1256  ShowCQTContext *s = ctx->priv;
1257  s->ctx = ctx;
1258 
1259  if (!s->fullhd) {
1260  av_log(ctx, AV_LOG_WARNING, "fullhd option is deprecated, use size/s option instead.\n");
1261  if (s->width != 1920 || s->height != 1080) {
1262  av_log(ctx, AV_LOG_ERROR, "fullhd set to 0 but with custom dimension.\n");
1263  return AVERROR(EINVAL);
1264  }
1265  s->width /= 2;
1266  s->height /= 2;
1267  s->fullhd = 1;
1268  }
1269 
1270  if (s->axis_h < 0) {
1271  s->axis_h = s->width / 60;
1272  if (s->axis_h & 1)
1273  s->axis_h++;
1274  if (s->bar_h >= 0 && s->sono_h >= 0)
1275  s->axis_h = s->height - s->bar_h - s->sono_h;
1276  if (s->bar_h >= 0 && s->sono_h < 0)
1277  s->axis_h = FFMIN(s->axis_h, s->height - s->bar_h);
1278  if (s->bar_h < 0 && s->sono_h >= 0)
1279  s->axis_h = FFMIN(s->axis_h, s->height - s->sono_h);
1280  }
1281 
1282  if (s->bar_h < 0) {
1283  s->bar_h = (s->height - s->axis_h) / 2;
1284  if (s->bar_h & 1)
1285  s->bar_h--;
1286  if (s->sono_h >= 0)
1287  s->bar_h = s->height - s->sono_h - s->axis_h;
1288  }
1289 
1290  if (s->sono_h < 0)
1291  s->sono_h = s->height - s->axis_h - s->bar_h;
1292 
1293  if ((s->width & 1) || (s->height & 1) || (s->bar_h & 1) || (s->axis_h & 1) || (s->sono_h & 1) ||
1294  (s->bar_h < 0) || (s->axis_h < 0) || (s->sono_h < 0) || (s->bar_h > s->height) ||
1295  (s->axis_h > s->height) || (s->sono_h > s->height) || (s->bar_h + s->axis_h + s->sono_h != s->height)) {
1296  av_log(ctx, AV_LOG_ERROR, "invalid dimension.\n");
1297  return AVERROR(EINVAL);
1298  }
1299 
1300  if (!s->fcount) {
1301  do {
1302  s->fcount++;
1303  } while(s->fcount * s->width < 1920 && s->fcount < 10);
1304  }
1305 
1307 
1308  return init_cscheme(s);
1309 }
1310 
1312 {
1313  common_uninit(ctx->priv);
1314 }
1315 
1317  AVFilterFormatsConfig **cfg_in,
1318  AVFilterFormatsConfig **cfg_out)
1319 {
1322  static const enum AVPixelFormat pix_fmts[] = {
1325  };
1328  int ret;
1329 
1330  /* set input audio formats */
1332  if ((ret = ff_formats_ref(formats, &cfg_in[0]->formats)) < 0)
1333  return ret;
1334 
1336  if (ret < 0)
1337  return ret;
1338 
1339  /* set output video format */
1341  if ((ret = ff_formats_ref(formats, &cfg_out[0]->formats)) < 0)
1342  return ret;
1343 
1344  return 0;
1345 }
1346 
1347 static int config_output(AVFilterLink *outlink)
1348 {
1349  FilterLink *l = ff_filter_link(outlink);
1350  AVFilterContext *ctx = outlink->src;
1351  AVFilterLink *inlink = ctx->inputs[0];
1352  ShowCQTContext *s = ctx->priv;
1353  float scale = 1.f;
1354  int ret;
1355 
1356  common_uninit(s);
1357 
1358  outlink->w = s->width;
1359  outlink->h = s->height;
1360  s->format = outlink->format;
1361  outlink->sample_aspect_ratio = av_make_q(1, 1);
1362  l->frame_rate = s->rate;
1363  outlink->time_base = av_inv_q(s->rate);
1364  av_log(ctx, AV_LOG_VERBOSE, "video: %dx%d %s %d/%d fps, bar_h = %d, axis_h = %d, sono_h = %d.\n",
1365  s->width, s->height, av_get_pix_fmt_name(s->format), s->rate.num, s->rate.den,
1366  s->bar_h, s->axis_h, s->sono_h);
1367 
1368  s->cqt_len = s->width * s->fcount;
1369  if (!(s->freq = create_freq_table(s->basefreq, s->endfreq, s->cqt_len)))
1370  return AVERROR(ENOMEM);
1371 
1372  if ((ret = init_volume(s)) < 0)
1373  return ret;
1374 
1375  s->fft_bits = FFMAX(ceil(log2(inlink->sample_rate * s->timeclamp)), 4);
1376  s->fft_len = 1 << s->fft_bits;
1377  av_log(ctx, AV_LOG_VERBOSE, "fft_len = %d, cqt_len = %d.\n", s->fft_len, s->cqt_len);
1378 
1379  ret = av_tx_init(&s->fft_ctx, &s->tx_fn, AV_TX_FLOAT_FFT, 0, s->fft_len, &scale, 0);
1380  s->fft_data = av_calloc(s->fft_len, sizeof(*s->fft_data));
1381  s->fft_input = av_calloc(FFALIGN(s->fft_len + 64, 256), sizeof(*s->fft_input));
1382  s->fft_result = av_calloc(FFALIGN(s->fft_len + 64, 256), sizeof(*s->fft_result));
1383  s->cqt_result = av_malloc_array(s->cqt_len, sizeof(*s->cqt_result));
1384  if (!s->fft_ctx || !s->fft_data || !s->fft_result || !s->cqt_result)
1385  return AVERROR(ENOMEM);
1386 
1387  s->remaining_fill_max = s->fft_len / 2;
1388  if (s->attack > 0.0) {
1389  int k;
1390 
1391  s->remaining_fill_max = FFMIN(s->remaining_fill_max, ceil(inlink->sample_rate * s->attack));
1392  s->attack_data = av_malloc_array(s->remaining_fill_max, sizeof(*s->attack_data));
1393  if (!s->attack_data)
1394  return AVERROR(ENOMEM);
1395 
1396  for (k = 0; k < s->remaining_fill_max; k++) {
1397  double y = M_PI * k / (inlink->sample_rate * s->attack);
1398  s->attack_data[k] = 0.355768 + 0.487396 * cos(y) + 0.144232 * cos(2*y) + 0.012604 * cos(3*y);
1399  }
1400  }
1401 
1402  s->cqt_align = 1;
1403  s->cqt_calc = cqt_calc;
1404  s->permute_coeffs = NULL;
1405  s->draw_sono = draw_sono;
1406  if (s->format == AV_PIX_FMT_RGB24) {
1407  s->draw_bar = draw_bar_rgb;
1408  s->draw_axis = draw_axis_rgb;
1409  s->update_sono = update_sono_rgb;
1410  } else {
1411  s->draw_bar = draw_bar_yuv;
1412  s->draw_axis = draw_axis_yuv;
1413  s->update_sono = update_sono_yuv;
1414  }
1415 
1416 #if ARCH_X86 && HAVE_X86ASM
1418 #endif
1419 
1420  if ((ret = init_cqt(s)) < 0)
1421  return ret;
1422 
1423  if (s->axis_h) {
1424  if (!s->axis) {
1425  if ((ret = init_axis_empty(s)) < 0)
1426  return ret;
1427  } else if (s->axisfile) {
1428  if (init_axis_from_file(s) < 0) {
1429  av_log(ctx, AV_LOG_WARNING, "loading axis image failed, fallback to font rendering.\n");
1430  if (init_axis_from_font(s) < 0) {
1431  av_log(ctx, AV_LOG_WARNING, "loading axis font failed, disable text drawing.\n");
1432  if ((ret = init_axis_empty(s)) < 0)
1433  return ret;
1434  }
1435  }
1436  } else {
1437  if (init_axis_from_font(s) < 0) {
1438  av_log(ctx, AV_LOG_WARNING, "loading axis font failed, disable text drawing.\n");
1439  if ((ret = init_axis_empty(s)) < 0)
1440  return ret;
1441  }
1442  }
1443  }
1444 
1445  if (s->sono_h) {
1446  s->sono_frame = alloc_frame_empty((outlink->format == AV_PIX_FMT_YUV420P) ?
1447  AV_PIX_FMT_YUV422P : outlink->format, s->width, s->sono_h);
1448  if (!s->sono_frame)
1449  return AVERROR(ENOMEM);
1450  }
1451 
1452  s->h_buf = av_malloc_array(s->cqt_len, sizeof (*s->h_buf));
1453  s->rcp_h_buf = av_malloc_array(s->width, sizeof(*s->rcp_h_buf));
1454  s->c_buf = av_malloc_array(s->width, sizeof(*s->c_buf));
1455  if (!s->h_buf || !s->rcp_h_buf || !s->c_buf)
1456  return AVERROR(ENOMEM);
1457 
1458  s->sono_count = 0;
1459  s->next_pts = 0;
1460  s->sono_idx = 0;
1461  s->remaining_fill = s->remaining_fill_max;
1462  s->remaining_frac = 0;
1463  s->step_frac = av_div_q(av_make_q(inlink->sample_rate, s->count) , s->rate);
1464  s->step = (int)(s->step_frac.num / s->step_frac.den);
1465  s->step_frac.num %= s->step_frac.den;
1466  if (s->step_frac.num) {
1467  av_log(ctx, AV_LOG_VERBOSE, "audio: %d Hz, step = %d + %d/%d.\n",
1468  inlink->sample_rate, s->step, s->step_frac.num, s->step_frac.den);
1469  } else {
1470  av_log(ctx, AV_LOG_VERBOSE, "audio: %d Hz, step = %d.\n",
1471  inlink->sample_rate, s->step);
1472  }
1473 
1474  return 0;
1475 }
1476 
1477 
1478 static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
1479 {
1480  AVFilterContext *ctx = inlink->dst;
1481  AVFilterLink *outlink = ctx->outputs[0];
1482  ShowCQTContext *s = ctx->priv;
1483  int remaining, step, ret, x, i, j, m, got_frame = 0;
1484  float *audio_data;
1485  AVFrame *out = NULL;
1486 
1487  if (!insamples) {
1488  while (s->remaining_fill < s->remaining_fill_max) {
1489  memset(&s->fft_data[s->fft_len/2 + s->remaining_fill_max - s->remaining_fill], 0, sizeof(*s->fft_data) * s->remaining_fill);
1490  ret = plot_cqt(ctx, &out);
1491  if (ret < 0)
1492  return ret;
1493 
1494  step = s->step + (s->step_frac.num + s->remaining_frac) / s->step_frac.den;
1495  s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den;
1496  for (x = 0; x < (s->fft_len/2 + s->remaining_fill_max - step); x++)
1497  s->fft_data[x] = s->fft_data[x+step];
1498  s->remaining_fill += step;
1499  s->next_pts++;
1500 
1501  if (out) {
1502  out->pts = s->next_pts;
1503  out->duration = 1;
1504  return ff_filter_frame(outlink, out);
1505  }
1506  }
1507  return 0;
1508  }
1509 
1510  remaining = insamples->nb_samples;
1511  audio_data = (float*) insamples->data[0];
1512 
1513  while (remaining) {
1514  i = insamples->nb_samples - remaining;
1515  j = s->fft_len/2 + s->remaining_fill_max - s->remaining_fill;
1516  if (remaining >= s->remaining_fill) {
1517  for (m = FFMAX(0, -j); m < s->remaining_fill; m++) {
1518  s->fft_data[j+m].re = audio_data[2*(i+m)];
1519  s->fft_data[j+m].im = audio_data[2*(i+m)+1];
1520  }
1521  ret = plot_cqt(ctx, &out);
1522  if (ret < 0) {
1523  av_frame_free(&insamples);
1524  return ret;
1525  }
1526  remaining -= s->remaining_fill;
1527  if (out) {
1528  int64_t pts = av_rescale_q(insamples->nb_samples - remaining - s->remaining_fill_max,
1529  av_make_q(1, inlink->sample_rate), inlink->time_base);
1530  out->pts = av_rescale_q(insamples->pts + pts, inlink->time_base, outlink->time_base);
1531  out->duration = 1;
1532  got_frame = 1;
1533  ret = ff_filter_frame(outlink, out);
1534  if (ret < 0) {
1535  av_frame_free(&insamples);
1536  return ret;
1537  }
1538  out = NULL;
1539  }
1540  step = s->step + (s->step_frac.num + s->remaining_frac) / s->step_frac.den;
1541  s->remaining_frac = (s->step_frac.num + s->remaining_frac) % s->step_frac.den;
1542  for (m = 0; m < s->fft_len/2 + s->remaining_fill_max - step; m++)
1543  s->fft_data[m] = s->fft_data[m+step];
1544  s->remaining_fill = step;
1545  } else {
1546  for (m = FFMAX(0, -j); m < remaining; m++) {
1547  s->fft_data[j+m].re = audio_data[2*(i+m)];
1548  s->fft_data[j+m].im = audio_data[2*(i+m)+1];
1549  }
1550  s->remaining_fill -= remaining;
1551  remaining = 0;
1552  }
1553  }
1554  if (!got_frame)
1555  ff_filter_set_ready(ctx, 100);
1556  av_frame_free(&insamples);
1557  return 0;
1558 }
1559 
1561 {
1562  AVFilterLink *inlink = ctx->inputs[0];
1563  AVFilterLink *outlink = ctx->outputs[0];
1564  ShowCQTContext *s = ctx->priv;
1565  int nb_samples, ret, status;
1566  int64_t pts;
1567  AVFrame *in;
1568 
1570 
1571  nb_samples = s->step + (s->step_frac.num + s->remaining_frac) / s->step_frac.den;
1572  ret = ff_inlink_consume_samples(inlink, nb_samples, nb_samples, &in);
1573  if (ret < 0)
1574  return ret;
1575  if (ret > 0)
1576  return filter_frame(inlink, in);
1577 
1579  if (status == AVERROR_EOF) {
1580  s->next_pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
1582  ff_outlink_set_status(outlink, AVERROR_EOF, s->next_pts);
1583  return ret;
1584  }
1585  }
1586 
1587  FF_FILTER_FORWARD_WANTED(outlink, inlink);
1588 
1589  return FFERROR_NOT_READY;
1590 }
1591 
1592 static const AVFilterPad showcqt_outputs[] = {
1593  {
1594  .name = "default",
1595  .type = AVMEDIA_TYPE_VIDEO,
1596  .config_props = config_output,
1597  },
1598 };
1599 
1601  .p.name = "showcqt",
1602  .p.description = NULL_IF_CONFIG_SMALL("Convert input audio to a CQT (Constant/Clamped Q Transform) spectrum video output."),
1603  .p.priv_class = &showcqt_class,
1604  .init = init,
1605  .activate = activate,
1606  .uninit = uninit,
1607  .priv_size = sizeof(ShowCQTContext),
1611 };
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:32
formats
formats
Definition: signature.h:47
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:118
rgb::b
uint8_t b
Definition: rpzaenc.c:63
av_gettime_relative
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
Definition: time.c:56
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:216
AV_CHANNEL_LAYOUT_STEREO_DOWNMIX
#define AV_CHANNEL_LAYOUT_STEREO_DOWNMIX
Definition: channel_layout.h:432
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
name
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 default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
level
uint8_t level
Definition: svq3.c:208
draw_axis_yuv
static void draw_axis_yuv(AVFrame *out, AVFrame *axis, const ColorFloat *c, int off)
Definition: avf_showcqt.c:964
r
const char * r
Definition: vf_curves.c:127
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
draw_bar_yuv
static void draw_bar_yuv(AVFrame *out, const float *h, const float *rcp_h, const ColorFloat *c, int bar_h, float bar_t)
Definition: avf_showcqt.c:811
out
static FILE * out
Definition: movenc.c:55
av_frame_get_buffer
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
Definition: frame.c:206
AV_CHANNEL_LAYOUT_STEREO
#define AV_CHANNEL_LAYOUT_STEREO
Definition: channel_layout.h:395
color
Definition: vf_paletteuse.c:513
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1067
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:931
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
ColorFloat
Definition: avf_showcqt.h:40
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition: opt.h:315
av_div_q
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
Definition: rational.c:88
init_cscheme
static int init_cscheme(ShowCQTContext *s)
Definition: avf_showcqt.c:1232
int64_t
long long int64_t
Definition: coverity.c:34
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
normalize.log
log
Definition: normalize.py:21
mask
int mask
Definition: mediacodecdec_common.c:154
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:64
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:264
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:427
pixdesc.h
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:529
step
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
Definition: rate_distortion.txt:58
AVFrame::width
int width
Definition: frame.h:499
u
#define u(width, name, range_min, range_max)
Definition: cbs_apv.c:68
AVOption
AVOption.
Definition: opt.h:429
b
#define b
Definition: input.c:42
ff_make_pixel_format_list
av_warn_unused_result AVFilterFormats * ff_make_pixel_format_list(const enum AVPixelFormat *fmts)
Create a list of supported pixel formats.
data
const char data[16]
Definition: mxf.c:149
expf
#define expf(x)
Definition: libm.h:285
FLAGS
#define FLAGS
Definition: avf_showcqt.c:60
half
static uint8_t half(int a, int b)
Definition: mobiclip.c:540
ff_set_common_channel_layouts_from_list2
int ff_set_common_channel_layouts_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const AVChannelLayout *fmts)
Definition: formats.c:1025
BLEND_WITH_CHROMA
#define BLEND_WITH_CHROMA(c)
Definition: avf_showcqt.c:891
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:226
base
uint8_t base
Definition: vp3data.h:128
c_weighting
static double c_weighting(void *p, double f)
Definition: avf_showcqt.c:223
AVComplexFloat
Definition: tx.h:27
max
#define max(a, b)
Definition: cuda_runtime.h:33
CSCHEME
#define CSCHEME
Definition: avf_showcqt.c:57
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
ff_avf_showcqt
const FFFilter ff_avf_showcqt
Definition: avf_showcqt.c:1600
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:220
render_default_font
static int render_default_font(AVFrame *tmp)
Definition: avf_showcqt.c:653
AVERROR_UNKNOWN
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:73
video.h
draw_axis_rgb
static void draw_axis_rgb(AVFrame *out, AVFrame *axis, const ColorFloat *c, int off)
Definition: avf_showcqt.c:862
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:639
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
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:448
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
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
avpriv_vga16_font_get
const uint8_t * avpriv_vga16_font_get(void)
Definition: xga_font_data.c:430
AVCOL_SPC_BT470BG
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
Definition: pixfmt.h:706
rgb
Definition: rpzaenc.c:60
AVComplexFloat::im
float im
Definition: tx.h:28
a_weighting
static double a_weighting(void *p, double f)
Definition: avf_showcqt.c:208
fail
#define fail()
Definition: checkasm.h:218
query_formats
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: avf_showcqt.c:1316
val
static double val(void *priv, double ch)
Definition: aeval.c:77
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: avf_showcqt.c:1311
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: filters.h:40
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:52
ceil
static __device__ float ceil(float a)
Definition: cuda_runtime.h:176
lrint
#define lrint
Definition: tablegen.h:53
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
av_cold
#define av_cold
Definition: attributes.h:106
FFFilter
Definition: filters.h:267
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:629
BLEND_WITHOUT_CHROMA
#define BLEND_WITHOUT_CHROMA(c, alpha_inc)
Definition: avf_showcqt.c:911
s
#define s(width, name)
Definition: cbs_vp9.c:198
UPDATE_TIME
#define UPDATE_TIME(t)
DRAW_BAR_WITHOUT_CHROMA
#define DRAW_BAR_WITHOUT_CHROMA(x)
Definition: avf_showcqt.c:800
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:108
init_colormatrix
static void init_colormatrix(ShowCQTContext *s)
Definition: avf_showcqt.c:1197
var_names
static const char *const var_names[]
Definition: noise.c:30
floor
static __device__ float floor(float a)
Definition: cuda_runtime.h:173
g
const char * g
Definition: vf_curves.c:128
AVCOL_SPC_SMPTE170M
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
Definition: pixfmt.h:707
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
Definition: opt.h:267
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:755
filters.h
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:296
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
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:231
ctx
static AVFormatContext * ctx
Definition: movenc.c:49
av_expr_eval
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:792
BLEND_CHROMA2x2
#define BLEND_CHROMA2x2(c)
Definition: avf_showcqt.c:942
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
AVExpr
Definition: eval.c:158
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
ShowCQTContext
Definition: avf_showcqt.h:45
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:265
tmp
static uint8_t tmp[40]
Definition: aes_ctr.c:52
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:74
if
if(ret)
Definition: filter_design.txt:179
ff_load_image
int ff_load_image(struct AVFrame **outframe, const char *filename, void *log_ctx)
Load image from filename and put the resulting image in an AVFrame.
Definition: lavfutils.c:32
clip_with_log
static double clip_with_log(void *log_ctx, const char *name, double val, double min, double max, double nan_replace, int idx)
Definition: avf_showcqt.c:187
xs
#define xs(width, name, var, subs,...)
Definition: cbs_vp9.c:305
result
and forward the result(frame or status change) to the corresponding input. If nothing is possible
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:1535
NULL
#define NULL
Definition: coverity.c:32
format
New swscale design to change SwsGraph is what coordinates multiple passes These can include cascaded scaling error diffusion and so on Or we could have separate passes for the vertical and horizontal scaling In between each SwsPass lies a fully allocated image buffer Graph passes may have different levels of e g we can have a single threaded error diffusion pass following a multi threaded scaling pass SwsGraph is internally recreated whenever the image format
Definition: swscale-v2.txt:14
init
static av_cold int init(AVFilterContext *ctx)
Definition: avf_showcqt.c:1254
vars
static const uint8_t vars[2][12]
Definition: camellia.c:183
render_freetype
static int render_freetype(ShowCQTContext *s, AVFrame *tmp, char *fontfile)
Definition: avf_showcqt.c:505
isnan
#define isnan(x)
Definition: libm.h:342
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition: opt.h:303
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:34
sqrtf
static __device__ float sqrtf(float a)
Definition: cuda_runtime.h:184
double
double
Definition: af_crystalizer.c:132
time.h
rgb_from_cqt
static void rgb_from_cqt(ColorFloat *c, const AVComplexFloat *v, float g, int len, float cscheme[6])
Definition: avf_showcqt.c:734
exp
int8_t exp
Definition: eval.c:73
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:1462
alloc_frame_empty
static AVFrame * alloc_frame_empty(enum AVPixelFormat format, int w, int h)
Definition: avf_showcqt.c:361
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
AVFilterFormatsConfig
Lists of formats / etc.
Definition: avfilter.h:121
inc
static int inc(int num, int period)
Definition: perlin.c:34
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:199
init_axis_from_file
static int init_axis_from_file(ShowCQTContext *s)
Definition: avf_showcqt.c:405
eval.h
f
f
Definition: af_crystalizer.c:122
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:75
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
showcqt_outputs
static const AVFilterPad showcqt_outputs[]
Definition: avf_showcqt.c:1592
height
#define height
Definition: dsp.h:89
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:319
process_cqt
static void process_cqt(ShowCQTContext *s)
Definition: avf_showcqt.c:1085
calculate_gamma
static float calculate_gamma(float v, float g)
Definition: avf_showcqt.c:721
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
init_axis_color
static int init_axis_color(ShowCQTContext *s, AVFrame *tmp, int half)
Definition: avf_showcqt.c:458
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:424
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
init_axis_from_font
static int init_axis_from_font(ShowCQTContext *s)
Definition: avf_showcqt.c:680
av_make_q
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition: rational.h:71
AVComplexFloat::re
float re
Definition: tx.h:28
update_sono_rgb
static void update_sono_rgb(AVFrame *sono, const ColorFloat *c, int idx)
Definition: avf_showcqt.c:1054
Coeffs::val
float * val
Definition: avf_showcqt.h:28
TLENGTH
#define TLENGTH
Definition: avf_showcqt.c:51
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:514
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
rgb::g
uint8_t g
Definition: rpzaenc.c:62
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:174
init_volume
static int init_volume(ShowCQTContext *s)
Definition: avf_showcqt.c:230
FF_FILTER_FORWARD_WANTED
FF_FILTER_FORWARD_WANTED(outlink, inlink)
xga_font_data.h
ENDFREQ
#define ENDFREQ
Definition: avf_showcqt.c:50
M_PI
#define M_PI
Definition: mathematics.h:67
yuv_from_cqt
static void yuv_from_cqt(ColorFloat *c, const AVComplexFloat *v, float gamma, int len, float cm[3][3], float cscheme[6])
Definition: avf_showcqt.c:744
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
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:271
BLEND_CHROMA2
#define BLEND_CHROMA2(c)
Definition: avf_showcqt.c:925
Coeffs::len
int len
Definition: avf_showcqt.h:29
AVCOL_SPC_SMPTE240M
@ AVCOL_SPC_SMPTE240M
derived from 170M primaries and D65 white point, 170M is derived from BT470 System M's primaries
Definition: pixfmt.h:708
convert_axis_pixel_format
static enum AVPixelFormat convert_axis_pixel_format(enum AVPixelFormat format)
Definition: avf_showcqt.c:387
create_freq_table
static double * create_freq_table(double base, double end, int n)
Definition: avf_showcqt.c:167
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:507
b_weighting
static double b_weighting(void *p, double f)
Definition: avf_showcqt.c:216
lrintf
#define lrintf(x)
Definition: libm_mips.h:72
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
b_func
static double b_func(void *p, double x)
Definition: avf_showcqt.c:452
r_func
static double r_func(void *p, double x)
Definition: avf_showcqt.c:440
AVCOL_SPC_BT2020_NCL
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:711
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:32
VOLUME_MAX
#define VOLUME_MAX
Definition: avf_showcqt.c:53
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:241
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
cbrtf
static av_always_inline float cbrtf(float x)
Definition: libm.h:63
TLENGTH_MIN
#define TLENGTH_MIN
Definition: avf_showcqt.c:52
rgb::r
uint8_t r
Definition: rpzaenc.c:61
OFFSET
#define OFFSET(x)
Definition: avf_showcqt.c:59
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
len
int len
Definition: vorbis_enc_data.h:426
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:46
draw_bar_rgb
static void draw_bar_rgb(AVFrame *out, const float *h, const float *rcp_h, const ColorFloat *c, int bar_h, float bar_t)
Definition: avf_showcqt.c:758
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:703
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:760
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:264
Coeffs::start
int start
Definition: avf_showcqt.h:29
log2
#define log2(x)
Definition: libm.h:406
cqt_calc
static void cqt_calc(AVComplexFloat *dst, const AVComplexFloat *src, const Coeffs *coeffs, int len, int fft_len)
Definition: avf_showcqt.c:272
activate
static int activate(AVFilterContext *ctx)
Definition: avf_showcqt.c:1560
common_uninit
static void common_uninit(ShowCQTContext *s)
Definition: avf_showcqt.c:110
ff_make_sample_format_list
av_warn_unused_result AVFilterFormats * ff_make_sample_format_list(const enum AVSampleFormat *fmts)
Create a list of supported sample formats.
plot_cqt
static int plot_cqt(AVFilterContext *ctx, AVFrame **frameout)
Definition: avf_showcqt.c:1131
ret
ret
Definition: filter_design.txt:187
config_output
static int config_output(AVFilterLink *outlink)
Definition: avf_showcqt.c:1347
FONTCOLOR
#define FONTCOLOR
Definition: avf_showcqt.c:54
showcqt_options
static const AVOption showcqt_options[]
Definition: avf_showcqt.c:62
AVFrame::height
int height
Definition: frame.h:499
Coeffs
Definition: af_atilt.c:28
status
ov_status_e status
Definition: dnn_backend_openvino.c:100
channel_layout.h
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AVCOL_SPC_FCC
@ AVCOL_SPC_FCC
FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:705
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avfilter.h
midi
static double midi(void *p, double f)
Definition: avf_showcqt.c:435
avf_showcqt.h
cm
#define cm
Definition: dvbsubdec.c:40
init_cqt
static int init_cqt(ShowCQTContext *s)
Definition: avf_showcqt.c:299
update_sono_yuv
static void update_sono_yuv(AVFrame *sono, const ColorFloat *c, int idx)
Definition: avf_showcqt.c:1066
ff_showcqt_init_x86
void ff_showcqt_init_x86(ShowCQTContext *s)
Definition: avf_showcqt_init.c:47
Windows::Graphics::DirectX::Direct3D11::p
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
Definition: vsrc_gfxcapture_winrt.hpp:53
lavfutils.h
g_func
static double g_func(void *p, double x)
Definition: avf_showcqt.c:446
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
AVFilterContext
An instance of a filter.
Definition: avfilter.h:274
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
Definition: avf_showcqt.c:1478
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
FFFilter::p
AVFilter p
The public AVFilter.
Definition: filters.h:271
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:77
mem.h
audio.h
BASEFREQ
#define BASEFREQ
Definition: avf_showcqt.c:49
w
uint8_t w
Definition: llvidencdsp.c:39
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:278
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
channel_layouts
static const uint16_t channel_layouts[7]
Definition: dca_lbr.c:112
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:472
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
h
h
Definition: vp9dsp_template.c:2070
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(showcqt)
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
width
#define width
Definition: dsp.h:89
AVCOL_SPC_BT709
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
Definition: pixfmt.h:702
ff_scale_image
int ff_scale_image(uint8_t *dst_data[4], int dst_linesize[4], int dst_w, int dst_h, enum AVPixelFormat dst_pix_fmt, uint8_t *const src_data[4], int src_linesize[4], int src_w, int src_h, enum AVPixelFormat src_pix_fmt, void *log_ctx)
Scale image using libswscale.
Definition: lswsutils.c:22
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
lswsutils.h
AV_SAMPLE_FMT_FLT
@ AV_SAMPLE_FMT_FLT
float
Definition: samplefmt.h:60
draw_sono
static void draw_sono(AVFrame *out, AVFrame *sono, int off, int idx)
Definition: avf_showcqt.c:1029
src
#define src
Definition: vp8dsp.c:248
av_clipd
av_clipd
Definition: af_crystalizer.c:132
DRAW_BAR_WITH_CHROMA
#define DRAW_BAR_WITH_CHROMA(x)
Definition: avf_showcqt.c:785
init_axis_empty
static int init_axis_empty(ShowCQTContext *s)
Definition: avf_showcqt.c:398
av_get_pix_fmt_name
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:3376
ff_filter_set_ready
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
Definition: avfilter.c:229
tx.h
funcs
CheckasmFunc * funcs
Definition: checkasm.c:448
min
float min
Definition: vorbis_enc_data.h:429
render_fontconfig
static int render_fontconfig(ShowCQTContext *s, AVFrame *tmp, char *font)
Definition: avf_showcqt.c:589