[FFmpeg-devel] [PATCH v4 05/11] fftools/textformat: Add function avtext_print_integer_flags()
Stefano Sabatini
stefasab at gmail.com
Thu Apr 24 01:56:59 EEST 2025
On date Sunday 2025-04-20 22:59:08 +0000, softworkz wrote:
> 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;
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 at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-devel
mailing list