ref: 6a9780228032bcc7c7b701df6d156e194c05b099
parent: a9947c480c80c53366a9ac441bdd5d47c36ca14e
author: Jean-Marc Valin <[email protected]>
date: Tue Oct 13 16:35:21 EDT 2009
Adjusting the allocation for stereo directly in the alloc function rather than in the table.
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -184,7 +184,6 @@
{
int i, j, nBark;
celt_int16_t *allocVectors;
- const int C = CHANNELS(mode);
/* Find the number of critical bands supported by our sampling rate */
for (nBark=1;nBark<BARK_BANDS;nBark++)
@@ -205,8 +204,7 @@
int edge, low;
celt_int32_t alloc;
edge = mode->eBands[eband+1]*res;
- alloc = band_allocation[i*BARK_BANDS+j];
- alloc = alloc*C*mode->mdctSize;
+ alloc = mode->mdctSize*band_allocation[i*BARK_BANDS+j];
if (edge < bark_freq[j+1])
{
int num, den;
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -175,6 +175,7 @@
void compute_allocation(const CELTMode *m, int *offsets, int total, int *pulses, int *ebits, int *fine_priority)
{
int lo, hi, len, j;
+ const int C = CHANNELS(m);
VARDECL(int, bits1);
VARDECL(int, bits2);
SAVE_STACK;
@@ -191,7 +192,7 @@
int mid = (lo+hi) >> 1;
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)
bits1[j] = 0;
psum += bits1[j];
@@ -207,8 +208,8 @@
/*printf ("interp between %d and %d\n", lo, hi);*/
for (j=0;j<len;j++)
{
- bits1[j] = m->allocVectors[lo*len+j] + offsets[j];
- bits2[j] = m->allocVectors[hi*len+j] + offsets[j];
+ bits1[j] = C*m->allocVectors[lo*len+j] + offsets[j];
+ bits2[j] = C*m->allocVectors[hi*len+j] + offsets[j];
if (bits1[j] < 0)
bits1[j] = 0;
if (bits2[j] < 0)