diff --git a/libcelt/bands.c b/libcelt/bands.c index 663008b1..52a2c696 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -95,7 +95,7 @@ void compute_pitch_gain(const CELTMode *m, float *X, float *P, float *gains, flo const int *pBands = m->pBands; B = m->nbMdctBlocks; float w[B*eBands[m->nbEBands]]; - for (i=0;inbEBands;i++) { int j; for (j=B*eBands[i];jpBands; + B = m->nbMdctBlocks; + for (i=0;inbPBands;i++) { int j; - for (j=B*pbank[i];jnbPBands];inbPBands+1];i++) P[i] = 0; } -void quant_bands(float *X, int B, float *P) +void quant_bands(const CELTMode *m, float *X, float *P) { - int i, j; - float norm[B*qbank[NBANDS+1]]; + int i, j, B; + const int *eBands = m->eBands; + B = m->nbMdctBlocks; + float norm[B*eBands[m->nbEBands+1]]; //float bits = 0; - for (i=0;inbEBands;i++) { int q; - q =qpulses[i]; + q = m->nbPulses[i]; if (q>0) { - float n = sqrt(B*(qbank[i+1]-qbank[i])); - alg_quant2(X+B*qbank[i], B*(qbank[i+1]-qbank[i]), q, P+B*qbank[i]); - for (j=B*qbank[i];jnbEBands];inbEBands+1];i++) X[i] = 0; } /* Scales the pulse-codebook entry in each band such that unit-energy is conserved when adding the pitch */ -void pitch_renormalise_bands(float *X, int B, float *P) +void pitch_renormalise_bands(const CELTMode *m, float *X, float *P) { - int i; - for (i=0;ieBands; + B = m->nbMdctBlocks; + for (i=0;inbEBands;i++) { int j; float Rpp=0; float Rxp=0; float Rxx=0; float gain1; - for (j=B*qbank[i];jnbEBands];inbEBands+1];i++) X[i] = 0; } diff --git a/libcelt/bands.h b/libcelt/bands.h index cbbda14d..cc114834 100644 --- a/libcelt/bands.h +++ b/libcelt/bands.h @@ -34,11 +34,6 @@ #include "modes.h" -/* Number of constant-energy bands */ -#define NBANDS 15 -/* Number of bands only for the pitch prediction */ -#define PBANDS 5 - void compute_band_energies(const CELTMode *m, float *X, float *bands); void normalise_bands(const CELTMode *m, float *X, float *bands); @@ -47,10 +42,10 @@ void denormalise_bands(const CELTMode *m, float *X, float *bands); void compute_pitch_gain(const CELTMode *m, float *X, float *P, float *gains, float *bank); -void pitch_quant_bands(float *X, int B, float *P, float *gains); +void pitch_quant_bands(const CELTMode *m, float *X, float *P, float *gains); -void quant_bands(float *X, int B, float *P); +void quant_bands(const CELTMode *m, float *X, float *P); -void pitch_renormalise_bands(float *X, int B, float *P); +void pitch_renormalise_bands(const CELTMode *m, float *X, float *P); #endif /* BANDS_H */ diff --git a/libcelt/celt.c b/libcelt/celt.c index 326d9ee2..44799d9c 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -159,9 +159,8 @@ int celt_encode(CELTState *st, short *pcm) float X[B*N]; /**< Interleaved signal MDCTs */ float P[B*N]; /**< Interleaved pitch MDCTs*/ - float bandEp[NBANDS]; - float bandE[NBANDS]; - float gains[PBANDS]; + float bandE[st->mode->nbEBands]; + float gains[st->mode->nbPBands]; int pitch_index; for (i=0;imode, X, bandE); //for (i=0;imode, P, bandEp); - normalise_bands(st->mode, P, bandEp); - + { + float bandEp[st->mode->nbEBands]; + compute_band_energies(st->mode, P, bandEp); + normalise_bands(st->mode, P, bandEp); + } + /* Pitch prediction */ compute_pitch_gain(st->mode, X, P, gains, bandE); //quantise_pitch(gains, PBANDS); - pitch_quant_bands(X, B, P, gains); + pitch_quant_bands(st->mode, X, P, gains); //for (i=0;imode, X, P); /* Synthesis */ denormalise_bands(st->mode, X, bandE); diff --git a/libcelt/modes.c b/libcelt/modes.c index f915a2b5..fc085325 100644 --- a/libcelt/modes.c +++ b/libcelt/modes.c @@ -53,7 +53,7 @@ const CELTMode mode1 = { qbank1, /**< eBands */ pbank1, /**< pBands*/ - qpulses1 /**< pulses */ + qpulses1 /**< nbPulses */ }; const CELTMode const *celt_mode1 = &mode1; diff --git a/libcelt/modes.h b/libcelt/modes.h index 76de37f7..1d5146d8 100644 --- a/libcelt/modes.h +++ b/libcelt/modes.h @@ -45,7 +45,7 @@ struct CELTMode_ { const int *eBands; const int *pBands; - const int *pulses; + const int *nbPulses; }; #endif