From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTPS id EF77D4BD6F
	for <ffmpegdev@gitmailbox.com>; Sun,  4 May 2025 22:36:37 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A055168BABF;
	Mon,  5 May 2025 01:35:47 +0300 (EEST)
Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com
 [209.85.210.181])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C0D6D68A76F
 for <ffmpeg-devel@ffmpeg.org>; Mon,  5 May 2025 01:35:45 +0300 (EEST)
Received: by mail-pf1-f181.google.com with SMTP id
 d2e1a72fcca58-736bfa487c3so3344235b3a.1
 for <ffmpeg-devel@ffmpeg.org>; Sun, 04 May 2025 15:35:45 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1746398144; x=1747002944; darn=ffmpeg.org;
 h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date
 :references:in-reply-to:message-id:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=pxjhzbbUyvZsAW4Fyk124j5RDnHMWaIRnLwyzWW+03g=;
 b=c1u0AgzwDLxDZgh8KADf6nnPkeMktmR0g6ZygwtOUteLF7tq0ObPBASlxx/n5cgesM
 yYXbzcjGVfVgT9EnZ6OVWnzXS5ZpvvAtQryjrv7N1cC8mzgMKEWLKC55Vzh7Adr579xZ
 4UsnymRiXW/YMwa1MauYL1qIsE+gVKKrxTfvaiVHrp1L1HAjjP05vtxz7RUlhjwHFOD2
 UjD1tDr/Tced3E932YMBNrTt6J4EoEYcsq8oe6HBnY2bgLXV3kGPQpAKvdYMEvO5lw3f
 tM5Mio+jkn3Z7v5EIurQuY69yyUePls1icznfbqQa5AR71BJ7SIDjv7E8+xu1RXV44Ag
 0Dow==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1746398144; x=1747002944;
 h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date
 :references:in-reply-to:message-id:from:x-gm-message-state:from:to
 :cc:subject:date:message-id:reply-to;
 bh=pxjhzbbUyvZsAW4Fyk124j5RDnHMWaIRnLwyzWW+03g=;
 b=NjcvKHqsd0BeeJk5pgRefppYxgNaSgpir3kmHITIhnwI4o3cl4sSUnRQ4II8QDXOoM
 rgHGIP6bY+y4dLKrjiwM9wRgthY4U/8lFiLS/EQyoa2yx843a/Nay7+D44bXl1iG9EKL
 Chkre6g8qccRXACXvFdxn/40s1WYkF84xJb1wFnd7LAVAh721d33ECLcu+o1rKSF6fGb
 Rtd/oBWIko8ruR0hAukMcKkkquOUwX8152c4I5OxIsOs1i0zZPl7EiR1Fm4XJyBB61LE
 iz/8RXTVSgjXIcq2DMkqp8xhbeQPEWyQPstXfyKuRXZfLF1krTaky3+zGlraneZi03ED
 x1Wg==
X-Gm-Message-State: AOJu0Ywn5ZGf935M8qIZizv/BPP1K9tVcxynl5xNZPrpp151KpZ0G6lS
 zHOXEWCVvcOQDtQ0U6u0XgfYHPn3u7vbkkiriGeBpyYx6QFZ6B74+US3yF2p
X-Gm-Gg: ASbGncsLnQ2evCiBBrk1bPaaANgvqLrXzhhJXjSm9XyzEYUpg1o/nx7D1fB4Kro8eW0
 qLEUsuthH0qyZ52ySxWMGgdPISTB4gFVsrlUNPFrIRFOXDmiSWvoMWGM1xhSp9hUlfDW1/Kub0t
 BvFs4ANcURRwr0ulVAfXNp53XlmlqvhLeThOsSCSDPlojZPF7gnBpgVrJ1kUwANy3T1xrdLq8V0
 YpbqTJdaC4HiBNMChKr+V2SJm7HWFAGEiewCHHWRz4uxJYSwEaFvi0DonO2ZJ5O5rl4fZ065x56
 YOo5bUpSgOOc0fM3J/0mgL2hFydF1E4HHxq3vUBkRM0PH6iJIBYg9mqwJOc=
X-Google-Smtp-Source: AGHT+IHi5hlp36f1owdDZQCGjFfM7q919LrvDRQ/87MX5iLcfIbvVXg+aDimMZMGSyXDm2m6g1CPUw==
X-Received: by 2002:a05:6a00:2908:b0:736:6ecd:8e34 with SMTP id
 d2e1a72fcca58-7406f177ea0mr7344581b3a.18.1746398143857; 
 Sun, 04 May 2025 15:35:43 -0700 (PDT)
Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50])
 by smtp.gmail.com with ESMTPSA id
 41be03b00d2f7-b1fbc81a1cdsm3013660a12.60.2025.05.04.15.35.43
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Sun, 04 May 2025 15:35:43 -0700 (PDT)
From: softworkz <ffmpegagent@gmail.com>
X-Google-Original-From: softworkz <softworkz@hotmail.com>
Message-Id: <3aa16bc39f30554808c946673dd3862380314788.1746398104.git.ffmpegagent@gmail.com>
In-Reply-To: <pull.66.v11.ffstaging.FFmpeg.1746398104.ffmpegagent@gmail.com>
References: <pull.66.v10.ffstaging.FFmpeg.1746327446.ffmpegagent@gmail.com>
 <pull.66.v11.ffstaging.FFmpeg.1746398104.ffmpegagent@gmail.com>
