From: softworkz <softwo...@hotmail.com> Make this function work analog to avtext_print_string() which already has a flags parameter.
Signed-off-by: softworkz <softwo...@hotmail.com> --- fftools/ffprobe.c | 2 +- fftools/textformat/avtextformat.c | 24 ++++++++++++++++++------ fftools/textformat/avtextformat.h | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 1277b1e4f9..444810cf43 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -422,7 +422,7 @@ static void log_callback(void *ptr, int level, const char *fmt, va_list vl) avtext_print_string(tfc, k, pbuf.str, 0); \ } while (0) -#define print_int(k, v) avtext_print_integer(tfc, k, v) +#define print_int(k, v) avtext_print_integer(tfc, k, v, 0) #define print_q(k, v, s) avtext_print_rational(tfc, k, v, s) #define print_str(k, v) avtext_print_string(tfc, k, v, 0) #define print_str_opt(k, v) avtext_print_string(tfc, k, v, AV_TEXTFORMAT_PRINT_STRING_OPTIONAL) diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c index 91469ef576..5b0f92d5cb 100644 --- a/fftools/textformat/avtextformat.c +++ b/fftools/textformat/avtextformat.c @@ -290,10 +290,20 @@ void avtext_print_section_footer(AVTextFormatContext *tctx) tctx->level--; } -void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val) +void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val, int flags) { const AVTextFormatSection *section; + av_assert0(tctx); + + if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER) + return; + + if (tctx->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); section = tctx->section[tctx->level]; @@ -445,10 +455,12 @@ 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 || - (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO - && (flags & AV_TEXTFORMAT_PRINT_STRING_OPTIONAL) - && !(tctx->formatter->flags & AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS))) + if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER) + return 0; + + if (tctx->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 (section->show_all_entries || av_dict_get(section->entries_to_show, key, NULL, 0)) { @@ -504,7 +516,7 @@ void avtext_print_ts(AVTextFormatContext *tctx, const char *key, int64_t ts, int if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0)) avtext_print_string(tctx, key, "N/A", AV_TEXTFORMAT_PRINT_STRING_OPTIONAL); else - avtext_print_integer(tctx, key, ts); + avtext_print_integer(tctx, key, ts, 0); } void avtext_print_data(AVTextFormatContext *tctx, const char *key, diff --git a/fftools/textformat/avtextformat.h b/fftools/textformat/avtextformat.h index 87f57d8c24..8f406de322 100644 --- a/fftools/textformat/avtextformat.h +++ b/fftools/textformat/avtextformat.h @@ -138,7 +138,7 @@ void avtext_print_section_header(AVTextFormatContext *tctx, const void *data, in void avtext_print_section_footer(AVTextFormatContext *tctx); -void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val); +void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val, int flags); int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *val, int flags); -- 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-requ...@ffmpeg.org with subject "unsubscribe".