From d748cd557018cb3691c5c83ac8dc875d95c92725 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Sat, 1 Mar 2008 07:27:03 +1100 Subject: [PATCH] Another C90-fying pass. Fixed some warnings in the process. --- libcelt/celt.c | 11 ++--------- libcelt/mdct.c | 3 +-- libcelt/modes.c | 6 +++++- libcelt/pitch.c | 3 ++- libcelt/psy.c | 3 ++- libcelt/quant_bands.c | 3 ++- libcelt/vq.c | 8 ++++++-- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/libcelt/celt.c b/libcelt/celt.c index 4bd083e6..071e4efe 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -51,10 +51,6 @@ #define MAX_PERIOD 1024 -#ifndef M_PI -#define M_PI 3.141592653 -#endif - /** Encoder state @brief Encoder state */ @@ -87,7 +83,7 @@ struct CELTEncoder { CELTEncoder *celt_encoder_create(const CELTMode *mode) { - int i, N, B, C, N4; + int N, B, C; CELTEncoder *st; if (check_mode(mode) != CELT_OK) @@ -104,7 +100,6 @@ CELTEncoder *celt_encoder_create(const CELTMode *mode) st->nb_blocks = B; st->overlap = mode->overlap; - N4 = (N-st->overlap)/2; ec_byte_writeinit(&st->buf); ec_enc_init(&st->enc,&st->buf); @@ -463,7 +458,7 @@ struct CELTDecoder { CELTDecoder *celt_decoder_create(const CELTMode *mode) { - int i, N, B, C, N4; + int N, B, C; CELTDecoder *st; if (check_mode(mode) != CELT_OK) @@ -480,8 +475,6 @@ CELTDecoder *celt_decoder_create(const CELTMode *mode) st->nb_blocks = B; st->overlap = mode->overlap; - N4 = (N-st->overlap)/2; - st->mdct_overlap = celt_alloc(N*C*sizeof(celt_sig_t)); st->out_mem = celt_alloc(MAX_PERIOD*C*sizeof(celt_sig_t)); diff --git a/libcelt/mdct.c b/libcelt/mdct.c index 1f090ff1..8cc6997f 100644 --- a/libcelt/mdct.c +++ b/libcelt/mdct.c @@ -135,13 +135,12 @@ void mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *ou void mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out) { int i; - int N, N2, N4, N8; + int N, N2, N4; VARDECL(kiss_fft_scalar *f); SAVE_STACK; N = l->n; N2 = N/2; N4 = N/4; - N8 = N/8; ALLOC(f, N2, kiss_fft_scalar); /* Pre-rotate */ diff --git a/libcelt/modes.c b/libcelt/modes.c index 22b6968e..f4617606 100644 --- a/libcelt/modes.c +++ b/libcelt/modes.c @@ -41,6 +41,10 @@ #define MODEVALID 0xa110ca7e #define MODEFREED 0xb10cf8ee +#ifndef M_PI +#define M_PI 3.141592653 +#endif + int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value) { @@ -273,7 +277,7 @@ CELTMode *celt_mode_create(int Fs, int channels, int frame_size, int lookahead, for (i=0;ioverlap;i++) mode->window[N4+i] = mode->window[2*N-N4-i-1] = Q15ONE*sin(.5*M_PI* sin(.5*M_PI*(i+.5)/mode->overlap) * sin(.5*M_PI*(i+.5)/mode->overlap)); - for (i=0;i<2*N4;i++) + for (i=0;iwindow[N-N4+i] = Q15ONE; mode->marker_start = MODEVALID; diff --git a/libcelt/pitch.c b/libcelt/pitch.c index d5b6858c..11550975 100644 --- a/libcelt/pitch.c +++ b/libcelt/pitch.c @@ -52,8 +52,9 @@ void find_spectral_pitch(kiss_fftr_cfg fft, struct PsyDecay *decay, celt_sig_t * VARDECL(celt_word32_t *X); VARDECL(celt_word32_t *Y); VARDECL(celt_mask_t *curve); + int n2; SAVE_STACK; - int n2 = lag/2; + n2 = lag/2; ALLOC(xx, lag*C, celt_word32_t); ALLOC(X, lag*C, celt_word32_t); ALLOC(curve, n2*C, celt_mask_t); diff --git a/libcelt/psy.c b/libcelt/psy.c index 6e2e1b54..045a8a8c 100644 --- a/libcelt/psy.c +++ b/libcelt/psy.c @@ -126,8 +126,9 @@ void compute_masking(struct PsyDecay *decay, celt_word32_t *X, celt_mask_t *mask { int i; VARDECL(float *psd); + int N; SAVE_STACK; - int N=len/2; + N=len/2; ALLOC(psd, N, float); psd[0] = X[0]*1.f*X[0]; for (i=1;iePredCoef; + celt_word16_t beta; VARDECL(celt_word16_t *error); SAVE_STACK; /* The .7 is a heuristic */ - celt_word16_t beta = MULT16_16_Q15(QCONST16(.7f,15),coef); + beta = MULT16_16_Q15(QCONST16(.7f,15),coef); ALLOC(error, m->nbEBands, celt_word16_t); bits = ec_enc_tell(enc, 0); diff --git a/libcelt/vq.c b/libcelt/vq.c index 68053b8b..f9b529bf 100644 --- a/libcelt/vq.c +++ b/libcelt/vq.c @@ -130,7 +130,6 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, celt_norm_t *P, cel VARDECL(celt_norm_t **ny); VARDECL(int **iy); VARDECL(int **iny); - SAVE_STACK; int i, j, k, m; int pulsesLeft; VARDECL(celt_word32_t *xy); @@ -141,7 +140,12 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, celt_norm_t *P, cel celt_word32_t Rpp=0, Rxp=0; int maxL = 1; #ifdef FIXED_POINT - int yshift = 14-EC_ILOG(K); + int yshift; +#endif + SAVE_STACK; + +#ifdef FIXED_POINT + yshift = 14-EC_ILOG(K); #endif ALLOC(_y, L*N, celt_norm_t);