Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/celt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jean-marc.valin@usherbrooke.ca>2008-01-12 15:38:01 +0300
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>2008-01-12 15:38:01 +0300
commitec71aee7727bfd58641a1804213f02b61bfe84b1 (patch)
tree3c220c25033ebd241a2de5bc1a231d472d8cba6e /libcelt/bands.c
parent3eff11d8d478772be7f888751c976aab8c2499fb (diff)
A bit of tuning and early work on bit allocation
Diffstat (limited to 'libcelt/bands.c')
-rw-r--r--libcelt/bands.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/libcelt/bands.c b/libcelt/bands.c
index bf747b9..925968f 100644
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -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
+}