[FFmpeg-devel] [PATCH 0/8] [RFC] avtextformat: Transform text writing into an independent API
ffmpegagent
ffmpegagent at gmail.com
Thu Feb 27 16:01:32 EET 2025
Hello everybody,
this is an effort to pull out the text writing code from ffprobe and shape
it as an independent API. To avoid any other big refacoring in the future,
this patchset is building it up as a public API in avutil, but it's not that
I would be insisting this to happen (or maybe not yet). It could very well
remain private and only shared by ffprobe and ffmpeg (filtergraph printing)
for the time being. Would like to know what people are thinking about -
specifically and in general.
This patchset doesn't aim to improve or change the API itself - that would
be a bit too much at once. The primary functional changes made were those
which were required to gain independence of the specific way of use inside
ffprobe - without causing any change to the output. Locally, I had some
failing FATE tests locally but the CI build with FATE (here on GitHub)
finished without error.
Non-functional changes are naming, made in the spirit of ramping up for
becoming a public API (possibly), and there's also a separation of
functionality: Currently, everything is called "writer" in some way, without
making any distinctions. The main change is that there are now:
* Text Formatters: AVTextFormatter and AVTextFormatContext These are
obviously in charge of formatting the output (csv, json, xml, compact,
etc.)
* Text Writers: AVTextWriter and AVTextWriterContext Responsible for
writing the formatted text somewhere. Currently 3 writers exist
* stdouwriter
* aviowriter - can output to a file or to an existing avio context
* bufferwriter - writes to a provided AVBprint buffer
I'll be happy about any hints or comments!
Known Issues
* Mixes avutil and fftool changes in commits (I kept it preliminarily like
that as it's easier to follow. Otherwise it would be a huge single commit
to ffprobe.c)
* No changelog, ApiChange entries and version bumps
* Public API isn't documented yet
* Some variables haven't been renamed yet (like wctx to tctx)
* Not sure whether every single commit builds successfully, the final one
does
Open Questions
* I'm not sure about the best way to expose the formatters and writers to
consumers Currently, there's still the register_formatter() way in
ffprobe.c and writers are accessible only via creator functions (like
avtextwriter_create_avio)
* There are two header files (avtextformat.h, avtextwriters.h), reflecting
the separation betwen formatters and writers and a separate code file for
each formatter and writer, all in a subfolder named textformat. Not sure
what the preferences are, it was hard to find a comparable precedence.
Will change when asked to.
* Do we want flags to be #defines always or can they be enums?
* Will it need a public/private separation (like recently introduced for
other entities)?
Thanks
softworkz (8):
ffprobe/avtextformat: Rename and move writer structs
ffprobe/avtextformat: Rename and move writer functions and options
ffprobe/avtextformat: Generalize ffprobe specifics
ffprobe/avtextformat: Rename flags and enums
ffprobe/avtextformat: Move flags
ffprobe/avtextformat: Rename writer to formatter
ffprobe/avtextformat: Move formatters to avutil
ffprobe/avtextformat: Split out text writers as independent classes
fftools/ffprobe.c | 2188 ++++-----------------------
libavutil/Makefile | 12 +
libavutil/avtextformat.h | 170 +++
libavutil/avtextwriters.h | 68 +
libavutil/textformat/avtextformat.c | 641 ++++++++
libavutil/textformat/tf_compact.c | 285 ++++
libavutil/textformat/tf_default.c | 150 ++
libavutil/textformat/tf_flat.c | 177 +++
libavutil/textformat/tf_ini.c | 165 ++
libavutil/textformat/tf_json.c | 220 +++
libavutil/textformat/tf_xml.c | 224 +++
libavutil/textformat/tw_avio.c | 129 ++
libavutil/textformat/tw_buffer.c | 91 ++
libavutil/textformat/tw_stdout.c | 82 +
14 files changed, 2737 insertions(+), 1865 deletions(-)
create mode 100644 libavutil/avtextformat.h
create mode 100644 libavutil/avtextwriters.h
create mode 100644 libavutil/textformat/avtextformat.c
create mode 100644 libavutil/textformat/tf_compact.c
create mode 100644 libavutil/textformat/tf_default.c
create mode 100644 libavutil/textformat/tf_flat.c
create mode 100644 libavutil/textformat/tf_ini.c
create mode 100644 libavutil/textformat/tf_json.c
create mode 100644 libavutil/textformat/tf_xml.c
create mode 100644 libavutil/textformat/tw_avio.c
create mode 100644 libavutil/textformat/tw_buffer.c
create mode 100644 libavutil/textformat/tw_stdout.c
base-commit: 99e2af4e7837ca09b97d93a562dc12947179fc48
Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-56%2Fsoftworkz%2Fsubmit_textformat-v1
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-56/softworkz/submit_textformat-v1
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/56
--
ffmpeg-codebot
More information about the ffmpeg-devel
mailing list