[xiph-commits] r12417 - trunk/speex/libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Fri Feb 2 06:29:39 PST 2007
Author: jm
Date: 2007-02-02 06:29:34 -0800 (Fri, 02 Feb 2007)
New Revision: 12417
Modified:
trunk/speex/libspeex/resample.c
Log:
remembering how much was allocated
Modified: trunk/speex/libspeex/resample.c
===================================================================
--- trunk/speex/libspeex/resample.c 2007-02-02 14:05:06 UTC (rev 12416)
+++ trunk/speex/libspeex/resample.c 2007-02-02 14:29:34 UTC (rev 12417)
@@ -222,18 +222,24 @@
st->mem = (spx_word16_t*)speex_alloc(st->nb_channels*(st->filt_len-1) * sizeof(spx_word16_t));
for (i=0;i<st->nb_channels*(st->filt_len-1);i++)
st->mem[i] = 0;
+ st->mem_alloc_size = st->filt_len-1;
/*speex_warning("init filter");*/
} else if (!st->started)
{
st->mem = (spx_word16_t*)speex_realloc(st->mem, st->nb_channels*(st->filt_len-1) * sizeof(spx_word16_t));
for (i=0;i<st->nb_channels*(st->filt_len-1);i++)
st->mem[i] = 0;
+ st->mem_alloc_size = st->filt_len-1;
/*speex_warning("reinit filter");*/
} else if (st->filt_len > old_length)
{
/* Increase the filter length */
/*speex_warning("increase filter size");*/
- st->mem = (spx_word16_t*)speex_realloc(st->mem, st->nb_channels*(st->filt_len-1) * sizeof(spx_word16_t));
+ if (st->filt_len-1 > st->mem_alloc_size)
+ {
+ st->mem = (spx_word16_t*)speex_realloc(st->mem, st->nb_channels*(st->filt_len-1) * sizeof(spx_word16_t));
+ st->mem_alloc_size = st->filt_len-1;
+ }
for (i=0;i<st->nb_channels;i++)
{
int j;
@@ -248,8 +254,10 @@
}
} else if (st->filt_len < old_length)
{
- /* Reduce filter length */
+ /* Reduce filter length, this a bit tricky */
/*speex_warning("decrease filter size (unimplemented)");*/
+ /* Adjust last_sample (which will likely end up negative) */
+ /*st->last_sample += (st->filt_len - old_length)/2;*/
}
}
More information about the commits
mailing list