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 411C54DC5C
	for <ffmpegdev@gitmailbox.com>; Wed, 23 Apr 2025 22:57:11 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4F33368B57A;
	Thu, 24 Apr 2025 01:57:09 +0300 (EEST)
Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com
 [209.85.218.44])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2A9C668B53E
 for <ffmpeg-devel@ffmpeg.org>; Thu, 24 Apr 2025 01:57:02 +0300 (EEST)
Received: by mail-ej1-f44.google.com with SMTP id
 a640c23a62f3a-ac2963dc379so62216866b.2
 for <ffmpeg-devel@ffmpeg.org>; Wed, 23 Apr 2025 15:57:02 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1745449021; x=1746053821; 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=pGKqrVgqsB4s4RcoNKlSAd4vS2eFyY0tX68noMpblY0=;
 b=jYEJoCXpkpMXETe+q0uU8Ecci7PD5CjuOi2TTtRcL4V0qZVg+PDN8xT/I4KyFNecAP
 8b3zAtO85oniw2OqhIhif0fsdT+jFKpTiVq5MDAJZ3f09jGNl0WPgOzt6rN0aRPVn3tq
 wE0wrjJGnSM09y1QWcF0Pa1Wq/9v3Zhy0i2vZzwNK4T7L5NQpAMi8CdBmAfAvg+t4WeV
 +6dIDdeOQRDM/c6bL65rFLb09wq6VqUqPxmmL6V25H4CGy5LYPiHZ7JsZYtzUqFwuxEe
 57TCN2smWvm8KBlqs3/q1qjdfRndRPz/gW1tp3JEcgGDjbhzomEFR652SEHx9V4gyzio
 b2gw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1745449021; x=1746053821;
 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=pGKqrVgqsB4s4RcoNKlSAd4vS2eFyY0tX68noMpblY0=;
 b=BZgV8yYnVtLc3rmUDYF1qH19aTDobYsMjsOcSHFbcH8dOkIW+gTs/jbQ/WuXWMC98Y
 8kGhs/PjuNNSqyXEi2xXayNvqYxf5Oj97TEhiV+qloMEfpRmN3jbk33h1Xh3K0ZO064r
 fdiw3qbM26hc96aKGXsDB8oZ1b+rlr4LORnAOWMnACLQvpD8m0n3Ui7o6RIMA4KlmuWP
 n74fQnt9BdAkBTKI0AOTDCrBV60Xpu2U38XZ6bboOXgfuHlpIThTy1RWo/HkMWVXNvI1
 kdnyi360X99HzBDFE6xBDybJSs+py14+ZdRLUH5cTZPBoDkUyBxTA429jEG/lcRLn2mn
 N0mw==
X-Gm-Message-State: AOJu0YzFmcOW9Bk4jCaHWapG5mU0H2lWG9XrPCLBuj598dzSf5ls+SNE
 lGnbvM14APfzCoItnC/hcQlIAWPOC79RKsPcZkW1GuKWuCdSUN50w/Az3w==
X-Gm-Gg: ASbGncscvan756yYBPcFrUaaxza2KgNBxSJ6E5OTiJrhveNNlpgUjgmQ3JAG9xLmc4x
 saY67SXTbHHziYtQVQnPuMTeBj7czQs4GqLxkd33sdyA91Dlbt2TLg3c+NxEBxARZB8U2o3X/Zw
 iLSKHmZEng3b8Fdl/HSRI+3B5FuFK3bMpkR3MnbQbLOo7rEv69Px9kO728inguwOfgtxbdSgqKo
 D9e55gJ36KWoselQJEZ2JOhxmdcVZM6755C8oiiF6gJh/3zWS7mP75ZhSEtIu7AJbKbMKTgzpT8
 aLS9dXpHO6PSP/54Xu4RRYVwhNJYFT6l6WbEwYuqZsDyA2FAqGxx6LolNn7h3rQLHqsa7AkkJCk
 4N4zC
X-Google-Smtp-Source: AGHT+IHdx9aSWx005YU04H3alAgsRbYub5ZVRd2Xe+hhrJMHNuBc5y8x6kzGFxYrMIYbK9x4v7lUKQ==
X-Received: by 2002:a17:907:3cd5:b0:acb:ba0f:4b0f with SMTP id
 a640c23a62f3a-ace572a2e27mr48352366b.31.1745449021028; 
 Wed, 23 Apr 2025 15:57:01 -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
 a640c23a62f3a-ace59c5d2efsm7571366b.162.2025.04.23.15.57.00
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 23 Apr 2025 15:57:00 -0700 (PDT)
Received: by mariano (Postfix, from userid 1000)
 id 2A069BFCE8; Thu, 24 Apr 2025 00:56:59 +0200 (CEST)
Date: Thu, 24 Apr 2025 00:56:59 +0200
From: Stefano Sabatini <stefasab@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Message-ID: <aAlwO1nXYrkHn7Nx@mariano>
Mail-Followup-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>,
	softworkz <softworkz-at-hotmail.com@ffmpeg.org>
References: <pull.66.v3.ffstaging.FFmpeg.1744945024.ffmpegagent@gmail.com>
 <pull.66.v4.ffstaging.FFmpeg.1745189954.ffmpegagent@gmail.com>
 <c1fea3027a229992eb8c4a78523b613746a18053.1745189955.git.ffmpegagent@gmail.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <c1fea3027a229992eb8c4a78523b613746a18053.1745189955.git.ffmpegagent@gmail.com>
User-Agent: Mutt/2.1.4 (2021-12-11)
Subject: Re: [FFmpeg-devel] [PATCH v4 05/11] fftools/textformat: Add
 function avtext_print_integer_flags()
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/aAlwO1nXYrkHn7Nx@mariano/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

On date Sunday 2025-04-20 22:59:08 +0000, softworkz wrote:
> From: softworkz <softworkz@hotmail.com>
> 
> This function works analog to the avtext_print_string() which already
> has a flags parameter.
> 
> Signed-off-by: softworkz <softworkz@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;

possibly complex logic which should be factorized if shared with
another function - this can be done through an inline function or macro?

> +
> +    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]++;
> +    }

We can make avtext_print_integer use the _flags variant to avoid code duplication.

> +}
> +
>  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
> 
> _______________________________________________
> 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".
_______________________________________________
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".