From 9eba823cf7b8ac52bfde83946436c2f862a7599a Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Sat, 2 Aug 2008 20:51:44 -0400 Subject: [PATCH] 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 --- libcelt/cwrs.c | 4 ++-- libcelt/modes.c | 5 +++-- libcelt/quant_bands.c | 42 ------------------------------------------ 3 files changed, 5 insertions(+), 46 deletions(-) diff --git a/libcelt/cwrs.c b/libcelt/cwrs.c index 0d8383b0..1e9c19e6 100644 --- a/libcelt/cwrs.c +++ b/libcelt/cwrs.c @@ -429,8 +429,8 @@ int get_required_bits(int N, int K, int frac) 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; } diff --git a/libcelt/modes.c b/libcelt/modes.c index f791fc76..86543936 100644 --- a/libcelt/modes.c +++ b/libcelt/modes.c @@ -104,7 +104,7 @@ static const celt_int16_t pitch_freq[PBANDS+1] ={0, 345, 689, 1034, 1378, 2067, 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 @@ static const int band_allocation[BARK_BANDS*BITALLOC_SIZE] = 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) diff --git a/libcelt/quant_bands.c b/libcelt/quant_bands.c index cdfb07e9..bcc35b47 100644 --- a/libcelt/quant_bands.c +++ b/libcelt/quant_bands.c @@ -47,48 +47,6 @@ const celt_word16_t eMeans[24] = {11520, -2048, -3072, -640, 256, 0, 0, 0, 0, 0, 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;inbAllocVectors;i++) - { - if (m->energy_alloc[i*(len+1)+len] > budget) - break; - } - if (i==0) - { - for (j=0;jenergy_alloc[(i-1)*(len+1)+j]; - budget -= m->energy_alloc[(i-1)*(len+1)+len]; - } - if (inbAllocVectors) - { - 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