Clipping the encoder input to +/-2 to prevent scaling errors
authorJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Sun, 23 Jan 2011 23:22:14 +0000 (18:22 -0500)
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Sun, 23 Jan 2011 23:22:14 +0000 (18:22 -0500)
If someone messed up scaling, they'll know because it'll sound bad

libcelt/arch.h

index e4f2739..f389166 100644 (file)
@@ -225,7 +225,7 @@ typedef float celt_mask;
 #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 */