FFmpeg
f_drawgraph.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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 "float.h"
22 
23 #include "libavutil/avstring.h"
24 #include "libavutil/eval.h"
25 #include "libavutil/intreadwrite.h"
26 #include "libavutil/opt.h"
27 #include "avfilter.h"
28 #include "formats.h"
29 #include "internal.h"
30 #include "video.h"
31 
32 typedef struct DrawGraphContext {
33  const AVClass *class;
34 
35  char *key[4];
36  float min, max;
37  char *fg_str[4];
39  uint8_t bg[4];
40  int mode;
41  int slide;
42  int w, h;
43 
45  int x;
46  int prev_y[4];
47  int first[4];
48  float *values[4];
49  int values_size[4];
50  int nb_values;
52 
53 #define OFFSET(x) offsetof(DrawGraphContext, x)
54 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
55 
56 static const AVOption drawgraph_options[] = {
57  { "m1", "set 1st metadata key", OFFSET(key[0]), AV_OPT_TYPE_STRING, {.str=""}, CHAR_MIN, CHAR_MAX, FLAGS },
58  { "fg1", "set 1st foreground color expression", OFFSET(fg_str[0]), AV_OPT_TYPE_STRING, {.str="0xffff0000"}, CHAR_MIN, CHAR_MAX, FLAGS },
59  { "m2", "set 2nd metadata key", OFFSET(key[1]), AV_OPT_TYPE_STRING, {.str=""}, CHAR_MIN, CHAR_MAX, FLAGS },
60  { "fg2", "set 2nd foreground color expression", OFFSET(fg_str[1]), AV_OPT_TYPE_STRING, {.str="0xff00ff00"}, CHAR_MIN, CHAR_MAX, FLAGS },
61  { "m3", "set 3rd metadata key", OFFSET(key[2]), AV_OPT_TYPE_STRING, {.str=""}, CHAR_MIN, CHAR_MAX, FLAGS },
62  { "fg3", "set 3rd foreground color expression", OFFSET(fg_str[2]), AV_OPT_TYPE_STRING, {.str="0xffff00ff"}, CHAR_MIN, CHAR_MAX, FLAGS },
63  { "m4", "set 4th metadata key", OFFSET(key[3]), AV_OPT_TYPE_STRING, {.str=""}, CHAR_MIN, CHAR_MAX, FLAGS },
64  { "fg4", "set 4th foreground color expression", OFFSET(fg_str[3]), AV_OPT_TYPE_STRING, {.str="0xffffff00"}, CHAR_MIN, CHAR_MAX, FLAGS },
65  { "bg", "set background color", OFFSET(bg), AV_OPT_TYPE_COLOR, {.str="white"}, CHAR_MIN, CHAR_MAX, FLAGS },
66  { "min", "set minimal value", OFFSET(min), AV_OPT_TYPE_FLOAT, {.dbl=-1.}, INT_MIN, INT_MAX, FLAGS },
67  { "max", "set maximal value", OFFSET(max), AV_OPT_TYPE_FLOAT, {.dbl=1.}, INT_MIN, INT_MAX, FLAGS },
68  { "mode", "set graph mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=2}, 0, 2, FLAGS, "mode" },
69  {"bar", "draw bars", OFFSET(mode), AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "mode"},
70  {"dot", "draw dots", OFFSET(mode), AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "mode"},
71  {"line", "draw lines", OFFSET(mode), AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "mode"},
72  { "slide", "set slide mode", OFFSET(slide), AV_OPT_TYPE_INT, {.i64=0}, 0, 4, FLAGS, "slide" },
73  {"frame", "draw new frames", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "slide"},
74  {"replace", "replace old columns with new", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "slide"},
75  {"scroll", "scroll from right to left", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "slide"},
76  {"rscroll", "scroll from left to right", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, FLAGS, "slide"},
77  {"picture", "display graph in single frame", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, FLAGS, "slide"},
78  { "size", "set graph size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="900x256"}, 0, 0, FLAGS },
79  { "s", "set graph size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="900x256"}, 0, 0, FLAGS },
80  { NULL }
81 };
82 
83 static const char *const var_names[] = { "MAX", "MIN", "VAL", NULL };
85 
87 {
88  DrawGraphContext *s = ctx->priv;
89  int ret, i;
90 
91  if (s->max <= s->min) {
92  av_log(ctx, AV_LOG_ERROR, "max is same or lower than min\n");
93  return AVERROR(EINVAL);
94  }
95 
96  for (i = 0; i < 4; i++) {
97  if (s->fg_str[i]) {
98  ret = av_expr_parse(&s->fg_expr[i], s->fg_str[i], var_names,
99  NULL, NULL, NULL, NULL, 0, ctx);
100 
101  if (ret < 0)
102  return ret;
103  }
104  }
105 
106  s->first[0] = s->first[1] = s->first[2] = s->first[3] = 1;
107 
108  if (s->slide == 4) {
109  s->values[0] = av_fast_realloc(NULL, &s->values_size[0], 2000);
110  s->values[1] = av_fast_realloc(NULL, &s->values_size[1], 2000);
111  s->values[2] = av_fast_realloc(NULL, &s->values_size[2], 2000);
112  s->values[3] = av_fast_realloc(NULL, &s->values_size[3], 2000);
113 
114  if (!s->values[0] || !s->values[1] ||
115  !s->values[2] || !s->values[3]) {
116  return AVERROR(ENOMEM);
117  }
118  }
119 
120  return 0;
121 }
122 
124 {
125  AVFilterLink *outlink = ctx->outputs[0];
126  static const enum AVPixelFormat pix_fmts[] = {
129  };
130  int ret;
131 
133  if ((ret = ff_formats_ref(fmts_list, &outlink->in_formats)) < 0)
134  return ret;
135 
136  return 0;
137 }
138 
140 {
141  int i, j;
142  int bg = AV_RN32(s->bg);
143 
144  for (i = 0; i < out->height; i++)
145  for (j = 0; j < out->width; j++)
146  AV_WN32(out->data[0] + i * out->linesize[0] + j * 4, bg);
147 }
148 
149 static inline void draw_dot(int fg, int x, int y, AVFrame *out)
150 {
151  AV_WN32(out->data[0] + y * out->linesize[0] + x * 4, fg);
152 }
153 
155 {
156  AVFilterContext *ctx = inlink->dst;
157  DrawGraphContext *s = ctx->priv;
158  AVFilterLink *outlink = ctx->outputs[0];
159  AVDictionary *metadata;
161  AVFrame *out = s->out;
162  int i;
163 
164  if (s->slide == 4 && s->nb_values >= s->values_size[0] / sizeof(float)) {
165  float *ptr;
166 
167  ptr = av_fast_realloc(s->values[0], &s->values_size[0], s->values_size[0] * 2);
168  if (!ptr)
169  return AVERROR(ENOMEM);
170  s->values[0] = ptr;
171 
172  ptr = av_fast_realloc(s->values[1], &s->values_size[1], s->values_size[1] * 2);
173  if (!ptr)
174  return AVERROR(ENOMEM);
175  s->values[1] = ptr;
176 
177  ptr = av_fast_realloc(s->values[2], &s->values_size[2], s->values_size[2] * 2);
178  if (!ptr)
179  return AVERROR(ENOMEM);
180  s->values[2] = ptr;
181 
182  ptr = av_fast_realloc(s->values[3], &s->values_size[3], s->values_size[3] * 2);
183  if (!ptr)
184  return AVERROR(ENOMEM);
185  s->values[3] = ptr;
186  }
187 
188  if (s->slide != 4 || s->nb_values == 0) {
189  if (!s->out || s->out->width != outlink->w ||
190  s->out->height != outlink->h) {
191  av_frame_free(&s->out);
192  s->out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
193  out = s->out;
194  if (!s->out) {
195  av_frame_free(&in);
196  return AVERROR(ENOMEM);
197  }
198 
199  clear_image(s, out, outlink);
200  }
202  }
203 
204  metadata = in->metadata;
205 
206  for (i = 0; i < 4; i++) {
207  double values[VAR_VARS_NB];
208  int j, y, x, old;
209  uint32_t fg, bg;
210  float vf;
211 
212  if (s->slide == 4)
213  s->values[i][s->nb_values] = NAN;
214 
215  e = av_dict_get(metadata, s->key[i], NULL, 0);
216  if (!e || !e->value)
217  continue;
218 
219  if (av_sscanf(e->value, "%f", &vf) != 1)
220  continue;
221 
222  vf = av_clipf(vf, s->min, s->max);
223 
224  if (s->slide == 4) {
225  s->values[i][s->nb_values] = vf;
226  continue;
227  }
228 
229  values[VAR_MIN] = s->min;
230  values[VAR_MAX] = s->max;
231  values[VAR_VAL] = vf;
232 
233  fg = av_expr_eval(s->fg_expr[i], values, NULL);
234  bg = AV_RN32(s->bg);
235 
236  if (i == 0 && (s->x >= outlink->w || s->slide == 3)) {
237  if (s->slide == 0 || s->slide == 1)
238  s->x = 0;
239 
240  if (s->slide == 2) {
241  s->x = outlink->w - 1;
242  for (j = 0; j < outlink->h; j++) {
243  memmove(out->data[0] + j * out->linesize[0] ,
244  out->data[0] + j * out->linesize[0] + 4,
245  (outlink->w - 1) * 4);
246  }
247  } else if (s->slide == 3) {
248  s->x = 0;
249  for (j = 0; j < outlink->h; j++) {
250  memmove(out->data[0] + j * out->linesize[0] + 4,
251  out->data[0] + j * out->linesize[0],
252  (outlink->w - 1) * 4);
253  }
254  } else if (s->slide == 0) {
255  clear_image(s, out, outlink);
256  }
257  }
258 
259  x = s->x;
260  y = (outlink->h - 1) * (1 - ((vf - s->min) / (s->max - s->min)));
261 
262  switch (s->mode) {
263  case 0:
264  if (i == 0 && (s->slide > 0))
265  for (j = 0; j < outlink->h; j++)
266  draw_dot(bg, x, j, out);
267 
268  old = AV_RN32(out->data[0] + y * out->linesize[0] + x * 4);
269  for (j = y; j < outlink->h; j++) {
270  if (old != bg &&
271  (AV_RN32(out->data[0] + j * out->linesize[0] + x * 4) != old) ||
272  AV_RN32(out->data[0] + FFMIN(j+1, outlink->h - 1) * out->linesize[0] + x * 4) != old) {
273  draw_dot(fg, x, j, out);
274  break;
275  }
276  draw_dot(fg, x, j, out);
277  }
278  break;
279  case 1:
280  if (i == 0 && (s->slide > 0))
281  for (j = 0; j < outlink->h; j++)
282  draw_dot(bg, x, j, out);
283  draw_dot(fg, x, y, out);
284  break;
285  case 2:
286  if (s->first[i]) {
287  s->first[i] = 0;
288  s->prev_y[i] = y;
289  }
290 
291  if (i == 0 && (s->slide > 0)) {
292  for (j = 0; j < y; j++)
293  draw_dot(bg, x, j, out);
294  for (j = outlink->h - 1; j > y; j--)
295  draw_dot(bg, x, j, out);
296  }
297  if (y <= s->prev_y[i]) {
298  for (j = y; j <= s->prev_y[i]; j++)
299  draw_dot(fg, x, j, out);
300  } else {
301  for (j = s->prev_y[i]; j <= y; j++)
302  draw_dot(fg, x, j, out);
303  }
304  s->prev_y[i] = y;
305  break;
306  }
307  }
308 
309  s->nb_values++;
310  s->x++;
311 
312  av_frame_free(&in);
313 
314  if (s->slide == 4)
315  return 0;
316 
317  return ff_filter_frame(outlink, av_frame_clone(s->out));
318 }
319 
320 static int request_frame(AVFilterLink *outlink)
321 {
322  AVFilterContext *ctx = outlink->src;
323  DrawGraphContext *s = ctx->priv;
324  AVFrame *out = s->out;
325  int ret, i, k, step, l;
326 
327  ret = ff_request_frame(ctx->inputs[0]);
328 
329  if (s->slide == 4 && ret == AVERROR_EOF && s->nb_values > 0) {
330  s->x = l = 0;
331  step = ceil(s->nb_values / (float)s->w);
332 
333  for (k = 0; k < s->nb_values; k++) {
334  for (i = 0; i < 4; i++) {
335  double values[VAR_VARS_NB];
336  int j, y, x, old;
337  uint32_t fg, bg;
338  float vf = s->values[i][k];
339 
340  if (isnan(vf))
341  continue;
342 
343  values[VAR_MIN] = s->min;
344  values[VAR_MAX] = s->max;
345  values[VAR_VAL] = vf;
346 
347  fg = av_expr_eval(s->fg_expr[i], values, NULL);
348  bg = AV_RN32(s->bg);
349 
350  x = s->x;
351  y = (outlink->h - 1) * (1 - ((vf - s->min) / (s->max - s->min)));
352 
353  switch (s->mode) {
354  case 0:
355  old = AV_RN32(out->data[0] + y * out->linesize[0] + x * 4);
356  for (j = y; j < outlink->h; j++) {
357  if (old != bg &&
358  (AV_RN32(out->data[0] + j * out->linesize[0] + x * 4) != old) ||
359  AV_RN32(out->data[0] + FFMIN(j+1, outlink->h - 1) * out->linesize[0] + x * 4) != old) {
360  draw_dot(fg, x, j, out);
361  break;
362  }
363  draw_dot(fg, x, j, out);
364  }
365  break;
366  case 1:
367  draw_dot(fg, x, y, out);
368  break;
369  case 2:
370  if (s->first[i]) {
371  s->first[i] = 0;
372  s->prev_y[i] = y;
373  }
374 
375  if (y <= s->prev_y[i]) {
376  for (j = y; j <= s->prev_y[i]; j++)
377  draw_dot(fg, x, j, out);
378  } else {
379  for (j = s->prev_y[i]; j <= y; j++)
380  draw_dot(fg, x, j, out);
381  }
382  s->prev_y[i] = y;
383  break;
384  }
385  }
386 
387  l++;
388  if (l >= step) {
389  l = 0;
390  s->x++;
391  }
392  }
393 
394  s->nb_values = 0;
395  out->pts = 0;
396  ret = ff_filter_frame(ctx->outputs[0], s->out);
397  }
398 
399  return ret;
400 }
401 
402 static int config_output(AVFilterLink *outlink)
403 {
404  DrawGraphContext *s = outlink->src->priv;
405 
406  outlink->w = s->w;
407  outlink->h = s->h;
408  outlink->sample_aspect_ratio = (AVRational){1,1};
409 
410  return 0;
411 }
412 
414 {
415  DrawGraphContext *s = ctx->priv;
416  int i;
417 
418  for (i = 0; i < 4; i++)
419  av_expr_free(s->fg_expr[i]);
420 
421  if (s->slide != 4)
422  av_frame_free(&s->out);
423 
424  av_freep(&s->values[0]);
425  av_freep(&s->values[1]);
426  av_freep(&s->values[2]);
427  av_freep(&s->values[3]);
428 }
429 
430 #if CONFIG_DRAWGRAPH_FILTER
431 
432 AVFILTER_DEFINE_CLASS(drawgraph);
433 
434 static const AVFilterPad drawgraph_inputs[] = {
435  {
436  .name = "default",
437  .type = AVMEDIA_TYPE_VIDEO,
438  .filter_frame = filter_frame,
439  },
440  { NULL }
441 };
442 
443 static const AVFilterPad drawgraph_outputs[] = {
444  {
445  .name = "default",
446  .type = AVMEDIA_TYPE_VIDEO,
447  .config_props = config_output,
448  .request_frame = request_frame,
449  },
450  { NULL }
451 };
452 
454  .name = "drawgraph",
455  .description = NULL_IF_CONFIG_SMALL("Draw a graph using input video metadata."),
456  .priv_size = sizeof(DrawGraphContext),
457  .priv_class = &drawgraph_class,
459  .init = init,
460  .uninit = uninit,
461  .inputs = drawgraph_inputs,
462  .outputs = drawgraph_outputs,
463 };
464 
465 #endif // CONFIG_DRAWGRAPH_FILTER
466 
467 #if CONFIG_ADRAWGRAPH_FILTER
468 
469 #define adrawgraph_options drawgraph_options
470 AVFILTER_DEFINE_CLASS(adrawgraph);
471 
472 static const AVFilterPad adrawgraph_inputs[] = {
473  {
474  .name = "default",
475  .type = AVMEDIA_TYPE_AUDIO,
476  .filter_frame = filter_frame,
477  },
478  { NULL }
479 };
480 
481 static const AVFilterPad adrawgraph_outputs[] = {
482  {
483  .name = "default",
484  .type = AVMEDIA_TYPE_VIDEO,
485  .config_props = config_output,
486  .request_frame = request_frame,
487  },
488  { NULL }
489 };
490 
492  .name = "adrawgraph",
493  .description = NULL_IF_CONFIG_SMALL("Draw a graph using input audio metadata."),
494  .priv_size = sizeof(DrawGraphContext),
495  .priv_class = &adrawgraph_class,
497  .init = init,
498  .uninit = uninit,
499  .inputs = adrawgraph_inputs,
500  .outputs = adrawgraph_outputs,
501 };
502 #endif // CONFIG_ADRAWGRAPH_FILTER
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
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: f_drawgraph.c:320
DrawGraphContext::first
int first[4]
Definition: f_drawgraph.c:47
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
DrawGraphContext::prev_y
int prev_y[4]
Definition: f_drawgraph.c:46
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:283
out
FILE * out
Definition: movenc.c:54
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1080
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:55
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: f_drawgraph.c:123
DrawGraphContext::fg_str
char * fg_str[4]
Definition: f_drawgraph.c:37
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
VAR_VAL
@ VAR_VAL
Definition: f_drawgraph.c:84
config_output
static int config_output(AVFilterLink *outlink)
Definition: f_drawgraph.c:402
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:202
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:295
step
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
Definition: rate_distortion.txt:58
w
uint8_t w
Definition: llviddspenc.c:38
AVOption
AVOption.
Definition: opt.h:246
ff_request_frame
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:407
float.h
max
#define max(a, b)
Definition: cuda_runtime.h:33
AVDictionary
Definition: dict.c:30
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:148
video.h
FLAGS
#define FLAGS
Definition: f_drawgraph.c:54
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
av_expr_parse
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
Definition: eval.c:679
DrawGraphContext::min
float min
Definition: f_drawgraph.c:36
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:353
DrawGraphContext::bg
uint8_t bg[4]
Definition: f_drawgraph.c:39
av_expr_free
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition: eval.c:334
draw_dot
static void draw_dot(int fg, int x, int y, AVFrame *out)
Definition: f_drawgraph.c:149
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
av_cold
#define av_cold
Definition: attributes.h:84
av_dict_get
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:40
av_fast_realloc
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
Definition: mem.c:476
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:257
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:440
ff_vf_drawgraph
AVFilter ff_vf_drawgraph
DrawGraphContext::fg_expr
AVExpr * fg_expr[4]
Definition: f_drawgraph.c:38
OFFSET
#define OFFSET(x)
Definition: f_drawgraph.c:53
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:275
ctx
AVFormatContext * ctx
Definition: movenc.c:48
av_expr_eval
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:734
DrawGraphContext::mode
int mode
Definition: f_drawgraph.c:40
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
AVExpr
Definition: eval.c:157
key
const char * key
Definition: hwcontext_opencl.c:168
NAN
#define NAN
Definition: mathematics.h:64
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
av_sscanf
int av_sscanf(const char *string, const char *format,...)
See libc sscanf manual for more information.
Definition: avsscanf.c:962
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
NULL
#define NULL
Definition: coverity.c:32
var_names
static const char *const var_names[]
Definition: f_drawgraph.c:83
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:654
DrawGraphContext
Definition: f_drawgraph.c:32
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
isnan
#define isnan(x)
Definition: libm.h:340
DrawGraphContext::values_size
int values_size[4]
Definition: f_drawgraph.c:49
AV_OPT_TYPE_COLOR
@ AV_OPT_TYPE_COLOR
Definition: opt.h:238
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:233
VAR_MIN
@ VAR_MIN
Definition: f_drawgraph.c:84
DrawGraphContext::key
char * key[4]
Definition: f_drawgraph.c:35
AV_RN32
#define AV_RN32(p)
Definition: intreadwrite.h:364
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
VAR_MAX
@ VAR_MAX
Definition: f_drawgraph.c:84
clear_image
static void clear_image(DrawGraphContext *s, AVFrame *out, AVFilterLink *outlink)
Definition: f_drawgraph.c:139
eval.h
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:188
AV_WN32
#define AV_WN32(p, v)
Definition: intreadwrite.h:376
DrawGraphContext::x
int x
Definition: f_drawgraph.c:45
ff_avf_adrawgraph
AVFilter ff_avf_adrawgraph
FFMIN
#define FFMIN(a, b)
Definition: common.h:96
internal.h
DrawGraphContext::values
float * values[4]
Definition: f_drawgraph.c:48
AVFILTER_DEFINE_CLASS
#define AVFILTER_DEFINE_CLASS(fname)
Definition: internal.h:334
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:226
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
init
static av_cold int init(AVFilterContext *ctx)
Definition: f_drawgraph.c:86
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
uint8_t
uint8_t
Definition: audio_convert.c:194
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
DrawGraphContext::w
int w
Definition: f_drawgraph.c:42
DrawGraphContext::max
float max
Definition: f_drawgraph.c:36
AVFilter
Filter definition.
Definition: avfilter.h:144
ret
ret
Definition: filter_design.txt:187
mode
mode
Definition: ebur128.h:83
DrawGraphContext::out
AVFrame * out
Definition: f_drawgraph.c:44
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: f_drawgraph.c:154
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
avfilter.h
values
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 values
Definition: filter_design.txt:263
AVFilterContext
An instance of a filter.
Definition: avfilter.h:338
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
drawgraph_options
static const AVOption drawgraph_options[]
Definition: f_drawgraph.c:56
AVDictionaryEntry
Definition: dict.h:81
DrawGraphContext::h
int h
Definition: f_drawgraph.c:42
DrawGraphContext::slide
int slide
Definition: f_drawgraph.c:41
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVDictionaryEntry::value
char * value
Definition: dict.h:83
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:227
DrawGraphContext::nb_values
int nb_values
Definition: f_drawgraph.c:50
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:232
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: f_drawgraph.c:413
VAR_VARS_NB
@ VAR_VARS_NB
Definition: f_drawgraph.c:84
min
float min
Definition: vorbis_enc_data.h:456