shithub: opus

Download patch

ref: d9127edb1f5100a3281beb6e60d8bb648a79b0a8
parent: 75f99bc51a9fd2afd899013c8712ba0f324f9a13
author: Jean-Marc Valin <[email protected]>
date: Mon Jan 10 05:34:20 EST 2011

32-bit fixes

--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -944,7 +944,8 @@
       int shortBlocks, int spread, int dual_stereo, int intensity, int *tf_res, int resynth,
       int total_bits, void *ec, int LM, int codedBands)
 {
-   int i, balance;
+   int i;
+   celt_int32 balance;
    celt_int32 remaining_bits;
    const celt_int16 * restrict eBands = m->eBands;
    celt_norm * restrict norm, * restrict norm2;
@@ -998,10 +999,10 @@
    lowband_offset = -1;
    for (i=start;i<end;i++)
    {
-      int tell;
+      celt_int32 tell;
       int b;
       int N;
-      int curr_balance;
+      celt_int32 curr_balance;
       int effective_lowband=-1;
       celt_norm * restrict X, * restrict Y;
       int tf_change=0;
@@ -1020,7 +1021,7 @@
       /* Compute how many bits we want to allocate to this band */
       if (i != start)
          balance -= tell;
-      remaining_bits = (total_bits<<BITRES)-tell-1;
+      remaining_bits = ((celt_int32)total_bits<<BITRES)-tell-1;
       if (i <= codedBands-1)
       {
          curr_balance = (codedBands-i);
@@ -1027,7 +1028,7 @@
          if (curr_balance > 3)
             curr_balance = 3;
          curr_balance = balance / curr_balance;
-         b = IMIN(remaining_bits+1,pulses[i]+curr_balance);
+         b = IMIN(16384, IMIN(remaining_bits+1,pulses[i]+curr_balance));
          if (b<0)
             b = 0;
       } else {