shithub: opus

Download patch

ref: 7fff572a8c24b49edf113b518ccb6a920bd54691
parent: d50b6287f2a8c6c3deb061ad083c8e854a15cd42
author: Jean-Marc Valin <[email protected]>
date: Mon Oct 18 12:20:00 EDT 2010

Making sure we can use up to 128 pulses.

Previous limit was effectively 120.

--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -81,6 +81,7 @@
    cindex = celt_alloc(sizeof(cache->index[0])*m->nbEBands*(LM+2));
    cache->index = cindex;
 
+   /* Scan for all unique band sizes */
    for (i=0;i<=LM+1;i++)
    {
       int j;
@@ -89,6 +90,7 @@
          int k;
          int N = (eBands[j+1]-eBands[j])<<i>>1;
          cindex[i*m->nbEBands+j] = -1;
+         /* Find other bands that have the same size */
          for (k=0;k<=i;k++)
          {
             int n;
@@ -106,7 +108,7 @@
             int K;
             entryN[nbEntries] = N;
             K = 0;
-            while (fits_in32(N,get_pulses(K+1)) && K<MAX_PSEUDO-1)
+            while (fits_in32(N,get_pulses(K+1)) && K<MAX_PSEUDO)
                K++;
             entryK[nbEntries] = K;
             cindex[i*m->nbEBands+j] = curr;
@@ -120,11 +122,12 @@
    bits = celt_alloc(sizeof(unsigned char)*curr);
    cache->bits = bits;
    cache->size = curr;
+   /* Compute the cache for all unique sizes */
    for (i=0;i<nbEntries;i++)
    {
       int j;
       unsigned char *ptr = bits+entryI[i];
-      celt_int16 tmp[MAX_PULSES];
+      celt_int16 tmp[MAX_PULSES+1];
       get_required_bits(tmp, entryN[i], get_pulses(entryK[i]), BITRES);
       for (j=1;j<=entryK[i];j++)
          ptr[j] = tmp[get_pulses(j)]-1;
--- a/libcelt/rate.h
+++ b/libcelt/rate.h
@@ -36,8 +36,7 @@
 #define MAX_PSEUDO 40
 #define LOG_MAX_PSEUDO 6
 
-#define MAX_PULSES 256
-#define LOG_MAX_PULSES 7
+#define MAX_PULSES 128
 
 #define BITRES 3
 #define FINE_OFFSET 21
@@ -67,7 +66,6 @@
 
    lo = 0;
    hi = cache[0];
-   //for (i=0;i<=hi;i++) printf ("%d ", cache[i]); printf ("\n");
    for (i=0;i<LOG_MAX_PSEUDO;i++)
    {
       int mid = (lo+hi)>>1;