MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / value_string

Function value_string

fftools/textformat/avtextformat.c:373–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371};
372
373static char *value_string(const AVTextFormatContext *tctx, char *buf, int buf_size, struct unit_value uv)
374{
375 double vald;
376 int64_t vali = 0;
377 int show_float = 0;
378
379 if (uv.unit == unit_second_str) {
380 vald = uv.val.d;
381 show_float = 1;
382 } else {
383 vald = (double)uv.val.i;
384 vali = uv.val.i;
385 }
386
387 if (uv.unit == unit_second_str && tctx->opts.use_value_sexagesimal_format) {
388 double secs;
389 int hours, mins;
390 secs = vald;
391 mins = (int)secs / 60;
392 secs = secs - mins * 60;
393 hours = mins / 60;
394 mins %= 60;
395 snprintf(buf, buf_size, "%d:%02d:%09.6f", hours, mins, secs);
396 } else {
397 const char *prefix_string = "";
398
399 if (tctx->opts.use_value_prefix && vald > 1) {
400 int64_t index;
401
402 if (uv.unit == unit_byte_str && tctx->opts.use_byte_value_binary_prefix) {
403 index = (int64_t)(log2(vald) / 10);
404 index = av_clip64(index, 0, FF_ARRAY_ELEMS(si_prefixes) - 1);
405 vald /= si_prefixes[index].bin_val;
406 prefix_string = si_prefixes[index].bin_str;
407 } else {
408 index = (int64_t)(log10(vald) / 3);
409 index = av_clip64(index, 0, FF_ARRAY_ELEMS(si_prefixes) - 1);
410 vald /= si_prefixes[index].dec_val;
411 prefix_string = si_prefixes[index].dec_str;
412 }
413 vali = (int64_t)vald;
414 }
415
416 if (show_float || (tctx->opts.use_value_prefix && vald != (int64_t)vald))
417 snprintf(buf, buf_size, "%f", vald);
418 else
419 snprintf(buf, buf_size, "%"PRId64, vali);
420
421 av_strlcatf(buf, buf_size, "%s%s%s", *prefix_string || tctx->opts.show_value_unit ? " " : "",
422 prefix_string, tctx->opts.show_value_unit ? uv.unit : "");
423 }
424
425 return buf;
426}
427
428
429void avtext_print_unit_integer(AVTextFormatContext *tctx, const char *key, int64_t val, const char *unit)

Callers 2

avtext_print_timeFunction · 0.85

Calls 1

av_strlcatfFunction · 0.85

Tested by

no test coverage detected