fixed-point: added a celt_ener_t type for band energy.
diff --git a/libcelt/arch.h b/libcelt/arch.h
index e954c70..49915e5 100644
--- a/libcelt/arch.h
+++ b/libcelt/arch.h
@@ -53,6 +53,7 @@
typedef celt_word32_t celt_sig_t;
typedef celt_word16_t celt_norm_t;
+typedef float celt_ener_t;
#define Q15ONE 32767
@@ -102,6 +103,7 @@
typedef float celt_sig_t;
typedef float celt_norm_t;
+typedef float celt_ener_t;
#define Q15ONE 1.0f
#define LPC_SCALING 1.f
diff --git a/libcelt/bands.c b/libcelt/bands.c
index 68e9191..f6f519f 100644
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -70,7 +70,7 @@
}
/* Compute the amplitude (sqrt energy) in each of the bands */
-void compute_band_energies(const CELTMode *m, celt_sig_t *X, float *bank)
+void compute_band_energies(const CELTMode *m, celt_sig_t *X, celt_ener_t *bank)
{
int i, c, B, C;
const int *eBands = m->eBands;
@@ -92,7 +92,7 @@
}
/* Normalise each band such that the energy is one. */
-void normalise_bands(const CELTMode *m, celt_sig_t *freq, celt_norm_t *X, float *bank)
+void normalise_bands(const CELTMode *m, celt_sig_t *freq, celt_norm_t *X, celt_ener_t *bank)
{
int i, c, B, C;
const int *eBands = m->eBands;
@@ -114,15 +114,15 @@
void renormalise_bands(const CELTMode *m, celt_norm_t *X)
{
- VARDECL(float *tmpE);
- ALLOC(tmpE, m->nbEBands*m->nbChannels, float);
+ VARDECL(celt_ener_t *tmpE);
+ ALLOC(tmpE, m->nbEBands*m->nbChannels, celt_ener_t);
compute_band_energies(m, X, tmpE);
/* FIXME: This isn't right */
normalise_bands(m, X, X, tmpE);
}
/* De-normalise the energy to produce the synthesis from the unit-energy bands */
-void denormalise_bands(const CELTMode *m, celt_norm_t *X, celt_sig_t *freq, float *bank)
+void denormalise_bands(const CELTMode *m, celt_norm_t *X, celt_sig_t *freq, celt_ener_t *bank)
{
int i, c, B, C;
const int *eBands = m->eBands;
@@ -144,7 +144,7 @@
/* Compute the best gain for each "pitch band" */
-void compute_pitch_gain(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float *gains, float *bank)
+void compute_pitch_gain(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float *gains, celt_ener_t *bank)
{
int i, B;
const int *eBands = m->eBands;
@@ -331,7 +331,7 @@
X[i] = 0;
}
-void stereo_mix(const CELTMode *m, celt_norm_t *X, float *bank, int dir)
+void stereo_mix(const CELTMode *m, celt_norm_t *X, celt_ener_t *bank, int dir)
{
int i, B, C;
const int *eBands = m->eBands;
diff --git a/libcelt/bands.h b/libcelt/bands.h
index e619ce4..7204e87 100644
--- a/libcelt/bands.h
+++ b/libcelt/bands.h
@@ -43,7 +43,7 @@
* @param X Spectrum
* @param bands Square root of the energy for each band (returned)
*/
-void compute_band_energies(const CELTMode *m, celt_sig_t *X, float *bands);
+void compute_band_energies(const CELTMode *m, celt_sig_t *X, celt_ener_t *bands);
/** Normalise each band of X such that the energy in each band is
equal to 1
@@ -51,7 +51,7 @@
* @param X Spectrum (returned normalised)
* @param bands Square root of the energy for each band
*/
-void normalise_bands(const CELTMode *m, celt_sig_t *freq, celt_norm_t *X, float *bands);
+void normalise_bands(const CELTMode *m, celt_sig_t *freq, celt_norm_t *X, celt_ener_t *bands);
void renormalise_bands(const CELTMode *m, celt_norm_t *X);
@@ -60,7 +60,7 @@
* @param X Spectrum (returned de-normalised)
* @param bands Square root of the energy for each band
*/
-void denormalise_bands(const CELTMode *m, celt_norm_t *X, celt_sig_t *freq, float *bands);
+void denormalise_bands(const CELTMode *m, celt_norm_t *X, celt_sig_t *freq, celt_ener_t *bands);
/** Compute the pitch predictor gain for each pitch band
* @param m Mode data
@@ -69,7 +69,7 @@
* @param gains Gain computed for each pitch band (returned)
* @param bank Square root of the energy for each band
*/
-void compute_pitch_gain(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float *gains, float *bank);
+void compute_pitch_gain(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float *gains, celt_ener_t *bank);
void pitch_quant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float *gains);
@@ -92,6 +92,6 @@
*/
void unquant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, int total_bits, ec_dec *dec);
-void stereo_mix(const CELTMode *m, celt_norm_t *X, float *bank, int dir);
+void stereo_mix(const CELTMode *m, celt_norm_t *X, celt_ener_t *bank, int dir);
#endif /* BANDS_H */
diff --git a/libcelt/celt.c b/libcelt/celt.c
index 7b8cac3..334609a 100644
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -230,7 +230,7 @@
VARDECL(celt_norm_t *X);
VARDECL(celt_norm_t *P);
VARDECL(float *mask);
- VARDECL(float *bandE);
+ VARDECL(celt_ener_t *bandE);
VARDECL(float *gains);
if (check_mode(st->mode) != CELT_OK)
@@ -244,7 +244,7 @@
ALLOC(X, B*C*N, celt_norm_t); /**< Interleaved normalised MDCTs */
ALLOC(P, B*C*N, celt_norm_t); /**< Interleaved normalised pitch MDCTs*/
ALLOC(mask, B*C*N, float); /**< Masking curve */
- ALLOC(bandE,st->mode->nbEBands*C, float);
+ ALLOC(bandE,st->mode->nbEBands*C, celt_ener_t);
ALLOC(gains,st->mode->nbPBands, float);
N4 = (N-st->overlap)/2;
@@ -322,8 +322,8 @@
if (curr_power + 1e5f < 10.f*pitch_power)
{
/* Normalise the pitch vector as well (discard the energies) */
- VARDECL(float *bandEp);
- ALLOC(bandEp, st->mode->nbEBands*st->mode->nbChannels, float);
+ VARDECL(celt_ener_t *bandEp);
+ ALLOC(bandEp, st->mode->nbEBands*st->mode->nbChannels, celt_ener_t);
compute_band_energies(st->mode, freq, bandEp);
normalise_bands(st->mode, freq, P, bandEp);
@@ -578,7 +578,7 @@
VARDECL(celt_sig_t *freq);
VARDECL(celt_norm_t *X);
VARDECL(celt_norm_t *P);
- VARDECL(float *bandE);
+ VARDECL(celt_ener_t *bandE);
VARDECL(float *gains);
if (check_mode(st->mode) != CELT_OK)
@@ -591,7 +591,7 @@
ALLOC(freq, C*B*N, celt_sig_t); /**< Interleaved signal MDCTs */
ALLOC(X, C*B*N, celt_norm_t); /**< Interleaved normalised MDCTs */
ALLOC(P, C*B*N, celt_norm_t); /**< Interleaved normalised pitch MDCTs*/
- ALLOC(bandE, st->mode->nbEBands*C, float);
+ ALLOC(bandE, st->mode->nbEBands*C, celt_ener_t);
ALLOC(gains, st->mode->nbPBands, float);
if (check_mode(st->mode) != CELT_OK)
@@ -625,8 +625,8 @@
compute_mdcts(&st->mdct_lookup, st->window, st->out_mem+pitch_index*C, freq, N, B, C);
{
- VARDECL(float *bandEp);
- ALLOC(bandEp, st->mode->nbEBands*C, float);
+ VARDECL(celt_ener_t *bandEp);
+ ALLOC(bandEp, st->mode->nbEBands*C, celt_ener_t);
compute_band_energies(st->mode, freq, bandEp);
normalise_bands(st->mode, freq, P, bandEp);
}
diff --git a/libcelt/quant_bands.c b/libcelt/quant_bands.c
index 5641ef8..bd70a04 100644
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -44,7 +44,7 @@
/*const int frac[24] = {4, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};*/
const int frac[24] = {8, 6, 5, 4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
-static void quant_energy_mono(const CELTMode *m, float *eBands, float *oldEBands, int budget, ec_enc *enc)
+static void quant_energy_mono(const CELTMode *m, celt_ener_t *eBands, float *oldEBands, int budget, ec_enc *enc)
{
int i;
int bits;
@@ -114,7 +114,7 @@
/*printf ("\n");*/
}
-static void unquant_energy_mono(const CELTMode *m, float *eBands, float *oldEBands, int budget, ec_dec *dec)
+static void unquant_energy_mono(const CELTMode *m, celt_ener_t *eBands, float *oldEBands, int budget, ec_dec *dec)
{
int i;
int bits;
@@ -163,7 +163,7 @@
-void quant_energy(const CELTMode *m, float *eBands, float *oldEBands, int budget, ec_enc *enc)
+void quant_energy(const CELTMode *m, celt_ener_t *eBands, float *oldEBands, int budget, ec_enc *enc)
{
int C;
@@ -175,8 +175,8 @@
#if 1
{
int c;
- VARDECL(float *E);
- ALLOC(E, m->nbEBands, float);
+ VARDECL(celt_ener_t *E);
+ ALLOC(E, m->nbEBands, celt_ener_t);
for (c=0;c<C;c++)
{
int i;
@@ -225,7 +225,7 @@
-void unquant_energy(const CELTMode *m, float *eBands, float *oldEBands, int budget, ec_dec *dec)
+void unquant_energy(const CELTMode *m, celt_ener_t *eBands, float *oldEBands, int budget, ec_dec *dec)
{
int C;
C = m->nbChannels;
@@ -234,8 +234,8 @@
unquant_energy_mono(m, eBands, oldEBands, budget, dec);
else {
int c;
- VARDECL(float *E);
- ALLOC(E, m->nbEBands, float);
+ VARDECL(celt_ener_t *E);
+ ALLOC(E, m->nbEBands, celt_ener_t);
for (c=0;c<C;c++)
{
int i;
diff --git a/libcelt/quant_bands.h b/libcelt/quant_bands.h
index 63b8c97..eff4e4f 100644
--- a/libcelt/quant_bands.h
+++ b/libcelt/quant_bands.h
@@ -32,12 +32,13 @@
#ifndef QUANT_BANDS
#define QUANT_BANDS
+#include "arch.h"
#include "modes.h"
#include "entenc.h"
#include "entdec.h"
-void quant_energy(const CELTMode *m, float *eBands, float *oldEBands, int budget, ec_enc *enc);
+void quant_energy(const CELTMode *m, celt_ener_t *eBands, float *oldEBands, int budget, ec_enc *enc);
-void unquant_energy(const CELTMode *m, float *eBands, float *oldEBands, int budget, ec_dec *dec);
+void unquant_energy(const CELTMode *m, celt_ener_t *eBands, float *oldEBands, int budget, ec_dec *dec);
#endif /* QUANT_BANDS */