ref: 14d63d18795a2081adb8a3f9c714e94d021a666b
parent: 7143b2d0ff61690b698cc8a8b0e61852ba74d984
author: Jean-Marc Valin <[email protected]>
date: Wed May 16 13:47:17 EDT 2012
Fixes the stereo_analysis() fixed-point overflow issue properly
--- a/celt/celt.c
+++ b/celt/celt.c
@@ -860,14 +860,14 @@
int j;
for (j=m->eBands[i]<<LM;j<m->eBands[i+1]<<LM;j++)
{
- opus_val16 L, R, M, S;
- L = X[j];
- R = X[N0+j];
- M = L+R;
- S = L-R;
+ opus_val32 L, R, M, S;
/* We cast to 32-bit first because of the -32768 case */
- sumLR += ABS32(EXTEND32(L)) + ABS32(EXTEND32(R));
- sumMS += ABS32(EXTEND32(M)) + ABS32(EXTEND32(S));
+ L = EXTEND32(X[j]);
+ R = EXTEND32(X[N0+j]);
+ M = ADD32(L, R);
+ S = SUB32(L, R);
+ sumLR = ADD32(sumLR, ADD32(ABS32(L), ABS32(R)));
+ sumMS = ADD32(sumMS, ADD32(ABS32(M), ABS32(S)));
}
}
sumMS = MULT16_32_Q15(QCONST16(0.707107f, 15), sumMS);
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -69,7 +69,7 @@
#ifdef FIXED_POINT
static inline opus_int16 SAT16(opus_int32 x) {
return x > 32767 ? 32767 : x < -32768 ? -32768 : (opus_int16)x;
-};
+}
#endif