56 #define OFFSET(x) offsetof(ShowSpatialContext, x) 57 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM 96 for (i = 0; i < 2; i++)
98 for (i = 0; i < 2; i++)
100 for (i = 0; i < 2; i++)
138 const int ch = jobnr;
142 s->
fft_data[ch][n].
re = p[n] * window_func_lut[n];
175 for (i = 0; i < 2; i++) {
179 for (i = 0; i < 2; i++) {
183 "The window size might be too high.\n");
188 for (i = 0; i < 2; i++) {
220 #define RE(y, ch) s->fft_data[ch][y].re 221 #define IM(y, ch) s->fft_data[ch][y].im 228 dst[linesize] =
value;
229 dst[-linesize] =
value;
247 for (
int i = 0;
i < outlink->
h;
i++) {
248 memset(outpicref->
data[0] +
i * outpicref->
linesize[0], 0, outlink->
w);
249 memset(outpicref->
data[1] +
i * outpicref->
linesize[1], 0, outlink->
w);
250 memset(outpicref->
data[2] +
i * outpicref->
linesize[2], 0, outlink->
w);
253 for (
int j = 0; j < z; j++) {
254 const int idx = z - 1 - j;
255 float l = hypotf(
RE(idx, 0),
IM(idx, 0));
256 float r = hypotf(
RE(idx, 1),
IM(idx, 1));
260 float diffp = ((rp - lp) / (2.
f *
M_PI) + 1.f) * 0.5
f;
261 float diff = (sum < 0.000001f ? 0.f : (r - l) / sum) * 0.5f + 0.5f;
262 float cr = av_clipf(
cbrtf(l / sum), 0, 1) * 255.f;
263 float cb = av_clipf(
cbrtf(r / sum), 0, 1) * 255.f;
268 x = av_clip(w * diff, 0, w - 2) + 1;
269 y = av_clip(h * diffp, 0, h - 2) + 1;
362 .
name =
"showspatial",
367 .
inputs = showspatial_inputs,
368 .
outputs = showspatial_outputs,
370 .priv_class = &showspatial_class,
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
AVFILTER_DEFINE_CLASS(showspatial)
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.
av_cold void av_fft_end(FFTContext *s)
Main libavfilter public API header.
int fft_bits
number of bits (FFT window size = 1<<fft_bits)
int h
agreed upon image height
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
static int draw_spatial(AVFilterLink *inlink, AVFrame *insamples)
FFTContext * ifft[2]
Inverse Fast Fourier Transform context.
#define FFERROR_NOT_READY
Filters implementation helper functions.
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)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define AV_CH_LAYOUT_STEREO
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.
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.
static double cb(void *priv, double x, double y)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static int spatial_activate(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
#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.
static const AVFilterPad showspatial_outputs[]
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.
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
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. ...
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...
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.
FFTComplex * fft_data[2]
bins holder for each (displayed) channels
static int config_output(AVFilterLink *outlink)
Context for an Audio FIFO Buffer.
int w
agreed upon image width
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)
float * window_func_lut
Window function LUT.
AVFilterContext * src
source filter
static const AVFilterPad inputs[]
AVFilterFormats * out_samplerates
static const AVFilterPad outputs[]
int format
agreed upon media format
A list of supported channel layouts.
AVSampleFormat
Audio sample formats.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
static const AVFilterPad showspatial_inputs[]
static void draw_dot(uint8_t *dst, int linesize, int value)
static av_always_inline float cbrtf(float x)
Describe the class of an AVClass context structure.
static int run_channel_fft(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
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
AVFilter ff_avf_showspatial
#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[]
#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.
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 const AVOption showspatial_options[]
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
int channels
Number of channels.
avfilter_execute_func * execute
static av_always_inline int diff(const uint32_t a, const uint32_t b)
AVFilterContext * dst
dest filter
static int query_formats(AVFilterContext *ctx)
int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples)
Peek data from an AVAudioFifo.
FFTContext * fft[2]
Fast Fourier Transform context.
static enum AVSampleFormat sample_fmts[]
static double cr(void *priv, double x, double y)
uint8_t ** extended_data
pointers to the data planes/channels.
void av_fft_calc(FFTContext *s, FFTComplex *z)
Do a complex FFT with the parameters defined in av_fft_init().
AVPixelFormat
Pixel format.
int nb_samples
number of audio samples (per channel) described by this frame
AVFilterFormats * out_formats