88 #define OFFSET(x) offsetof(ShowSpectrumContext, x)
89 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
160 { 0.13, .03587126228984074, .1573300977624594, -.02548747583751842 },
161 { 0.30, .18572281794568020, .1772436246393981, .17475554840414750 },
162 { 0.60, .28184980583656130, -.1593064119945782, .47132074554608920 },
163 { 0.73, .65830621175547810, -.3716070802232764, .24352759331252930 },
164 { 0.78, .76318535758242900, -.4307467689263783, .16866496622310430 },
165 { 0.91, .95336363636363640, -.2045454545454546, .03313636363636363 },
169 { 0.13, 44/256., (189-128)/256., (138-128)/256. },
170 { 0.25, 29/256., (186-128)/256., (119-128)/256. },
171 { 0.38, 119/256., (194-128)/256., (53-128)/256. },
172 { 0.60, 111/256., (73-128)/256., (59-128)/256. },
173 { 0.73, 205/256., (19-128)/256., (149-128)/256. },
174 { 0.86, 135/256., (83-128)/256., (200-128)/256. },
175 { 1, 73/256., (95-128)/256., (225-128)/256. }},
177 { 0, 44/256., (181-128)/256., (112-128)/256. },
178 { 0.13, 126/256., (177-128)/256., (106-128)/256. },
179 { 0.25, 164/256., (163-128)/256., (109-128)/256. },
180 { 0.38, 200/256., (140-128)/256., (120-128)/256. },
181 { 0.60, 201/256., (117-128)/256., (141-128)/256. },
182 { 0.73, 177/256., (103-128)/256., (165-128)/256. },
183 { 0.86, 136/256., (100-128)/256., (183-128)/256. },
184 { 1, 68/256., (117-128)/256., (203-128)/256. }},
186 { 0, 10/256., (134-128)/256., (132-128)/256. },
187 { 0.23, 21/256., (137-128)/256., (130-128)/256. },
188 { 0.45, 35/256., (134-128)/256., (134-128)/256. },
189 { 0.57, 51/256., (130-128)/256., (139-128)/256. },
190 { 0.67, 104/256., (116-128)/256., (162-128)/256. },
191 { 0.77, 120/256., (105-128)/256., (188-128)/256. },
192 { 0.87, 140/256., (105-128)/256., (188-128)/256. },
196 { 0.23, 44/256., (132-128)/256., (127-128)/256. },
197 { 0.45, 62/256., (116-128)/256., (140-128)/256. },
198 { 0.57, 75/256., (105-128)/256., (152-128)/256. },
199 { 0.67, 95/256., (91-128)/256., (166-128)/256. },
200 { 0.77, 126/256., (74-128)/256., (172-128)/256. },
201 { 0.87, 164/256., (73-128)/256., (162-128)/256. },
205 { 0.23, 36/256., (116-128)/256., (163-128)/256. },
206 { 0.45, 52/256., (102-128)/256., (200-128)/256. },
207 { 0.57, 116/256., (84-128)/256., (196-128)/256. },
208 { 0.67, 157/256., (67-128)/256., (181-128)/256. },
209 { 0.77, 193/256., (40-128)/256., (155-128)/256. },
210 { 0.87, 221/256., (101-128)/256., (134-128)/256. },
214 { 0.20, 29/256., (136-128)/256., (119-128)/256. },
215 { 0.30, 60/256., (119-128)/256., (90-128)/256. },
216 { 0.40, 85/256., (91-128)/256., (85-128)/256. },
217 { 0.50, 116/256., (70-128)/256., (105-128)/256. },
218 { 0.60, 151/256., (50-128)/256., (146-128)/256. },
219 { 0.70, 191/256., (63-128)/256., (178-128)/256. },
220 { 1, 98/256., (80-128)/256., (221-128)/256. }},
299 int i, fft_bits,
h, w;
302 if (!strcmp(ctx->
filter->
name,
"showspectrumpic"))
322 for (fft_bits = 1; 1 << fft_bits < 2 *
h; fft_bits++);
325 for (fft_bits = 1; 1 << fft_bits < 2 * w; fft_bits++);
355 "The window size might be too high.\n");
412 for (s->
win_scale = 0, i = 0; i < s->win_size; i++) {
424 for (i = 0; i < outlink->
h; i++) {
425 memset(outpicref->
data[0] + i * outpicref->
linesize[0], 0, outlink->
w);
426 memset(outpicref->
data[1] + i * outpicref->
linesize[1], 128, outlink->
w);
427 memset(outpicref->
data[2] + i * outpicref->
linesize[2], 128, outlink->
w);
467 const int ch = jobnr;
485 #define RE(y, ch) s->fft_data[ch][y].re
486 #define IM(y, ch) s->fft_data[ch][y].im
487 #define MAGNITUDE(y, ch) hypot(RE(y, ch), IM(y, ch))
488 #define PHASE(y, ch) atan2(IM(y, ch), RE(y, ch))
495 const float f = s->
gain * w;
496 const int ch = jobnr;
499 for (y = 0; y <
h; y++)
509 const int ch = jobnr;
513 for (y = 0; y <
h; y++)
514 phases[y] = (
PHASE(y, ch) /
M_PI + 1) / 2;
523 const float f = s->
gain * w;
528 for (y = 0; y <
h; y++)
540 for (y = 0; y <
h; y++)
541 magnitudes[y] *= scale;
546 float *yf,
float *uf,
float *vf)
602 float yf,
float uf,
float vf,
626 float lerpfrac = (a -
start) / (end - start);
649 for (y = 0; y <
size; y++) {
660 const int ch = jobnr;
670 for (y = 0; y <
h; y++) {
691 a = av_clipf(a, 0, 1);
694 a = av_clipf(sqrt(a), 0, 1);
697 a = av_clipf(
cbrt(a), 0, 1);
700 a = av_clipf(sqrt(sqrt(a)), 0, 1);
703 a = av_clipf(pow(a, 0.20), 0, 1);
706 a = 1 + log10(av_clipd(a, 1e-6, 1)) / 6;
732 for (y = 0; y < z * 3; y++) {
742 for (plane = 0; plane < 3; plane++) {
743 for (y = 0; y < s->
h; y++) {
746 memmove(p, p + 1, s->
w - 1);
751 for (plane = 0; plane < 3; plane++) {
752 for (y = 0; y < s->
h; y++) {
755 memmove(p + 1, p, s->
w - 1);
760 for (plane = 0; plane < 3; plane++) {
764 for (y = 0; y < s->
h; y++) {
771 for (plane = 0; plane < 3; plane++) {
772 for (y = 1; y < s->
h; y++) {
773 memmove(outpicref->
data[plane] + (y-1) * outpicref->
linesize[plane],
774 outpicref->
data[plane] + (y ) * outpicref->
linesize[plane],
780 for (plane = 0; plane < 3; plane++) {
781 for (y = s->
h - 1; y >= 1; y--) {
782 memmove(outpicref->
data[plane] + (y ) * outpicref->
linesize[plane],
783 outpicref->
data[plane] + (y-1) * outpicref->
linesize[plane],
789 for (plane = 0; plane < 3; plane++) {
792 for (x = 0; x < s->
w; x++) {
800 outpicref->
pts = insamples->
pts;
816 #if CONFIG_SHOWSPECTRUM_FILTER
829 for (i = 0; i < outlink->
h; i++) {
835 for (i = s->
xpos; i < outlink->
h; i++) {
853 int ret = 0, consumed = 0;
867 fin->
pts = s->
pts + consumed;
905 static const AVFilterPad showspectrum_outputs[] = {
916 .
name =
"showspectrum",
921 .
inputs = showspectrum_inputs,
922 .
outputs = showspectrum_outputs,
923 .priv_class = &showspectrum_class,
926 #endif // CONFIG_SHOWSPECTRUM_FILTER
928 #if CONFIG_SHOWSPECTRUMPIC_FILTER
930 static const AVOption showspectrumpic_options[] = {
986 static void drawtext(
AVFrame *pic,
int x,
int y,
const char *txt,
int o)
994 for (i = 0; txt[i]; i++) {
998 for (char_y = font_height - 1; char_y >= 0; char_y--) {
1000 for (mask = 0x80;
mask; mask >>= 1) {
1001 if (font[txt[i] * font_height + font_height - 1 - char_y] & mask)
1002 p[char_y] = ~p[char_y];
1008 for (char_y = 0; char_y < font_height; char_y++) {
1009 for (mask = 0x80;
mask; mask >>= 1) {
1010 if (font[txt[i] * font_height + char_y] & mask)
1020 static int showspectrumpic_request_frame(
AVFilterLink *outlink)
1036 spf =
FFMAX(1, spf);
1038 spb = (samples / (spf * sz)) * spf;
1053 if (ret < s->win_size) {
1056 (s->
win_size - ret) *
sizeof(
float));
1064 if (consumed >= spb) {
1072 memset(s->
magnitudes[ch], 0, h *
sizeof(
float));
1081 float spp = samples / (float)sz;
1087 for (x = 0; x < s->
w + 1; x++)
1090 for (x = 0; x < s->
w + 1; x++)
1092 for (y = 0; y < s->
h + 2; y++) {
1100 for (y = 0; y <
h; y += 20) {
1105 for (y = 0; y <
h; y += 40) {
1111 for (x = 0; x < s->
w; x+=40)
1114 for (x = 0; x < s->
w; x+=80)
1117 for (x = 0; x < s->
w; x+=40) {
1121 for (x = 0; x < s->
w; x+=80) {
1124 for (y = 0; y <
h; y += 40) {
1140 for (x = 0; x < s->
w; x+=80) {
1146 else if (log10(seconds) > 6)
1147 units =
av_asprintf(
"%.2fh", seconds / (60 * 60));
1148 else if (log10(seconds) > 3)
1164 for (y = 0; y < s->
h; y += 20) {
1169 for (y = 0; y < s->
h; y += 40) {
1176 for (x = 0; x < w; x+=40)
1179 for (x = 0; x < w; x+=80)
1182 for (x = 0; x < w; x+=40) {
1186 for (x = 0; x < w; x+=80) {
1189 for (x = 0; x < w; x += 80) {
1205 for (y = 0; y < s->
h; y+=40) {
1211 else if (log10(seconds) > 6)
1212 units =
av_asprintf(
"%.2fh", seconds / (60 * 60));
1213 else if (log10(seconds) > 3)
1230 for (y = 0; y <
h; y++) {
1231 float out[3] = { 0., 127.5, 127.5};
1240 pick_color(s, yf, uf, vf, y / (
float)h, lout);
1250 for (y = 0; ch == 0 && y <
h; y += h / 10) {
1251 float value = 120.0 * log10(1. - y / (
float)h);
1283 static const AVFilterPad showspectrumpic_inputs[] = {
1287 .filter_frame = showspectrumpic_filter_frame,
1292 static const AVFilterPad showspectrumpic_outputs[] = {
1297 .request_frame = showspectrumpic_request_frame,
1302 AVFilter ff_avf_showspectrumpic = {
1303 .
name =
"showspectrumpic",
1304 .description =
NULL_IF_CONFIG_SMALL(
"Convert input audio to a spectrum video output single picture."),
1308 .
inputs = showspectrumpic_inputs,
1309 .
outputs = showspectrumpic_outputs,
1310 .priv_class = &showspectrumpic_class,
1314 #endif // CONFIG_SHOWSPECTRUMPIC_FILTER
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.
ptrdiff_t const GLvoid * data
av_cold void av_fft_end(FFTContext *s)
float rotation
color rotation
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Main libavfilter public API header.
FFTComplex ** fft_data
bins holder for each (displayed) channels
int h
agreed upon image height
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
float * window_func_lut
Window function LUT.
void av_fft_permute(FFTContext *s, FFTComplex *z)
Do the permutation needed BEFORE calling ff_fft_calc().
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.
static void drawtext(AVFrame *pic, int x, int y, const char *txt, int o)
int sliding
1 if sliding mode, 0 otherwise
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 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)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
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.
void av_frame_set_color_range(AVFrame *frame, enum AVColorRange val)
A filter pad used for either input or output.
A link between two filters.
static int plot_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#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
#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)
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 request_frame(AVFilterLink *outlink)
GLsizei GLboolean const GLfloat * value
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static void acalc_magnitudes(ShowSpectrumContext *s)
AVFilterContext * src
source filter
static const AVFilterPad outputs[]
AVFilterFormats * out_samplerates
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int format
agreed upon media format
#define FF_ARRAY_ELEMS(a)
the normal 2^n-1 "JPEG" YUV ranges
A list of supported channel layouts.
static const AVFilterPad inputs[]
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.
static AVRational av_make_q(int num, int den)
Create an AVRational.
Describe the class of an AVClass context structure.
void ff_generate_window_func(float *lut, int N, int win_func, float *overlap)
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
static enum AVPixelFormat pix_fmts[]
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
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 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.
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_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),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){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) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;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)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_YASM &&1) 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);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=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){intplanes=out->planar?out->ch_count:1;unsignedm=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){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch
int channels
Number of channels.
avfilter_execute_func * execute
AVFilterContext * dst
dest filter
int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples)
Peek data from an AVAudioFifo.
static enum AVSampleFormat sample_fmts[]
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)
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
#define AV_NOPTS_VALUE
Undefined timestamp value.
CGA/EGA/VGA ROM font data.
AVFilterFormats * out_formats
int color_mode
display color scheme