FFmpeg
Loading...
Searching...
No Matches
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 "libavutil/mem.h"
24#include "libavutil/pixdesc.h"
26#include "libavutil/opt.h"
27#include "libavutil/timestamp.h"
29#include "audio.h"
30#include "avfilter.h"
31#include "filters.h"
32#include "formats.h"
33#include "video.h"
34
38
39typedef struct GraphMonitorContext {
40 const AVClass *class;
41
42 int w, h;
43 float opacity;
44 int mode;
45 int flags;
47
48 int eof;
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 gray[4];
58 uint8_t bg[4];
59
61 unsigned int cache_size;
62 unsigned int cache_index;
64
65enum {
72};
73
74enum {
75 FLAG_NONE = 0 << 0,
76 FLAG_QUEUE = 1 << 0,
77 FLAG_FCIN = 1 << 1,
78 FLAG_FCOUT = 1 << 2,
79 FLAG_PTS = 1 << 3,
80 FLAG_TIME = 1 << 4,
81 FLAG_TB = 1 << 5,
82 FLAG_FMT = 1 << 6,
83 FLAG_SIZE = 1 << 7,
84 FLAG_RATE = 1 << 8,
85 FLAG_EOF = 1 << 9,
86 FLAG_SCIN = 1 << 10,
87 FLAG_SCOUT = 1 << 11,
88 FLAG_PTS_DELTA = 1 << 12,
89 FLAG_TIME_DELTA = 1 << 13,
90 FLAG_FC_DELTA = 1 << 14,
91 FLAG_SC_DELTA = 1 << 15,
92 FLAG_DISABLED = 1 << 16,
93};
94
95#define OFFSET(x) offsetof(GraphMonitorContext, x)
96#define VF AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
97#define VFR AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
98
100 { "size", "set monitor size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, VF },
101 { "s", "set monitor size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, VF },
102 { "opacity", "set video opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=.9}, 0, 1, VFR },
103 { "o", "set video opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=.9}, 0, 1, VFR },
104 { "mode", "set mode", OFFSET(mode), AV_OPT_TYPE_FLAGS, {.i64=0}, 0, MODE_MAX, VFR, .unit = "mode" },
105 { "m", "set mode", OFFSET(mode), AV_OPT_TYPE_FLAGS, {.i64=0}, 0, MODE_MAX, VFR, .unit = "mode" },
106 { "full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_FULL}, 0, 0, VFR, .unit = "mode" },
107 { "compact", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_COMPACT},0, 0, VFR, .unit = "mode" },
108 { "nozero", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_NOZERO}, 0, 0, VFR, .unit = "mode" },
109 { "noeof", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_NOEOF}, 0, 0, VFR, .unit = "mode" },
110 { "nodisabled",NULL,0,AV_OPT_TYPE_CONST, {.i64=MODE_NODISABLED},0,0,VFR,.unit = "mode" },
111 { "flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=FLAG_QUEUE}, 0, INT_MAX, VFR, .unit = "flags" },
112 { "f", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=FLAG_QUEUE}, 0, INT_MAX, VFR, .unit = "flags" },
113 { "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_NONE}, 0, 0, VFR, .unit = "flags" },
114 { "all", NULL, 0, AV_OPT_TYPE_CONST, {.i64=INT_MAX}, 0, 0, VFR, .unit = "flags" },
115 { "queue", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_QUEUE}, 0, 0, VFR, .unit = "flags" },
116 { "frame_count_in", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_FCOUT}, 0, 0, VFR, .unit = "flags" },
117 { "frame_count_out", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_FCIN}, 0, 0, VFR, .unit = "flags" },
118 { "frame_count_delta",NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_FC_DELTA},0, 0, VFR, .unit = "flags" },
119 { "pts", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_PTS}, 0, 0, VFR, .unit = "flags" },
120 { "pts_delta", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_PTS_DELTA},0,0, VFR, .unit = "flags" },
121 { "time", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_TIME}, 0, 0, VFR, .unit = "flags" },
122 { "time_delta", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_TIME_DELTA},0,0,VFR, .unit = "flags" },
123 { "timebase", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_TB}, 0, 0, VFR, .unit = "flags" },
124 { "format", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_FMT}, 0, 0, VFR, .unit = "flags" },
125 { "size", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_SIZE}, 0, 0, VFR, .unit = "flags" },
126 { "rate", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_RATE}, 0, 0, VFR, .unit = "flags" },
127 { "eof", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_EOF}, 0, 0, VFR, .unit = "flags" },
128 { "sample_count_in", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_SCOUT}, 0, 0, VFR, .unit = "flags" },
129 { "sample_count_out", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_SCIN}, 0, 0, VFR, .unit = "flags" },
130 { "sample_count_delta",NULL,0, AV_OPT_TYPE_CONST, {.i64=FLAG_SC_DELTA},0, 0, VFR, .unit = "flags" },
131 { "disabled", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_DISABLED},0, 0, VFR, .unit = "flags" },
132 { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, VF },
133 { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, VF },
134 { NULL }
135};
136
138{
139 GraphMonitorContext *s = ctx->priv;
140
141 s->cache = av_fast_realloc(NULL, &s->cache_size,
142 8192 * sizeof(*(s->cache)));
143 if (!s->cache)
144 return AVERROR(ENOMEM);
145
146 return 0;
147}
148
150 AVFilterFormatsConfig **cfg_in,
151 AVFilterFormatsConfig **cfg_out)
152{
153 static const enum AVPixelFormat pix_fmts[] = {
156 };
157 int ret;
158
160 if ((ret = ff_formats_ref(fmts_list, &cfg_out[0]->formats)) < 0)
161 return ret;
162
163 return 0;
164}
165
167{
168 const int h = out->height;
169 const int w = out->width;
170 uint8_t *dst = out->data[0];
171 int bg = AV_RN32(s->bg);
172
173 for (int j = 0; j < w; j++)
174 AV_WN32(dst + j * 4, bg);
175 dst += out->linesize[0];
176 for (int i = 1; i < h; i++) {
177 memcpy(dst, out->data[0], w * 4);
178 dst += out->linesize[0];
179 }
180}
181
182static void drawtext(AVFrame *pic, int x, int y, const char *txt,
183 const int len, uint8_t *color)
184{
185 const uint8_t *font;
186 int font_height;
187 int i;
188
189 font = avpriv_cga_font_get(), font_height = 8;
190
191 if (y + 8 >= pic->height ||
192 x + len * 8 >= pic->width)
193 return;
194
195 for (i = 0; txt[i]; i++) {
196 int char_y, mask;
197
198 uint8_t *p = pic->data[0] + y*pic->linesize[0] + (x + i*8)*4;
199 for (char_y = 0; char_y < font_height; char_y++) {
200 for (mask = 0x80; mask; mask >>= 1) {
201 if (font[txt[i] * font_height + char_y] & mask) {
202 p[0] = color[0];
203 p[1] = color[1];
204 p[2] = color[2];
205 }
206 p += 4;
207 }
208 p += pic->linesize[0] - 8 * 4;
209 }
210 }
211}
212
214{
215 for (int j = 0; j < filter->nb_inputs; j++) {
216 AVFilterLink *l = filter->inputs[j];
217
218 if (!ff_outlink_get_status(l))
219 return 0;
220 }
221
222 for (int j = 0; j < filter->nb_outputs; j++) {
223 AVFilterLink *l = filter->outputs[j];
224
225 if (!ff_outlink_get_status(l))
226 return 0;
227 }
228
229 return 1;
230}
231
233{
234 for (int j = 0; j < filter->nb_inputs; j++) {
235 AVFilterLink *l = filter->inputs[j];
237
238 if (frames)
239 return 1;
240 }
241
242 for (int j = 0; j < filter->nb_outputs; j++) {
243 AVFilterLink *l = filter->outputs[j];
245
246 if (frames)
247 return 1;
248 }
249
250 return 0;
251}
252
255 AVFrame *out,
256 int xpos, int ypos,
257 AVFilterLink *l,
258 size_t frames)
259{
260 GraphMonitorContext *s = ctx->priv;
261 FilterLink *fl = ff_filter_link(l);
262 int64_t previous_pts_us = s->cache[s->cache_index].previous_pts_us;
263 int64_t current_pts_us = fl->current_pts_us;
264 const int flags = s->flags;
265 const int mode = s->mode;
266 char buffer[1024] = { 0 };
267 int len = 0;
268
269 if (flags & FLAG_FMT) {
270 if (l->type == AVMEDIA_TYPE_VIDEO) {
271 len = snprintf(buffer, sizeof(buffer)-1, " | format: %s",
273 } else if (l->type == AVMEDIA_TYPE_AUDIO) {
274 len = snprintf(buffer, sizeof(buffer)-1, " | format: %s",
276 }
277 drawtext(out, xpos, ypos, buffer, len, s->white);
278 xpos += len * 8;
279 }
280 if (flags & FLAG_SIZE) {
281 if (l->type == AVMEDIA_TYPE_VIDEO) {
282 len = snprintf(buffer, sizeof(buffer)-1, " | size: %dx%d", l->w, l->h);
283 } else if (l->type == AVMEDIA_TYPE_AUDIO) {
284 len = snprintf(buffer, sizeof(buffer)-1, " | channels: %d", l->ch_layout.nb_channels);
285 }
286 drawtext(out, xpos, ypos, buffer, len, s->white);
287 xpos += len * 8;
288 }
289 if (flags & FLAG_RATE) {
290 if (l->type == AVMEDIA_TYPE_VIDEO) {
291 len = snprintf(buffer, sizeof(buffer)-1, " | fps: %d/%d", fl->frame_rate.num, fl->frame_rate.den);
292 } else if (l->type == AVMEDIA_TYPE_AUDIO) {
293 len = snprintf(buffer, sizeof(buffer)-1, " | samplerate: %d", l->sample_rate);
294 }
295 drawtext(out, xpos, ypos, buffer, len, s->white);
296 xpos += len * 8;
297 }
298 if (flags & FLAG_TB) {
299 len = snprintf(buffer, sizeof(buffer)-1, " | tb: %d/%d", l->time_base.num, l->time_base.den);
300 drawtext(out, xpos, ypos, buffer, len, s->white);
301 xpos += len * 8;
302 }
303 if ((flags & FLAG_QUEUE) && (!(mode & MODE_NOZERO) || frames)) {
304 len = snprintf(buffer, sizeof(buffer)-1, " | queue: ");
305 drawtext(out, xpos, ypos, buffer, len, s->white);
306 xpos += len * 8;
307 len = snprintf(buffer, sizeof(buffer)-1, "%zu", frames);
308 drawtext(out, xpos, ypos, buffer, len, frames > 0 ? frames >= 10 ? frames >= 50 ? s->red : s->yellow : s->green : s->white);
309 xpos += len * 8;
310 }
311 if ((flags & FLAG_FCIN) && (!(mode & MODE_NOZERO) || fl->frame_count_in)) {
312 len = snprintf(buffer, sizeof(buffer)-1, " | in: %"PRId64, fl->frame_count_in);
313 drawtext(out, xpos, ypos, buffer, len, s->white);
314 xpos += len * 8;
315 }
316 if ((flags & FLAG_FCOUT) && (!(mode & MODE_NOZERO) || fl->frame_count_out)) {
317 len = snprintf(buffer, sizeof(buffer)-1, " | out: %"PRId64, fl->frame_count_out);
318 drawtext(out, xpos, ypos, buffer, len, s->white);
319 xpos += len * 8;
320 }
321 if ((flags & FLAG_FC_DELTA) && (!(mode & MODE_NOZERO) || (fl->frame_count_in - fl->frame_count_out))) {
322 len = snprintf(buffer, sizeof(buffer)-1, " | delta: %"PRId64, fl->frame_count_in - fl->frame_count_out);
323 drawtext(out, xpos, ypos, buffer, len, s->white);
324 xpos += len * 8;
325 }
326 if ((flags & FLAG_SCIN) && (!(mode & MODE_NOZERO) || fl->sample_count_in)) {
327 len = snprintf(buffer, sizeof(buffer)-1, " | sin: %"PRId64, fl->sample_count_in);
328 drawtext(out, xpos, ypos, buffer, len, s->white);
329 xpos += len * 8;
330 }
331 if ((flags & FLAG_SCOUT) && (!(mode & MODE_NOZERO) || fl->sample_count_out)) {
332 len = snprintf(buffer, sizeof(buffer)-1, " | sout: %"PRId64, fl->sample_count_out);
333 drawtext(out, xpos, ypos, buffer, len, s->white);
334 xpos += len * 8;
335 }
336 if ((flags & FLAG_SC_DELTA) && (!(mode & MODE_NOZERO) || (fl->sample_count_in - fl->sample_count_out))) {
337 len = snprintf(buffer, sizeof(buffer)-1, " | sdelta: %"PRId64, fl->sample_count_in - fl->sample_count_out);
338 drawtext(out, xpos, ypos, buffer, len, s->white);
339 xpos += len * 8;
340 }
341 if ((flags & FLAG_PTS) && (!(mode & MODE_NOZERO) || current_pts_us)) {
342 len = snprintf(buffer, sizeof(buffer)-1, " | pts: %s", av_ts2str(current_pts_us));
343 drawtext(out, xpos, ypos, buffer, len, s->white);
344 xpos += len * 8;
345 }
346 if ((flags & FLAG_PTS_DELTA) && (!(mode & MODE_NOZERO) || (current_pts_us - previous_pts_us))) {
347 len = snprintf(buffer, sizeof(buffer)-1, " | pts_delta: %s", av_ts2str(current_pts_us - previous_pts_us));
348 drawtext(out, xpos, ypos, buffer, len, s->white);
349 xpos += len * 8;
350 }
351 if ((flags & FLAG_TIME) && (!(mode & MODE_NOZERO) || current_pts_us)) {
352 len = snprintf(buffer, sizeof(buffer)-1, " | time: %s", av_ts2timestr(current_pts_us, &AV_TIME_BASE_Q));
353 drawtext(out, xpos, ypos, buffer, len, s->white);
354 xpos += len * 8;
355 }
356 if ((flags & FLAG_TIME_DELTA) && (!(mode & MODE_NOZERO) || (current_pts_us - previous_pts_us))) {
357 len = snprintf(buffer, sizeof(buffer)-1, " | time_delta: %s", av_ts2timestr(current_pts_us - previous_pts_us, &AV_TIME_BASE_Q));
358 drawtext(out, xpos, ypos, buffer, len, s->white);
359 xpos += len * 8;
360 }
361 if ((flags & FLAG_EOF) && ff_outlink_get_status(l)) {
362 len = snprintf(buffer, sizeof(buffer)-1, " | eof");
363 drawtext(out, xpos, ypos, buffer, len, s->blue);
364 xpos += len * 8;
365 }
366 if ((flags & FLAG_DISABLED) && filter->is_disabled) {
367 len = snprintf(buffer, sizeof(buffer)-1, " | off");
368 drawtext(out, xpos, ypos, buffer, len, s->gray);
369 xpos += len * 8;
370 }
371
372 s->cache[s->cache_index].previous_pts_us = current_pts_us;
373
374 if (s->cache_index + 1 >= s->cache_size / sizeof(*(s->cache))) {
375 void *ptr = av_fast_realloc(s->cache, &s->cache_size, s->cache_size * 2);
376
377 if (!ptr)
378 return AVERROR(ENOMEM);
379 s->cache = ptr;
380 }
381 s->cache_index++;
382
383 return 0;
384}
385
387{
388 GraphMonitorContext *s = ctx->priv;
389 AVFilterLink *outlink = ctx->outputs[0];
390 int ret, len, xpos, ypos = 0;
391 char buffer[1024];
392 AVFrame *out;
393
394 out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
395 if (!out)
396 return AVERROR(ENOMEM);
397
398 s->bg[3] = 255 * s->opacity;
399 clear_image(s, out, outlink);
400
401 s->cache_index = 0;
402
403 for (int i = 0; i < ctx->graph->nb_filters; i++) {
404 AVFilterContext *filter = ctx->graph->filters[i];
405
406 if ((s->mode & MODE_COMPACT) && !filter_have_queued(filter))
407 continue;
408
409 if ((s->mode & MODE_NOEOF) && filter_have_eof(filter))
410 continue;
411
412 if ((s->mode & MODE_NODISABLED) && filter->is_disabled)
413 continue;
414
415 xpos = 0;
416 len = strlen(filter->name);
417 drawtext(out, xpos, ypos, filter->name, len, s->white);
418 xpos += len * 8 + 10;
419 len = strlen(filter->filter->name);
420 drawtext(out, xpos, ypos, filter->filter->name, len, s->white);
421 ypos += 10;
422 for (int j = 0; j < filter->nb_inputs; j++) {
423 AVFilterLink *l = filter->inputs[j];
425
426 if ((s->mode & MODE_COMPACT) && !frames)
427 continue;
428
429 if ((s->mode & MODE_NOEOF) && ff_outlink_get_status(l))
430 continue;
431
432 xpos = 10;
433 len = snprintf(buffer, sizeof(buffer)-1, "in%d: ", j);
434 drawtext(out, xpos, ypos, buffer, len, s->white);
435 xpos += len * 8;
436 len = strlen(l->src->name);
437 drawtext(out, xpos, ypos, l->src->name, len, s->white);
438 xpos += len * 8 + 10;
439 ret = draw_items(ctx, filter, out, xpos, ypos, l, frames);
440 if (ret < 0)
441 goto error;
442 ypos += 10;
443 }
444
445 ypos += 2;
446 for (int j = 0; j < filter->nb_outputs; j++) {
447 AVFilterLink *l = filter->outputs[j];
449
450 if ((s->mode & MODE_COMPACT) && !frames)
451 continue;
452
453 if ((s->mode & MODE_NOEOF) && ff_outlink_get_status(l))
454 continue;
455
456 xpos = 10;
457 len = snprintf(buffer, sizeof(buffer)-1, "out%d: ", j);
458 drawtext(out, xpos, ypos, buffer, len, s->white);
459 xpos += len * 8;
460 len = strlen(l->dst->name);
461 drawtext(out, xpos, ypos, l->dst->name, len, s->white);
462 xpos += len * 8 + 10;
463 ret = draw_items(ctx, filter, out, xpos, ypos, l, frames);
464 if (ret < 0)
465 goto error;
466 ypos += 10;
467 }
468 ypos += 5;
469 }
470
471 out->pts = pts;
472 out->duration = 1;
473 s->pts = pts + 1;
474 if (s->eof_frames)
475 s->eof_frames = 0;
476 return ff_filter_frame(outlink, out);
477error:
479 return ret;
480}
481
483{
484 GraphMonitorContext *s = ctx->priv;
485 AVFilterLink *inlink = ctx->inputs[0];
486 AVFilterLink *outlink = ctx->outputs[0];
488 int status;
489
490 FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
491
492 if (!s->eof && ff_inlink_queued_frames(inlink)) {
493 AVFrame *frame = NULL;
494 int ret;
495
496 ret = ff_inlink_consume_frame(inlink, &frame);
497 if (ret < 0)
498 return ret;
499 if (ret > 0) {
500 pts = frame->pts;
502 }
503 }
504
505 if (pts != AV_NOPTS_VALUE) {
506 pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
507 if (s->pts == AV_NOPTS_VALUE)
508 s->pts = pts;
509 s->next_pts = pts;
510 } else if (s->eof) {
511 s->next_pts = s->pts + 1;
512 }
513
514 if (s->eof && s->eof_frames == 0) {
515 ff_outlink_set_status(outlink, AVERROR_EOF, s->next_pts);
516 return 0;
517 }
518
519 if (s->eof || (s->pts < s->next_pts && ff_outlink_frame_wanted(outlink)))
520 return create_frame(ctx, s->pts);
521
522 if (!s->eof && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
523 s->eof = 1;
524 s->eof_frames = 1;
526 return 0;
527 }
528
529 if (!s->eof) {
530 FF_FILTER_FORWARD_WANTED(outlink, inlink);
531 } else {
533 return 0;
534 }
535
536 return FFERROR_NOT_READY;
537}
538
539static int config_output(AVFilterLink *outlink)
540{
541 FilterLink *l = ff_filter_link(outlink);
542 GraphMonitorContext *s = outlink->src->priv;
543
544 s->white[0] = s->white[1] = s->white[2] = 255;
545 s->yellow[0] = s->yellow[1] = 255;
546 s->red[0] = 255;
547 s->green[1] = 255;
548 s->blue[2] = 255;
549 s->gray[0] = s->gray[1] = s->gray[2] = 128;
550 s->pts = AV_NOPTS_VALUE;
551 s->next_pts = AV_NOPTS_VALUE;
552 outlink->w = s->w;
553 outlink->h = s->h;
554 outlink->sample_aspect_ratio = (AVRational){1,1};
555 l->frame_rate = s->frame_rate;
556 outlink->time_base = av_inv_q(s->frame_rate);
557
558 return 0;
559}
560
562{
563 GraphMonitorContext *s = ctx->priv;
564
565 av_freep(&s->cache);
566 s->cache_size = s->cache_index = 0;
567}
568
569AVFILTER_DEFINE_CLASS_EXT(graphmonitor, "(a)graphmonitor", graphmonitor_options);
570
572 {
573 .name = "default",
574 .type = AVMEDIA_TYPE_VIDEO,
575 .config_props = config_output,
576 },
577};
578
579#if CONFIG_GRAPHMONITOR_FILTER
580
582 .p.name = "graphmonitor",
583 .p.description = NULL_IF_CONFIG_SMALL("Show various filtergraph stats."),
584 .p.priv_class = &graphmonitor_class,
585 .priv_size = sizeof(GraphMonitorContext),
586 .init = init,
587 .uninit = uninit,
592 .process_command = ff_filter_process_command,
593};
594
595#endif // CONFIG_GRAPHMONITOR_FILTER
596
597#if CONFIG_AGRAPHMONITOR_FILTER
598
600 .p.name = "agraphmonitor",
601 .p.description = NULL_IF_CONFIG_SMALL("Show various filtergraph stats."),
602 .p.priv_class = &graphmonitor_class,
603 .priv_size = sizeof(GraphMonitorContext),
604 .init = init,
605 .uninit = uninit,
610 .process_command = ff_filter_process_command,
611};
612#endif // CONFIG_AGRAPHMONITOR_FILTER
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
const FFFilter ff_avf_agraphmonitor
const FFFilter ff_vf_graphmonitor
static FILE * out
static int frames
static AVFormatContext * ctx
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
Definition audio.c:34
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
Definition avfilter.c:1648
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
Definition avfilter.c:1467
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1068
int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
Definition avfilter.c:1690
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition avfilter.c:906
size_t ff_inlink_queued_frames(AVFilterLink *link)
Get the number of frames available on the link.
Definition avfilter.c:1483
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
Definition avfilter.c:229
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:1520
Main libavfilter public API header.
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
static AVFrame * frame
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
static const AVOption graphmonitor_options[]
static int create_frame(AVFilterContext *ctx, int64_t pts)
static void clear_image(GraphMonitorContext *s, AVFrame *out, AVFilterLink *outlink)
static int filter_have_eof(AVFilterContext *filter)
@ FLAG_SCIN
@ FLAG_PTS_DELTA
@ FLAG_FCOUT
@ FLAG_FCIN
@ FLAG_RATE
@ FLAG_EOF
@ FLAG_TIME_DELTA
@ FLAG_PTS
@ FLAG_SCOUT
@ FLAG_NONE
@ FLAG_FC_DELTA
@ FLAG_QUEUE
@ FLAG_FMT
@ FLAG_TB
@ FLAG_SIZE
@ FLAG_SC_DELTA
@ FLAG_DISABLED
@ FLAG_TIME
static void drawtext(AVFrame *pic, int x, int y, const char *txt, const int len, uint8_t *color)
static int filter_have_queued(AVFilterContext *filter)
static int draw_items(AVFilterContext *ctx, AVFilterContext *filter, AVFrame *out, int xpos, int ypos, AVFilterLink *l, size_t frames)
#define VFR
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int activate(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad graphmonitor_outputs[]
#define OFFSET(x)
static int config_output(AVFilterLink *outlink)
@ MODE_NODISABLED
@ MODE_COMPACT
@ MODE_MAX
@ MODE_FULL
@ MODE_NOZERO
@ MODE_NOEOF
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add ref as a new reference to formats.
Definition formats.c:756
av_warn_unused_result AVFilterFormats * ff_make_pixel_format_list(const enum AVPixelFormat *fmts)
Create a list of supported pixel formats.
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition opt.h:302
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition opt.h:254
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition opt.h:314
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition opt.h:270
#define AVERROR_EOF
End of file.
Definition error.h:57
#define AVERROR(e)
Definition error.h:45
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition rational.h:159
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
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
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
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
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition avutil.h:247
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition avutil.h:263
#define AV_WN32(p, v)
#define AV_RN32(p)
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
#define VF
Definition af_afir.c:733
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FF_FILTER_FORWARD_WANTED(outlink, inlink)
Forward the frame_wanted_out flag from an output link to an input link.
Definition filters.h:694
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
Definition filters.h:629
#define FFERROR_NOT_READY
Filters implementation helper functions and internal structures.
Definition filters.h:34
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
Definition filters.h:639
#define AVFILTER_DEFINE_CLASS_EXT(name, desc, options)
Definition filters.h:470
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition filters.h:199
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:241
#define av_cold
Definition attributes.h:117
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
uint8_t w
Definition llvidencdsp.c:39
static const uint16_t mask[17]
Definition lzw.c:38
Memory handling functions.
AVOptions.
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:3380
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition pixfmt.h:100
formats
Definition signature.h:47
#define snprintf
Definition snprintf.h:34
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
Definition log.h:76
An instance of a filter.
Definition avfilter.h:273
char * name
name of this filter instance
Definition avfilter.h:278
void * priv
private data for use by the filter
Definition avfilter.h:288
Lists of formats / etc.
Definition avfilter.h:120
A list of supported formats for one end of a filter link.
Definition formats.h:64
A filter pad used for either input or output.
Definition filters.h:40
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition frame.h:493
int width
Definition frame.h:544
int height
Definition frame.h:544
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:517
AVOption.
Definition opt.h:428
Rational number (pair of numerator and denominator).
Definition rational.h:58
int num
Numerator.
Definition rational.h:59
int den
Denominator.
Definition rational.h:60
int64_t previous_pts_us
unsigned int cache_index
unsigned int cache_size
Definition swscale.c:71
#define av_freep(p)
static void error(const char *err)
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
Definition h263dsp.c:29
static char buffer[20]
Definition seek.c:32
timestamp utils, mostly useful for debugging/logging purposes
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition timestamp.h:54
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition timestamp.h:83
static int64_t pts
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition video.c:37
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition video.c:89
int len
const uint8_t * avpriv_cga_font_get(void)
CGA/EGA/VGA ROM font data.