50 #define OFFSET(x) offsetof(ShowSpectrumContext, x)
51 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
67 showspectrum->
class = &showspectrum_class;
124 int i, rdft_bits, win_size;
126 outlink->
w = showspectrum->
w;
127 outlink->
h = showspectrum->
h;
130 for (rdft_bits = 1; 1<<rdft_bits < 2*outlink->
h; rdft_bits++);
131 win_size = 1 << rdft_bits;
134 if (rdft_bits != showspectrum->
rdft_bits) {
159 for (i = 0; i < win_size; i++)
166 outlink->
w, outlink->
h);
170 memset(outpicref->
data[0], 0, outlink->
h * outpicref->
linesize[0]);
173 if (showspectrum->
xpos >= outlink->
w)
174 showspectrum->
xpos = 0;
177 showspectrum->
w, showspectrum->
h, win_size);
185 showspectrum->
xpos++;
186 if (showspectrum->
xpos >= outlink->
w)
187 showspectrum->
xpos = 0;
220 const int nb_freq = 1 << (showspectrum->
rdft_bits - 1);
221 const int win_size = nb_freq << 1;
225 const int nb_display_channels =
FFMIN(nb_channels, 2);
226 const int start = showspectrum->
filled;
227 const int add_samples =
FFMIN(win_size - start, nb_samples);
230 for (ch = 0; ch < nb_display_channels; ch++) {
234 data[ch] = showspectrum->
rdft_data + win_size * ch;
235 for (n = 0; n < add_samples; n++)
238 showspectrum->
filled += add_samples;
241 if (showspectrum->
filled == win_size) {
244 for (ch = 0; ch < nb_display_channels; ch++)
248 #define RE(ch) data[ch][2*y + 0]
249 #define IM(ch) data[ch][2*y + 1]
250 #define MAGNITUDE(re, im) sqrt((re)*(re) + (im)*(im))
252 for (y = 0; y < outlink->
h; y++) {
255 const double w = 1. / sqrt(nb_freq);
257 int b = nb_display_channels > 1 ? sqrt(w *
MAGNITUDE(
RE(1),
IM(1))) :
a;
260 memmove(p, p + 3, (outlink->
w - 1) * 3);
261 p += (outlink->
w - 1) * 3;
263 p += showspectrum->
xpos * 3;
272 outpicref->
pts = insamples->
pts +
289 while (left_samples) {
291 showspectrum->
consumed += added_samples;
292 left_samples -= added_samples;
320 .
name =
"showspectrum",
326 .
inputs = showspectrum_inputs,
327 .
outputs = showspectrum_outputs,
328 .priv_class = &showspectrum_class,