Ignore:
Timestamp:
May 22, 2006 10:48:11 AM (18 years ago)
Author:
bennylp
Message:

Change jitter calculation in sound test (sndtest) to show the worst jitter value

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/samples/sndtest.c

    r469 r471  
    253253{ 
    254254    unsigned i, dur; 
     255    int ptime; 
    255256    unsigned min_jitter, max_jitter, sum_jitter, avg_jitter=0; 
    256257 
     
    298299    } 
    299300 
     301    /* Calculate frame ptime in usec */ 
     302    ptime = test_data->samples_per_frame * 1000000 / 
     303            test_data->clock_rate; 
     304 
    300305    /* Calculate jitter */ 
    301306    min_jitter = 0xFFFFF; 
     
    304309 
    305310    for (i=1; i<strm_data->counter; ++i) { 
    306         int jitter; 
    307         jitter = strm_data->delay[i] - strm_data->delay[i-1]; 
    308         if (jitter < 0) jitter = -jitter; 
     311        int jitter1, jitter2, jitter; 
     312 
     313        /* jitter1 is interarrival difference */ 
     314        jitter1 = strm_data->delay[i] - strm_data->delay[i-1]; 
     315        if (jitter1 < 0) jitter1 = -jitter1; 
    309316         
     317        /* jitter2 is difference between actual and scheduled arrival. 
     318         * This is intended to capture situation when frames are coming 
     319         * instantaneously, which will calculate as zero jitter with 
     320         * jitter1 calculation. 
     321         */ 
     322        jitter2 = ptime - strm_data->delay[i]; 
     323        if (jitter2 < 0) jitter2 = -jitter2; 
     324 
     325        /* Set jitter as the maximum of the two jitter calculations.  
     326         * This is intended to show the worst result. 
     327         */ 
     328        jitter = (jitter1>jitter2) ? jitter1 : jitter2; 
     329 
     330        /* Calculate min, max, avg jitter */ 
    310331        if (jitter < (int)min_jitter) min_jitter = jitter; 
    311332        if (jitter > (int)max_jitter) max_jitter = jitter; 
Note: See TracChangeset for help on using the changeset viewer.