From 4d56c6675a862f2212deabebb7ae0511c69821ca Mon Sep 17 00:00:00 2001 From: Julien Chavanton Date: Thu, 25 Mar 2021 08:28:29 -0700 Subject: [PATCH] mos calculation adjustment for negative r-factor --- daemon/ssrc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/daemon/ssrc.c b/daemon/ssrc.c index 3e6f09fab..63079a1c3 100644 --- a/daemon/ssrc.c +++ b/daemon/ssrc.c @@ -71,11 +71,15 @@ static void mos_calc(struct ssrc_stats_block *ssb) { else r = 93.2 - (eff_rtt - 120) / 10.0; r = r - (ssb->packetloss * 2.5); - if (r < 0) - r = 0; - double mos = 1.0 + (0.035) * r + (.000007) * r * (r-60) * (100-r); - int64_t intmos = mos * 10.0; - if (intmos < 0) + + int64_t intmos; + if (r < 0) { + intmos = 10; + } else { + double mos = 1.0 + (0.035) * r + (.000007) * r * (r-60) * (100-r); + intmos = mos * 10.0; + } + if (intmos < 10) // must be an invalid input intmos = 0; ssb->mos = intmos; }