Renamed some funciton that were likely to clash with other (non-Opus) code
[opus.git] / libcelt / bands.c
index 75c3224..835d726 100644 (file)
@@ -41,7 +41,7 @@
 #include "mathops.h"
 #include "rate.h"
 
-opus_uint32 lcg_rand(opus_uint32 seed)
+opus_uint32 celt_lcg_rand(opus_uint32 seed)
 {
    return 1664525 * seed + 1013904223;
 }
@@ -283,7 +283,7 @@ void anti_collapse(const CELTMode *m, celt_norm *_X, unsigned char *collapse_mas
                /* Fill with noise */
                for (j=0;j<N0;j++)
                {
-                  seed = lcg_rand(seed);
+                  seed = celt_lcg_rand(seed);
                   X[(j<<LM)+k] = (seed&0x8000 ? r : -r);
                }
                renormalize = 1;
@@ -758,7 +758,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c
          split = 1;
          LM -= 1;
          if (B==1)
-            fill = fill&1|fill<<1;
+            fill = (fill&1)|(fill<<1);
          B = (B+1)>>1;
       }
    }
@@ -1020,13 +1020,13 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c
                folding will be done to the side. */
             cm |= quant_band(encode, m, i, Y, NULL, N, sbits, spread, B, intensity, tf_change,
                   next_lowband2, ec, remaining_bits, LM, NULL,
-                  NULL, next_level, seed, MULT16_16_P15(gain,side), NULL, fill>>B)<<(B0>>1&stereo-1);
+                  NULL, next_level, seed, MULT16_16_P15(gain,side), NULL, fill>>B)<<((B0>>1)&(stereo-1));
          } else {
             /* For a stereo split, the high bits of fill are always zero, so no
                folding will be done to the side. */
             cm = quant_band(encode, m, i, Y, NULL, N, sbits, spread, B, intensity, tf_change,
                   next_lowband2, ec, remaining_bits, LM, NULL,
-                  NULL, next_level, seed, MULT16_16_P15(gain,side), NULL, fill>>B)<<(B0>>1&stereo-1);
+                  NULL, next_level, seed, MULT16_16_P15(gain,side), NULL, fill>>B)<<((B0>>1)&(stereo-1));
             rebalance = sbits - (rebalance-*remaining_bits);
             if (rebalance > 3<<BITRES && itheta!=16384)
                mbits += rebalance - (3<<BITRES);
@@ -1082,8 +1082,8 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c
                   /* Noise */
                   for (j=0;j<N;j++)
                   {
-                     *seed = lcg_rand(*seed);
-                     X[j] = (opus_int32)(*seed)>>20;
+                     *seed = celt_lcg_rand(*seed);
+                     X[j] = (celt_norm)((opus_int32)*seed>>20);
                   }
                   cm = cm_mask;
                } else {
@@ -1091,7 +1091,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c
                   for (j=0;j<N;j++)
                   {
                      opus_val16 tmp;
-                     *seed = lcg_rand(*seed);
+                     *seed = celt_lcg_rand(*seed);
                      /* About 48 dB below the "normal" folding level */
                      tmp = QCONST16(1.0f/256, 10);
                      tmp = (*seed)&0x8000 ? tmp : -tmp;