aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/textformat/tf_default.c
diff options
context:
space:
mode:
authorsoftworkz <softworkz@hotmail.com>2025-04-29 01:35:50 +0200
committersoftworkz <softworkz@hotmail.com>2025-05-15 23:04:44 +0200
commitcee7b8a051739d9fa6b41f961ecec480cdaa02bd (patch)
treee6e29b87d6ec9aa4b45a77988ce81e750109bbb4 /fftools/textformat/tf_default.c
parente4830b8c5e589ae77d4e1c9dc68a1a6240cfc3c3 (diff)
downloadffmpeg-cee7b8a051739d9fa6b41f961ecec480cdaa02bd.tar.gz
fftools/textformat: Introduce common header and deduplicate code
Also change writer_printf signature in AVTextWriter to use va_list, so that it can be called by the new function writer_printf() in tf_internal.h. Reviewed-by: Stefano Sabatini <stefasab@gmail.com> Signed-off-by: softworkz <softworkz@hotmail.com>
Diffstat (limited to 'fftools/textformat/tf_default.c')
-rw-r--r--fftools/textformat/tf_default.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/fftools/textformat/tf_default.c b/fftools/textformat/tf_default.c
index ad97173b0b..019bda9d44 100644
--- a/fftools/textformat/tf_default.c
+++ b/fftools/textformat/tf_default.c
@@ -27,21 +27,7 @@
#include "avtextformat.h"
#include "libavutil/bprint.h"
#include "libavutil/opt.h"
-
-#define writer_w8(wctx_, b_) (wctx_)->writer->writer->writer_w8((wctx_)->writer, b_)
-#define writer_put_str(wctx_, str_) (wctx_)->writer->writer->writer_put_str((wctx_)->writer, str_)
-#define writer_printf(wctx_, fmt_, ...) (wctx_)->writer->writer->writer_printf((wctx_)->writer, fmt_, __VA_ARGS__)
-
-#define DEFINE_FORMATTER_CLASS(name) \
-static const char *name##_get_name(void *ctx) \
-{ \
- return #name ; \
-} \
-static const AVClass name##_class = { \
- .class_name = #name, \
- .item_name = name##_get_name, \
- .option = name##_options \
-}
+#include "tf_internal.h"
/* Default output */
@@ -80,9 +66,11 @@ static void default_print_section_header(AVTextFormatContext *wctx, const void *
{
DefaultContext *def = wctx->priv;
char buf[32];
- const struct AVTextFormatSection *section = wctx->section[wctx->level];
- const struct AVTextFormatSection *parent_section = wctx->level ?
- wctx->section[wctx->level-1] : NULL;
+ const AVTextFormatSection *section = tf_get_section(wctx, wctx->level);
+ const AVTextFormatSection *parent_section = tf_get_parent_section(wctx, wctx->level);
+
+ if (!section)
+ return;
av_bprint_clear(&wctx->section_pbuf[wctx->level]);
if (parent_section &&
@@ -104,7 +92,8 @@ static void default_print_section_header(AVTextFormatContext *wctx, const void *
static void default_print_section_footer(AVTextFormatContext *wctx)
{
DefaultContext *def = wctx->priv;
- const struct AVTextFormatSection *section = wctx->section[wctx->level];
+ const AVTextFormatSection *section = tf_get_section(wctx, wctx->level);
+
char buf[32];
if (!section)