fixed-point: added a celt_ener_t type for band energy.
This commit is contained in:
parent
e046c18acf
commit
e901fe35b8
6 changed files with 33 additions and 30 deletions
|
@ -53,6 +53,7 @@ typedef celt_int32_t celt_word32_t;
|
|||
|
||||
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_word32_t;
|
|||
|
||||
typedef float celt_sig_t;
|
||||
typedef float celt_norm_t;
|
||||
typedef float celt_ener_t;
|
||||
|
||||
#define Q15ONE 1.0f
|
||||
#define LPC_SCALING 1.f
|
||||
|
|
|
@ -70,7 +70,7 @@ static void exp_rotation(celt_norm_t *X, int len, float theta, int dir, int stri
|
|||
}
|
||||
|
||||
/* 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 @@ void compute_band_energies(const CELTMode *m, celt_sig_t *X, float *bank)
|
|||
}
|
||||
|
||||
/* 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 normalise_bands(const CELTMode *m, celt_sig_t *freq, celt_norm_t *X, float
|
|||
|
||||
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 @@ void denormalise_bands(const CELTMode *m, celt_norm_t *X, celt_sig_t *freq, floa
|
|||
|
||||
|
||||
/* 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 @@ void unquant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, int total_
|
|||
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;
|
||||
|
|
|
@ -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 @@ void compute_band_energies(const CELTMode *m, celt_sig_t *X, float *bands);
|
|||
* @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 @@ void renormalise_bands(const CELTMode *m, celt_norm_t *X);
|
|||
* @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 @@ void denormalise_bands(const CELTMode *m, celt_norm_t *X, celt_sig_t *freq, floa
|
|||
* @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 quant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float *W, in
|
|||
*/
|
||||
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 */
|
||||
|
|
|
@ -230,7 +230,7 @@ int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compressed, i
|
|||
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 @@ int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compressed, i
|
|||
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 @@ int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compressed, i
|
|||
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 @@ int celt_decode(CELTDecoder *st, unsigned char *data, int len, celt_int16_t *pcm
|
|||
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 @@ int celt_decode(CELTDecoder *st, unsigned char *data, int len, celt_int16_t *pcm
|
|||
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 @@ int celt_decode(CELTDecoder *st, unsigned char *data, int len, celt_int16_t *pcm
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ const float eMeans[24] = {45.f, -8.f, -12.f, -2.5f, 1.f, 0.f, 0.f, 0.f, 0.f, 0.f
|
|||
/*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 @@ static void quant_energy_mono(const CELTMode *m, float *eBands, float *oldEBands
|
|||
/*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 @@ static void unquant_energy_mono(const CELTMode *m, float *eBands, float *oldEBan
|
|||
|
||||
|
||||
|
||||
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 @@ void quant_energy(const CELTMode *m, float *eBands, float *oldEBands, int budget
|
|||
#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 quant_energy(const CELTMode *m, float *eBands, float *oldEBands, int budget
|
|||
|
||||
|
||||
|
||||
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 @@ void unquant_energy(const CELTMode *m, float *eBands, float *oldEBands, int budg
|
|||
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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue