Another C90-fying pass. Fixed some warnings in the process.

This commit is contained in:
Jean-Marc Valin 2008-03-01 07:27:03 +11:00
parent 81b38c2295
commit d748cd5570
7 changed files with 20 additions and 17 deletions

View file

@ -51,10 +51,6 @@
#define MAX_PERIOD 1024 #define MAX_PERIOD 1024
#ifndef M_PI
#define M_PI 3.141592653
#endif
/** Encoder state /** Encoder state
@brief Encoder state @brief Encoder state
*/ */
@ -87,7 +83,7 @@ struct CELTEncoder {
CELTEncoder *celt_encoder_create(const CELTMode *mode) CELTEncoder *celt_encoder_create(const CELTMode *mode)
{ {
int i, N, B, C, N4; int N, B, C;
CELTEncoder *st; CELTEncoder *st;
if (check_mode(mode) != CELT_OK) if (check_mode(mode) != CELT_OK)
@ -104,7 +100,6 @@ CELTEncoder *celt_encoder_create(const CELTMode *mode)
st->nb_blocks = B; st->nb_blocks = B;
st->overlap = mode->overlap; st->overlap = mode->overlap;
N4 = (N-st->overlap)/2;
ec_byte_writeinit(&st->buf); ec_byte_writeinit(&st->buf);
ec_enc_init(&st->enc,&st->buf); ec_enc_init(&st->enc,&st->buf);
@ -463,7 +458,7 @@ struct CELTDecoder {
CELTDecoder *celt_decoder_create(const CELTMode *mode) CELTDecoder *celt_decoder_create(const CELTMode *mode)
{ {
int i, N, B, C, N4; int N, B, C;
CELTDecoder *st; CELTDecoder *st;
if (check_mode(mode) != CELT_OK) if (check_mode(mode) != CELT_OK)
@ -480,8 +475,6 @@ CELTDecoder *celt_decoder_create(const CELTMode *mode)
st->nb_blocks = B; st->nb_blocks = B;
st->overlap = mode->overlap; st->overlap = mode->overlap;
N4 = (N-st->overlap)/2;
st->mdct_overlap = celt_alloc(N*C*sizeof(celt_sig_t)); st->mdct_overlap = celt_alloc(N*C*sizeof(celt_sig_t));
st->out_mem = celt_alloc(MAX_PERIOD*C*sizeof(celt_sig_t)); st->out_mem = celt_alloc(MAX_PERIOD*C*sizeof(celt_sig_t));

View file

@ -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) void mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out)
{ {
int i; int i;
int N, N2, N4, N8; int N, N2, N4;
VARDECL(kiss_fft_scalar *f); VARDECL(kiss_fft_scalar *f);
SAVE_STACK; SAVE_STACK;
N = l->n; N = l->n;
N2 = N/2; N2 = N/2;
N4 = N/4; N4 = N/4;
N8 = N/8;
ALLOC(f, N2, kiss_fft_scalar); ALLOC(f, N2, kiss_fft_scalar);
/* Pre-rotate */ /* Pre-rotate */

View file

@ -41,6 +41,10 @@
#define MODEVALID 0xa110ca7e #define MODEVALID 0xa110ca7e
#define MODEFREED 0xb10cf8ee #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) 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;i<mode->overlap;i++) for (i=0;i<mode->overlap;i++)
mode->window[N4+i] = mode->window[2*N-N4-i-1] 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)); = 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;i<N2;i++)
mode->window[N-N4+i] = Q15ONE; mode->window[N-N4+i] = Q15ONE;
mode->marker_start = MODEVALID; mode->marker_start = MODEVALID;

View file

@ -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 *X);
VARDECL(celt_word32_t *Y); VARDECL(celt_word32_t *Y);
VARDECL(celt_mask_t *curve); VARDECL(celt_mask_t *curve);
int n2;
SAVE_STACK; SAVE_STACK;
int n2 = lag/2; n2 = lag/2;
ALLOC(xx, lag*C, celt_word32_t); ALLOC(xx, lag*C, celt_word32_t);
ALLOC(X, lag*C, celt_word32_t); ALLOC(X, lag*C, celt_word32_t);
ALLOC(curve, n2*C, celt_mask_t); ALLOC(curve, n2*C, celt_mask_t);

View file

@ -126,8 +126,9 @@ void compute_masking(struct PsyDecay *decay, celt_word32_t *X, celt_mask_t *mask
{ {
int i; int i;
VARDECL(float *psd); VARDECL(float *psd);
int N;
SAVE_STACK; SAVE_STACK;
int N=len/2; N=len/2;
ALLOC(psd, N, float); ALLOC(psd, N, float);
psd[0] = X[0]*1.f*X[0]; psd[0] = X[0]*1.f*X[0];
for (i=1;i<N;i++) for (i=1;i<N;i++)

View file

@ -89,10 +89,11 @@ static void quant_energy_mono(const CELTMode *m, celt_ener_t *eBands, celt_word1
int bits; int bits;
celt_word16_t prev = 0; celt_word16_t prev = 0;
celt_word16_t coef = m->ePredCoef; celt_word16_t coef = m->ePredCoef;
celt_word16_t beta;
VARDECL(celt_word16_t *error); VARDECL(celt_word16_t *error);
SAVE_STACK; SAVE_STACK;
/* The .7 is a heuristic */ /* 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); ALLOC(error, m->nbEBands, celt_word16_t);
bits = ec_enc_tell(enc, 0); bits = ec_enc_tell(enc, 0);

View file

@ -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(celt_norm_t **ny);
VARDECL(int **iy); VARDECL(int **iy);
VARDECL(int **iny); VARDECL(int **iny);
SAVE_STACK;
int i, j, k, m; int i, j, k, m;
int pulsesLeft; int pulsesLeft;
VARDECL(celt_word32_t *xy); 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; celt_word32_t Rpp=0, Rxp=0;
int maxL = 1; int maxL = 1;
#ifdef FIXED_POINT #ifdef FIXED_POINT
int yshift = 14-EC_ILOG(K); int yshift;
#endif
SAVE_STACK;
#ifdef FIXED_POINT
yshift = 14-EC_ILOG(K);
#endif #endif
ALLOC(_y, L*N, celt_norm_t); ALLOC(_y, L*N, celt_norm_t);