Commit ec71aee7 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

A bit of tuning and early work on bit allocation

parent 3eff11d8
......@@ -227,6 +227,28 @@ void pitch_quant_bands(const CELTMode *m, float *X, float *P, float *gains)
P[i] = 0;
}
static int compute_allocation(const CELTMode *m, int *pulses)
{
int i, N, BC, bits;
const int *eBands = m->eBands;
BC = m->nbMdctBlocks*m->nbChannels;
bits = 0;
for (i=0;i<m->nbEBands;i++)
{
int q;
N = BC*(eBands[i+1]-eBands[i]);
q = pulses[i];
if (q<=0)
{
bits += ec_ilog64(eBands[i] - (eBands[i+1]-eBands[i])) + 1;
q = -q;
}
if (q != 0)
bits += ec_ilog64(ncwrs64(N, pulses[i])) + 1;
}
return bits;
}
/* Quantisation of the residual */
void quant_bands(const CELTMode *m, float *X, float *P, float *W, ec_enc *enc)
{
......@@ -235,6 +257,7 @@ void quant_bands(const CELTMode *m, float *X, float *P, float *W, ec_enc *enc)
B = m->nbMdctBlocks*m->nbChannels;
float norm[B*eBands[m->nbEBands+1]];
/*printf ("%d %d\n", ec_enc_tell(enc, 0), compute_allocation(m, m->nbPulses));*/
for (i=0;i<m->nbEBands;i++)
{
int q;
......@@ -326,4 +349,4 @@ void stereo_mix(const CELTMode *m, float *X, float *bank, int dir)
for (i=B*C*eBands[m->nbEBands];i<B*C*eBands[m->nbEBands+1];i++)
X[i] = 0;
}
\ No newline at end of file
}
......@@ -60,7 +60,7 @@ static const int decay18[18] = {
const int qbank0[NBANDS +2] = {0, 4, 8, 12, 16, 20, 24, 28, 32, 38, 44, 52, 62, 74, 90,112,142,182, 232,256};
const int pbank0[PBANDS +2] = {0, 4, 8, 12, 16, 24, 38, 62, PITCH_END, 256};
//const int pbank0[PBANDS +2] = {0, 4, 8, 12, 19, PITCH_END, 128};
const int qpulses0[NBANDS ] = {7, 6, 5, 5, 4, 3, 3, 3, 3, 3, 3, 2, 2, 1, 0, 0, 0, 0};
const int qpulses0[NBANDS ] = {7, 6, 6, 5, 5, 5, 5, 4, 3, 3, 3, 3, 3, 3, -3, -2, 0, 0};
//const int qpulses0[NBANDS ] = {7, 5, 5, 5, 4, 4, 3, 3, 3, 3, 4, 3, 3, -2, 0, 0, 0, 0};
......
......@@ -52,8 +52,9 @@ int main(int argc, char *argv[])
outFile = argv[2];
fout = fopen(outFile, "wb+");
enc = celt_encoder_new(celt_mode1);
dec = celt_decoder_new(celt_mode1);
/* Use mode4 for stereo and don't forget to change the value of CHANNEL above */
enc = celt_encoder_new(celt_mode0);
dec = celt_decoder_new(celt_mode0);
while (!feof(fin))
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment