This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit ca6f3f3c174f63e396c08787f70eb707bd2e52bc
Author:     Marton Balint <[email protected]>
AuthorDate: Wed Jan 14 00:58:15 2026 +0100
Commit:     Marton Balint <[email protected]>
CommitDate: Wed Feb 4 21:46:30 2026 +0100

    fftools/ffprobe: use an AVTextFormatOptions struct in AVTextFormatContext
    
    Signed-off-by: Marton Balint <[email protected]>
---
 fftools/graph/graphprint.c        | 10 ++++-----
 fftools/textformat/avtextformat.c | 34 ++++++++++++-----------------
 fftools/textformat/avtextformat.h | 45 +++++++++++++++++----------------------
 fftools/textformat/tf_xml.c       |  4 ++--
 4 files changed, 40 insertions(+), 53 deletions(-)

diff --git a/fftools/graph/graphprint.c b/fftools/graph/graphprint.c
index 9a8c4c4230..5b050506d0 100644
--- a/fftools/graph/graphprint.c
+++ b/fftools/graph/graphprint.c
@@ -271,7 +271,7 @@ static void print_link(GraphPrintContext *gpc, AVFilterLink 
*link)
         }
 
         if (link->w && link->h) {
-            if (tfc->show_value_unit) {
+            if (tfc->opts.show_value_unit) {
                 print_fmt("size", "%dx%d", link->w, link->h);
             } else {
                 print_int("width", link->w);
@@ -292,7 +292,7 @@ static void print_link(GraphPrintContext *gpc, AVFilterLink 
*link)
         ////print_str("format", 
av_x_if_null(av_get_subtitle_fmt_name(link->format), "?"));
 
         if (link->w && link->h) {
-            if (tfc->show_value_unit) {
+            if (tfc->opts.show_value_unit) {
                 print_fmt("size", "%dx%d", link->w, link->h);
             } else {
                 print_int("width", link->w);
@@ -306,7 +306,7 @@ static void print_link(GraphPrintContext *gpc, AVFilterLink 
*link)
         av_channel_layout_describe(&link->ch_layout, layout_string, 
sizeof(layout_string));
         print_str("channel_layout", layout_string);
         print_val("channels", link->ch_layout.nb_channels, "ch");
-        if (tfc->show_value_unit)
+        if (tfc->opts.show_value_unit)
             print_fmt("sample_rate", "%d.1 kHz", link->sample_rate / 1000);
         else
             print_val("sample_rate", link->sample_rate, "Hz");
@@ -912,8 +912,8 @@ static int init_graphprint(GraphPrintContext **pgpc, 
AVBPrint *target_buf)
     gpc->id_prefix_num = atomic_fetch_add(&prefix_num, 1);
     gpc->is_diagram = !!(tfc->formatter->flags & 
AV_TEXTFORMAT_FLAG_IS_DIAGRAM_FORMATTER);
     if (gpc->is_diagram) {
-        tfc->show_value_unit = 1;
-        tfc->show_optional_fields = -1;
+        tfc->opts.show_value_unit = 1;
+        tfc->opts.show_optional_fields = -1;
         gpc->opt_flags = AV_TEXTFORMAT_PRINT_STRING_OPTIONAL;
         gpc->skip_buffer_filters = 1;
         ////} else {
diff --git a/fftools/textformat/avtextformat.c 
b/fftools/textformat/avtextformat.c
index 98f4656790..ca1039b67e 100644
--- a/fftools/textformat/avtextformat.c
+++ b/fftools/textformat/avtextformat.c
@@ -147,13 +147,7 @@ int avtext_context_open(AVTextFormatContext **ptctx, const 
AVTextFormatter *form
         goto fail;
     }
 
-    tctx->is_key_selected = options.is_key_selected;
-    tctx->show_value_unit = options.show_value_unit;
-    tctx->use_value_prefix = options.use_value_prefix;
-    tctx->use_byte_value_binary_prefix = options.use_byte_value_binary_prefix;
-    tctx->use_value_sexagesimal_format = options.use_value_sexagesimal_format;
-    tctx->show_optional_fields = options.show_optional_fields;
-    tctx->data_dump_format = options.data_dump_format;
+    tctx->opts = options;
 
     if (nb_sections > SECTION_MAX_NB_SECTIONS) {
         av_log(tctx, AV_LOG_ERROR, "The number of section definitions (%d) is 
larger than the maximum allowed (%d)\n", nb_sections, SECTION_MAX_NB_SECTIONS);
@@ -293,17 +287,17 @@ void avtext_print_integer(AVTextFormatContext *tctx, 
const char *key, int64_t va
 {
     av_assert0(tctx);
 
-    if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER)
+    if (tctx->opts.show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER)
         return;
 
-    if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
+    if (tctx->opts.show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
         && (flags & AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)
         && !(tctx->formatter->flags & 
AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS))
         return;
 
     av_assert0(key && tctx->level >= 0 && tctx->level < SECTION_MAX_NB_LEVELS);
 
-    if (!tctx->is_key_selected || tctx->is_key_selected(tctx, key)) {
+    if (!tctx->opts.is_key_selected || tctx->opts.is_key_selected(tctx, key)) {
         tctx->formatter->print_integer(tctx, key, val);
         tctx->nb_item[tctx->level]++;
     }
@@ -389,7 +383,7 @@ static char *value_string(const AVTextFormatContext *tctx, 
char *buf, int buf_si
         vali = uv.val.i;
     }
 
-    if (uv.unit == unit_second_str && tctx->use_value_sexagesimal_format) {
+    if (uv.unit == unit_second_str && tctx->opts.use_value_sexagesimal_format) 
{
         double secs;
         int hours, mins;
         secs  = vald;
@@ -401,10 +395,10 @@ static char *value_string(const AVTextFormatContext 
*tctx, char *buf, int buf_si
     } else {
         const char *prefix_string = "";
 
-        if (tctx->use_value_prefix && vald > 1) {
+        if (tctx->opts.use_value_prefix && vald > 1) {
             int64_t index;
 
-            if (uv.unit == unit_byte_str && 
tctx->use_byte_value_binary_prefix) {
+            if (uv.unit == unit_byte_str && 
tctx->opts.use_byte_value_binary_prefix) {
                 index = (int64_t)(log2(vald) / 10);
                 index = av_clip64(index, 0, FF_ARRAY_ELEMS(si_prefixes) - 1);
                 vald /= si_prefixes[index].bin_val;
@@ -418,13 +412,13 @@ static char *value_string(const AVTextFormatContext 
*tctx, char *buf, int buf_si
             vali = (int64_t)vald;
         }
 
-        if (show_float || (tctx->use_value_prefix && vald != (int64_t)vald))
+        if (show_float || (tctx->opts.use_value_prefix && vald != 
(int64_t)vald))
             snprintf(buf, buf_size, "%f", vald);
         else
             snprintf(buf, buf_size, "%"PRId64, vali);
 
-        av_strlcatf(buf, buf_size, "%s%s%s", *prefix_string || 
tctx->show_value_unit ? " " : "",
-                    prefix_string, tctx->show_value_unit ? uv.unit : "");
+        av_strlcatf(buf, buf_size, "%s%s%s", *prefix_string || 
tctx->opts.show_value_unit ? " " : "",
+                    prefix_string, tctx->opts.show_value_unit ? uv.unit : "");
     }
 
     return buf;
@@ -450,15 +444,15 @@ int avtext_print_string(AVTextFormatContext *tctx, const 
char *key, const char *
 
     section = tctx->section[tctx->level];
 
-    if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER)
+    if (tctx->opts.show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER)
         return 0;
 
-    if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
+    if (tctx->opts.show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
         && (flags & AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)
         && !(tctx->formatter->flags & 
AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS))
         return 0;
 
-    if (!tctx->is_key_selected || tctx->is_key_selected(tctx, key)) {
+    if (!tctx->opts.is_key_selected || tctx->opts.is_key_selected(tctx, key)) {
         if (flags & AV_TEXTFORMAT_PRINT_STRING_VALIDATE) {
             char *key1 = NULL, *val1 = NULL;
             ret = validate_string(tctx, &key1, key);
@@ -543,7 +537,7 @@ void avtext_print_data(AVTextFormatContext *tctx, const 
char *key,
 {
     AVBPrint bp;
     av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
-    switch (tctx->data_dump_format) {
+    switch (tctx->opts.data_dump_format) {
     case AV_TEXTFORMAT_DATADUMP_XXD:
         print_data_xxd(&bp, data, size);
         break;
diff --git a/fftools/textformat/avtextformat.h 
b/fftools/textformat/avtextformat.h
index 0f8ccfed72..a86ce64dfe 100644
--- a/fftools/textformat/avtextformat.h
+++ b/fftools/textformat/avtextformat.h
@@ -111,6 +111,24 @@ typedef struct AVTextFormatter {
 #define SECTION_MAX_NB_LEVELS    12
 #define SECTION_MAX_NB_SECTIONS 100
 
+typedef struct AVTextFormatOptions {
+    /**
+     * Callback to discard certain elements based upon the key used.
+     * It is called before any element with a key is printed.
+     * If this callback is unset, all elements are printed.
+     *
+     * @retval 1 if the element is supposed to be printed
+     * @retval 0 if the element is supposed to be discarded
+     */
+    int (*is_key_selected)(struct AVTextFormatContext *tctx, const char *key);
+    int show_optional_fields;
+    int show_value_unit;
+    int use_value_prefix;
+    int use_byte_value_binary_prefix;
+    int use_value_sexagesimal_format;
+    AVTextFormatDataDump data_dump_format;
+} AVTextFormatOptions;
+
 struct AVTextFormatContext {
     const AVClass *class;              ///< class of the formatter
     const AVTextFormatter *formatter;  ///< the AVTextFormatter of which this 
is an instance
@@ -133,22 +151,7 @@ struct AVTextFormatContext {
     AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]; ///< generic print buffer 
dedicated to each section,
                                                   ///  used by various 
formatters
 
-    /**
-     * Callback to discard certain elements based upon the key used.
-     * It is called before any element with a key is printed.
-     * If this callback is unset, all elements are printed.
-     *
-     * @retval 1 if the element is supposed to be printed
-     * @retval 0 if the element is supposed to be discarded
-     */
-    int (*is_key_selected)(struct AVTextFormatContext *tctx, const char *key);
-
-    int show_optional_fields;
-    int show_value_unit;
-    int use_value_prefix;
-    int use_byte_value_binary_prefix;
-    int use_value_sexagesimal_format;
-    AVTextFormatDataDump data_dump_format;
+    AVTextFormatOptions opts;
 
     struct AVHashContext *hash;
 
@@ -157,16 +160,6 @@ struct AVTextFormatContext {
     unsigned int string_validation_utf8_flags;
 };
 
-typedef struct AVTextFormatOptions {
-    int (*is_key_selected)(struct AVTextFormatContext *tctx, const char *key);
-    int show_optional_fields;
-    int show_value_unit;
-    int use_value_prefix;
-    int use_byte_value_binary_prefix;
-    int use_value_sexagesimal_format;
-    AVTextFormatDataDump data_dump_format;
-} AVTextFormatOptions;
-
 #define AV_TEXTFORMAT_PRINT_STRING_OPTIONAL 1
 #define AV_TEXTFORMAT_PRINT_STRING_VALIDATE 2
 
diff --git a/fftools/textformat/tf_xml.c b/fftools/textformat/tf_xml.c
index 6b09e09ab4..d4329110f9 100644
--- a/fftools/textformat/tf_xml.c
+++ b/fftools/textformat/tf_xml.c
@@ -64,8 +64,8 @@ static av_cold int xml_init(AVTextFormatContext *wctx)
             return AVERROR(EINVAL);                                     \
         }
         ////CHECK_COMPLIANCE(show_private_data, "private");
-        CHECK_COMPLIANCE(wctx->show_value_unit,   "unit");
-        CHECK_COMPLIANCE(wctx->use_value_prefix,  "prefix");
+        CHECK_COMPLIANCE(wctx->opts.show_value_unit,   "unit");
+        CHECK_COMPLIANCE(wctx->opts.use_value_prefix,  "prefix");
     }
 
     return 0;

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to