diff --git a/libcelt/_kiss_fft_guts.h b/libcelt/_kiss_fft_guts.h index a4976832396e7b838a991c94920c23e3d54229f6..4b5f4f70d3123c981f6bb174f8e39acba49a9738 100644 --- a/libcelt/_kiss_fft_guts.h +++ b/libcelt/_kiss_fft_guts.h @@ -55,7 +55,7 @@ struct kiss_fft_state{ #ifdef DOUBLE_PRECISION # define FRACBITS 31 -# define SAMPPROD celt_int64_t +# define SAMPPROD long long #define SAMP_MAX 2147483647 #ifdef MIXED_PRECISION #define TWID_MAX 32767 @@ -69,7 +69,7 @@ struct kiss_fft_state{ #else /* DOUBLE_PRECISION */ # define FRACBITS 15 -# define SAMPPROD celt_int32_t +# define SAMPPROD celt_int32 #define SAMP_MAX 32767 #define TRIG_UPSCALE 1 #define EXT32(a) EXTEND32(a) diff --git a/libcelt/arch.h b/libcelt/arch.h index 0a06f21ea3d2abc5970452978758e7683cbd6d68..7eef2080256d14fe0c80a4fd684b45035d6e4003 100644 --- a/libcelt/arch.h +++ b/libcelt/arch.h @@ -49,8 +49,8 @@ #endif #define IMUL32(a,b) ((a)*(b)) -#define UMUL32(a,b) ((celt_int32_t)(a)*(celt_int32_t)(b)) -#define UMUL16_16(a,b) ((celt_int32_t)(a)*(celt_int32_t)(b)) +#define UMUL32(a,b) ((celt_int32)(a)*(celt_int32)(b)) +#define UMUL16_16(a,b) ((celt_int32)(a)*(celt_int32)(b)) #define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */ #define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */ @@ -68,8 +68,8 @@ #ifdef FIXED_POINT -typedef celt_int16_t celt_word16_t; -typedef celt_int32_t celt_word32_t; +typedef celt_int16 celt_word16_t; +typedef celt_int32 celt_word32_t; typedef celt_word32_t celt_sig_t; typedef celt_word16_t celt_norm_t; diff --git a/libcelt/bands.c b/libcelt/bands.c index 7024487784e784c07d2f3e80177422178f860161..0c1b9f762fbb9f50c4b755f0fbc75b53e83e7f90 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -49,7 +49,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *bank, int _C) { int i, c, N; - const celt_int16_t *eBands = m->eBands; + const celt_int16 *eBands = m->eBands; const int C = CHANNELS(_C); N = FRAMESIZE(m); for (c=0;c<C;c++) @@ -88,7 +88,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t * void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_norm_t * restrict X, const celt_ener_t *bank, int _C) { int i, c, N; - const celt_int16_t *eBands = m->eBands; + const celt_int16 *eBands = m->eBands; const int C = CHANNELS(_C); N = FRAMESIZE(m); for (c=0;c<C;c++) @@ -112,7 +112,7 @@ void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_n void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *bank, int _C) { int i, c, N; - const celt_int16_t *eBands = m->eBands; + const celt_int16 *eBands = m->eBands; const int C = CHANNELS(_C); N = FRAMESIZE(m); for (c=0;c<C;c++) @@ -134,7 +134,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t * void compute_noise_energies(const CELTMode *m, const celt_sig_t *X, const celt_word16_t *tonality, celt_ener_t *bank, int _C) { int i, c, N; - const celt_int16_t *eBands = m->eBands; + const celt_int16 *eBands = m->eBands; const int C = CHANNELS(_C); N = FRAMESIZE(m); for (c=0;c<C;c++) @@ -157,7 +157,7 @@ void compute_noise_energies(const CELTMode *m, const celt_sig_t *X, const celt_w void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_norm_t * restrict X, const celt_ener_t *bank, int _C) { int i, c, N; - const celt_int16_t *eBands = m->eBands; + const celt_int16 *eBands = m->eBands; const int C = CHANNELS(_C); N = FRAMESIZE(m); for (c=0;c<C;c++) @@ -177,7 +177,7 @@ void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_n void renormalise_bands(const CELTMode *m, celt_norm_t * restrict X, int _C) { int i, c; - const celt_int16_t *eBands = m->eBands; + const celt_int16 *eBands = m->eBands; const int C = CHANNELS(_C); for (c=0;c<C;c++) { @@ -191,7 +191,7 @@ void renormalise_bands(const CELTMode *m, celt_norm_t * restrict X, int _C) void denormalise_bands(const CELTMode *m, const celt_norm_t * restrict X, celt_sig_t * restrict freq, const celt_ener_t *bank, int _C) { int i, c, N; - const celt_int16_t *eBands = m->eBands; + const celt_int16 *eBands = m->eBands; const int C = CHANNELS(_C); N = FRAMESIZE(m); if (C>2) @@ -333,7 +333,7 @@ void apply_pitch(const CELTMode *m, celt_sig_t *X, const celt_sig_t *P, int gain static void stereo_band_mix(const CELTMode *m, celt_norm_t *X, celt_norm_t *Y, const celt_ener_t *bank, int stereo_mode, int bandID, int dir) { int i = bandID; - const celt_int16_t *eBands = m->eBands; + const celt_int16 *eBands = m->eBands; int j; celt_word16_t a1, a2; if (stereo_mode==0) @@ -372,7 +372,7 @@ int folding_decision(const CELTMode *m, celt_norm_t *X, celt_word16_t *average, int NR=0; celt_word32_t ratio = EPSILON; const int C = CHANNELS(_C); - const celt_int16_t * restrict eBands = m->eBands; + const celt_int16 * restrict eBands = m->eBands; N0 = FRAMESIZE(m); @@ -440,7 +440,7 @@ int folding_decision(const CELTMode *m, celt_norm_t *X, celt_word16_t *average, 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) { int i, j, remaining_bits, balance; - const celt_int16_t * restrict eBands = m->eBands; + const celt_int16 * restrict eBands = m->eBands; celt_norm_t * restrict norm; VARDECL(celt_norm_t, _norm); int B; @@ -457,7 +457,7 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, const celt_ener_t int N; int q; celt_word16_t n; - const celt_int16_t * const *BPbits; + const celt_int16 * const *BPbits; int curr_balance, curr_bits; @@ -510,7 +510,7 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, const celt_ener_t 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) { int i, j, remaining_bits, balance; - const celt_int16_t * restrict eBands = m->eBands; + const celt_int16 * restrict eBands = m->eBands; celt_norm_t * restrict norm; VARDECL(celt_norm_t, _norm); int B; @@ -528,7 +528,7 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *b int tell; int q1, q2; celt_word16_t n; - const celt_int16_t * const *BPbits; + const celt_int16 * const *BPbits; int b, qb; int N; int curr_balance, curr_bits; @@ -741,7 +741,7 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *b 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) { int i, j, remaining_bits, balance; - const celt_int16_t * restrict eBands = m->eBands; + const celt_int16 * restrict eBands = m->eBands; celt_norm_t * restrict norm; VARDECL(celt_norm_t, _norm); int B; @@ -759,7 +759,7 @@ void unquant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t int tell; int q1, q2; celt_word16_t n; - const celt_int16_t * const *BPbits; + const celt_int16 * const *BPbits; int b, qb; int N; int curr_balance, curr_bits; diff --git a/libcelt/c64_fft.c b/libcelt/c64_fft.c index aaf89c4177409fce23aa793f9aa94807cd7925bb..07b77d6d8bb238726de98e6e3b304d43e8c15747 100644 --- a/libcelt/c64_fft.c +++ b/libcelt/c64_fft.c @@ -161,7 +161,7 @@ static c64_fft_t *cache32[NBCACHE] = {NULL,}; c64_fft_t *c64_fft16_alloc(int length, int x, int y) { c64_fft_t *state; - celt_int16_t *w, *iw; + celt_int16 *w, *iw; int i, c; @@ -175,13 +175,13 @@ c64_fft_t *c64_fft16_alloc(int length, int x, int y) state = (c64_fft_t *)celt_alloc(sizeof(c64_fft_t)); state->shift = log(length)/log(2) - ceil(log(length)/log(4)-1); state->nfft = length; - state->twiddle = celt_alloc(length*2*sizeof(celt_int16_t)); - state->itwiddle = celt_alloc(length*2*sizeof(celt_int16_t)); + state->twiddle = celt_alloc(length*2*sizeof(celt_int16)); + state->itwiddle = celt_alloc(length*2*sizeof(celt_int16)); - gen_twiddle16((celt_int16_t *)state->twiddle, length, 32767.0); + gen_twiddle16((celt_int16 *)state->twiddle, length, 32767.0); - w = (celt_int16_t *)state->twiddle; - iw = (celt_int16_t *)state->itwiddle; + w = (celt_int16 *)state->twiddle; + iw = (celt_int16 *)state->itwiddle; for (i = 0; i < length; i++) { iw[2*i+0] = w[2*i+0]; @@ -212,8 +212,8 @@ c64_fft_t *c64_fft32_alloc(int length, int x, int y) state = (c64_fft_t *)celt_alloc(sizeof(c64_fft_t)); state->shift = log(length)/log(2) - ceil(log(length)/log(4)-1); state->nfft = length; - state->twiddle = celt_alloc(length*2*sizeof(celt_int32_t)); - state->itwiddle = celt_alloc(length*2*sizeof(celt_int32_t)); + state->twiddle = celt_alloc(length*2*sizeof(celt_int32)); + state->itwiddle = celt_alloc(length*2*sizeof(celt_int32)); // Generate the inverse twiddle first because it does not need scaling gen_twiddle32(state->itwiddle, length, 2147483647.000000000); @@ -243,22 +243,22 @@ void c64_fft32_free(c64_fft_t *state) } -void c64_fft16_inplace(c64_fft_t * restrict state, celt_int16_t *X) +void c64_fft16_inplace(c64_fft_t * restrict state, celt_int16 *X) { int i; - VARDECL(celt_int16_t, cin); - VARDECL(celt_int16_t, cout); + VARDECL(celt_int16, cin); + VARDECL(celt_int16, cout); SAVE_STACK; - ALLOC(cin, state->nfft*2, celt_int16_t); - ALLOC(cout, state->nfft*2, celt_int16_t); + ALLOC(cin, state->nfft*2, celt_int16); + ALLOC(cout, state->nfft*2, celt_int16); for (i = 0; i < state->nfft; i++) { cin[2*i+0] = X[2*i+0]; cin[2*i+1] = X[2*i+1]; } - DSP_fft16x16t((celt_int16_t *)state->twiddle, state->nfft, cin, cout); + DSP_fft16x16t((celt_int16 *)state->twiddle, state->nfft, cin, cout); for (i = 0; i < state->nfft; i++) { X[2*i+0] = cout[2*i+0]; @@ -270,12 +270,12 @@ void c64_fft16_inplace(c64_fft_t * restrict state, celt_int16_t *X) -void c64_fft32(c64_fft_t * restrict state, const celt_int32_t *X, celt_int32_t *Y) +void c64_fft32(c64_fft_t * restrict state, const celt_int32 *X, celt_int32 *Y) { int i; - VARDECL(celt_int32_t, cin); + VARDECL(celt_int32, cin); SAVE_STACK; - ALLOC(cin, state->nfft*2, celt_int32_t); + ALLOC(cin, state->nfft*2, celt_int32); for (i = 0; i < state->nfft; i++) { cin[2*i+0] = X[2*i+0] >> state->shift; @@ -288,16 +288,16 @@ void c64_fft32(c64_fft_t * restrict state, const celt_int32_t *X, celt_int32_t * } -void c64_ifft16(c64_fft_t * restrict state, const celt_int16_t *X, celt_int16_t *Y) +void c64_ifft16(c64_fft_t * restrict state, const celt_int16 *X, celt_int16 *Y) { int i; - VARDECL(celt_int16_t, cin); - VARDECL(celt_int16_t, cout); + VARDECL(celt_int16, cin); + VARDECL(celt_int16, cout); SAVE_STACK; - ALLOC(cin, state->nfft*2, celt_int16_t); - if ((celt_int32_t)Y & 7) - ALLOC(cout, state->nfft*2, celt_int16_t); + ALLOC(cin, state->nfft*2, celt_int16); + if ((celt_int32)Y & 7) + ALLOC(cout, state->nfft*2, celt_int16); else cout = Y; @@ -308,9 +308,9 @@ void c64_ifft16(c64_fft_t * restrict state, const celt_int16_t *X, celt_int16_t cin[2*i+1] = X[2*i+1]; } - DSP_fft16x16t((celt_int16_t *)state->itwiddle, state->nfft, cin, cout); + DSP_fft16x16t((celt_int16 *)state->itwiddle, state->nfft, cin, cout); - if ((celt_int32_t)Y & 7) + if ((celt_int32)Y & 7) for (i = 0; i < state->nfft; i++) { Y[2*i+0] = cout[2*i+0]; Y[2*i+1] = cout[2*i+1]; @@ -320,12 +320,12 @@ void c64_ifft16(c64_fft_t * restrict state, const celt_int16_t *X, celt_int16_t } -void c64_ifft32(c64_fft_t * restrict state, const celt_int32_t *X, celt_int32_t *Y) +void c64_ifft32(c64_fft_t * restrict state, const celt_int32 *X, celt_int32 *Y) { int i; - VARDECL(celt_int32_t, cin); + VARDECL(celt_int32, cin); SAVE_STACK; - ALLOC(cin, state->nfft*2, celt_int32_t); + ALLOC(cin, state->nfft*2, celt_int32); celt_assert(Y & 7 == 0); diff --git a/libcelt/c64_fft.h b/libcelt/c64_fft.h index 9456e7c945e6a12744269e9389afe398617df496..981bfb601893e79012a7d6c2f007b56083e65ad4 100644 --- a/libcelt/c64_fft.h +++ b/libcelt/c64_fft.h @@ -41,18 +41,18 @@ typedef struct { int nfft; int shift; - celt_int32_t *twiddle; - celt_int32_t *itwiddle; + celt_int32 *twiddle; + celt_int32 *itwiddle; } c64_fft_t; extern c64_fft_t *c64_fft16_alloc(int length, int x, int y); extern void c64_fft16_free(c64_fft_t *state); -extern void c64_fft16_inplace(c64_fft_t *state, celt_int16_t *X); -extern void c64_ifft16(c64_fft_t *state, const celt_int16_t *X, celt_int16_t *Y); +extern void c64_fft16_inplace(c64_fft_t *state, celt_int16 *X); +extern void c64_ifft16(c64_fft_t *state, const celt_int16 *X, celt_int16 *Y); extern c64_fft_t *c64_fft32_alloc(int length, int x, int y); extern void c64_fft32_free(c64_fft_t *state); -extern void c64_fft32(c64_fft_t *state, const celt_int32_t *X, celt_int32_t *Y); -extern void c64_ifft32(c64_fft_t *state, const celt_int32_t *X, celt_int32_t *Y); +extern void c64_fft32(c64_fft_t *state, const celt_int32 *X, celt_int32 *Y); +extern void c64_ifft32(c64_fft_t *state, const celt_int32 *X, celt_int32 *Y); #endif diff --git a/libcelt/celt.c b/libcelt/celt.c index e7872dacdbc6791f8666c5233bf58ec8b1645065..fded6557d3e3353e743a95495c5f2412a5253460 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -74,7 +74,7 @@ static const float transientWindow[16] = { @brief Encoder state */ struct CELTEncoder { - celt_uint32_t marker; + celt_uint32 marker; const CELTMode *mode; /**< Mode used by the encoder */ int frame_size; int block_size; @@ -237,12 +237,12 @@ void celt_encoder_destroy(CELTEncoder *st) celt_free(st); } -static inline celt_int16_t FLOAT2INT16(float x) +static inline celt_int16 FLOAT2INT16(float x) { x = x*CELT_SIG_SCALE; x = MAX32(x, -32768); x = MIN32(x, 32767); - return (celt_int16_t)float2int(x); + return (celt_int16)float2int(x); } static inline celt_word16_t SIG2WORD16(celt_sig_t x) @@ -517,7 +517,7 @@ static void mdct_shape(const CELTMode *mode, celt_norm_t *X, int start, int end, #ifdef FIXED_POINT -int celt_encode(CELTEncoder * restrict st, const celt_int16_t * pcm, celt_int16_t * optional_synthesis, unsigned char *compressed, int nbCompressedBytes) +int celt_encode(CELTEncoder * restrict st, const celt_int16 * pcm, celt_int16 * optional_synthesis, unsigned char *compressed, int nbCompressedBytes) { #else int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_sig_t * optional_synthesis, unsigned char *compressed, int nbCompressedBytes) @@ -630,7 +630,7 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si compute_mdcts(st->mode, shortBlocks, in, freq, C); - norm_rate = (nbCompressedBytes-5)*8*(celt_uint32_t)st->mode->Fs/(C*N)>>10; + norm_rate = (nbCompressedBytes-5)*8*(celt_uint32)st->mode->Fs/(C*N)>>10; /* Pitch analysis: we do it early to save on the peak stack space */ /* Don't use pitch if there isn't enough data available yet, or if we're using shortBlocks */ @@ -834,7 +834,7 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si int celt_encode_float(CELTEncoder * restrict st, const float * pcm, float * optional_synthesis, unsigned char *compressed, int nbCompressedBytes) { int j, ret, C, N; - VARDECL(celt_int16_t, in); + VARDECL(celt_int16, in); SAVE_STACK; if (check_encoder(st) != CELT_OK) @@ -848,7 +848,7 @@ int celt_encode_float(CELTEncoder * restrict st, const float * pcm, float * opti C = CHANNELS(st->channels); N = st->block_size; - ALLOC(in, C*N, celt_int16_t); + ALLOC(in, C*N, celt_int16); for (j=0;j<C*N;j++) in[j] = FLOAT2INT16(pcm[j]); @@ -866,7 +866,7 @@ int celt_encode_float(CELTEncoder * restrict st, const float * pcm, float * opti } #endif /*DISABLE_FLOAT_API*/ #else -int celt_encode(CELTEncoder * restrict st, const celt_int16_t * pcm, celt_int16_t * optional_synthesis, unsigned char *compressed, int nbCompressedBytes) +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); @@ -922,7 +922,7 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...) break; case CELT_SET_COMPLEXITY_REQUEST: { - int value = va_arg(ap, celt_int32_t); + int value = va_arg(ap, celt_int32); if (value<0 || value>10) goto bad_arg; if (value<=2) { @@ -937,7 +937,7 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...) break; case CELT_SET_PREDICTION_REQUEST: { - int value = va_arg(ap, celt_int32_t); + int value = va_arg(ap, celt_int32); if (value<0 || value>2) goto bad_arg; if (value==0) @@ -955,7 +955,7 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...) break; case CELT_SET_VBR_RATE_REQUEST: { - celt_int32_t value = va_arg(ap, celt_int32_t); + celt_int32 value = va_arg(ap, celt_int32); if (value<0) goto bad_arg; if (value>3072000) @@ -1016,7 +1016,7 @@ bad_request: @brief Decoder state */ struct CELTDecoder { - celt_uint32_t marker; + celt_uint32 marker; const CELTMode *mode; int frame_size; int block_size; @@ -1212,7 +1212,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16_t * restrict #endif #ifdef FIXED_POINT -int celt_decode(CELTDecoder * restrict st, const unsigned char *data, int len, celt_int16_t * restrict pcm) +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) @@ -1364,7 +1364,7 @@ int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int len, float * restrict pcm) { int j, ret, C, N; - VARDECL(celt_int16_t, out); + VARDECL(celt_int16, out); SAVE_STACK; if (check_decoder(st) != CELT_OK) @@ -1379,7 +1379,7 @@ int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int C = CHANNELS(st->channels); N = st->block_size; - ALLOC(out, C*N, celt_int16_t); + ALLOC(out, C*N, celt_int16); ret=celt_decode(st, data, len, out); for (j=0;j<C*N;j++) pcm[j]=out[j]*(1/32768.); @@ -1389,7 +1389,7 @@ int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int } #endif /*DISABLE_FLOAT_API*/ #else -int celt_decode(CELTDecoder * restrict st, const unsigned char *data, int len, celt_int16_t * restrict pcm) +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); diff --git a/libcelt/celt.h b/libcelt/celt.h index 05f75155a2e5c0b03217cfd5dfa1419bf5485b06..7f70b39b236e3cfd7d9c9bd07555e94614393ff6 100644 --- a/libcelt/celt.h +++ b/libcelt/celt.h @@ -51,7 +51,7 @@ extern "C" { #define EXPORT #endif -#define _celt_check_int(x) (((void)((x) == (celt_int32_t)0)), (celt_int32_t)(x)) +#define _celt_check_int(x) (((void)((x) == (celt_int32)0)), (celt_int32)(x)) #define _celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (CELTMode**)(ptr))) /* Error codes */ @@ -138,7 +138,7 @@ typedef struct CELTMode CELTMode; @param error Returned error code (if NULL, no error will be returned) @return A newly created mode */ -EXPORT CELTMode *celt_mode_create(celt_int32_t Fs, int frame_size, int *error); +EXPORT CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error); /** Destroys a mode struct. Only call this after all encoders and decoders using this mode are destroyed as well. @@ -147,7 +147,7 @@ EXPORT CELTMode *celt_mode_create(celt_int32_t Fs, int frame_size, int *error); EXPORT void celt_mode_destroy(CELTMode *mode); /** Query information from a mode */ -EXPORT int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value); +EXPORT int celt_mode_info(const CELTMode *mode, int request, celt_int32 *value); /* Encoder stuff */ @@ -208,7 +208,7 @@ EXPORT int celt_encode_float(CELTEncoder *st, const float *pcm, float *optional_ * the length returned be somehow transmitted to the decoder. Otherwise, no * decoding is possible. */ -EXPORT int celt_encode(CELTEncoder *st, const celt_int16_t *pcm, celt_int16_t *optional_synthesis, unsigned char *compressed, int nbCompressedBytes); +EXPORT int celt_encode(CELTEncoder *st, const celt_int16 *pcm, celt_int16 *optional_synthesis, unsigned char *compressed, int nbCompressedBytes); /** Query and set encoder parameters @param st Encoder state @@ -254,7 +254,7 @@ EXPORT int celt_decode_float(CELTDecoder *st, const unsigned char *data, int len returned here in 16-bit PCM format (native endian). @return Error code. */ -EXPORT int celt_decode(CELTDecoder *st, const unsigned char *data, int len, celt_int16_t *pcm); +EXPORT int celt_decode(CELTDecoder *st, const unsigned char *data, int len, celt_int16 *pcm); /** Query and set decoder parameters @param st Decoder state diff --git a/libcelt/celt_header.h b/libcelt/celt_header.h index a4a0c8ea362c9991dff078b49758ed71320e7d9a..0bb5fa5008ad55dfc1c2298f59d14560be96285d 100644 --- a/libcelt/celt_header.h +++ b/libcelt/celt_header.h @@ -45,22 +45,22 @@ extern "C" { typedef struct { char codec_id[8]; /**< MUST be "CELT " (four spaces) */ char codec_version[20]; /**< Version used (as string) */ - celt_int32_t version_id; /**< Version id (negative for until stream is frozen) */ - celt_int32_t header_size; /**< Size of this header */ - celt_int32_t sample_rate; /**< Sampling rate of the original audio */ - celt_int32_t nb_channels; /**< Number of channels */ - celt_int32_t frame_size; /**< Samples per frame (per channel) */ - celt_int32_t overlap; /**< Overlapping samples (per channel) */ - celt_int32_t bytes_per_packet; /**< Number of bytes per compressed packet (0 if unknown) */ - celt_int32_t extra_headers; /**< Number of additional headers that follow this header */ + celt_int32 version_id; /**< Version id (negative for until stream is frozen) */ + celt_int32 header_size; /**< Size of this header */ + celt_int32 sample_rate; /**< Sampling rate of the original audio */ + celt_int32 nb_channels; /**< Number of channels */ + celt_int32 frame_size; /**< Samples per frame (per channel) */ + celt_int32 overlap; /**< Overlapping samples (per channel) */ + celt_int32 bytes_per_packet; /**< Number of bytes per compressed packet (0 if unknown) */ + celt_int32 extra_headers; /**< Number of additional headers that follow this header */ } CELTHeader; /** Creates a basic header struct */ EXPORT int celt_header_init(CELTHeader *header, const CELTMode *m, int channels); -EXPORT int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32_t size); +EXPORT int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32 size); -EXPORT int celt_header_from_packet(const unsigned char *packet, celt_uint32_t size, CELTHeader *header); +EXPORT int celt_header_from_packet(const unsigned char *packet, celt_uint32 size, CELTHeader *header); #ifdef __cplusplus } diff --git a/libcelt/celt_types.h b/libcelt/celt_types.h index b6a4fd7add2ac835be67302e1039c2106b75d2ce..fecd457564cc37912a15af2fb949f383055b9ff3 100644 --- a/libcelt/celt_types.h +++ b/libcelt/celt_types.h @@ -26,142 +26,114 @@ #if (defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) || defined (HAVE_STDINT_H)) #include <stdint.h> - typedef int16_t celt_int16_t; - typedef uint16_t celt_uint16_t; - typedef int32_t celt_int32_t; - typedef uint32_t celt_uint32_t; - typedef int64_t celt_int64_t; - typedef uint64_t celt_uint64_t; + typedef int16_t celt_int16; + typedef uint16_t celt_uint16; + typedef int32_t celt_int32; + typedef uint32_t celt_uint32; #elif defined(_WIN32) # if defined(__CYGWIN__) # include <_G_config.h> - typedef _G_int32_t celt_int32_t; - typedef _G_uint32_t celt_uint32_t; - typedef _G_int16_t celt_int16_t; - typedef _G_uint16_t celt_uint16_t; - typedef _G_int64_t celt_int64_t; - typedef _G_uint64_t celt_uint64_t; + typedef _G_int32_t celt_int32; + typedef _G_uint32_t celt_uint32; + typedef _G_int16 celt_int16; + typedef _G_uint16 celt_uint16; # elif defined(__MINGW32__) - typedef short celt_int16_t; - typedef unsigned short celt_uint16_t; - typedef int celt_int32_t; - typedef unsigned int celt_uint32_t; - typedef long long celt_int64_t; - typedef unsigned long long celt_uint64_t; + typedef short celt_int16; + typedef unsigned short celt_uint16; + typedef int celt_int32; + typedef unsigned int celt_uint32; # elif defined(__MWERKS__) - typedef int celt_int32_t; - typedef unsigned int celt_uint32_t; - typedef short celt_int16_t; - typedef unsigned short celt_uint16_t; - typedef long long celt_int64_t; - typedef unsigned long long celt_uint64_t; + typedef int celt_int32; + typedef unsigned int celt_uint32; + typedef short celt_int16; + typedef unsigned short celt_uint16; # else /* MSVC/Borland */ - typedef __int32 celt_int32_t; - typedef unsigned __int32 celt_uint32_t; - typedef __int16 celt_int16_t; - typedef unsigned __int16 celt_uint16_t; - typedef __int64 celt_int64_t; - typedef unsigned __int64 celt_uint64_t; + typedef __int32 celt_int32; + typedef unsigned __int32 celt_uint32; + typedef __int16 celt_int16; + typedef unsigned __int16 celt_uint16; # endif #elif defined(__MACOS__) # include <sys/types.h> - typedef SInt16 celt_int16_t; - typedef UInt16 celt_uint16_t; - typedef SInt32 celt_int32_t; - typedef UInt32 celt_uint32_t; - typedef SInt64 celt_int64_t; - typedef UInt64 celt_uint64_t; + typedef SInt16 celt_int16; + typedef UInt16 celt_uint16; + typedef SInt32 celt_int32; + typedef UInt32 celt_uint32; #elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ # include <sys/types.h> - typedef int16_t celt_int16_t; - typedef u_int16_t celt_uint16_t; - typedef int32_t celt_int32_t; - typedef u_int32_t celt_uint32_t; - typedef int64_t celt_int64_t; - typedef u_int64_t celt_uint64_t; + typedef int16 celt_int16; + typedef u_int16 celt_uint16; + typedef int32_t celt_int32; + typedef u_int32_t celt_uint32; #elif defined(__BEOS__) /* Be */ # include <inttypes.h> - typedef int16_t celt_int16_t; - typedef u_int16_t celt_uint16_t; - typedef int32_t celt_int32_t; - typedef u_int32_t celt_uint32_t; - typedef int64_t celt_int64_t; - typedef u_int64_t celt_uint64_t; + typedef int16 celt_int16; + typedef u_int16 celt_uint16; + typedef int32_t celt_int32; + typedef u_int32_t celt_uint32; #elif defined (__EMX__) /* OS/2 GCC */ - typedef short celt_int16_t; - typedef unsigned short celt_uint16_t; - typedef int celt_int32_t; - typedef unsigned int celt_uint32_t; - typedef long long celt_int64_t; - typedef unsigned long long celt_uint64_t; + typedef short celt_int16; + typedef unsigned short celt_uint16; + typedef int celt_int32; + typedef unsigned int celt_uint32; #elif defined (DJGPP) /* DJGPP */ - typedef short celt_int16_t; - typedef int celt_int32_t; - typedef unsigned int celt_uint32_t; - typedef long long celt_int64_t; - typedef unsigned long long celt_uint64_t; + typedef short celt_int16; + typedef unsigned short celt_uint16; + typedef int celt_int32; + typedef unsigned int celt_uint32; #elif defined(R5900) /* PS2 EE */ - typedef int celt_int32_t; - typedef unsigned celt_uint32_t; - typedef short celt_int16_t; - typedef long celt_int64_t; - typedef unsigned long celt_uint64_t; + typedef int celt_int32; + typedef unsigned celt_uint32; + typedef short celt_int16; + typedef unsigned short celt_uint16; #elif defined(__SYMBIAN32__) /* Symbian GCC */ - typedef signed short celt_int16_t; - typedef unsigned short celt_uint16_t; - typedef signed int celt_int32_t; - typedef unsigned int celt_uint32_t; - typedef long long int celt_int64_t; - typedef unsigned long long int celt_uint64_t; + typedef signed short celt_int16; + typedef unsigned short celt_uint16; + typedef signed int celt_int32; + typedef unsigned int celt_uint32; #elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) - typedef short celt_int16_t; - typedef unsigned short celt_uint16_t; - typedef long celt_int32_t; - typedef unsigned long celt_uint32_t; - typedef long long celt_int64_t; - typedef unsigned long long celt_uint64_t; + typedef short celt_int16; + typedef unsigned short celt_uint16; + typedef long celt_int32; + typedef unsigned long celt_uint32; #elif defined(CONFIG_TI_C6X) - typedef short celt_int16_t; - typedef unsigned short celt_uint16_t; - typedef int celt_int32_t; - typedef unsigned int celt_uint32_t; - typedef long long int celt_int64_t; - typedef unsigned long long int celt_uint64_t; + typedef short celt_int16; + typedef unsigned short celt_uint16; + typedef int celt_int32; + typedef unsigned int celt_uint32; #else /* Give up, take a reasonable guess */ - typedef short celt_int16_t; - typedef unsigned short celt_uint16_t; - typedef int celt_int32_t; - typedef unsigned int celt_uint32_t; - typedef long long celt_int64_t; - typedef unsigned long long celt_uint64_t; + typedef short celt_int16; + typedef unsigned short celt_uint16; + typedef int celt_int32; + typedef unsigned int celt_uint32; #endif diff --git a/libcelt/cwrs.c b/libcelt/cwrs.c index 8d2d7628d077b10550ba0ce7ce0c21f7ecc58a79..d675d258737fbe6f0b7749e6fcc4d5bd8e34ef90 100644 --- a/libcelt/cwrs.c +++ b/libcelt/cwrs.c @@ -74,7 +74,7 @@ int log2_frac(ec_uint32 val, int frac) #define MASK32 (0xFFFFFFFF) /*INV_TABLE[i] holds the multiplicative inverse of (2*i+1) mod 2**32.*/ -static const celt_uint32_t INV_TABLE[128]={ +static const celt_uint32 INV_TABLE[128]={ 0x00000001,0xAAAAAAAB,0xCCCCCCCD,0xB6DB6DB7, 0x38E38E39,0xBA2E8BA3,0xC4EC4EC5,0xEEEEEEEF, 0xF0F0F0F1,0x286BCA1B,0x3CF3CF3D,0xE9BD37A7, @@ -113,8 +113,8 @@ static const celt_uint32_t INV_TABLE[128]={ _a, _b, _c, and _d may be arbitrary so long as the arbitrary precision result fits in 32 bits, but currently the table for multiplicative inverses is only valid for _d<128.*/ -static inline celt_uint32_t imusdiv32odd(celt_uint32_t _a,celt_uint32_t _b, - celt_uint32_t _c,int _d){ +static inline celt_uint32 imusdiv32odd(celt_uint32 _a,celt_uint32 _b, + celt_uint32 _c,int _d){ return (_a*_b-_c)*INV_TABLE[_d]&MASK32; } @@ -125,9 +125,9 @@ static inline celt_uint32_t imusdiv32odd(celt_uint32_t _a,celt_uint32_t _b, table for multiplicative inverses is only valid for _d<=256). _b and _c may be arbitrary so long as the arbitrary precision reuslt fits in 32 bits.*/ -static inline celt_uint32_t imusdiv32even(celt_uint32_t _a,celt_uint32_t _b, - celt_uint32_t _c,int _d){ - celt_uint32_t inv; +static inline celt_uint32 imusdiv32even(celt_uint32 _a,celt_uint32 _b, + celt_uint32 _c,int _d){ + celt_uint32 inv; int mask; int shift; int one; @@ -144,7 +144,7 @@ static inline celt_uint32_t imusdiv32even(celt_uint32_t _a,celt_uint32_t _b, /*Compute floor(sqrt(_val)) with exact arithmetic. This has been tested on all possible 32-bit inputs.*/ -static unsigned isqrt32(celt_uint32_t _val){ +static unsigned isqrt32(celt_uint32 _val){ unsigned b; unsigned g; int bshift; @@ -156,8 +156,8 @@ static unsigned isqrt32(celt_uint32_t _val){ bshift=EC_ILOG(_val)-1>>1; b=1U<<bshift; do{ - celt_uint32_t t; - t=((celt_uint32_t)g<<1)+b<<bshift; + celt_uint32 t; + t=((celt_uint32)g<<1)+b<<bshift; if(t<=_val){ g+=b; _val-=t; @@ -169,39 +169,6 @@ static unsigned isqrt32(celt_uint32_t _val){ return g; } -#if 0 -/*Compute floor(sqrt(_val)) with exact arithmetic. - This has been tested on all possible 36-bit inputs.*/ -static celt_uint32_t isqrt36(celt_uint64_t _val){ - celt_uint32_t val32; - celt_uint32_t b; - celt_uint32_t g; - int bshift; - g=0; - b=0x20000; - for(bshift=18;bshift-->13;){ - celt_uint64_t t; - t=((celt_uint64_t)g<<1)+b<<bshift; - if(t<=_val){ - g+=b; - _val-=t; - } - b>>=1; - } - val32=(celt_uint32_t)_val; - for(;bshift>=0;bshift--){ - celt_uint32_t t; - t=(g<<1)+b<<bshift; - if(t<=val32){ - g+=b; - val32-=t; - } - b>>=1; - } - return g; -} -#endif - /*Although derived separately, the pulse vector coding scheme is equivalent to a Pyramid Vector Quantizer \cite{Fis86}. Some additional notes about an early version appear at @@ -325,10 +292,10 @@ static celt_uint32_t isqrt36(celt_uint64_t _val){ N and K are themselves limited to 15 bits.*/ int fits_in32(int _n, int _k) { - static const celt_int16_t maxN[15] = { + static const celt_int16 maxN[15] = { 32767, 32767, 32767, 1476, 283, 109, 60, 40, 29, 24, 20, 18, 16, 14, 13}; - static const celt_int16_t maxK[15] = { + static const celt_int16 maxK[15] = { 32767, 32767, 32767, 32767, 1172, 238, 95, 53, 36, 27, 22, 18, 16, 15, 13}; if (_n>=14) @@ -359,46 +326,46 @@ static inline unsigned ucwrs2(unsigned _k){ } /*Compute V(2,_k).*/ -static inline celt_uint32_t ncwrs2(int _k){ - return _k?4*(celt_uint32_t)_k:1; +static inline celt_uint32 ncwrs2(int _k){ + return _k?4*(celt_uint32)_k:1; } /*Compute U(3,_k). Note that this may be called with _k=32768 (maxK[3]+1).*/ -static inline celt_uint32_t ucwrs3(unsigned _k){ - return _k?(2*(celt_uint32_t)_k-2)*_k+1:0; +static inline celt_uint32 ucwrs3(unsigned _k){ + return _k?(2*(celt_uint32)_k-2)*_k+1:0; } /*Compute V(3,_k).*/ -static inline celt_uint32_t ncwrs3(int _k){ - return _k?2*(2*(unsigned)_k*(celt_uint32_t)_k+1):1; +static inline celt_uint32 ncwrs3(int _k){ + return _k?2*(2*(unsigned)_k*(celt_uint32)_k+1):1; } /*Compute U(4,_k).*/ -static inline celt_uint32_t ucwrs4(int _k){ - return _k?imusdiv32odd(2*_k,(2*_k-3)*(celt_uint32_t)_k+4,3,1):0; +static inline celt_uint32 ucwrs4(int _k){ + return _k?imusdiv32odd(2*_k,(2*_k-3)*(celt_uint32)_k+4,3,1):0; } /*Compute V(4,_k).*/ -static inline celt_uint32_t ncwrs4(int _k){ - return _k?((_k*(celt_uint32_t)_k+2)*_k)/3<<3:1; +static inline celt_uint32 ncwrs4(int _k){ + return _k?((_k*(celt_uint32)_k+2)*_k)/3<<3:1; } /*Compute U(5,_k).*/ -static inline celt_uint32_t ucwrs5(int _k){ - return _k?(((((_k-2)*(unsigned)_k+5)*(celt_uint32_t)_k-4)*_k)/3<<1)+1:0; +static inline celt_uint32 ucwrs5(int _k){ + return _k?(((((_k-2)*(unsigned)_k+5)*(celt_uint32)_k-4)*_k)/3<<1)+1:0; } /*Compute V(5,_k).*/ -static inline celt_uint32_t ncwrs5(int _k){ - return _k?(((_k*(unsigned)_k+5)*(celt_uint32_t)_k*_k)/3<<2)+2:1; +static inline celt_uint32 ncwrs5(int _k){ + return _k?(((_k*(unsigned)_k+5)*(celt_uint32)_k*_k)/3<<2)+2:1; } /*Computes the next row/column of any recurrence that obeys the relation u[i][j]=u[i-1][j]+u[i][j-1]+u[i-1][j-1]. _ui0 is the base case for the new row/column.*/ -static inline void unext(celt_uint32_t *_ui,unsigned _len,celt_uint32_t _ui0){ - celt_uint32_t ui1; +static inline void unext(celt_uint32 *_ui,unsigned _len,celt_uint32 _ui0){ + celt_uint32 ui1; unsigned j; /*This do-while will overrun the array if we don't have storage for at least 2 values.*/ @@ -413,8 +380,8 @@ static inline void unext(celt_uint32_t *_ui,unsigned _len,celt_uint32_t _ui0){ /*Computes the previous row/column of any recurrence that obeys the relation u[i-1][j]=u[i][j]-u[i][j-1]-u[i-1][j-1]. _ui0 is the base case for the new row/column.*/ -static inline void uprev(celt_uint32_t *_ui,unsigned _n,celt_uint32_t _ui0){ - celt_uint32_t ui1; +static inline void uprev(celt_uint32 *_ui,unsigned _n,celt_uint32 _ui0){ + celt_uint32 ui1; unsigned j; /*This do-while will overrun the array if we don't have storage for at least 2 values.*/ @@ -428,8 +395,8 @@ static inline void uprev(celt_uint32_t *_ui,unsigned _n,celt_uint32_t _ui0){ /*Compute V(_n,_k), as well as U(_n,0..._k+1). _u: On exit, _u[i] contains U(_n,i) for i in [0..._k+1].*/ -static celt_uint32_t ncwrs_urow(unsigned _n,unsigned _k,celt_uint32_t *_u){ - celt_uint32_t um2; +static celt_uint32 ncwrs_urow(unsigned _n,unsigned _k,celt_uint32 *_u){ + celt_uint32 um2; unsigned len; unsigned k; len=_k+2; @@ -449,8 +416,8 @@ static celt_uint32_t ncwrs_urow(unsigned _n,unsigned _k,celt_uint32_t *_u){ for(k=2;k<_n;k++)unext(_u+1,_k+1,1); } else{ - celt_uint32_t um1; - celt_uint32_t n2m1; + celt_uint32 um1; + celt_uint32 n2m1; _u[2]=n2m1=um1=(_n<<1)-1; for(k=3;k<len;k++){ /*U(N,K) = ((2*N-1)*U(N,K-1)-U(N,K-2))/(K-1) + U(N,K-2)*/ @@ -466,7 +433,7 @@ static celt_uint32_t ncwrs_urow(unsigned _n,unsigned _k,celt_uint32_t *_u){ /*Returns the _i'th combination of _k elements (at most 32767) chosen from a set of size 1 with associated sign bits. _y: Returns the vector of pulses.*/ -static inline void cwrsi1(int _k,celt_uint32_t _i,int *_y){ +static inline void cwrsi1(int _k,celt_uint32 _i,int *_y){ int s; s=-(int)_i; _y[0]=_k+s^s; @@ -475,8 +442,8 @@ static inline void cwrsi1(int _k,celt_uint32_t _i,int *_y){ /*Returns the _i'th combination of _k elements (at most 32767) chosen from a set of size 2 with associated sign bits. _y: Returns the vector of pulses.*/ -static inline void cwrsi2(int _k,celt_uint32_t _i,int *_y){ - celt_uint32_t p; +static inline void cwrsi2(int _k,celt_uint32 _i,int *_y){ + celt_uint32 p; int s; int yj; p=ucwrs2(_k+1U); @@ -494,8 +461,8 @@ static inline void cwrsi2(int _k,celt_uint32_t _i,int *_y){ /*Returns the _i'th combination of _k elements (at most 32767) chosen from a set of size 3 with associated sign bits. _y: Returns the vector of pulses.*/ -static void cwrsi3(int _k,celt_uint32_t _i,int *_y){ - celt_uint32_t p; +static void cwrsi3(int _k,celt_uint32 _i,int *_y){ + celt_uint32 p; int s; int yj; p=ucwrs3(_k+1U); @@ -515,8 +482,8 @@ static void cwrsi3(int _k,celt_uint32_t _i,int *_y){ /*Returns the _i'th combination of _k elements (at most 1172) chosen from a set of size 4 with associated sign bits. _y: Returns the vector of pulses.*/ -static void cwrsi4(int _k,celt_uint32_t _i,int *_y){ - celt_uint32_t p; +static void cwrsi4(int _k,celt_uint32 _i,int *_y){ + celt_uint32 p; int s; int yj; int kl; @@ -549,21 +516,14 @@ static void cwrsi4(int _k,celt_uint32_t _i,int *_y){ /*Returns the _i'th combination of _k elements (at most 238) chosen from a set of size 5 with associated sign bits. _y: Returns the vector of pulses.*/ -static void cwrsi5(int _k,celt_uint32_t _i,int *_y){ - celt_uint32_t p; +static void cwrsi5(int _k,celt_uint32 _i,int *_y){ + celt_uint32 p; int s; int yj; p=ucwrs5(_k+1); s=-(_i>=p); _i-=p&s; yj=_k; -#if 0 - /*Finds the maximum _k such that ucwrs5(_k)<=_i (tested for all - _i<2157192969=U(5,239)).*/ - if(_i>=0x2AAAAAA9UL)_k=isqrt32(2*isqrt36(10+6*(celt_uint64_t)_i)-7)+1>>1; - else _k=_i>0?isqrt32(2*(celt_uint32_t)isqrt32(10+6*_i)-7)+1>>1:0; - p=ucwrs5(_k); -#else /* A binary search on U(5,K) avoids the need for 64-bit arithmetic */ { int kl=0; @@ -579,7 +539,6 @@ static void cwrsi5(int _k,celt_uint32_t _i,int *_y){ else break; } } -#endif _i-=p; yj-=_k; _y[0]=yj+s^s; @@ -591,12 +550,12 @@ static void cwrsi5(int _k,celt_uint32_t _i,int *_y){ _y: Returns the vector of pulses. _u: Must contain entries [0..._k+1] of row _n of U() on input. Its contents will be destructively modified.*/ -static void cwrsi(int _n,int _k,celt_uint32_t _i,int *_y,celt_uint32_t *_u){ +static void cwrsi(int _n,int _k,celt_uint32 _i,int *_y,celt_uint32 *_u){ int j; celt_assert(_n>0); j=0; do{ - celt_uint32_t p; + celt_uint32 p; int s; int yj; p=_u[_k+1]; @@ -618,7 +577,7 @@ static void cwrsi(int _n,int _k,celt_uint32_t _i,int *_y,celt_uint32_t *_u){ of size 1 with associated sign bits. _y: The vector of pulses, whose sum of absolute values is K. _k: Returns K.*/ -static inline celt_uint32_t icwrs1(const int *_y,int *_k){ +static inline celt_uint32 icwrs1(const int *_y,int *_k){ *_k=abs(_y[0]); return _y[0]<0; } @@ -627,8 +586,8 @@ static inline celt_uint32_t icwrs1(const int *_y,int *_k){ of size 2 with associated sign bits. _y: The vector of pulses, whose sum of absolute values is K. _k: Returns K.*/ -static inline celt_uint32_t icwrs2(const int *_y,int *_k){ - celt_uint32_t i; +static inline celt_uint32 icwrs2(const int *_y,int *_k){ + celt_uint32 i; int k; i=icwrs1(_y+1,&k); i+=ucwrs2(k); @@ -642,8 +601,8 @@ static inline celt_uint32_t icwrs2(const int *_y,int *_k){ of size 3 with associated sign bits. _y: The vector of pulses, whose sum of absolute values is K. _k: Returns K.*/ -static inline celt_uint32_t icwrs3(const int *_y,int *_k){ - celt_uint32_t i; +static inline celt_uint32 icwrs3(const int *_y,int *_k){ + celt_uint32 i; int k; i=icwrs2(_y+1,&k); i+=ucwrs3(k); @@ -657,8 +616,8 @@ static inline celt_uint32_t icwrs3(const int *_y,int *_k){ of size 4 with associated sign bits. _y: The vector of pulses, whose sum of absolute values is K. _k: Returns K.*/ -static inline celt_uint32_t icwrs4(const int *_y,int *_k){ - celt_uint32_t i; +static inline celt_uint32 icwrs4(const int *_y,int *_k){ + celt_uint32 i; int k; i=icwrs3(_y+1,&k); i+=ucwrs4(k); @@ -672,8 +631,8 @@ static inline celt_uint32_t icwrs4(const int *_y,int *_k){ of size 5 with associated sign bits. _y: The vector of pulses, whose sum of absolute values is K. _k: Returns K.*/ -static inline celt_uint32_t icwrs5(const int *_y,int *_k){ - celt_uint32_t i; +static inline celt_uint32 icwrs5(const int *_y,int *_k){ + celt_uint32 i; int k; i=icwrs4(_y+1,&k); i+=ucwrs5(k); @@ -687,9 +646,9 @@ static inline celt_uint32_t icwrs5(const int *_y,int *_k){ of size _n with associated sign bits. _y: The vector of pulses, whose sum of absolute values must be _k. _nc: Returns V(_n,_k).*/ -celt_uint32_t icwrs(int _n,int _k,celt_uint32_t *_nc,const int *_y, - celt_uint32_t *_u){ - celt_uint32_t i; +celt_uint32 icwrs(int _n,int _k,celt_uint32 *_nc,const int *_y, + celt_uint32 *_u){ + celt_uint32 i; int j; int k; /*We can't unroll the first two iterations of the loop unless _n>=2.*/ @@ -716,8 +675,8 @@ celt_uint32_t icwrs(int _n,int _k,celt_uint32_t *_nc,const int *_y, _left_bits and _right_bits must contain the required bits for the left and right sides of the split, respectively (which themselves may require splitting).*/ -static void get_required_split_bits(celt_int16_t *_bits, - const celt_int16_t *_left_bits,const celt_int16_t *_right_bits, +static void get_required_split_bits(celt_int16 *_bits, + const celt_int16 *_left_bits,const celt_int16 *_right_bits, int _n,int _maxk,int _frac){ int k; for(k=_maxk;k-->0;){ @@ -748,9 +707,9 @@ static void get_required_split_bits(celt_int16_t *_bits, _n1 and _n2 must either be equal or two consecutive integers. Returns the buffer used to store the required bits for _n2, which is either _bits1 if _n1==_n2 or _bits2 if _n1+1==_n2.*/ -static celt_int16_t *get_required_bits_pair(celt_int16_t *_bits1, - celt_int16_t *_bits2,celt_int16_t *_tmp,int _n1,int _n2,int _maxk,int _frac){ - celt_int16_t *tmp2; +static celt_int16 *get_required_bits_pair(celt_int16 *_bits1, + celt_int16 *_bits2,celt_int16 *_tmp,int _n1,int _n2,int _maxk,int _frac){ + celt_int16 *tmp2; /*If we only need a single set of required bits...*/ if(_n1==_n2){ /*Stop recursing if everything fits.*/ @@ -796,28 +755,28 @@ static celt_int16_t *get_required_bits_pair(celt_int16_t *_bits1, return _bits2; } -void get_required_bits(celt_int16_t *_bits,int _n,int _maxk,int _frac){ +void get_required_bits(celt_int16 *_bits,int _n,int _maxk,int _frac){ int k; /*_maxk==0 => there's nothing to do.*/ celt_assert(_maxk>0); if(fits_in32(_n,_maxk-1)){ _bits[0]=0; if(_maxk>1){ - VARDECL(celt_uint32_t,u); + VARDECL(celt_uint32,u); SAVE_STACK; - ALLOC(u,_maxk+1U,celt_uint32_t); + ALLOC(u,_maxk+1U,celt_uint32); ncwrs_urow(_n,_maxk-1,u); for(k=1;k<_maxk;k++)_bits[k]=log2_frac(u[k]+u[k+1],_frac); RESTORE_STACK; } } else{ - VARDECL(celt_int16_t,n1bits); - VARDECL(celt_int16_t,n2bits_buf); - celt_int16_t *n2bits; + VARDECL(celt_int16,n1bits); + VARDECL(celt_int16,n2bits_buf); + celt_int16 *n2bits; SAVE_STACK; - ALLOC(n1bits,_maxk,celt_int16_t); - ALLOC(n2bits_buf,_maxk,celt_int16_t); + ALLOC(n1bits,_maxk,celt_int16); + ALLOC(n2bits_buf,_maxk,celt_int16); n2bits=get_required_bits_pair(n1bits,n2bits_buf,_bits, _n>>1,_n+1>>1,_maxk,_frac); get_required_split_bits(_bits,n1bits,n2bits,_n,_maxk,_frac); @@ -827,7 +786,7 @@ void get_required_bits(celt_int16_t *_bits,int _n,int _maxk,int _frac){ static inline void encode_pulses32(int _n,int _k,const int *_y,ec_enc *_enc){ - celt_uint32_t i; + celt_uint32 i; switch(_n){ case 1:{ i=icwrs1(_y,&_k); @@ -851,10 +810,10 @@ static inline void encode_pulses32(int _n,int _k,const int *_y,ec_enc *_enc){ ec_enc_uint(_enc,i,ncwrs5(_k)); }break; default:{ - VARDECL(celt_uint32_t,u); - celt_uint32_t nc; + VARDECL(celt_uint32,u); + celt_uint32 nc; SAVE_STACK; - ALLOC(u,_k+2U,celt_uint32_t); + ALLOC(u,_k+2U,celt_uint32); i=icwrs(_n,_k,&nc,_y,u); ec_enc_uint(_enc,i,nc); RESTORE_STACK; @@ -892,9 +851,9 @@ static inline void decode_pulses32(int _n,int _k,int *_y,ec_dec *_dec){ case 4:cwrsi4(_k,ec_dec_uint(_dec,ncwrs4(_k)),_y);break; case 5:cwrsi5(_k,ec_dec_uint(_dec,ncwrs5(_k)),_y);break; default:{ - VARDECL(celt_uint32_t,u); + VARDECL(celt_uint32,u); SAVE_STACK; - ALLOC(u,_k+2U,celt_uint32_t); + ALLOC(u,_k+2U,celt_uint32); cwrsi(_n,_k,ec_dec_uint(_dec,ncwrs_urow(_n,_k,u)),_y,u); RESTORE_STACK; } diff --git a/libcelt/cwrs.h b/libcelt/cwrs.h index 6da087536242f088a997a7570b2bad571564362c..aa6eace27b9ba26e1a7f53803a9e2ef549e82e97 100644 --- a/libcelt/cwrs.h +++ b/libcelt/cwrs.h @@ -41,7 +41,7 @@ int log2_frac(ec_uint32 val, int frac); /* Whether the CWRS codebook will fit into 32 bits */ int fits_in32(int _n, int _m); -void get_required_bits(celt_int16_t *bits, int N, int K, int frac); +void get_required_bits(celt_int16 *bits, int N, int K, int frac); void encode_pulses(int *_y, int N, int K, ec_enc *enc); diff --git a/libcelt/dump_modes.c b/libcelt/dump_modes.c index eb6e0375a6f1a980ebb61ef1b68808b19a3043c9..dd3b12191b9556e7b985ad46e19dc495fb586076 100644 --- a/libcelt/dump_modes.c +++ b/libcelt/dump_modes.c @@ -65,7 +65,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) CELTMode *mode = modes[i]; fprintf(file, "#ifndef DEF_EBANDS%d_%d\n", mode->Fs, mode->mdctSize); fprintf(file, "#define DEF_EBANDS%d_%d\n", mode->Fs, mode->mdctSize); - fprintf (file, "static const celt_int16_t eBands%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands+2); + fprintf (file, "static const celt_int16 eBands%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands+2); for (j=0;j<mode->nbEBands+2;j++) fprintf (file, "%d, ", mode->eBands[j]); fprintf (file, "};\n"); @@ -94,7 +94,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) fprintf(file, "#ifndef DEF_ALLOC_VECTORS%d_%d\n", mode->Fs, mode->mdctSize); fprintf(file, "#define DEF_ALLOC_VECTORS%d_%d\n", mode->Fs, mode->mdctSize); - fprintf (file, "static const celt_int16_t allocVectors%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands*mode->nbAllocVectors); + fprintf (file, "static const celt_int16 allocVectors%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands*mode->nbAllocVectors); for (j=0;j<mode->nbAllocVectors;j++) { int k; @@ -113,7 +113,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) int k; if (j==0 || (mode->bits[j] != mode->bits[j-1])) { - fprintf (file, "static const celt_int16_t allocCache_band%d_%d_%d[MAX_PULSES] = {\n", j, mode->Fs, mode->mdctSize); + fprintf (file, "static const celt_int16 allocCache_band%d_%d_%d[MAX_PULSES] = {\n", j, mode->Fs, mode->mdctSize); for (k=0;k<MAX_PULSES;k++) fprintf (file, "%2d, ", mode->bits[j][k]); fprintf (file, "};\n"); @@ -121,7 +121,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) fprintf (file, "#define allocCache_band%d_%d_%d allocCache_band%d_%d_%d\n", j, mode->Fs, mode->mdctSize, j-1, mode->Fs, mode->mdctSize); } } - fprintf (file, "static const celt_int16_t *allocCache%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands); + fprintf (file, "static const celt_int16 *allocCache%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands); for (j=0;j<mode->nbEBands;j++) { fprintf (file, "allocCache_band%d_%d_%d, ", j, mode->Fs, mode->mdctSize); diff --git a/libcelt/entcode.h b/libcelt/entcode.h index 57107d492d2593b21fd856add18eb4c17403fea6..7513c3560dc6b8b77e79b874501b14cbbc703ea1 100644 --- a/libcelt/entcode.h +++ b/libcelt/entcode.h @@ -38,9 +38,8 @@ -typedef celt_int32_t ec_int32; -typedef celt_uint32_t ec_uint32; -typedef celt_uint64_t ec_uint64; +typedef celt_int32 ec_int32; +typedef celt_uint32 ec_uint32; typedef struct ec_byte_buffer ec_byte_buffer; @@ -94,6 +93,5 @@ static inline unsigned char *ec_byte_get_buffer(ec_byte_buffer *_b){ } int ec_ilog(ec_uint32 _v); -int ec_ilog64(ec_uint64 _v); #endif diff --git a/libcelt/entdec.h b/libcelt/entdec.h index 8c6de86c21c6fb462f04875f4ee05a78c208c1ef..36d5274a6432b479282818bfc1d32385953f71a3 100644 --- a/libcelt/entdec.h +++ b/libcelt/entdec.h @@ -103,13 +103,6 @@ void ec_dec_update(ec_dec *_this,unsigned _fl,unsigned _fh, This must be at least one, and no more than 32. Return: The decoded bits.*/ ec_uint32 ec_dec_bits(ec_dec *_this,int _ftb); -/*Extracts a sequence of raw bits from the stream. - The bits must have been encoded with ec_enc_bits64(). - No call to ec_dec_update() is necessary after this call. - _ftb: The number of bits to extract. - This must be at least one, and no more than 64. - Return: The decoded bits.*/ -ec_uint64 ec_dec_bits64(ec_dec *_this,int _ftb); /*Extracts a raw unsigned integer with a non-power-of-2 range from the stream. The bits must have been encoded with ec_enc_uint(). No call to ec_dec_update() is necessary after this call. @@ -117,13 +110,6 @@ ec_uint64 ec_dec_bits64(ec_dec *_this,int _ftb); This must be at least one, and no more than 2**32-1. Return: The decoded bits.*/ ec_uint32 ec_dec_uint(ec_dec *_this,ec_uint32 _ft); -/*Extracts a raw unsigned integer with a non-power-of-2 range from the stream. - The bits must have been encoded with ec_enc_uint64(). - No call to ec_dec_update() is necessary after this call. - _ft: The number of integers that can be decoded (one more than the max). - This must be at least one, and no more than 2**64-1. - Return: The decoded bits.*/ -ec_uint64 ec_dec_uint64(ec_dec *_this,ec_uint64 _ft); /*Returns the number of bits "used" by the decoded symbols so far. The actual number of bits may be larger, due to rounding to whole bytes, or diff --git a/libcelt/entenc.h b/libcelt/entenc.h index 10647eb3659a9f1836cd13fc25ebd4d64355f5d2..49f27522e8e0dc21b30ce827fd0a680d074dc7b3 100644 --- a/libcelt/entenc.h +++ b/libcelt/entenc.h @@ -85,21 +85,11 @@ void ec_encode_raw(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned bits); _ftb: The number of bits to encode. This must be at least one, and no more than 32.*/ void ec_enc_bits(ec_enc *_this,ec_uint32 _fl,int _ftb); -/*Encodes a sequence of raw bits in the stream. - _fl: The bits to encode. - _ftb: The number of bits to encode. - This must be at least one, and no more than 64.*/ -void ec_enc_bits64(ec_enc *_this,ec_uint64 _fl,int _ftb); /*Encodes a raw unsigned integer in the stream. _fl: The integer to encode. _ft: The number of integers that can be encoded (one more than the max). This must be at least one, and no more than 2**32-1.*/ void ec_enc_uint(ec_enc *_this,ec_uint32 _fl,ec_uint32 _ft); -/*Encodes a raw unsigned integer in the stream. - _fl: The integer to encode. - _ft: The number of integers that can be encoded (one more than the max). - This must be at least one, and no more than 2**64-1.*/ -void ec_enc_uint64(ec_enc *_this,ec_uint64 _fl,ec_uint64 _ft); /*Returns the number of bits "used" by the encoded symbols so far. The actual number of bits may be larger, due to rounding to whole bytes, or diff --git a/libcelt/fixed_debug.h b/libcelt/fixed_debug.h index 4b90bde737393f09299052049b12555d9e576cb9..0039ab926a3aef323818a31569c0f5405f7b2a27 100644 --- a/libcelt/fixed_debug.h +++ b/libcelt/fixed_debug.h @@ -45,7 +45,7 @@ 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_t)(b)) +#define MULT16_16SU(a,b) ((celt_word32_t)(celt_word16_t)(a)*(celt_word32_t)(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 */ diff --git a/libcelt/fixed_generic.h b/libcelt/fixed_generic.h index a273c6206410c381b42b396036627aa575ce37a6..d4e02af509871ff6ee851b41c5ec388f58ff6d62 100644 --- a/libcelt/fixed_generic.h +++ b/libcelt/fixed_generic.h @@ -36,7 +36,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_t)(b)) +#define MULT16_16SU(a,b) ((celt_word32_t)(celt_word16_t)(a)*(celt_word32_t)(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)) diff --git a/libcelt/header.c b/libcelt/header.c index d718356c91671e1fcbc5c649a434d052c7426201..dddfdd1a294754d82b2fc5fbe53769181c3a2928 100644 --- a/libcelt/header.c +++ b/libcelt/header.c @@ -37,22 +37,10 @@ #include "os_support.h" #include "modes.h" -/*typedef struct { - char codec_id[8]; - char codec_version[20]; - celt_int32_t version_id; - celt_int32_t header_size; - celt_int32_t mode; - celt_int32_t sample_rate; - celt_int32_t nb_channels; - celt_int32_t bytes_per_packet; - celt_int32_t extra_headers; -} CELTHeader;*/ - -static celt_uint32_t -_le_32 (celt_uint32_t i) +static celt_uint32 +_le_32 (celt_uint32 i) { - celt_uint32_t ret=i; + celt_uint32 ret=i; #if !defined(__LITTLE_ENDIAN__) && ( defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__) ) ret = (i>>24); ret += (i>>8) & 0x0000ff00; @@ -84,9 +72,9 @@ int celt_header_init(CELTHeader *header, const CELTMode *m, int channels) return CELT_OK; } -int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32_t size) +int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32 size) { - celt_int32_t * h; + celt_int32 * h; if ((size < 56) || (header==NULL) || (packet==NULL)) return CELT_BAD_ARG; /* FAIL */ @@ -98,7 +86,7 @@ int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_ CELT_COPY(packet, (unsigned char*)header, 28); /* Copy the int32 fields */ - h = (celt_int32_t*)(packet+28); + h = (celt_int32*)(packet+28); *h++ = _le_32 (header->version_id); *h++ = _le_32 (header->header_size); *h++ = _le_32 (header->sample_rate); @@ -111,9 +99,9 @@ int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_ return sizeof(*header); } -int celt_header_from_packet(const unsigned char *packet, celt_uint32_t size, CELTHeader *header) +int celt_header_from_packet(const unsigned char *packet, celt_uint32 size, CELTHeader *header) { - celt_int32_t * h; + celt_int32 * h; if ((size < 56) || (header==NULL) || (packet==NULL)) return CELT_BAD_ARG; /* FAIL */ @@ -125,7 +113,7 @@ int celt_header_from_packet(const unsigned char *packet, celt_uint32_t size, CEL CELT_COPY((unsigned char*)header, packet, 28); /* Copy the int32 fields */ - h = (celt_int32_t*)(packet+28); + h = (celt_int32*)(packet+28); header->version_id = _le_32(*h++); header->header_size = _le_32(*h++); header->sample_rate = _le_32(*h++); diff --git a/libcelt/kfft_double.h b/libcelt/kfft_double.h index 9f9d703ebe8d9a4f97d80bff423ac0fe2ec59c97..c39363263e2964f4af829f542f2f256cd47607c7 100644 --- a/libcelt/kfft_double.h +++ b/libcelt/kfft_double.h @@ -61,8 +61,8 @@ #define cpx32_fft_alloc(length) (kiss_fft_cfg)(c64_fft32_alloc(length, 0, 0)) #define cpx32_fft_free(state) c64_fft32_free((c64_fft_t *)state) -#define cpx32_fft(state, X, Y, nx) c64_fft32 ((c64_fft_t *)state, (const celt_int32_t *)(X), (celt_int32_t *)(Y)) -#define cpx32_ifft(state, X, Y, nx) c64_ifft32((c64_fft_t *)state, (const celt_int32_t *)(X), (celt_int32_t *)(Y)) +#define cpx32_fft(state, X, Y, nx) c64_fft32 ((c64_fft_t *)state, (const celt_int32 *)(X), (celt_int32 *)(Y)) +#define cpx32_ifft(state, X, Y, nx) c64_ifft32((c64_fft_t *)state, (const celt_int32 *)(X), (celt_int32 *)(Y)) #else /* ENABLE_TI_DSPLIB55/64 */ diff --git a/libcelt/kiss_fft.c b/libcelt/kiss_fft.c index 2d5e9a6d563848fb9d9fc1f82dd95116912385a8..a065e6731df552a5b1717d3f1ca6bcbaaf352c7f 100644 --- a/libcelt/kiss_fft.c +++ b/libcelt/kiss_fft.c @@ -597,7 +597,7 @@ void kf_factor(int n,int * facbuf) case 2: p = 3; break; default: p += 2; break; } - if (p>32000 || (celt_int32_t)p*(celt_int32_t)p > n) + if (p>32000 || (celt_int32)p*(celt_int32)p > n) p = n; /* no more factors, skip to end */ } n /= p; diff --git a/libcelt/kiss_fft.h b/libcelt/kiss_fft.h index f35e87ea47a79152939b8a5fffb52a05259f2482..abddd02474c5e9afecd8608953530db513c71f29 100644 --- a/libcelt/kiss_fft.h +++ b/libcelt/kiss_fft.h @@ -52,12 +52,12 @@ extern "C" { #ifdef FIXED_POINT #include "arch.h" #ifdef DOUBLE_PRECISION -# define kiss_fft_scalar celt_int32_t -# define kiss_twiddle_scalar celt_int32_t +# define kiss_fft_scalar celt_int32 +# define kiss_twiddle_scalar celt_int32 # define KF_SUFFIX _celt_double #else -# define kiss_fft_scalar celt_int16_t -# define kiss_twiddle_scalar celt_int16_t +# define kiss_fft_scalar celt_int16 +# define kiss_twiddle_scalar celt_int16 # define KF_SUFFIX _celt_single #endif #else diff --git a/libcelt/mathops.h b/libcelt/mathops.h index 8096b42dff21e243d92d15585bad4225bb0b481c..25fe18c6167d144af247ac8979da31b486600a39 100644 --- a/libcelt/mathops.h +++ b/libcelt/mathops.h @@ -41,7 +41,7 @@ #ifndef OVERRIDE_CELT_ILOG2 /** Integer log in base2. Undefined for zero and negative numbers */ -static inline celt_int16_t celt_ilog2(celt_word32_t x) +static inline celt_int16 celt_ilog2(celt_word32_t x) { celt_assert2(x>0, "celt_ilog2() only defined for strictly positive numbers"); return EC_ILOG(x)-1; @@ -82,12 +82,12 @@ static inline int find_max32(celt_word32_t *x, int len) } #endif -#define FRAC_MUL16(a,b) ((16384+((celt_int32_t)(celt_int16_t)(a)*(celt_int16_t)(b)))>>15) -static inline celt_int16_t bitexact_cos(celt_int16_t x) +#define FRAC_MUL16(a,b) ((16384+((celt_int32)(celt_int16)(a)*(celt_int16)(b)))>>15) +static inline celt_int16 bitexact_cos(celt_int16 x) { - celt_int32_t tmp; - celt_int16_t x2; - tmp = (4096+((celt_int32_t)(x)*(x)))>>13; + celt_int32 tmp; + celt_int16 x2; + tmp = (4096+((celt_int32)(x)*(x)))>>13; if (tmp > 32767) tmp = 32767; x2 = tmp; @@ -122,7 +122,7 @@ static inline float celt_log2(float x) float frac; union { float f; - celt_uint32_t i; + celt_uint32 i; } in; in.f = x; integer = (in.i>>23)-127; @@ -140,7 +140,7 @@ static inline float celt_exp2(float x) float frac; union { float f; - celt_uint32_t i; + celt_uint32 i; } res; integer = floor(x); if (integer < -50) @@ -177,7 +177,7 @@ static inline celt_word16_t celt_maxabs16(celt_word16_t *x, int len) #endif /** Integer log in base2. Defined for zero, but not for negative numbers */ -static inline celt_int16_t celt_zlog2(celt_word32_t x) +static inline celt_int16 celt_zlog2(celt_word32_t x) { return x <= 0 ? 0 : celt_ilog2(x); } diff --git a/libcelt/modes.c b/libcelt/modes.c index 7c5508e5e5e40409dcf4bc307a923aaade44d61e..9729a4fae982228e81109377017784566c3ba5dc 100644 --- a/libcelt/modes.c +++ b/libcelt/modes.c @@ -53,7 +53,7 @@ #endif -int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value) +int celt_mode_info(const CELTMode *mode, int request, celt_int32 *value) { if (check_mode(mode) != CELT_OK) return CELT_INVALID_MODE; @@ -82,7 +82,7 @@ int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value) /* Defining 25 critical bands for the full 0-20 kHz audio bandwidth Taken from http://ccrma.stanford.edu/~jos/bbt/Bark_Frequency_Scale.html */ #define BARK_BANDS 25 -static const celt_int16_t bark_freq[BARK_BANDS+1] = { +static const celt_int16 bark_freq[BARK_BANDS+1] = { 0, 100, 200, 300, 400, 510, 630, 770, 920, 1080, 1270, 1480, 1720, 2000, 2320, @@ -115,10 +115,10 @@ static const int band_allocation[BARK_BANDS*BITALLOC_SIZE] = }; #endif -static celt_int16_t *compute_ebands(celt_int32_t Fs, int frame_size, int nbShortMdcts, int *nbEBands) +static celt_int16 *compute_ebands(celt_int32 Fs, int frame_size, int nbShortMdcts, int *nbEBands) { int min_bins = 3; - celt_int16_t *eBands; + celt_int16 *eBands; int i, res, min_width, lin, low, high, nBark, offset=0; /*if (min_bins < nbShortMdcts) @@ -139,7 +139,7 @@ static celt_int16_t *compute_ebands(celt_int32_t Fs, int frame_size, int nbShort low = ((bark_freq[lin]/res)+(min_bins-1))/min_bins; high = nBark-lin; *nbEBands = low+high; - eBands = celt_alloc(sizeof(celt_int16_t)*(*nbEBands+2)); + eBands = celt_alloc(sizeof(celt_int16)*(*nbEBands+2)); if (eBands==NULL) return NULL; @@ -180,7 +180,7 @@ static celt_int16_t *compute_ebands(celt_int32_t Fs, int frame_size, int nbShort static void compute_allocation_table(CELTMode *mode, int res) { int i, j, nBark; - celt_int16_t *allocVectors; + celt_int16 *allocVectors; /* Find the number of critical bands supported by our sampling rate */ for (nBark=1;nBark<BARK_BANDS;nBark++) @@ -188,18 +188,18 @@ static void compute_allocation_table(CELTMode *mode, int res) break; mode->nbAllocVectors = BITALLOC_SIZE; - allocVectors = celt_alloc(sizeof(celt_int16_t)*(BITALLOC_SIZE*mode->nbEBands)); + allocVectors = celt_alloc(sizeof(celt_int16)*(BITALLOC_SIZE*mode->nbEBands)); if (allocVectors==NULL) return; /* Compute per-codec-band allocation from per-critical-band matrix */ for (i=0;i<BITALLOC_SIZE;i++) { - celt_int32_t current = 0; + celt_int32 current = 0; int eband = 0; for (j=0;j<nBark;j++) { int edge, low; - celt_int32_t alloc; + celt_int32 alloc; edge = mode->eBands[eband+1]*res; alloc = mode->mdctSize*band_allocation[i*BARK_BANDS+j]; if (edge < bark_freq[j+1]) @@ -223,7 +223,7 @@ static void compute_allocation_table(CELTMode *mode, int res) #endif /* STATIC_MODES */ -CELTMode *celt_mode_create(celt_int32_t Fs, int frame_size, int *error) +CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error) { int i; #ifdef STDIN_TUNING @@ -336,7 +336,7 @@ CELTMode *celt_mode_create(celt_int32_t Fs, int frame_size, int *error) if (mode->eBands==NULL) goto failure; - mode->pitchEnd = 4000*(celt_int32_t)frame_size/Fs; + mode->pitchEnd = 4000*(celt_int32)frame_size/Fs; /* Overlap must be divisible by 4 */ if (mode->nbShortMdcts > 1) @@ -361,7 +361,7 @@ CELTMode *celt_mode_create(celt_int32_t Fs, int frame_size, int *error) #endif mode->window = window; - mode->bits = (const celt_int16_t **)compute_alloc_cache(mode, 1); + mode->bits = (const celt_int16 **)compute_alloc_cache(mode, 1); if (mode->bits==NULL) goto failure; @@ -413,7 +413,7 @@ failure: void celt_mode_destroy(CELTMode *mode) { int i; - const celt_int16_t *prevPtr = NULL; + const celt_int16 *prevPtr = NULL; if (mode == NULL) { celt_warning("NULL passed to celt_mode_destroy"); diff --git a/libcelt/modes.h b/libcelt/modes.h index 173a3891058eff12d008ebb873b39f5e288034a9..a03c25a60b5ce4e30654c18df4b73aa45db2740d 100644 --- a/libcelt/modes.h +++ b/libcelt/modes.h @@ -77,22 +77,22 @@ @brief Mode definition */ struct CELTMode { - celt_uint32_t marker_start; - celt_int32_t Fs; + celt_uint32 marker_start; + celt_int32 Fs; int overlap; int mdctSize; int nbEBands; int pitchEnd; - const celt_int16_t *eBands; /**< Definition for each "pseudo-critical band" */ + const celt_int16 *eBands; /**< Definition for each "pseudo-critical band" */ celt_word16_t ePredCoef;/**< Prediction coefficient for the energy encoding */ int nbAllocVectors; /**< Number of lines in the matrix below */ - const celt_int16_t *allocVectors; /**< Number of bits in each band for several rates */ + const celt_int16 *allocVectors; /**< Number of bits in each band for several rates */ - const celt_int16_t * const *bits; /**< Cache for pulses->bits mapping in each band */ + const celt_int16 * const *bits; /**< Cache for pulses->bits mapping in each band */ /* Stuff that could go in the {en,de}coder, but we save space this way */ mdct_lookup mdct; @@ -108,7 +108,7 @@ struct CELTMode { struct PsyDecay psy; int *prob; - celt_uint32_t marker_end; + celt_uint32 marker_end; }; int check_mode(const CELTMode *mode); diff --git a/libcelt/psy.c b/libcelt/psy.c index 65e4a2c485721232feaacab845374f55d5c36594..96867e6a1d1d5e3a2449d3d1e753ff4731762cbf 100644 --- a/libcelt/psy.c +++ b/libcelt/psy.c @@ -49,7 +49,7 @@ recursive filter. The filter coefficient is frequency dependent and chosen such that we have a -10dB/Bark slope on the right side and a -25dB/Bark slope on the left side. */ -void psydecay_init(struct PsyDecay *decay, int len, celt_int32_t Fs) +void psydecay_init(struct PsyDecay *decay, int len, celt_int32 Fs) { int i; celt_word16_t *decayR = (celt_word16_t*)celt_alloc(sizeof(celt_word16_t)*len); diff --git a/libcelt/psy.h b/libcelt/psy.h index 3b26bce7684a461eb8d7f221d022aa8f632882bb..bf0a51a7bca5025ed220558261723000de455a95 100644 --- a/libcelt/psy.h +++ b/libcelt/psy.h @@ -40,7 +40,7 @@ struct PsyDecay { }; /** Pre-compute the decay of the psycho-acoustic spreading function */ -void psydecay_init(struct PsyDecay *decay, int len, celt_int32_t Fs); +void psydecay_init(struct PsyDecay *decay, int len, celt_int32 Fs); /** Free the memory allocated for the spreading function */ void psydecay_clear(struct PsyDecay *decay); diff --git a/libcelt/quant_bands.c b/libcelt/quant_bands.c index 46ad5bbc5bf394b1c8bb61999b28e0d2ea4a1597..d6226949ed4f2267357849d8f2d1c2fe30626490 100644 --- a/libcelt/quant_bands.c +++ b/libcelt/quant_bands.c @@ -152,7 +152,7 @@ void quant_fine_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *ol /* Encode finer resolution */ for (i=0;i<m->nbEBands;i++) { - celt_int16_t frac = 1<<fine_quant[i]; + celt_int16 frac = 1<<fine_quant[i]; if (fine_quant[i] <= 0) continue; c=0; diff --git a/libcelt/rate.c b/libcelt/rate.c index 0ea0a941f1813e0496a2910c00d13c5b86a4c11a..81145050e19ede5ade797f26071b012a9f91697b 100644 --- a/libcelt/rate.c +++ b/libcelt/rate.c @@ -45,14 +45,14 @@ #ifndef STATIC_MODES -celt_int16_t **compute_alloc_cache(CELTMode *m, int C) +celt_int16 **compute_alloc_cache(CELTMode *m, int C) { int i, prevN; int error = 0; - celt_int16_t **bits; - const celt_int16_t *eBands = m->eBands; + celt_int16 **bits; + const celt_int16 *eBands = m->eBands; - bits = celt_alloc(m->nbEBands*sizeof(celt_int16_t*)); + bits = celt_alloc(m->nbEBands*sizeof(celt_int16*)); if (bits==NULL) return NULL; @@ -64,10 +64,10 @@ celt_int16_t **compute_alloc_cache(CELTMode *m, int C) { bits[i] = bits[i-1]; } else { - bits[i] = celt_alloc(MAX_PSEUDO*sizeof(celt_int16_t)); + bits[i] = celt_alloc(MAX_PSEUDO*sizeof(celt_int16)); if (bits[i]!=NULL) { int j; - celt_int16_t tmp[MAX_PULSES]; + celt_int16 tmp[MAX_PULSES]; get_required_bits(tmp, N, MAX_PULSES, BITRES); for (j=0;j<MAX_PSEUDO;j++) bits[i][j] = tmp[get_pulses(j)]; @@ -79,7 +79,7 @@ celt_int16_t **compute_alloc_cache(CELTMode *m, int C) } if (error) { - const celt_int16_t *prevPtr = NULL; + const celt_int16 *prevPtr = NULL; if (bits!=NULL) { for (i=0;i<m->nbEBands;i++) diff --git a/libcelt/rate.h b/libcelt/rate.h index 4dbd91d417df2ceaac02b626c823e4b0b81102ba..2c2e1c769fc8a993c57557bebed53f10426136e4 100644 --- a/libcelt/rate.h +++ b/libcelt/rate.h @@ -51,7 +51,7 @@ static inline int get_pulses(int i) return i<8 ? i : (8 + (i&7)) << ((i>>3)-1); } -static inline int bits2pulses(const CELTMode *m, const celt_int16_t *cache, int N, int bits) +static inline int bits2pulses(const CELTMode *m, const celt_int16 *cache, int N, int bits) { int i; int lo, hi; @@ -131,7 +131,7 @@ static inline int bits2pulses(const CELTMode *m, const celt_int16_t *cache, int } -static inline int pulses2bits(const celt_int16_t *cache, int N, int pulses) +static inline int pulses2bits(const celt_int16 *cache, int N, int pulses) { #if 0 /* Use of more than MAX_PULSES is disabled until we are able to cwrs that decently */ if (pulses > 127) @@ -154,7 +154,7 @@ static inline int pulses2bits(const celt_int16_t *cache, int N, int pulses) } /** Computes a cache of the pulses->bits mapping in each band */ -celt_int16_t **compute_alloc_cache(CELTMode *m, int C); +celt_int16 **compute_alloc_cache(CELTMode *m, int C); /** Compute the pulse allocation, i.e. how many pulses will go in each * band. diff --git a/libcelt/testcelt.c b/libcelt/testcelt.c index 9e6c2d1f5b552a937a4a06ea0b081484493671fe..bcaf391efea526c5b53502d61a041c672bba42ce 100644 --- a/libcelt/testcelt.c +++ b/libcelt/testcelt.c @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) CELTEncoder *enc; CELTDecoder *dec; int len; - celt_int32_t frame_size, channels; + celt_int32 frame_size, channels; int bytes_per_packet; unsigned char data[MAX_PACKET]; int rate; @@ -61,8 +61,8 @@ int main(int argc, char *argv[]) double rmsd = 0; #endif int count = 0; - celt_int32_t skip; - celt_int16_t *in, *out; + celt_int32 skip; + celt_int16 *in, *out; if (argc != 9 && argc != 8 && argc != 7) { fprintf (stderr, "Usage: testcelt <rate> <channels> <frame size> " @@ -126,8 +126,8 @@ int main(int argc, char *argv[]) } celt_mode_info(mode, CELT_GET_FRAME_SIZE, &frame_size); - in = (celt_int16_t*)malloc(frame_size*channels*sizeof(celt_int16_t)); - out = (celt_int16_t*)malloc(frame_size*channels*sizeof(celt_int16_t)); + in = (celt_int16*)malloc(frame_size*channels*sizeof(celt_int16)); + out = (celt_int16*)malloc(frame_size*channels*sizeof(celt_int16)); while (!feof(fin)) { err = fread(in, sizeof(short), frame_size*channels, fin); diff --git a/tests/cwrs32-test.c b/tests/cwrs32-test.c index 345bee10895d81cb75b263ec0894dddfe82b7a6a..9cc623118691a893b61a199b14aac3e2edf1c190 100644 --- a/tests/cwrs32-test.c +++ b/tests/cwrs32-test.c @@ -33,21 +33,21 @@ int main(int _argc,char **_argv){ dk=kmax[n]>7?kmax[n]/7:1; k=1-dk; do{ - celt_uint32_t uu[KMAX+2U]; - celt_uint32_t inc; - celt_uint32_t nc; - celt_uint32_t i; + celt_uint32 uu[KMAX+2U]; + celt_uint32 inc; + celt_uint32 nc; + celt_uint32 i; k=kmax[n]-dk<k?kmax[n]:k+dk; printf("Testing CWRS with N=%i, K=%i...\n",n,k); nc=ncwrs_urow(n,k,uu); inc=nc/10000; if(inc<1)inc=1; for(i=0;i<nc;i+=inc){ - celt_uint32_t u[KMAX+2U]; + celt_uint32 u[KMAX+2U]; int y[NMAX]; int yy[5]; - celt_uint32_t v; - celt_uint32_t ii; + celt_uint32 v; + celt_uint32 ii; int kk; int j; memcpy(u,uu,(k+2U)*sizeof(*u)); diff --git a/tests/mathops-test.c b/tests/mathops-test.c index f0e6e22d88ae8890b0a1ffd992fd016d0579134e..bb854fa555fc89c3cd033edae1b48650fff37b05 100644 --- a/tests/mathops-test.c +++ b/tests/mathops-test.c @@ -19,7 +19,7 @@ int ret = 0; void testdiv(void) { - celt_int32_t i; + celt_int32 i; for (i=1;i<=327670;i++) { double prod; @@ -40,7 +40,7 @@ void testdiv(void) void testsqrt(void) { - celt_int32_t i; + celt_int32 i; for (i=1;i<=1000000000;i++) { double ratio; @@ -58,7 +58,7 @@ void testsqrt(void) void testrsqrt(void) { - celt_int32_t i; + celt_int32 i; for (i=1;i<=2000000;i++) { double ratio; diff --git a/tests/type-test.c b/tests/type-test.c index 47a676eb676076763d693298ac7b3c5199831885..e0b1e62376f7f7c35262bb96339221320b2dc050 100644 --- a/tests/type-test.c +++ b/tests/type-test.c @@ -7,22 +7,17 @@ int main(void) { - celt_int16_t i = 1; + celt_int16 i = 1; i <<= 14; if (i>>14 != 1) { - fprintf(stderr, "celt_int16_t isn't 16 bits\n"); + fprintf(stderr, "celt_int16 isn't 16 bits\n"); return 1; } - if (sizeof(celt_int16_t)*2 != sizeof(celt_int32_t)) + if (sizeof(celt_int16)*2 != sizeof(celt_int32)) { fprintf(stderr, "16*2 != 32\n"); return 1; } - if (sizeof(celt_int32_t)*2 != sizeof(celt_int64_t)) - { - fprintf(stderr, "32*2 != 64\n"); - return 1; - } return 0; } diff --git a/tools/celtdec.c b/tools/celtdec.c index 83edaddb911fae93b4d72f6f5fbc37cc0a1f58b0..11dc361a777a4b166d00357a955d78a9aa399525 100644 --- a/tools/celtdec.c +++ b/tools/celtdec.c @@ -286,7 +286,7 @@ void version_short(void) printf ("Copyright (C) 2008 Jean-Marc Valin\n"); } -static CELTDecoder *process_header(ogg_packet *op, celt_int32_t enh_enabled, celt_int32_t *frame_size, int *granule_frame_size, celt_int32_t *rate, int *nframes, int forceMode, int *channels, int *overlap, int *extra_headers, int quiet, CELTMode **mode) +static CELTDecoder *process_header(ogg_packet *op, celt_int32 enh_enabled, celt_int32 *frame_size, int *granule_frame_size, celt_int32 *rate, int *nframes, int forceMode, int *channels, int *overlap, int *extra_headers, int quiet, CELTMode **mode) { CELTDecoder *st; CELTHeader header; @@ -581,7 +581,7 @@ int main(int argc, char **argv) } if (print_bitrate) { - celt_int32_t tmp=op.bytes; + celt_int32 tmp=op.bytes; char ch=13; fputc (ch, stderr); fprintf (stderr, "Bitrate in use: %d bytes/packet ", tmp); diff --git a/tools/celtenc.c b/tools/celtenc.c index cad89db31c94c05f784ced4afcc0d035ea2dbedd..8a44d7904c717a0256e94187557f5f6a61a6fb97 100644 --- a/tools/celtenc.c +++ b/tools/celtenc.c @@ -85,7 +85,7 @@ int oe_write_page(ogg_page *page, FILE *fp) #define IMAX(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum int value. */ /* Convert input audio bits, endians and channels */ -static int read_samples(FILE *fin,int frame_size, int bits, int channels, int lsb, short * input, char *buff, celt_int32_t *size) +static int read_samples(FILE *fin,int frame_size, int bits, int channels, int lsb, short * input, char *buff, celt_int32 *size) { unsigned char in[MAX_FRAME_SIZE*2]; int i; @@ -167,7 +167,7 @@ void add_fishead_packet (ogg_stream_state *os) { /* * Adds the fishead packets in the skeleton output stream along with the e_o_s packet */ -void add_fisbone_packet (ogg_stream_state *os, celt_int32_t serialno, CELTHeader *header) { +void add_fisbone_packet (ogg_stream_state *os, celt_int32 serialno, CELTHeader *header) { fisbone_packet fp; @@ -247,7 +247,7 @@ int main(int argc, char **argv) char *inFile, *outFile; FILE *fin, *fout; short input[MAX_FRAME_SIZE]; - celt_int32_t frame_size = 256; + celt_int32 frame_size = 256; int quiet=0; int nbBytes; CELTMode *mode; @@ -283,8 +283,8 @@ int main(int argc, char **argv) {0, 0, 0, 0} }; int print_bitrate=0; - celt_int32_t rate=44100; - celt_int32_t size; + celt_int32 rate=44100; + celt_int32 size; int chan=1; int fmt=16; int lsb=1; @@ -303,7 +303,7 @@ int main(int argc, char **argv) float bitrate=-1; char first_bytes[12]; int wave_input=0; - celt_int32_t lookahead = 0; + celt_int32 lookahead = 0; int bytes_per_packet=48; int complexity=-127; int prediction=2; diff --git a/tools/wav_io.c b/tools/wav_io.c index aea72019223ddba1aa2a25ae187d2c4714e99307..4f2ab066aa35387fe5b5ed7314e4773c28d493b5 100644 --- a/tools/wav_io.c +++ b/tools/wav_io.c @@ -40,13 +40,13 @@ #include "wav_io.h" -int read_wav_header(FILE *file, int *rate, int *channels, int *format, celt_int32_t *size) +int read_wav_header(FILE *file, int *rate, int *channels, int *format, celt_int32 *size) { char ch[5]; - celt_int32_t itmp; - celt_int16_t stmp; - celt_int32_t bpersec; - celt_int16_t balign; + celt_int32 itmp; + celt_int16 stmp; + celt_int32 bpersec; + celt_int16 balign; int skip_bytes; int i; @@ -185,8 +185,8 @@ int read_wav_header(FILE *file, int *rate, int *channels, int *format, celt_int3 void write_wav_header(FILE *file, int rate, int channels, int format, int size) { char ch[5]; - celt_int32_t itmp; - celt_int16_t stmp; + celt_int32 itmp; + celt_int16 stmp; ch[4]=0; diff --git a/tools/wav_io.h b/tools/wav_io.h index cbcf47aea749c2bad242e2289e6ccb7d14501fac..11561997b582baba65f8a33a9a2cab7a3d03736c 100644 --- a/tools/wav_io.h +++ b/tools/wav_io.h @@ -44,10 +44,10 @@ #endif /** Convert little endian */ -static inline celt_int32_t le_int(celt_int32_t i) +static inline celt_int32 le_int(celt_int32 i) { #if !defined(__LITTLE_ENDIAN__) && ( defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__) ) - celt_uint32_t ui, ret; + celt_uint32 ui, ret; ui = i; ret = ui>>24; ret |= (ui>>8)&0x0000ff00; @@ -59,7 +59,7 @@ static inline celt_int32_t le_int(celt_int32_t i) #endif } -int read_wav_header(FILE *file, int *rate, int *channels, int *format, celt_int32_t *size); +int read_wav_header(FILE *file, int *rate, int *channels, int *format, celt_int32 *size); void write_wav_header(FILE *file, int rate, int channels, int format, int size);