54#define OFFSET(x) offsetof(ShowSpatialContext, x)
55#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
73 for (
int i = 0;
i < 2;
i++)
75 for (
int i = 0;
i < 2;
i++) {
111 const float *window_func_lut =
s->window_func_lut;
113 const int ch = jobnr;
117 s->fft_tdata[ch][n].re = p[n] * window_func_lut[n];
118 s->fft_tdata[ch][n].im = 0.f;
143 if (
s->win_size !=
s->buf_size) {
144 s->buf_size =
s->win_size;
149 for (
int i = 0;
i < 2;
i++) {
154 for (
int i = 0;
i < 2;
i++) {
157 0,
s->win_size, &
scale, 0);
162 for (
int i = 0;
i < 2;
i++) {
163 s->fft_tdata[
i] =
av_calloc(
s->buf_size,
sizeof(**
s->fft_tdata));
164 if (!
s->fft_tdata[
i])
167 s->fft_data[
i] =
av_calloc(
s->buf_size,
sizeof(**
s->fft_data));
175 sizeof(*
s->window_func_lut));
176 if (!
s->window_func_lut)
190#define RE(y, ch) s->fft_data[ch][y].re
191#define IM(y, ch) s->fft_data[ch][y].im
210 int z =
s->win_size / 2;
218 for (
int i = 0;
i < outlink->
h;
i++) {
219 memset(outpicref->
data[0] +
i * outpicref->
linesize[0], 0, outlink->
w);
220 memset(outpicref->
data[1] +
i * outpicref->
linesize[1], 0, outlink->
w);
221 memset(outpicref->
data[2] +
i * outpicref->
linesize[2], 0, outlink->
w);
224 for (
int j = 0; j < z; j++) {
225 const int idx = z - 1 - j;
226 float l = hypotf(
RE(idx, 0),
IM(idx, 0));
227 float r = hypotf(
RE(idx, 1),
IM(idx, 1));
231 float diffp = ((rp - lp) / (2.f *
M_PI) + 1.f) * 0.5f;
232 float diff = (sum < 0.000001f ? 0.f : (
r - l) / sum) * 0.5f + 0.5f;
282 fin->
pts =
s->pts +
s->consumed;
283 s->consumed +=
s->hop_size;
325 .p.name =
"showspatial",
327 .p.priv_class = &showspatial_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static enum AVSampleFormat sample_fmts[]
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
const FFFilter ff_avf_showspatial
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static const AVOption showspatial_options[]
static int draw_spatial(AVFilterLink *inlink, AVFrame *insamples)
static void draw_dot(uint8_t *dst, int linesize, int value)
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static const AVFilterPad showspatial_outputs[]
static av_cold void uninit(AVFilterContext *ctx)
static int config_output(AVFilterLink *outlink)
static int run_channel_fft(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int spatial_activate(AVFilterContext *ctx)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
#define AV_CHANNEL_LAYOUT_STEREO
int av_audio_fifo_peek(const AVAudioFifo *af, void *const *data, int nb_samples)
Peek data from an AVAudioFifo.
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
int av_audio_fifo_write(AVAudioFifo *af, void *const *data, int nb_samples)
Write data to an AVAudioFifo.
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples)
Drain data from an AVAudioFifo.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_FLTP
float, planar
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FF_FILTER_FORWARD_STATUS(inlink, outlink)
Acknowledge the status on an input link and forward it to an output link.
#define FFERROR_NOT_READY
Filters implementation helper functions and internal structures.
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
static FilterLink * ff_filter_link(AVFilterLink *link)
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
static av_always_inline float cbrtf(float x)
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
enum MovChannelLayoutTag * layouts
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Context for an Audio FIFO Buffer.
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
int sample_rate
samples per second
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
int64_t duration
Duration of the frame, in the same units as pts.
uint8_t ** extended_data
pointers to the data planes/channels.
Rational number (pair of numerator and denominator).
Link properties exposed to filter code, but not external callers.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
float * window_func_lut
Window function LUT.
AVComplexFloat * fft_tdata[2]
bins holder for each (displayed) channels
AVTXContext * fft[2]
Fast Fourier Transform context.
AVComplexFloat * fft_data[2]
bins holder for each (displayed) channels
#define av_realloc_f(p, o, n)
static AVFormatContext * ctx
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
@ AV_TX_FLOAT_FFT
Standard complex to complex FFT with sample data type of AVComplexFloat, AVComplexDouble or AVComplex...
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
static double cr(void *priv, double x, double y)
static double cb(void *priv, double x, double y)
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define WIN_FUNC_OPTION(win_func_opt_name, win_func_offset, flag, default_window_func)
static void generate_window_func(float *lut, int N, int win_func, float *overlap)