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 36FAC4DC3D
	for <ffmpegdev@gitmailbox.com>; Wed, 23 Apr 2025 22:49:05 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F128068B39C;
	Thu, 24 Apr 2025 01:49:01 +0300 (EEST)
Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com
 [209.85.208.52])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D402B689BFC
 for <ffmpeg-devel@ffmpeg.org>; Thu, 24 Apr 2025 01:48:55 +0300 (EEST)
Received: by mail-ed1-f52.google.com with SMTP id
 4fb4d7f45d1cf-5e6f4b3ebe5so577650a12.0
 for <ffmpeg-devel@ffmpeg.org>; Wed, 23 Apr 2025 15:48:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1745448535; x=1746053335; darn=ffmpeg.org;
 h=user-agent:in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc
 :subject:date:message-id:reply-to;
 bh=HaHlr+axJl9D/KgHO8ICn1KJibehXiW3k/5XWwddTwI=;
 b=TudyzOPPg5uFv3ltNdUvHJ8pM976dgGCdTtA5AMfshTfBaYVMohb7LUH2jKTYa70sp
 N+I/g3ym7ABqWOp//2KQkT9IB5334o9H62GXhdkMDiLOaw8rUTyaJTDkL/S0NWcyQtnN
 uoqN+7QTSW8uAgPOQNkcCet7zFnedinW/l1VAZ/eBx/7saMtY+H/gjxmgSjuFA3xjGeX
 bQVhJG370sA5SjD/+RtAQSNbUpIbcfY5Meaq+9hYS3KtU1qedq1r3eCDN8ZeI9VffSwO
 WcsSwxKcIrcorcJE30YNKC2ajB27Xh/dWwPopWXaxInrTxMaYUZeojRqbfF3xi5Toy0B
 0Fcw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1745448535; x=1746053335;
 h=user-agent:in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:cc:to:from:date
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=HaHlr+axJl9D/KgHO8ICn1KJibehXiW3k/5XWwddTwI=;
 b=LwRbP9j/N8p3TniywN96URpEoT9kIh82QA1z3+wfhHYSwiz/2lHDfD4RbAiz/4RXJ8
 6TUSOrBva1A9Fy3JHe9k379TeWs4jw82+6PQUHzfBy7UHjxgiBDnZVTxCJDCR6T2VidU
 H3WYmcSD/UGRrqDmWXbFUvp3H421yJ/D0fSc3GHKwc4qcZEgdW9LXuAtZ1jVzogc1yLH
 27FYcPcF5JwXXR5L0nWqF6sbVpsfRzcyAg1RnFPWPm21F0Y5/LUodlZmHmvQO7xynPiO
 zheMdLVnp47OEwTivRpAwm69MCKp1WxZM/br3yqakH6qhR6VhRgn6aHdiKL37X1Tf0Rh
 S6LQ==
X-Gm-Message-State: AOJu0Yxrj/goLI/HwFOcdji1Tbfif3y5hT2aAWTqRLfrrHMV78xFtj4s
 0xQVn4YGcbdfcPWw+DrKqbuwJmCSSK4ub2c1QlrdEQi/3xpKIjAw+Xp77Q==
X-Gm-Gg: ASbGncvBJyu/ya9FXP0coJiIl9Myx18a7LCJHro+qH58Ec5l0CdDpN0+FOvjBpZanr8
 BEkLqfNFSvQtkIqlx3Ry1dOAUAwCviRSA6j680HKwmo/9xRu3aiQVkzMCPMC7UTdAlVbw5sl1mb
 9ePKsWxkaB+1d2JsoY40mVqRWKR99rrGcOGtIi8LSuO/nswAtn4bVkZ4BhlblRo8piUNxXffKa3
 wveKlUdZhpK6WKZBNagidxQ4SqrV0rXUVczHPOkH2CRvYvg4z+psipSs3+kjUQuA71aYrWIg1Ni
 FTLtS0lz6PPNSTJ2BtZWpcXM81EEP9jtEA9Uo1W9GJXZQ4oGBLF86q4b+0qewhJ9FiHTS6I9qlN
 35qx5
X-Google-Smtp-Source: AGHT+IE6Yisr5KHRyE2tUXiNVVdDJ+BRVrgtt45vMRh7O2WdaIEz54HFLtaeKeeVNjILs6T6rNT4nA==
X-Received: by 2002:a05:6402:5249:b0:5e5:d9e5:c4d7 with SMTP id
 4fb4d7f45d1cf-5f6df53e638mr701138a12.28.1745448534663; 
 Wed, 23 Apr 2025 15:48:54 -0700 (PDT)
Received: from mariano (dynamic-adsl-84-220-189-10.clienti.tiscali.it.
 [84.220.189.10]) by smtp.gmail.com with ESMTPSA id
 4fb4d7f45d1cf-5f6eb43ed8csm220021a12.27.2025.04.23.15.48.52
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 23 Apr 2025 15:48:53 -0700 (PDT)
Received: by mariano (Postfix, from userid 1000)
 id 5E6BCBFCE8; Thu, 24 Apr 2025 00:48:51 +0200 (CEST)
Date: Thu, 24 Apr 2025 00:48:51 +0200
From: Stefano Sabatini <stefasab@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Message-ID: <aAluUwl7VX9QhF7u@mariano>
Mail-Followup-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>,
	softworkz <softworkz-at-hotmail.com@ffmpeg.org>
References: <pull.66.v4.ffstaging.FFmpeg.1745189954.ffmpegagent@gmail.com>
 <pull.66.v5.ffstaging.FFmpeg.1745358943.ffmpegagent@gmail.com>
 <26be409371cab3a946c6b28dcab1ac185a264e0c.1745358943.git.ffmpegagent@gmail.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <26be409371cab3a946c6b28dcab1ac185a264e0c.1745358943.git.ffmpegagent@gmail.com>
User-Agent: Mutt/2.1.4 (2021-12-11)
Subject: Re: [FFmpeg-devel] [PATCH v5 04/14] 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/aAluUwl7VX9QhF7u@mariano/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

On date Tuesday 2025-04-22 21:55:33 +0000, softworkz wrote:
> From: softworkz <softworkz@hotmail.com>
> 
> This allows future addition of options without
> changes to the signature of avtext_context_open().
> 
> Signed-off-by: softworkz <softworkz@hotmail.com>
> ---
>  fftools/ffprobe.c                 | 13 +++++++++----
>  fftools/textformat/avtextformat.c | 21 ++++++++-------------
>  fftools/textformat/avtextformat.h | 22 +++++++++++++++-------
>  3 files changed, 32 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 0a221f4a9a..217d9da25e 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;
> @@ -155,11 +149,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);
> @@ -202,7 +196,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;
> @@ -213,6 +207,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 aea691f351..05a358132e 100644
> --- a/fftools/textformat/avtextformat.h
> +++ b/fftools/textformat/avtextformat.h
> @@ -118,17 +118,25 @@ 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
>  
> +#define AV_TEXTFORMAT_OPEN_SHOW_VALUE_UNIT               1
> +#define AV_TEXTFORMAT_OPEN_USE_VALUE_PREFIX              2
> +#define AV_TEXTFORMAT_OPEN_USE_BYTE_BINARY_PREFIX        4
> +#define AV_TEXTFORMAT_OPEN_USE_VALUE_SEXAGESIMAL_FORMAT  8
> +#define AV_TEXTFORMAT_OPEN_SHOW_OPTIONAL_FIELDS         16

Since this is a bitmap shouldn't we use a flags field directly?
_______________________________________________
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".