| 56 | static const char *unit_bit_per_second_str = "bit/s"; |
| 57 | |
| 58 | static char *value_string(char *buf, int buf_size, double val, const char *unit) |
| 59 | { |
| 60 | if (unit == unit_second_str && use_value_sexagesimal_format) { |
| 61 | double secs; |
| 62 | int hours, mins; |
| 63 | secs = val; |
| 64 | mins = (int)secs / 60; |
| 65 | secs = secs - mins * 60; |
| 66 | hours = mins / 60; |
| 67 | mins %= 60; |
| 68 | snprintf(buf, buf_size, "%d:%02d:%09.6f", hours, mins, secs); |
| 69 | } else if (use_value_prefix) { |
| 70 | const char *prefix_string; |
| 71 | int index; |
| 72 | |
| 73 | if (unit == unit_byte_str && use_byte_value_binary_prefix) { |
| 74 | index = (int) (log(val)/log(2)) / 10; |
| 75 | index = av_clip(index, 0, FF_ARRAY_ELEMS(binary_unit_prefixes) -1); |
| 76 | val /= pow(2, index*10); |
| 77 | prefix_string = binary_unit_prefixes[index]; |
| 78 | } else { |
| 79 | index = (int) (log10(val)) / 3; |
| 80 | index = av_clip(index, 0, FF_ARRAY_ELEMS(decimal_unit_prefixes) -1); |
| 81 | val /= pow(10, index*3); |
| 82 | prefix_string = decimal_unit_prefixes[index]; |
| 83 | } |
| 84 | |
| 85 | snprintf(buf, buf_size, "%.3f %s%s", val, prefix_string, show_value_unit ? unit : ""); |
| 86 | } else { |
| 87 | snprintf(buf, buf_size, "%f %s", val, show_value_unit ? unit : ""); |
| 88 | } |
| 89 | |
| 90 | return buf; |
| 91 | } |
| 92 | |
| 93 | static char *time_value_string(char *buf, int buf_size, int64_t val, const AVRational *time_base) |
| 94 | { |
no test coverage detected