From oku at iki.fi Wed May 2 07:28:08 2012 From: oku at iki.fi (oku at iki.fi) Date: Wed, 2 May 2012 17:28:08 +0300 Subject: [Speex-dev] [PATCH] resample: Fix input indexing bug from interleaved functions Message-ID: <1335968888-19327-1-git-send-email-oku@iki.fi> From: Jyri Sarha This bug happens quite often when resampling from a low to a high sample-rate with big enough factor. Also the resampling call has to be limited by the output buffer size and some unused samples needs be left in the input buffer. Sometimes when up-sampling with a big factor the resampling function wants to peek one more sample from the input buffer to produce one more output sample, but the inputs sample is not consumed because it is also needed to produce the next output sample. When resampling the next channel this peeked sample is not any more available because *in_len parameter value was updated when resampling the first channel. Signed-off-by: Jyri Sarha --- libspeex/resample.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libspeex/resample.c b/libspeex/resample.c index 7957c61..d59508d 100644 --- a/libspeex/resample.c +++ b/libspeex/resample.c @@ -970,13 +970,15 @@ EXPORT int speex_resampler_process_interleaved_float(SpeexResamplerState *st, co { spx_uint32_t i; int istride_save, ostride_save; - spx_uint32_t bak_len = *out_len; + spx_uint32_t bak_out_len = *out_len; + spx_uint32_t bak_in_len = *in_len; istride_save = st->in_stride; ostride_save = st->out_stride; st->in_stride = st->out_stride = st->nb_channels; for (i=0;inb_channels;i++) { - *out_len = bak_len; + *out_len = bak_out_len; + *in_len = bak_in_len; if (in != NULL) speex_resampler_process_float(st, i, in+i, in_len, out+i, out_len); else @@ -991,13 +993,15 @@ EXPORT int speex_resampler_process_interleaved_int(SpeexResamplerState *st, cons { spx_uint32_t i; int istride_save, ostride_save; - spx_uint32_t bak_len = *out_len; + spx_uint32_t bak_out_len = *out_len; + spx_uint32_t bak_in_len = *in_len; istride_save = st->in_stride; ostride_save = st->out_stride; st->in_stride = st->out_stride = st->nb_channels; for (i=0;inb_channels;i++) { - *out_len = bak_len; + *out_len = bak_out_len; + *in_len = bak_in_len; if (in != NULL) speex_resampler_process_int(st, i, in+i, in_len, out+i, out_len); else -- 1.7.4.1 From smithja at hkalid.com Wed May 23 15:26:19 2012 From: smithja at hkalid.com (smithja at hkalid.com) Date: Wed, 23 May 2012 15:26:19 -0700 Subject: [Speex-dev] problem with encoding/decoding examples Message-ID: <20120523152619.4942b699627ba2147677575eeef7bb17.9688f1fcec.wbe@email13.secureserver.net> An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20120523/664858e3/attachment.htm From smithja at hkalid.com Wed May 23 21:59:34 2012 From: smithja at hkalid.com (smithja at hkalid.com) Date: Wed, 23 May 2012 21:59:34 -0700 Subject: [Speex-dev] problem with encoding/decoding examples Message-ID: <20120523215934.4942b699627ba2147677575eeef7bb17.0bb5d5bf14.wbe@email13.secureserver.net> An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20120523/4694df38/attachment.htm