Band energy quantisation info now in the mode directly

This commit is contained in:
Jean-Marc Valin 2007-12-13 14:59:30 +11:00
parent 4a897680e3
commit 36d78e6f74
4 changed files with 85 additions and 24 deletions

View file

@ -37,6 +37,7 @@ typedef struct CELTDecoder CELTDecoder;
typedef struct CELTMode CELTMode; typedef struct CELTMode CELTMode;
extern const CELTMode const *celt_mode0;
extern const CELTMode const *celt_mode1; extern const CELTMode const *celt_mode1;
extern const CELTMode const *celt_mode2; extern const CELTMode const *celt_mode2;
extern const CELTMode const *celt_mode3; extern const CELTMode const *celt_mode3;

View file

@ -31,21 +31,69 @@
#include "modes.h" #include "modes.h"
#define NBANDS 18
#define PBANDS 5
#define PITCH_END 37
#define NBANDS128 15 #define NBANDS128 15
#define PBANDS128 5 #define PBANDS128 5
#define PITCH_END128 36 #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}; static const float means18[18] = {
const int qpulses2[NBANDS128] = {28,24,20,16,24,20, 18, 12, 10, 10,-7, -4, 0, 0, 0}; 9.9067, 8.4524, 6.8577, 6.3804, 6.1786, 5.9815,
const int qpulses2s[NBANDS128] = {38,30,24,20,24,20, 18, 16, 14, 20,-20,-14, -8, -8, -5}; 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 #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 */ /* Approx 38 kbps @ 44.1 kHz */
const CELTMode mode1 = { const CELTMode mode1 = {
@ -60,7 +108,11 @@ const CELTMode mode1 = {
qbank1, /**< eBands */ qbank1, /**< eBands */
pbank1, /**< pBands*/ pbank1, /**< pBands*/
qpulses1 /**< nbPulses */ qpulses1, /**< nbPulses */
0.7, /**< ePredCoef */
means, /**< eMeans */
decay, /**< eDecay */
}; };
/* Approx 58 kbps @ 44.1 kHz */ /* Approx 58 kbps @ 44.1 kHz */
@ -76,7 +128,11 @@ const CELTMode mode2 = {
qbank1, /**< eBands */ qbank1, /**< eBands */
pbank1, /**< pBands*/ pbank1, /**< pBands*/
qpulses2 /**< nbPulses */ qpulses2, /**< nbPulses */
0.7, /**< ePredCoef */
means, /**< eMeans */
decay, /**< eDecay */
}; };
const CELTMode mode3 = { const CELTMode mode3 = {
@ -91,7 +147,11 @@ const CELTMode mode3 = {
qbank3, /**< eBands */ qbank3, /**< eBands */
pbank3, /**< pBands*/ pbank3, /**< pBands*/
qpulses2 /**< nbPulses */ qpulses2, /**< nbPulses */
0.7, /**< ePredCoef */
means, /**< eMeans */
decay, /**< eDecay */
}; };
/* Stereo mode around 120 kbps */ /* Stereo mode around 120 kbps */
@ -107,9 +167,14 @@ const CELTMode mode4 = {
qbank1, /**< eBands */ qbank1, /**< eBands */
pbank1, /**< pBands*/ 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_mode1 = &mode1;
const CELTMode const *celt_mode2 = &mode2; const CELTMode const *celt_mode2 = &mode2;
const CELTMode const *celt_mode3 = &mode3; const CELTMode const *celt_mode3 = &mode3;

View file

@ -47,6 +47,10 @@ struct CELTMode {
const int *eBands; const int *eBands;
const int *pBands; const int *pBands;
const int *nbPulses; const int *nbPulses;
float ePredCoef;
const float *eMeans;
const int *eDecay;
}; };
#endif #endif

View file

@ -34,15 +34,6 @@
#include "laplace.h" #include "laplace.h"
#include <math.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) void quant_energy(const CELTMode *m, float *eBands, float *oldEBands, ec_enc *enc)
{ {
@ -54,13 +45,13 @@ void quant_energy(const CELTMode *m, float *eBands, float *oldEBands, ec_enc *en
float q; float q;
float res; float res;
float x; float x;
float pred = .7*oldEBands[i]+means[i]; float pred = m->ePredCoef*oldEBands[i]+m->eMeans[i];
x = 20*log10(.3+eBands[i]); x = 20*log10(.3+eBands[i]);
res = .25f*(i+3.f); res = .25f*(i+3.f);
//res = 1; //res = 1;
qi = (int)floor(.5+(x-pred-prev)/res); 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; q = qi*res;
//printf("%d ", qi); //printf("%d ", qi);
@ -85,10 +76,10 @@ void unquant_energy(const CELTMode *m, float *eBands, float *oldEBands, ec_dec *
int qi; int qi;
float q; float q;
float res; float res;
float pred = .7*oldEBands[i]+means[i]; float pred = m->ePredCoef*oldEBands[i]+m->eMeans[i];
res = .25f*(i+3.f); res = .25f*(i+3.f);
qi = ec_laplace_decode(dec, decay[i]); qi = ec_laplace_decode(dec, m->eDecay[i]);
q = qi*res; q = qi*res;
//printf("%f %f ", pred+prev+q, x); //printf("%f %f ", pred+prev+q, x);
//printf("%d ", qi); //printf("%d ", qi);