Ignore:
Timestamp:
Jun 16, 2006 3:54:43 PM (17 years ago)
Author:
bennylp
Message:

Optimizations mostly in the conference bridge (gained more than 3x faster)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/resample.c

    r495 r513  
    5959 *  - move stddefs.h and resample.h to this file. 
    6060 *  - const correctness. 
    61  *  - fixed SrcLinear() may write pass output buffer. 
    62  *  - assume the same for SrcUp() and SrcUD(), so put the same 
    63  *    protection. 
    6461 */ 
    6562#include <pjmedia/resample.h> 
     
    261258    Yend = Ystart + (unsigned)(nx * pFactor); 
    262259    endTime = time + (1<<Np)*(WORD)nx; 
    263     while (time < endTime && Y < Yend)  /* bennylp fix: added Y < Yend */ 
     260    while (time < endTime) 
    264261    { 
    265262        iconst = (time) & Pmask; 
     
    400397    Yend = Ystart + (unsigned)(nx * pFactor); 
    401398    endTime = time + (1<<Np)*(WORD)nx; 
    402     while (time < endTime && Y < Yend)  /* bennylp fix: protect Y */ 
     399    while (time < endTime) 
    403400    { 
    404401        xp = &X[time>>Np];      /* Ptr to current input sample */ 
     
    444441    Yend = Ystart + (unsigned)(nx * pFactor); 
    445442    endTime = time + (1<<Np)*(WORD)nx; 
    446     while (time < endTime && Y < Yend) /* bennylp fix: protect Y */ 
     443    while (time < endTime) 
    447444    { 
    448445        xp = &X[time>>Np];      /* Ptr to current input sample */ 
     
    496493    /* 
    497494     * If we're downsampling, always use the fast algorithm since it seems 
    498      * to yield the same performance. 
     495     * to yield the same quality. 
    499496     */ 
    500497    if (rate_out < rate_in) { 
     498        //no this is not a good idea. It sounds pretty good with speech, 
     499        //but very poor with background noise etc. 
    501500        //high_quality = 0; 
    502501    } 
     
    534533    if (high_quality) { 
    535534        unsigned size; 
    536         unsigned i; 
    537535 
    538536        /* This is a bug in xoff calculation, thanks Stephane Lussier 
     
    552550        PJ_ASSERT_RETURN(resample->buffer, PJ_ENOMEM); 
    553551 
    554         for (i=0; i<resample->xoff*2; ++i) { 
    555             resample->buffer[i] = 0; 
    556         } 
     552        pjmedia_zero_samples(resample->buffer, resample->xoff*2); 
    557553 
    558554 
     
    562558 
    563559    *p_resample = resample; 
     560 
     561    PJ_LOG(5,(THIS_FILE, "resample created: %s qualiy, %s filter, in/out " 
     562                          "rate=%d/%d",  
     563                          (high_quality?"high":"low"), 
     564                          (large_filter?"large":"small"), 
     565                          rate_in, rate_out)); 
    564566    return PJ_SUCCESS; 
    565567} 
     
    574576 
    575577    if (resample->high_quality) { 
    576         unsigned i; 
    577578        pj_int16_t *dst_buf; 
    578579        const pj_int16_t *src_buf; 
     
    645646         */ 
    646647        dst_buf = resample->buffer + resample->xoff*2; 
    647         for (i=0; i<resample->frame_size; ++i) dst_buf[i] = input[i]; 
     648        pjmedia_copy_samples(dst_buf, input, resample->frame_size); 
    648649             
    649650        if (resample->factor >= 1) { 
     
    689690        dst_buf = resample->buffer; 
    690691        src_buf = input + resample->frame_size - resample->xoff*2; 
    691         for (i=0; i<resample->xoff * 2; ++i) { 
    692             dst_buf[i] = src_buf[i]; 
    693         } 
     692        pjmedia_copy_samples(dst_buf, src_buf, resample->xoff * 2); 
    694693 
    695694    } else { 
Note: See TracChangeset for help on using the changeset viewer.