## opalvoip-devel

 [Opalvoip-devel] Fix for problem in jitter statistics calculation From: Alexander Sbitnev - 2012-09-06 14:38:45 ``` For ages i keep seeing insane jitter values for received streams. I put some time and look inside this problem. Here it is a code for jitter calculation: // As per RFC3550 Appendix 8 diff *= GetJitterTimeUnits(); // Convert to timestamp units long variance = diff - lastTransitTime; PTRACE(2, "RTP\tJitter calculation " << variance << "=" << diff......................................................... << "-" << lastTransitTime);.. lastTransitTime = diff; if (variance < 0) variance = -variance; jitterLevel += variance - ((jitterLevel+(1<<(JitterRoundingGuardBits-1))) >> JitterRoundingGuardBits); Doing introspection with print i found source of this problem: long variance = diff - lastTransitTime; Problem is 64 bit long and diff and lastTransitTime is 32 bit DWORD. So doing explicit cast to long for both operands solves this problem. long variance = (long)diff - (long)lastTransitTime; I suppose on systems with 32 bit long there is no problem here. ```
 Re: [Opalvoip-devel] Fix for problem in jitter statistics calculation From: Robert Jongbloed - 2012-09-06 23:46:25 Attachments: Message as HTML ```Patch applied. Thank you very much for some great digging. *Robert Jongbloed* /OPAL/OpenH323/PTLib Architect and Co-founder./ Commercial support at http://www.voxlucida.com.au On 7/09/2012 12:38 AM, Alexander Sbitnev wrote: > For ages i keep seeing insane jitter values for received streams. I > put some time and look inside this problem. > Here it is a code for jitter calculation: > > // As per RFC3550 Appendix 8 > diff *= GetJitterTimeUnits(); // Convert to timestamp units > long variance = diff - lastTransitTime; > PTRACE(2, "RTP\tJitter calculation " << variance << "=" << > diff......................................................... > << "-" << lastTransitTime);.. > lastTransitTime = diff; > if (variance < 0) > variance = -variance; > jitterLevel += variance - > ((jitterLevel+(1<<(JitterRoundingGuardBits-1))) >> JitterRoundingGuardBits); > > Doing introspection with print i found source of this problem: > long variance = diff - lastTransitTime; > > Problem is 64 bit long and diff and lastTransitTime is 32 bit DWORD. > So doing explicit cast to long for both operands solves this problem. > > long variance = (long)diff - (long)lastTransitTime; > > I suppose on systems with 32 bit long there is no problem here. > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Opalvoip-devel mailing list > Opalvoip-devel@... > https://lists.sourceforge.net/lists/listinfo/opalvoip-devel ```