From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 8DA194DC20 for ; Sat, 1 Mar 2025 22:55:14 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9742D68E1FF; Sun, 2 Mar 2025 00:55:10 +0200 (EET) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0FBFF68E18D for ; Sun, 2 Mar 2025 00:54:59 +0200 (EET) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-22349bb8605so65076215ad.0; Sat, 01 Mar 2025 14:54:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740869697; x=1741474497; darn=ffmpeg.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=IkZhPL1zp84N/S8r39lvxofarGbtJ/lIf4TiYY/oNhI=; b=CQ2g9HGpXodKfiXJB3Kr3Ck//0qln9y4pyTFPrKFEAP9aNX28OyunJKBGf93IMvLEu tBKCYdVKDunyTCQRwtTiQ28o55cdljmt0uDj0FaOar5kCofqklr6PJQLUdMhKqZDQSNT 30v3V+4i7Z5a7E6t6S6GSrpiZgWyLnNmGUdefkPGo8MXjAr5t7qEoAUaiPNJv9LJrACq 0qLBzU+m3sbDBbRwIFlb4s0XOLjGBwyKQvj2iYiPlAF37P42YWNPmQXcM2j5+kzrRAGO g1M0XB9Rz3+ShKuoC37A6EHdKHWOm28xsWukorovIJ3phcYXo8YOI/2GU5KmTTOtOYIH WYew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740869697; x=1741474497; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IkZhPL1zp84N/S8r39lvxofarGbtJ/lIf4TiYY/oNhI=; b=ZJo3Z2hQat8Tas3PmU58+vpDvlXuiiKx37x1hN81hL+LkZNkWp+GNiTxP2va3+qBEp SD+l073ePU/rnI7I/R+N0/yV2RIlL9hsnHkB3ooEdYUnGSXXj0Ku/+hdCoJ3ev/gzCRt A+Gkw69bc3hJEE0XEz8B8AOcvxgBMewoci+1nvaJSm9hzEzXy4Le1a8dXHH2TuPAwA5D YAPo9C6dM46LWMcvSe9Tv9+B1VbRpjcP5IDjwKpp9pP5ChGLSj/UnEPM7aTwudkgvJf0 3XYErM4zk7HR8mbQftp3hRB2TNA/YtTS009pGMuZfLZixoFSbOYY6LSOmMPSfGTOLilq 001Q== X-Forwarded-Encrypted: i=1; AJvYcCWR45Fi4D6nTayp5qOpEp+WztHtWEGP4nxGKh6uG4YngEk+0Vj+jPSEQJEmzWAf+mYx6s1F9gxjjiDN+fePDNkZy/7deAly9qI=@ffmpeg.org X-Gm-Message-State: AOJu0YzpT/UfIUzsZX00jiFLWXDzsmlr2EMgG1ZGmHrp62wC0Z4CUJIA twXa1k4nDNF8Cte1GalOqvGxL/mnCdYkMyTKob6/GvI+wH55a/3qg7TajQ== X-Gm-Gg: ASbGnctGhS9hNJ12tQ5B5zeLBON54XuwHwaQtcoxYyLFzgDZohkFXPEOja1TTC0QVW2 IAgBimChXlyxpu2Qry0G8BssFO8E0g2FOdzpF4SX+b4ckLFtEOrSNXzSZg4QYFK0wzrgUP6Qzms qXGbmgxzMRoUD8j3Xw8xmdeGJ/gYNF6mcWHc8QTdwH5xa36QyVOnpjZrAiltYfh6DvQqdBFii8L 3fK1h3I7Nv71DcB/+lT6cLJKuppTzLQoB8MH8Tw3Ok4fQSOnh/puZZS58fnboW5hyOwUUZEmHvd UV2rZQvNk51T1IdvGsChO/QCOPtzavP+/uelpCda1quQmb4yydAp8N//Q3my55E= X-Google-Smtp-Source: AGHT+IH6LI/y6RvY5ZkkmZnx+v9O4MtT1oTVPok/KrdtXqKncdeOpswY0GqL2R7u96P//uBfIueTFQ== X-Received: by 2002:a17:903:41d2:b0:216:2dc5:233c with SMTP id d9443c01a7336-223692517f4mr134377805ad.41.1740869697059; Sat, 01 Mar 2025 14:54:57 -0800 (PST) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-223504dc2ddsm52637355ad.163.2025.03.01.14.54.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Mar 2025 14:54:56 -0800 (PST) Message-Id: In-Reply-To: References: From: ffmpegagent Date: Sat, 01 Mar 2025 22:54:44 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v4 0/7] print_graphs: Complete Filtergraph Printing X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Soft Works , softworkz , Andreas Rheinhardt Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This new version of the patchset starts by extracting the text formatting and writing APIs from ffprobe.c into a subfolder under fftools. The type naming follows public API naming style, ramping up for making it a public API in the future without another big renaming. The extraction of the text formatting APIs can be followed in smaller steps in the recent patchset "[RFC] avtextformat: Transform text writing into an independent API". To make this more review-friendly, the ffprobe changes are done in two steps. The 2nd commit includes all essential changes while the large part of renamings is deferred to the 3rd commit (containing renamings only). The graph-printing uses the extracted APIs. It supports all ffprobe output formats now. Otherwise it's functional equivalent to the previous version: * Different to other graph printing methods, this is outputting: * both, simple and complex filtergraphs * all graphs with runtime state (including auto-inserted filters) * each graph with its inputs and outputs * all filters with their in- and output pads * all connections between all input- and output pads * for each connection: * the runtime-negotiated format and media type * the hw context * if video hw context, both: hw pixfmt + sw pixfmt * Output can either be printed to stdout or written to specified file * Output is machine-readable Right after filtergraph configuration, the connection details are often not complete yet. On the other side, when waiting too long or if an error occurs somewhere, the graph info might never be printed. Experience has shown, that the most suitable and realiable point in time for printing graph information is right before cleanup. Due to the changes for multi-threading, this is no longer doable as easy as before, so the following method is used: Each filtergraph initiates its own graph printing short before cleanup into a buffer. Before final cleanup in ffmpeg.c, the outputs from the individual graphs are pieced together for the actual output to file or console. (the structure according to the output format remains valid) Example output: https://gist.github.com/softworkz/2a9e8699b288f5d40fa381c2a496e165 Update V2 * Change NULL checks to match common code style * Add Add avfilter_link_get_hw_frames_ctx() function to avoid importing filters.h * Do the same without including avfilter/filters.h (as per note from Andreas Reinhardt) Update V3 * Includes extraction and generalization of the text formatting APIs * All output formats supported now Update V4 * Fix "new warnings" were generated * Fix missing colon in commit message * Rebase due to changesin ApiChanges softworkz (7): fftools/textformat: Extract and generalize textformat api from ffprobe.c fftools/ffprobe: Change to use textformat api fftools/ffprobe: Rename writer_print_section_* and WriterContext fftools/ffmpeg_filter: Move some declaration to new header file avfilter/avfilter: Add avfilter_link_get_hw_frames_ctx() fftools/ffmpeg_graphprint: Add options for filtergraph printing fftools: Enable filtergraph printing and update docs doc/APIchanges | 3 + doc/ffmpeg.texi | 10 + fftools/Makefile | 23 + fftools/ffmpeg.c | 4 + fftools/ffmpeg.h | 3 + fftools/ffmpeg_filter.c | 193 +-- fftools/ffmpeg_filter.h | 232 +++ fftools/ffmpeg_graphprint.c | 518 +++++++ fftools/ffmpeg_graphprint.h | 35 + fftools/ffmpeg_opt.c | 12 + fftools/ffprobe.c | 2190 ++++------------------------ fftools/textformat/avtextformat.c | 671 +++++++++ fftools/textformat/avtextformat.h | 171 +++ fftools/textformat/avtextwriters.h | 68 + fftools/textformat/tf_compact.c | 282 ++++ fftools/textformat/tf_default.c | 145 ++ fftools/textformat/tf_flat.c | 174 +++ fftools/textformat/tf_ini.c | 160 ++ fftools/textformat/tf_json.c | 215 +++ fftools/textformat/tf_xml.c | 221 +++ fftools/textformat/tw_avio.c | 129 ++ fftools/textformat/tw_buffer.c | 92 ++ fftools/textformat/tw_stdout.c | 82 ++ libavfilter/avfilter.c | 9 + libavfilter/avfilter.h | 12 + libavfilter/version.h | 2 +- 26 files changed, 3576 insertions(+), 2080 deletions(-) create mode 100644 fftools/ffmpeg_filter.h create mode 100644 fftools/ffmpeg_graphprint.c create mode 100644 fftools/ffmpeg_graphprint.h create mode 100644 fftools/textformat/avtextformat.c create mode 100644 fftools/textformat/avtextformat.h create mode 100644 fftools/textformat/avtextwriters.h create mode 100644 fftools/textformat/tf_compact.c create mode 100644 fftools/textformat/tf_default.c create mode 100644 fftools/textformat/tf_flat.c create mode 100644 fftools/textformat/tf_ini.c create mode 100644 fftools/textformat/tf_json.c create mode 100644 fftools/textformat/tf_xml.c create mode 100644 fftools/textformat/tw_avio.c create mode 100644 fftools/textformat/tw_buffer.c create mode 100644 fftools/textformat/tw_stdout.c base-commit: 0245e9382c748eba91645b65a377c4c9c4a44849 Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-52%2Fsoftworkz%2Fsubmit_print_graphs5-v4 Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-52/softworkz/submit_print_graphs5-v4 Pull-Request: https://github.com/ffstaging/FFmpeg/pull/52 Range-diff vs v3: 1: 6239813ba0 = 1: 55bfc6c6a6 fftools/textformat: Extract and generalize textformat api from ffprobe.c 2: 805f66cd92 = 2: 1950903610 fftools/ffprobe: Change to use textformat api 3: 8dcc17112d = 3: 01cc022c3b fftools/ffprobe: Rename writer_print_section_* and WriterContext 4: 06174ae7ef ! 4: aed98ad79d fftools/ffmpeg_filter: Move some declaration to new header file @@ fftools/ffmpeg_filter.h (new) + +} FilterGraphPriv; + -+static FilterGraphPriv *fgp_from_fg(FilterGraph *fg) ++static inline FilterGraphPriv *fgp_from_fg(FilterGraph *fg) +{ + return (FilterGraphPriv*)fg; +} + -+static const FilterGraphPriv *cfgp_from_cfg(const FilterGraph *fg) ++static inline const FilterGraphPriv *cfgp_from_cfg(const FilterGraph *fg) +{ + return (const FilterGraphPriv*)fg; +} @@ fftools/ffmpeg_filter.h (new) + } sub2video; +} InputFilterPriv; + -+static InputFilterPriv *ifp_from_ifilter(InputFilter *ifilter) ++static inline InputFilterPriv *ifp_from_ifilter(InputFilter *ifilter) +{ + return (InputFilterPriv*)ifilter; +} @@ fftools/ffmpeg_filter.h (new) + unsigned flags; +} OutputFilterPriv; + -+static OutputFilterPriv *ofp_from_ofilter(OutputFilter *ofilter) ++static inline OutputFilterPriv *ofp_from_ofilter(OutputFilter *ofilter) +{ + return (OutputFilterPriv*)ofilter; +} 5: d93c23872f ! 5: 4b8d7ee51b avfilter/avfilter Add avfilter_link_get_hw_frames_ctx() @@ Metadata Author: softworkz ## Commit message ## - avfilter/avfilter Add avfilter_link_get_hw_frames_ctx() + avfilter/avfilter: Add avfilter_link_get_hw_frames_ctx() ## doc/APIchanges ## @@ doc/APIchanges: The last version increases of all libraries were on 2024-03-07 @@ doc/APIchanges: The last version increases of all libraries were on 2024-03-07 +2025-02-xx - xxxxxxxxxx - lavfi 10.10.100 - avfilter.h + Add avfilter_link_get_hw_frames_ctx(). + - 2025-02-xx - xxxxxxxxxx - lavu 59.57.100 - log.h - Add flags AV_LOG_PRINT_TIME and AV_LOG_PRINT_DATETIME. + 2025-03-01 - xxxxxxxxxx - lavu 59.58.100 - pixfmt.h + Add AV_PIX_FMT_GRAY32BE and AV_PIX_FMT_GRAY32LE. ## libavfilter/avfilter.c ## 6: 9d76b4df1b ! 6: f43eb56f39 fftools/ffmpeg_graphprint: Add options for filtergraph printing @@ fftools/ffmpeg_graphprint.c (new) +#include "libavutil/hwcontext.h" +#include "textformat/avtextformat.h" + ++typedef enum { ++ SECTION_ID_ROOT, ++ SECTION_ID_PROGRAM_VERSION, ++ SECTION_ID_FILTERGRAPHS, ++ SECTION_ID_FILTERGRAPH, ++ SECTION_ID_INPUTS, ++ SECTION_ID_INPUT, ++ SECTION_ID_OUTPUTS, ++ SECTION_ID_OUTPUT, ++ SECTION_ID_FILTERS, ++ SECTION_ID_FILTER, ++ SECTION_ID_HWDEViCECONTEXT, ++ SECTION_ID_HWFRAMESCONTEXT, ++ SECTION_ID_ERROR, ++ SECTION_ID_LOG, ++ SECTION_ID_LOGS, ++} SectionID; ++ ++static struct AVTextFormatSection sections[] = { ++ [SECTION_ID_ROOT] = { SECTION_ID_ROOT, "GraphDescription", AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER, ++ { SECTION_ID_ERROR, SECTION_ID_PROGRAM_VERSION, SECTION_ID_FILTERGRAPHS, SECTION_ID_LOGS, -1} }, ++ [SECTION_ID_PROGRAM_VERSION] = { SECTION_ID_PROGRAM_VERSION, "ProgramVersion", 0, { -1 } }, ++ ++ [SECTION_ID_FILTERGRAPHS] = { SECTION_ID_FILTERGRAPHS, "Graphs", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_FILTERGRAPH, -1 } }, ++ [SECTION_ID_FILTERGRAPH] = { SECTION_ID_FILTERGRAPH, "Graph", 0, { SECTION_ID_INPUTS, SECTION_ID_OUTPUTS, SECTION_ID_FILTERS, -1 }, }, ++ ++ [SECTION_ID_INPUTS] = { SECTION_ID_INPUTS, "Inputs", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_INPUT, SECTION_ID_ERROR, -1 } }, ++ [SECTION_ID_INPUT] = { SECTION_ID_INPUT, "Input", 0, { SECTION_ID_HWFRAMESCONTEXT, SECTION_ID_ERROR, -1 }, }, ++ ++ [SECTION_ID_OUTPUTS] = { SECTION_ID_OUTPUTS, "Outputs", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_OUTPUT, SECTION_ID_ERROR, -1 } }, ++ [SECTION_ID_OUTPUT] = { SECTION_ID_OUTPUT, "Output", 0, { SECTION_ID_HWFRAMESCONTEXT, SECTION_ID_ERROR, -1 }, }, ++ ++ [SECTION_ID_FILTERS] = { SECTION_ID_FILTERS, "Filters", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_FILTER, SECTION_ID_ERROR, -1 } }, ++ [SECTION_ID_FILTER] = { SECTION_ID_FILTER, "Filter", 0, { SECTION_ID_HWDEViCECONTEXT, SECTION_ID_ERROR, -1 }, }, ++ ++ [SECTION_ID_HWDEViCECONTEXT] = { SECTION_ID_HWDEViCECONTEXT, "HwDeviceContext", 0, { SECTION_ID_ERROR, -1 }, }, ++ [SECTION_ID_HWFRAMESCONTEXT] = { SECTION_ID_HWFRAMESCONTEXT, "HwFramesContext", 0, { SECTION_ID_ERROR, -1 }, }, ++ ++ [SECTION_ID_ERROR] = { SECTION_ID_ERROR, "Error", 0, { -1 } }, ++ [SECTION_ID_LOGS] = { SECTION_ID_LOGS, "Log", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_LOG, -1 } }, ++ [SECTION_ID_LOG] = { SECTION_ID_LOG, "LogEntry", 0, { -1 }, }, ++}; ++ +/* Text Format API Shortcuts */ +#define print_int(k, v) avtext_print_integer(w, k, v) +#define print_q(k, v, s) avtext_print_rational(w, k, v, s) @@ fftools/ffmpeg_graphprint.c (new) + +static void print_link(AVTextFormatContext *w, AVFilterLink *link) +{ ++ AVBufferRef *hw_frames_ctx; + char layoutString[64]; + + switch (link->type) { @@ fftools/ffmpeg_graphprint.c (new) + break; + } + -+ AVBufferRef *hw_frames_ctx = avfilter_link_get_hw_frames_ctx(link); ++ hw_frames_ctx = avfilter_link_get_hw_frames_ctx(link); + + if (hw_frames_ctx && hw_frames_ctx->buffer) { + print_hwframescontext(w, (AVHWFramesContext *)hw_frames_ctx->data); @@ fftools/ffmpeg_graphprint.h (new) +#include "libavutil/bprint.h" +#include "textformat/avtextformat.h" + -+typedef enum { -+ SECTION_ID_ROOT, -+ SECTION_ID_PROGRAM_VERSION, -+ SECTION_ID_FILTERGRAPHS, -+ SECTION_ID_FILTERGRAPH, -+ SECTION_ID_INPUTS, -+ SECTION_ID_INPUT, -+ SECTION_ID_OUTPUTS, -+ SECTION_ID_OUTPUT, -+ SECTION_ID_FILTERS, -+ SECTION_ID_FILTER, -+ SECTION_ID_HWDEViCECONTEXT, -+ SECTION_ID_HWFRAMESCONTEXT, -+ SECTION_ID_ERROR, -+ SECTION_ID_LOG, -+ SECTION_ID_LOGS, -+ -+} SectionID; -+ -+static struct AVTextFormatSection sections[] = { -+ [SECTION_ID_ROOT] = { SECTION_ID_ROOT, "GraphDescription", AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER, -+ { SECTION_ID_ERROR, SECTION_ID_PROGRAM_VERSION, SECTION_ID_FILTERGRAPHS, SECTION_ID_LOGS, -1} }, -+ [SECTION_ID_PROGRAM_VERSION] = { SECTION_ID_PROGRAM_VERSION, "ProgramVersion", 0, { -1 } }, -+ -+ [SECTION_ID_FILTERGRAPHS] = { SECTION_ID_FILTERGRAPHS, "Graphs", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_FILTERGRAPH, -1 } }, -+ [SECTION_ID_FILTERGRAPH] = { SECTION_ID_FILTERGRAPH, "Graph", 0, { SECTION_ID_INPUTS, SECTION_ID_OUTPUTS, SECTION_ID_FILTERS, -1 }, }, -+ -+ [SECTION_ID_INPUTS] = { SECTION_ID_INPUTS, "Inputs", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_INPUT, SECTION_ID_ERROR, -1 } }, -+ [SECTION_ID_INPUT] = { SECTION_ID_INPUT, "Input", 0, { SECTION_ID_HWFRAMESCONTEXT, SECTION_ID_ERROR, -1 }, }, -+ -+ [SECTION_ID_OUTPUTS] = { SECTION_ID_OUTPUTS, "Outputs", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_OUTPUT, SECTION_ID_ERROR, -1 } }, -+ [SECTION_ID_OUTPUT] = { SECTION_ID_OUTPUT, "Output", 0, { SECTION_ID_HWFRAMESCONTEXT, SECTION_ID_ERROR, -1 }, }, -+ -+ [SECTION_ID_FILTERS] = { SECTION_ID_FILTERS, "Filters", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_FILTER, SECTION_ID_ERROR, -1 } }, -+ [SECTION_ID_FILTER] = { SECTION_ID_FILTER, "Filter", 0, { SECTION_ID_HWDEViCECONTEXT, SECTION_ID_ERROR, -1 }, }, -+ -+ [SECTION_ID_HWDEViCECONTEXT] = { SECTION_ID_HWDEViCECONTEXT, "HwDeviceContext", 0, { SECTION_ID_ERROR, -1 }, }, -+ [SECTION_ID_HWFRAMESCONTEXT] = { SECTION_ID_HWFRAMESCONTEXT, "HwFramesContext", 0, { SECTION_ID_ERROR, -1 }, }, -+ -+ [SECTION_ID_ERROR] = { SECTION_ID_ERROR, "Error", 0, { -1 } }, -+ [SECTION_ID_LOGS] = { SECTION_ID_LOGS, "Log", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_LOG, -1 } }, -+ [SECTION_ID_LOG] = { SECTION_ID_LOG, "LogEntry", 0, { -1 }, }, -+}; -+ +int print_filtergraphs(FilterGraph **graphs, int nb_graphs, OutputFile **output_files, int nb_output_files); +int print_filtergraph(FilterGraph *fg, AVFilterGraph *graph); + 7: 049f720ae7 = 7: c0cf4adcd9 fftools: Enable filtergraph printing and update docs -- ffmpeg-codebot _______________________________________________ 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".