From 234969c9034f8c90148266b2e08999828d8368e2 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Sat, 17 Oct 2009 22:12:42 -0400 Subject: Removed the _t from all the celt*_t types to avoid clashing with POSIX --- libcelt/arch.h | 49 ++++++++------- libcelt/bands.c | 126 +++++++++++++++++++------------------- libcelt/bands.h | 26 ++++---- libcelt/celt.c | 160 ++++++++++++++++++++++++------------------------ libcelt/dump_modes.c | 4 +- libcelt/fixed_c5x.h | 2 +- libcelt/fixed_c6x.h | 2 +- libcelt/fixed_debug.h | 14 ++--- libcelt/fixed_generic.h | 36 +++++------ libcelt/kiss_fft.c | 2 +- libcelt/kiss_fftr.c | 2 +- libcelt/mathops.h | 72 +++++++++++----------- libcelt/mdct.c | 16 ++--- libcelt/mdct.h | 4 +- libcelt/modes.c | 6 +- libcelt/modes.h | 6 +- libcelt/pitch.c | 30 ++++----- libcelt/pitch.h | 2 +- libcelt/psy.c | 24 ++++---- libcelt/psy.h | 10 +-- libcelt/quant_bands.c | 54 ++++++++-------- libcelt/quant_bands.h | 18 +++--- libcelt/vq.c | 62 +++++++++---------- libcelt/vq.h | 8 +-- tests/mathops-test.c | 10 +-- tests/mdct-test.c | 2 +- tests/rotation-test.c | 4 +- 27 files changed, 375 insertions(+), 376 deletions(-) diff --git a/libcelt/arch.h b/libcelt/arch.h index 3d803b0..084b298 100644 --- a/libcelt/arch.h +++ b/libcelt/arch.h @@ -71,14 +71,13 @@ #ifdef FIXED_POINT -typedef celt_int16 celt_word16_t; -typedef celt_int32 celt_word32_t; +typedef celt_int16 celt_word16; +typedef celt_int32 celt_word32; -typedef celt_word32_t celt_sig_t; -typedef celt_word16_t celt_norm_t; -typedef celt_word32_t celt_ener_t; -typedef celt_word16_t celt_pgain_t; -typedef celt_word32_t celt_mask_t; +typedef celt_word32 celt_sig; +typedef celt_word16 celt_norm; +typedef celt_word32 celt_ener; +typedef celt_word32 celt_mask; #define Q15ONE 32767 #define Q30ONE 1073741823 @@ -102,9 +101,9 @@ typedef celt_word32_t celt_mask_t; #define EPSILON 1 #define VERY_SMALL 0 -#define VERY_LARGE32 ((celt_word32_t)2147483647) -#define VERY_LARGE16 ((celt_word16_t)32767) -#define Q15_ONE ((celt_word16_t)32767) +#define VERY_LARGE32 ((celt_word32)2147483647) +#define VERY_LARGE16 ((celt_word16)32767) +#define Q15_ONE ((celt_word16)32767) #define Q15_ONE_1 (1.f/32768.f) #define SCALEIN(a) (a) @@ -133,14 +132,14 @@ typedef celt_word32_t celt_mask_t; #else /* FIXED_POINT */ -typedef float celt_word16_t; -typedef float celt_word32_t; +typedef float celt_word16; +typedef float celt_word32; -typedef float celt_sig_t; -typedef float celt_norm_t; -typedef float celt_ener_t; -typedef float celt_pgain_t; -typedef float celt_mask_t; +typedef float celt_sig; +typedef float celt_norm; +typedef float celt_ener; +typedef float celt_pgain; +typedef float celt_mask; #define Q15ONE 1.0f #define Q30ONE 1.0f @@ -159,8 +158,8 @@ typedef float celt_mask_t; #define VERY_SMALL 1e-15f #define VERY_LARGE32 1e15f #define VERY_LARGE16 1e15f -#define Q15_ONE ((celt_word16_t)1.f) -#define Q15_ONE_1 ((celt_word16_t)1.f) +#define Q15_ONE ((celt_word16)1.f) +#define Q15_ONE_1 ((celt_word16)1.f) #define QCONST16(x,bits) (x) #define QCONST32(x,bits) (x) @@ -192,8 +191,8 @@ typedef float celt_mask_t; #define ADD32(a,b) ((a)+(b)) #define SUB32(a,b) ((a)-(b)) #define MULT16_16_16(a,b) ((a)*(b)) -#define MULT16_16(a,b) ((celt_word32_t)(a)*(celt_word32_t)(b)) -#define MAC16_16(c,a,b) ((c)+(celt_word32_t)(a)*(celt_word32_t)(b)) +#define MULT16_16(a,b) ((celt_word32)(a)*(celt_word32)(b)) +#define MAC16_16(c,a,b) ((c)+(celt_word32)(a)*(celt_word32)(b)) #define MULT16_32_Q11(a,b) ((a)*(b)) #define MULT16_32_Q13(a,b) ((a)*(b)) @@ -218,10 +217,10 @@ typedef float celt_mask_t; #define MULT16_16_P13(a,b) ((a)*(b)) #define MULT16_16_P14(a,b) ((a)*(b)) -#define DIV32_16(a,b) (((celt_word32_t)(a))/(celt_word16_t)(b)) -#define PDIV32_16(a,b) (((celt_word32_t)(a))/(celt_word16_t)(b)) -#define DIV32(a,b) (((celt_word32_t)(a))/(celt_word32_t)(b)) -#define PDIV32(a,b) (((celt_word32_t)(a))/(celt_word32_t)(b)) +#define DIV32_16(a,b) (((celt_word32)(a))/(celt_word16)(b)) +#define PDIV32_16(a,b) (((celt_word32)(a))/(celt_word16)(b)) +#define DIV32(a,b) (((celt_word32)(a))/(celt_word32)(b)) +#define PDIV32(a,b) (((celt_word32)(a))/(celt_word32)(b)) #define SCALEIN(a) ((a)*CELT_SIG_SCALE) #define SCALEOUT(a) ((a)*(1/CELT_SIG_SCALE)) diff --git a/libcelt/bands.c b/libcelt/bands.c index a0998eb..231b2cd 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -48,7 +48,7 @@ #ifdef FIXED_POINT /* Compute the amplitude (sqrt energy) in each of the bands */ -void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *bank, int _C) +void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bank, int _C) { int i, c, N; const celt_int16 *eBands = m->eBands; @@ -59,8 +59,8 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t * for (i=0;inbEBands;i++) { int j; - celt_word32_t maxval=0; - celt_word32_t sum = 0; + celt_word32 maxval=0; + celt_word32 sum = 0; j=eBands[i]; do { maxval = MAX32(maxval, X[j+c*N]); @@ -87,7 +87,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t * } /* Normalise each band such that the energy is one. */ -void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_norm_t * restrict X, const celt_ener_t *bank, int _C) +void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_norm * restrict X, const celt_ener *bank, int _C) { int i, c, N; const celt_int16 *eBands = m->eBands; @@ -96,9 +96,9 @@ void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_n for (c=0;cnbEBands])-13; E = VSHR32(bank[i+c*m->nbEBands], shift); g = EXTRACT16(celt_rcp(SHL32(E,3))); @@ -111,7 +111,7 @@ void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_n #else /* FIXED_POINT */ /* Compute the amplitude (sqrt energy) in each of the bands */ -void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *bank, int _C) +void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bank, int _C) { int i, c, N; const celt_int16 *eBands = m->eBands; @@ -122,7 +122,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t * for (i=0;inbEBands;i++) { int j; - celt_word32_t sum = 1e-10; + celt_word32 sum = 1e-10; for (j=eBands[i];jnbEBands] = sqrt(sum); @@ -133,7 +133,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t * } #ifdef EXP_PSY -void compute_noise_energies(const CELTMode *m, const celt_sig_t *X, const celt_word16_t *tonality, celt_ener_t *bank, int _C) +void compute_noise_energies(const CELTMode *m, const celt_sig *X, const celt_word16 *tonality, celt_ener *bank, int _C) { int i, c, N; const celt_int16 *eBands = m->eBands; @@ -144,7 +144,7 @@ void compute_noise_energies(const CELTMode *m, const celt_sig_t *X, const celt_w for (i=0;inbEBands;i++) { int j; - celt_word32_t sum = 1e-10; + celt_word32 sum = 1e-10; for (j=eBands[i];jnbEBands] = sqrt(sum); @@ -156,7 +156,7 @@ void compute_noise_energies(const CELTMode *m, const celt_sig_t *X, const celt_w #endif /* Normalise each band such that the energy is one. */ -void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_norm_t * restrict X, const celt_ener_t *bank, int _C) +void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_norm * restrict X, const celt_ener *bank, int _C) { int i, c, N; const celt_int16 *eBands = m->eBands; @@ -167,7 +167,7 @@ void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_n for (i=0;inbEBands;i++) { int j; - celt_word16_t g = 1.f/(1e-10+bank[i+c*m->nbEBands]); + celt_word16 g = 1.f/(1e-10+bank[i+c*m->nbEBands]); for (j=eBands[i];jeBands; @@ -190,7 +190,7 @@ void renormalise_bands(const CELTMode *m, celt_norm_t * restrict X, int _C) } /* De-normalise the energy to produce the synthesis from the unit-energy bands */ -void denormalise_bands(const CELTMode *m, const celt_norm_t * restrict X, celt_sig_t * restrict freq, const celt_ener_t *bank, int _C) +void denormalise_bands(const CELTMode *m, const celt_norm * restrict X, celt_sig * restrict freq, const celt_ener *bank, int _C) { int i, c, N; const celt_int16 *eBands = m->eBands; @@ -203,7 +203,7 @@ void denormalise_bands(const CELTMode *m, const celt_norm_t * restrict X, celt_s for (i=0;inbEBands;i++) { int j; - celt_word32_t g = SHR32(bank[i+c*m->nbEBands],1); + celt_word32 g = SHR32(bank[i+c*m->nbEBands],1); j=eBands[i]; do { freq[j+c*N] = SHL32(MULT16_32_Q15(X[j+c*N], g),2); } while (++jpitchEnd; const int N = FRAMESIZE(m); #ifdef FIXED_POINT int shift = 0; - celt_word32_t maxabs=0; + celt_word32 maxabs=0; for (c=0;cpitchEnd; @@ -321,7 +321,7 @@ void apply_pitch(const CELTMode *m, celt_sig_t *X, const celt_sig_t *P, int gain delta = -delta; for (c=0;ceBands; int j; - celt_word16_t a1, a2; + celt_word16 a1, a2; if (stereo_mode==0) { /* Do mid-side when not doing intensity stereo */ a1 = QCONST16(.70711f,14); a2 = dir*QCONST16(.70711f,14); } else { - celt_word16_t left, right; - celt_word16_t norm; + celt_word16 left, right; + celt_word16 norm; #ifdef FIXED_POINT int shift = celt_zlog2(MAX32(bank[i], bank[i+m->nbEBands]))-13; #endif @@ -357,7 +357,7 @@ static void stereo_band_mix(const CELTMode *m, celt_norm_t *X, celt_norm_t *Y, c } for (j=0;jeBands; @@ -384,9 +384,9 @@ int folding_decision(const CELTMode *m, celt_norm_t *X, celt_word16_t *average, { int j, N; int max_i=0; - celt_word16_t max_val=EPSILON; - celt_word32_t floor_ener=EPSILON; - celt_norm_t * restrict x = X+eBands[i]+c*N0; + celt_word16 max_val=EPSILON; + celt_word32 floor_ener=EPSILON; + celt_norm * restrict x = X+eBands[i]+c*N0; N = eBands[i+1]-eBands[i]; for (j=0;j7) { - celt_word16_t r; - celt_word16_t den = celt_sqrt(floor_ener); + celt_word16 r; + celt_word16 den = celt_sqrt(floor_ener); den = MAX32(QCONST16(.02, 15), den); r = DIV32_16(SHL32(EXTEND32(max_val),8),den); ratio = ADD32(ratio, EXTEND32(r)); @@ -439,17 +439,17 @@ int folding_decision(const CELTMode *m, celt_norm_t *X, celt_word16_t *average, } /* Quantisation of the residual */ -void quant_bands(const CELTMode *m, celt_norm_t * restrict X, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, int encode, void *enc_dec) +void quant_bands(const CELTMode *m, celt_norm * restrict X, const celt_ener *bandE, int *pulses, int shortBlocks, int fold, int total_bits, int encode, void *enc_dec) { int i, j, remaining_bits, balance; const celt_int16 * restrict eBands = m->eBands; - celt_norm_t * restrict norm; - VARDECL(celt_norm_t, _norm); + celt_norm * restrict norm; + VARDECL(celt_norm, _norm); int B; SAVE_STACK; B = shortBlocks ? m->nbShortMdcts : 1; - ALLOC(_norm, eBands[m->nbEBands+1], celt_norm_t); + ALLOC(_norm, eBands[m->nbEBands+1], celt_norm); norm = _norm; balance = 0; @@ -458,7 +458,7 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, const celt_ener_t int tell; int N; int q; - celt_word16_t n; + celt_word16 n; const celt_int16 * const *BPbits; int curr_balance, curr_bits; @@ -509,18 +509,18 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, const celt_ener_t #ifndef DISABLE_STEREO -void quant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_enc *enc) +void quant_bands_stereo(const CELTMode *m, celt_norm *_X, const celt_ener *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_enc *enc) { int i, j, remaining_bits, balance; const celt_int16 * restrict eBands = m->eBands; - celt_norm_t * restrict norm; - VARDECL(celt_norm_t, _norm); + celt_norm * restrict norm; + VARDECL(celt_norm, _norm); int B; - celt_word16_t mid, side; + celt_word16 mid, side; SAVE_STACK; B = shortBlocks ? m->nbShortMdcts : 1; - ALLOC(_norm, eBands[m->nbEBands+1], celt_norm_t); + ALLOC(_norm, eBands[m->nbEBands+1], celt_norm); norm = _norm; balance = 0; @@ -529,7 +529,7 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *b int c; int tell; int q1, q2; - celt_word16_t n; + celt_word16 n; const celt_int16 * const *BPbits; int b, qb; int N; @@ -537,7 +537,7 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *b int imid, iside, itheta; int mbits, sbits, delta; int qalloc; - celt_norm_t * restrict X, * restrict Y; + celt_norm * restrict X, * restrict Y; X = _X+eBands[i]; Y = X+eBands[m->nbEBands+1]; @@ -605,8 +605,8 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *b { int c2; int sign=1; - celt_norm_t v[2], w[2]; - celt_norm_t *x2, *y2; + celt_norm v[2], w[2]; + celt_norm *x2, *y2; mbits = b-qalloc; sbits = 0; if (itheta != 0 && itheta != 16384) @@ -740,18 +740,18 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *b #ifndef DISABLE_STEREO -void unquant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_dec *dec) +void unquant_bands_stereo(const CELTMode *m, celt_norm *_X, const celt_ener *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_dec *dec) { int i, j, remaining_bits, balance; const celt_int16 * restrict eBands = m->eBands; - celt_norm_t * restrict norm; - VARDECL(celt_norm_t, _norm); + celt_norm * restrict norm; + VARDECL(celt_norm, _norm); int B; - celt_word16_t mid, side; + celt_word16 mid, side; SAVE_STACK; B = shortBlocks ? m->nbShortMdcts : 1; - ALLOC(_norm, eBands[m->nbEBands+1], celt_norm_t); + ALLOC(_norm, eBands[m->nbEBands+1], celt_norm); norm = _norm; balance = 0; @@ -760,7 +760,7 @@ void unquant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t int c; int tell; int q1, q2; - celt_word16_t n; + celt_word16 n; const celt_int16 * const *BPbits; int b, qb; int N; @@ -768,7 +768,7 @@ void unquant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t int imid, iside, itheta; int mbits, sbits, delta; int qalloc; - celt_norm_t * restrict X, * restrict Y; + celt_norm * restrict X, * restrict Y; X = _X+eBands[i]; Y = X+eBands[m->nbEBands+1]; @@ -825,8 +825,8 @@ void unquant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t { int c2; int sign=1; - celt_norm_t v[2], w[2]; - celt_norm_t *x2, *y2; + celt_norm v[2], w[2]; + celt_norm *x2, *y2; mbits = b-qalloc; sbits = 0; if (itheta != 0 && itheta != 16384) diff --git a/libcelt/bands.h b/libcelt/bands.h index 5fb5ee8..78a3172 100644 --- a/libcelt/bands.h +++ b/libcelt/bands.h @@ -45,9 +45,9 @@ * @param X Spectrum * @param bands Square root of the energy for each band (returned) */ -void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *bands, int _C); +void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bands, int _C); -/*void compute_noise_energies(const CELTMode *m, const celt_sig_t *X, const celt_word16_t *tonality, celt_ener_t *bank);*/ +/*void compute_noise_energies(const CELTMode *m, const celt_sig *X, const celt_word16 *tonality, celt_ener *bank);*/ /** Normalise each band of X such that the energy in each band is equal to 1 @@ -55,16 +55,16 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t * * @param X Spectrum (returned normalised) * @param bands Square root of the energy for each band */ -void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_norm_t * restrict X, const celt_ener_t *bands, int _C); +void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_norm * restrict X, const celt_ener *bands, int _C); -void renormalise_bands(const CELTMode *m, celt_norm_t * restrict X, int _C); +void renormalise_bands(const CELTMode *m, celt_norm * restrict X, int _C); /** Denormalise each band of X to restore full amplitude * @param m Mode data * @param X Spectrum (returned de-normalised) * @param bands Square root of the energy for each band */ -void denormalise_bands(const CELTMode *m, const celt_norm_t * restrict X, celt_sig_t * restrict freq, const celt_ener_t *bands, int _C); +void denormalise_bands(const CELTMode *m, const celt_norm * restrict X, celt_sig * restrict freq, const celt_ener *bands, int _C); /** Compute the pitch predictor gain for each pitch band * @param m Mode data @@ -73,11 +73,11 @@ void denormalise_bands(const CELTMode *m, const celt_norm_t * restrict X, celt_s * @param gains Gain computed for each pitch band (returned) * @param bank Square root of the energy for each band */ -int compute_pitch_gain(const CELTMode *m, const celt_sig_t *X, const celt_sig_t *P, int norm_rate, int *gain_id, int _C, celt_word16_t *gain_prod); +int compute_pitch_gain(const CELTMode *m, const celt_sig *X, const celt_sig *P, int norm_rate, int *gain_id, int _C, celt_word16 *gain_prod); -void apply_pitch(const CELTMode *m, celt_sig_t *X, const celt_sig_t *P, int gain_id, int pred, int _C); +void apply_pitch(const CELTMode *m, celt_sig *X, const celt_sig *P, int gain_id, int pred, int _C); -int folding_decision(const CELTMode *m, celt_norm_t *X, celt_word16_t *average, int *last_decision, int _C); +int folding_decision(const CELTMode *m, celt_norm *X, celt_word16 *average, int *last_decision, int _C); /** Quantisation/encoding of the residual spectrum * @param m Mode data @@ -85,9 +85,9 @@ int folding_decision(const CELTMode *m, celt_norm_t *X, celt_word16_t *average, * @param total_bits Total number of bits that can be used for the frame (including the ones already spent) * @param enc Entropy encoder */ -void quant_bands(const CELTMode *m, celt_norm_t * restrict X, const celt_ener_t *bandE, int *pulses, int time_domain, int fold, int total_bits, int encode, void *enc_dec); +void quant_bands(const CELTMode *m, celt_norm * restrict X, const celt_ener *bandE, int *pulses, int time_domain, int fold, int total_bits, int encode, void *enc_dec); -void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, const celt_ener_t *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_enc *enc); +void quant_bands_stereo(const CELTMode *m, celt_norm * restrict X, const celt_ener *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_enc *enc); /** Decoding of the residual spectrum * @param m Mode data @@ -95,10 +95,10 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, const celt_ * @param total_bits Total number of bits that can be used for the frame (including the ones already spent) * @param dec Entropy decoder */ -void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, const celt_ener_t *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_dec *dec); +void unquant_bands(const CELTMode *m, celt_norm * restrict X, const celt_ener *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_dec *dec); -void unquant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, const celt_ener_t *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_dec *dec); +void unquant_bands_stereo(const CELTMode *m, celt_norm * restrict X, const celt_ener *bandE, int *pulses, int time_domain, int fold, int total_bits, ec_dec *dec); -void stereo_decision(const CELTMode *m, celt_norm_t * restrict X, int *stereo_mode, int len); +void stereo_decision(const CELTMode *m, celt_norm * restrict X, int *stereo_mode, int len); #endif /* BANDS_H */ diff --git a/libcelt/celt.c b/libcelt/celt.c index 91b20b7..1e3bf9b 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -54,10 +54,10 @@ #include "float_cast.h" #include -static const celt_word16_t preemph = QCONST16(0.8f,15); +static const celt_word16 preemph = QCONST16(0.8f,15); #ifdef FIXED_POINT -static const celt_word16_t transientWindow[16] = { +static const celt_word16 transientWindow[16] = { 279, 1106, 2454, 4276, 6510, 9081, 11900, 14872, 17896, 20868, 23687, 26258, 28492, 30314, 31662, 32489}; #else @@ -88,20 +88,20 @@ struct CELTEncoder { int pitch_available; /* Amount of pitch buffer available */ int force_intra; int delayedIntra; - celt_word16_t tonal_average; + celt_word16 tonal_average; int fold_decision; - celt_word16_t gain_prod; + celt_word16 gain_prod; int VBR_rate; /* Target number of 16th bits per frame */ - celt_word16_t * restrict preemph_memE; - celt_sig_t * restrict preemph_memD; + celt_word16 * restrict preemph_memE; + celt_sig * restrict preemph_memD; - celt_sig_t *in_mem; - celt_sig_t *out_mem; + celt_sig *in_mem; + celt_sig *out_mem; - celt_word16_t *oldBandE; + celt_word16 *oldBandE; #ifdef EXP_PSY - celt_word16_t *psy_mem; + celt_word16 *psy_mem; struct PsyDecay psy; #endif }; @@ -167,16 +167,16 @@ CELTEncoder *celt_encoder_create(const CELTMode *mode, int channels, int *error) st->tonal_average = QCONST16(1.,8); st->fold_decision = 1; - st->in_mem = celt_alloc(st->overlap*C*sizeof(celt_sig_t)); - st->out_mem = celt_alloc((MAX_PERIOD+st->overlap)*C*sizeof(celt_sig_t)); + st->in_mem = celt_alloc(st->overlap*C*sizeof(celt_sig)); + st->out_mem = celt_alloc((MAX_PERIOD+st->overlap)*C*sizeof(celt_sig)); - st->oldBandE = (celt_word16_t*)celt_alloc(C*mode->nbEBands*sizeof(celt_word16_t)); + st->oldBandE = (celt_word16*)celt_alloc(C*mode->nbEBands*sizeof(celt_word16)); - st->preemph_memE = (celt_word16_t*)celt_alloc(C*sizeof(celt_word16_t)); - st->preemph_memD = (celt_sig_t*)celt_alloc(C*sizeof(celt_sig_t)); + st->preemph_memE = (celt_word16*)celt_alloc(C*sizeof(celt_word16)); + st->preemph_memD = (celt_sig*)celt_alloc(C*sizeof(celt_sig)); #ifdef EXP_PSY - st->psy_mem = celt_alloc(MAX_PERIOD*sizeof(celt_word16_t)); + st->psy_mem = celt_alloc(MAX_PERIOD*sizeof(celt_word16)); psydecay_init(&st->psy, MAX_PERIOD/2, st->mode->Fs); #endif @@ -247,7 +247,7 @@ static inline celt_int16 FLOAT2INT16(float x) return (celt_int16)float2int(x); } -static inline celt_word16_t SIG2WORD16(celt_sig_t x) +static inline celt_word16 SIG2WORD16(celt_sig x) { #ifdef FIXED_POINT x = PSHR32(x, SIG_SHIFT); @@ -255,17 +255,17 @@ static inline celt_word16_t SIG2WORD16(celt_sig_t x) x = MIN32(x, 32767); return EXTRACT16(x); #else - return (celt_word16_t)x; + return (celt_word16)x; #endif } -static int transient_analysis(celt_word32_t *in, int len, int C, int *transient_time, int *transient_shift) +static int transient_analysis(celt_word32 *in, int len, int C, int *transient_time, int *transient_shift) { int c, i, n; - celt_word32_t ratio; - VARDECL(celt_word32_t, begin); + celt_word32 ratio; + VARDECL(celt_word32, begin); SAVE_STACK; - ALLOC(begin, len, celt_word32_t); + ALLOC(begin, len, celt_word32); for (i=0;ishortMdctSize; B = mode->nbShortMdcts; } - ALLOC(x, N+overlap, celt_word32_t); - ALLOC(tmp, N, celt_word32_t); + ALLOC(x, N+overlap, celt_word32); + ALLOC(tmp, N, celt_word32); for (c=0;cwindow, overlap); } else { - VARDECL(celt_word32_t, x); - VARDECL(celt_word32_t, tmp); + VARDECL(celt_word32, x); + VARDECL(celt_word32, tmp); int b; int N2 = N; int B = 1; @@ -374,8 +374,8 @@ static void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig_t const mdct_lookup *lookup = MDCT(mode); SAVE_STACK; - ALLOC(x, 2*N, celt_word32_t); - ALLOC(tmp, N, celt_word32_t); + ALLOC(x, 2*N, celt_word32); + ALLOC(tmp, N, celt_word32); if (shortBlocks) { @@ -484,7 +484,7 @@ static void decode_flags(ec_dec *dec, int *intra_ener, int *has_pitch, int *shor /*printf ("dec %d: %d %d %d %d\n", flag_bits, *intra_ener, *has_pitch, *shortBlocks, *has_fold);*/ } -static void deemphasis(celt_sig_t *in, celt_word16_t *pcm, int N, int _C, celt_word16_t coef, celt_sig_t *mem) +static void deemphasis(celt_sig *in, celt_word16 *pcm, int N, int _C, celt_word16 coef, celt_sig *mem) { const int C = CHANNELS(_C); int c; @@ -493,7 +493,7 @@ static void deemphasis(celt_sig_t *in, celt_word16_t *pcm, int N, int _C, celt_w int j; for (j=0;jblock_size; N4 = (N-st->overlap)>>1; - ALLOC(in, 2*C*N-2*C*N4, celt_sig_t); + ALLOC(in, 2*C*N-2*C*N4, celt_sig); CELT_COPY(in, st->in_mem, C*st->overlap); for (c=0;coverlap+c; + const celt_word16 * restrict pcmp = pcm+c; + celt_sig * restrict inp = in+C*st->overlap+c; for (i=0;ipreemph_memE[c]),3)); st->preemph_memE[c] = SCALEIN(*pcmp); inp += C; @@ -625,9 +625,9 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si has_fold = 1; } - ALLOC(freq, C*N, celt_sig_t); /**< Interleaved signal MDCTs */ - ALLOC(bandE,st->mode->nbEBands*C, celt_ener_t); - ALLOC(bandLogE,st->mode->nbEBands*C, celt_word16_t); + ALLOC(freq, C*N, celt_sig); /**< Interleaved signal MDCTs */ + ALLOC(bandE,st->mode->nbEBands*C, celt_ener); + ALLOC(bandLogE,st->mode->nbEBands*C, celt_word16); /* Compute MDCTs */ compute_mdcts(st->mode, shortBlocks, in, freq, C); @@ -646,9 +646,9 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si /* Deferred allocation after find_spectral_pitch() to reduce the peak memory usage */ - ALLOC(X, C*N, celt_norm_t); /**< Interleaved normalised MDCTs */ + ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ - ALLOC(pitch_freq, C*N, celt_sig_t); /**< Interleaved signal MDCTs */ + ALLOC(pitch_freq, C*N, celt_sig); /**< Interleaved signal MDCTs */ if (has_pitch) { @@ -678,13 +678,13 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si NN = st->mode->eBands[st->mode->nbEBands]; if (shortBlocks && !transient_shift) { - celt_word32_t sum[8]={1,1,1,1,1,1,1,1}; + celt_word32 sum[8]={1,1,1,1,1,1,1,1}; int m; for (c=0;cmode->nbShortMdcts) tmp += ABS32(X[i]); sum[m++] += tmp; @@ -749,7 +749,7 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si ALLOC(pulses, st->mode->nbEBands, int); /* Bit allocation */ - ALLOC(error, C*st->mode->nbEBands, celt_word16_t); + ALLOC(error, C*st->mode->nbEBands, celt_word16); coarse_needed = quant_coarse_energy(st->mode, bandLogE, st->oldBandE, nbCompressedBytes*8/3, intra_ener, st->mode->prob, error, &enc, C); coarse_needed = ((coarse_needed*3-1)>>3)+1; @@ -871,7 +871,7 @@ int celt_encode_float(CELTEncoder * restrict st, const float * pcm, float * opti int celt_encode(CELTEncoder * restrict st, const celt_int16 * pcm, celt_int16 * optional_synthesis, unsigned char *compressed, int nbCompressedBytes) { int j, ret, C, N; - VARDECL(celt_sig_t, in); + VARDECL(celt_sig, in); SAVE_STACK; if (check_encoder(st) != CELT_OK) @@ -885,7 +885,7 @@ int celt_encode(CELTEncoder * restrict st, const celt_int16 * pcm, celt_int16 * C=CHANNELS(st->channels); N=st->block_size; - ALLOC(in, C*N, celt_sig_t); + ALLOC(in, C*N, celt_sig); for (j=0;joverlap = mode->overlap; st->channels = channels; - st->decode_mem = celt_alloc((DECODE_BUFFER_SIZE+st->overlap)*C*sizeof(celt_sig_t)); + st->decode_mem = celt_alloc((DECODE_BUFFER_SIZE+st->overlap)*C*sizeof(celt_sig)); st->out_mem = st->decode_mem+DECODE_BUFFER_SIZE-MAX_PERIOD; - st->oldBandE = (celt_word16_t*)celt_alloc(C*mode->nbEBands*sizeof(celt_word16_t)); + st->oldBandE = (celt_word16*)celt_alloc(C*mode->nbEBands*sizeof(celt_word16)); - st->preemph_memD = (celt_sig_t*)celt_alloc(C*sizeof(celt_sig_t)); + st->preemph_memD = (celt_sig*)celt_alloc(C*sizeof(celt_sig)); st->loss_count = 0; @@ -1156,18 +1156,18 @@ void celt_decoder_destroy(CELTDecoder *st) #ifdef NEW_PLC #include "plc.c" #else -static void celt_decode_lost(CELTDecoder * restrict st, celt_word16_t * restrict pcm) +static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict pcm) { int c, N; int pitch_index; - celt_word16_t fade = Q15ONE; + celt_word16 fade = Q15ONE; int i, len; - VARDECL(celt_sig_t, freq); + VARDECL(celt_sig, freq); const int C = CHANNELS(st->channels); int offset; SAVE_STACK; N = st->block_size; - ALLOC(freq,C*N, celt_sig_t); /**< Interleaved signal MDCTs */ + ALLOC(freq,C*N, celt_sig); /**< Interleaved signal MDCTs */ len = N+st->mode->overlap; @@ -1200,7 +1200,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16_t * restrict int j; for (j=0;jout_mem[C*(MAX_PERIOD-N)+C*j+c], + celt_sig tmp = MAC16_32_Q15(st->out_mem[C*(MAX_PERIOD-N)+C*j+c], preemph,st->preemph_memD[c]); st->preemph_memD[c] = tmp; pcm[C*j+c] = SCALEOUT(SIG2WORD16(tmp)); @@ -1217,7 +1217,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16_t * restrict int celt_decode(CELTDecoder * restrict st, const unsigned char *data, int len, celt_int16 * restrict pcm) { #else -int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int len, celt_sig_t * restrict pcm) +int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int len, celt_sig * restrict pcm) { #endif int i, N, N4; @@ -1226,10 +1226,10 @@ int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int int bits; ec_dec dec; ec_byte_buffer buf; - VARDECL(celt_sig_t, freq); - VARDECL(celt_sig_t, pitch_freq); - VARDECL(celt_norm_t, X); - VARDECL(celt_ener_t, bandE); + VARDECL(celt_sig, freq); + VARDECL(celt_sig, pitch_freq); + VARDECL(celt_norm, X); + VARDECL(celt_ener, bandE); VARDECL(int, fine_quant); VARDECL(int, pulses); VARDECL(int, offsets); @@ -1257,9 +1257,9 @@ int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int N = st->block_size; N4 = (N-st->overlap)>>1; - ALLOC(freq, C*N, celt_sig_t); /**< Interleaved signal MDCTs */ - ALLOC(X, C*N, celt_norm_t); /**< Interleaved normalised MDCTs */ - ALLOC(bandE, st->mode->nbEBands*C, celt_ener_t); + ALLOC(freq, C*N, celt_sig); /**< Interleaved signal MDCTs */ + ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ + ALLOC(bandE, st->mode->nbEBands*C, celt_ener); if (data == NULL) { @@ -1322,7 +1322,7 @@ int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int unquant_fine_energy(st->mode, bandE, st->oldBandE, fine_quant, &dec, C); - ALLOC(pitch_freq, C*N, celt_sig_t); /**< Interleaved signal MDCTs */ + ALLOC(pitch_freq, C*N, celt_sig); /**< Interleaved signal MDCTs */ if (has_pitch) { /* Pitch MDCT */ @@ -1394,7 +1394,7 @@ int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int int celt_decode(CELTDecoder * restrict st, const unsigned char *data, int len, celt_int16 * restrict pcm) { int j, ret, C, N; - VARDECL(celt_sig_t, out); + VARDECL(celt_sig, out); SAVE_STACK; if (check_decoder(st) != CELT_OK) @@ -1408,7 +1408,7 @@ int celt_decode(CELTDecoder * restrict st, const unsigned char *data, int len, c C = CHANNELS(st->channels); N = st->block_size; - ALLOC(out, C*N, celt_sig_t); + ALLOC(out, C*N, celt_sig); ret=celt_decode_float(st, data, len, out); diff --git a/libcelt/dump_modes.c b/libcelt/dump_modes.c index 8e3b786..fbe50a9 100644 --- a/libcelt/dump_modes.c +++ b/libcelt/dump_modes.c @@ -76,7 +76,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) fprintf(file, "#ifndef DEF_WINDOW%d\n", mode->overlap); fprintf(file, "#define DEF_WINDOW%d\n", mode->overlap); - fprintf (file, "static const celt_word16_t window%d[%d] = {\n", mode->overlap, mode->overlap); + fprintf (file, "static const celt_word16 window%d[%d] = {\n", mode->overlap, mode->overlap); for (j=0;joverlap;j++) fprintf (file, WORD16 ", ", mode->window[j]); fprintf (file, "};\n"); @@ -85,7 +85,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) fprintf(file, "#ifndef DEF_PSY%d\n", mode->Fs); fprintf(file, "#define DEF_PSY%d\n", mode->Fs); - fprintf (file, "static const celt_word16_t psy_decayR_%d[%d] = {\n", mode->Fs, MAX_PERIOD/2); + fprintf (file, "static const celt_word16 psy_decayR_%d[%d] = {\n", mode->Fs, MAX_PERIOD/2); for (j=0;jpsy.decayR[j]); fprintf (file, "};\n"); diff --git a/libcelt/fixed_c5x.h b/libcelt/fixed_c5x.h index de7a217..d0e39fe 100644 --- a/libcelt/fixed_c5x.h +++ b/libcelt/fixed_c5x.h @@ -82,7 +82,7 @@ static inline long IMUL32(long i, long j) #define OVERRIDE_CELT_MAXABS16 #define OVERRIDE_FIND_MAX16 -static inline int find_max16(celt_word16_t *x, int len) +static inline int find_max16(celt_word16 *x, int len) { DATA max_corr16 = -VERY_LARGE16; DATA pitch16 = 0; diff --git a/libcelt/fixed_c6x.h b/libcelt/fixed_c6x.h index 73f12d5..467a9e5 100644 --- a/libcelt/fixed_c6x.h +++ b/libcelt/fixed_c6x.h @@ -72,7 +72,7 @@ #define OVERRIDE_CELT_MAXABS16 #define OVERRIDE_FIND_MAX16 -static inline int find_max16(celt_word16_t *x, int len) +static inline int find_max16(celt_word16 *x, int len) { DATA max_corr16 = -VERY_LARGE16; DATA pitch16 = 0; diff --git a/libcelt/fixed_debug.h b/libcelt/fixed_debug.h index 9fe6523..8d447e1 100644 --- a/libcelt/fixed_debug.h +++ b/libcelt/fixed_debug.h @@ -46,14 +46,14 @@ extern long long celt_mips; #define MIPS_INC celt_mips++, -#define MULT16_16SU(a,b) ((celt_word32_t)(celt_word16_t)(a)*(celt_word32_t)(celt_uint16)(b)) +#define MULT16_16SU(a,b) ((celt_word32)(celt_word16)(a)*(celt_word32)(celt_uint16)(b)) #define MULT32_32_Q31(a,b) ADD32(ADD32(SHL32(MULT16_16(SHR32((a),16),SHR((b),16)),1), SHR32(MULT16_16SU(SHR32((a),16),((b)&0x0000ffff)),15)), SHR32(MULT16_16SU(SHR32((b),16),((a)&0x0000ffff)),15)) /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ #define MULT16_32_Q16(a,b) ADD32(MULT16_16((a),SHR32((b),16)), SHR32(MULT16_16SU((a),((b)&0x0000ffff)),16)) -#define QCONST16(x,bits) ((celt_word16_t)(.5+(x)*(((celt_word32_t)1)<<(bits)))) -#define QCONST32(x,bits) ((celt_word32_t)(.5+(x)*(((celt_word32_t)1)<<(bits)))) +#define QCONST16(x,bits) ((celt_word16)(.5+(x)*(((celt_word32)1)<<(bits)))) +#define QCONST32(x,bits) ((celt_word32)(.5+(x)*(((celt_word32)1)<<(bits)))) #define VERIFY_SHORT(x) ((x)<=32767&&(x)>=-32768) @@ -177,7 +177,7 @@ static inline int SHL32(long long a, int shift) } #define PSHR16(a,shift) (celt_mips--,SHR16(ADD16((a),((1<<((shift))>>1))),shift)) -#define PSHR32(a,shift) (celt_mips--,SHR32(ADD32((a),(((celt_word32_t)(1)<<((shift))>>1))),shift)) +#define PSHR32(a,shift) (celt_mips--,SHR32(ADD32((a),(((celt_word32)(1)<<((shift))>>1))),shift)) #define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift))) #define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) @@ -335,7 +335,7 @@ static inline int _MULT16_32_QX(int a, long long b, int Q, char *file, int line) { fprintf (stderr, "MULT16_32_Q%d: inputs are not short+int: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line); } - if (ABS32(b)>=((celt_word32_t)(1)<<(15+Q))) + if (ABS32(b)>=((celt_word32)(1)<<(15+Q))) fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line); res = (((long long)a)*(long long)b) >> Q; if (!VERIFY_INT(res)) @@ -354,9 +354,9 @@ static inline int MULT16_32_PX(int a, long long b, int Q) { fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d\n", Q, (int)a, (int)b); } - if (ABS32(b)>=((celt_word32_t)(1)<<(15+Q))) + if (ABS32(b)>=((celt_word32)(1)<<(15+Q))) fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d\n", Q, (int)a, (int)b); - res = ((((long long)a)*(long long)b) + (((celt_word32_t)(1)<>1))>> Q; + res = ((((long long)a)*(long long)b) + (((celt_word32)(1)<>1))>> Q; if (!VERIFY_INT(res)) fprintf (stderr, "MULT16_32_P%d: output is not int: %d*%d=%d\n", Q, (int)a, (int)b,(int)res); if (Q==15) diff --git a/libcelt/fixed_generic.h b/libcelt/fixed_generic.h index 5e9c94b..08ee0c5 100644 --- a/libcelt/fixed_generic.h +++ b/libcelt/fixed_generic.h @@ -38,7 +38,7 @@ #define FIXED_GENERIC_H /** Multiply a 16-bit signed value by a 16-bit unsigned value. The result is a 32-bit signed value */ -#define MULT16_16SU(a,b) ((celt_word32_t)(celt_word16_t)(a)*(celt_word32_t)(celt_uint16)(b)) +#define MULT16_16SU(a,b) ((celt_word32)(celt_word16)(a)*(celt_word32)(celt_uint16)(b)) /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ #define MULT16_32_Q16(a,b) ADD32(MULT16_16((a),SHR((b),16)), SHR(MULT16_16SU((a),((b)&0x0000ffff)),16)) @@ -53,9 +53,9 @@ #define MULT32_32_Q32(a,b) ADD32(ADD32(MULT16_16(SHR((a),16),SHR((b),16)), SHR(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),16)), SHR(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),16)) /** Compile-time conversion of float constant to 16-bit value */ -#define QCONST16(x,bits) ((celt_word16_t)(.5+(x)*(((celt_word32_t)1)<<(bits)))) +#define QCONST16(x,bits) ((celt_word16)(.5+(x)*(((celt_word32)1)<<(bits)))) /** Compile-time conversion of float constant to 32-bit value */ -#define QCONST32(x,bits) ((celt_word32_t)(.5+(x)*(((celt_word32_t)1)<<(bits)))) +#define QCONST32(x,bits) ((celt_word32)(.5+(x)*(((celt_word32)1)<<(bits)))) /** Negate a 16-bit value */ #define NEG16(x) (-(x)) @@ -63,9 +63,9 @@ #define NEG32(x) (-(x)) /** Change a 32-bit value into a 16-bit value. The value is assumed to fit in 16-bit, otherwise the result is undefined */ -#define EXTRACT16(x) ((celt_word16_t)(x)) +#define EXTRACT16(x) ((celt_word16)(x)) /** Change a 16-bit value into a 32-bit value */ -#define EXTEND32(x) ((celt_word32_t)(x)) +#define EXTEND32(x) ((celt_word32)(x)) /** Arithmetic shift-right of a 16-bit value */ #define SHR16(a,shift) ((a) >> (shift)) @@ -74,7 +74,7 @@ /** Arithmetic shift-right of a 32-bit value */ #define SHR32(a,shift) ((a) >> (shift)) /** Arithmetic shift-left of a 32-bit value */ -#define SHL32(a,shift) ((celt_word32_t)(a) << (shift)) +#define SHL32(a,shift) ((celt_word32)(a) << (shift)) /** 16-bit arithmetic shift right with rounding-to-nearest instead of rounding down */ #define PSHR16(a,shift) (SHR16((a)+((1<<((shift))>>1)),shift)) @@ -90,7 +90,7 @@ /** "RAW" macros, should not be used outside of this header file */ #define SHR(a,shift) ((a) >> (shift)) -#define SHL(a,shift) ((celt_word32_t)(a) << (shift)) +#define SHL(a,shift) ((celt_word32)(a) << (shift)) #define PSHR(a,shift) (SHR((a)+((EXTEND32(1)<<((shift))>>1)),shift)) #define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) @@ -100,21 +100,21 @@ #define HALF32(x) (SHR32(x,1)) /** Add two 16-bit values */ -#define ADD16(a,b) ((celt_word16_t)((celt_word16_t)(a)+(celt_word16_t)(b))) +#define ADD16(a,b) ((celt_word16)((celt_word16)(a)+(celt_word16)(b))) /** Subtract two 16-bit values */ -#define SUB16(a,b) ((celt_word16_t)(a)-(celt_word16_t)(b)) +#define SUB16(a,b) ((celt_word16)(a)-(celt_word16)(b)) /** Add two 32-bit values */ -#define ADD32(a,b) ((celt_word32_t)(a)+(celt_word32_t)(b)) +#define ADD32(a,b) ((celt_word32)(a)+(celt_word32)(b)) /** Subtract two 32-bit values */ -#define SUB32(a,b) ((celt_word32_t)(a)-(celt_word32_t)(b)) +#define SUB32(a,b) ((celt_word32)(a)-(celt_word32)(b)) /** 16x16 multiplication where the result fits in 16 bits */ -#define MULT16_16_16(a,b) ((((celt_word16_t)(a))*((celt_word16_t)(b)))) +#define MULT16_16_16(a,b) ((((celt_word16)(a))*((celt_word16)(b)))) -/* (celt_word32_t)(celt_word16_t) gives TI compiler a hint that it's 16x16->32 multiply */ +/* (celt_word32)(celt_word16) gives TI compiler a hint that it's 16x16->32 multiply */ /** 16x16 multiplication where the result fits in 32 bits */ -#define MULT16_16(a,b) (((celt_word32_t)(celt_word16_t)(a))*((celt_word32_t)(celt_word16_t)(b))) +#define MULT16_16(a,b) (((celt_word32)(celt_word16)(a))*((celt_word32)(celt_word16)(b))) /** 16x16 multiply-add where the result fits in 32 bits */ #define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b)))) @@ -150,12 +150,12 @@ #define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15)) /** Divide a 32-bit value by a 16-bit value. Result fits in 16 bits */ -#define DIV32_16(a,b) ((celt_word16_t)(((celt_word32_t)(a))/((celt_word16_t)(b)))) +#define DIV32_16(a,b) ((celt_word16)(((celt_word32)(a))/((celt_word16)(b)))) /** Divide a 32-bit value by a 16-bit value and round to nearest. Result fits in 16 bits */ -#define PDIV32_16(a,b) ((celt_word16_t)(((celt_word32_t)(a)+((celt_word16_t)(b)>>1))/((celt_word16_t)(b)))) +#define PDIV32_16(a,b) ((celt_word16)(((celt_word32)(a)+((celt_word16)(b)>>1))/((celt_word16)(b)))) /** Divide a 32-bit value by a 32-bit value. Result fits in 32 bits */ -#define DIV32(a,b) (((celt_word32_t)(a))/((celt_word32_t)(b))) +#define DIV32(a,b) (((celt_word32)(a))/((celt_word32)(b))) /** Divide a 32-bit value by a 32-bit value and round to nearest. Result fits in 32 bits */ -#define PDIV32(a,b) (((celt_word32_t)(a)+((celt_word16_t)(b)>>1))/((celt_word32_t)(b))) +#define PDIV32(a,b) (((celt_word32)(a)+((celt_word16)(b)>>1))/((celt_word32)(b))) #endif diff --git a/libcelt/kiss_fft.c b/libcelt/kiss_fft.c index 0a64c6c..63e9e81 100644 --- a/libcelt/kiss_fft.c +++ b/libcelt/kiss_fft.c @@ -633,7 +633,7 @@ kiss_fft_cfg kiss_fft_alloc(int nfft,void * mem,size_t * lenmem ) #endif #if defined(FIXED_POINT) && (!defined(DOUBLE_PRECISION) || defined(MIXED_PRECISION)) for (i=0;itwiddles+i, DIV32(SHL32(phase,17),nfft)); } #else diff --git a/libcelt/kiss_fftr.c b/libcelt/kiss_fftr.c index ee8d7bb..c98f349 100644 --- a/libcelt/kiss_fftr.c +++ b/libcelt/kiss_fftr.c @@ -63,7 +63,7 @@ kiss_fftr_cfg kiss_fftr_alloc(int nfft,void * mem,size_t * lenmem) #if defined (FIXED_POINT) && (!defined(DOUBLE_PRECISION) || defined(MIXED_PRECISION)) for (i=0;i>1); + celt_word32 phase = i+(nfft>>1); kf_cexp2(st->super_twiddles+i, DIV32(SHL32(phase,16),nfft)); } #else diff --git a/libcelt/mathops.h b/libcelt/mathops.h index f057650..62bdc7c 100644 --- a/libcelt/mathops.h +++ b/libcelt/mathops.h @@ -44,7 +44,7 @@ #ifndef OVERRIDE_CELT_ILOG2 /** Integer log in base2. Undefined for zero and negative numbers */ -static inline celt_int16 celt_ilog2(celt_word32_t x) +static inline celt_int16 celt_ilog2(celt_word32 x) { celt_assert2(x>0, "celt_ilog2() only defined for strictly positive numbers"); return EC_ILOG(x)-1; @@ -52,9 +52,9 @@ static inline celt_int16 celt_ilog2(celt_word32_t x) #endif #ifndef OVERRIDE_FIND_MAX16 -static inline int find_max16(celt_word16_t *x, int len) +static inline int find_max16(celt_word16 *x, int len) { - celt_word16_t max_corr=-VERY_LARGE16; + celt_word16 max_corr=-VERY_LARGE16; int i, id = 0; for (i=0;i>1; x = VSHR32(x, (k-7)<<1); /* Range of n is [-16384,32767] */ @@ -203,12 +203,12 @@ static inline celt_word32_t celt_rsqrt(celt_word32_t x) } /** Sqrt approximation (QX input, QX/2 output) */ -static inline celt_word32_t celt_sqrt(celt_word32_t x) +static inline celt_word32 celt_sqrt(celt_word32 x) { int k; - celt_word16_t n; - celt_word32_t rt; - const celt_word16_t C[5] = {23174, 11584, -3011, 1570, -557}; + celt_word16 n; + celt_word32 rt; + const celt_word16 C[5] = {23174, 11584, -3011, 1570, -557}; if (x==0) return 0; k = (celt_ilog2(x)>>1)-7; @@ -222,12 +222,12 @@ static inline celt_word32_t celt_sqrt(celt_word32_t x) /** Sqrt approximation (QX input, QX/2 output) that assumes that the input is strictly positive */ -static inline celt_word32_t celt_psqrt(celt_word32_t x) +static inline celt_word32 celt_psqrt(celt_word32 x) { int k; - celt_word16_t n; - celt_word32_t rt; - const celt_word16_t C[5] = {23174, 11584, -3011, 1570, -557}; + celt_word16 n; + celt_word32 rt; + const celt_word16 C[5] = {23174, 11584, -3011, 1570, -557}; k = (celt_ilog2(x)>>1)-7; x = VSHR32(x, (k<<1)); n = x-32768; @@ -242,9 +242,9 @@ static inline celt_word32_t celt_psqrt(celt_word32_t x) #define L3 8277 #define L4 -626 -static inline celt_word16_t _celt_cos_pi_2(celt_word16_t x) +static inline celt_word16 _celt_cos_pi_2(celt_word16 x) { - celt_word16_t x2; + celt_word16 x2; x2 = MULT16_16_P15(x,x); return ADD16(1,MIN16(32766,ADD32(SUB16(L1,x2), MULT16_16_P15(x2, ADD32(L2, MULT16_16_P15(x2, ADD32(L3, MULT16_16_P15(L4, x2 @@ -256,7 +256,7 @@ static inline celt_word16_t _celt_cos_pi_2(celt_word16_t x) #undef L3 #undef L4 -static inline celt_word16_t celt_cos_norm(celt_word32_t x) +static inline celt_word16 celt_cos_norm(celt_word32 x) { x = x&0x0001ffff; if (x>SHL32(EXTEND32(1), 16)) @@ -279,12 +279,12 @@ static inline celt_word16_t celt_cos_norm(celt_word32_t x) } } -static inline celt_word16_t celt_log2(celt_word32_t x) +static inline celt_word16 celt_log2(celt_word32 x) { int i; - celt_word16_t n, frac; + celt_word16 n, frac; /*-0.41446 0.96093 -0.33981 0.15600 */ - const celt_word16_t C[4] = {-6791, 7872, -1392, 319}; + const celt_word16 C[4] = {-6791, 7872, -1392, 319}; if (x==0) return -32767; i = celt_ilog2(x); @@ -304,10 +304,10 @@ static inline celt_word16_t celt_log2(celt_word32_t x) #define D2 3726 #define D3 1301 /** Base-2 exponential approximation (2^x). (Q11 input, Q16 output) */ -static inline celt_word32_t celt_exp2(celt_word16_t x) +static inline celt_word32 celt_exp2(celt_word16 x) { int integer; - celt_word16_t frac; + celt_word16 frac; integer = SHR16(x,11); if (integer>14) return 0x7f000000; @@ -319,11 +319,11 @@ static inline celt_word32_t celt_exp2(celt_word16_t x) } /** Reciprocal approximation (Q15 input, Q16 output) */ -static inline celt_word32_t celt_rcp(celt_word32_t x) +static inline celt_word32 celt_rcp(celt_word32 x) { int i; - celt_word16_t n, frac; - const celt_word16_t C[5] = {21848, -7251, 2403, -934, 327}; + celt_word16 n, frac; + const celt_word16 C[5] = {21848, -7251, 2403, -934, 327}; celt_assert2(x>0, "celt_rcp() only defined for positive values"); i = celt_ilog2(x); n = VSHR32(x,i-16)-SHL32(EXTEND32(3),15); @@ -332,7 +332,7 @@ static inline celt_word32_t celt_rcp(celt_word32_t x) return VSHR32(EXTEND32(frac),i-16); } -#define celt_div(a,b) MULT32_32_Q31((celt_word32_t)(a),celt_rcp(b)) +#define celt_div(a,b) MULT32_32_Q31((celt_word32)(a),celt_rcp(b)) #define M1 32767 @@ -340,7 +340,7 @@ static inline celt_word32_t celt_rcp(celt_word32_t x) #define M3 -11943 #define M4 4936 -static inline celt_word16_t celt_atan01(celt_word16_t x) +static inline celt_word16 celt_atan01(celt_word16 x) { return MULT16_16_P15(x, ADD32(M1, MULT16_16_P15(x, ADD32(M2, MULT16_16_P15(x, ADD32(M3, MULT16_16_P15(M4, x))))))); } @@ -350,17 +350,17 @@ static inline celt_word16_t celt_atan01(celt_word16_t x) #undef M3 #undef M4 -static inline celt_word16_t celt_atan2p(celt_word16_t y, celt_word16_t x) +static inline celt_word16 celt_atan2p(celt_word16 y, celt_word16 x) { if (y < x) { - celt_word32_t arg; + celt_word32 arg; arg = celt_div(SHL32(EXTEND32(y),15),x); if (arg >= 32767) arg = 32767; return SHR16(celt_atan01(EXTRACT16(arg)),1); } else { - celt_word32_t arg; + celt_word32 arg; arg = celt_div(SHL32(EXTEND32(x),15),y); if (arg >= 32767) arg = 32767; diff --git a/libcelt/mdct.c b/libcelt/mdct.c index a61d01f..c873fed 100644 --- a/libcelt/mdct.c +++ b/libcelt/mdct.c @@ -93,7 +93,7 @@ void mdct_clear(mdct_lookup *l) celt_free(l->trig); } -void mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const celt_word16_t *window, int overlap) +void mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const celt_word16 *window, int overlap) { int i; int N, N2, N4; @@ -111,8 +111,8 @@ void mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * r const kiss_fft_scalar * restrict xp1 = in+(overlap>>1); const kiss_fft_scalar * restrict xp2 = in+N2-1+(overlap>>1); kiss_fft_scalar * restrict yp = out; - const celt_word16_t * restrict wp1 = window+(overlap>>1); - const celt_word16_t * restrict wp2 = window+(overlap>>1)-1; + const celt_word16 * restrict wp1 = window+(overlap>>1); + const celt_word16 * restrict wp2 = window+(overlap>>1)-1; for(i=0;i<(overlap>>2);i++) { /* Real part arranged as -d-cR, Imag part arranged as -b+aR*/ @@ -184,7 +184,7 @@ void mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * r } -void mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const celt_word16_t * restrict window, int overlap) +void mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const celt_word16 * restrict window, int overlap) { int i; int N, N2, N4; @@ -252,8 +252,8 @@ void mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * kiss_fft_scalar * restrict fp1 = f2+N4-1; kiss_fft_scalar * restrict xp1 = out+N2-1; kiss_fft_scalar * restrict yp1 = out+N4-overlap/2; - const celt_word16_t * restrict wp1 = window; - const celt_word16_t * restrict wp2 = window+overlap-1; + const celt_word16 * restrict wp1 = window; + const celt_word16 * restrict wp2 = window+overlap-1; for(i = 0; i< N4-overlap/2; i++) { *xp1 = *fp1; @@ -274,8 +274,8 @@ void mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * kiss_fft_scalar * restrict fp2 = f2+N4; kiss_fft_scalar * restrict xp2 = out+N2; kiss_fft_scalar * restrict yp2 = out+N-1-(N4-overlap/2); - const celt_word16_t * restrict wp1 = window; - const celt_word16_t * restrict wp2 = window+overlap-1; + const celt_word16 * restrict wp1 = window; + const celt_word16 * restrict wp2 = window+overlap-1; for(i = 0; i< N4-overlap/2; i++) { *xp2 = *fp2; diff --git a/libcelt/mdct.h b/libcelt/mdct.h index 6bb3859..f05643f 100644 --- a/libcelt/mdct.h +++ b/libcelt/mdct.h @@ -59,10 +59,10 @@ void mdct_init(mdct_lookup *l,int N); void mdct_clear(mdct_lookup *l); /** Compute a forward MDCT and scale by 4/N */ -void mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const celt_word16_t *window, int overlap); +void mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const celt_word16 *window, int overlap); /** Compute a backward MDCT (no scaling) and performs weighted overlap-add (scales implicitly by 1/2) */ -void mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const celt_word16_t * restrict window, int overlap); +void mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const celt_word16 * restrict window, int overlap); #endif diff --git a/libcelt/modes.c b/libcelt/modes.c index af0d6ca..4411d6d 100644 --- a/libcelt/modes.c +++ b/libcelt/modes.c @@ -272,7 +272,7 @@ CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error) #else int res; CELTMode *mode=NULL; - celt_word16_t *window; + celt_word16 *window; ALLOC_STACK; #if !defined(VAR_ARRAYS) && !defined(USE_ALLOCA) if (global_stack==NULL) @@ -350,7 +350,7 @@ CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error) if (mode->allocVectors==NULL) goto failure; - window = (celt_word16_t*)celt_alloc(mode->overlap*sizeof(celt_word16_t)); + window = (celt_word16*)celt_alloc(mode->overlap*sizeof(celt_word16)); if (window==NULL) goto failure; @@ -450,7 +450,7 @@ void celt_mode_destroy(CELTMode *mode) celt_free((int*)mode->eBands); celt_free((int*)mode->allocVectors); - celt_free((celt_word16_t*)mode->window); + celt_free((celt_word16*)mode->window); #ifndef SHORTCUTS psydecay_clear(&mode->psy); diff --git a/libcelt/modes.h b/libcelt/modes.h index 4e99d69..b810370 100644 --- a/libcelt/modes.h +++ b/libcelt/modes.h @@ -89,7 +89,7 @@ struct CELTMode { const celt_int16 *eBands; /**< Definition for each "pseudo-critical band" */ - celt_word16_t ePredCoef;/**< Prediction coefficient for the energy encoding */ + celt_word16 ePredCoef;/**< Prediction coefficient for the energy encoding */ int nbAllocVectors; /**< Number of lines in the matrix below */ const celt_int16 *allocVectors; /**< Number of bits in each band for several rates */ @@ -100,12 +100,12 @@ struct CELTMode { mdct_lookup mdct; kiss_fftr_cfg fft; - const celt_word16_t *window; + const celt_word16 *window; int nbShortMdcts; int shortMdctSize; mdct_lookup shortMdct; - const celt_word16_t *shortWindow; + const celt_word16 *shortWindow; struct PsyDecay psy; diff --git a/libcelt/pitch.c b/libcelt/pitch.c index 7e06f45..413dc11 100644 --- a/libcelt/pitch.c +++ b/libcelt/pitch.c @@ -62,10 +62,10 @@ void pitch_state_free(kiss_fftr_cfg st) } #ifdef FIXED_POINT -static void normalise16(celt_word16_t *x, int len, celt_word16_t val) +static void normalise16(celt_word16 *x, int len, celt_word16 val) { int i; - celt_word16_t maxabs; + celt_word16 maxabs; maxabs = celt_maxabs16(x,len); if (maxabs > val) { @@ -105,18 +105,18 @@ static void normalise16(celt_word16_t *x, int len, celt_word16_t val) #define INPUT_SHIFT 15 -void find_spectral_pitch(const CELTMode *m, kiss_fftr_cfg fft, const struct PsyDecay *decay, const celt_sig_t * restrict x, const celt_sig_t * restrict y, const celt_word16_t * restrict window, celt_word16_t * restrict spectrum, int len, int max_pitch, int *pitch, int _C) +void find_spectral_pitch(const CELTMode *m, kiss_fftr_cfg fft, const struct PsyDecay *decay, const celt_sig * restrict x, const celt_sig * restrict y, const celt_word16 * restrict window, celt_word16 * restrict spectrum, int len, int max_pitch, int *pitch, int _C) { int c, i; - VARDECL(celt_word16_t, _X); - VARDECL(celt_word16_t, _Y); - const celt_word16_t * restrict wptr; + VARDECL(celt_word16, _X); + VARDECL(celt_word16, _Y); + const celt_word16 * restrict wptr; #ifndef SHORTCUTS - VARDECL(celt_mask_t, curve); + VARDECL(celt_mask, curve); #endif - celt_word16_t * restrict X, * restrict Y; - celt_word16_t * restrict Xptr, * restrict Yptr; - const celt_sig_t * restrict yptr; + celt_word16 * restrict X, * restrict Y; + celt_word16 * restrict Xptr, * restrict Yptr; + const celt_sig * restrict yptr; int n2; int L2; const int C = CHANNELS(_C); @@ -125,16 +125,16 @@ void find_spectral_pitch(const CELTMode *m, kiss_fftr_cfg fft, const struct PsyD SAVE_STACK; n2 = lag>>1; L2 = len>>1; - ALLOC(_X, lag, celt_word16_t); + ALLOC(_X, lag, celt_word16); X = _X; #ifndef SHORTCUTS - ALLOC(curve, n2, celt_mask_t); + ALLOC(curve, n2, celt_mask); #endif CELT_MEMSET(X,0,lag); /* Sum all channels of the current frame and copy into X in bit-reverse order */ for (c=0;cdecayR = decayR; if (decayR==NULL) return; @@ -77,15 +77,15 @@ void psydecay_init(struct PsyDecay *decay, int len, celt_int32 Fs) void psydecay_clear(struct PsyDecay *decay) { - celt_free((celt_word16_t *)decay->decayR); + celt_free((celt_word16 *)decay->decayR); /*celt_free(decay->decayL);*/ } #endif -static void spreading_func(const struct PsyDecay *d, celt_word32_t * restrict psd, int len) +static void spreading_func(const struct PsyDecay *d, celt_word32 * restrict psd, int len) { int i; - celt_word32_t mem; + celt_word32 mem; /* Compute right slope (-10 dB/Bark) */ mem=psd[0]; for (i=0;idecayR[i], d->decayR[i]); + celt_word16 decayL = MULT16_16_Q15(d->decayR[i], d->decayR[i]); /* psd = (1-decay)*psd + decay*mem */ psd[i] = EPSILON + psd[i] + MULT16_32_Q15(decayL,mem-psd[i]); mem = psd[i]; @@ -110,7 +110,7 @@ static void spreading_func(const struct PsyDecay *d, celt_word32_t * restrict ps { int start,end; int j; - celt_word32_t Esig=0, Emask=0; + celt_word32 Esig=0, Emask=0; start = (int)floor(fromBARK((float)i)*(2*len)/Fs); if (start<0) start = 0; @@ -131,7 +131,7 @@ static void spreading_func(const struct PsyDecay *d, celt_word32_t * restrict ps } /* Compute a marking threshold from the spectrum X. */ -void compute_masking(const struct PsyDecay *decay, celt_word16_t *X, celt_mask_t * restrict mask, int len) +void compute_masking(const struct PsyDecay *decay, celt_word16 *X, celt_mask * restrict mask, int len) { int i; int N; @@ -145,7 +145,7 @@ void compute_masking(const struct PsyDecay *decay, celt_word16_t *X, celt_mask_t } #ifdef EXP_PSY /* Not needed for now, but will be useful in the future */ -void compute_mdct_masking(const struct PsyDecay *decay, celt_word32_t *X, celt_word16_t *tonality, celt_word16_t *long_window, celt_mask_t *mask, int len) +void compute_mdct_masking(const struct PsyDecay *decay, celt_word32 *X, celt_word16 *tonality, celt_word16 *long_window, celt_mask *mask, int len) { int i; VARDECL(float, psd); @@ -164,11 +164,11 @@ void compute_mdct_masking(const struct PsyDecay *decay, celt_word32_t *X, celt_w RESTORE_STACK; } -void compute_tonality(const CELTMode *m, celt_word16_t * restrict X, celt_word16_t * mem, int len, celt_word16_t *tonality, int mdct_size) +void compute_tonality(const CELTMode *m, celt_word16 * restrict X, celt_word16 * mem, int len, celt_word16 *tonality, int mdct_size) { int i; - celt_word16_t norm_1; - celt_word16_t *mem2; + celt_word16 norm_1; + celt_word16 *mem2; int N = len>>2; mem2 = mem+2*N; @@ -177,7 +177,7 @@ void compute_tonality(const CELTMode *m, celt_word16_t * restrict X, celt_word16 tonality[0] = 1; for (i=1;i 2*len; @@ -86,14 +86,14 @@ void quant_prob_free(int *freq) celt_free(freq); } -unsigned quant_coarse_energy(const CELTMode *m, celt_word16_t *eBands, celt_word16_t *oldEBands, int budget, int intra, int *prob, celt_word16_t *error, ec_enc *enc, int _C) +unsigned quant_coarse_energy(const CELTMode *m, celt_word16 *eBands, celt_word16 *oldEBands, int budget, int intra, int *prob, celt_word16 *error, ec_enc *enc, int _C) { int i, c; unsigned bits; unsigned bits_used = 0; - celt_word16_t prev[2] = {0,0}; - celt_word16_t coef = m->ePredCoef; - celt_word16_t beta; + celt_word16 prev[2] = {0,0}; + celt_word16 coef = m->ePredCoef; + celt_word16 beta; const int C = CHANNELS(_C); if (intra) @@ -111,10 +111,10 @@ unsigned quant_coarse_energy(const CELTMode *m, celt_word16_t *eBands, celt_word c=0; do { int qi; - celt_word16_t q; /* dB */ - celt_word16_t x; /* dB */ - celt_word16_t f; /* Q8 */ - celt_word16_t mean = MULT16_16_Q15(Q15ONE-coef,eMeans[i]); + celt_word16 q; /* dB */ + celt_word16 x; /* dB */ + celt_word16 f; /* Q8 */ + celt_word16 mean = MULT16_16_Q15(Q15ONE-coef,eMeans[i]); x = eBands[i+c*m->nbEBands]; #ifdef FIXED_POINT f = x-mean -MULT16_16_Q15(coef,oldEBands[i+c*m->nbEBands])-prev[c]; @@ -145,7 +145,7 @@ unsigned quant_coarse_energy(const CELTMode *m, celt_word16_t *eBands, celt_word return bits_used; } -void quant_fine_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, celt_word16_t *error, int *fine_quant, ec_enc *enc, int _C) +void quant_fine_energy(const CELTMode *m, celt_ener *eBands, celt_word16 *oldEBands, celt_word16 *error, int *fine_quant, ec_enc *enc, int _C) { int i, c; const int C = CHANNELS(_C); @@ -159,7 +159,7 @@ void quant_fine_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *ol c=0; do { int q2; - celt_word16_t offset; + celt_word16 offset; #ifdef FIXED_POINT /* Has to be without rounding */ q2 = (error[i+c*m->nbEBands]+QCONST16(.5f,8))>>(8-fine_quant[i]); @@ -184,7 +184,7 @@ void quant_fine_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *ol eBands[i] = log2Amp(oldEBands[i]); } -void quant_energy_finalise(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, celt_word16_t *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int _C) +void quant_energy_finalise(const CELTMode *m, celt_ener *eBands, celt_word16 *oldEBands, celt_word16 *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int _C) { int i, prio, c; const int C = CHANNELS(_C); @@ -199,7 +199,7 @@ void quant_energy_finalise(const CELTMode *m, celt_ener_t *eBands, celt_word16_t c=0; do { int q2; - celt_word16_t offset; + celt_word16 offset; q2 = error[i+c*m->nbEBands]<0 ? 0 : 1; ec_enc_bits(enc, q2, 1); #ifdef FIXED_POINT @@ -220,13 +220,13 @@ void quant_energy_finalise(const CELTMode *m, celt_ener_t *eBands, celt_word16_t } } -void unquant_coarse_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, int budget, int intra, int *prob, ec_dec *dec, int _C) +void unquant_coarse_energy(const CELTMode *m, celt_ener *eBands, celt_word16 *oldEBands, int budget, int intra, int *prob, ec_dec *dec, int _C) { int i, c; unsigned bits; - celt_word16_t prev[2] = {0, 0}; - celt_word16_t coef = m->ePredCoef; - celt_word16_t beta; + celt_word16 prev[2] = {0, 0}; + celt_word16 coef = m->ePredCoef; + celt_word16 beta; const int C = CHANNELS(_C); if (intra) @@ -244,8 +244,8 @@ void unquant_coarse_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t c=0; do { int qi; - celt_word16_t q; - celt_word16_t mean = MULT16_16_Q15(Q15ONE-coef,eMeans[i]); + celt_word16 q; + celt_word16 mean = MULT16_16_Q15(Q15ONE-coef,eMeans[i]); /* If we didn't have enough bits to encode all the energy, just assume something safe. We allow slightly busting the budget here */ if (ec_dec_tell(dec, 0) - bits > budget) @@ -260,7 +260,7 @@ void unquant_coarse_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t } } -void unquant_fine_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, int *fine_quant, ec_dec *dec, int _C) +void unquant_fine_energy(const CELTMode *m, celt_ener *eBands, celt_word16 *oldEBands, int *fine_quant, ec_dec *dec, int _C) { int i, c; const int C = CHANNELS(_C); @@ -272,7 +272,7 @@ void unquant_fine_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t * c=0; do { int q2; - celt_word16_t offset; + celt_word16 offset; q2 = ec_dec_bits(dec, fine_quant[i]); #ifdef FIXED_POINT offset = SUB16(SHR16(SHL16(q2,8)+QCONST16(.5,8),fine_quant[i]),QCONST16(.5f,8)); @@ -286,7 +286,7 @@ void unquant_fine_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t * eBands[i] = log2Amp(oldEBands[i]); } -void unquant_energy_finalise(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int _C) +void unquant_energy_finalise(const CELTMode *m, celt_ener *eBands, celt_word16 *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int _C) { int i, prio, c; const int C = CHANNELS(_C); @@ -301,7 +301,7 @@ void unquant_energy_finalise(const CELTMode *m, celt_ener_t *eBands, celt_word16 c=0; do { int q2; - celt_word16_t offset; + celt_word16 offset; q2 = ec_dec_bits(dec, 1); #ifdef FIXED_POINT offset = SHR16(SHL16(q2,8)-QCONST16(.5,8),fine_quant[i]+1); diff --git a/libcelt/quant_bands.h b/libcelt/quant_bands.h index 28e0000..2c2c583 100644 --- a/libcelt/quant_bands.h +++ b/libcelt/quant_bands.h @@ -39,12 +39,12 @@ #include "entdec.h" #include "mathops.h" -static inline celt_word16_t amp2Log(celt_word32_t amp) +static inline celt_word16 amp2Log(celt_word32 amp) { return celt_log2(MAX32(QCONST32(.001f,14),SHL32(amp,2))); } -static inline celt_word32_t log2Amp(celt_word16_t lg) +static inline celt_word32 log2Amp(celt_word16 lg) { return PSHR32(celt_exp2(SHL16(lg,3)),4); } @@ -54,18 +54,18 @@ void quant_prob_free(int *freq); void compute_fine_allocation(const CELTMode *m, int *bits, int budget); -int intra_decision(celt_word16_t *eBands, celt_word16_t *oldEBands, int len); +int intra_decision(celt_word16 *eBands, celt_word16 *oldEBands, int len); -unsigned quant_coarse_energy(const CELTMode *m, celt_word16_t *eBands, celt_word16_t *oldEBands, int budget, int intra, int *prob, celt_word16_t *error, ec_enc *enc, int _C); +unsigned quant_coarse_energy(const CELTMode *m, celt_word16 *eBands, celt_word16 *oldEBands, int budget, int intra, int *prob, celt_word16 *error, ec_enc *enc, int _C); -void quant_fine_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, celt_word16_t *error, int *fine_quant, ec_enc *enc, int _C); +void quant_fine_energy(const CELTMode *m, celt_ener *eBands, celt_word16 *oldEBands, celt_word16 *error, int *fine_quant, ec_enc *enc, int _C); -void quant_energy_finalise(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, celt_word16_t *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int _C); +void quant_energy_finalise(const CELTMode *m, celt_ener *eBands, celt_word16 *oldEBands, celt_word16 *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int _C); -void unquant_coarse_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, int budget, int intra, int *prob, ec_dec *dec, int _C); +void unquant_coarse_energy(const CELTMode *m, celt_ener *eBands, celt_word16 *oldEBands, int budget, int intra, int *prob, ec_dec *dec, int _C); -void unquant_fine_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, int *fine_quant, ec_dec *dec, int _C); +void unquant_fine_energy(const CELTMode *m, celt_ener *eBands, celt_word16 *oldEBands, int *fine_quant, ec_dec *dec, int _C); -void unquant_energy_finalise(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int _C); +void unquant_energy_finalise(const CELTMode *m, celt_ener *eBands, celt_word16 *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int _C); #endif /* QUANT_BANDS */ diff --git a/libcelt/vq.c b/libcelt/vq.c index c7ece7d..e05ab87 100644 --- a/libcelt/vq.c +++ b/libcelt/vq.c @@ -45,13 +45,13 @@ #define M_PI 3.141592653 #endif -static void exp_rotation(celt_norm_t *X, int len, int dir, int stride, int K) +static void exp_rotation(celt_norm *X, int len, int dir, int stride, int K) { int i, k, iter; - celt_word16_t c, s; - celt_word16_t gain, theta; - celt_norm_t *Xptr; - gain = celt_div((celt_word32_t)MULT16_16(Q15_ONE,len),(celt_word32_t)(3+len+6*K)); + celt_word16 c, s; + celt_word16 gain, theta; + celt_norm *Xptr; + gain = celt_div((celt_word32)MULT16_16(Q15_ONE,len),(celt_word32)(3+len+6*K)); /* FIXME: Make that HALF16 instead of HALF32 */ theta = SUB16(Q15ONE, HALF32(MULT16_16_Q15(gain,gain))); /*if (len==30) @@ -72,7 +72,7 @@ static void exp_rotation(celt_norm_t *X, int len, int dir, int stride, int K) Xptr = X; for (i=0;i=0;i--) { - celt_norm_t x1, x2; + celt_norm x1, x2; x1 = Xptr[0]; x2 = Xptr[stride]; Xptr[stride] = MULT16_16_Q15(c,x2) + MULT16_16_Q15(s,x1); @@ -100,10 +100,10 @@ static void exp_rotation(celt_norm_t *X, int len, int dir, int stride, int K) /** Takes the pitch vector and the decoded residual vector, computes the gain that will give ||p+g*y||=1 and mixes the residual with the pitch. */ -static void normalise_residual(int * restrict iy, celt_norm_t * restrict X, int N, int K, celt_word32_t Ryy) +static void normalise_residual(int * restrict iy, celt_norm * restrict X, int N, int K, celt_word32 Ryy) { int i; - celt_word32_t g; + celt_word32 g; g = celt_rsqrt(Ryy); @@ -113,16 +113,16 @@ static void normalise_residual(int * restrict iy, celt_norm_t * restrict X, int while (++i < N); } -void alg_quant(celt_norm_t *X, int N, int K, int spread, ec_enc *enc) +void alg_quant(celt_norm *X, int N, int K, int spread, ec_enc *enc) { - VARDECL(celt_norm_t, y); + VARDECL(celt_norm, y); VARDECL(int, iy); - VARDECL(celt_word16_t, signx); + VARDECL(celt_word16, signx); int j, is; - celt_word16_t s; + celt_word16 s; int pulsesLeft; - celt_word32_t sum; - celt_word32_t xy, yy; + celt_word32 sum; + celt_word32 xy, yy; int N_1; /* Inverse of N, in Q14 format (even for float) */ #ifdef FIXED_POINT int yshift; @@ -134,9 +134,9 @@ void alg_quant(celt_norm_t *X, int N, int K, int spread, ec_enc *enc) yshift = 13-celt_ilog2(K); #endif - ALLOC(y, N, celt_norm_t); + ALLOC(y, N, celt_norm); ALLOC(iy, N, int); - ALLOC(signx, N, celt_word16_t); + ALLOC(signx, N, celt_word16); N_1 = 512/N; if (spread) @@ -161,7 +161,7 @@ void alg_quant(celt_norm_t *X, int N, int K, int spread, ec_enc *enc) /* Do a pre-search by projecting on the pyramid */ if (K > (N>>1)) { - celt_word16_t rcp; + celt_word16 rcp; sum=0; j=0; do { sum += X[j]; @@ -201,9 +201,9 @@ void alg_quant(celt_norm_t *X, int N, int K, int spread, ec_enc *enc) { int pulsesAtOnce=1; int best_id; - celt_word16_t magnitude; - celt_word32_t best_num = -VERY_LARGE16; - celt_word16_t best_den = 0; + celt_word16 magnitude; + celt_word32 best_num = -VERY_LARGE16; + celt_word16 best_den = 0; #ifdef FIXED_POINT int rshift; #endif @@ -224,7 +224,7 @@ void alg_quant(celt_norm_t *X, int N, int K, int spread, ec_enc *enc) /* This should ensure that anything we can process will have a better score */ j=0; do { - celt_word16_t Rxy, Ryy; + celt_word16 Rxy, Ryy; /* Select sign based on X[j] alone */ s = magnitude; /* Temporary sums of the new pulse(s) */ @@ -280,10 +280,10 @@ void alg_quant(celt_norm_t *X, int N, int K, int spread, ec_enc *enc) /** Decode pulse vector and combine the result with the pitch vector to produce the final normalised signal in the current band. */ -void alg_unquant(celt_norm_t *X, int N, int K, int spread, ec_dec *dec) +void alg_unquant(celt_norm *X, int N, int K, int spread, ec_dec *dec) { int i; - celt_word32_t Ryy; + celt_word32 Ryy; VARDECL(int, iy); SAVE_STACK; K = get_pulses(K); @@ -300,13 +300,13 @@ void alg_unquant(celt_norm_t *X, int N, int K, int spread, ec_dec *dec) RESTORE_STACK; } -celt_word16_t renormalise_vector(celt_norm_t *X, celt_word16_t value, int N, int stride) +celt_word16 renormalise_vector(celt_norm *X, celt_word16 value, int N, int stride) { int i; - celt_word32_t E = EPSILON; - celt_word16_t rE; - celt_word16_t g; - celt_norm_t *xptr = X; + celt_word32 E = EPSILON; + celt_word16 rE; + celt_word16 g; + celt_norm *xptr = X; for (i=0;i .001 && fabs(val-sqrt(i)) > 2) @@ -62,7 +62,7 @@ void testrsqrt(void) for (i=1;i<=2000000;i++) { double ratio; - celt_word16_t val; + celt_word16 val; val = celt_rsqrt(i); ratio = val*sqrt(i)/Q15ONE; if (fabs(ratio - 1) > .05) @@ -119,10 +119,10 @@ void testexp2log2(void) #else void testilog2(void) { - celt_word32_t x; + celt_word32 x; for (x=1;x<=268435455;x+=127) { - celt_word32_t error = abs(celt_ilog2(x)-(int)floor(log2(x))); + celt_word32 error = abs(celt_ilog2(x)-(int)floor(log2(x))); if (error!=0) { printf("celt_ilog2 failed: celt_ilog2(x)!=floor(log2(x)) (x = %d, error = %d)\n",x,error); diff --git a/tests/mdct-test.c b/tests/mdct-test.c index ba9e9ec..61008c8 100644 --- a/tests/mdct-test.c +++ b/tests/mdct-test.c @@ -86,7 +86,7 @@ void test1d(int nfft,int isinverse) kiss_fft_scalar * in = (kiss_fft_scalar*)malloc(buflen); kiss_fft_scalar * out= (kiss_fft_scalar*)malloc(buflen); - celt_word16_t * window= (celt_word16_t*)malloc(sizeof(celt_word16_t)*nfft/2); + celt_word16 * window= (celt_word16*)malloc(sizeof(celt_word16)*nfft/2); int k; mdct_init(&cfg, nfft); diff --git a/tests/rotation-test.c b/tests/rotation-test.c index b66154f..164a6ea 100644 --- a/tests/rotation-test.c +++ b/tests/rotation-test.c @@ -14,8 +14,8 @@ void test_rotation(int N, int K) { int i; double err = 0, ener = 0, snr, snr0; - celt_word16_t x0[MAX_SIZE]; - celt_word16_t x1[MAX_SIZE]; + celt_word16 x0[MAX_SIZE]; + celt_word16 x1[MAX_SIZE]; int nb_rotations = (N+4*K)/(8*K); for (i=0;i