[FFmpeg-cvslog] avfilter/f_graphmonitor: add nozeroeof mode

Paul B Mahol git at videolan.org
Thu May 18 19:15:20 EEST 2023


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Wed May 17 01:32:01 2023 +0200| [386de9319e6020bd6464a9da9b763752e248e620] | committer: Paul B Mahol

avfilter/f_graphmonitor: add nozeroeof mode

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=386de9319e6020bd6464a9da9b763752e248e620
---

 libavfilter/f_graphmonitor.c | 52 ++++++++++++++++++++++++++++++++++----------
 1 file changed, 41 insertions(+), 11 deletions(-)

diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c
index d48f9fd990..fa213d6e79 100644
--- a/libavfilter/f_graphmonitor.c
+++ b/libavfilter/f_graphmonitor.c
@@ -65,6 +65,7 @@ enum {
     MODE_FULL,
     MODE_COMPACT,
     MODE_NOZERO,
+    MODE_NOZEROEOF,
     NB_MODES
 };
 
@@ -100,6 +101,7 @@ static const AVOption graphmonitor_options[] = {
         { "full",     NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_FULL},   0, 0, VF, "mode" },
         { "compact",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_COMPACT},0, 0, VF, "mode" },
         { "nozero",   NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_NOZERO}, 0, 0, VF, "mode" },
