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