Date: Sun, 04 May 2025 22:34:55 +0000
Fcc: Sent
MIME-Version: 1.0
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH v11 06/15] fftools/textformat: Introduce
 AVTextFormatOptions for avtext_context_open()
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: softworkz <softworkz@hotmail.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/3aa16bc39f30554808c946673dd3862380314788.1746398104.git.ffmpegagent@gmail.com/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

From: softworkz <softworkz@hotmail.com>

This allows future addition of options without
changes to the signature of avtext_context_open().

Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: softworkz <softworkz@hotmail.com>
---
 fftools/ffprobe.c                 | 13 +++++++++----
 fftools/textformat/avtextformat.c | 21 ++++++++-------------
 fftools/textformat/avtextformat.h | 16 +++++++++-------
 3 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index f5c83925b9..1277b1e4f9 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -3168,10 +3168,15 @@ int main(int argc, char **argv)
     if (ret < 0)
         goto end;
 
-    if ((ret = avtext_context_open(&tctx, f, wctx, f_args,
-                           sections, FF_ARRAY_ELEMS(sections), show_value_unit,
-                            use_value_prefix, use_byte_value_binary_prefix, use_value_sexagesimal_format,
-                            show_optional_fields, show_data_hash)) >= 0) {
+    AVTextFormatOptions tf_options = {
+        .show_optional_fields = show_optional_fields,
+        .show_value_unit = show_value_unit,
+        .use_value_prefix = use_value_prefix,
+        .use_byte_value_binary_prefix = use_byte_value_binary_prefix,
+        .use_value_sexagesimal_format = use_value_sexagesimal_format,
+    };
+
+    if ((ret = avtext_context_open(&tctx, f, wctx, f_args, sections, FF_ARRAY_ELEMS(sections), tf_options, show_data_hash)) >= 0) {
         if (f == &avtextformatter_xml)
             tctx->string_validation_utf8_flags |= AV_UTF8_FLAG_EXCLUDE_XML_INVALID_CONTROL_CODES;
 
diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c
index b2c3aa3fc7..91469ef576 100644
--- a/fftools/textformat/avtextformat.c
+++ b/fftools/textformat/avtextformat.c
@@ -125,13 +125,7 @@ void avtext_context_close(AVTextFormatContext **ptctx)
 
 
 int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *formatter, AVTextWriterContext *writer_context, const char *args,
-                        const AVTextFormatSection *sections, int nb_sections,
-                        int show_value_unit,
-                        int use_value_prefix,
-                        int use_byte_value_binary_prefix,
-                        int use_value_sexagesimal_format,
-                        int show_optional_fields,
-                        char *show_data_hash)
+                        const AVTextFormatSection *sections, int nb_sections, AVTextFormatOptions options, char *show_data_hash)
 {
     AVTextFormatContext *tctx;
     int i, ret = 0;
@@ -154,11 +148,11 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form
         goto fail;
     }
 
-    tctx->show_value_unit = show_value_unit;
-    tctx->use_value_prefix = use_value_prefix;
-    tctx->use_byte_value_binary_prefix = use_byte_value_binary_prefix;
-    tctx->use_value_sexagesimal_format = use_value_sexagesimal_format;
-    tctx->show_optional_fields = show_optional_fields;
+    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;
 
     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);
@@ -201,7 +195,7 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form
         av_dict_free(&opts);
     }
 
-    if (show_data_hash)
+    if (show_data_hash) {
         if ((ret = av_hash_alloc(&tctx->hash, show_data_hash)) < 0) {
             if (ret == AVERROR(EINVAL)) {
                 const char *n;
@@ -212,6 +206,7 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form
             }
             goto fail;
         }
+    }
 
     /* validate replace string */
     {
diff --git a/fftools/textformat/avtextformat.h b/fftools/textformat/avtextformat.h
index 8ff503401a..87f57d8c24 100644
--- a/fftools/textformat/avtextformat.h
+++ b/fftools/textformat/avtextformat.h
@@ -117,17 +117,19 @@ struct AVTextFormatContext {
     unsigned int string_validation_utf8_flags;
 };
 
+typedef struct AVTextFormatOptions {
+    int show_optional_fields;
+    int show_value_unit;
+    int use_value_prefix;
+    int use_byte_value_binary_prefix;
+    int use_value_sexagesimal_format;
+} AVTextFormatOptions;
+
 #define AV_TEXTFORMAT_PRINT_STRING_OPTIONAL 1
 #define AV_TEXTFORMAT_PRINT_STRING_VALIDATE 2
 
 int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *formatter, AVTextWriterContext *writer_context, const char *args,
-                        const AVTextFormatSection *sections, int nb_sections,
-                        int show_value_unit,
-                        int use_value_prefix,
-                        int use_byte_value_binary_prefix,
-                        int use_value_sexagesimal_format,
-                        int show_optional_fields,
-                        char *show_data_hash);
+                        const AVTextFormatSection *sections, int nb_sections, AVTextFormatOptions options, char *show_data_hash);
 
 void avtext_context_close(AVTextFormatContext **tctx);
 
-- 
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".