Changeset 3085


Ignore:
Timestamp:
Feb 1, 2010 11:23:54 AM (14 years ago)
Author:
nanang
Message:

Ticket #766:

Location:
pjproject/trunk
Files:
3 edited

Legend:

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

    r2755 r3085  
    373373        //                                 conf->samples_per_frame *  
    374374        //                                 conf_port->clock_rate * 1.0 / 
    375         //                                 conf->clock_rate); 
     375        //                                 conf->clock_rate + 0.5); 
    376376        conf_port->rx_buf_cap = conf_port->clock_rate * buff_ptime / 1000; 
    377377        if (conf_port->channel_count > conf->channel_count) 
     
    14381438 
    14391439        samples_req = (unsigned) (count * 1.0 *  
    1440                       cport->clock_rate / conf->clock_rate); 
     1440                      cport->clock_rate / conf->clock_rate + 0.5); 
    14411441 
    14421442        while (cport->rx_buf_count < samples_req) { 
     
    15101510 
    15111511            src_count = (unsigned)(count * 1.0 * cport->clock_rate /  
    1512                                    conf->clock_rate); 
     1512                                   conf->clock_rate + 0.5); 
    15131513            cport->rx_buf_count -= src_count; 
    15141514            if (cport->rx_buf_count) { 
     
    16941694                              cport->tx_buf + cport->tx_buf_count ); 
    16951695        dst_count = (unsigned)(conf->samples_per_frame * 1.0 * 
    1696                                cport->clock_rate / conf->clock_rate); 
     1696                               cport->clock_rate / conf->clock_rate + 0.5); 
    16971697    } else { 
    16981698        /* Same clock rate. 
  • pjproject/trunk/pjmedia/src/pjmedia/resample_resample.c

    r2394 r3085  
    124124        /* Allocate temporary output buffer */ 
    125125        size = (unsigned) (resample->frame_size * sizeof(pj_int16_t) *  
    126                            resample->factor / channel_count); 
     126                           resample->factor / channel_count + 0.5); 
    127127        resample->tmp_buffer = (pj_int16_t*) pj_pool_alloc(pool, size); 
    128128        PJ_ASSERT_RETURN(resample->tmp_buffer, PJ_ENOMEM); 
     
    246246         
    247247            mono_frm_sz_in  = resample->frame_size / resample->channel_cnt; 
    248             mono_frm_sz_out = (unsigned)(mono_frm_sz_in * resample->factor); 
     248            mono_frm_sz_out = (unsigned)(mono_frm_sz_in * resample->factor + 0.5); 
    249249 
    250250            /* Deinterleave input */ 
  • pjproject/trunk/third_party/resample/src/resamplesubs.c

    r1969 r3085  
    119119     
    120120    Ystart = Y; 
    121     Yend = Ystart + (unsigned)(nx * pFactor); 
     121    Yend = Ystart + (unsigned)(nx * pFactor + 0.5); 
    122122    endTime = time + (1<<Np)*(RES_WORD)nx; 
    123     while (time < endTime) 
     123     
     124    // Integer round down in dtb calculation may cause (endTime % dtb > 0),  
     125    // so it may cause resample write pass the output buffer (Y >= Yend). 
     126    // while (time < endTime) 
     127    while (Y < Yend) 
    124128    { 
    125129        iconst = (time) & Pmask; 
     
    258262     
    259263    Ystart = Y; 
    260     Yend = Ystart + (unsigned)(nx * pFactor); 
     264    Yend = Ystart + (unsigned)(nx * pFactor + 0.5); 
    261265    endTime = time + (1<<Np)*(RES_WORD)nx; 
    262266 
     
    306310     
    307311    Ystart = Y; 
    308     Yend = Ystart + (unsigned)(nx * pFactor); 
     312    Yend = Ystart + (unsigned)(nx * pFactor + 0.5); 
    309313    endTime = time + (1<<Np)*(RES_WORD)nx; 
    310314 
Note: See TracChangeset for help on using the changeset viewer.