50 enum ColorMode {
CHANNEL,
INTENSITY,
RAINBOW,
MORELAND,
NEBULAE,
FIRE,
FIERY,
FRUIT,
COOL,
MAGMA,
GREEN,
VIRIDIS,
PLASMA,
CIVIDIS,
TERRAIN,
NB_CLMODES };
103 #define OFFSET(x) offsetof(ShowSpectrumContext, x) 104 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM 189 { 0.13, .03587126228984074, .1573300977624594, -.02548747583751842 },
190 { 0.30, .18572281794568020, .1772436246393981, .17475554840414750 },
191 { 0.60, .28184980583656130, -.1593064119945782, .47132074554608920 },
192 { 0.73, .65830621175547810, -.3716070802232764, .24352759331252930 },
193 { 0.78, .76318535758242900, -.4307467689263783, .16866496622310430 },
194 { 0.91, .95336363636363640, -.2045454545454546, .03313636363636363 },
198 { 0.13, 44/256., (189-128)/256., (138-128)/256. },
199 { 0.25, 29/256., (186-128)/256., (119-128)/256. },
200 { 0.38, 119/256., (194-128)/256., (53-128)/256. },
201 { 0.60, 111/256., (73-128)/256., (59-128)/256. },
202 { 0.73, 205/256., (19-128)/256., (149-128)/256. },
203 { 0.86, 135/256., (83-128)/256., (200-128)/256. },
204 { 1, 73/256., (95-128)/256., (225-128)/256. }},
206 { 0, 44/256., (181-128)/256., (112-128)/256. },
207 { 0.13, 126/256., (177-128)/256., (106-128)/256. },
208 { 0.25, 164/256., (163-128)/256., (109-128)/256. },
209 { 0.38, 200/256., (140-128)/256., (120-128)/256. },
210 { 0.60, 201/256., (117-128)/256., (141-128)/256. },
211 { 0.73, 177/256., (103-128)/256., (165-128)/256. },
212 { 0.86, 136/256., (100-128)/256., (183-128)/256. },
213 { 1, 68/256., (117-128)/256., (203-128)/256. }},
215 { 0, 10/256., (134-128)/256., (132-128)/256. },
216 { 0.23, 21/256., (137-128)/256., (130-128)/256. },
217 { 0.45, 35/256., (134-128)/256., (134-128)/256. },
218 { 0.57, 51/256., (130-128)/256., (139-128)/256. },
219 { 0.67, 104/256., (116-128)/256., (162-128)/256. },
220 { 0.77, 120/256., (105-128)/256., (188-128)/256. },
221 { 0.87, 140/256., (105-128)/256., (188-128)/256. },
225 { 0.23, 44/256., (132-128)/256., (127-128)/256. },
226 { 0.45, 62/256., (116-128)/256., (140-128)/256. },
227 { 0.57, 75/256., (105-128)/256., (152-128)/256. },
228 { 0.67, 95/256., (91-128)/256., (166-128)/256. },
229 { 0.77, 126/256., (74-128)/256., (172-128)/256. },
230 { 0.87, 164/256., (73-128)/256., (162-128)/256. },
234 { 0.23, 36/256., (116-128)/256., (163-128)/256. },
235 { 0.45, 52/256., (102-128)/256., (200-128)/256. },
236 { 0.57, 116/256., (84-128)/256., (196-128)/256. },
237 { 0.67, 157/256., (67-128)/256., (181-128)/256. },
238 { 0.77, 193/256., (40-128)/256., (155-128)/256. },
239 { 0.87, 221/256., (101-128)/256., (134-128)/256. },
243 { 0.20, 29/256., (136-128)/256., (119-128)/256. },
244 { 0.30, 60/256., (119-128)/256., (90-128)/256. },
245 { 0.40, 85/256., (91-128)/256., (85-128)/256. },
246 { 0.50, 116/256., (70-128)/256., (105-128)/256. },
247 { 0.60, 151/256., (50-128)/256., (146-128)/256. },
248 { 0.70, 191/256., (63-128)/256., (178-128)/256. },
249 { 1, 98/256., (80-128)/256., (221-128)/256. }},
256 { 0.10, 23/256., (175-128)/256., (120-128)/256. },
257 { 0.23, 43/256., (158-128)/256., (144-128)/256. },
258 { 0.35, 85/256., (138-128)/256., (179-128)/256. },
259 { 0.48, 96/256., (128-128)/256., (189-128)/256. },
260 { 0.64, 128/256., (103-128)/256., (214-128)/256. },
261 { 0.92, 205/256., (80-128)/256., (152-128)/256. },
269 { 0.10, 0x39/255., (0x9D -128)/255., (0x8F -128)/255. },
270 { 0.23, 0x5C/255., (0x9A -128)/255., (0x68 -128)/255. },
271 { 0.35, 0x69/255., (0x93 -128)/255., (0x57 -128)/255. },
272 { 0.48, 0x76/255., (0x88 -128)/255., (0x4B -128)/255. },
273 { 0.64, 0x8A/255., (0x72 -128)/255., (0x4F -128)/255. },
274 { 0.80, 0xA3/255., (0x50 -128)/255., (0x66 -128)/255. },
275 { 1, 0xCC/255., (0x2F -128)/255., (0x87 -128)/255. }},
278 { 0.10, 0x27/255., (0xC2 -128)/255., (0x82 -128)/255. },
279 { 0.58, 0x5B/255., (0x9A -128)/255., (0xAE -128)/255. },
280 { 0.70, 0x89/255., (0x44 -128)/255., (0xAB -128)/255. },
281 { 0.80, 0xB4/255., (0x2B -128)/255., (0x9E -128)/255. },
282 { 0.91, 0xD2/255., (0x38 -128)/255., (0x92 -128)/255. },
286 { 0.20, 0x28/255., (0x98 -128)/255., (0x6F -128)/255. },
287 { 0.50, 0x48/255., (0x95 -128)/255., (0x74 -128)/255. },
288 { 0.63, 0x69/255., (0x84 -128)/255., (0x7F -128)/255. },
289 { 0.76, 0x89/255., (0x75 -128)/255., (0x84 -128)/255. },
290 { 0.90, 0xCE/255., (0x35 -128)/255., (0x95 -128)/255. },
295 { 0.60, 1, -.5, -.5 },
296 { 0.85, 1, -.5, .5 },
383 const int ch = jobnr;
395 float theta, phi, psi,
a,
b,
S,
c;
405 for (
int n = 0; n <
M; n++) {
410 for (
int n = M; n <
L; n++) {
415 for (
int n = L - N; n <
L; n++) {
416 h[
n].
re =
cosf((L - n) * (L - n) / 2.
f * phi);
417 h[
n].
im =
sinf((L - n) * (L - n) / 2.
f * phi);
420 for (
int n = 0; n <
N; n++) {
425 for (
int n = N; n <
L; n++) {
430 for (
int n = 0; n <
N; n++) {
431 psi = n * theta + n * n / 2.f * phi;
434 a = c * g[
n].
re - S * g[
n].
im;
435 b = S * g[
n].
re + c * g[
n].
im;
446 for (
int n = 0; n <
L; n++) {
449 a = c * h[
n].
re - S * h[
n].
im;
450 b = S * h[
n].
re + c * h[
n].
im;
459 for (
int k = 0; k <
M; k++) {
460 psi = k * k / 2.f * phi;
463 a = c * g[k].
re - S * g[k].
im;
464 b = S * g[k].
re + c * g[k].
im;
485 for (i = 0; txt[
i]; i++) {
489 for (char_y = font_height - 1; char_y >= 0; char_y--) {
491 for (mask = 0x80;
mask; mask >>= 1) {
492 if (font[txt[i] * font_height + font_height - 1 - char_y] & mask)
493 p[char_y] = ~p[char_y];
499 for (char_y = 0; char_y < font_height; char_y++) {
500 for (mask = 0x80;
mask; mask >>= 1) {
501 if (font[txt[i] * font_height + char_y] & mask)
512 float *yf,
float *uf,
float *vf)
574 float yf,
float uf,
float vf,
598 float lerpfrac = (a -
start) / (end - start);
623 else if (log10(seconds) > 6)
625 else if (log10(seconds) > 3)
640 const float b = logf(max / min) / (max -
min);
641 const float a = max /
expf(max * b);
643 return expf(value * b) *
a;
649 const float max_freq = sample_rate / 2;
650 const float hz_per_bin = max_freq / num_bins;
651 const float freq = hz_per_bin * bin;
652 const float scaled_freq =
log_scale(freq + 1, 21, max_freq) - 1;
654 return num_bins * scaled_freq / max_freq;
665 const float b = logf(max / min) / (max -
min);
666 const float a = max /
expf(max * b);
668 return logf(value / a) /
b;
674 const float max_freq = sample_rate / 2;
675 const float hz_per_bin = max_freq / num_bins;
676 const float freq = hz_per_bin * bin;
677 const float scaled_freq =
inv_log_scale(freq + 1, 21, max_freq) - 1;
679 return num_bins * scaled_freq / max_freq;
689 float spp = samples / (float)sz;
692 char chlayout_str[128];
710 for (x = 0; x < s->
w + 1; x++)
713 for (x = 0; x < s->
w + 1; x++)
715 for (y = 0; y < s->
h + 2; y++) {
724 for (y = 0; y <
h; y += 20) {
729 for (y = 0; y <
h; y += 40) {
735 for (x = 0; x < s->
w; x+=40)
738 for (x = 0; x < s->
w; x+=80)
741 for (x = 0; x < s->
w; x+=40) {
745 for (x = 0; x < s->
w; x+=80) {
748 for (y = 0; y <
h; y += 40) {
751 float hertz = s->
start + bin * range / (float)(1 << (
int)ceil(
log2(h)));
768 char *units =
get_time(ctx, seconds, x);
779 for (y = 0; y < s->
h; y += 20) {
784 for (y = 0; y < s->
h; y += 40) {
791 for (x = 0; x <
w; x+=40)
794 for (x = 0; x <
w; x+=80)
797 for (x = 0; x <
w; x+=40) {
801 for (x = 0; x <
w; x+=80) {
804 for (x = 0; x < w - 79; x += 80) {
807 float hertz = s->
start + bin * range / (float)(1 << (
int)ceil(
log2(w)));
824 char *units =
get_time(ctx, seconds, x);
836 for (y = 0; y <
h; y++) {
837 float out[3] = { 0., 127.5, 127.5};
846 pick_color(s, yf, uf, vf, y / (
float)h, lout);
856 for (y = 0; ch == 0 && y <
h; y += h / 10) {
896 a = av_clipf(a, 0, 1);
899 a = av_clipf(sqrtf(a), 0, 1);
902 a = av_clipf(
cbrtf(a), 0, 1);
905 a = av_clipf(sqrtf(sqrtf(a)), 0, 1);
908 a = av_clipf(
powf(a, 0.20), 0, 1);
911 a = 1.f +
log10f(av_clipf(a, 1e-6, 1)) / 6.f;
924 const int ch = jobnr;
932 for (y = 0; y <
h; y++) {
948 const int ch = jobnr;
956 for (y = 0; y < h && yy <
h; yy++) {
959 float delta = pos1 - pos0;
964 for (
float j = pos0; j < pos1 && y + j - pos0 <
h; j++) {
965 float row = (s->
mode ==
COMBINED) ? y + j - pos0 : ch * h + y + j - pos0;
967 float lerpfrac = (j - pos0) / delta;
969 pick_color(s, yf, uf, vf, lerpfrac * a1 + (1.
f-lerpfrac) * a0, out);
997 if (!strcmp(ctx->
filter->
name,
"showspectrumpic"))
1018 for (fft_bits = 1; 1 << fft_bits < 2 *
h; fft_bits++);
1021 for (fft_bits = 1; 1 << fft_bits < 2 *
w; fft_bits++);
1067 "The window size might be too high.\n");
1073 "The window size might be too high.\n");
1149 for (i = 0; i < outlink->
h; i++) {
1150 memset(outpicref->
data[0] + i * outpicref->
linesize[0], 0, outlink->
w);
1151 memset(outpicref->
data[1] + i * outpicref->
linesize[1], 128, outlink->
w);
1152 memset(outpicref->
data[2] + i * outpicref->
linesize[2], 128, outlink->
w);
1199 #define RE(y, ch) s->fft_data[ch][y].re 1200 #define IM(y, ch) s->fft_data[ch][y].im 1201 #define MAGNITUDE(y, ch) hypotf(RE(y, ch), IM(y, ch)) 1202 #define PHASE(y, ch) atan2f(IM(y, ch), RE(y, ch)) 1209 const float f = s->
gain *
w;
1210 const int ch = jobnr;
1213 for (y = 0; y <
h; y++)
1223 const int ch = jobnr;
1227 for (y = 0; y <
h; y++)
1228 phases[y] = (
PHASE(y, ch) /
M_PI + 1) / 2;
1237 const float f = s->
gain *
w;
1242 for (y = 0; y <
h; y++)
1254 for (y = 0; y <
h; y++)
1255 magnitudes[y] *= scale;
1263 for (y = 0; y <
size; y++) {
1284 for (y = 0; y < z * 3; y++) {
1294 for (plane = 0; plane < 3; plane++) {
1295 for (y = 0; y < s->
h; y++) {
1298 memmove(p, p + 1, s->
w - 1);
1303 for (plane = 0; plane < 3; plane++) {
1304 for (y = 0; y < s->
h; y++) {
1307 memmove(p + 1, p, s->
w - 1);
1312 for (plane = 0; plane < 3; plane++) {
1316 for (y = 0; y < s->
h; y++) {
1323 for (plane = 0; plane < 3; plane++) {
1324 for (y = 1; y < s->
h; y++) {
1332 for (plane = 0; plane < 3; plane++) {
1333 for (y = s->
h - 1; y >= 1; y--) {
1341 for (plane = 0; plane < 3; plane++) {
1344 for (x = 0; x < s->
w; x++) {
1365 for (y = 0; y < 10; y++) {
1370 outlink->
w / 2 - 4 * strlen(units),
1374 for (y = 0; y < 10 * s->
old_len; y++) {
1380 outlink->
h / 2 - 4 * strlen(units),
1397 #if CONFIG_SHOWSPECTRUM_FILTER 1461 for (
int i = 0;
i < outlink->
h;
i++) {
1467 for (
int i = s->
xpos; i < outlink->
h;
i++) {
1494 static const AVFilterPad showspectrum_inputs[] = {
1502 static const AVFilterPad showspectrum_outputs[] = {
1512 .
name =
"showspectrum",
1517 .
inputs = showspectrum_inputs,
1518 .
outputs = showspectrum_outputs,
1520 .priv_class = &showspectrum_class,
1523 #endif // CONFIG_SHOWSPECTRUM_FILTER 1525 #if CONFIG_SHOWSPECTRUMPIC_FILTER 1527 static const AVOption showspectrumpic_options[] = {
1595 static int showspectrumpic_request_frame(
AVFilterLink *outlink)
1611 spf =
FFMAX(1, spf);
1613 spb = (samples / (spf * sz)) * spf;
1631 (s->
win_size - ret) *
sizeof(
float));
1639 if (consumed >= spb) {
1647 memset(s->
magnitudes[ch], 0, h *
sizeof(
float));
1675 static const AVFilterPad showspectrumpic_inputs[] = {
1679 .filter_frame = showspectrumpic_filter_frame,
1684 static const AVFilterPad showspectrumpic_outputs[] = {
1689 .request_frame = showspectrumpic_request_frame,
1695 .
name =
"showspectrumpic",
1696 .description =
NULL_IF_CONFIG_SMALL(
"Convert input audio to a spectrum video output single picture."),
1700 .
inputs = showspectrumpic_inputs,
1701 .
outputs = showspectrumpic_outputs,
1702 .priv_class = &showspectrumpic_class,
1706 #endif // CONFIG_SHOWSPECTRUMPIC_FILTER
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
#define av_realloc_f(p, o, n)
This structure describes decoded (raw) audio or video data.
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
av_cold void av_fft_end(FFTContext *s)
float rotation
color rotation
static int plot_channel_log(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Main libavfilter public API header.
static float get_log_hz(const int bin, const int num_bins, const float sample_rate)
FFTComplex ** fft_data
bins holder for each (displayed) channels
static int plot_channel_lin(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int h
agreed upon image height
static int draw_legend(AVFilterContext *ctx, int samples)
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&HAVE_MMX) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
#define FFERROR_NOT_READY
Filters implementation helper functions.
float * window_func_lut
Window function LUT.
void av_fft_permute(FFTContext *s, FFTComplex *z)
Do the permutation needed BEFORE calling ff_fft_calc().
static void generate_window_func(float *lut, int N, int win_func, float *overlap)
int fft_bits
number of bits (FFT window size = 1<<fft_bits)
static int query_formats(AVFilterContext *ctx)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
int sliding
1 if sliding mode, 0 otherwise
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
static int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
int mode
channel display mode
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static void drawtext(AVFrame *pic, int x, int y, const char *txt, int o)
static const AVOption showspectrum_options[]
static int calc_channel_magnitudes(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static av_cold int end(AVCodecContext *avctx)
AVRational auto_frame_rate
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define u(width, name, range_min, range_max)
static int run_channel_fft(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int calc_channel_phases(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
static char * get_time(AVFilterContext *ctx, float seconds, int x)
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
A link between two filters.
#define i(width, name, range_min, range_max)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const uint8_t avpriv_cga_font[2048]
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0, will be automatically copied from the first input of the source filter if it exists.
int sample_rate
samples per second
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
static const uint16_t mask[17]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
float ** color_buffer
color buffer (3 * h * ch items)
void * priv
private data for use by the filter
enum AVColorRange color_range
MPEG vs JPEG YUV range.
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
float saturation
color saturation multiplier
float * combine_buffer
color combining buffer (3 * h items)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
simple assert() macros that are a bit more flexible than ISO C assert().
struct AVFilterChannelLayouts * out_channel_layouts
FFTContext * av_fft_init(int nbits, int inverse)
Set up a complex FFT.
AVFilterFormats * in_formats
Lists of formats and channel layouts supported by the input and output filters respectively.
Context for an Audio FIFO Buffer.
int w
agreed upon image width
char * av_asprintf(const char *fmt,...)
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
audio channel layout utility functions
static int activate(AVFilterContext *ctx)
static void acalc_magnitudes(ShowSpectrumContext *s)
static float get_value(AVFilterContext *ctx, int ch, int y)
AVFilterContext * src
source filter
static const AVFilterPad inputs[]
AVFilterFormats * out_samplerates
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
static const AVFilterPad outputs[]
int format
agreed upon media format
#define FF_ARRAY_ELEMS(a)
FFTContext ** ifft
Inverse Fast Fourier Transform context.
the normal 2^n-1 "JPEG" YUV ranges
A list of supported channel layouts.
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.
static float bin_pos(const int bin, const int num_bins, const float sample_rate)
static int config_output(AVFilterLink *outlink)
static void color_range(ShowSpectrumContext *s, int ch, float *yf, float *uf, float *vf)
AVSampleFormat
Audio sample formats.
static const struct ColorTable color_table[][8]
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
AVFilter ff_avf_showspectrum
static AVRational av_make_q(int num, int den)
Create an AVRational.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
static av_always_inline float cbrtf(float x)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Describe the class of an AVClass context structure.
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
AVFILTER_DEFINE_CLASS(showspectrum)
Rational number (pair of numerator and denominator).
const char * name
Filter name.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
offset must point to two consecutive integers
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
#define FF_FILTER_FORWARD_STATUS(inlink, outlink)
Acknowledge the status on an input link and forward it to an output link.
static enum AVPixelFormat pix_fmts[]
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
#define flags(name, subs,...)
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples)
Write data to an AVAudioFifo.
static av_cold void uninit(AVFilterContext *ctx)
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples)
Drain data from an AVAudioFifo.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples)
channel
Use these values when setting the channel map with ebur128_set_channel().
FFTContext ** fft
Fast Fourier Transform context.
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
int channels
Number of channels.
avfilter_execute_func * execute
int(* plot_channel)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
AVFilterContext * dst
dest filter
int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples)
Peek data from an AVAudioFifo.
AVFilter ff_avf_showspectrumpic
static enum AVSampleFormat sample_fmts[]
static float log_scale(const float value, const float min, const float max)
static void scale_magnitudes(ShowSpectrumContext *s, float scale)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
static void pick_color(ShowSpectrumContext *s, float yf, float uf, float vf, float a, float *out)
uint8_t ** extended_data
pointers to the data planes/channels.
int xpos
x position (current column)
void av_fft_calc(FFTContext *s, FFTComplex *z)
Do a complex FFT with the parameters defined in av_fft_init().
AVPixelFormat
Pixel format.
static void clear_combine_buffer(ShowSpectrumContext *s, int size)
static float inv_log_scale(const float value, const float min, const float max)
mode
Use these values in ebur128_init (or'ed).
int nb_samples
number of audio samples (per channel) described by this frame
const AVFilter * filter
the AVFilter of which this is an instance
FFTComplex ** fft_scratch
scratch buffers
CGA/EGA/VGA ROM font data.
AVFilterFormats * out_formats
int color_mode
display color scheme