shithub: opus

Download patch

ref: 9eba823cf7b8ac52bfde83946436c2f862a7599a
parent: eb7ce0316590cb752056b556724b0f96f7ea5f2a
author: Jean-Marc Valin <[email protected]>
date: Sat Aug 2 16:51:44 EDT 2008

Turns out that the worse case of the vector split is the same as that of the
pulse split. Also, added an allocation line for even higher bit-rates

--- a/libcelt/cwrs.c
+++ b/libcelt/cwrs.c
@@ -429,8 +429,8 @@
       RESTORE_STACK;
    } else {
       nbits = log2_frac64(N, frac);
-      nbits += get_required_bits((N+1)/2, (K+1)/2, frac);
-      nbits += get_required_bits((N+1)/2, K/2, frac);
+      nbits += get_required_bits(N/2+1, (K+1)/2, frac);
+      nbits += get_required_bits(N/2+1, K/2, frac);
    }
    return nbits;
 }
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -104,7 +104,7 @@
 int BITALLOC_SIZE;
 int *band_allocation;
 #else
-#define BITALLOC_SIZE 10
+#define BITALLOC_SIZE 11
 static const int band_allocation[BARK_BANDS*BITALLOC_SIZE] = 
    {  2,  2,  1,  1,  2,  2,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
       2,  2,  2,  1,  2,  2,  2,  2,  2,  1,  2,  2,  4,  5,  7,  7,  7,  5,  4,  0,  0,  0,  0,  0,  0,
@@ -116,7 +116,8 @@
       6,  6,  6,  6,  6,  6,  7,  7,  9,  9, 11, 12, 13, 18, 22, 23, 24, 25, 28, 30, 35, 35, 35, 35, 15,
       7,  7,  7,  7,  7,  7, 10, 10, 10, 13, 14, 18, 20, 24, 28, 32, 32, 35, 38, 38, 42, 50, 59, 54, 31,
       8,  8,  8,  8,  8,  9, 10, 12, 14, 20, 22, 25, 28, 30, 35, 42, 46, 50, 55, 60, 62, 62, 62, 62, 62,
-};
+     12, 12, 12, 12, 12, 13, 15, 18, 22, 30, 32, 35, 40, 45, 55, 62, 66, 70, 85, 90, 92, 92, 92, 92, 92,
+   };
 #endif
 
 static celt_int16_t *compute_ebands(celt_int32_t Fs, int frame_size, int *nbEBands)
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -47,48 +47,6 @@
 const celt_word16_t eMeans[24] = {45.f, -8.f, -12.f, -2.5f, 1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
 #endif
 
-/*const int frac[24] = {4, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};*/
-/*const int frac[24] = {8, 6, 5, 4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};*/
-
-void compute_fine_allocation(const CELTMode *m, int *bits, int budget)
-{
-   int i,j;
-   int len;
-   len = m->nbEBands;
-   for (i=0;i<m->nbAllocVectors;i++)
-   {
-      if (m->energy_alloc[i*(len+1)+len] > budget)
-         break;
-   }
-   if (i==0)
-   {
-      for (j=0;j<len;j++)
-         bits[j] = 0;
-   } else {
-      for (j=0;j<len;j++)
-         bits[j] = m->energy_alloc[(i-1)*(len+1)+j];
-      budget -= m->energy_alloc[(i-1)*(len+1)+len];
-   }
-   if (i<m->nbAllocVectors)
-   {
-      j=0;
-      while (budget>0)
-      {
-         if (m->energy_alloc[i*(len+1)+j]>bits[j])
-         {
-            bits[j]++;
-            budget--;
-         }
-         j++;
-         if (j>=len)
-            j=0;
-      }
-   }
-   
-   /*for (j=0;j<len;j++)
-      printf ("%d ", bits[j]);
-   printf ("\n");*/
-}
 
 #ifdef FIXED_POINT
 static inline celt_ener_t dB2Amp(celt_ener_t dB)