From: Nicolas George <george@nsup.org>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 2/7] lavfi/graphdump: add plain listing output
Date: Tue, 2 Aug 2022 18:54:16 +0200
Message-ID: <20220802165421.137563-2-george@nsup.org> (raw)
In-Reply-To: <20220802165421.137563-1-george@nsup.org>
Signed-off-by: Nicolas George <george@nsup.org>
---
libavfilter/avfilter.h | 5 ++-
libavfilter/graphdump.c | 79 +++++++++++++++++++++++++++++++++++++++--
2 files changed, 80 insertions(+), 4 deletions(-)
Identical to the one posted months ago.
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 2e8197c9a6..ad38f1bdc2 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -1163,7 +1163,10 @@ int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const
* Dump a graph into a human-readable string representation.
*
* @param graph the graph to dump
- * @param options formatting options; currently ignored
+ * @param options formatting options; can be NULL, empty
+ * or "f=aa" for clumsy ascii-art drawing,
+ * or "f=tech" for plain listing;
+ * other values silently ignored
* @return a string, or NULL in case of memory allocation failure;
* the string must be freed using av_free
*/
diff --git a/libavfilter/graphdump.c b/libavfilter/graphdump.c
index 80f7bf6c98..992183a882 100644
--- a/libavfilter/graphdump.c
+++ b/libavfilter/graphdump.c
@@ -27,6 +27,9 @@
#include "avfilter.h"
#include "internal.h"
+#define FORMAT_AA 0
+#define FORMAT_TECH 1
+
static int print_link_prop(AVBPrint *buf, AVFilterLink *link)
{
const char *format;
@@ -62,7 +65,51 @@ static int print_link_prop(AVBPrint *buf, AVFilterLink *link)
return buf->len;
}
-static void avfilter_graph_dump_to_buf(AVBPrint *buf, AVFilterGraph *graph)
+static inline const char *fcname(const AVFilterContext *filter)
+{
+ return filter->name ? filter->name : "<unnamed>";
+}
+
+static void dump_tech(AVBPrint *buf, AVFilterGraph *graph)
+{
+ unsigned i, j;
+
+ for (i = 0; i < graph->nb_filters; i++) {
+ AVFilterContext *filter = graph->filters[i];
+
+ if (i)
+ av_bprintf(buf, "\n");
+ av_bprintf(buf, "Filter: %s (%s)\n", fcname(filter), filter->filter->name);
+
+ for (j = 0; j < filter->nb_inputs; j++) {
+ AVFilterPad *pad = &filter->input_pads[j];
+ AVFilterLink *link = filter->inputs[j];
+ AVFilterPad *ppad = link->srcpad;
+ AVFilterContext *peer = link->src;
+
+ av_bprintf(buf, " in %d: %s ← %s.%d:%s ",
+ j, pad->name,
+ fcname(peer), FF_OUTLINK_IDX(link), ppad->name);
+ print_link_prop(buf, link);
+ av_bprintf(buf, "\n");
+ }
+
+ for (j = 0; j < filter->nb_outputs; j++) {
+ AVFilterPad *pad = &filter->output_pads[j];
+ AVFilterLink *link = filter->outputs[j];
+ AVFilterPad *ppad = link->dstpad;
+ AVFilterContext *peer = link->dst;
+
+ av_bprintf(buf, " out %d: %s → %s.%d:%s ",
+ j, pad->name,
+ fcname(peer), FF_INLINK_IDX(link), ppad->name);
+ print_link_prop(buf, link);
+ av_bprintf(buf, "\n");
+ }
+ }
+}
+
+static void dump_ascii_art(AVBPrint *buf, AVFilterGraph *graph)
{
unsigned i, j, x, e;
@@ -154,17 +201,43 @@ static void avfilter_graph_dump_to_buf(AVBPrint *buf, AVFilterGraph *graph)
}
}
+static void avfilter_graph_dump_to_buf(AVBPrint *buf, AVFilterGraph *graph, const char *options)
+{
+ unsigned format = FORMAT_AA;
+
+ /* For a very long time, options was ignored.
+ Having a string for that task was a mistake, but it is not important.
+ It is not worth a proper parsing.
+ */
+ if (options && *options) {
+ if (!strcmp("f=aa", options)) {
+ format = FORMAT_AA;
+ } else if (!strcmp("f=tech", options)) {
+ format = FORMAT_TECH;
+ }
+ /* ignore other values */
+ }
+ switch (format) {
+ case FORMAT_AA:
+ dump_ascii_art(buf, graph);
+ break;
+ case FORMAT_TECH:
+ dump_tech(buf, graph);
+ break;
+ }
+}
+
char *avfilter_graph_dump(AVFilterGraph *graph, const char *options)
{
AVBPrint buf;
char *dump = NULL;
av_bprint_init(&buf, 0, AV_BPRINT_SIZE_COUNT_ONLY);
- avfilter_graph_dump_to_buf(&buf, graph);
+ avfilter_graph_dump_to_buf(&buf, graph, options);
dump = av_malloc(buf.len + 1);
if (!dump)
return NULL;
av_bprint_init_for_buffer(&buf, dump, buf.len + 1);
- avfilter_graph_dump_to_buf(&buf, graph);
+ avfilter_graph_dump_to_buf(&buf, graph, options);
return dump;
}
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-08-02 16:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-02 16:54 [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions Nicolas George
2022-08-02 16:54 ` Nicolas George [this message]
2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 3/7] fftools: add -lavfi_dump option Nicolas George
2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 4/7] lavfi/(a)format: factor finding the delimiter Nicolas George
2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 5/7] lavfi/(a)format: support slash as a delimiter Nicolas George
2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 6/7] lavi/pixdesc: add comments about pixel format scoring Nicolas George
2022-08-04 13:52 ` Michael Niedermayer
2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 7/7] tests: add coverage for libavfilter's format negotiation Nicolas George
2022-08-04 13:49 ` [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions Michael Niedermayer
2022-08-04 13:57 ` Nicolas George
2022-08-04 15:04 ` Michael Niedermayer
2022-08-06 10:36 ` Nicolas George
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220802165421.137563-2-george@nsup.org \
--to=george@nsup.org \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git