ref: 36d78e6f74a85cda823083d6b07235d474bda527
parent: 4a897680e34dc59aebc0dfa8076e38338fbe48e9
author: Jean-Marc Valin <[email protected]>
date: Thu Dec 13 09:59:30 EST 2007
Band energy quantisation info now in the mode directly
--- a/libcelt/celt.h
+++ b/libcelt/celt.h
@@ -37,6 +37,7 @@
typedef struct CELTMode CELTMode;
+extern const CELTMode const *celt_mode0;
extern const CELTMode const *celt_mode1;
extern const CELTMode const *celt_mode2;
extern const CELTMode const *celt_mode3;
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -31,22 +31,70 @@
#include "modes.h"
+#define NBANDS 18
+#define PBANDS 5
+#define PITCH_END 37
+
#define NBANDS128 15
#define PBANDS128 5
#define PITCH_END128 36
-const int qbank1[NBANDS128+2] = {0, 2, 4, 6, 8, 12, 16, 20, 24, 28, 36, 44, 52, 68, 84, 116, 128};
+static const float means[15] = {
+ 14.8621, 12.6918, 10.2978, 9.5862, 10.3784,
+ 10.4555, 9.1594, 9.0280, 8.3291, 8.3410,
+ 8.5737, 8.5614, 9.0107, 7.6809, 7.0665};
-const int qpulses1[NBANDS128] = {7, 5, 5, 5, 4, 5, 4, 5, 5, 4, -2, 0, 0, 0, 0};
-const int qpulses2[NBANDS128] = {28,24,20,16,24,20, 18, 12, 10, 10,-7, -4, 0, 0, 0};
-const int qpulses2s[NBANDS128] = {38,30,24,20,24,20, 18, 16, 14, 20,-20,-14, -8, -8, -5};
+static const float means18[18] = {
+ 9.9067, 8.4524, 6.8577, 6.3804, 6.1786, 5.9815,
+ 6.2068, 6.1076, 5.7711, 5.7734, 5.7935, 5.3981,
+ 5.1992, 5.7214, 5.9656, 5.7548, 5.0802, 4.2626};
-const int pbank1[PBANDS128+2] = {0, 4, 8, 12, 20, PITCH_END128, 128};
+static const int decay[15] = {
+ 14800, 13800, 12600, 12000, 11000, 10000, 9800, 8400, 8000, 7500, 7000, 7000, 7000, 6000, 6000
+};
-const int qbank3[NBANDS128+2] = {0, 4, 8, 12, 16, 24, 32, 40, 48, 56, 72, 88, 104, 126, 168, 232, 256};
+static const int decay18[18] = {
+ 14800, 13800, 12600, 12000, 11000, 11000, 10000, 10000, 9800, 8400, 8400, 8000, 7500, 7000, 7000, 7000, 6000, 6000
+};
+
+const int qbank0[NBANDS +2] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 19, 22, 26, 31, 37, 45, 56, 71, 91, 116, 128};
+const int pbank0[PBANDS +2] = {0, 4, 8, 12, 19, PITCH_END, 128};
+const int qpulses0[NBANDS ] = {7, 5, 5, 4, 4, 3, 3, 2, 3, 2, 2, 2, 2, 0, 0, 0, 0, 0};
+//const int qpulses0[NBANDS ] = {7, 5, 5, 5, 4, 4, 3, 3, 3, 3, 4, 3, 3, -2, 0, 0, 0, 0};
+
+
+const int qbank1[NBANDS128+2] = {0, 2, 4, 6, 8, 12, 16, 20, 24, 28, 36, 44, 52, 68, 84, 116, 128};
+
+const int qpulses1[NBANDS128] = {7, 5, 5, 5, 4, 5, 4, 5, 5, 4, -2, 0, 0, 0, 0};
+const int qpulses2[NBANDS128] = {28,24,20,16,24,20, 18, 12, 10, 10,-7, -4, 0, 0, 0};
+const int qpulses2s[NBANDS128] ={38,30,24,20,24,20, 18, 16, 14, 20,-20,-14, -8, -8, -5};
+
+const int pbank1[PBANDS128+2] = {0, 4, 8, 12, 20, PITCH_END128, 128};
+
+const int qbank3[NBANDS128+2] = {0, 4, 8, 12, 16, 24, 32, 40, 48, 56, 72, 88, 104, 126, 168, 232, 256};
#define PITCH_END256 72
-const int pbank3[PBANDS128+2] = {0, 8, 16, 24, 40, PITCH_END256, 256};
+const int pbank3[PBANDS128+2] = {0, 8, 16, 24, 40, PITCH_END256, 256};
+const CELTMode mode0 = {
+ 256, /**< frameSize */
+ 128, /**< mdctSize */
+ 2, /**< nbMdctBlocks */
+ 1, /**< channels */
+
+ NBANDS, /**< nbEBands */
+ PBANDS, /**< nbPBands */
+ PITCH_END, /**< pitchEnd */
+
+ qbank0, /**< eBands */
+ pbank0, /**< pBands*/
+ qpulses0, /**< nbPulses */
+
+ 0.8, /**< ePredCoef */
+ means18, /**< eMeans */
+ decay18, /**< eDecay */
+};
+
+
/* Approx 38 kbps @ 44.1 kHz */
const CELTMode mode1 = {
256, /**< frameSize */
@@ -60,7 +108,11 @@
qbank1, /**< eBands */
pbank1, /**< pBands*/
- qpulses1 /**< nbPulses */
+ qpulses1, /**< nbPulses */
+
+ 0.7, /**< ePredCoef */
+ means, /**< eMeans */
+ decay, /**< eDecay */
};
/* Approx 58 kbps @ 44.1 kHz */
@@ -76,7 +128,11 @@
qbank1, /**< eBands */
pbank1, /**< pBands*/
- qpulses2 /**< nbPulses */
+ qpulses2, /**< nbPulses */
+
+ 0.7, /**< ePredCoef */
+ means, /**< eMeans */
+ decay, /**< eDecay */
};
const CELTMode mode3 = {
@@ -91,7 +147,11 @@
qbank3, /**< eBands */
pbank3, /**< pBands*/
- qpulses2 /**< nbPulses */
+ qpulses2, /**< nbPulses */
+
+ 0.7, /**< ePredCoef */
+ means, /**< eMeans */
+ decay, /**< eDecay */
};
/* Stereo mode around 120 kbps */
@@ -107,9 +167,14 @@
qbank1, /**< eBands */
pbank1, /**< pBands*/
- qpulses2s /**< nbPulses */
+ qpulses2s, /**< nbPulses */
+
+ 0.7, /**< ePredCoef */
+ means, /**< eMeans */
+ decay, /**< eDecay */
};
+const CELTMode const *celt_mode0 = &mode0;
const CELTMode const *celt_mode1 = &mode1;
const CELTMode const *celt_mode2 = &mode2;
const CELTMode const *celt_mode3 = &mode3;
--- a/libcelt/modes.h
+++ b/libcelt/modes.h
@@ -47,6 +47,10 @@
const int *eBands;
const int *pBands;
const int *nbPulses;
+
+ float ePredCoef;
+ const float *eMeans;
+ const int *eDecay;
};
#endif
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -34,16 +34,7 @@
#include "laplace.h"
#include <math.h>
-/* FIXME: Should be in the mode */
-static const float means[15] = {
- 14.8621, 12.6918, 10.2978, 9.5862, 10.3784,
- 10.4555, 9.1594, 9.0280, 8.3291, 8.3410,
- 8.5737, 8.5614, 9.0107, 7.6809, 7.0665};
-static const int decay[15] = {
- 14800, 13800, 12600, 12000, 11000, 10000, 9800, 8400, 8000, 7500, 7000, 7000, 7000, 6000, 6000
-};
-
void quant_energy(const CELTMode *m, float *eBands, float *oldEBands, ec_enc *enc)
{
int i;
@@ -54,13 +45,13 @@
float q;
float res;
float x;
- float pred = .7*oldEBands[i]+means[i];
+ float pred = m->ePredCoef*oldEBands[i]+m->eMeans[i];
x = 20*log10(.3+eBands[i]);
res = .25f*(i+3.f);
//res = 1;
qi = (int)floor(.5+(x-pred-prev)/res);
- ec_laplace_encode(enc, qi, decay[i]);
+ ec_laplace_encode(enc, qi, m->eDecay[i]);
q = qi*res;
//printf("%d ", qi);
@@ -85,10 +76,10 @@
int qi;
float q;
float res;
- float pred = .7*oldEBands[i]+means[i];
+ float pred = m->ePredCoef*oldEBands[i]+m->eMeans[i];
res = .25f*(i+3.f);
- qi = ec_laplace_decode(dec, decay[i]);
+ qi = ec_laplace_decode(dec, m->eDecay[i]);
q = qi*res;
//printf("%f %f ", pred+prev+q, x);
//printf("%d ", qi);