diff options
author | Nanang Izzuddin <nanang@teluu.com> | 2010-02-01 11:23:54 +0000 |
---|---|---|
committer | Nanang Izzuddin <nanang@teluu.com> | 2010-02-01 11:23:54 +0000 |
commit | dc61d27b5e6b321067e38cb830ead225ae0b9829 (patch) | |
tree | 561e2fb2f7d12e1d6cb07e46d0a8f680aa5413af /pjmedia | |
parent | e13dbde5e2e020f31bebd8ca48e10e2c2d3900d3 (diff) |
Ticket #766:
- Applied patch provided by Bram Kuijvenhoven related to truncation issue in floating-point to integer type-casts in pjmedia components.
- Original patch proposal and description can be found here: http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2010-January/010258.html.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3085 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia')
-rw-r--r-- | pjmedia/src/pjmedia/conference.c | 8 | ||||
-rw-r--r-- | pjmedia/src/pjmedia/resample_resample.c | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/pjmedia/src/pjmedia/conference.c b/pjmedia/src/pjmedia/conference.c index fd237aa4..fd6477ce 100644 --- a/pjmedia/src/pjmedia/conference.c +++ b/pjmedia/src/pjmedia/conference.c @@ -372,7 +372,7 @@ static pj_status_t create_conf_port( pj_pool_t *pool, //conf_port->rx_buf_cap = (unsigned)(conf_port->samples_per_frame + // conf->samples_per_frame * // conf_port->clock_rate * 1.0 / - // conf->clock_rate); + // conf->clock_rate + 0.5); conf_port->rx_buf_cap = conf_port->clock_rate * buff_ptime / 1000; if (conf_port->channel_count > conf->channel_count) conf_port->rx_buf_cap *= conf_port->channel_count; @@ -1437,7 +1437,7 @@ static pj_status_t read_port( pjmedia_conf *conf, */ samples_req = (unsigned) (count * 1.0 * - cport->clock_rate / conf->clock_rate); + cport->clock_rate / conf->clock_rate + 0.5); while (cport->rx_buf_count < samples_req) { @@ -1509,7 +1509,7 @@ static pj_status_t read_port( pjmedia_conf *conf, pjmedia_resample_run( cport->rx_resample,cport->rx_buf, frame); src_count = (unsigned)(count * 1.0 * cport->clock_rate / - conf->clock_rate); + conf->clock_rate + 0.5); cport->rx_buf_count -= src_count; if (cport->rx_buf_count) { pjmedia_move_samples(cport->rx_buf, cport->rx_buf+src_count, @@ -1693,7 +1693,7 @@ static pj_status_t write_port(pjmedia_conf *conf, struct conf_port *cport, pjmedia_resample_run( cport->tx_resample, buf, cport->tx_buf + cport->tx_buf_count ); dst_count = (unsigned)(conf->samples_per_frame * 1.0 * - cport->clock_rate / conf->clock_rate); + cport->clock_rate / conf->clock_rate + 0.5); } else { /* Same clock rate. * Just copy the samples to tx_buffer. diff --git a/pjmedia/src/pjmedia/resample_resample.c b/pjmedia/src/pjmedia/resample_resample.c index 39a293a7..d251859c 100644 --- a/pjmedia/src/pjmedia/resample_resample.c +++ b/pjmedia/src/pjmedia/resample_resample.c @@ -123,7 +123,7 @@ PJ_DEF(pj_status_t) pjmedia_resample_create( pj_pool_t *pool, /* Allocate temporary output buffer */ size = (unsigned) (resample->frame_size * sizeof(pj_int16_t) * - resample->factor / channel_count); + resample->factor / channel_count + 0.5); resample->tmp_buffer = (pj_int16_t*) pj_pool_alloc(pool, size); PJ_ASSERT_RETURN(resample->tmp_buffer, PJ_ENOMEM); } @@ -245,7 +245,7 @@ PJ_DEF(void) pjmedia_resample_run( pjmedia_resample *resample, unsigned mono_frm_sz_out; mono_frm_sz_in = resample->frame_size / resample->channel_cnt; - mono_frm_sz_out = (unsigned)(mono_frm_sz_in * resample->factor); + mono_frm_sz_out = (unsigned)(mono_frm_sz_in * resample->factor + 0.5); /* Deinterleave input */ dst_buf = resample->in_buffer[i] + resample->xoff*2; |