shithub: opus

Download patch

ref: 6ec2ca56cf92418734e6b4029de2202eac73c2a9
parent: 3a56c9e1c67e4af4748484bfb35ed207f200748e
author: Jean-Marc Valin <[email protected]>
date: Sun Jan 23 13:22:14 EST 2011

Clipping the encoder input to +/-2 to prevent scaling errors

If someone messed up scaling, they'll know because it'll sound bad

--- a/libcelt/arch.h
+++ b/libcelt/arch.h
@@ -225,7 +225,7 @@
 #define DIV32(a,b)     (((celt_word32)(a))/(celt_word32)(b))
 #define PDIV32(a,b)     (((celt_word32)(a))/(celt_word32)(b))
 
-#define SCALEIN(a)	((a)*CELT_SIG_SCALE)
+#define SCALEIN(a)	(MAX16(-2, MIN16(2,a))*CELT_SIG_SCALE)
 #define SCALEOUT(a)	((a)*(1/CELT_SIG_SCALE))
 
 #endif /* !FIXED_POINT */