Saturation in SIG2INT16 using MIN/MAX
authorJean-Marc Valin <Jean-Marc.Valin@csiro.au>
Fri, 18 Apr 2008 05:57:18 +0000 (15:57 +1000)
committerJean-Marc Valin <Jean-Marc.Valin@csiro.au>
Fri, 18 Apr 2008 05:57:18 +0000 (15:57 +1000)
libcelt/celt.c

index 34c3f27..94d975d 100644 (file)
@@ -141,10 +141,8 @@ void EXPORT celt_encoder_destroy(CELTEncoder *st)
 static inline celt_int16_t SIG2INT16(celt_sig_t x)
 {
    x = PSHR32(x, SIG_SHIFT);
-   if (x>32767)
-      x = 32767;
-   else if (x<-32767)
-      x = -32767;
+   x = MAX32(x, -32768);
+   x = MIN32(x, 32767);
 #ifdef FIXED_POINT
    return EXTRACT16(x);
 #else