From 6a9780228032bcc7c7b701df6d156e194c05b099 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Tue, 13 Oct 2009 20:35:21 -0400 Subject: [PATCH] Adjusting the allocation for stereo directly in the alloc function rather than in the table. --- libcelt/modes.c | 4 +--- libcelt/rate.c | 7 ++++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libcelt/modes.c b/libcelt/modes.c index 032aafa4..056d67aa 100644 --- a/libcelt/modes.c +++ b/libcelt/modes.c @@ -184,7 +184,6 @@ static void compute_allocation_table(CELTMode *mode, int res) { 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;nBarkeBands[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; diff --git a/libcelt/rate.c b/libcelt/rate.c index a275843e..0b49a5a6 100644 --- a/libcelt/rate.c +++ b/libcelt/rate.c @@ -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) { int lo, hi, len, j; + const int C = CHANNELS(m); VARDECL(int, bits1); VARDECL(int, bits2); SAVE_STACK; @@ -191,7 +192,7 @@ void compute_allocation(const CELTMode *m, int *offsets, int total, int *pulses, int mid = (lo+hi) >> 1; for (j=0;jallocVectors[mid*len+j] + offsets[j])<allocVectors[mid*len+j] + offsets[j])<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)