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 },
153 int i, rdft_bits, win_size, h;
155 outlink->
w = showspectrum->
w;
156 outlink->
h = showspectrum->
h;
162 for (rdft_bits = 1; 1 << rdft_bits < 2 * h; rdft_bits++);
163 win_size = 1 << rdft_bits;
166 if (rdft_bits != showspectrum->
rdft_bits) {
167 size_t rdft_size, rdft_listsize;
186 win_size, &rdft_size) < 0)
204 for (i = 0; i < win_size; i++)
214 for (i = 0; i < outlink->
h; i++) {
215 memset(outpicref->
data[0] + i * outpicref->
linesize[0], 0, outlink->
w);
216 memset(outpicref->
data[1] + i * outpicref->
linesize[1], 128, outlink->
w);
217 memset(outpicref->
data[2] + i * outpicref->
linesize[2], 128, outlink->
w);
221 if (showspectrum->
xpos >= outlink->
w)
222 showspectrum->
xpos = 0;
229 showspectrum->
w, showspectrum->
h, win_size);
237 showspectrum->
xpos++;
238 if (showspectrum->
xpos >= outlink->
w)
239 showspectrum->
xpos = 0;
272 const int nb_freq = 1 << (showspectrum->
rdft_bits - 1);
273 const int win_size = nb_freq << 1;
274 const double w = 1. / (sqrt(nb_freq) * 32768.);
278 const int add_samples =
FFMIN(win_size - start, nb_samples);
285 for (n = 0; n < add_samples; n++)
288 showspectrum->
filled += add_samples;
291 if (showspectrum->
filled == win_size) {
301 #define RE(y, ch) showspectrum->rdft_data[ch][2 * y + 0]
302 #define IM(y, ch) showspectrum->rdft_data[ch][2 * y + 1]
303 #define MAGNITUDE(y, ch) hypot(RE(y, ch), IM(y, ch))
306 for (y = 0; y < outlink->
h; y++) {
316 switch (showspectrum->
mode) {
358 for (y = 0; y < h; y++) {
359 int row = (showspectrum->
mode ==
COMBINED) ? y : ch * h + y;
366 switch (showspectrum->
scale) {
376 a = 1 - log(
FFMAX(
FFMIN(1, a), 1e-6)) / log(1e-6);
402 float lerpfrac = (a -
start) / (end - start);
424 for (plane = 0; plane < 3; plane++) {
425 for (y = 0; y < outlink->
h; y++) {
428 memmove(p, p + 1, outlink->
w - 1);
431 showspectrum->
xpos = outlink->
w - 1;
433 for (plane = 0; plane < 3; plane++) {
435 (outlink->
h - 1) * outpicref->
linesize[plane] +
437 for (y = 0; y < outlink->
h; y++) {
443 outpicref->
pts = insamples->
pts +
462 while (left_samples) {
494 .
name =
"showspectrum",
499 .
inputs = showspectrum_inputs,
500 .
outputs = showspectrum_outputs,
501 .priv_class = &showspectrum_class,