diff --git a/libcelt/arch.h b/libcelt/arch.h index afb9fd65..73c32d74 100644 --- a/libcelt/arch.h +++ b/libcelt/arch.h @@ -54,6 +54,7 @@ typedef celt_int32_t celt_word32_t; typedef celt_word32_t celt_sig_t; typedef celt_word16_t celt_norm_t; typedef celt_word32_t celt_ener_t; +typedef double celt_pgain_t; #define Q15ONE 32767 @@ -63,6 +64,8 @@ typedef celt_word32_t celt_ener_t; #define NORM_SCALING_1 0.000061035 #define ENER_SCALING 16384.f #define ENER_SCALING_1 0.000061035 +#define PGAIN_SCALING 1.f +#define PGAIN_SCALING_1 1.f #define VERY_SMALL 0 #define VERY_LARGE32 ((celt_word32_t)2147483647) @@ -95,6 +98,7 @@ typedef float celt_word32_t; typedef float celt_sig_t; typedef float celt_norm_t; typedef float celt_ener_t; +typedef float celt_pgain_t; #define Q15ONE 1.0f @@ -104,6 +108,8 @@ typedef float celt_ener_t; #define NORM_SCALING_1 1.f #define ENER_SCALING 1.f #define ENER_SCALING_1 1.f +#define PGAIN_SCALING 1.f +#define PGAIN_SCALING_1 1.f #define VERY_SMALL 1e-15f diff --git a/libcelt/bands.c b/libcelt/bands.c index b92606ad..b3ab2b02 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -144,7 +144,7 @@ void denormalise_bands(const CELTMode *m, celt_norm_t *X, celt_sig_t *freq, celt /* 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, celt_ener_t *bank) +void compute_pitch_gain(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, celt_pgain_t *gains, celt_ener_t *bank) { int i, B; const int *eBands = m->eBands; @@ -192,7 +192,7 @@ void compute_pitch_gain(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float } /* Apply the (quantised) gain to each "pitch band" */ -void pitch_quant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float *gains) +void pitch_quant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, celt_pgain_t *gains) { int i, B; const int *pBands = m->pBands; diff --git a/libcelt/bands.h b/libcelt/bands.h index 7204e879..01a1f523 100644 --- a/libcelt/bands.h +++ b/libcelt/bands.h @@ -69,9 +69,9 @@ void denormalise_bands(const CELTMode *m, celt_norm_t *X, celt_sig_t *freq, celt * @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, celt_ener_t *bank); +void compute_pitch_gain(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, celt_pgain_t *gains, celt_ener_t *bank); -void pitch_quant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float *gains); +void pitch_quant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, celt_pgain_t *gains); /** Quantisation/encoding of the residual spectrum * @param m Mode data diff --git a/libcelt/celt.c b/libcelt/celt.c index 334609a8..8c83b5ea 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -231,7 +231,7 @@ int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compressed, i VARDECL(celt_norm_t *P); VARDECL(float *mask); VARDECL(celt_ener_t *bandE); - VARDECL(float *gains); + VARDECL(celt_pgain_t *gains); if (check_mode(st->mode) != CELT_OK) return CELT_INVALID_MODE; @@ -245,7 +245,7 @@ int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compressed, i 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, celt_ener_t); - ALLOC(gains,st->mode->nbPBands, float); + ALLOC(gains,st->mode->nbPBands, celt_pgain_t); N4 = (N-st->overlap)/2; @@ -579,7 +579,7 @@ int celt_decode(CELTDecoder *st, unsigned char *data, int len, celt_int16_t *pcm VARDECL(celt_norm_t *X); VARDECL(celt_norm_t *P); VARDECL(celt_ener_t *bandE); - VARDECL(float *gains); + VARDECL(celt_pgain_t *gains); if (check_mode(st->mode) != CELT_OK) return CELT_INVALID_MODE; @@ -592,7 +592,7 @@ int celt_decode(CELTDecoder *st, unsigned char *data, int len, celt_int16_t *pcm 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, celt_ener_t); - ALLOC(gains, st->mode->nbPBands, float); + ALLOC(gains, st->mode->nbPBands, celt_pgain_t); if (check_mode(st->mode) != CELT_OK) return CELT_INVALID_MODE; diff --git a/libcelt/quant_pitch.c b/libcelt/quant_pitch.c index 47f37705..49beaabc 100644 --- a/libcelt/quant_pitch.c +++ b/libcelt/quant_pitch.c @@ -62,7 +62,7 @@ int vq_index(float *in, const float *codebook, int len, int entries) return best_index; } -int quant_pitch(float *gains, int len, ec_enc *enc) +int quant_pitch(celt_pgain_t *gains, int len, ec_enc *enc) { int i, id; VARDECL(float *g2); @@ -78,7 +78,7 @@ int quant_pitch(float *gains, int len, ec_enc *enc) return id!=0; } -int unquant_pitch(float *gains, int len, ec_dec *dec) +int unquant_pitch(celt_pgain_t *gains, int len, ec_dec *dec) { int i, id; id = ec_dec_uint(dec, 128); diff --git a/libcelt/quant_pitch.h b/libcelt/quant_pitch.h index d1984284..6ee4ecfd 100644 --- a/libcelt/quant_pitch.h +++ b/libcelt/quant_pitch.h @@ -32,13 +32,14 @@ #ifndef QUANT_PITCH_H #define QUANT_PITCH_H +#include "arch.h" #include "entenc.h" #include "entdec.h" /** If this returns 0, the gain is zero (don't encode the pitch index) */ -int quant_pitch(float *gains, int len, ec_enc *enc); +int quant_pitch(celt_pgain_t *gains, int len, ec_enc *enc); /** If this returns 0, the gain is zero (don't decode the pitch index) */ -int unquant_pitch(float *gains, int len, ec_dec *dec); +int unquant_pitch(celt_pgain_t *gains, int len, ec_dec *dec); #endif /* QUANT_PITCH_H */