FFmpeg
f_graphmonitor.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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/pixdesc.h"
26 #include "libavutil/eval.h"
27 #include "libavutil/intreadwrite.h"
28 #include "libavutil/opt.h"
29 #include "libavutil/timestamp.h"
31 #include "avfilter.h"
32 #include "filters.h"
33 #include "formats.h"
34 #include "internal.h"
35 #include "video.h"
36 
37 typedef struct CacheItem {
38  int64_t previous_pts_us;
39 } CacheItem;
40 
41 typedef struct GraphMonitorContext {
42  const AVClass *class;
43 
44  int w, h;
45  float opacity;
46  int mode;
47  int flags;
49 
50  int64_t pts;
51  int64_t next_pts;
52  uint8_t white[4];
53  uint8_t yellow[4];
54  uint8_t red[4];
55  uint8_t green[4];
56  uint8_t blue[4];
57  uint8_t bg[4];
58 
60  unsigned int cache_size;
61  unsigned int cache_index;
63 
64 enum {
65  MODE_QUEUE = 1 << 0,
66  MODE_FCIN = 1 << 1,
67  MODE_FCOUT = 1 << 2,
68  MODE_PTS = 1 << 3,
69  MODE_TIME = 1 << 4,
70  MODE_TB = 1 << 5,
71  MODE_FMT = 1 << 6,
72  MODE_SIZE = 1 << 7,
73  MODE_RATE = 1 << 8,
74  MODE_EOF = 1 << 9,
75  MODE_SCIN = 1 << 10,
76  MODE_SCOUT = 1 << 11,
77  MODE_PTS_DELTA = 1 << 12,
78  MODE_TIME_DELTA = 1 << 13,
79  MODE_FC_DELTA = 1 << 14,
80  MODE_SC_DELTA = 1 << 15,
81 };
82 
83 #define OFFSET(x) offsetof(GraphMonitorContext, x)
84 #define VF AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
85 
86 static const AVOption graphmonitor_options[] = {
87  { "size", "set monitor size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, VF },
88  { "s", "set monitor size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, VF },
89  { "opacity", "set video opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=.9}, 0, 1, VF },
90  { "o", "set video opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=.9}, 0, 1, VF },
91  { "mode", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, VF, "mode" },
92  { "m", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, VF, "mode" },
93  { "full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, VF, "mode" },
94  { "compact", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, VF, "mode" },
95  { "flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=MODE_QUEUE}, 0, INT_MAX, VF, "flags" },
96  { "f", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=MODE_QUEUE}, 0, INT_MAX, VF, "flags" },
97  { "queue", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_QUEUE}, 0, 0, VF, "flags" },
98  { "frame_count_in", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_FCOUT}, 0, 0, VF, "flags" },
99  { "frame_count_out", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_FCIN}, 0, 0, VF, "flags" },
100  { "frame_count_delta",NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_FC_DELTA},0, 0, VF, "flags" },
101  { "pts", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_PTS}, 0, 0, VF, "flags" },
102  { "pts_delta", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_PTS_DELTA},0,0, VF, "flags" },
103  { "time", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_TIME}, 0, 0, VF, "flags" },
104  { "time_delta", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_TIME_DELTA},0,0,VF, "flags" },
105  { "timebase", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_TB}, 0, 0, VF, "flags" },
106  { "format", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_FMT}, 0, 0, VF, "flags" },
107  { "size", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_SIZE}, 0, 0, VF, "flags" },
108  { "rate", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_RATE}, 0, 0, VF, "flags" },
109  { "eof", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_EOF}, 0, 0, VF, "flags" },
110  { "sample_count_in", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_SCOUT}, 0, 0, VF, "flags" },
111  { "sample_count_out", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_SCIN}, 0, 0, VF, "flags" },
112  { "sample_count_delta",NULL,0, AV_OPT_TYPE_CONST, {.i64=MODE_SC_DELTA},0, 0, VF, "flags" },
113  { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, VF },
114  { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, VF },
115  { NULL }
116 };
117 
119 {
120  GraphMonitorContext *s = ctx->priv;
121 
122  s->cache = av_fast_realloc(NULL, &s->cache_size,
123  8192 * sizeof(*(s->cache)));
124  if (!s->cache)
125  return AVERROR(ENOMEM);
126 
127  return 0;
128 }
129 
131 {
132  AVFilterLink *outlink = ctx->outputs[0];
133  static const enum AVPixelFormat pix_fmts[] = {
136  };
137  int ret;
138 
140  if ((ret = ff_formats_ref(fmts_list, &outlink->incfg.formats)) < 0)
141  return ret;
142 
143  return 0;
144 }
145 
147 {
148  int bg = AV_RN32(s->bg);
149 
150  for (int i = 0; i < out->height; i++)
151  for (int j = 0; j < out->width; j++)
152  AV_WN32(out->data[0] + i * out->linesize[0] + j * 4, bg);
153 }
154 
155 static void drawtext(AVFrame *pic, int x, int y, const char *txt, uint8_t *color)
156 {
157  const uint8_t *font;
158  int font_height;
159  int i;
160 
161  font = avpriv_cga_font, font_height = 8;
162 
163  if (y + 8 >= pic->height ||
164  x + strlen(txt) * 8 >= pic->width)
165  return;
166 
167  for (i = 0; txt[i]; i++) {
168  int char_y, mask;
169 
170  uint8_t *p = pic->data[0] + y*pic->linesize[0] + (x + i*8)*4;
171  for (char_y = 0; char_y < font_height; char_y++) {
172  for (mask = 0x80; mask; mask >>= 1) {
173  if (font[txt[i] * font_height + char_y] & mask) {
174  p[0] = color[0];
175  p[1] = color[1];
176  p[2] = color[2];
177  }
178  p += 4;
179  }
180  p += pic->linesize[0] - 8 * 4;
181  }
182  }
183 }
184 
186 {
187  for (int j = 0; j < filter->nb_inputs; j++) {
188  AVFilterLink *l = filter->inputs[j];
189  size_t frames = ff_inlink_queued_frames(l);
190 
191  if (frames)
192  return 1;
193  }
194 
195  for (int j = 0; j < filter->nb_outputs; j++) {
196  AVFilterLink *l = filter->outputs[j];
197  size_t frames = ff_inlink_queued_frames(l);
198 
199  if (frames)
200  return 1;
201  }
202 
203  return 0;
204 }
205 
207  int xpos, int ypos,
208  AVFilterLink *l,
209  size_t frames)
210 {
211  GraphMonitorContext *s = ctx->priv;
212  int64_t previous_pts_us = s->cache[s->cache_index].previous_pts_us;
213  int64_t current_pts_us = l->current_pts_us;
214  char buffer[1024] = { 0 };
215 
216  if (s->flags & MODE_FMT) {
217  if (l->type == AVMEDIA_TYPE_VIDEO) {
218  snprintf(buffer, sizeof(buffer)-1, " | format: %s",
220  } else if (l->type == AVMEDIA_TYPE_AUDIO) {
221  snprintf(buffer, sizeof(buffer)-1, " | format: %s",
223  }
224  drawtext(out, xpos, ypos, buffer, s->white);
225  xpos += strlen(buffer) * 8;
226  }
227  if (s->flags & MODE_SIZE) {
228  if (l->type == AVMEDIA_TYPE_VIDEO) {
229  snprintf(buffer, sizeof(buffer)-1, " | size: %dx%d", l->w, l->h);
230  } else if (l->type == AVMEDIA_TYPE_AUDIO) {
231  snprintf(buffer, sizeof(buffer)-1, " | channels: %d", l->ch_layout.nb_channels);
232  }
233  drawtext(out, xpos, ypos, buffer, s->white);
234  xpos += strlen(buffer) * 8;
235  }
236  if (s->flags & MODE_RATE) {
237  if (l->type == AVMEDIA_TYPE_VIDEO) {
238  snprintf(buffer, sizeof(buffer)-1, " | fps: %d/%d", l->frame_rate.num, l->frame_rate.den);
239  } else if (l->type == AVMEDIA_TYPE_AUDIO) {
240  snprintf(buffer, sizeof(buffer)-1, " | samplerate: %d", l->sample_rate);
241  }
242  drawtext(out, xpos, ypos, buffer, s->white);
243  xpos += strlen(buffer) * 8;
244  }
245  if (s->flags & MODE_TB) {
246  snprintf(buffer, sizeof(buffer)-1, " | tb: %d/%d", l->time_base.num, l->time_base.den);
247  drawtext(out, xpos, ypos, buffer, s->white);
248  xpos += strlen(buffer) * 8;
249  }
250  if (s->flags & MODE_QUEUE) {
251  snprintf(buffer, sizeof(buffer)-1, " | queue: ");
252  drawtext(out, xpos, ypos, buffer, s->white);
253  xpos += strlen(buffer) * 8;
254  snprintf(buffer, sizeof(buffer)-1, "%"SIZE_SPECIFIER, frames);
255  drawtext(out, xpos, ypos, buffer, frames > 0 ? frames >= 10 ? frames >= 50 ? s->red : s->yellow : s->green : s->white);
256  xpos += strlen(buffer) * 8;
257  }
258  if (s->flags & MODE_FCIN) {
259  snprintf(buffer, sizeof(buffer)-1, " | in: %"PRId64, l->frame_count_in);
260  drawtext(out, xpos, ypos, buffer, s->white);
261  xpos += strlen(buffer) * 8;
262  }
263  if (s->flags & MODE_FCOUT) {
264  snprintf(buffer, sizeof(buffer)-1, " | out: %"PRId64, l->frame_count_out);
265  drawtext(out, xpos, ypos, buffer, s->white);
266  xpos += strlen(buffer) * 8;
267  }
268  if (s->flags & MODE_FC_DELTA) {
269  snprintf(buffer, sizeof(buffer)-1, " | delta: %"PRId64, l->frame_count_in - l->frame_count_out);
270  drawtext(out, xpos, ypos, buffer, s->white);
271  xpos += strlen(buffer) * 8;
272  }
273  if (s->flags & MODE_SCIN) {
274  snprintf(buffer, sizeof(buffer)-1, " | sin: %"PRId64, l->sample_count_in);
275  drawtext(out, xpos, ypos, buffer, s->white);
276  xpos += strlen(buffer) * 8;
277  }
278  if (s->flags & MODE_SCOUT) {
279  snprintf(buffer, sizeof(buffer)-1, " | sout: %"PRId64, l->sample_count_out);
280  drawtext(out, xpos, ypos, buffer, s->white);
281  xpos += strlen(buffer) * 8;
282  }
283  if (s->flags & MODE_SC_DELTA) {
284  snprintf(buffer, sizeof(buffer)-1, " | sdelta: %"PRId64, l->sample_count_in - l->sample_count_out);
285  drawtext(out, xpos, ypos, buffer, s->white);
286  xpos += strlen(buffer) * 8;
287  }
288  if (s->flags & MODE_PTS) {
289  snprintf(buffer, sizeof(buffer)-1, " | pts: %s", av_ts2str(current_pts_us));
290  drawtext(out, xpos, ypos, buffer, s->white);
291  xpos += strlen(buffer) * 8;
292  }
293  if (s->flags & MODE_PTS_DELTA) {
294  snprintf(buffer, sizeof(buffer)-1, " | pts_delta: %s", av_ts2str(current_pts_us - previous_pts_us));
295  drawtext(out, xpos, ypos, buffer, s->white);
296  xpos += strlen(buffer) * 8;
297  }
298  if (s->flags & MODE_TIME) {
299  snprintf(buffer, sizeof(buffer)-1, " | time: %s", av_ts2timestr(current_pts_us, &AV_TIME_BASE_Q));
300  drawtext(out, xpos, ypos, buffer, s->white);
301  xpos += strlen(buffer) * 8;
302  }
303  if (s->flags & MODE_TIME_DELTA) {
304  snprintf(buffer, sizeof(buffer)-1, " | time_delta: %s", av_ts2timestr(current_pts_us - previous_pts_us, &AV_TIME_BASE_Q));
305  drawtext(out, xpos, ypos, buffer, s->white);
306  xpos += strlen(buffer) * 8;
307  }
308  if (s->flags & MODE_EOF && ff_outlink_get_status(l)) {
309  snprintf(buffer, sizeof(buffer)-1, " | eof");
310  drawtext(out, xpos, ypos, buffer, s->blue);
311  xpos += strlen(buffer) * 8;
312  }
313 
314  s->cache[s->cache_index].previous_pts_us = l->current_pts_us;
315 
316  if (s->cache_index + 1 >= s->cache_size / sizeof(*(s->cache))) {
317  void *ptr = av_fast_realloc(s->cache, &s->cache_size, s->cache_size * 2);
318 
319  if (!ptr)
320  return AVERROR(ENOMEM);
321  s->cache = ptr;
322  }
323  s->cache_index++;
324 
325  return 0;
326 }
327 
328 static int create_frame(AVFilterContext *ctx, int64_t pts)
329 {
330  GraphMonitorContext *s = ctx->priv;
331  AVFilterLink *outlink = ctx->outputs[0];
332  AVFrame *out;
333  int ret, xpos, ypos = 0;
334 
335  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
336  if (!out)
337  return AVERROR(ENOMEM);
338 
339  clear_image(s, out, outlink);
340 
341  s->cache_index = 0;
342 
343  for (int i = 0; i < ctx->graph->nb_filters; i++) {
344  AVFilterContext *filter = ctx->graph->filters[i];
345  char buffer[1024] = { 0 };
346 
347  if (s->mode && !filter_have_queued(filter))
348  continue;
349 
350  xpos = 0;
351  drawtext(out, xpos, ypos, filter->name, s->white);
352  xpos += strlen(filter->name) * 8 + 10;
353  drawtext(out, xpos, ypos, filter->filter->name, s->white);
354  ypos += 10;
355  for (int j = 0; j < filter->nb_inputs; j++) {
356  AVFilterLink *l = filter->inputs[j];
357  size_t frames = ff_inlink_queued_frames(l);
358 
359  if (s->mode && !frames)
360  continue;
361 
362  xpos = 10;
363  snprintf(buffer, sizeof(buffer)-1, "in%d: ", j);
364  drawtext(out, xpos, ypos, buffer, s->white);
365  xpos += strlen(buffer) * 8;
366  drawtext(out, xpos, ypos, l->src->name, s->white);
367  xpos += strlen(l->src->name) * 8 + 10;
368  ret = draw_items(ctx, out, xpos, ypos, l, frames);
369  if (ret < 0)
370  goto error;
371  ypos += 10;
372  }
373 
374  ypos += 2;
375  for (int j = 0; j < filter->nb_outputs; j++) {
376  AVFilterLink *l = filter->outputs[j];
377  size_t frames = ff_inlink_queued_frames(l);
378 
379  if (s->mode && !frames)
380  continue;
381 
382  xpos = 10;
383  snprintf(buffer, sizeof(buffer)-1, "out%d: ", j);
384  drawtext(out, xpos, ypos, buffer, s->white);
385  xpos += strlen(buffer) * 8;
386  drawtext(out, xpos, ypos, l->dst->name, s->white);
387  xpos += strlen(l->dst->name) * 8 + 10;
388  ret = draw_items(ctx, out, xpos, ypos, l, frames);
389  if (ret < 0)
390  goto error;
391  ypos += 10;
392  }
393  ypos += 5;
394  }
395 
396  out->pts = pts;
397  s->pts = pts + 1;
398  return ff_filter_frame(outlink, out);
399 error:
400  av_frame_free(&out);
401  return ret;
402 }
403 
405 {
406  GraphMonitorContext *s = ctx->priv;
407  AVFilterLink *inlink = ctx->inputs[0];
408  AVFilterLink *outlink = ctx->outputs[0];
409  int64_t pts = AV_NOPTS_VALUE;
410 
412 
414  AVFrame *frame = NULL;
415  int ret;
416 
418  if (ret < 0)
419  return ret;
420  if (ret > 0) {
421  pts = frame->pts;
423  }
424  }
425 
426  if (pts != AV_NOPTS_VALUE) {
427  pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
428  if (s->pts == AV_NOPTS_VALUE)
429  s->pts = pts;
430  s->next_pts = pts;
431  }
432 
433  if (s->pts < s->next_pts && ff_outlink_frame_wanted(outlink))
434  return create_frame(ctx, s->pts);
435 
438 
439  return FFERROR_NOT_READY;
440 }
441 
442 static int config_output(AVFilterLink *outlink)
443 {
444  GraphMonitorContext *s = outlink->src->priv;
445 
446  s->bg[3] = 255 * s->opacity;
447  s->white[0] = s->white[1] = s->white[2] = 255;
448  s->yellow[0] = s->yellow[1] = 255;
449  s->red[0] = 255;
450  s->green[1] = 255;
451  s->blue[2] = 255;
452  s->pts = AV_NOPTS_VALUE;
453  s->next_pts = AV_NOPTS_VALUE;
454  outlink->w = s->w;
455  outlink->h = s->h;
456  outlink->sample_aspect_ratio = (AVRational){1,1};
457  outlink->frame_rate = s->frame_rate;
458  outlink->time_base = av_inv_q(s->frame_rate);
459 
460  return 0;
461 }
462 
464 {
465  GraphMonitorContext *s = ctx->priv;
466 
467  av_freep(&s->cache);
468  s->cache_size = s->cache_index = 0;
469 }
470 
471 AVFILTER_DEFINE_CLASS_EXT(graphmonitor, "(a)graphmonitor", graphmonitor_options);
472 
473 #if CONFIG_GRAPHMONITOR_FILTER
474 
475 static const AVFilterPad graphmonitor_inputs[] = {
476  {
477  .name = "default",
478  .type = AVMEDIA_TYPE_VIDEO,
479  },
480 };
481 
482 static const AVFilterPad graphmonitor_outputs[] = {
483  {
484  .name = "default",
485  .type = AVMEDIA_TYPE_VIDEO,
486  .config_props = config_output,
487  },
488 };
489 
491  .name = "graphmonitor",
492  .description = NULL_IF_CONFIG_SMALL("Show various filtergraph stats."),
493  .priv_size = sizeof(GraphMonitorContext),
494  .priv_class = &graphmonitor_class,
495  .init = init,
496  .uninit = uninit,
497  .activate = activate,
498  FILTER_INPUTS(graphmonitor_inputs),
499  FILTER_OUTPUTS(graphmonitor_outputs),
501 };
502 
503 #endif // CONFIG_GRAPHMONITOR_FILTER
504 
505 #if CONFIG_AGRAPHMONITOR_FILTER
506 
507 static const AVFilterPad agraphmonitor_inputs[] = {
508  {
509  .name = "default",
510  .type = AVMEDIA_TYPE_AUDIO,
511  },
512 };
513 
514 static const AVFilterPad agraphmonitor_outputs[] = {
515  {
516  .name = "default",
517  .type = AVMEDIA_TYPE_VIDEO,
518  .config_props = config_output,
519  },
520 };
521 
523  .name = "agraphmonitor",
524  .description = NULL_IF_CONFIG_SMALL("Show various filtergraph stats."),
525  .priv_class = &graphmonitor_class,
526  .priv_size = sizeof(GraphMonitorContext),
527  .init = init,
528  .uninit = uninit,
529  .activate = activate,
530  FILTER_INPUTS(agraphmonitor_inputs),
531  FILTER_OUTPUTS(agraphmonitor_outputs),
533 };
534 #endif // CONFIG_AGRAPHMONITOR_FILTER
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:31
GraphMonitorContext::mode
int mode
Definition: f_graphmonitor.c:46
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
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
CacheItem::previous_pts_us
int64_t previous_pts_us
Definition: f_graphmonitor.c:38
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
MODE_FMT
@ MODE_FMT
Definition: f_graphmonitor.c:71
out
FILE * out
Definition: movenc.c:54
color
Definition: vf_paletteuse.c:509
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:969
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
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:260
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:99
GraphMonitorContext::opacity
float opacity
Definition: f_graphmonitor.c:45
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:330
pixdesc.h
AVFrame::width
int width
Definition: frame.h:402
w
uint8_t w
Definition: llviddspenc.c:38
OFFSET
#define OFFSET(x)
Definition: f_graphmonitor.c:83
AVOption
AVOption.
Definition: opt.h:251
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:171
MODE_FCIN
@ MODE_FCIN
Definition: f_graphmonitor.c:66
float.h
filter
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
Definition: filter_design.txt:228
GraphMonitorContext::cache_index
unsigned int cache_index
Definition: f_graphmonitor.c:61
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:165
draw_items
static int draw_items(AVFilterContext *ctx, AVFrame *out, int xpos, int ypos, AVFilterLink *l, size_t frames)
Definition: f_graphmonitor.c:206
MODE_SCOUT
@ MODE_SCOUT
Definition: f_graphmonitor.c:76
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: f_graphmonitor.c:463
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:311
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
create_frame
static int create_frame(AVFilterContext *ctx, int64_t pts)
Definition: f_graphmonitor.c:328
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:351
GraphMonitorContext::cache
CacheItem * cache
Definition: f_graphmonitor.c:59
MODE_TIME
@ MODE_TIME
Definition: f_graphmonitor.c:69
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
ff_avf_agraphmonitor
const AVFilter ff_avf_agraphmonitor
ff_inlink_consume_frame
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Definition: avfilter.c:1364
GraphMonitorContext::bg
uint8_t bg[4]
Definition: f_graphmonitor.c:57
MODE_SC_DELTA
@ MODE_SC_DELTA
Definition: f_graphmonitor.c:80
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:407
MODE_EOF
@ MODE_EOF
Definition: f_graphmonitor.c:74
frames
if it could not because there are no more frames
Definition: filter_design.txt:266
pts
static int64_t pts
Definition: transcode_aac.c:653
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: f_graphmonitor.c:130
AVRational::num
int num
Numerator.
Definition: rational.h:59
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:49
MODE_FCOUT
@ MODE_FCOUT
Definition: f_graphmonitor.c:67
GraphMonitorContext::green
uint8_t green[4]
Definition: f_graphmonitor.c:55
av_cold
#define av_cold
Definition: attributes.h:90
mask
static const uint16_t mask[17]
Definition: lzw.c:38
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:495
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
filters.h
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:296
GraphMonitorContext::white
uint8_t white[4]
Definition: f_graphmonitor.c:52
ctx
AVFormatContext * ctx
Definition: movenc.c:48
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
av_get_sample_fmt_name
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
Definition: samplefmt.c:51
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:194
GraphMonitorContext::pts
int64_t pts
Definition: f_graphmonitor.c:50
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
GraphMonitorContext::red
uint8_t red[4]
Definition: f_graphmonitor.c:54
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
AV_RN32
#define AV_RN32(p)
Definition: intreadwrite.h:364
AVFilterContext::name
char * name
name of this filter instance
Definition: avfilter.h:397
MODE_FC_DELTA
@ MODE_FC_DELTA
Definition: f_graphmonitor.c:79
MODE_PTS_DELTA
@ MODE_PTS_DELTA
Definition: f_graphmonitor.c:77
VF
#define VF
Definition: f_graphmonitor.c:84
ff_inlink_queued_frames
size_t ff_inlink_queued_frames(AVFilterLink *link)
Get the number of frames available on the link.
Definition: avfilter.c:1333
MODE_TIME_DELTA
@ MODE_TIME_DELTA
Definition: f_graphmonitor.c:78
activate
static int activate(AVFilterContext *ctx)
Definition: f_graphmonitor.c:404
eval.h
av_ts2timestr
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: timestamp.h:76
GraphMonitorContext::next_pts
int64_t next_pts
Definition: f_graphmonitor.c:51
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:115
AV_WN32
#define AV_WN32(p, v)
Definition: intreadwrite.h:376
init
static av_cold int init(AVFilterContext *ctx)
Definition: f_graphmonitor.c:118
MODE_TB
@ MODE_TB
Definition: f_graphmonitor.c:70
MODE_RATE
@ MODE_RATE
Definition: f_graphmonitor.c:73
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
MODE_SCIN
@ MODE_SCIN
Definition: f_graphmonitor.c:75
GraphMonitorContext
Definition: f_graphmonitor.c:41
FF_FILTER_FORWARD_WANTED
FF_FILTER_FORWARD_WANTED(outlink, inlink)
xga_font_data.h
MODE_QUEUE
@ MODE_QUEUE
Definition: f_graphmonitor.c:65
drawtext
static void drawtext(AVFrame *pic, int x, int y, const char *txt, uint8_t *color)
Definition: f_graphmonitor.c:155
internal.h
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
GraphMonitorContext::cache_size
unsigned int cache_size
Definition: f_graphmonitor.c:60
GraphMonitorContext::blue
uint8_t blue[4]
Definition: f_graphmonitor.c:56
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
CacheItem
Definition: f_graphmonitor.c:37
graphmonitor_options
static const AVOption graphmonitor_options[]
Definition: f_graphmonitor.c:86
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:55
GraphMonitorContext::frame_rate
AVRational frame_rate
Definition: f_graphmonitor.c:48
AVFilter
Filter definition.
Definition: avfilter.h:161
ret
ret
Definition: filter_design.txt:187
filter_have_queued
static int filter_have_queued(AVFilterContext *filter)
Definition: f_graphmonitor.c:185
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
GraphMonitorContext::w
int w
Definition: f_graphmonitor.c:44
clear_image
static void clear_image(GraphMonitorContext *s, AVFrame *out, AVFilterLink *outlink)
Definition: f_graphmonitor.c:146
config_output
static int config_output(AVFilterLink *outlink)
Definition: f_graphmonitor.c:442
SIZE_SPECIFIER
#define SIZE_SPECIFIER
Definition: internal.h:150
AVFrame::height
int height
Definition: frame.h:402
GraphMonitorContext::h
int h
Definition: f_graphmonitor.c:44
buffer
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
Definition: filter_design.txt:49
AVRational::den
int den
Denominator.
Definition: rational.h:60
mode
mode
Definition: ebur128.h:83
MODE_PTS
@ MODE_PTS
Definition: f_graphmonitor.c:68
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
ff_outlink_get_status
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
Definition: avfilter.c:1504
AVFilterContext
An instance of a filter.
Definition: avfilter.h:392
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVFilterFormatsConfig::formats
AVFilterFormats * formats
List of supported formats (pixel or sample).
Definition: avfilter.h:496
GraphMonitorContext::flags
int flags
Definition: f_graphmonitor.c:47
avpriv_cga_font
const uint8_t avpriv_cga_font[2048]
Definition: xga_font_data.c:29
FF_FILTER_FORWARD_STATUS
FF_FILTER_FORWARD_STATUS(inlink, outlink)
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:195
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:224
timestamp.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:375
av_ts2str
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: timestamp.h:54
ff_outlink_frame_wanted
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
GraphMonitorContext::yellow
uint8_t yellow[4]
Definition: f_graphmonitor.c:53
MODE_SIZE
@ MODE_SIZE
Definition: f_graphmonitor.c:72
AVFILTER_DEFINE_CLASS_EXT
AVFILTER_DEFINE_CLASS_EXT(graphmonitor, "(a)graphmonitor", graphmonitor_options)
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
snprintf
#define snprintf
Definition: snprintf.h:34
ff_vf_graphmonitor
const AVFilter ff_vf_graphmonitor
av_get_pix_fmt_name
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:2808