ref: 4fb956870990f7e121e54cec531382cdcb836346
parent: d6b79eeb7a22813756a91457fc8deb0d4b68b26f
author: Jean-Marc Valin <[email protected]>
date: Tue Apr 20 19:30:22 EDT 2010
Bands are now (again) a multiple of the number of short MDCTs
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -119,12 +119,12 @@
static celt_int16 *compute_ebands(celt_int32 Fs, int frame_size, int nbShortMdcts, int *nbEBands)
{
- int min_bins = 3;
+ int min_bins = 2;
celt_int16 *eBands;
int i, res, min_width, lin, low, high, nBark, offset=0;
- /*if (min_bins < nbShortMdcts)
- min_bins = nbShortMdcts;*/
+ if (min_bins < nbShortMdcts)
+ min_bins = nbShortMdcts;
res = (Fs+frame_size)/(2*frame_size);
min_width = min_bins*res;
@@ -137,8 +137,8 @@
for (lin=0;lin<nBark;lin++)
if (bark_freq[lin+1]-bark_freq[lin] >= min_width)
break;
-
- low = ((bark_freq[lin]/res)+(min_bins-1))/min_bins;
+
+ low = (bark_freq[lin]+res*min_bins/2)/(res*min_bins);
high = nBark-lin;
*nbEBands = low+high;
eBands = celt_alloc(sizeof(celt_int16)*(*nbEBands+2));
@@ -153,7 +153,7 @@
for (i=0;i<high;i++)
{
int target = bark_freq[lin+i];
- eBands[i+low] = (2*target+offset+res)/(2*res);
+ eBands[i+low] = (target+(offset+res*nbShortMdcts)/2)/(res*nbShortMdcts)*nbShortMdcts;
offset = eBands[i+low]*res - target;
}
/* Enforce the minimum spacing at the boundary */
@@ -160,7 +160,7 @@
for (i=0;i<*nbEBands;i++)
if (eBands[i] < min_bins*i)
eBands[i] = min_bins*i;
- eBands[*nbEBands] = (bark_freq[nBark]+res/2)/res;
+ eBands[*nbEBands] = (bark_freq[nBark]+res*nbShortMdcts/2)/(res*nbShortMdcts)*nbShortMdcts;
eBands[*nbEBands+1] = frame_size;
if (eBands[*nbEBands] > eBands[*nbEBands+1])
eBands[*nbEBands] = eBands[*nbEBands+1];
@@ -168,7 +168,7 @@
{
if (eBands[i+1]-eBands[i] < eBands[i]-eBands[i-1])
{
- eBands[i] -= (2*eBands[i]-eBands[i-1]-eBands[i+1]+1)/2;
+ eBands[i] -= (2*eBands[i]-eBands[i-1]-eBands[i+1]+nbShortMdcts)/(2*nbShortMdcts)*nbShortMdcts;
}
}
/*for (i=0;i<*nbEBands+1;i++)