b=973374 complete speex_resampler_reset_mem r=jmspeex
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 18 Feb 2014 09:52:20 +1300
changeset 169180 1bf41db3ca502ea9a3c9eadd5e7a31f7f55483bc
parent 169179 aa631f68a4feeeacc4345f2c631119a3f861de3f
child 169181 2dd72beeb8f23852a2950010fe3e4d8ac1c4abdf
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjmspeex
bugs973374
milestone30.0a1
b=973374 complete speex_resampler_reset_mem r=jmspeex sample_frac_num is the array most likely to be non-zero after resampling a previous stream, but the other arrays can also be left at non-zero values in other situations.
media/libspeex_resampler/reset.patch
media/libspeex_resampler/src/resample.c
media/libspeex_resampler/update.sh
new file mode 100644
--- /dev/null
+++ b/media/libspeex_resampler/reset.patch
@@ -0,0 +1,35 @@
+# HG changeset patch
+# Parent b65da7e13aaee4756135be04016e081a95e86855
+# User Karl Tomlinson <karlt+@karlt.net>
+b=973374 complete speex_resampler_reset_mem r=jmspeex
+
+sample_frac_num is the array most likely to be non-zero after resampling a
+previous stream, but the other arrays can also be left at non-zero values
+in other situations.
+
+diff --git a/media/libspeex_resampler/src/resample.c b/media/libspeex_resampler/src/resample.c
+--- a/media/libspeex_resampler/src/resample.c
++++ b/media/libspeex_resampler/src/resample.c
+@@ -1141,16 +1141,22 @@ SPX_RESAMPLE_EXPORT int speex_resampler_
+    for (i=0;i<st->nb_channels;i++)
+       st->last_sample[i] = st->filt_len/2;
+    return RESAMPLER_ERR_SUCCESS;
+ }
+ 
+ SPX_RESAMPLE_EXPORT int speex_resampler_reset_mem(SpeexResamplerState *st)
+ {
+    spx_uint32_t i;
++   for (i=0;i<st->nb_channels;i++)
++   {
++      st->last_sample[i] = 0;
++      st->magic_samples[i] = 0;
++      st->samp_frac_num[i] = 0;
++   }
+    for (i=0;i<st->nb_channels*(st->filt_len-1);i++)
+       st->mem[i] = 0;
+    return RESAMPLER_ERR_SUCCESS;
+ }
+ 
+ SPX_RESAMPLE_EXPORT const char *speex_resampler_strerror(int err)
+ {
+    switch (err)
--- a/media/libspeex_resampler/src/resample.c
+++ b/media/libspeex_resampler/src/resample.c
@@ -1141,16 +1141,22 @@ SPX_RESAMPLE_EXPORT int speex_resampler_
    for (i=0;i<st->nb_channels;i++)
       st->last_sample[i] = st->filt_len/2;
    return RESAMPLER_ERR_SUCCESS;
 }
 
 SPX_RESAMPLE_EXPORT int speex_resampler_reset_mem(SpeexResamplerState *st)
 {
    spx_uint32_t i;
+   for (i=0;i<st->nb_channels;i++)
+   {
+      st->last_sample[i] = 0;
+      st->magic_samples[i] = 0;
+      st->samp_frac_num[i] = 0;
+   }
    for (i=0;i<st->nb_channels*(st->filt_len-1);i++)
       st->mem[i] = 0;
    return RESAMPLER_ERR_SUCCESS;
 }
 
 SPX_RESAMPLE_EXPORT const char *speex_resampler_strerror(int err)
 {
    switch (err)
--- a/media/libspeex_resampler/update.sh
+++ b/media/libspeex_resampler/update.sh
@@ -14,8 +14,9 @@ cp $1/src/resample_sse.h src
 cp $1/src/arch.h src
 cp $1/src/stack_alloc.h src
 cp $1/src/speex_resampler.h src
 cp $1/AUTHORS .
 cp $1/COPYING .
 
 # apply outstanding local patches
 patch -p1 < sse-detect-runtime.patch
+patch -p3 < reset.patch