shithub: opus

Download patch

ref: 85a6618af89a541e63b9596f6e2b5ab09d29d7c4
parent: 088929d1f1db2b1aa9a860c385e3938c65270c39
author: Jean-Marc Valin <[email protected]>
date: Thu May 23 23:41:04 EDT 2013

Make pitch_xcorr() work when len and max_pitch aren't multiples of 4.

--- a/celt/pitch.c
+++ b/celt/pitch.c
@@ -209,7 +209,9 @@
 #ifdef FIXED_POINT
    opus_val32 maxcorr=1;
 #endif
-   for (i=0;i<max_pitch;i+=4)
+   /* Truncate slightly if len is not a multiple of 4. */
+   len -= len&3;
+   for (i=0;i<max_pitch-3;i+=4)
    {
       /* Compute correlation*/
       /*corr[nb_pitch-1-i]=inner_prod(x, _y+i, len);*/
@@ -261,6 +263,17 @@
       sum3 = MAX32(sum3, sum4);
       sum1 = MAX32(sum1, sum3);
       maxcorr = MAX32(maxcorr, sum1);
+#endif
+   }
+   /* In case max_pitch isn't a multiple of 4, do non-unrolled version. */
+   for (;i<max_pitch;i++)
+   {
+      opus_val32 sum = 0;
+      for (j=0;j<len;j++)
+         sum = MAC16_16(sum, _x[j],_y[i+j]);
+      xcorr[i] = MAX32(-1, sum);
+#ifdef FIXED_POINT
+      maxcorr = MAX32(maxcorr, sum);
 #endif
    }
 #ifdef FIXED_POINT