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
420420 avtext_print_string(tfc, k, pbuf.str, 0); \
421421 } while (0)
422422
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)
424424 #define print_q(k, v, s) avtext_print_rational(tfc, k, v, s)
425425 #define print_str(k, v) avtext_print_string(tfc, k, v, 0)
426426 #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
289289 tctx->level--;
290290 }
291291
292−void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val)
292+void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val, int flags)
293293 {
294294 const AVTextFormatSection *section;
295295
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+
296306 av_assert0(key && tctx->level >= 0 && tctx->level < SECTION_MAX_NB_LEVELS);
297307
298308 section = tctx->section[tctx->level];
@@ -444,10 +454,12 @@ int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char * · 145 unmodified lines
444454
445455 section = tctx->section[tctx->level];
446456
447− if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER ||
448− (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
449− && (flags & AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)
450− && !(tctx->formatter->flags & AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS)))
457+ if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER)
458+ return 0;
459+
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))
451463 return 0;
452464
453465 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
503515 if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0))
504516 avtext_print_string(tctx, key, "N/A", AV_TEXTFORMAT_PRINT_STRING_OPTIONAL);
505517 else
506− avtext_print_integer(tctx, key, ts);
518+ avtext_print_integer(tctx, key, ts, 0);
507519 }
508520
509521 void 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
138138
139139 void avtext_print_section_footer(AVTextFormatContext *tctx);
140140
141−void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val);
141+void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val, int flags);
142142
143143 int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *val, int flags);
144144

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