ref: 39f68ac99735ddf504f50ea64bd8872e324c947e
parent: e12017ee2c47772962398601e6ec68d34efbe433
author: Jean-Marc Valin <[email protected]>
date: Sat Oct 3 19:27:52 EDT 2009
making compute_ebands() a tiny bit less stupid.
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -122,7 +122,7 @@
{
int min_bins = 3;
celt_int16_t *eBands;
- int i, res, min_width, lin, low, high, nBark;
+ int i, res, min_width, lin, low, high, nBark, offset=0;
/*if (min_bins < nbShortMdcts)
min_bins = nbShortMdcts;*/
@@ -152,7 +152,11 @@
eBands[i] = min_bins*i;
/* Spacing follows critical bands */
for (i=0;i<high;i++)
- eBands[i+low] = (bark_freq[lin+i]+res/2)/res;
+ {
+ int target = bark_freq[lin+i];
+ eBands[i+low] = (2*target+offset+res)/(2*res);
+ offset = eBands[i+low]*res - target;
+ }
/* Enforce the minimum spacing at the boundary */
for (i=0;i<*nbEBands;i++)
if (eBands[i] < min_bins*i)
@@ -165,12 +169,13 @@
{
if (eBands[i+1]-eBands[i] < eBands[i]-eBands[i-1])
{
- eBands[i] -= min_bins;
+ eBands[i] -= (2*eBands[i]-eBands[i-1]-eBands[i+1]+1)/2;
}
}
/*for (i=0;i<*nbEBands+1;i++)
printf ("%d ", eBands[i]);
- printf ("\n");*/
+ printf ("\n");
+ exit(1);*/
/* FIXME: Remove last band if too small */
return eBands;
}