[FFmpeg-devel] [PATCH v4 05/11] fftools/textformat: Add function avtext_print_integer_flags()

softworkz ffmpegagent at gmail.com
Mon Apr 21 01:59:08 EEST 2025


From: softworkz <softworkz at hotmail.com>

This function works analog to the avtext_print_string() which already
has a flags parameter.

Signed-off-by: softworkz <softworkz at hotmail.com>
---
 fftools/textformat/avtextformat.c | 21 +++++++++++++++++++++
 fftools/textformat/avtextformat.h |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c
index 893b11298e..d2d84c4f1d 100644
--- a/fftools/textformat/avtextformat.c
+++ b/fftools/textformat/avtextformat.c
@@ -311,6 +311,27 @@ void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t va
     }
 }
 
+void avtext_print_integer_flags(AVTextFormatContext *tctx, const char *key, int64_t val, int flags)
+{
+    const AVTextFormatSection *section;
+
+    if (!tctx || !key || tctx->level < 0 || tctx->level >= SECTION_MAX_NB_LEVELS)
+        return;
+
+    section = tctx->section[tctx->level];
+
+    if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER ||
+        (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
+            && (flags & AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)
+            && !(tctx->formatter->flags & AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS)))
+        return;
+
+    if (section->show_all_entries || av_dict_get(section->entries_to_show, key, NULL, 0)) {
+        tctx->formatter->print_integer(tctx, key, val);
+        tctx->nb_item[tctx->level]++;
+    }
+}
+
 static inline int validate_string(AVTextFormatContext *tctx, char **dstp, const char *src)
 {
     const uint8_t *p, *endp, *srcp = (const uint8_t *)src;
diff --git a/fftools/textformat/avtextformat.h b/fftools/textformat/avtextformat.h
index aea691f351..16cd9b214f 100644
--- a/fftools/textformat/avtextformat.h
+++ b/fftools/textformat/avtextformat.h
@@ -139,6 +139,8 @@ void avtext_print_section_footer(AVTextFormatContext *tctx);
 
 void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val);
 
+void avtext_print_integer_flags(AVTextFormatContext *tctx, const char *key, int64_t val, int flags);
+
 int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *val, int flags);
 
 void avtext_print_unit_int(AVTextFormatContext *tctx, const char *key, int value, const char *unit);
-- 
ffmpeg-codebot



More information about the ffmpeg-devel mailing list