From c2bf75709ef1257433e328e321f7943318704c86 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Thu, 27 Jun 2024 22:16:08 +0200 Subject: [PATCH] command: convert bitrates to bytes when printing to the OSD --- player/command.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/player/command.c b/player/command.c index c97d3d16ba39b..c84ab65ded216 100644 --- a/player/command.c +++ b/player/command.c @@ -3355,19 +3355,20 @@ static int mp_property_packet_bitrate(void *ctx, struct m_property *prop, if (r[type] < 0) return M_PROPERTY_UNAVAILABLE; - // r[type] is in bytes/second -> bits - double rate = r[type] * 8; + // r[type] is in bytes/second + double rate = r[type]; if (action == M_PROPERTY_PRINT) { - rate /= 1000; - if (rate < 1000) { - *(char **)arg = talloc_asprintf(NULL, "%.f kbps", rate); + rate /= 1024; + if (rate < 1024) { + *(char **)arg = talloc_asprintf(NULL, "%.f KiBps", rate); } else { - *(char **)arg = talloc_asprintf(NULL, "%.3f Mbps", rate / 1000.0); + *(char **)arg = talloc_asprintf(NULL, "%.3f MiBps", rate / 1024); } return M_PROPERTY_OK; } - return m_property_int64_ro(action, arg, llrint(rate)); + + return m_property_int64_ro(action, arg, llrint(rate * 8)); } static int mp_property_cwd(void *ctx, struct m_property *prop,