| 371 | }; |
| 372 | |
| 373 | static 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 | |
| 429 | void avtext_print_unit_integer(AVTextFormatContext *tctx, const char *key, int64_t val, const char *unit) |
no test coverage detected