ref: ec71aee7727bfd58641a1804213f02b61bfe84b1
parent: 3eff11d8d478772be7f888751c976aab8c2499fb
author: Jean-Marc Valin <[email protected]>
date: Sat Jan 12 18:38:01 EST 2008
A bit of tuning and early work on bit allocation
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -227,6 +227,28 @@
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 @@
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 @@
for (i=B*C*eBands[m->nbEBands];i<B*C*eBands[m->nbEBands+1];i++)
X[i] = 0;
-}
\ No newline at end of file
+}
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -60,7 +60,7 @@
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};
--- a/libcelt/testcelt.c
+++ b/libcelt/testcelt.c
@@ -52,8 +52,9 @@
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))
{