diff mbox series

[FFmpeg-devel,3/3] avfilter/f_graphmonitor: use sample_count_in/out

Message ID 20210805111717.1474-3-onemda@gmail.com
State Accepted
Commit 9dbf95f2099a6f53d87c0041d9c2ac710fb80366
Headers show
Series [FFmpeg-devel,1/3] avfilter/avfilter: add sample_count_in and sample_count_out | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Paul B Mahol Aug. 5, 2021, 11:17 a.m. UTC
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 doc/filters.texi             |  6 ++++++
 libavfilter/f_graphmonitor.c | 14 ++++++++++++++
 2 files changed, 20 insertions(+)
diff mbox series

Patch

diff --git a/doc/filters.texi b/doc/filters.texi
index 7a266c2a32..28996a4a64 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -13020,6 +13020,12 @@  Display video frame rate or sample rate in case of audio used by filter link.
 
 @item eof
 Display link output status.
+
+@item sample_count_in
+Display number of samples taken from filter.
+
+@item sample_count_out
+Display number of samples given out from filter.
 @end table
 
 @item rate, r
diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c
index ba17f1f638..90e93a4ac3 100644
--- a/libavfilter/f_graphmonitor.c
+++ b/libavfilter/f_graphmonitor.c
@@ -62,6 +62,8 @@  enum {
     MODE_SIZE  = 1 << 7,
     MODE_RATE  = 1 << 8,
     MODE_EOF   = 1 << 9,
+    MODE_SCIN  = 1 << 10,
+    MODE_SCOUT = 1 << 11,
 };
 
 #define OFFSET(x) offsetof(GraphMonitorContext, x)
@@ -88,6 +90,8 @@  static const AVOption graphmonitor_options[] = {
         { "size",             NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_SIZE},    0, 0, VF, "flags" },
         { "rate",             NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_RATE},    0, 0, VF, "flags" },
         { "eof",              NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_EOF},     0, 0, VF, "flags" },
+        { "sample_count_in",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_SCOUT},   0, 0, VF, "flags" },
+        { "sample_count_out", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_SCIN},    0, 0, VF, "flags" },
     { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, VF },
     { "r",    "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, VF },
     { NULL }
@@ -229,6 +233,16 @@  static void draw_items(AVFilterContext *ctx, AVFrame *out,
         drawtext(out, xpos, ypos, buffer, s->white);
         xpos += strlen(buffer) * 8;
     }
+    if (s->flags & MODE_SCIN) {
+        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 & MODE_SCOUT) {
+        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 & MODE_PTS) {
         snprintf(buffer, sizeof(buffer)-1, " | pts: %s", av_ts2str(l->current_pts_us));
         drawtext(out, xpos, ypos, buffer, s->white);