ref: d748cd557018cb3691c5c83ac8dc875d95c92725
parent: 81b38c2295700e450f80d09e97d04dcb87aff617
author: Jean-Marc Valin <[email protected]>
date: Sat Mar 1 02:27:03 EST 2008
Another C90-fying pass. Fixed some warnings in the process.
--- 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 @@
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 @@
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 @@
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 @@
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));
--- a/libcelt/mdct.c
+++ b/libcelt/mdct.c
@@ -135,13 +135,12 @@
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 */
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -41,7 +41,11 @@
#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)
{
switch (request)
@@ -273,7 +277,7 @@
for (i=0;i<mode->overlap;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;i<N2;i++)
mode->window[N-N4+i] = Q15ONE;
mode->marker_start = MODEVALID;
--- a/libcelt/pitch.c
+++ b/libcelt/pitch.c
@@ -52,8 +52,9 @@
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);
--- a/libcelt/psy.c
+++ b/libcelt/psy.c
@@ -126,8 +126,9 @@
{
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;i<N;i++)
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -89,10 +89,11 @@
int bits;
celt_word16_t prev = 0;
celt_word16_t coef = m->ePredCoef;
+ 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);
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -130,7 +130,6 @@
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 @@
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);