ref: 37546cc3f60fd52880663d26f3e1cc0915f19538
parent: a345decd971cb77263343168b8801c0812a42f88
author: Jean-Marc Valin <[email protected]>
date: Tue Jul 27 18:39:15 EDT 2010
Bit allocation Also convert the stereo split code to use log(N)/2 as the bit allocation offset
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -598,11 +598,11 @@
int qalloc;
celt_word16 mid, side;
int offset, N2;
- offset = m->logN[i]+(LM<<BITRES)-QTHETA_OFFSET;
+ offset = ((m->logN[i]+(LM<<BITRES))>>1)-QTHETA_OFFSET;
/* Decide on the resolution to give to the split parameter theta */
N2 = 2*N-1;
- if (stereo && N>2)
+ if (stereo && N==2)
N2--;
qb = (b+N2*offset)/(N2<<BITRES);
if (qb > (b>>(BITRES+1))-1)
@@ -627,7 +627,7 @@
mid = renormalise_vector(X, Q15ONE, N, 1);
side = renormalise_vector(Y, Q15ONE, N, 1);
- /* theta is the atan() of the ration between the (normalized)
+ /* theta is the atan() of the ratio between the (normalized)
side and mid. With just that parameter, we can re-scale both
mid and side because we know that 1) they have unit norm and
2) they are orthogonal. */
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -173,8 +173,8 @@
if (N==1)
ebits[j] = (bits[j]/C >> BITRES)-1;
- if (ebits[j] < 1)
- ebits[j] = 1;
+ if (ebits[j] < C)
+ ebits[j] = C;
/* Make sure not to bust */
if (C*ebits[j] > (bits[j]>>BITRES))
ebits[j] = bits[j]/C >> BITRES;
--- a/libcelt/rate.h
+++ b/libcelt/rate.h
@@ -41,7 +41,7 @@
#define BITRES 3
#define FINE_OFFSET 14
-#define QTHETA_OFFSET 18
+#define QTHETA_OFFSET (-2)
#define BITOVERFLOW 30000