FFmpeg
avf_avectorscope.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 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 /**
22  * @file
23  * audio to video multimedia vectorscope filter
24  */
25 
26 #include "libavutil/avassert.h"
28 #include "libavutil/opt.h"
29 #include "libavutil/parseutils.h"
30 #include "avfilter.h"
31 #include "filters.h"
32 #include "formats.h"
33 #include "audio.h"
34 #include "video.h"
35 #include "internal.h"
36 
42 };
43 
45  DOT,
48 };
49 
51  LIN,
54  LOG,
56 };
57 
58 typedef struct AudioVectorScopeContext {
59  const AVClass *class;
61  int w, h;
62  int hw, hh;
63  int mode;
64  int draw;
65  int scale;
66  int contrast[4];
67  int fade[4];
68  double zoom;
69  int swap;
70  int mirror;
71  unsigned prev_x, prev_y;
75 
76 #define OFFSET(x) offsetof(AudioVectorScopeContext, x)
77 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
78 
79 static const AVOption avectorscope_options[] = {
80  { "mode", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=LISSAJOUS}, 0, MODE_NB-1, FLAGS, "mode" },
81  { "m", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=LISSAJOUS}, 0, MODE_NB-1, FLAGS, "mode" },
82  { "lissajous", "", 0, AV_OPT_TYPE_CONST, {.i64=LISSAJOUS}, 0, 0, FLAGS, "mode" },
83  { "lissajous_xy", "", 0, AV_OPT_TYPE_CONST, {.i64=LISSAJOUS_XY}, 0, 0, FLAGS, "mode" },
84  { "polar", "", 0, AV_OPT_TYPE_CONST, {.i64=POLAR}, 0, 0, FLAGS, "mode" },
85  { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
86  { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
87  { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="400x400"}, 0, 0, FLAGS },
88  { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="400x400"}, 0, 0, FLAGS },
89  { "rc", "set red contrast", OFFSET(contrast[0]), AV_OPT_TYPE_INT, {.i64=40}, 0, 255, FLAGS },
90  { "gc", "set green contrast", OFFSET(contrast[1]), AV_OPT_TYPE_INT, {.i64=160}, 0, 255, FLAGS },
91  { "bc", "set blue contrast", OFFSET(contrast[2]), AV_OPT_TYPE_INT, {.i64=80}, 0, 255, FLAGS },
92  { "ac", "set alpha contrast", OFFSET(contrast[3]), AV_OPT_TYPE_INT, {.i64=255}, 0, 255, FLAGS },
93  { "rf", "set red fade", OFFSET(fade[0]), AV_OPT_TYPE_INT, {.i64=15}, 0, 255, FLAGS },
94  { "gf", "set green fade", OFFSET(fade[1]), AV_OPT_TYPE_INT, {.i64=10}, 0, 255, FLAGS },
95  { "bf", "set blue fade", OFFSET(fade[2]), AV_OPT_TYPE_INT, {.i64=5}, 0, 255, FLAGS },
96  { "af", "set alpha fade", OFFSET(fade[3]), AV_OPT_TYPE_INT, {.i64=5}, 0, 255, FLAGS },
97  { "zoom", "set zoom factor", OFFSET(zoom), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 10, FLAGS },
98  { "draw", "set draw mode", OFFSET(draw), AV_OPT_TYPE_INT, {.i64=DOT}, 0, DRAW_NB-1, FLAGS, "draw" },
99  { "dot", "", 0, AV_OPT_TYPE_CONST, {.i64=DOT} , 0, 0, FLAGS, "draw" },
100  { "line", "", 0, AV_OPT_TYPE_CONST, {.i64=LINE}, 0, 0, FLAGS, "draw" },
101  { "scale", "set amplitude scale mode", OFFSET(scale), AV_OPT_TYPE_INT, {.i64=LIN}, 0, SCALE_NB-1, FLAGS, "scale" },
102  { "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=LIN}, 0, 0, FLAGS, "scale" },
103  { "sqrt", "square root", 0, AV_OPT_TYPE_CONST, {.i64=SQRT}, 0, 0, FLAGS, "scale" },
104  { "cbrt", "cube root", 0, AV_OPT_TYPE_CONST, {.i64=CBRT}, 0, 0, FLAGS, "scale" },
105  { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=LOG}, 0, 0, FLAGS, "scale" },
106  { "swap", "swap x axis with y axis", OFFSET(swap), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS },
107  { "mirror", "mirror axis", OFFSET(mirror), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS, "mirror" },
108  { "none", "no mirror", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "mirror" },
109  { "x", "mirror x", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "mirror" },
110  { "y", "mirror y", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "mirror" },
111  { "xy", "mirror both", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, FLAGS, "mirror" },
112  { NULL }
113 };
114 
115 AVFILTER_DEFINE_CLASS(avectorscope);
116 
117 static void draw_dot(AudioVectorScopeContext *s, unsigned x, unsigned y)
118 {
119  const int linesize = s->outpicref->linesize[0];
120  uint8_t *dst;
121 
122  if (s->zoom > 1) {
123  if (y >= s->h || x >= s->w)
124  return;
125  } else {
126  y = FFMIN(y, s->h - 1);
127  x = FFMIN(x, s->w - 1);
128  }
129 
130  dst = &s->outpicref->data[0][y * linesize + x * 4];
131  dst[0] = FFMIN(dst[0] + s->contrast[0], 255);
132  dst[1] = FFMIN(dst[1] + s->contrast[1], 255);
133  dst[2] = FFMIN(dst[2] + s->contrast[2], 255);
134  dst[3] = FFMIN(dst[3] + s->contrast[3], 255);
135 }
136 
137 static void draw_line(AudioVectorScopeContext *s, int x0, int y0, int x1, int y1)
138 {
139  int dx = FFABS(x1-x0), sx = x0 < x1 ? 1 : -1;
140  int dy = FFABS(y1-y0), sy = y0 < y1 ? 1 : -1;
141  int err = (dx>dy ? dx : -dy) / 2, e2;
142 
143  for (;;) {
144  draw_dot(s, x0, y0);
145 
146  if (x0 == x1 && y0 == y1)
147  break;
148 
149  e2 = err;
150 
151  if (e2 >-dx) {
152  err -= dy;
153  x0 += sx;
154  }
155 
156  if (e2 < dy) {
157  err += dx;
158  y0 += sy;
159  }
160  }
161 }
162 
164 {
165  const int linesize = s->outpicref->linesize[0];
166  int i, j;
167 
168  if (s->fade[0] || s->fade[1] || s->fade[2]) {
169  uint8_t *d = s->outpicref->data[0];
170  for (i = 0; i < s->h; i++) {
171  for (j = 0; j < s->w*4; j+=4) {
172  d[j+0] = FFMAX(d[j+0] - s->fade[0], 0);
173  d[j+1] = FFMAX(d[j+1] - s->fade[1], 0);
174  d[j+2] = FFMAX(d[j+2] - s->fade[2], 0);
175  d[j+3] = FFMAX(d[j+3] - s->fade[3], 0);
176  }
177  d += linesize;
178  }
179  }
180 }
181 
183 {
186  AVFilterLink *inlink = ctx->inputs[0];
187  AVFilterLink *outlink = ctx->outputs[0];
189  static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE };
190  int ret;
191 
193  if ((ret = ff_formats_ref (formats, &inlink->outcfg.formats )) < 0 ||
195  (ret = ff_channel_layouts_ref (layout , &inlink->outcfg.channel_layouts)) < 0)
196  return ret;
197 
199  if ((ret = ff_formats_ref(formats, &inlink->outcfg.samplerates)) < 0)
200  return ret;
201 
203  if ((ret = ff_formats_ref(formats, &outlink->incfg.formats)) < 0)
204  return ret;
205 
206  return 0;
207 }
208 
210 {
211  AVFilterContext *ctx = inlink->dst;
212  AudioVectorScopeContext *s = ctx->priv;
213 
214  s->nb_samples = FFMAX(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
215 
216  return 0;
217 }
218 
219 static int config_output(AVFilterLink *outlink)
220 {
221  AudioVectorScopeContext *s = outlink->src->priv;
222 
223  outlink->w = s->w;
224  outlink->h = s->h;
225  outlink->sample_aspect_ratio = (AVRational){1,1};
226  outlink->frame_rate = s->frame_rate;
227 
228  s->prev_x = s->hw = s->w / 2;
229  s->prev_y = s->hh = s->mode == POLAR ? s->h - 1 : s->h / 2;
230 
231  return 0;
232 }
233 
234 static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
235 {
236  AVFilterContext *ctx = inlink->dst;
237  AVFilterLink *outlink = ctx->outputs[0];
238  AudioVectorScopeContext *s = ctx->priv;
239  const int hw = s->hw;
240  const int hh = s->hh;
241  AVFrame *clone;
242  unsigned x, y;
243  unsigned prev_x = s->prev_x, prev_y = s->prev_y;
244  double zoom = s->zoom;
245  int i;
246 
247  if (!s->outpicref || s->outpicref->width != outlink->w ||
248  s->outpicref->height != outlink->h) {
249  av_frame_free(&s->outpicref);
250  s->outpicref = ff_get_video_buffer(outlink, outlink->w, outlink->h);
251  if (!s->outpicref) {
252  av_frame_free(&insamples);
253  return AVERROR(ENOMEM);
254  }
255 
256  s->outpicref->sample_aspect_ratio = (AVRational){1,1};
257  for (i = 0; i < outlink->h; i++)
258  memset(s->outpicref->data[0] + i * s->outpicref->linesize[0], 0, outlink->w * 4);
259  }
260  s->outpicref->pts = insamples->pts;
261 
262  fade(s);
263 
264  if (zoom < 1) {
265  float max = 0;
266 
267  switch (insamples->format) {
268  case AV_SAMPLE_FMT_S16: {
269  int16_t *samples = (int16_t *)insamples->data[0];
270 
271  for (i = 0; i < insamples->nb_samples * 2; i++) {
272  float sample = samples[i] / (float)INT16_MAX;
273  max = FFMAX(FFABS(sample), max);
274  }
275 
276  }
277  break;
278  case AV_SAMPLE_FMT_FLT: {
279  float *samples = (float *)insamples->data[0];
280 
281  for (i = 0; i < insamples->nb_samples * 2; i++) {
282  max = FFMAX(FFABS(samples[i]), max);
283  }
284  }
285  break;
286  default:
287  av_assert2(0);
288  }
289 
290  zoom = 1. / max;
291  }
292 
293  for (i = 0; i < insamples->nb_samples; i++) {
294  int16_t *samples = (int16_t *)insamples->data[0] + i * 2;
295  float *samplesf = (float *)insamples->data[0] + i * 2;
296  float src[2];
297 
298  switch (insamples->format) {
299  case AV_SAMPLE_FMT_S16:
300  src[0] = samples[0] / (float)INT16_MAX;
301  src[1] = samples[1] / (float)INT16_MAX;
302  break;
303  case AV_SAMPLE_FMT_FLT:
304  src[0] = samplesf[0];
305  src[1] = samplesf[1];
306  break;
307  default:
308  av_assert2(0);
309  }
310 
311  switch (s->scale) {
312  case SQRT:
313  src[0] = FFSIGN(src[0]) * sqrtf(FFABS(src[0]));
314  src[1] = FFSIGN(src[1]) * sqrtf(FFABS(src[1]));
315  break;
316  case CBRT:
317  src[0] = FFSIGN(src[0]) * cbrtf(FFABS(src[0]));
318  src[1] = FFSIGN(src[1]) * cbrtf(FFABS(src[1]));
319  break;
320  case LOG:
321  src[0] = FFSIGN(src[0]) * logf(1 + FFABS(src[0])) / logf(2);
322  src[1] = FFSIGN(src[1]) * logf(1 + FFABS(src[1])) / logf(2);
323  break;
324  }
325 
326  if (s->mirror & 1)
327  src[0] = -src[0];
328 
329  if (s->mirror & 2)
330  src[1] = -src[1];
331 
332  if (s->swap)
333  FFSWAP(float, src[0], src[1]);
334 
335  if (s->mode == LISSAJOUS) {
336  x = ((src[1] - src[0]) * zoom / 2 + 1) * hw;
337  y = (1.0 - (src[0] + src[1]) * zoom / 2) * hh;
338  } else if (s->mode == LISSAJOUS_XY) {
339  x = (src[1] * zoom + 1) * hw;
340  y = (src[0] * zoom + 1) * hh;
341  } else {
342  float sx, sy, cx, cy;
343 
344  sx = src[1] * zoom;
345  sy = src[0] * zoom;
346  cx = sx * sqrtf(1 - 0.5 * sy * sy);
347  cy = sy * sqrtf(1 - 0.5 * sx * sx);
348  x = hw + hw * FFSIGN(cx + cy) * (cx - cy) * .7;
349  y = s->h - s->h * fabsf(cx + cy) * .7;
350  }
351 
352  if (s->draw == DOT) {
353  draw_dot(s, x, y);
354  } else {
355  draw_line(s, x, y, prev_x, prev_y);
356  }
357  prev_x = x;
358  prev_y = y;
359  }
360 
361  s->prev_x = x, s->prev_y = y;
362  av_frame_free(&insamples);
363 
364  clone = av_frame_clone(s->outpicref);
365  if (!clone)
366  return AVERROR(ENOMEM);
367 
368  return ff_filter_frame(outlink, clone);
369 }
370 
372 {
373  AVFilterLink *inlink = ctx->inputs[0];
374  AVFilterLink *outlink = ctx->outputs[0];
375  AudioVectorScopeContext *s = ctx->priv;
376  AVFrame *in;
377  int ret;
378 
380 
381  ret = ff_inlink_consume_samples(inlink, s->nb_samples, s->nb_samples, &in);
382  if (ret < 0)
383  return ret;
384  if (ret > 0)
385  return filter_frame(inlink, in);
386 
389 
390  return FFERROR_NOT_READY;
391 }
392 
394 {
395  AudioVectorScopeContext *s = ctx->priv;
396 
397  av_frame_free(&s->outpicref);
398 }
399 
401  {
402  .name = "default",
403  .type = AVMEDIA_TYPE_AUDIO,
404  .config_props = config_input,
405  },
406  { NULL }
407 };
408 
410  {
411  .name = "default",
412  .type = AVMEDIA_TYPE_VIDEO,
413  .config_props = config_output,
414  },
415  { NULL }
416 };
417 
419  .name = "avectorscope",
420  .description = NULL_IF_CONFIG_SMALL("Convert input audio to vectorscope video output."),
421  .uninit = uninit,
422  .query_formats = query_formats,
423  .priv_size = sizeof(AudioVectorScopeContext),
424  .activate = activate,
427  .priv_class = &avectorscope_class,
428 };
AudioVectorScopeContext::draw
int draw
Definition: avf_avectorscope.c:64
formats
formats
Definition: signature.h:48
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:99
AVFilterChannelLayouts
A list of supported channel layouts.
Definition: formats.h:86
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
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:286
FFSWAP
#define FFSWAP(type, a, b)
Definition: common.h:108
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1096
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:925
ff_channel_layouts_ref
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:461
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
Definition: opt.h:238
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
DRAW_NB
@ DRAW_NB
Definition: avf_avectorscope.c:47
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
VectorScopeScale
VectorScopeScale
Definition: avf_avectorscope.c:50
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:411
w
uint8_t w
Definition: llviddspenc.c:39
AVOption
AVOption.
Definition: opt.h:248
AudioVectorScopeContext::frame_rate
AVRational frame_rate
Definition: avf_avectorscope.c:72
max
#define max(a, b)
Definition: cuda_runtime.h:33
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:149
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:199
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:332
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:65
formats.h
LISSAJOUS_XY
@ LISSAJOUS_XY
Definition: avf_avectorscope.c:39
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:356
AudioVectorScopeContext::hw
int hw
Definition: avf_avectorscope.c:62
FFSIGN
#define FFSIGN(a)
Definition: common.h:73
AudioVectorScopeContext::hh
int hh
Definition: avf_avectorscope.c:62
OFFSET
#define OFFSET(x)
Definition: avf_avectorscope.c:76
fabsf
static __device__ float fabsf(float a)
Definition: cuda_runtime.h:181
AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_STEREO
Definition: channel_layout.h:91
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
LIN
@ LIN
Definition: avf_avectorscope.c:51
CBRT
@ CBRT
Definition: avf_avectorscope.c:53
avassert.h
av_cold
#define av_cold
Definition: attributes.h:90
AudioVectorScopeContext::fade
int fade[4]
Definition: avf_avectorscope.c:67
SQRT
@ SQRT
Definition: avf_avectorscope.c:52
ff_add_channel_layout
int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout)
Definition: formats.c:338
AudioVectorScopeContext::nb_samples
int nb_samples
Definition: avf_avectorscope.c:73
s
#define s(width, name)
Definition: cbs_vp9.c:257
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:227
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:466
AudioVectorScopeContext::contrast
int contrast[4]
Definition: avf_avectorscope.c:66
AudioVectorScopeContext::mode
int mode
Definition: avf_avectorscope.c:63
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
filters.h
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:309
ctx
AVFormatContext * ctx
Definition: movenc.c:48
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:540
AudioVectorScopeContext::zoom
double zoom
Definition: avf_avectorscope.c:68
draw_line
static void draw_line(AudioVectorScopeContext *s, int x0, int y0, int x1, int y1)
Definition: avf_avectorscope.c:137
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
ff_inlink_consume_samples
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
Definition: avfilter.c:1513
NULL
#define NULL
Definition: coverity.c:32
LOG
@ LOG
Definition: avf_avectorscope.c:54
config_input
static int config_input(AVFilterLink *inlink)
Definition: avf_avectorscope.c:209
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:235
AudioVectorScopeContext::mirror
int mirror
Definition: avf_avectorscope.c:70
DOT
@ DOT
Definition: avf_avectorscope.c:45
VectorScopeDraw
VectorScopeDraw
Definition: avf_avectorscope.c:44
src
#define src
Definition: vp8dsp.c:255
parseutils.h
AudioVectorScopeContext::prev_x
unsigned prev_x
Definition: avf_avectorscope.c:71
inputs
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 inputs
Definition: filter_design.txt:243
LISSAJOUS
@ LISSAJOUS
Definition: avf_avectorscope.c:38
for
for(j=16;j >0;--j)
Definition: h264pred_template.c:469
AudioVectorScopeContext::h
int h
Definition: avf_avectorscope.c:61
AudioVectorScopeContext
Definition: avf_avectorscope.c:58
mirror
static void mirror(const float *modifier, float *vec)
Definition: vf_v360.c:3945
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:117
FFMAX
#define FFMAX(a, b)
Definition: common.h:103
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
sample
#define sample
Definition: flacdsp_template.c:44
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:391
LINE
@ LINE
Definition: avf_avectorscope.c:46
FFMIN
#define FFMIN(a, b)
Definition: common.h:105
FF_FILTER_FORWARD_WANTED
FF_FILTER_FORWARD_WANTED(outlink, inlink)
audiovectorscope_inputs
static const AVFilterPad audiovectorscope_inputs[]
Definition: avf_avectorscope.c:400
AudioVectorScopeContext::swap
int swap
Definition: avf_avectorscope.c:69
internal.h
AudioVectorScopeContext::scale
int scale
Definition: avf_avectorscope.c:65
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
in
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Definition: audio_convert.c:326
av_assert2
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:64
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:384
MODE_NB
@ MODE_NB
Definition: avf_avectorscope.c:41
i
int i
Definition: input.c:407
draw_dot
static void draw_dot(AudioVectorScopeContext *s, unsigned x, unsigned y)
Definition: avf_avectorscope.c:117
FLAGS
#define FLAGS
Definition: avf_avectorscope.c:77
ff_avf_avectorscope
AVFilter ff_avf_avectorscope
Definition: avf_avectorscope.c:418
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
cbrtf
static av_always_inline float cbrtf(float x)
Definition: libm.h:61
uint8_t
uint8_t
Definition: audio_convert.c:194
AudioVectorScopeContext::outpicref
AVFrame * outpicref
Definition: avf_avectorscope.c:60
AV_SAMPLE_FMT_S16
@ AV_SAMPLE_FMT_S16
signed 16 bits
Definition: samplefmt.h:61
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(avectorscope)
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
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
AVFilter
Filter definition.
Definition: avfilter.h:145
VectorScopeMode
VectorScopeMode
Definition: avf_avectorscope.c:37
ret
ret
Definition: filter_design.txt:187
ff_all_samplerates
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:421
channel_layout.h
mode
mode
Definition: ebur128.h:83
config_output
static int config_output(AVFilterLink *outlink)
Definition: avf_avectorscope.c:219
SCALE_NB
@ SCALE_NB
Definition: avf_avectorscope.c:55
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
avfilter.h
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: avf_avectorscope.c:393
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
Definition: avf_avectorscope.c:234
AVFilterContext
An instance of a filter.
Definition: avfilter.h:341
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
POLAR
@ POLAR
Definition: avf_avectorscope.c:40
audio.h
AVFilterFormatsConfig::formats
AVFilterFormats * formats
List of supported formats (pixel or sample).
Definition: avfilter.h:445
avectorscope_options
static const AVOption avectorscope_options[]
Definition: avf_avectorscope.c:79
activate
static int activate(AVFilterContext *ctx)
Definition: avf_avectorscope.c:371
AudioVectorScopeContext::w
int w
Definition: avf_avectorscope.c:61
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: avf_avectorscope.c:182
FF_FILTER_FORWARD_STATUS
FF_FILTER_FORWARD_STATUS(inlink, outlink)
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:242
AudioVectorScopeContext::prev_y
unsigned prev_y
Definition: avf_avectorscope.c:71
audiovectorscope_outputs
static const AVFilterPad audiovectorscope_outputs[]
Definition: avf_avectorscope.c:409
fade
static void fade(AudioVectorScopeContext *s)
Definition: avf_avectorscope.c:163
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
AV_SAMPLE_FMT_FLT
@ AV_SAMPLE_FMT_FLT
float
Definition: samplefmt.h:63