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;
44 
46  int x;
47  int prev_y[4];
48  int first[4];
49  float *values[4];
50  int values_size[4];
51  int nb_values;
52  int64_t prev_pts;
54 
55 #define OFFSET(x) offsetof(DrawGraphContext, x)
56 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
57 
58 static const AVOption drawgraph_options[] = {
59  { "m1", "set 1st metadata key", OFFSET(key[0]), AV_OPT_TYPE_STRING, {.str=""}, 0, 0, FLAGS },
60  { "fg1", "set 1st foreground color expression", OFFSET(fg_str[0]), AV_OPT_TYPE_STRING, {.str="0xffff0000"}, 0, 0, FLAGS },
61  { "m2", "set 2nd metadata key", OFFSET(key[1]), AV_OPT_TYPE_STRING, {.str=""}, 0, 0, FLAGS },
62  { "fg2", "set 2nd foreground color expression", OFFSET(fg_str[1]), AV_OPT_TYPE_STRING, {.str="0xff00ff00"}, 0, 0, FLAGS },
63  { "m3", "set 3rd metadata key", OFFSET(key[2]), AV_OPT_TYPE_STRING, {.str=""}, 0, 0, FLAGS },
64  { "fg3", "set 3rd foreground color expression", OFFSET(fg_str[2]), AV_OPT_TYPE_STRING, {.str="0xffff00ff"}, 0, 0, FLAGS },
65  { "m4", "set 4th metadata key", OFFSET(key[3]), AV_OPT_TYPE_STRING, {.str=""}, 0, 0, FLAGS },
66  { "fg4", "set 4th foreground color expression", OFFSET(fg_str[3]), AV_OPT_TYPE_STRING, {.str="0xffffff00"}, 0, 0, FLAGS },
67  { "bg", "set background color", OFFSET(bg), AV_OPT_TYPE_COLOR, {.str="white"}, 0, 0, FLAGS },
68  { "min", "set minimal value", OFFSET(min), AV_OPT_TYPE_FLOAT, {.dbl=-1.}, INT_MIN, INT_MAX, FLAGS },
69  { "max", "set maximal value", OFFSET(max), AV_OPT_TYPE_FLOAT, {.dbl=1.}, INT_MIN, INT_MAX, FLAGS },
70  { "mode", "set graph mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=2}, 0, 2, FLAGS, "mode" },
71  {"bar", "draw bars", OFFSET(mode), AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "mode"},
72  {"dot", "draw dots", OFFSET(mode), AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "mode"},
73  {"line", "draw lines", OFFSET(mode), AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "mode"},
74  { "slide", "set slide mode", OFFSET(slide), AV_OPT_TYPE_INT, {.i64=0}, 0, 4, FLAGS, "slide" },
75  {"frame", "draw new frames", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "slide"},
76  {"replace", "replace old columns with new", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "slide"},
77  {"scroll", "scroll from right to left", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "slide"},
78  {"rscroll", "scroll from left to right", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, FLAGS, "slide"},
79  {"picture", "display graph in single frame", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, FLAGS, "slide"},
80  { "size", "set graph size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="900x256"}, 0, 0, FLAGS },
81  { "s", "set graph size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="900x256"}, 0, 0, FLAGS },
82  { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
83  { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
84  { NULL }
85 };
86 
87 AVFILTER_DEFINE_CLASS_EXT(drawgraph, "(a)drawgraph", drawgraph_options);
88 
89 static const char *const var_names[] = { "MAX", "MIN", "VAL", NULL };
91 
93 {
94  DrawGraphContext *s = ctx->priv;
95  int ret, i;
96 
97  if (s->max <= s->min) {
98  av_log(ctx, AV_LOG_ERROR, "max is same or lower than min\n");
99  return AVERROR(EINVAL);
100  }
101 
102  for (i = 0; i < 4; i++) {
103  if (s->fg_str[i]) {
104  ret = av_expr_parse(&s->fg_expr[i], s->fg_str[i], var_names,
105  NULL, NULL, NULL, NULL, 0, ctx);
106 
107  if (ret < 0)
108  return ret;
109  }
110  }
111 
112  s->first[0] = s->first[1] = s->first[2] = s->first[3] = 1;
113 
114  if (s->slide == 4) {
115  s->values[0] = av_fast_realloc(NULL, &s->values_size[0], 2000);
116  s->values[1] = av_fast_realloc(NULL, &s->values_size[1], 2000);
117  s->values[2] = av_fast_realloc(NULL, &s->values_size[2], 2000);
118  s->values[3] = av_fast_realloc(NULL, &s->values_size[3], 2000);
119 
120  if (!s->values[0] || !s->values[1] ||
121  !s->values[2] || !s->values[3]) {
122  return AVERROR(ENOMEM);
123  }
124  }
125 
126  return 0;
127 }
128 
130 {
131  AVFilterLink *outlink = ctx->outputs[0];
132  static const enum AVPixelFormat pix_fmts[] = {
135  };
136  int ret;
137 
139  if ((ret = ff_formats_ref(fmts_list, &outlink->incfg.formats)) < 0)
140  return ret;
141 
142  return 0;
143 }
144 
146 {
147  int i, j;
148  int bg = AV_RN32(s->bg);
149 
150  for (i = 0; i < out->height; i++)
151  for (j = 0; j < out->width; j++)
152  AV_WN32(out->data[0] + i * out->linesize[0] + j * 4, bg);
153 }
154 
155 static inline void draw_dot(int fg, int x, int y, AVFrame *out)
156 {
157  AV_WN32(out->data[0] + y * out->linesize[0] + x * 4, fg);
158 }
159 
161 {
162  AVFilterContext *ctx = inlink->dst;
163  DrawGraphContext *s = ctx->priv;
164  AVFilterLink *outlink = ctx->outputs[0];
165  AVDictionary *metadata;
167  AVFrame *out = s->out;
168  AVFrame *clone = NULL;
169  int64_t in_pts, out_pts;
170  int i;
171 
172  if (s->slide == 4 && s->nb_values >= s->values_size[0] / sizeof(float)) {
173  float *ptr;
174 
175  ptr = av_fast_realloc(s->values[0], &s->values_size[0], s->values_size[0] * 2);
176  if (!ptr)
177  return AVERROR(ENOMEM);
178  s->values[0] = ptr;
179 
180  ptr = av_fast_realloc(s->values[1], &s->values_size[1], s->values_size[1] * 2);
181  if (!ptr)
182  return AVERROR(ENOMEM);
183  s->values[1] = ptr;
184 
185  ptr = av_fast_realloc(s->values[2], &s->values_size[2], s->values_size[2] * 2);
186  if (!ptr)
187  return AVERROR(ENOMEM);
188  s->values[2] = ptr;
189 
190  ptr = av_fast_realloc(s->values[3], &s->values_size[3], s->values_size[3] * 2);
191  if (!ptr)
192  return AVERROR(ENOMEM);
193  s->values[3] = ptr;
194  }
195 
196  if (s->slide != 4 || s->nb_values == 0) {
197  if (!s->out || s->out->width != outlink->w ||
198  s->out->height != outlink->h) {
199  av_frame_free(&s->out);
200  s->out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
201  out = s->out;
202  if (!s->out) {
203  av_frame_free(&in);
204  return AVERROR(ENOMEM);
205  }
206 
207  clear_image(s, out, outlink);
208  }
210  }
211 
212  metadata = in->metadata;
213 
214  for (i = 0; i < 4; i++) {
215  double values[VAR_VARS_NB];
216  int j, y, x, old;
217  uint32_t fg, bg;
218  float vf;
219 
220  if (s->slide == 4)
221  s->values[i][s->nb_values] = NAN;
222 
223  e = av_dict_get(metadata, s->key[i], NULL, 0);
224  if (!e || !e->value)
225  continue;
226 
227  if (av_sscanf(e->value, "%f", &vf) != 1)
228  continue;
229 
230  vf = av_clipf(vf, s->min, s->max);
231 
232  if (s->slide == 4) {
233  s->values[i][s->nb_values] = vf;
234  continue;
235  }
236 
237  values[VAR_MIN] = s->min;
238  values[VAR_MAX] = s->max;
239  values[VAR_VAL] = vf;
240 
241  fg = av_expr_eval(s->fg_expr[i], values, NULL);
242  bg = AV_RN32(s->bg);
243 
244  if (i == 0 && (s->x >= outlink->w || s->slide == 3)) {
245  if (s->slide == 0 || s->slide == 1)
246  s->x = 0;
247 
248  if (s->slide == 2) {
249  s->x = outlink->w - 1;
250  for (j = 0; j < outlink->h; j++) {
251  memmove(out->data[0] + j * out->linesize[0] ,
252  out->data[0] + j * out->linesize[0] + 4,
253  (outlink->w - 1) * 4);
254  }
255  } else if (s->slide == 3) {
256  s->x = 0;
257  for (j = 0; j < outlink->h; j++) {
258  memmove(out->data[0] + j * out->linesize[0] + 4,
259  out->data[0] + j * out->linesize[0],
260  (outlink->w - 1) * 4);
261  }
262  } else if (s->slide == 0) {
263  clear_image(s, out, outlink);
264  }
265  }
266 
267  x = s->x;
268  y = (outlink->h - 1) * (1 - ((vf - s->min) / (s->max - s->min)));
269 
270  switch (s->mode) {
271  case 0:
272  if (i == 0 && (s->slide > 0))
273  for (j = 0; j < outlink->h; j++)
274  draw_dot(bg, x, j, out);
275 
276  old = AV_RN32(out->data[0] + y * out->linesize[0] + x * 4);
277  for (j = y; j < outlink->h; j++) {
278  if (old != bg &&
279  (AV_RN32(out->data[0] + j * out->linesize[0] + x * 4) != old) ||
280  AV_RN32(out->data[0] + FFMIN(j+1, outlink->h - 1) * out->linesize[0] + x * 4) != old) {
281  draw_dot(fg, x, j, out);
282  break;
283  }
284  draw_dot(fg, x, j, out);
285  }
286  break;
287  case 1:
288  if (i == 0 && (s->slide > 0))
289  for (j = 0; j < outlink->h; j++)
290  draw_dot(bg, x, j, out);
291  draw_dot(fg, x, y, out);
292  break;
293  case 2:
294  if (s->first[i]) {
295  s->first[i] = 0;
296  s->prev_y[i] = y;
297  }
298 
299  if (i == 0 && (s->slide > 0)) {
300  for (j = 0; j < y; j++)
301  draw_dot(bg, x, j, out);
302  for (j = outlink->h - 1; j > y; j--)
303  draw_dot(bg, x, j, out);
304  }
305  if (y <= s->prev_y[i]) {
306  for (j = y; j <= s->prev_y[i]; j++)
307  draw_dot(fg, x, j, out);
308  } else {
309  for (j = s->prev_y[i]; j <= y; j++)
310  draw_dot(fg, x, j, out);
311  }
312  s->prev_y[i] = y;
313  break;
314  }
315  }
316 
317  s->nb_values++;
318  s->x++;
319 
320  in_pts = in->pts;
321 
322  av_frame_free(&in);
323 
324  if (s->slide == 4)
325  return 0;
326 
327  out_pts = av_rescale_q(in_pts, inlink->time_base, outlink->time_base);
328 
329  if (out_pts == s->prev_pts)
330  return 0;
331 
332  clone = av_frame_clone(s->out);
333  if (!clone)
334  return AVERROR(ENOMEM);
335 
336  clone->pts = s->prev_pts = out_pts;
337  return ff_filter_frame(outlink, clone);
338 }
339 
340 static int request_frame(AVFilterLink *outlink)
341 {
342  AVFilterContext *ctx = outlink->src;
343  DrawGraphContext *s = ctx->priv;
344  AVFrame *out = s->out;
345  int ret, i, k, step, l;
346 
347  ret = ff_request_frame(ctx->inputs[0]);
348 
349  if (s->slide == 4 && ret == AVERROR_EOF && s->nb_values > 0) {
350  s->x = l = 0;
351  step = ceil(s->nb_values / (float)s->w);
352 
353  for (k = 0; k < s->nb_values; k++) {
354  for (i = 0; i < 4; i++) {
355  double values[VAR_VARS_NB];
356  int j, y, x, old;
357  uint32_t fg, bg;
358  float vf = s->values[i][k];
359 
360  if (isnan(vf))
361  continue;
362 
363  values[VAR_MIN] = s->min;
364  values[VAR_MAX] = s->max;
365  values[VAR_VAL] = vf;
366 
367  fg = av_expr_eval(s->fg_expr[i], values, NULL);
368  bg = AV_RN32(s->bg);
369 
370  x = s->x;
371  y = (outlink->h - 1) * (1 - ((vf - s->min) / (s->max - s->min)));
372 
373  switch (s->mode) {
374  case 0:
375  old = AV_RN32(out->data[0] + y * out->linesize[0] + x * 4);
376  for (j = y; j < outlink->h; j++) {
377  if (old != bg &&
378  (AV_RN32(out->data[0] + j * out->linesize[0] + x * 4) != old) ||
379  AV_RN32(out->data[0] + FFMIN(j+1, outlink->h - 1) * out->linesize[0] + x * 4) != old) {
380  draw_dot(fg, x, j, out);
381  break;
382  }
383  draw_dot(fg, x, j, out);
384  }
385  break;
386  case 1:
387  draw_dot(fg, x, y, out);
388  break;
389  case 2:
390  if (s->first[i]) {
391  s->first[i] = 0;
392  s->prev_y[i] = y;
393  }
394 
395  if (y <= s->prev_y[i]) {
396  for (j = y; j <= s->prev_y[i]; j++)
397  draw_dot(fg, x, j, out);
398  } else {
399  for (j = s->prev_y[i]; j <= y; j++)
400  draw_dot(fg, x, j, out);
401  }
402  s->prev_y[i] = y;
403  break;
404  }
405  }
406 
407  l++;
408  if (l >= step) {
409  l = 0;
410  s->x++;
411  }
412  }
413 
414  s->nb_values = 0;
415  out->pts = 0;
416  ret = ff_filter_frame(ctx->outputs[0], s->out);
417  }
418 
419  return ret;
420 }
421 
422 static int config_output(AVFilterLink *outlink)
423 {
424  DrawGraphContext *s = outlink->src->priv;
425 
426  outlink->w = s->w;
427  outlink->h = s->h;
428  outlink->sample_aspect_ratio = (AVRational){1,1};
429  outlink->frame_rate = s->frame_rate;
430  outlink->time_base = av_inv_q(outlink->frame_rate);
431  s->prev_pts = AV_NOPTS_VALUE;
432 
433  return 0;
434 }
435 
437 {
438  DrawGraphContext *s = ctx->priv;
439  int i;
440 
441  for (i = 0; i < 4; i++)
442  av_expr_free(s->fg_expr[i]);
443 
444  if (s->slide != 4)
445  av_frame_free(&s->out);
446 
447  av_freep(&s->values[0]);
448  av_freep(&s->values[1]);
449  av_freep(&s->values[2]);
450  av_freep(&s->values[3]);
451 }
452 
453 #if CONFIG_DRAWGRAPH_FILTER
454 
455 static const AVFilterPad drawgraph_inputs[] = {
456  {
457  .name = "default",
458  .type = AVMEDIA_TYPE_VIDEO,
459  .filter_frame = filter_frame,
460  },
461 };
462 
463 static const AVFilterPad drawgraph_outputs[] = {
464  {
465  .name = "default",
466  .type = AVMEDIA_TYPE_VIDEO,
467  .config_props = config_output,
468  .request_frame = request_frame,
469  },
470 };
471 
472 const AVFilter ff_vf_drawgraph = {
473  .name = "drawgraph",
474  .description = NULL_IF_CONFIG_SMALL("Draw a graph using input video metadata."),
475  .priv_size = sizeof(DrawGraphContext),
476  .priv_class = &drawgraph_class,
477  .init = init,
478  .uninit = uninit,
479  FILTER_INPUTS(drawgraph_inputs),
480  FILTER_OUTPUTS(drawgraph_outputs),
482 };
483 
484 #endif // CONFIG_DRAWGRAPH_FILTER
485 
486 #if CONFIG_ADRAWGRAPH_FILTER
487 
488 static const AVFilterPad adrawgraph_inputs[] = {
489  {
490  .name = "default",
491  .type = AVMEDIA_TYPE_AUDIO,
492  .filter_frame = filter_frame,
493  },
494 };
495 
496 static const AVFilterPad adrawgraph_outputs[] = {
497  {
498  .name = "default",
499  .type = AVMEDIA_TYPE_VIDEO,
500  .config_props = config_output,
501  .request_frame = request_frame,
502  },
503 };
504 
505 const AVFilter ff_avf_adrawgraph = {
506  .name = "adrawgraph",
507  .description = NULL_IF_CONFIG_SMALL("Draw a graph using input audio metadata."),
508  .priv_class = &drawgraph_class,
509  .priv_size = sizeof(DrawGraphContext),
510  .init = init,
511  .uninit = uninit,
512  FILTER_INPUTS(adrawgraph_inputs),
513  FILTER_OUTPUTS(adrawgraph_outputs),
515 };
516 #endif // CONFIG_ADRAWGRAPH_FILTER
AVFILTER_DEFINE_CLASS_EXT
AVFILTER_DEFINE_CLASS_EXT(drawgraph, "(a)drawgraph", drawgraph_options)
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:98
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: f_drawgraph.c:340
DrawGraphContext::first
int first[4]
Definition: f_drawgraph.c:48
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
VAR_MIN
@ VAR_MIN
Definition: f_drawgraph.c:90
DrawGraphContext::prev_y
int prev_y[4]
Definition: f_drawgraph.c:47
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:381
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:1018
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
Definition: opt.h:237
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: f_drawgraph.c:129
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
config_output
static int config_output(AVFilterLink *outlink)
Definition: f_drawgraph.c:422
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:424
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
VAR_VAL
@ VAR_VAL
Definition: f_drawgraph.c:90
AVOption
AVOption.
Definition: opt.h:247
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:168
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:420
float.h
max
#define max(a, b)
Definition: cuda_runtime.h:33
AVDictionary
Definition: dict.c:30
ff_avf_adrawgraph
const AVFilter ff_avf_adrawgraph
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:169
video.h
FLAGS
#define FLAGS
Definition: f_drawgraph.c:56
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:685
DrawGraphContext::min
float min
Definition: f_drawgraph.c:36
VAR_MAX
@ VAR_MAX
Definition: f_drawgraph.c:90
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:417
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:336
draw_dot
static void draw_dot(int fg, int x, int y, AVFrame *out)
Definition: f_drawgraph.c:155
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
ceil
static __device__ float ceil(float a)
Definition: cuda_runtime.h:176
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
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:504
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:257
VAR_VARS_NB
@ VAR_VARS_NB
Definition: f_drawgraph.c:90
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:555
DrawGraphContext::fg_expr
AVExpr * fg_expr[4]
Definition: f_drawgraph.c:38
OFFSET
#define OFFSET(x)
Definition: f_drawgraph.c:55
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:296
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:766
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:422
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:141
AVExpr
Definition: eval.c:157
key
const char * key
Definition: hwcontext_opencl.c:168
NAN
#define NAN
Definition: mathematics.h:64
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
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:960
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
var_names
static const char *const var_names[]
Definition: f_drawgraph.c:89
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:537
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:50
AV_OPT_TYPE_COLOR
@ AV_OPT_TYPE_COLOR
Definition: opt.h:239
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:234
av_clipf
#define av_clipf
Definition: common.h:144
DrawGraphContext::key
char * key[4]
Definition: f_drawgraph.c:35
AV_RN32
#define AV_RN32(p)
Definition: intreadwrite.h:364
DrawGraphContext::prev_pts
int64_t prev_pts
Definition: f_drawgraph.c:52
ff_vf_drawgraph
const AVFilter ff_vf_drawgraph
clear_image
static void clear_image(DrawGraphContext *s, AVFrame *out, AVFilterLink *outlink)
Definition: f_drawgraph.c:145
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:117
AV_WN32
#define AV_WN32(p, v)
Definition: intreadwrite.h:376
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
DrawGraphContext::x
int x
Definition: f_drawgraph.c:46
DrawGraphContext::frame_rate
AVRational frame_rate
Definition: f_drawgraph.c:43
internal.h
DrawGraphContext::values
float * values[4]
Definition: f_drawgraph.c:49
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:227
init
static av_cold int init(AVFilterContext *ctx)
Definition: f_drawgraph.c:92
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
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: internal.h:56
DrawGraphContext::w
int w
Definition: f_drawgraph.c:42
DrawGraphContext::max
float max
Definition: f_drawgraph.c:36
AVFilter
Filter definition.
Definition: avfilter.h:165
ret
ret
Definition: filter_design.txt:187
mode
mode
Definition: ebur128.h:83
DrawGraphContext::out
AVFrame * out
Definition: f_drawgraph.c:45
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:160
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
avfilter.h
AVFrame::metadata
AVDictionary * metadata
metadata.
Definition: frame.h:608
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:402
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVFilterFormatsConfig::formats
AVFilterFormats * formats
List of supported formats (pixel or sample).
Definition: avfilter.h:506
drawgraph_options
static const AVOption drawgraph_options[]
Definition: f_drawgraph.c:58
AVDictionaryEntry
Definition: dict.h:79
DrawGraphContext::h
int h
Definition: f_drawgraph.c:42
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
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:81
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:228
DrawGraphContext::nb_values
int nb_values
Definition: f_drawgraph.c:51
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: f_drawgraph.c:436
min
float min
Definition: vorbis_enc_data.h:429