+        { "nozeroeof",   NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_NOZEROEOF}, 0, 0, VF, "mode" },
     { "flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=FLAG_QUEUE}, 0, INT_MAX, VF, "flags" },
     { "f",     "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=FLAG_QUEUE}, 0, INT_MAX, VF, "flags" },
         { "queue",            NULL, 0, AV_OPT_TYPE_CONST, {.i64=FLAG_QUEUE},   0, 0, VF, "flags" },
@@ -190,6 +192,25 @@ static void drawtext(AVFrame *pic, int x, int y, const char *txt, uint8_t *color
     }
 }
 
+static int filter_have_eof(AVFilterContext *filter)
+{
+    for (int j = 0; j < filter->nb_inputs; j++) {
+        AVFilterLink *l = filter->inputs[j];
+
+        if (!ff_outlink_get_status(l))
+            return 0;
+    }
+
+    for (int j = 0; j < filter->nb_outputs; j++) {
+        AVFilterLink *l = filter->outputs[j];
+
+        if (!ff_outlink_get_status(l))
+            return 0;
+    }
+
+    return 1;
+}
+
 static int filter_have_queued(AVFilterContext *filter)
 {
     for (int j = 0; j < filter->nb_inputs; j++) {
@@ -255,7 +276,7 @@ static int draw_items(AVFilterContext *ctx, AVFrame *out,
         drawtext(out, xpos, ypos, buffer, s->white);
         xpos += strlen(buffer) * 8;
     }
-    if ((s->flags & FLAG_QUEUE) && (s->mode != MODE_NOZERO || frames)) {
+    if ((s->flags & FLAG_QUEUE) && (s->mode < MODE_NOZERO || frames)) {
         snprintf(buffer, sizeof(buffer)-1, " | queue: ");
         drawtext(out, xpos, ypos, buffer, s->white);
         xpos += strlen(buffer) * 8;
@@ -263,52 +284,52 @@ static int draw_items(AVFilterContext *ctx, AVFrame *out,
         drawtext(out, xpos, ypos, buffer, frames > 0 ? frames >= 10 ? frames >= 50 ? s->red : s->yellow : s->green : s->white);
         xpos += strlen(buffer) * 8;
     }
-    if ((s->flags & FLAG_FCIN) && (s->mode != MODE_NOZERO || l->frame_count_in)) {
+    if ((s->flags & FLAG_FCIN) && (s->mode < MODE_NOZERO || l->frame_count_in)) {
         snprintf(buffer, sizeof(buffer)-1, " | in: %"PRId64, l->frame_count_in);
         drawtext(out, xpos, ypos, buffer, s->white);
         xpos += strlen(buffer) * 8;
     }
-    if ((s->flags & FLAG_FCOUT) && (s->mode != MODE_NOZERO || l->frame_count_out)) {
+    if ((s->flags & FLAG_FCOUT) && (s->mode < MODE_NOZERO || l->frame_count_out)) {
         snprintf(buffer, sizeof(buffer)-1, " | out: %"PRId64, l->frame_count_out);
         drawtext(out, xpos, ypos, buffer, s->white);
         xpos += strlen(buffer) * 8;
     }
-    if ((s->flags & FLAG_FC_DELTA) && (s->mode != MODE_NOZERO || (l->frame_count_in - l->frame_count_out))) {
+    if ((s->flags & FLAG_FC_DELTA) && (s->mode < MODE_NOZERO || (l->frame_count_in - l->frame_count_out))) {
         snprintf(buffer, sizeof(buffer)-1, " | delta: %"PRId64, l->frame_count_in - l->frame_count_out);
         drawtext(out, xpos, ypos, buffer, s->white);
         xpos += strlen(buffer) * 8;
     }
-    if ((s->flags & FLAG_SCIN) && (s->mode != MODE_NOZERO || l->sample_count_in)) {
+    if ((s->flags & FLAG_SCIN) && (s->mode < MODE_NOZERO || l->sample_count_in)) {
         snprintf(buffer, sizeof(buffer)-1, " | sin: %"PRId64, l->sample_count_in);
         drawtext(out, xpos, ypos, buffer, s->white);
         xpos += strlen(buffer) * 8;
     }
-    if ((s->flags & FLAG_SCOUT) && (s->mode != MODE_NOZERO || l->sample_count_out)) {
+    if ((s->flags & FLAG_SCOUT) && (s->mode < MODE_NOZERO || l->sample_count_out)) {
         snprintf(buffer, sizeof(buffer)-1, " | sout: %"PRId64, l->sample_count_out);
         drawtext(out, xpos, ypos, buffer, s->white);
         xpos += strlen(buffer) * 8;
     }
-    if ((s->flags & FLAG_SC_DELTA) && (s->mode != MODE_NOZERO || (l->sample_count_in - l->sample_count_out))) {
+    if ((s->flags & FLAG_SC_DELTA) && (s->mode < MODE_NOZERO || (l->sample_count_in - l->sample_count_out))) {
         snprintf(buffer, sizeof(buffer)-1, " | sdelta: %"PRId64, l->sample_count_in - l->sample_count_out);
         drawtext(out, xpos, ypos, buffer, s->white);
         xpos += strlen(buffer) * 8;
     }
-    if ((s->flags & FLAG_PTS) && (s->mode != MODE_NOZERO || current_pts_us)) {
+    if ((s->flags & FLAG_PTS) && (s->mode < MODE_NOZERO || current_pts_us)) {
         snprintf(buffer, sizeof(buffer)-1, " | pts: %s", av_ts2str(current_pts_us));
         drawtext(out, xpos, ypos, buffer, s->white);
         xpos += strlen(buffer) * 8;
     }
-    if ((s->flags & FLAG_PTS_DELTA) && (s->mode != MODE_NOZERO || (current_pts_us - previous_pts_us))) {
+    if ((s->flags & FLAG_PTS_DELTA) && (s->mode < MODE_NOZERO || (current_pts_us - previous_pts_us))) {
         snprintf(buffer, sizeof(buffer)-1, " | pts_delta: %s", av_ts2str(current_pts_us - previous_pts_us));
         drawtext(out, xpos, ypos, buffer, s->white);
         xpos += strlen(buffer) * 8;
     }
-    if ((s->flags & FLAG_TIME) && (s->mode != MODE_NOZERO || current_pts_us)) {
+    if ((s->flags & FLAG_TIME) && (s->mode < MODE_NOZERO || current_pts_us)) {
         snprintf(buffer, sizeof(buffer)-1, " | time: %s", av_ts2timestr(current_pts_us, &AV_TIME_BASE_Q));
         drawtext(out, xpos, ypos, buffer, s->white);
         xpos += strlen(buffer) * 8;
     }
-    if ((s->flags & FLAG_TIME_DELTA) && (s->mode != MODE_NOZERO || (current_pts_us - previous_pts_us))) {
+    if ((s->flags & FLAG_TIME_DELTA) && (s->mode < MODE_NOZERO || (current_pts_us - previous_pts_us))) {
         snprintf(buffer, sizeof(buffer)-1, " | time_delta: %s", av_ts2timestr(current_pts_us - previous_pts_us, &AV_TIME_BASE_Q));
         drawtext(out, xpos, ypos, buffer, s->white);
         xpos += strlen(buffer) * 8;
@@ -355,6 +376,9 @@ static int create_frame(AVFilterContext *ctx, int64_t pts)
         if (s->mode == MODE_COMPACT && !filter_have_queued(filter))
             continue;
 
+        if (s->mode == MODE_NOZEROEOF && filter_have_eof(filter))
+            continue;
+
         xpos = 0;
         drawtext(out, xpos, ypos, filter->name, s->white);
         xpos += strlen(filter->name) * 8 + 10;
@@ -367,6 +391,9 @@ static int create_frame(AVFilterContext *ctx, int64_t pts)
             if (s->mode == MODE_COMPACT && !frames)
                 continue;
 
+            if (s->mode == MODE_NOZEROEOF && ff_outlink_get_status(l))
+                continue;
+
             xpos = 10;
             snprintf(buffer, sizeof(buffer)-1, "in%d: ", j);
             drawtext(out, xpos, ypos, buffer, s->white);
@@ -387,6 +414,9 @@ static int create_frame(AVFilterContext *ctx, int64_t pts)
             if (s->mode == MODE_COMPACT && !frames)
                 continue;
 
+            if (s->mode == MODE_NOZEROEOF && ff_outlink_get_status(l))
+                continue;
+
             xpos = 10;
             snprintf(buffer, sizeof(buffer)-1, "out%d: ", j);
             drawtext(out, xpos, ypos, buffer, s->white);



More information about the ffmpeg-cvslog mailing list