History

avfilter/f_graphmonitor: add nozero display mode

Paul B Mahol committed 3 years ago

Commit c27895b1 parent 6eecfc52 files · +28 −20Browse files

Unified · Split

2 files
  1. doc/filters.texi +2 −1
  2. libavfilter/f_graphmonitor.c +26 −19
doc/filters.texi+2−1
@@ -14639,8 +14639,9 @@ Set video output size. Default is @var{hd720}. · 14638 unmodified lines
1463914639 Set video opacity. Default is @var{0.9}. Allowed range is from @var{0} to @var{1}.
1464014640
1464114641 @item mode, m
14642−Set output mode, can be @var{fulll} or @var{compact}.
14642+Set output mode, can be @var{full} or @var{compact} or @var{nozero}.
1464314643 In @var{compact} mode only filters with some queued frames have displayed stats.
14644+In @var{nozero} mode only non-zero stats values are displayed.
1464414645
1464514646 @item flags, f
1464614647 Set flags which enable which stats are shown in video.
libavfilter/f_graphmonitor.c+26−19
@@ -61,6 +61,13 @@ typedef struct GraphMonitorContext { · 60 unmodified lines
6161 unsigned int cache_index;
6262 } GraphMonitorContext;
6363
64+enum {
65+ MODE_FULL,
66+ MODE_COMPACT,
67+ MODE_NOZERO,
68+ NB_MODES
69+};
70+
6471 enum {
6572 FLAG_QUEUE = 1 << 0,
6673 FLAG_FCIN = 1 << 1,
@@ -88,11 +95,11 @@ static const AVOption graphmonitor_options[] = { · 21 unmodified lines
8895 { "s", "set monitor size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, VF },
8996 { "opacity", "set video opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=.9}, 0, 1, VF },
9097 { "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, 2, VF, "mode" },
92− { "m", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, 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− { "nozero", NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, VF, "mode" },
98+ { "mode", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_MODES-1, VF, "mode" },
99+ { "m", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_MODES-1, VF, "mode" },
100+ { "full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_FULL}, 0, 0, VF, "mode" },
101+ { "compact", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_COMPACT},0, 0, VF, "mode" },
102+ { "nozero", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_NOZERO}, 0, 0, VF, "mode" },
96103 { "flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=FLAG_QUEUE}, 0, INT_MAX, VF, "flags" },
97104 { "f", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=FLAG_QUEUE}, 0, INT_MAX, VF, "flags" },
98105 { "queue", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_QUEUE}, 0, 0, VF, "flags" },
@@ -248,7 +255,7 @@ static int draw_items(AVFilterContext *ctx, AVFrame *out, · 149 unmodified lines
248255 drawtext(out, xpos, ypos, buffer, s->white);
249256 xpos += strlen(buffer) * 8;
250257 }
251− if (s->flags & FLAG_QUEUE) {
258+ if ((s->flags & FLAG_QUEUE) && (s->mode != MODE_NOZERO || frames)) {
252259 snprintf(buffer, sizeof(buffer)-1, " | queue: ");
253260 drawtext(out, xpos, ypos, buffer, s->white);
254261 xpos += strlen(buffer) * 8;
@@ -256,52 +263,52 @@ static int draw_items(AVFilterContext *ctx, AVFrame *out, · 1 unmodified line
256263 drawtext(out, xpos, ypos, buffer, frames > 0 ? frames >= 10 ? frames >= 50 ? s->red : s->yellow : s->green : s->white);
257264 xpos += strlen(buffer) * 8;
258265 }
259− if (s->flags & FLAG_FCIN) {
266+ if ((s->flags & FLAG_FCIN) && (s->mode != MODE_NOZERO || l->frame_count_in)) {
260267 snprintf(buffer, sizeof(buffer)-1, " | in: %"PRId64, l->frame_count_in);
261268 drawtext(out, xpos, ypos, buffer, s->white);
262269 xpos += strlen(buffer) * 8;
263270 }
264− if (s->flags & FLAG_FCOUT) {
271+ if ((s->flags & FLAG_FCOUT) && (s->mode != MODE_NOZERO || l->frame_count_out)) {
265272 snprintf(buffer, sizeof(buffer)-1, " | out: %"PRId64, l->frame_count_out);
266273 drawtext(out, xpos, ypos, buffer, s->white);
267274 xpos += strlen(buffer) * 8;
268275 }
269− if (s->flags & FLAG_FC_DELTA) {
276+ if ((s->flags & FLAG_FC_DELTA) && (s->mode != MODE_NOZERO || (l->frame_count_in - l->frame_count_out))) {
270277 snprintf(buffer, sizeof(buffer)-1, " | delta: %"PRId64, l->frame_count_in - l->frame_count_out);
271278 drawtext(out, xpos, ypos, buffer, s->white);
272279 xpos += strlen(buffer) * 8;
273280 }
274− if (s->flags & FLAG_SCIN) {
281+ if ((s->flags & FLAG_SCIN) && (s->mode != MODE_NOZERO || l->sample_count_in)) {
275282 snprintf(buffer, sizeof(buffer)-1, " | sin: %"PRId64, l->sample_count_in);
276283 drawtext(out, xpos, ypos, buffer, s->white);
277284 xpos += strlen(buffer) * 8;
278285 }
279− if (s->flags & FLAG_SCOUT) {
286+ if ((s->flags & FLAG_SCOUT) && (s->mode != MODE_NOZERO || l->sample_count_out)) {
280287 snprintf(buffer, sizeof(buffer)-1, " | sout: %"PRId64, l->sample_count_out);
281288 drawtext(out, xpos, ypos, buffer, s->white);
282289 xpos += strlen(buffer) * 8;
283290 }
284− if (s->flags & FLAG_SC_DELTA) {
291+ if ((s->flags & FLAG_SC_DELTA) && (s->mode != MODE_NOZERO || (l->sample_count_in - l->sample_count_out))) {
285292 snprintf(buffer, sizeof(buffer)-1, " | sdelta: %"PRId64, l->sample_count_in - l->sample_count_out);
286293 drawtext(out, xpos, ypos, buffer, s->white);
287294 xpos += strlen(buffer) * 8;
288295 }
289− if (s->flags & FLAG_PTS) {
296+ if ((s->flags & FLAG_PTS) && (s->mode != MODE_NOZERO || current_pts_us)) {
290297 snprintf(buffer, sizeof(buffer)-1, " | pts: %s", av_ts2str(current_pts_us));
291298 drawtext(out, xpos, ypos, buffer, s->white);
292299 xpos += strlen(buffer) * 8;
293300 }
294− if (s->flags & FLAG_PTS_DELTA) {
301+ if ((s->flags & FLAG_PTS_DELTA) && (s->mode != MODE_NOZERO || (current_pts_us - previous_pts_us))) {
295302 snprintf(buffer, sizeof(buffer)-1, " | pts_delta: %s", av_ts2str(current_pts_us - previous_pts_us));
296303 drawtext(out, xpos, ypos, buffer, s->white);
297304 xpos += strlen(buffer) * 8;
298305 }
299− if (s->flags & FLAG_TIME) {
306+ if ((s->flags & FLAG_TIME) && (s->mode != MODE_NOZERO || current_pts_us)) {
300307 snprintf(buffer, sizeof(buffer)-1, " | time: %s", av_ts2timestr(current_pts_us, &AV_TIME_BASE_Q));
301308 drawtext(out, xpos, ypos, buffer, s->white);
302309 xpos += strlen(buffer) * 8;
303310 }
304− if (s->flags & FLAG_TIME_DELTA) {
311+ if ((s->flags & FLAG_TIME_DELTA) && (s->mode != MODE_NOZERO || (current_pts_us - previous_pts_us))) {
305312 snprintf(buffer, sizeof(buffer)-1, " | time_delta: %s", av_ts2timestr(current_pts_us - previous_pts_us, &AV_TIME_BASE_Q));
306313 drawtext(out, xpos, ypos, buffer, s->white);
307314 xpos += strlen(buffer) * 8;
@@ -345,7 +352,7 @@ static int create_frame(AVFilterContext *ctx, int64_t pts) · 37 unmodified lines
345352 AVFilterContext *filter = ctx->graph->filters[i];
346353 char buffer[1024] = { 0 };
347354
348− if (s->mode && !filter_have_queued(filter))
355+ if (s->mode == MODE_COMPACT && !filter_have_queued(filter))
349356 continue;
350357
351358 xpos = 0;
@@ -357,7 +364,7 @@ static int create_frame(AVFilterContext *ctx, int64_t pts) · 5 unmodified lines
357364 AVFilterLink *l = filter->inputs[j];
358365 size_t frames = ff_inlink_queued_frames(l);
359366
360− if (s->mode && !frames)
367+ if (s->mode == MODE_COMPACT && !frames)
361368 continue;
362369
363370 xpos = 10;
@@ -377,7 +384,7 @@ static int create_frame(AVFilterContext *ctx, int64_t pts) · 13 unmodified lines
377384 AVFilterLink *l = filter->outputs[j];
378385 size_t frames = ff_inlink_queued_frames(l);
379386
380− if (s->mode && !frames)
387+ if (s->mode == MODE_COMPACT && !frames)
381388 continue;
382389
383390 xpos = 10;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t