Allocation table now in bits/sample
This commit is contained in:
parent
6c37fb150c
commit
bb8fa1fca2
2 changed files with 20 additions and 5 deletions
|
@ -206,8 +206,9 @@ static void compute_allocation_table(CELTMode *mode, int res)
|
||||||
{
|
{
|
||||||
int edge, low, high;
|
int edge, low, high;
|
||||||
celt_int32 alloc;
|
celt_int32 alloc;
|
||||||
|
/* This compensates for the sampling rate. The 46000 here reflects the fact that we
|
||||||
alloc = mode->shortMdctSize*band_allocation[i*BARK_BANDS+j];
|
originally tuned using both 44.1 and 48 kHz. */
|
||||||
|
alloc = ((celt_int32)46000*mode->shortMdctSize/mode->Fs)*band_allocation[i*BARK_BANDS+j];
|
||||||
low = bark_freq[j];
|
low = bark_freq[j];
|
||||||
high = bark_freq[j+1];
|
high = bark_freq[j+1];
|
||||||
|
|
||||||
|
@ -216,6 +217,7 @@ static void compute_allocation_table(CELTMode *mode, int res)
|
||||||
{
|
{
|
||||||
celt_int32 num;
|
celt_int32 num;
|
||||||
int den, bits;
|
int den, bits;
|
||||||
|
int N = (mode->eBands[eband+1]-mode->eBands[eband]);
|
||||||
num = alloc * (edge-low);
|
num = alloc * (edge-low);
|
||||||
den = high-low;
|
den = high-low;
|
||||||
/* Divide with rounding */
|
/* Divide with rounding */
|
||||||
|
@ -225,6 +227,7 @@ static void compute_allocation_table(CELTMode *mode, int res)
|
||||||
allocVectors[i*mode->nbEBands+eband] -= 1<<BITRES;
|
allocVectors[i*mode->nbEBands+eband] -= 1<<BITRES;
|
||||||
if (allocVectors[i*mode->nbEBands+eband]<0)
|
if (allocVectors[i*mode->nbEBands+eband]<0)
|
||||||
allocVectors[i*mode->nbEBands+eband]=0;
|
allocVectors[i*mode->nbEBands+eband]=0;
|
||||||
|
allocVectors[i*mode->nbEBands+eband] = (2*allocVectors[i*mode->nbEBands+eband]+N)/(2*N);
|
||||||
/* Remove the part of the band we just allocated */
|
/* Remove the part of the band we just allocated */
|
||||||
low = edge;
|
low = edge;
|
||||||
alloc -= bits;
|
alloc -= bits;
|
||||||
|
@ -238,13 +241,23 @@ static void compute_allocation_table(CELTMode *mode, int res)
|
||||||
}
|
}
|
||||||
if (eband < mode->nbEBands)
|
if (eband < mode->nbEBands)
|
||||||
{
|
{
|
||||||
|
int N = (mode->eBands[eband+1]-mode->eBands[eband]);
|
||||||
allocVectors[i*mode->nbEBands+eband] = (current+128)>>(8-BITRES);
|
allocVectors[i*mode->nbEBands+eband] = (current+128)>>(8-BITRES);
|
||||||
/* Same hack as above FIXME: again */
|
/* Same hack as above FIXME: again */
|
||||||
allocVectors[i*mode->nbEBands+eband] -= 1<<BITRES;
|
allocVectors[i*mode->nbEBands+eband] -= 1<<BITRES;
|
||||||
if (allocVectors[i*mode->nbEBands+eband]<0)
|
if (allocVectors[i*mode->nbEBands+eband]<0)
|
||||||
allocVectors[i*mode->nbEBands+eband]=0;
|
allocVectors[i*mode->nbEBands+eband]=0;
|
||||||
|
allocVectors[i*mode->nbEBands+eband] = (2*allocVectors[i*mode->nbEBands+eband]+N)/(2*N);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*for (i=0;i<BITALLOC_SIZE;i++)
|
||||||
|
{
|
||||||
|
for (j=0;j<mode->nbEBands;j++)
|
||||||
|
printf ("%d ", allocVectors[i*mode->nbEBands+j]);
|
||||||
|
printf ("\n");
|
||||||
|
}
|
||||||
|
exit(0);*/
|
||||||
|
|
||||||
mode->allocVectors = allocVectors;
|
mode->allocVectors = allocVectors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,8 @@ void compute_allocation(const CELTMode *m, int start, int *offsets, int total, i
|
||||||
int mid = (lo+hi) >> 1;
|
int mid = (lo+hi) >> 1;
|
||||||
for (j=start;j<len;j++)
|
for (j=start;j<len;j++)
|
||||||
{
|
{
|
||||||
bits1[j] = (C*M*m->allocVectors[mid*len+j] + offsets[j]);
|
int N = m->eBands[j+1]-m->eBands[j];
|
||||||
|
bits1[j] = (C*M*N*m->allocVectors[mid*len+j] + offsets[j]);
|
||||||
if (bits1[j] < 0)
|
if (bits1[j] < 0)
|
||||||
bits1[j] = 0;
|
bits1[j] = 0;
|
||||||
psum += bits1[j];
|
psum += bits1[j];
|
||||||
|
@ -223,8 +224,9 @@ void compute_allocation(const CELTMode *m, int start, int *offsets, int total, i
|
||||||
/*printf ("interp between %d and %d\n", lo, hi);*/
|
/*printf ("interp between %d and %d\n", lo, hi);*/
|
||||||
for (j=start;j<len;j++)
|
for (j=start;j<len;j++)
|
||||||
{
|
{
|
||||||
bits1[j] = C*M*m->allocVectors[lo*len+j] + offsets[j];
|
int N = m->eBands[j+1]-m->eBands[j];
|
||||||
bits2[j] = C*M*m->allocVectors[hi*len+j] + offsets[j];
|
bits1[j] = C*M*N*m->allocVectors[lo*len+j] + offsets[j];
|
||||||
|
bits2[j] = C*M*N*m->allocVectors[hi*len+j] + offsets[j];
|
||||||
if (bits1[j] < 0)
|
if (bits1[j] < 0)
|
||||||
bits1[j] = 0;
|
bits1[j] = 0;
|
||||||
if (bits2[j] < 0)
|
if (bits2[j] < 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue