Ensure the filter length is a multiple of 8
authorRon <ron@debian.org>
Fri, 6 Dec 2013 06:18:13 +0000 (01:18 -0500)
committerTristan Matthews <le.businessman@gmail.com>
Fri, 6 Dec 2013 06:18:13 +0000 (01:18 -0500)
Fixes a bug where the SSE implementation would read past the end of the
buffer if it wasn't.

Also taken from f426ab5260fe9f1618a187fc2a8264dbba4aef08 in opus-tools.

Signed-off-by: Tristan Matthews <le.businessman@gmail.com>
libspeexdsp/resample.c

index 6358f46..d178507 100644 (file)
@@ -567,8 +567,8 @@ static void update_filter(SpeexResamplerState *st)
       st->cutoff = quality_map[st->quality].downsample_bandwidth * st->den_rate / st->num_rate;
       /* FIXME: divide the numerator and denominator by a certain amount if they're too large */
       st->filt_len = st->filt_len*st->num_rate / st->den_rate;
-      /* Round down to make sure we have a multiple of 4 */
-      st->filt_len &= (~0x3);
+      /* Round up to make sure we have a multiple of 8 for SSE */
+      st->filt_len = ((st->filt_len-1)&(~0x7))+8;
       if (2*st->den_rate < st->num_rate)
          st->oversample >>= 1;
       if (4*st->den_rate < st->num_rate)