Better allocation rounding as suggested by derf
This commit is contained in:
parent
520eeaee1a
commit
fda0e10f01
2 changed files with 10 additions and 5 deletions
|
@ -248,11 +248,11 @@ static void compute_allocation_table(CELTMode *mode, int res)
|
||||||
for (j=0;j<mode->nbEBands;j++)
|
for (j=0;j<mode->nbEBands;j++)
|
||||||
allocVectors[i*mode->nbEBands+j] = (allocVectors[i*mode->nbEBands+j]+128)/256;
|
allocVectors[i*mode->nbEBands+j] = (allocVectors[i*mode->nbEBands+j]+128)/256;
|
||||||
}
|
}
|
||||||
for (i=0;i<mode->nbAllocVectors;i++)
|
/*for (i=0;i<mode->nbAllocVectors;i++)
|
||||||
{
|
{
|
||||||
for (j=0;j<mode->nbEBands;j++)
|
for (j=0;j<mode->nbEBands;j++)
|
||||||
allocVectors[i*mode->nbEBands+j] += C;
|
allocVectors[i*mode->nbEBands+j] += C;
|
||||||
}
|
}*/
|
||||||
mode->energy_alloc = allocEnergy;
|
mode->energy_alloc = allocEnergy;
|
||||||
mode->allocVectors = allocVectors;
|
mode->allocVectors = allocVectors;
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,13 +113,18 @@ static void interp_bits2pulses(const CELTMode *m, int *bits1, int *bits2, int to
|
||||||
}
|
}
|
||||||
for (j=0;j<len;j++)
|
for (j=0;j<len;j++)
|
||||||
{
|
{
|
||||||
|
int N, d;
|
||||||
int offset;
|
int offset;
|
||||||
int min_bits=0;
|
int min_bits=0;
|
||||||
if (bits[j] >= C>>BITRES)
|
if (bits[j] >= C<<BITRES)
|
||||||
min_bits = 1;
|
min_bits = 1;
|
||||||
|
|
||||||
|
N=m->eBands[j+1]-m->eBands[j];
|
||||||
|
d=C*N<<BITRES;
|
||||||
|
offset = 50 - log2_frac(N, 4);
|
||||||
/* Offset for the number of fine bits compared to their "fair share" of total/N */
|
/* Offset for the number of fine bits compared to their "fair share" of total/N */
|
||||||
offset = 45 - log2_frac(m->eBands[j+1]-m->eBands[j], 4);
|
ebits[j] = IMAX(min_bits, (bits[j]-offset*N*C+(d>>1))/d);
|
||||||
ebits[j] = IMAX(min_bits , ((bits[j]+C*(m->eBands[j+1]-m->eBands[j])/2) / (C*(m->eBands[j+1]-m->eBands[j])) - offset)>>BITRES );
|
|
||||||
/* Make sure not to bust */
|
/* Make sure not to bust */
|
||||||
if (C*ebits[j] > (bits[j]>>BITRES))
|
if (C*ebits[j] > (bits[j]>>BITRES))
|
||||||
ebits[j] = bits[j]/C >> BITRES;
|
ebits[j] = bits[j]/C >> BITRES;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue