FFmpeg
avf_showspatial.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Paul B Mahol
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <math.h>
22 
23 #include "libavutil/mem.h"
24 #include "libavutil/tx.h"
25 #include "libavutil/audio_fifo.h"
26 #include "libavutil/avassert.h"
28 #include "libavutil/opt.h"
29 #include "audio.h"
30 #include "formats.h"
31 #include "video.h"
32 #include "avfilter.h"
33 #include "filters.h"
34 #include "window_func.h"
35 
36 typedef struct ShowSpatialContext {
37  const AVClass *class;
38  int w, h;
40  AVTXContext *fft[2]; ///< Fast Fourier Transform context
41  AVComplexFloat *fft_data[2]; ///< bins holder for each (displayed) channels
42  AVComplexFloat *fft_tdata[2]; ///< bins holder for each (displayed) channels
43  float *window_func_lut; ///< Window function LUT
45  int win_func;
46  int win_size;
47  int buf_size;
48  int consumed;
49  int hop_size;
53 
54 #define OFFSET(x) offsetof(ShowSpatialContext, x)
55 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
56 
57 static const AVOption showspatial_options[] = {
58  { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "512x512"}, 0, 0, FLAGS },
59  { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "512x512"}, 0, 0, FLAGS },
60  { "win_size", "set window size", OFFSET(win_size), AV_OPT_TYPE_INT, {.i64 = 4096}, 1024, 65536, FLAGS },
61  WIN_FUNC_OPTION("win_func", OFFSET(win_func), FLAGS, WFUNC_HANNING),
62  { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
63  { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
64  { NULL }
65 };
66 
67 AVFILTER_DEFINE_CLASS(showspatial);
68 
70 {
71  ShowSpatialContext *s = ctx->priv;
72 
73  for (int i = 0; i < 2; i++)
74  av_tx_uninit(&s->fft[i]);
75  for (int i = 0; i < 2; i++) {
76  av_freep(&s->fft_data[i]);
77  av_freep(&s->fft_tdata[i]);
78  }
79  av_freep(&s->window_func_lut);
80  av_audio_fifo_free(s->fifo);
81 }
82 
84 {
87  AVFilterLink *inlink = ctx->inputs[0];
88  AVFilterLink *outlink = ctx->outputs[0];
90  static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_GBRP, AV_PIX_FMT_NONE };
91  int ret;
92 
94  if ((ret = ff_formats_ref (formats, &inlink->outcfg.formats )) < 0 ||
96  (ret = ff_channel_layouts_ref (layout , &inlink->outcfg.channel_layouts)) < 0)
97  return ret;
98 
100  if ((ret = ff_formats_ref(formats, &inlink->outcfg.samplerates)) < 0)
101  return ret;
102 
104  if ((ret = ff_formats_ref(formats, &outlink->incfg.formats)) < 0)
105  return ret;
106 
107  return 0;
108 }
109 
110 static int run_channel_fft(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
111 {
112  ShowSpatialContext *s = ctx->priv;
113  const float *window_func_lut = s->window_func_lut;
114  AVFrame *fin = arg;
115  const int ch = jobnr;
116  const float *p = (float *)fin->extended_data[ch];
117 
118  for (int n = 0; n < fin->nb_samples; n++) {
119  s->fft_tdata[ch][n].re = p[n] * window_func_lut[n];
120  s->fft_tdata[ch][n].im = 0.f;
121  }
122 
123  s->tx_fn[ch](s->fft[ch], s->fft_data[ch], s->fft_tdata[ch], sizeof(AVComplexFloat));
124 
125  return 0;
126 }
127 
128 static int config_output(AVFilterLink *outlink)
129 {
130  FilterLink *l = ff_filter_link(outlink);
131  AVFilterContext *ctx = outlink->src;
132  AVFilterLink *inlink = ctx->inputs[0];
133  ShowSpatialContext *s = ctx->priv;
134  float overlap;
135  int ret;
136 
137  outlink->w = s->w;
138  outlink->h = s->h;
139  outlink->sample_aspect_ratio = (AVRational){1,1};
140 
141  l->frame_rate = s->frame_rate;
142  outlink->time_base = av_inv_q(l->frame_rate);
143 
144  /* (re-)configuration if the video output changed (or first init) */
145  if (s->win_size != s->buf_size) {
146  s->buf_size = s->win_size;
147 
148  /* FFT buffers: x2 for each channel buffer.
149  * Note: we use free and malloc instead of a realloc-like function to
150  * make sure the buffer is aligned in memory for the FFT functions. */
151  for (int i = 0; i < 2; i++) {
152  av_tx_uninit(&s->fft[i]);
153  av_freep(&s->fft_data[i]);
154  av_freep(&s->fft_tdata[i]);
155  }
156  for (int i = 0; i < 2; i++) {
157  float scale = 1.f;
158  ret = av_tx_init(&s->fft[i], &s->tx_fn[i], AV_TX_FLOAT_FFT,
159  0, s->win_size, &scale, 0);
160  if (ret < 0)
161  return ret;
162  }
163 
164  for (int i = 0; i < 2; i++) {
165  s->fft_tdata[i] = av_calloc(s->buf_size, sizeof(**s->fft_tdata));
166  if (!s->fft_tdata[i])
167  return AVERROR(ENOMEM);
168 
169  s->fft_data[i] = av_calloc(s->buf_size, sizeof(**s->fft_data));
170  if (!s->fft_data[i])
171  return AVERROR(ENOMEM);
172  }
173 
174  /* pre-calc windowing function */
175  s->window_func_lut =
176  av_realloc_f(s->window_func_lut, s->win_size,
177  sizeof(*s->window_func_lut));
178  if (!s->window_func_lut)
179  return AVERROR(ENOMEM);
180  generate_window_func(s->window_func_lut, s->win_size, s->win_func, &overlap);
181 
182  s->hop_size = FFMAX(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
183  }
184 
185  av_audio_fifo_free(s->fifo);
186  s->fifo = av_audio_fifo_alloc(inlink->format, inlink->ch_layout.nb_channels, s->win_size);
187  if (!s->fifo)
188  return AVERROR(ENOMEM);
189  return 0;
190 }
191 
192 #define RE(y, ch) s->fft_data[ch][y].re
193 #define IM(y, ch) s->fft_data[ch][y].im
194 
195 static void draw_dot(uint8_t *dst, int linesize, int value)
196 {
197  dst[0] = value;
198  dst[1] = value;
199  dst[-1] = value;
200  dst[linesize] = value;
201  dst[-linesize] = value;
202 }
203 
204 static int draw_spatial(AVFilterLink *inlink, AVFrame *insamples)
205 {
206  AVFilterContext *ctx = inlink->dst;
207  AVFilterLink *outlink = ctx->outputs[0];
208  ShowSpatialContext *s = ctx->priv;
209  AVFrame *outpicref;
210  int h = s->h - 2;
211  int w = s->w - 2;
212  int z = s->win_size / 2;
213  int64_t pts = av_rescale_q(insamples->pts, inlink->time_base, outlink->time_base);
214 
215  outpicref = ff_get_video_buffer(outlink, outlink->w, outlink->h);
216  if (!outpicref)
217  return AVERROR(ENOMEM);
218 
219  outpicref->sample_aspect_ratio = (AVRational){1,1};
220  for (int i = 0; i < outlink->h; i++) {
221  memset(outpicref->data[0] + i * outpicref->linesize[0], 0, outlink->w);
222  memset(outpicref->data[1] + i * outpicref->linesize[1], 0, outlink->w);
223  memset(outpicref->data[2] + i * outpicref->linesize[2], 0, outlink->w);
224  }
225 
226  for (int j = 0; j < z; j++) {
227  const int idx = z - 1 - j;
228  float l = hypotf(RE(idx, 0), IM(idx, 0));
229  float r = hypotf(RE(idx, 1), IM(idx, 1));
230  float sum = l + r;
231  float lp = atan2f(IM(idx, 0), RE(idx, 0));
232  float rp = atan2f(IM(idx, 1), RE(idx, 1));
233  float diffp = ((rp - lp) / (2.f * M_PI) + 1.f) * 0.5f;
234  float diff = (sum < 0.000001f ? 0.f : (r - l) / sum) * 0.5f + 0.5f;
235  float cr = av_clipf(cbrtf(l / sum), 0, 1) * 255.f;
236  float cb = av_clipf(cbrtf(r / sum), 0, 1) * 255.f;
237  float cg;
238  int x, y;
239 
240  cg = diffp * 255.f;
241  x = av_clip(w * diff, 0, w - 2) + 1;
242  y = av_clip(h * diffp, 0, h - 2) + 1;
243 
244  draw_dot(outpicref->data[0] + outpicref->linesize[0] * y + x, outpicref->linesize[0], cg);
245  draw_dot(outpicref->data[1] + outpicref->linesize[1] * y + x, outpicref->linesize[1], cb);
246  draw_dot(outpicref->data[2] + outpicref->linesize[2] * y + x, outpicref->linesize[2], cr);
247  }
248 
249  outpicref->pts = pts;
250  outpicref->duration = 1;
251 
252  return ff_filter_frame(outlink, outpicref);
253 }
254 
256 {
257  AVFilterLink *inlink = ctx->inputs[0];
258  AVFilterLink *outlink = ctx->outputs[0];
259  ShowSpatialContext *s = ctx->priv;
260  int ret;
261 
263 
264  if (av_audio_fifo_size(s->fifo) < s->win_size) {
265  AVFrame *frame = NULL;
266 
268  if (ret < 0)
269  return ret;
270  if (ret > 0) {
271  s->pts = frame->pts;
272  s->consumed = 0;
273 
274  av_audio_fifo_write(s->fifo, (void **)frame->extended_data, frame->nb_samples);
276  }
277  }
278 
279  if (av_audio_fifo_size(s->fifo) >= s->win_size) {
280  AVFrame *fin = ff_get_audio_buffer(inlink, s->win_size);
281  if (!fin)
282  return AVERROR(ENOMEM);
283 
284  fin->pts = s->pts + s->consumed;
285  s->consumed += s->hop_size;
286  ret = av_audio_fifo_peek(s->fifo, (void **)fin->extended_data,
287  FFMIN(s->win_size, av_audio_fifo_size(s->fifo)));
288  if (ret < 0) {
289  av_frame_free(&fin);
290  return ret;
291  }
292 
293  av_assert0(fin->nb_samples == s->win_size);
294 
296 
297  ret = draw_spatial(inlink, fin);
298 
299  av_frame_free(&fin);
300  av_audio_fifo_drain(s->fifo, s->hop_size);
301  if (ret <= 0)
302  return ret;
303  }
304 
306  if (ff_outlink_frame_wanted(outlink) && av_audio_fifo_size(s->fifo) < s->win_size) {
308  return 0;
309  }
310 
311  if (av_audio_fifo_size(s->fifo) >= s->win_size) {
313  return 0;
314  }
315  return FFERROR_NOT_READY;
316 }
317 
319  {
320  .name = "default",
321  .type = AVMEDIA_TYPE_VIDEO,
322  .config_props = config_output,
323  },
324 };
325 
327  .name = "showspatial",
328  .description = NULL_IF_CONFIG_SMALL("Convert input audio to a spatial video output."),
329  .uninit = uninit,
330  .priv_size = sizeof(ShowSpatialContext),
334  .activate = spatial_activate,
335  .priv_class = &showspatial_class,
337 };
av_audio_fifo_free
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
Definition: audio_fifo.c:48
formats
formats
Definition: signature.h:47
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:116
ff_get_audio_buffer
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:98
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
AVFilterChannelLayouts
A list of supported channel layouts.
Definition: formats.h:85
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
showspatial_outputs
static const AVFilterPad showspatial_outputs[]
Definition: avf_showspatial.c:318
ShowSpatialContext::hop_size
int hop_size
Definition: avf_showspatial.c:49
av_clip
#define av_clip
Definition: common.h:100
r
const char * r
Definition: vf_curves.c:127
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:435
AV_CHANNEL_LAYOUT_STEREO
#define AV_CHANNEL_LAYOUT_STEREO
Definition: channel_layout.h:387
cb
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:247
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1023
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:948
AVFrame::duration
int64_t duration
Duration of the frame, in the same units as pts.
Definition: frame.h:780
ff_channel_layouts_ref
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:673
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition: opt.h:315
av_audio_fifo_write
int av_audio_fifo_write(AVAudioFifo *af, void *const *data, int nb_samples)
Write data to an AVAudioFifo.
Definition: audio_fifo.c:119
AVTXContext
Definition: tx_priv.h:235
atan2f
#define atan2f(y, x)
Definition: libm.h:45
int64_t
long long int64_t
Definition: coverity.c:34
spatial_activate
static int spatial_activate(AVFilterContext *ctx)
Definition: avf_showspatial.c:255
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:160
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:374
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:486
w
uint8_t w
Definition: llviddspenc.c:38
AVOption
AVOption.
Definition: opt.h:429
ShowSpatialContext::window_func_lut
float * window_func_lut
Window function LUT.
Definition: avf_showspatial.c:43
AVComplexFloat
Definition: tx.h:27
WIN_FUNC_OPTION
#define WIN_FUNC_OPTION(win_func_opt_name, win_func_offset, flag, default_window_func)
Definition: window_func.h:37
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
ShowSpatialContext::frame_rate
AVRational frame_rate
Definition: avf_showspatial.c:39
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:205
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: avf_showspatial.c:69
video.h
FF_FILTER_FORWARD_STATUS_BACK
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
Definition: filters.h:434
av_tx_init
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...
Definition: tx.c:903
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:395
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
ff_inlink_consume_frame
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Definition: avfilter.c:1451
AVAudioFifo
Context for an Audio FIFO Buffer.
Definition: audio_fifo.c:37
RE
#define RE(y, ch)
Definition: avf_showspatial.c:192
av_audio_fifo_drain
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples)
Drain data from an AVAudioFifo.
Definition: audio_fifo.c:195
pts
static int64_t pts
Definition: transcode_aac.c:644
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:38
avassert.h
av_cold
#define av_cold
Definition: attributes.h:90
showspatial_options
static const AVOption showspatial_options[]
Definition: avf_showspatial.c:57
av_tx_fn
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
Definition: tx.h:151
ShowSpatialContext::consumed
int consumed
Definition: avf_showspatial.c:48
ff_inlink_request_frame
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1578
s
#define s(width, name)
Definition: cbs_vp9.c:198
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:678
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
filters.h
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:304
AV_TX_FLOAT_FFT
@ AV_TX_FLOAT_FFT
Standard complex to complex FFT with sample data type of AVComplexFloat, AVComplexDouble or AVComplex...
Definition: tx.h:47
ctx
AVFormatContext * ctx
Definition: movenc.c:49
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
FLAGS
#define FLAGS
Definition: avf_showspatial.c:55
OFFSET
#define OFFSET(x)
Definition: avf_showspatial.c:54
ShowSpatialContext
Definition: avf_showspatial.c:36
arg
const char * arg
Definition: jacosubdec.c:67
av_realloc_f
#define av_realloc_f(p, o, n)
Definition: tableprint_vlc.h:32
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
av_audio_fifo_alloc
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
Definition: audio_fifo.c:62
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition: opt.h:303
ff_audio_default_filterpad
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
Definition: audio.c:34
generate_window_func
static void generate_window_func(float *lut, int N, int win_func, float *overlap)
Definition: window_func.h:63
WFUNC_HANNING
@ WFUNC_HANNING
Definition: window_func.h:29
av_clipf
av_clipf
Definition: af_crystalizer.c:122
ShowSpatialContext::fft_tdata
AVComplexFloat * fft_tdata[2]
bins holder for each (displayed) channels
Definition: avf_showspatial.c:42
ff_add_channel_layout
int ff_add_channel_layout(AVFilterChannelLayouts **l, const AVChannelLayout *channel_layout)
Definition: formats.c:521
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:197
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(showspatial)
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: avf_showspatial.c:83
f
f
Definition: af_crystalizer.c:122
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:311
ShowSpatialContext::buf_size
int buf_size
Definition: avf_showspatial.c:47
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
ShowSpatialContext::fifo
AVAudioFifo * fifo
Definition: avf_showspatial.c:50
ShowSpatialContext::h
int h
Definition: avf_showspatial.c:38
diff
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
Definition: vf_paletteuse.c:164
ShowSpatialContext::win_size
int win_size
Definition: avf_showspatial.c:46
av_audio_fifo_peek
int av_audio_fifo_peek(const AVAudioFifo *af, void *const *data, int nb_samples)
Peek data from an AVAudioFifo.
Definition: audio_fifo.c:145
run_channel_fft
static int run_channel_fft(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: avf_showspatial.c:110
av_audio_fifo_size
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
Definition: audio_fifo.c:222
M_PI
#define M_PI
Definition: mathematics.h:67
av_tx_uninit
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
Definition: tx.c:295
layout
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel layout
Definition: filter_design.txt:18
IM
#define IM(y, ch)
Definition: avf_showspatial.c:193
ShowSpatialContext::tx_fn
av_tx_fn tx_fn[2]
Definition: avf_showspatial.c:44
ShowSpatialContext::pts
int64_t pts
Definition: avf_showspatial.c:51
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:454
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:435
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
cbrtf
static av_always_inline float cbrtf(float x)
Definition: libm.h:61
audio_fifo.h
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:44
av_rescale
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:129
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:264
AVFilter
Filter definition.
Definition: avfilter.h:201
ret
ret
Definition: filter_design.txt:187
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
AVFrame::sample_aspect_ratio
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition: frame.h:481
window_func.h
ff_all_samplerates
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:606
channel_layout.h
ff_filter_execute
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: avfilter.c:1651
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avfilter.h
draw_dot
static void draw_dot(uint8_t *dst, int linesize, int value)
Definition: avf_showspatial.c:195
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:152
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
mem.h
audio.h
ShowSpatialContext::fft_data
AVComplexFloat * fft_data[2]
bins holder for each (displayed) channels
Definition: avf_showspatial.c:41
AVFilterFormatsConfig::formats
AVFilterFormats * formats
List of supported formats (pixel or sample).
Definition: avfilter.h:116
ff_avf_showspatial
const AVFilter ff_avf_showspatial
Definition: avf_showspatial.c:326
ShowSpatialContext::fft
AVTXContext * fft[2]
Fast Fourier Transform context.
Definition: avf_showspatial.c:40
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:291
FF_FILTER_FORWARD_STATUS
FF_FILTER_FORWARD_STATUS(inlink, outlink)
cr
static double cr(void *priv, double x, double y)
Definition: vf_geq.c:248
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
draw_spatial
static int draw_spatial(AVFilterLink *inlink, AVFrame *insamples)
Definition: avf_showspatial.c:204
ShowSpatialContext::win_func
int win_func
Definition: avf_showspatial.c:45
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:419
h
h
Definition: vp9dsp_template.c:2070
ff_outlink_frame_wanted
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: filters.h:236
config_output
static int config_output(AVFilterLink *outlink)
Definition: avf_showspatial.c:128
ff_filter_set_ready
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
Definition: avfilter.c:237
tx.h
ShowSpatialContext::w
int w
Definition: avf_showspatial.c:38