Changeset 1961 for pjproject/trunk/pjmedia/src/pjmedia/rtcp_xr.c
 Timestamp:
 May 17, 2008 2:54:18 PM (15 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

pjproject/trunk/pjmedia/src/pjmedia/rtcp_xr.c
r1945 r1961 27 27 #include <pj/string.h> 28 28 29 #if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)29 #if 1 //defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0) 30 30 31 31 #define THIS_FILE "rtcp_xr.c" … … 58 58 # define TRACE_(x) ; 59 59 #endif 60 61 /* Integer square root for calculating standard deviation */62 static pj_uint32_t my_isqrt(pj_uint32_t i)63 {64 pj_uint32_t res = 1, prev;65 66 /* Rough guess */67 prev = i >> 2;68 while (prev) {69 prev >>= 2;70 res <<= 1;71 }72 73 /* Babilonian method */74 do {75 prev = res;76 res = (prev + i/prev) >> 1;77 } while ((prev+res)>>1 != res);78 79 return res;80 }81 60 82 61 void pjmedia_rtcp_xr_init( pjmedia_rtcp_xr_session *session, … … 231 210 r>jitter_min = pj_htonl(sess>stat.rx.stat_sum.jitter.min); 232 211 r>jitter_max = pj_htonl(sess>stat.rx.stat_sum.jitter.max); 233 r>jitter_mean = pj_htonl(sess>stat.rx.stat_sum.jitter.mean);234 sess>stat.rx.stat_sum.jitter.dev =235 my_isqrt(sess>stat.rx.stat_sum.jitter.dev);236 r>jitter_dev = pj_htonl(sess>stat.rx.stat_sum.jitter.dev);212 r>jitter_mean = 213 pj_htonl((unsigned)sess>stat.rx.stat_sum.jitter.mean); 214 r>jitter_dev = 215 pj_htonl(pj_math_stat_get_stddev(&sess>stat.rx.stat_sum.jitter)); 237 216 } 238 217 if (sess>stat.rx.stat_sum.t) { 239 218 r>toh_min = sess>stat.rx.stat_sum.toh.min; 240 219 r>toh_max = sess>stat.rx.stat_sum.toh.max; 241 r>toh_mean = sess>stat.rx.stat_sum.toh.mean; 242 sess>stat.rx.stat_sum.toh.dev = 243 my_isqrt(sess>stat.rx.stat_sum.toh.dev); 244 r>toh_dev = sess>stat.rx.stat_sum.toh.dev; 220 r>toh_mean = (unsigned) sess>stat.rx.stat_sum.toh.mean; 221 r>toh_dev = pj_math_stat_get_stddev(&sess>stat.rx.stat_sum.toh); 245 222 } 246 223 … … 293 270 294 271 /* Calculate burst and densities. */ 295 if (c total) {272 if (c11 && (c23  c33)) { 296 273 p32 = c32 / (c31 + c32 + c33); 297 274 if((c22 + c23) < 1) { … … 518 495 */ 519 496 if (eedelay <= 30 * 1000 * 1000UL) { 520 if (sess>stat.rtt.update_cnt == 0)521 sess>stat.rtt.min = rtt;522 523 497 /* "Normalize" rtt value that is exceptionally high. 524 498 * For such values, "normalize" the rtt to be three times 525 499 * the average value. 526 500 */ 527 if (rtt>( sess>stat.rtt.avg*3) && sess>stat.rtt.update_cnt!=0)501 if (rtt>((unsigned)sess>stat.rtt.mean*3) && sess>stat.rtt.n!=0) 528 502 { 529 503 unsigned orig_rtt = rtt; 530 rtt = sess>stat.rtt.avg*3;504 rtt = (unsigned)sess>stat.rtt.mean*3; 531 505 PJ_LOG(5,(sess>name, 532 506 "RTT value %d usec is normalized to %d usec", … … 535 509 536 510 TRACE_((sess>name, "RTCP RTT is set to %d usec", rtt)); 537 538 if (rtt < sess>stat.rtt.min && rtt) 539 sess>stat.rtt.min = rtt; 540 if (rtt > sess>stat.rtt.max) 541 sess>stat.rtt.max = rtt; 542 543 sess>stat.rtt.avg = 544 (sess>stat.rtt.avg * sess>stat.rtt.update_cnt + rtt) / 545 (sess>stat.rtt.update_cnt + 1); 546 547 sess>stat.rtt.last = rtt; 548 sess>stat.rtt.update_cnt++; 511 pj_math_stat_update(&sess>stat.rtt, rtt); 549 512 } 550 513 } else { … … 586 549 sess>stat.tx.stat_sum.jitter.min = pj_ntohl(rb_stats>jitter_min); 587 550 sess>stat.tx.stat_sum.jitter.max = pj_ntohl(rb_stats>jitter_max); 588 sess>stat.tx.stat_sum.jitter.mean = pj_ntohl(rb_stats>jitter_mean); 589 sess>stat.tx.stat_sum.jitter.dev = pj_ntohl(rb_stats>jitter_dev); 551 sess>stat.tx.stat_sum.jitter.mean= pj_ntohl(rb_stats>jitter_mean); 552 pj_math_stat_set_stddev(&sess>stat.tx.stat_sum.jitter, 553 pj_ntohl(rb_stats>jitter_dev)); 590 554 } 591 555 … … 593 557 sess>stat.tx.stat_sum.toh.min = rb_stats>toh_min; 594 558 sess>stat.tx.stat_sum.toh.max = rb_stats>toh_max; 595 sess>stat.tx.stat_sum.toh.mean = rb_stats>toh_mean; 596 sess>stat.tx.stat_sum.toh.dev = rb_stats>toh_dev; 559 sess>stat.tx.stat_sum.toh.mean= rb_stats>toh_mean; 560 pj_math_stat_set_stddev(&sess>stat.tx.stat_sum.toh, 561 pj_ntohl(rb_stats>toh_dev)); 597 562 } 598 563 … … 728 693 729 694 if (jitter >= 0) { 730 pj_int32_t diff;731 732 695 sess>stat.rx.stat_sum.j = PJ_TRUE; 733 if (sess>stat.rx.stat_sum.jitter.min > (pj_uint32_t)jitter) 734 sess>stat.rx.stat_sum.jitter.min = jitter; 735 if (sess>stat.rx.stat_sum.jitter.max < (pj_uint32_t)jitter) 736 sess>stat.rx.stat_sum.jitter.max = jitter; 737 sess>stat.rx.stat_sum.jitter.mean = 738 (jitter + sess>stat.rx.stat_sum.jitter.mean * 739 sess>stat.rx.stat_sum.jitter.count) / 740 (sess>stat.rx.stat_sum.jitter.count + 1); 741 742 diff = sess>stat.rx.stat_sum.jitter.mean  jitter; 743 sess>stat.rx.stat_sum.jitter.dev = 744 (diff * diff + sess>stat.rx.stat_sum.jitter.dev * 745 sess>stat.rx.stat_sum.jitter.count) / 746 (sess>stat.rx.stat_sum.jitter.count + 1); 747 748 ++sess>stat.rx.stat_sum.jitter.count; 696 pj_math_stat_update(&sess>stat.rx.stat_sum.jitter, jitter); 749 697 } 750 698 751 699 if (toh >= 0) { 752 pj_int32_t diff;753 754 700 sess>stat.rx.stat_sum.t = toh_ipv4? 1 : 2; 755 756 if (sess>stat.rx.stat_sum.toh.min > (pj_uint32_t)toh) 757 sess>stat.rx.stat_sum.toh.min = toh; 758 if (sess>stat.rx.stat_sum.toh.max < (pj_uint32_t)toh) 759 sess>stat.rx.stat_sum.toh.max = toh; 760 sess>stat.rx.stat_sum.toh.mean = 761 (toh + sess>stat.rx.stat_sum.toh.mean * 762 sess>stat.rx.stat_sum.toh.count) / 763 (sess>stat.rx.stat_sum.toh.count + 1); 764 765 diff = sess>stat.rx.stat_sum.toh.mean  toh; 766 sess>stat.rx.stat_sum.toh.dev = 767 (diff * diff + sess>stat.rx.stat_sum.toh.dev * 768 sess>stat.rx.stat_sum.toh.count) / 769 (sess>stat.rx.stat_sum.toh.count + 1); 770 771 ++sess>stat.rx.stat_sum.toh.count; 701 pj_math_stat_update(&sess>stat.rx.stat_sum.toh, toh); 772 702 } 773 703
Note: See TracChangeset
for help on using the changeset viewer.