shithub: opus

Download patch

ref: 40f956eed01dc512e3f53d2e90a5fd281a4706a6
parent: b6c3f06b538413701a76087036ddb775fa7126da
author: Gregory Maxwell <[email protected]>
date: Thu Sep 1 15:42:37 EDT 2011

Various minor cleanups (removing dead arguments, macros) to libcelt/. Reinstate -Wunused-parameter.

--- a/configure.ac
+++ b/configure.ac
@@ -161,7 +161,7 @@
 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])
--- a/libcelt/arch.h
+++ b/libcelt/arch.h
@@ -87,7 +87,6 @@
 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 celt_sig;
 typedef float celt_norm;
 typedef float celt_ener;
-typedef float celt_pgain;
-typedef float celt_mask;
 
 #define Q15ONE 1.0f
 
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -1059,9 +1059,15 @@
 
          /* 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;
--- a/libcelt/bands.h
+++ b/libcelt/bands.h
@@ -86,8 +86,6 @@
       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);
--- a/libcelt/cwrs.c
+++ b/libcelt/cwrs.c
@@ -539,7 +539,7 @@
    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;
--- a/libcelt/laplace.c
+++ b/libcelt/laplace.c
@@ -68,7 +68,7 @@
          fs = (fs*(opus_int32)decay)>>15;
       }
       /* Everything beyond that has probability LAPLACE_MINP. */
-      if (fs <= 0)
+      if (!fs)
       {
          int di;
          int ndi_max;
--- a/libcelt/mathops.h
+++ b/libcelt/mathops.h
@@ -49,9 +49,7 @@
 #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))
--- 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++)
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -399,17 +399,19 @@
 
 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;i<TOTAL_MODES;i++)
    {
-      if (mode == static_mode_list[i])
-      {
-         return;
-      }
+     int i;
+     for (i=0;i<TOTAL_MODES;i++)
+     {
+        if (mode == static_mode_list[i])
+        {
+           return;
+        }
+     }
    }
 #endif /* CUSTOM_MODES_ONLY */
    opus_free((opus_int16*)mode->eBands);
--- 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 @@
    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 @@
       for (j=0;j<len>>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<max_pitch>>1;i++)
    {
       opus_val32 sum=0;
@@ -210,9 +224,15 @@
       for (j=0;j<len>>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)
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -305,6 +305,7 @@
 
    if (!intra)
    {
+      unsigned char *intra_buf;
       ec_enc enc_intra_state;
       opus_int32 tell_intra;
       opus_uint32 nstart_bytes;
@@ -318,11 +319,10 @@
 
       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 @@
       {
          *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;
--- a/libcelt/quant_bands.h
+++ b/libcelt/quant_bands.h
@@ -41,9 +41,6 @@
 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,
--- a/libcelt/rate.h
+++ b/libcelt/rate.h
@@ -86,9 +86,6 @@
    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
--- a/libcelt/tests/cwrs32-test.c
+++ b/libcelt/tests/cwrs32-test.c
@@ -53,7 +53,7 @@
 
 #endif
 
-int main(int _argc,char **_argv){
+int main(void){
   int t;
   int n;
   ALLOC_STACK;
--- a/libcelt/tests/mdct-test.c
+++ b/libcelt/tests/mdct-test.c
@@ -69,7 +69,7 @@
          double phase = 2*M_PI*(bin+.5+.25*nfft)*(k+.5)/nfft;
          double re = cos(phase);
 
-         //re *= 2;
+         /*re *= 2;*/
 
          ansr += in[k] * re;
       }
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -166,8 +166,11 @@
    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);
--- 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)