Commit 2fa01995 authored by Paul B Mahol's avatar Paul B Mahol

avfilter: add showfreqs filter

parent e6b8797b
......@@ -31,6 +31,7 @@ version <next>:
- atadenoise video filter
- OS X VideoToolbox support
- aphasemeter filter
- showfreqs filter
version 2.7:
......
......@@ -2785,6 +2785,8 @@ select_filter_select="pixelutils"
smartblur_filter_deps="gpl swscale"
showcqt_filter_deps="avcodec"
showcqt_filter_select="fft"
showfreqs_filter_deps="avcodec"
showfreqs_filter_select="fft"
showspectrum_filter_deps="avcodec"
showspectrum_filter_select="rdft"
spp_filter_deps="gpl avcodec"
......
......@@ -12704,6 +12704,121 @@ gamma=2:gamma2=2
@end itemize
@section showfreqs
Convert input audio to video output representing the audio power spectrum.
Audio amplitude is on Y-axis while frequency is on X-axis.
The filter accepts the following options:
@table @option
@item size, s
Specify size of video. For the syntax of this option, check the
@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}.
Default is @code{1024x512}.
@item mode
Set display mode.
This set how each frequency bin will be represented.
It accepts the following values:
@table @samp
@item line
@item bar
@item dot
@end table
Default is @code{bar}.
@item ascale
Set amplitude scale.
It accepts the following values:
@table @samp
@item lin
Linear scale.
@item sqrt
Square root scale.
@item cbrt
Cubic root scale.
@item log
Logarithmic scale.
@end table
Default is @code{log}.
@item fscale
Set frequency scale.
It accepts the following values:
@table @samp
@item lin
Linear scale.
@item log
Logarithmic scale.
@item rlog
Reverse logarithmic scale.
@end table
Default is @code{lin}.
@item win_size
Set window size.
It accepts the following values:
@table @samp
@item w16
@item w32
@item w64
@item w128
@item w256
@item w512
@item w1024
@item w2048
@item w4096
@item w8192
@item w16384
@item w32768
@item w65536
@end table
Default is @code{w2048}
@item win_func
Set windowing function.
It accepts the following values:
@table @samp
@item rect
@item bartlett
@item hanning
@item hamming
@item blackman
@item welch
@item flattop
@item bharris
@item bnuttall
@item bhann
@item sine
@item nuttall
@end table
Default is @code{hanning}.
@item overlap
Set window overlap. In range @code{[0, 1]}. Default is @code{1},
which means optimal overlap for selected window function will be picked.
@item averaging
Set time averaging. Setting this to 0 will display current maximal peaks.
Default is @code{1}, which means time averaging is disabled.
@item color
Specify list of colors separated by space or by '|' which will be used to
draw channel frequencies. Unrecognized or missing colors will be replaced
by white color.
@end table
@section showspectrum
Convert input audio to a video output, representing the audio frequency
......
......@@ -258,6 +258,7 @@ OBJS-$(CONFIG_APHASEMETER_FILTER) += avf_aphasemeter.o
OBJS-$(CONFIG_AVECTORSCOPE_FILTER) += avf_avectorscope.o
OBJS-$(CONFIG_CONCAT_FILTER) += avf_concat.o
OBJS-$(CONFIG_SHOWCQT_FILTER) += avf_showcqt.o
OBJS-$(CONFIG_SHOWFREQS_FILTER) += avf_showfreqs.o
OBJS-$(CONFIG_SHOWSPECTRUM_FILTER) += avf_showspectrum.o
OBJS-$(CONFIG_SHOWVOLUME_FILTER) += avf_showvolume.o
OBJS-$(CONFIG_SHOWWAVES_FILTER) += avf_showwaves.o
......
......@@ -273,6 +273,7 @@ void avfilter_register_all(void)
REGISTER_FILTER(AVECTORSCOPE, avectorscope, avf);
REGISTER_FILTER(CONCAT, concat, avf);
REGISTER_FILTER(SHOWCQT, showcqt, avf);
REGISTER_FILTER(SHOWFREQS, showfreqs, avf);
REGISTER_FILTER(SHOWSPECTRUM, showspectrum, avf);
REGISTER_FILTER(SHOWVOLUME, showvolume, avf);
REGISTER_FILTER(SHOWWAVES, showwaves, avf);
......
This diff is collapsed.
......@@ -30,7 +30,7 @@
#include "libavutil/version.h"
#define LIBAVFILTER_VERSION_MAJOR 5
#define LIBAVFILTER_VERSION_MINOR 34
#define LIBAVFILTER_VERSION_MINOR 35
#define LIBAVFILTER_VERSION_MICRO 100
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
......
......@@ -136,6 +136,25 @@ int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples)
return nb_samples;
}
int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples)
{
int i, ret, size;
if (nb_samples < 0)
return AVERROR(EINVAL);
nb_samples = FFMIN(nb_samples, af->nb_samples);
if (!nb_samples)
return 0;
size = nb_samples * af->sample_size;
for (i = 0; i < af->nb_buffers; i++) {
if ((ret = av_fifo_generic_peek(af->buf[i], data[i], size, NULL)) < 0)
return AVERROR_BUG;
}
return nb_samples;
}
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples)
{
int i, ret, size;
......
......@@ -93,6 +93,22 @@ int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples);
*/
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples);
/**
* Peek data from an AVAudioFifo.
*
* @see enum AVSampleFormat
* The documentation for AVSampleFormat describes the data layout.
*
* @param af AVAudioFifo to read from
* @param data audio data plane pointers
* @param nb_samples number of samples to peek
* @return number of samples actually peek, or negative AVERROR code
* on failure. The number of samples actually peek will not
* be greater than nb_samples, and will only be less than
* nb_samples if av_audio_fifo_size is less than nb_samples.
*/
int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples);
/**
* Read data from an AVAudioFifo.
*
......
......@@ -148,6 +148,32 @@ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size,
return total - size;
}
int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size,
void (*func)(void *, void *, int))
{
// Read memory barrier needed for SMP here in theory
uint8_t *rptr = f->rptr;
uint32_t rndx = f->rndx;
do {
int len = FFMIN(f->end - f->rptr, buf_size);
if (func)
func(dest, f->rptr, len);
else {
memcpy(dest, f->rptr, len);
dest = (uint8_t *)dest + len;
}
// memory barrier needed for SMP here in theory
av_fifo_drain(f, len);
buf_size -= len;
} while (buf_size > 0);
f->rptr = rptr;
f->rndx = rndx;
return 0;
}
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size,
void (*func)(void *, void *, int))
{
......
......@@ -83,6 +83,16 @@ int av_fifo_size(const AVFifoBuffer *f);
*/
int av_fifo_space(const AVFifoBuffer *f);
/**
* Feed data from an AVFifoBuffer to a user-supplied callback.
* Similar as av_fifo_gereric_read but without discarding data.
* @param f AVFifoBuffer to read from
* @param buf_size number of bytes to read
* @param func generic read function
* @param dest data destination
*/
int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
/**
* Feed data from an AVFifoBuffer to a user-supplied callback.
* @param f AVFifoBuffer to read from
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment