From 40f956eed01dc512e3f53d2e90a5fd281a4706a6 Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Thu, 1 Sep 2011 19:42:37 -0400 Subject: [PATCH] Various minor cleanups (removing dead arguments, macros) to libcelt/. Reinstate -Wunused-parameter. --- configure.ac | 2 +- libcelt/arch.h | 3 --- libcelt/bands.c | 10 ++++++++-- libcelt/bands.h | 2 -- libcelt/cwrs.c | 2 +- libcelt/laplace.c | 2 +- libcelt/mathops.h | 2 -- libcelt/mdct.c | 6 ++++-- libcelt/modes.c | 16 +++++++++------- libcelt/pitch.c | 30 +++++++++++++++++++++++++----- libcelt/quant_bands.c | 9 ++++----- libcelt/quant_bands.h | 3 --- libcelt/rate.h | 3 --- libcelt/tests/cwrs32-test.c | 2 +- libcelt/tests/mdct-test.c | 2 +- libcelt/vq.c | 7 +++++-- libcelt/vq.h | 6 +++++- 17 files changed, 65 insertions(+), 42 deletions(-) diff --git a/configure.ac b/configure.ac index 4f1982be..bb7a4d23 100644 --- a/configure.ac +++ b/configure.ac @@ -161,7 +161,7 @@ AC_SUBST(SYMBOL_VISIBILITY) fi if test $ac_cv_c_compiler_gnu = yes ; then - CFLAGS="$CFLAGS -W -Wstrict-prototypes -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wno-unused-parameter" + CFLAGS="$CFLAGS -W -Wstrict-prototypes -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow" fi AC_CHECK_FUNCS([lrintf]) diff --git a/libcelt/arch.h b/libcelt/arch.h index 5ef14cc5..08286e94 100644 --- a/libcelt/arch.h +++ b/libcelt/arch.h @@ -87,7 +87,6 @@ typedef opus_int32 opus_val32; typedef opus_val32 celt_sig; typedef opus_val16 celt_norm; typedef opus_val32 celt_ener; -typedef opus_val32 celt_mask; #define Q15ONE 32767 @@ -132,8 +131,6 @@ typedef float opus_val32; typedef float celt_sig; typedef float celt_norm; typedef float celt_ener; -typedef float celt_pgain; -typedef float celt_mask; #define Q15ONE 1.0f diff --git a/libcelt/bands.c b/libcelt/bands.c index 835d7262..da9c3675 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -1059,9 +1059,15 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c /* Finally do the actual quantization */ if (encode) - cm = alg_quant(X, N, K, spread, B, ec, gain); - else + { + cm = alg_quant(X, N, K, spread, B, ec +#ifdef RESYNTH + , gain +#endif + ); + } else { cm = alg_unquant(X, N, K, spread, B, ec, gain); + } } else { /* If there's no pulse, fill the band anyway */ int j; diff --git a/libcelt/bands.h b/libcelt/bands.h index 9bb2f7ea..25c0a00e 100644 --- a/libcelt/bands.h +++ b/libcelt/bands.h @@ -86,8 +86,6 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, int time_domain, int fold, int dual_stereo, int intensity, int *tf_res, opus_int32 total_bits, opus_int32 balance, ec_ctx *ec, int M, int codedBands, opus_uint32 *seed); -void stereo_decision(const CELTMode *m, celt_norm * restrict X, int *stereo_mode, int len, int M); - void anti_collapse(const CELTMode *m, celt_norm *_X, unsigned char *collapse_masks, int LM, int C, int CC, int size, int start, int end, opus_val16 *logE, opus_val16 *prev1logE, opus_val16 *prev2logE, int *pulses, opus_uint32 seed); diff --git a/libcelt/cwrs.c b/libcelt/cwrs.c index 1a7c56f8..91be9800 100644 --- a/libcelt/cwrs.c +++ b/libcelt/cwrs.c @@ -539,7 +539,7 @@ static inline opus_uint32 icwrs4(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).*/ -opus_uint32 icwrs(int _n,int _k,opus_uint32 *_nc,const int *_y, +static inline opus_uint32 icwrs(int _n,int _k,opus_uint32 *_nc,const int *_y, opus_uint32 *_u){ opus_uint32 i; int j; diff --git a/libcelt/laplace.c b/libcelt/laplace.c index 24b68c9a..53673130 100644 --- a/libcelt/laplace.c +++ b/libcelt/laplace.c @@ -68,7 +68,7 @@ void ec_laplace_encode(ec_enc *enc, int *value, unsigned fs, int decay) fs = (fs*(opus_int32)decay)>>15; } /* Everything beyond that has probability LAPLACE_MINP. */ - if (fs <= 0) + if (!fs) { int di; int ndi_max; diff --git a/libcelt/mathops.h b/libcelt/mathops.h index d9ef3f54..4944391b 100644 --- a/libcelt/mathops.h +++ b/libcelt/mathops.h @@ -49,9 +49,7 @@ unsigned isqrt32(opus_uint32 _val); #define celt_sqrt(x) ((float)sqrt(x)) #define celt_rsqrt(x) (1.f/celt_sqrt(x)) #define celt_rsqrt_norm(x) (celt_rsqrt(x)) -#define celt_exp exp #define celt_cos_norm(x) ((float)cos((.5f*PI)*(x))) -#define celt_atan atan #define celt_rcp(x) (1.f/(x)) #define celt_div(a,b) ((a)/(b)) #define frac_div32(a,b) ((float)(a)/(b)) diff --git a/libcelt/mdct.c b/libcelt/mdct.c index 0d461e30..72011305 100644 --- a/libcelt/mdct.c +++ b/libcelt/mdct.c @@ -58,10 +58,12 @@ int clt_mdct_init(mdct_lookup *l,int N, int maxshift) { int i; - int N4, N2; + int N4; kiss_twiddle_scalar *trig; +#if defined(FIXED_POINT) + int N2=N>>1; +#endif l->n = N; - N2 = N>>1; N4 = N>>2; l->maxshift = maxshift; for (i=0;i<=maxshift;i++) diff --git a/libcelt/modes.c b/libcelt/modes.c index 3b64dd68..0c3e374e 100644 --- a/libcelt/modes.c +++ b/libcelt/modes.c @@ -399,17 +399,19 @@ failure: void opus_custom_mode_destroy(CELTMode *mode) { -#ifdef CUSTOM_MODES - int i; if (mode == NULL) return; +#ifdef CUSTOM_MODES #ifndef CUSTOM_MODES_ONLY - for (i=0;ieBands); diff --git a/libcelt/pitch.c b/libcelt/pitch.c index bc8680d7..f6a97f9b 100644 --- a/libcelt/pitch.c +++ b/libcelt/pitch.c @@ -41,8 +41,12 @@ #include "stack_alloc.h" #include "mathops.h" -static void find_best_pitch(opus_val32 *xcorr, opus_val32 maxcorr, opus_val16 *y, - int yshift, int len, int max_pitch, int *best_pitch) +static void find_best_pitch(opus_val32 *xcorr, opus_val16 *y, int len, + int max_pitch, int *best_pitch +#ifdef FIXED_POINT + , int yshift, opus_val32 maxcorr +#endif + ) { int i, j; opus_val32 Syy=1; @@ -154,9 +158,11 @@ void pitch_search(const opus_val16 * restrict x_lp, opus_val16 * restrict y, VARDECL(opus_val16, x_lp4); VARDECL(opus_val16, y_lp4); VARDECL(opus_val32, xcorr); +#ifdef FIXED_POINT opus_val32 maxcorr=1; - int offset; int shift=0; +#endif + int offset; SAVE_STACK; @@ -195,12 +201,20 @@ void pitch_search(const opus_val16 * restrict x_lp, opus_val16 * restrict y, for (j=0;j>2;j++) sum = MAC16_16(sum, x_lp4[j],y_lp4[i+j]); xcorr[i] = MAX32(-1, sum); +#ifdef FIXED_POINT maxcorr = MAX32(maxcorr, sum); +#endif } - find_best_pitch(xcorr, maxcorr, y_lp4, 0, len>>2, max_pitch>>2, best_pitch); + find_best_pitch(xcorr, y_lp4, len>>2, max_pitch>>2, best_pitch +#ifdef FIXED_POINT + , 0, maxcorr +#endif + ); /* Finer search with 2x decimation */ +#ifdef FIXED_POINT maxcorr=1; +#endif for (i=0;i>1;i++) { opus_val32 sum=0; @@ -210,9 +224,15 @@ void pitch_search(const opus_val16 * restrict x_lp, opus_val16 * restrict y, for (j=0;j>1;j++) sum += SHR32(MULT16_16(x_lp[j],y[i+j]), shift); xcorr[i] = MAX32(-1, sum); +#ifdef FIXED_POINT maxcorr = MAX32(maxcorr, sum); +#endif } - find_best_pitch(xcorr, maxcorr, y, shift, len>>1, max_pitch>>1, best_pitch); + find_best_pitch(xcorr, y, len>>1, max_pitch>>1, best_pitch +#ifdef FIXED_POINT + , shift, maxcorr +#endif + ); /* Refine by pseudo-interpolation */ if (best_pitch[0]>0 && best_pitch[0]<(max_pitch>>1)-1) diff --git a/libcelt/quant_bands.c b/libcelt/quant_bands.c index ceb15182..9927a189 100644 --- a/libcelt/quant_bands.c +++ b/libcelt/quant_bands.c @@ -305,6 +305,7 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, if (!intra) { + unsigned char *intra_buf; ec_enc enc_intra_state; opus_int32 tell_intra; opus_uint32 nstart_bytes; @@ -318,11 +319,10 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, nstart_bytes = ec_range_bytes(&enc_start_state); nintra_bytes = ec_range_bytes(&enc_intra_state); + intra_buf = ec_get_buffer(&enc_intra_state) + nstart_bytes; ALLOC(intra_bits, nintra_bytes-nstart_bytes, unsigned char); /* Copy bits from intra bit-stream */ - OPUS_COPY(intra_bits, - ec_get_buffer(&enc_intra_state) + nstart_bytes, - nintra_bytes - nstart_bytes); + OPUS_COPY(intra_bits, intra_buf, nintra_bytes - nstart_bytes); *enc = enc_start_state; @@ -333,8 +333,7 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, { *enc = enc_intra_state; /* Copy intra bits to bit-stream */ - OPUS_COPY(ec_get_buffer(&enc_intra_state) + nstart_bytes, - intra_bits, nintra_bytes - nstart_bytes); + OPUS_COPY(intra_buf, intra_bits, nintra_bytes - nstart_bytes); OPUS_COPY(oldEBands, oldEBands_intra, C*m->nbEBands); OPUS_COPY(error, error_intra, C*m->nbEBands); intra = 1; diff --git a/libcelt/quant_bands.h b/libcelt/quant_bands.h index 3700c4c2..9eeae4b3 100644 --- a/libcelt/quant_bands.h +++ b/libcelt/quant_bands.h @@ -41,9 +41,6 @@ void amp2Log2(const CELTMode *m, int effEnd, int end, void log2Amp(const CELTMode *m, int start, int end, celt_ener *eBands, opus_val16 *oldEBands, int _C); -unsigned char *quant_prob_alloc(const CELTMode *m); -void quant_prob_free(const opus_int16 *freq); - void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, const opus_val16 *eBands, opus_val16 *oldEBands, opus_uint32 budget, opus_val16 *error, ec_enc *enc, int _C, int LM, diff --git a/libcelt/rate.h b/libcelt/rate.h index e1346eed..d19d0b30 100644 --- a/libcelt/rate.h +++ b/libcelt/rate.h @@ -86,9 +86,6 @@ static inline int pulses2bits(const CELTMode *m, int band, int LM, int pulses) return pulses == 0 ? 0 : cache[pulses]+1; } -/** Computes a cache of the pulses->bits mapping in each band */ -opus_int16 **compute_alloc_cache(CELTMode *m, int M); - /** Compute the pulse allocation, i.e. how many pulses will go in each * band. @param m mode diff --git a/libcelt/tests/cwrs32-test.c b/libcelt/tests/cwrs32-test.c index b6158c59..b8885d6c 100644 --- a/libcelt/tests/cwrs32-test.c +++ b/libcelt/tests/cwrs32-test.c @@ -53,7 +53,7 @@ static const int pkmax[NDIMS]={ #endif -int main(int _argc,char **_argv){ +int main(void){ int t; int n; ALLOC_STACK; diff --git a/libcelt/tests/mdct-test.c b/libcelt/tests/mdct-test.c index f6b24679..4f0733a8 100644 --- a/libcelt/tests/mdct-test.c +++ b/libcelt/tests/mdct-test.c @@ -69,7 +69,7 @@ void check_inv(kiss_fft_scalar * in,kiss_fft_scalar * out,int nfft,int isinver double phase = 2*M_PI*(bin+.5+.25*nfft)*(k+.5)/nfft; double re = cos(phase); - //re *= 2; + /*re *= 2;*/ ansr += in[k] * re; } diff --git a/libcelt/vq.c b/libcelt/vq.c index 89b36873..ce807b36 100644 --- a/libcelt/vq.c +++ b/libcelt/vq.c @@ -166,8 +166,11 @@ static unsigned extract_collapse_mask(int *iy, int N, int B) return collapse_mask; } -unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, - ec_enc *enc, opus_val16 gain) +unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc +#ifdef RESYNTH + , opus_val16 gain +#endif + ) { VARDECL(celt_norm, y); VARDECL(int, iy); diff --git a/libcelt/vq.h b/libcelt/vq.h index a74743bd..4193ae5c 100644 --- a/libcelt/vq.h +++ b/libcelt/vq.h @@ -49,7 +49,11 @@ * @ret A mask indicating which blocks in the band received pulses */ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, - ec_enc *enc, opus_val16 gain); + ec_enc *enc +#ifdef RESYNTH + , opus_val16 gain +#endif + ); /** Algebraic pulse decoder * @param x Decoded normalised spectrum (returned)