Adjusting the allocation for stereo directly in the alloc function rather than

in the table.
This commit is contained in:
Jean-Marc Valin 2009-10-13 20:35:21 -04:00
parent a9947c480c
commit 6a97802280
2 changed files with 5 additions and 6 deletions

View file

@ -184,7 +184,6 @@ static void compute_allocation_table(CELTMode *mode, int res)
{ {
int i, j, nBark; int i, j, nBark;
celt_int16_t *allocVectors; celt_int16_t *allocVectors;
const int C = CHANNELS(mode);
/* Find the number of critical bands supported by our sampling rate */ /* Find the number of critical bands supported by our sampling rate */
for (nBark=1;nBark<BARK_BANDS;nBark++) for (nBark=1;nBark<BARK_BANDS;nBark++)
@ -205,8 +204,7 @@ static void compute_allocation_table(CELTMode *mode, int res)
int edge, low; int edge, low;
celt_int32_t alloc; celt_int32_t alloc;
edge = mode->eBands[eband+1]*res; edge = mode->eBands[eband+1]*res;
alloc = band_allocation[i*BARK_BANDS+j]; alloc = mode->mdctSize*band_allocation[i*BARK_BANDS+j];
alloc = alloc*C*mode->mdctSize;
if (edge < bark_freq[j+1]) if (edge < bark_freq[j+1])
{ {
int num, den; int num, den;

View file

@ -175,6 +175,7 @@ static void interp_bits2pulses(const CELTMode *m, int *bits1, int *bits2, int to
void compute_allocation(const CELTMode *m, int *offsets, int total, int *pulses, int *ebits, int *fine_priority) void compute_allocation(const CELTMode *m, int *offsets, int total, int *pulses, int *ebits, int *fine_priority)
{ {
int lo, hi, len, j; int lo, hi, len, j;
const int C = CHANNELS(m);
VARDECL(int, bits1); VARDECL(int, bits1);
VARDECL(int, bits2); VARDECL(int, bits2);
SAVE_STACK; SAVE_STACK;
@ -191,7 +192,7 @@ void compute_allocation(const CELTMode *m, int *offsets, int total, int *pulses,
int mid = (lo+hi) >> 1; int mid = (lo+hi) >> 1;
for (j=0;j<len;j++) for (j=0;j<len;j++)
{ {
bits1[j] = (m->allocVectors[mid*len+j] + offsets[j])<<BITRES; bits1[j] = (C*m->allocVectors[mid*len+j] + offsets[j])<<BITRES;
if (bits1[j] < 0) if (bits1[j] < 0)
bits1[j] = 0; bits1[j] = 0;
psum += bits1[j]; psum += bits1[j];
@ -207,8 +208,8 @@ void compute_allocation(const CELTMode *m, int *offsets, int total, int *pulses,
/*printf ("interp between %d and %d\n", lo, hi);*/ /*printf ("interp between %d and %d\n", lo, hi);*/
for (j=0;j<len;j++) for (j=0;j<len;j++)
{ {
bits1[j] = m->allocVectors[lo*len+j] + offsets[j]; bits1[j] = C*m->allocVectors[lo*len+j] + offsets[j];
bits2[j] = m->allocVectors[hi*len+j] + offsets[j]; bits2[j] = C*m->allocVectors[hi*len+j] + offsets[j];
if (bits1[j] < 0) if (bits1[j] < 0)
bits1[j] = 0; bits1[j] = 0;
if (bits2[j] < 0) if (bits2[j] < 0)