Changed compute_allocation_table() so it handles ebands that start and end in the same allocation band. Also fixed a minor C89 issue.
This commit is contained in:
parent
31bec963bb
commit
137f3366bc
2 changed files with 28 additions and 15 deletions
|
@ -200,25 +200,37 @@ static void compute_allocation_table(CELTMode *mode, int res)
|
||||||
int eband = 0;
|
int eband = 0;
|
||||||
for (j=0;j<nBark;j++)
|
for (j=0;j<nBark;j++)
|
||||||
{
|
{
|
||||||
int edge, low;
|
int edge, low, high;
|
||||||
celt_int32 alloc;
|
celt_int32 alloc;
|
||||||
edge = mode->eBands[eband+1]*res;
|
|
||||||
alloc = mode->mdctSize*band_allocation[i*BARK_BANDS+j];
|
alloc = mode->mdctSize*band_allocation[i*BARK_BANDS+j];
|
||||||
if (edge < bark_freq[j+1])
|
low = bark_freq[j];
|
||||||
|
high = bark_freq[j+1];
|
||||||
|
|
||||||
|
edge = mode->eBands[eband+1]*res;
|
||||||
|
while (edge <= high)
|
||||||
{
|
{
|
||||||
int num, den;
|
celt_int32 num;
|
||||||
num = alloc * (edge-bark_freq[j]);
|
int den, bits;
|
||||||
den = bark_freq[j+1]-bark_freq[j];
|
num = alloc * (edge-low);
|
||||||
low = (num+den/2)/den;
|
den = high-low;
|
||||||
allocVectors[i*mode->nbEBands+eband] = (current+low+128)/256;
|
/* Divide with rounding */
|
||||||
current=0;
|
bits = (2*num+den)/(2*den);
|
||||||
|
allocVectors[i*mode->nbEBands+eband] = (current+bits+128)>>8;
|
||||||
|
|
||||||
|
/* Remove the part of the band we just allocated */
|
||||||
|
low = edge;
|
||||||
|
alloc -= bits;
|
||||||
|
|
||||||
|
/* Move to next eband */
|
||||||
|
current = 0;
|
||||||
eband++;
|
eband++;
|
||||||
current += alloc-low;
|
edge = mode->eBands[eband+1]*res;
|
||||||
} else {
|
}
|
||||||
current += alloc;
|
current += alloc;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
allocVectors[i*mode->nbEBands+eband] = (current+128)/256;
|
if (eband < mode->nbEBands)
|
||||||
|
allocVectors[i*mode->nbEBands+eband] = (current+128)>>8;
|
||||||
}
|
}
|
||||||
mode->allocVectors = allocVectors;
|
mode->allocVectors = allocVectors;
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,6 +360,7 @@ celt_word16 renormalise_vector(celt_norm *X, celt_word16 value, int N, int strid
|
||||||
int i;
|
int i;
|
||||||
celt_word32 E = EPSILON;
|
celt_word32 E = EPSILON;
|
||||||
celt_word16 g;
|
celt_word16 g;
|
||||||
|
celt_word32 t;
|
||||||
celt_norm *xptr = X;
|
celt_norm *xptr = X;
|
||||||
for (i=0;i<N;i++)
|
for (i=0;i<N;i++)
|
||||||
{
|
{
|
||||||
|
@ -369,7 +370,7 @@ celt_word16 renormalise_vector(celt_norm *X, celt_word16 value, int N, int strid
|
||||||
#ifdef FIXED_POINT
|
#ifdef FIXED_POINT
|
||||||
int k = celt_ilog2(E)>>1;
|
int k = celt_ilog2(E)>>1;
|
||||||
#endif
|
#endif
|
||||||
celt_word32 t = VSHR32(E, (k-7)<<1);
|
t = VSHR32(E, (k-7)<<1);
|
||||||
g = MULT16_16_Q15(value, celt_rsqrt_norm(t));
|
g = MULT16_16_Q15(value, celt_rsqrt_norm(t));
|
||||||
|
|
||||||
xptr = X;
|
xptr = X;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue