forked from voipmonitor/sniffer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mos_g729.cpp
45 lines (33 loc) · 12.6 KB
/
mos_g729.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Author: Martin Vit support@voipmonitor.org
2012
*/
/*
l - packet loss on scale 0.0 - 1.0
b - burstr
*/
#include <cmath>
#include <stdio.h>
#include "voipmonitor.h"
long double mos_g729(long double l, long double b) {
l *= 100.0;
// this equation is validated only for l > 0 and l <= 60, and b >= 1 and b <= 30
if(l == 0) {
return 3.92;
} else if(l > 60) {
l = 60;
}
if(b < 1) {
b = 1;
} else if(b > 30) {
b = 30;
}
//TODO: freebsd is missing powl
#ifndef FREEBSD
long double mos =
3.899966470200899-0.43883840459088874*l+0.1170871828582757*powl(l,2)-0.02213005983214617*powl(l,3)+0.0030029397703084685*powl(l,4)-0.0002925328212152316*powl(l,5)+0.00002041319765782261*powl(l,6)-1.0206101887838336*powl(10,-6)*powl(l,7)+3.651145268040383*powl(10,-8)*powl(l,8)-9.286009450952845*powl(10,-10)*powl(l,9)+1.653166685001697*powl(10,-11)*powl(l,10)-1.9968014200873874*powl(10,-13)*powl(l,11)+1.5394901465965007*powl(10,-15)*powl(l,12)-6.637577424962478*powl(10,-18)*powl(l,13)+1.052050257253187*powl(10,-20)*powl(l,14)+1.0286427757215853*powl(10,-23)*powl(l,15)-0.31778891490989963*b-0.007808987370399977*l*b-0.03842177339995715*powl(l,2)*b+0.008486249245535805*powl(l,3)*b-0.0012245323699946313*powl(l,4)*b+0.00012223354307984747*powl(l,5)*b-8.313319533374972*powl(10,-6)*powl(l,6)*b+3.776124761299721*powl(10,-7)*powl(l,7)*b-1.0847581711671669*powl(10,-8)*powl(l,8)*b+1.6074398083861926*powl(10,-10)*powl(l,9)*b+5.127965580721449*powl(10,-13)*powl(l,10)*b-7.518973820292614*powl(10,-14)*powl(l,11)*b+1.5681792182195698*powl(10,-15)*powl(l,12)*b-1.6546259700511855*powl(10,-17)*powl(l,13)*b+9.121674971573233*powl(10,-20)*powl(l,14)*b-2.0753476241124036*powl(10,-22)*powl(l,15)*b+0.31136799968406215*powl(b,2)+0.08505172406063888*l*powl(b,2)-0.0020178569034205777*powl(l,2)*powl(b,2)-0.00021076608399553398*powl(l,3)*powl(b,2)+0.00010446269377011418*powl(l,4)*powl(b,2)-0.000016441419967216755*powl(l,5)*powl(b,2)+1.3975523963931974*powl(10,-6)*powl(l,6)*powl(b,2)-7.229368735201562*powl(10,-8)*powl(l,7)*powl(b,2)+2.261925310786015*powl(10,-9)*powl(l,8)*powl(b,2)-3.614972604215507*powl(10,-11)*powl(l,9)*powl(b,2)-4.9191959823513297*powl(10,-14)*powl(l,10)*powl(b,2)+1.4402418317918903*powl(10,-14)*powl(l,11)*powl(b,2)-2.8757120613146323*powl(10,-16)*powl(l,12)*powl(b,2)+2.6785068967433723*powl(10,-18)*powl(l,13)*powl(b,2)-1.1604121306952917*powl(10,-20)*powl(l,14)*powl(b,2)+1.5635861542023963*powl(10,-23)*powl(l,15)*powl(b,2)-0.16370558004954106*powl(b,3)-0.04554695069022862*l*powl(b,3)+0.0045142523491560685*powl(l,2)*powl(b,3)-0.00059562462181575*powl(l,3)*powl(b,3)+0.00004532356107575911*powl(l,4)*powl(b,3)-1.6966528113545439*powl(10,-6)*powl(l,5)*powl(b,3)+5.263476782117947*powl(10,-10)*powl(l,6)*powl(b,3)+3.3453975227349757*powl(10,-9)*powl(l,7)*powl(b,3)-1.6847914700227762*powl(10,-10)*powl(l,8)*powl(b,3)+3.640936684301378*powl(10,-12)*powl(l,9)*powl(b,3)-1.7239773256201913*powl(10,-14)*powl(l,10)*powl(b,3)-7.506495452233981*powl(10,-16)*powl(l,11)*powl(b,3)+1.3471744859426048*powl(10,-17)*powl(l,12)*powl(b,3)-3.884702213436834*powl(10,-20)*powl(l,13)*powl(b,3)-7.5101035403974615*powl(10,-22)*powl(l,14)*powl(b,3)+5.008544095547508*powl(10,-24)*powl(l,15)*powl(b,3)+0.05266529484381676*powl(b,4)+0.013046067957844206*l*powl(b,4)-0.0012355600304114007*powl(l,2)*powl(b,4)+0.00015004842406486461*powl(l,3)*powl(b,4)-0.00001133067177179606*powl(l,4)*powl(b,4)+5.328114077754467*powl(10,-7)*powl(l,5)*powl(b,4)-1.664933721954034*powl(10,-8)*powl(l,6)*powl(b,4)+2.9387669966869334*powl(10,-10)*powl(l,7)*powl(b,4)+1.2043331068463185*powl(10,-13)*powl(l,8)*powl(b,4)-1.0310401445256838*powl(10,-13)*powl(l,9)*powl(b,4)+6.03811850713338*powl(10,-16)*powl(l,10)*powl(b,4)+2.7743383660103925*powl(10,-17)*powl(l,11)*powl(b,4)-5.285338446296616*powl(10,-20)*powl(l,12)*powl(b,4)-1.2780090288820867*powl(10,-20)*powl(l,13)*powl(b,4)+1.872088989759841*powl(10,-22)*powl(l,14)*powl(b,4)-8.035198482401381*powl(10,-25)*powl(l,15)*powl(b,4)-0.011153669403454426*powl(b,5)-0.0024819882487607803*l*powl(b,5)+0.00017956666767746587*powl(l,2)*powl(b,5)-0.00001762665226334342*powl(l,3)*powl(b,5)+1.108215601902326*powl(10,-6)*powl(l,4)*powl(b,5)-4.143607724516007*powl(10,-8)*powl(l,5)*powl(b,5)+1.0707467952528225*powl(10,-9)*powl(l,6)*powl(b,5)-2.115017333244234*powl(10,-11)*powl(l,7)*powl(b,5)+2.277070379867627*powl(10,-13)*powl(l,8)*powl(b,5)+1.4113425941168082*powl(10,-15)*powl(l,9)*powl(b,5)-1.4464930778655737*powl(10,-17)*powl(l,10)*powl(b,5)-1.381130247652408*powl(10,-18)*powl(l,11)*powl(b,5)+1.8369302577587405*powl(10,-21)*powl(l,12)*powl(b,5)+6.928802756712293*powl(10,-22)*powl(l,13)*powl(b,5)-9.56535949041296*powl(10,-24)*powl(l,14)*powl(b,5)+3.677127457221157*powl(10,-26)*powl(l,15)*powl(b,5)+0.0016325661069707203*powl(b,6)+0.0003415396841978621*l*powl(b,6)-0.00001727133816520934*powl(l,2)*powl(b,6)+1.2072207978416998*powl(10,-6)*powl(l,3)*powl(b,6)-5.720690584857614*powl(10,-8)*powl(l,4)*powl(b,6)+1.2546325073060002*powl(10,-9)*powl(l,5)*powl(b,6)-2.507918321517083*powl(10,-12)*powl(l,6)*powl(b,6)-3.1456807654395366*powl(10,-13)*powl(l,7)*powl(b,6)+1.896086362703528*powl(10,-15)*powl(l,8)*powl(b,6)-5.89378083954602*powl(10,-17)*powl(l,9)*powl(b,6)+2.3617095943897633*powl(10,-18)*powl(l,10)*powl(b,6)+1.9679872034745865*powl(10,-20)*powl(l,11)*powl(b,6)-6.436895513637877*powl(10,-22)*powl(l,12)*powl(b,6)-2.5046929507988916*powl(10,-24)*powl(l,13)*powl(b,6)+2.804888564733372*powl(10,-26)*powl(l,14)*powl(b,6)+3.8798071126153533*powl(10,-28)*powl(l,15)*powl(b,6)-0.0001708377375828754*powl(b,7)-0.00003504471426639981*l*powl(b,7)+1.2386574338217034*powl(10,-6)*powl(l,2)*powl(b,7)-5.097696089593491*powl(10,-8)*powl(l,3)*powl(b,7)+1.4104981301590728*powl(10,-9)*powl(l,4)*powl(b,7)-6.371286455698268*powl(10,-12)*powl(l,5)*powl(b,7)-9.846252209795459*powl(10,-13)*powl(l,6)*powl(b,7)+3.422499216079645*powl(10,-14)*powl(l,7)*powl(b,7)-1.420953832742917*powl(10,-17)*powl(l,8)*powl(b,7)-8.511145225317494*powl(10,-18)*powl(l,9)*powl(b,7)-2.993022809760791*powl(10,-20)*powl(l,10)*powl(b,7)+1.298476952622852*powl(10,-21)*powl(l,11)*powl(b,7)+2.360116302973296*powl(10,-24)*powl(l,12)*powl(b,7)-2.879578800843848*powl(10,-25)*powl(l,13)*powl(b,7)+9.501858934675991*powl(10,-27)*powl(l,14)*powl(b,7)-7.849945855775244*powl(10,-29)*powl(l,15)*powl(b,7)+0.00001307931350940649*powl(b,8)+2.6798386654168886*powl(10,-6)*l*powl(b,8)-7.009396972980531*powl(10,-8)*powl(l,2)*powl(b,8)+1.4815020016881236*powl(10,-9)*powl(l,3)*powl(b,8)+1.1008127078001856*powl(10,-11)*powl(l,4)*powl(b,8)-8.109991713369257*powl(10,-13)*powl(l,5)*powl(b,8)-2.0760879165541408*powl(10,-14)*powl(l,6)*powl(b,8)+1.9959316626116744*powl(10,-16)*powl(l,7)*powl(b,8)-2.476190494388524*powl(10,-18)*powl(l,8)*powl(b,8)+1.9477394759808006*powl(10,-19)*powl(l,9)*powl(b,8)+6.571953728974191*powl(10,-22)*powl(l,10)*powl(b,8)-2.6126337274250706*powl(10,-24)*powl(l,11)*powl(b,8)+2.0157517039176586*powl(10,-25)*powl(l,12)*powl(b,8)-1.2271360863062199*powl(10,-26)*powl(l,13)*powl(b,8)-9.391692528954248*powl(10,-29)*powl(l,14)*powl(b,8)+1.4430528280077132*powl(10,-30)*powl(l,15)*powl(b,8)-7.430154327977153*powl(10,-7)*powl(b,9)-1.4982577764012905*powl(10,-7)*l*powl(b,9)+2.8673003515829324*powl(10,-9)*powl(l,2)*powl(b,9)-5.026289808544609*powl(10,-11)*powl(l,3)*powl(b,9)-1.2802083412588946*powl(10,-12)*powl(l,4)*powl(b,9)+6.603501099570078*powl(10,-14)*powl(l,5)*powl(b,9)+1.7240285279491447*powl(10,-15)*powl(l,6)*powl(b,9)-2.994686823058215*powl(10,-17)*powl(l,7)*powl(b,9)-4.835781728431845*powl(10,-19)*powl(l,8)*powl(b,9)+9.033585812836383*powl(10,-21)*powl(l,9)*powl(b,9)-8.145081738409607*powl(10,-23)*powl(l,10)*powl(b,9)-2.5049661373385143*powl(10,-24)*powl(l,11)*powl(b,9)+2.222982399952401*powl(10,-26)*powl(l,12)*powl(b,9)+5.268527786945157*powl(10,-28)*powl(l,13)*powl(b,9)-3.371890678546338*powl(10,-30)*powl(l,14)*powl(b,9)+4.324636949418699*powl(10,-32)*powl(l,15)*powl(b,9)+3.1478192264849045*powl(10,-8)*powl(b,10)+5.912607588960367*powl(10,-9)*l*powl(b,10)-4.816669193386681*powl(10,-11)*powl(l,2)*powl(b,10)+1.7373951517428646*powl(10,-12)*powl(l,3)*powl(b,10)-4.8322230156340246*powl(10,-14)*powl(l,4)*powl(b,10)-2.2640986180761632*powl(10,-15)*powl(l,5)*powl(b,10)+1.8258864565790424*powl(10,-17)*powl(l,6)*powl(b,10)-1.8179046906036924*powl(10,-19)*powl(l,7)*powl(b,10)+2.1609337040534873*powl(10,-21)*powl(l,8)*powl(b,10)+3.1986519428587163*powl(10,-22)*powl(l,9)*powl(b,10)-1.1068921973973137*powl(10,-24)*powl(l,10)*powl(b,10)-2.5073011869269846*powl(10,-26)*powl(l,11)*powl(b,10)+6.069637925697897*powl(10,-28)*powl(l,12)*powl(b,10)+8.264217780239248*powl(10,-30)*powl(l,13)*powl(b,10)-2.2795578785845427*powl(10,-31)*powl(l,14)*powl(b,10)-2.674732870828612*powl(10,-33)*powl(l,15)*powl(b,10)-9.883245076937735*powl(10,-10)*powl(b,11)-1.5465355491254617*powl(10,-10)*l*powl(b,11)-2.8644484993126064*powl(10,-12)*powl(l,2)*powl(b,11)+4.29123104352728*powl(10,-14)*powl(l,3)*powl(b,11)+4.872273098711899*powl(10,-15)*powl(l,4)*powl(b,11)-3.3497991617834587*powl(10,-17)*powl(l,5)*powl(b,11)-1.1246529292411666*powl(10,-18)*powl(l,6)*powl(b,11)+2.387672865213082*powl(10,-20)*powl(l,7)*powl(b,11)+1.3999529203366345*powl(10,-22)*powl(l,8)*powl(b,11)-7.569594417356819*powl(10,-24)*powl(l,9)*powl(b,11)-7.870568358022501*powl(10,-26)*powl(l,10)*powl(b,11)+1.4127697527133066*powl(10,-27)*powl(l,11)*powl(b,11)-1.8646512341653862*powl(10,-29)*powl(l,12)*powl(b,11)-5.31058199926569*powl(10,-31)*powl(l,13)*powl(b,11)+6.14861851474332*powl(10,-33)*powl(l,14)*powl(b,11)+1.5716904113340019*powl(10,-34)*powl(l,15)*powl(b,11)+2.247453752454704*powl(10,-11)*powl(b,12)+2.3209669949374004*powl(10,-12)*l*powl(b,12)+2.35208196754038*powl(10,-13)*powl(l,2)*powl(b,12)-7.996582721820584*powl(10,-15)*powl(l,3)*powl(b,12)-5.0539032455275684*powl(10,-17)*powl(l,4)*powl(b,12)+2.899467683129404*powl(10,-18)*powl(l,5)*powl(b,12)-3.996921953877034*powl(10,-20)*powl(l,6)*powl(b,12)+5.5509345170524825*powl(10,-22)*powl(l,7)*powl(b,12)+2.548453156757029*powl(10,-24)*powl(l,8)*powl(b,12)-4.2606916898490345*powl(10,-25)*powl(l,9)*powl(b,12)+2.436923598925315*powl(10,-27)*powl(l,10)*powl(b,12)+1.5051037309806006*powl(10,-28)*powl(l,11)*powl(b,12)-6.546845758205041*powl(10,-31)*powl(l,12)*powl(b,12)-1.2519705361435955*powl(10,-32)*powl(l,13)*powl(b,12)+3.375397026077028*powl(10,-34)*powl(l,14)*powl(b,12)-7.019176043780393*powl(10,-36)*powl(l,15)*powl(b,12)-3.5165449081723103*powl(10,-13)*powl(b,13)-9.9568306849724*powl(10,-15)*l*powl(b,13)-7.611144487546826*powl(10,-15)*powl(l,2)*powl(b,13)+3.481676324898193*powl(10,-16)*powl(l,3)*powl(b,13)-5.152189611163925*powl(10,-18)*powl(l,4)*powl(b,13)+3.6556456787701954*powl(10,-20)*powl(l,5)*powl(b,13)+1.8755341288152811*powl(10,-22)*powl(l,6)*powl(b,13)-1.8303586633194578*powl(10,-23)*powl(l,7)*powl(b,13)+2.8741374868832894*powl(10,-25)*powl(l,8)*powl(b,13)-1.8922266429951746*powl(10,-27)*powl(l,9)*powl(b,13)+8.789856462319716*powl(10,-29)*powl(l,10)*powl(b,13)-3.7660714932591605*powl(10,-32)*powl(l,11)*powl(b,13)-6.133791568095988*powl(10,-32)*powl(l,12)*powl(b,13)+2.572995522263487*powl(10,-34)*powl(l,13)*powl(b,13)+2.0058230801788795*powl(10,-36)*powl(l,14)*powl(b,13)+8.174349688464047*powl(10,-38)*powl(l,15)*powl(b,13)+3.3942308496287094*powl(10,-15)*powl(b,14)-2.1605620606538865*powl(10,-16)*l*powl(b,14)+1.2278585988072048*powl(10,-16)*powl(l,2)*powl(b,14)-6.804931823792896*powl(10,-18)*powl(l,3)*powl(b,14)+1.8346021822677158*powl(10,-19)*powl(l,4)*powl(b,14)-3.983709892900733*powl(10,-21)*powl(l,5)*powl(b,14)+8.054546749684859*powl(10,-23)*powl(l,6)*powl(b,14)-1.2189597790969087*powl(10,-24)*powl(l,7)*powl(b,14)+4.760432797233759*powl(10,-27)*powl(l,8)*powl(b,14)+2.3487193308773845*powl(10,-28)*powl(l,9)*powl(b,14)-1.0638584587219675*powl(10,-30)*powl(l,10)*powl(b,14)-1.2550411328022192*powl(10,-31)*powl(l,11)*powl(b,14)+8.037475971291596*powl(10,-34)*powl(l,12)*powl(b,14)+5.50067450832022*powl(10,-35)*powl(l,13)*powl(b,14)-8.759566581150109*powl(10,-37)*powl(l,14)*powl(b,14)+2.893222836259769*powl(10,-39)*powl(l,15)*powl(b,14)-1.5226085441632255*powl(10,-17)*powl(b,15)+2.512711039248748*powl(10,-18)*l*powl(b,15)-8.101751959076253*powl(10,-19)*powl(l,2)*powl(b,15)+5.1740921521694933*powl(10,-20)*powl(l,3)*powl(b,15)-1.862741394534655*powl(10,-21)*powl(l,4)*powl(b,15)+5.586020993843898*powl(10,-23)*powl(l,5)*powl(b,15)-1.5085972150009295*powl(10,-24)*powl(l,6)*powl(b,15)+3.0855584988854196*powl(10,-26)*powl(l,7)*powl(b,15)-3.2504838607051448*powl(10,-28)*powl(l,8)*powl(b,15)-6.851816390594346*powl(10,-31)*powl(l,9)*powl(b,15)+2.5622796956957424*powl(10,-32)*powl(l,10)*powl(b,15)-1.116933718584682*powl(10,-34)*powl(l,11)*powl(b,15)+4.3234794592099036*powl(10,-35)*powl(l,12)*powl(b,15)-1.4559090011757903*powl(10,-36)*powl(l,13)*powl(b,15)+1.6892742168172772*powl(10,-38)*powl(l,14)*powl(b,15)-6.361081946238136*powl(10,-41)*powl(l,15)*powl(b,15);
#else
long double mos = 4.5;
#endif
return mos;
}