Fixes a fixed-point overflow in stereo angle calculation
authorJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Thu, 9 Dec 2010 20:23:45 +0000 (15:23 -0500)
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Thu, 9 Dec 2010 20:23:45 +0000 (15:23 -0500)
libcelt/vq.c

index e8bb562..b80b65c 100644 (file)
@@ -381,8 +381,8 @@ int stereo_itheta(celt_norm *X, celt_norm *Y, int stereo, int N)
       for (i=0;i<N;i++)
       {
          celt_norm m, s;
-         m = X[i]+Y[i];
-         s = X[i]-Y[i];
+         m = ADD16(SHR16(X[i],1),SHR16(Y[i],1));
+         s = SUB16(SHR16(X[i],1),SHR16(Y[i],1));
          Emid = MAC16_16(Emid, m, m);
          Eside = MAC16_16(Eside, s, s);
       }