History

fftools/textformat: Add flags param to function avtext_print_integer()

Make this function work analog to avtext_print_string() which already has a flags parameter.

softworkz committed 1 year ago

Commit b71b4441 parent bb3a1443 files · +20 −8Browse files

Unified · Split

3 files
  1. fftools/ffprobe.c +1 −1
  2. fftools/textformat/avtextformat.c +18 −6
  3. fftools/textformat/avtextformat.h +1 −1
fftools/ffprobe.c+1−1
@@ -420,7 +420,7 @@ static void log_callback(void *ptr, int level, const char *fmt, va_list vl) · 419 unmodified lines
420 avtext_print_string(tfc, k, pbuf.str, 0); \420 avtext_print_string(tfc, k, pbuf.str, 0); \
421} while (0)421} while (0)
422 422
423#define print_int(k, v) avtext_print_integer(tfc, k, v)423#define print_int(k, v) avtext_print_integer(tfc, k, v, 0)
424#define print_q(k, v, s) avtext_print_rational(tfc, k, v, s)424#define print_q(k, v, s) avtext_print_rational(tfc, k, v, s)
425#define print_str(k, v) avtext_print_string(tfc, k, v, 0)425#define print_str(k, v) avtext_print_string(tfc, k, v, 0)
426#define print_str_opt(k, v) avtext_print_string(tfc, k, v, AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)426#define print_str_opt(k, v) avtext_print_string(tfc, k, v, AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)
fftools/textformat/avtextformat.c+18−6
@@ -289,10 +289,20 @@ void avtext_print_section_footer(AVTextFormatContext *tctx) · 288 unmodified lines
289 tctx->level--;289 tctx->level--;
290}290}
291 291
292void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val)292void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val, int flags)
293{293{
294 const AVTextFormatSection *section;294 const AVTextFormatSection *section;
295 295
296 av_assert0(tctx);
297
298 if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER)
299 return;
300
301 if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
302 && (flags & AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)
303 && !(tctx->formatter->flags & AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS))
304 return;
305
296 av_assert0(key && tctx->level >= 0 && tctx->level < SECTION_MAX_NB_LEVELS);306 av_assert0(key && tctx->level >= 0 && tctx->level < SECTION_MAX_NB_LEVELS);
297 307
298 section = tctx->section[tctx->level];308 section = tctx->section[tctx->level];
@@ -444,10 +454,12 @@ int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char * · 145 unmodified lines
444 454
445 section = tctx->section[tctx->level];455 section = tctx->section[tctx->level];
446 456
447 if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER ||457 if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER)
448 (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO458 return 0;
449 && (flags & AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)459
450 && !(tctx->formatter->flags & AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS)))460 if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
461 && (flags & AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)
462 && !(tctx->formatter->flags & AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS))
451 return 0;463 return 0;
452 464
453 if (section->show_all_entries || av_dict_get(section->entries_to_show, key, NULL, 0)) {465 if (section->show_all_entries || av_dict_get(section->entries_to_show, key, NULL, 0)) {
@@ -503,7 +515,7 @@ void avtext_print_ts(AVTextFormatContext *tctx, const char *key, int64_t ts, int · 49 unmodified lines
503 if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0))515 if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0))
504 avtext_print_string(tctx, key, "N/A", AV_TEXTFORMAT_PRINT_STRING_OPTIONAL);516 avtext_print_string(tctx, key, "N/A", AV_TEXTFORMAT_PRINT_STRING_OPTIONAL);
505 else517 else
506 avtext_print_integer(tctx, key, ts);518 avtext_print_integer(tctx, key, ts, 0);
507}519}
508 520
509void avtext_print_data(AVTextFormatContext *tctx, const char *key,521void avtext_print_data(AVTextFormatContext *tctx, const char *key,
fftools/textformat/avtextformat.h+1−1
@@ -138,7 +138,7 @@ void avtext_print_section_header(AVTextFormatContext *tctx, const void *data, in · 137 unmodified lines
138 138
139void avtext_print_section_footer(AVTextFormatContext *tctx);139void avtext_print_section_footer(AVTextFormatContext *tctx);
140 140
141void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val);141void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val, int flags);
142 142
143int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *val, int flags);143int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *val, int flags);
144 144

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t