63 #define OFFSET(x) offsetof(ShowSpectrumContext, x)
64 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
91 { 0.13, .03587126228984074, .1573300977624594, -.02548747583751842 },
92 { 0.30, .18572281794568020, .1772436246393981, .17475554840414750 },
93 { 0.60, .28184980583656130, -.1593064119945782, .47132074554608920 },
94 { 0.73, .65830621175547810, -.3716070802232764, .24352759331252930 },
95 { 0.78, .76318535758242900, -.4307467689263783, .16866496622310430 },
96 { 0.91, .95336363636363640, -.2045454545454546, .03313636363636363 },
105 showspectrum->
class = &showspectrum_class;
167 int i, rdft_bits, win_size, h;
169 outlink->
w = showspectrum->
w;
170 outlink->
h = showspectrum->
h;
176 for (rdft_bits = 1; 1 << rdft_bits < 2 * h; rdft_bits++);
177 win_size = 1 << rdft_bits;
180 if (rdft_bits != showspectrum->
rdft_bits) {
181 size_t rdft_size, rdft_listsize;
200 win_size, &rdft_size) < 0)
218 for (i = 0; i < win_size; i++)
225 outlink->
w, outlink->
h);
229 memset(outpicref->
data[0], 0, outlink->
h * outpicref->
linesize[0]);
232 if (showspectrum->
xpos >= outlink->
w)
233 showspectrum->
xpos = 0;
240 showspectrum->
w, showspectrum->
h, win_size);
248 showspectrum->
xpos++;
249 if (showspectrum->
xpos >= outlink->
w)
250 showspectrum->
xpos = 0;
282 const int nb_freq = 1 << (showspectrum->
rdft_bits - 1);
283 const int win_size = nb_freq << 1;
284 const double w = 1. / (sqrt(nb_freq) * 32768.);
287 const int start = showspectrum->
filled;
288 const int add_samples =
FFMIN(win_size - start, nb_samples);
295 for (n = 0; n < add_samples; n++)
298 showspectrum->
filled += add_samples;
301 if (showspectrum->
filled == win_size) {
311 #define RE(y, ch) showspectrum->rdft_data[ch][2 * y + 0]
312 #define IM(y, ch) showspectrum->rdft_data[ch][2 * y + 1]
313 #define MAGNITUDE(y, ch) hypot(RE(y, ch), IM(y, ch))
316 for (y = 0; y < outlink->
h; y++) {
326 switch (showspectrum->
mode) {
368 for (y = 0; y < h; y++) {
369 int row = (showspectrum->
mode ==
COMBINED) ? y : ch * h + y;
376 switch (showspectrum->
scale) {
386 a = 1 - log(
FFMAX(
FFMIN(1, a), 1e-6)) / log(1e-6);
412 float lerpfrac = (a - start) / (end - start);
434 for (plane = 0; plane < 3; plane++) {
435 for (y = 0; y < outlink->
h; y++) {
438 memmove(p, p + 1, outlink->
w - 1);
441 showspectrum->
xpos = outlink->
w - 1;
443 for (plane = 0; plane < 3; plane++) {
445 (outlink->
h - 1) * outpicref->
linesize[plane] +
447 for (y = 0; y < outlink->
h; y++) {
453 outpicref->
pts = insamples->
pts +
470 while (left_samples) {
472 showspectrum->
consumed += added_samples;
473 left_samples -= added_samples;
501 .
name =
"showspectrum",
507 .
inputs = showspectrum_inputs,
508 .
outputs = showspectrum_outputs,
509 .priv_class = &showspectrum_class,