shithub: opus

Download patch

ref: 52dc66b88777f5617e6ecf5838e81c48348aaa84
parent: 79b34eb83e53268a520affed056a46030999d270
author: Jean-Marc Valin <[email protected]>
date: Mon Dec 6 16:31:15 EST 2010

Take into accound the 32-bit limit in the VQ

This reduces waste at high bit-rate

--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -166,6 +166,9 @@
       for (j=start;j<end;j++)
       {
          int tmp = bits1[j] + (mid*bits2[j]>>ALLOC_STEPS);
+         /* Don't allocate more than we can actually use */
+         if (tmp > 64*C<<BITRES<<LM)
+            tmp = 64*C<<BITRES<<LM;
          if (tmp >= thresh[j])
             psum += tmp;
          else if (tmp >= 1<<BITRES)
@@ -189,6 +192,9 @@
          bits[j] = 1<<BITRES;
       else
          bits[j] = 0;
+      /* Don't allocate more than we can actually use */
+      if (bits[j] > 64*C<<BITRES<<LM)
+         bits[j] = 64*C<<BITRES<<LM;
       psum += bits[j];
    }
    codedBands++;