shithub: opus

Download patch

ref: 120800f8fa478d75ad9f94d91dae775386c6b0d5
parent: e1be1920bac28c897a940be55319abbb1bed0f51
author: Ralph Giles <[email protected]>
date: Fri Nov 25 08:02:00 EST 2011

Rename '_FOO' to avoid potentional collisions with reserved identifiers.

C reserves identifiers of the from _[A-Z]+ and we have a number of
those in the code. This patch renames the various function arguments,
MACROS and preprocessor symbols to avoid the reserved form.

It also removes the CHANNELS() macro altogether. This was a
minor optimization for TI DSP to force a mono-only build,
as were the associated local 'const' versions. Since stereo
support is manditory, it wasn't worth keeping.

Thanks to John Ridges for raising the issue, and Jean-Marc Valin
and Greg Maxwell for reviewing the changes.

--- a/celt/bands.c
+++ b/celt/bands.c
@@ -75,11 +75,10 @@
 
 #ifdef FIXED_POINT
 /* Compute the amplitude (sqrt energy) in each of the bands */
-void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bank, int end, int _C, int M)
+void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bank, int end, int C, int M)
 {
    int i, c, N;
    const opus_int16 *eBands = m->eBands;
-   const int C = CHANNELS(_C);
    N = M*m->shortMdctSize;
    c=0; do {
       for (i=0;i<end;i++)
@@ -113,11 +112,10 @@
 }
 
 /* Normalise each band such that the energy is one. */
-void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_norm * restrict X, const celt_ener *bank, int end, int _C, int M)
+void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_norm * restrict X, const celt_ener *bank, int end, int C, int M)
 {
    int i, c, N;
    const opus_int16 *eBands = m->eBands;
-   const int C = CHANNELS(_C);
    N = M*m->shortMdctSize;
    c=0; do {
       i=0; do {
@@ -136,11 +134,10 @@
 
 #else /* FIXED_POINT */
 /* Compute the amplitude (sqrt energy) in each of the bands */
-void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bank, int end, int _C, int M)
+void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bank, int end, int C, int M)
 {
    int i, c, N;
    const opus_int16 *eBands = m->eBands;
-   const int C = CHANNELS(_C);
    N = M*m->shortMdctSize;
    c=0; do {
       for (i=0;i<end;i++)
@@ -157,11 +154,10 @@
 }
 
 /* Normalise each band such that the energy is one. */
-void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_norm * restrict X, const celt_ener *bank, int end, int _C, int M)
+void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_norm * restrict X, const celt_ener *bank, int end, int C, int M)
 {
    int i, c, N;
    const opus_int16 *eBands = m->eBands;
-   const int C = CHANNELS(_C);
    N = M*m->shortMdctSize;
    c=0; do {
       for (i=0;i<end;i++)
@@ -177,11 +173,10 @@
 #endif /* FIXED_POINT */
 
 /* De-normalise the energy to produce the synthesis from the unit-energy bands */
-void denormalise_bands(const CELTMode *m, const celt_norm * restrict X, celt_sig * restrict freq, const celt_ener *bank, int end, int _C, int M)
+void denormalise_bands(const CELTMode *m, const celt_norm * restrict X, celt_sig * restrict freq, const celt_ener *bank, int end, int C, int M)
 {
    int i, c, N;
    const opus_int16 *eBands = m->eBands;
-   const int C = CHANNELS(_C);
    N = M*m->shortMdctSize;
    celt_assert2(C<=2, "denormalise_bands() not implemented for >2 channels");
    c=0; do {
@@ -206,7 +201,7 @@
 }
 
 /* This prevents energy collapse for transients with multiple short MDCTs */
-void anti_collapse(const CELTMode *m, celt_norm *_X, unsigned char *collapse_masks, int LM, int C, int CC, int size,
+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)
 {
@@ -274,7 +269,7 @@
          r = MIN16(thresh, r);
          r = r*sqrt_1;
 #endif
-         X = _X+c*size+(m->eBands[i]<<LM);
+         X = X_+c*size+(m->eBands[i]<<LM);
          for (k=0;k<1<<LM;k++)
          {
             /* Detect collapse */
@@ -394,11 +389,10 @@
 /* Decide whether we should spread the pulses in the current frame */
 int spreading_decision(const CELTMode *m, celt_norm *X, int *average,
       int last_decision, int *hf_average, int *tapset_decision, int update_hf,
-      int end, int _C, int M)
+      int end, int C, int M)
 {
    int i, c, N0;
    int sum = 0, nbBands=0;
-   const int C = CHANNELS(_C);
    const opus_int16 * restrict eBands = m->eBands;
    int decision;
    int hf_sum=0;
@@ -1171,7 +1165,7 @@
 }
 
 void quant_all_bands(int encode, const CELTMode *m, int start, int end,
-      celt_norm *_X, celt_norm *_Y, unsigned char *collapse_masks, const celt_ener *bandE, int *pulses,
+      celt_norm *X_, celt_norm *Y_, unsigned char *collapse_masks, const celt_ener *bandE, int *pulses,
       int shortBlocks, int spread, int dual_stereo, int intensity, int *tf_res,
       opus_int32 total_bits, opus_int32 balance, ec_ctx *ec, int LM, int codedBands, opus_uint32 *seed)
 {
@@ -1185,7 +1179,7 @@
    int M;
    int lowband_offset;
    int update_lowband = 1;
-   int C = _Y != NULL ? 2 : 1;
+   int C = Y_ != NULL ? 2 : 1;
 #ifdef RESYNTH
    int resynth = 1;
 #else
@@ -1213,9 +1207,9 @@
       unsigned x_cm;
       unsigned y_cm;
 
-      X = _X+M*eBands[i];
-      if (_Y!=NULL)
-         Y = _Y+M*eBands[i];
+      X = X_+M*eBands[i];
+      if (Y_!=NULL)
+         Y = Y_+M*eBands[i];
       else
          Y = NULL;
       N = M*eBands[i+1]-M*eBands[i];
@@ -1240,7 +1234,7 @@
       if (i>=m->effEBands)
       {
          X=norm;
-         if (_Y!=NULL)
+         if (Y_!=NULL)
             Y = norm;
       }
 
--- a/celt/bands.h
+++ b/celt/bands.h
@@ -41,7 +41,7 @@
  * @param X Spectrum
  * @param bands Square root of the energy for each band (returned)
  */
-void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bands, int end, int _C, int M);
+void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bands, int end, int C, int M);
 
 /*void compute_noise_energies(const CELTMode *m, const celt_sig *X, const opus_val16 *tonality, celt_ener *bank);*/
 
@@ -51,7 +51,7 @@
  * @param X Spectrum (returned normalised)
  * @param bands Square root of the energy for each band
  */
-void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_norm * restrict X, const celt_ener *bands, int end, int _C, int M);
+void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_norm * restrict X, const celt_ener *bands, int end, int C, int M);
 
 /** Denormalise each band of X to restore full amplitude
  * @param m Mode data
@@ -58,7 +58,7 @@
  * @param X Spectrum (returned de-normalised)
  * @param bands Square root of the energy for each band
  */
-void denormalise_bands(const CELTMode *m, const celt_norm * restrict X, celt_sig * restrict freq, const celt_ener *bands, int end, int _C, int M);
+void denormalise_bands(const CELTMode *m, const celt_norm * restrict X, celt_sig * restrict freq, const celt_ener *bands, int end, int C, int M);
 
 #define SPREAD_NONE       (0)
 #define SPREAD_LIGHT      (1)
@@ -67,7 +67,7 @@
 
 int spreading_decision(const CELTMode *m, celt_norm *X, int *average,
       int last_decision, int *hf_average, int *tapset_decision, int update_hf,
-      int end, int _C, int M);
+      int end, int C, int M);
 
 #ifdef MEASURE_NORM_MSE
 void measure_norm_mse(const CELTMode *m, float *X, float *X0, float *bandE, float *bandE0, int M, int N, int C);
@@ -86,7 +86,7 @@
       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 anti_collapse(const CELTMode *m, celt_norm *_X, unsigned char *collapse_masks, int LM, int C, int CC, int size,
+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/celt/celt.c
+++ b/celt/celt.c
@@ -100,7 +100,7 @@
    else
       return fromOpusTable[(c>>3)-16] | (c&0x7);
 }
-#endif /*CUSTOM_MODES*/
+#endif /* CUSTOM_MODES */
 
 #define COMBFILTER_MAXPERIOD 1024
 #define COMBFILTER_MINPERIOD 15
@@ -383,9 +383,8 @@
 
 /** Apply window and compute the MDCT for all sub-frames and
     all channels in a frame */
-static void compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig * restrict in, celt_sig * restrict out, int _C, int LM)
+static void compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig * restrict in, celt_sig * restrict out, int C, int LM)
 {
-   const int C = CHANNELS(_C);
    if (C==1 && !shortBlocks)
    {
       const int overlap = OVERLAP(mode);
@@ -414,10 +413,9 @@
     all channels in a frame */
 static void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig *X,
       celt_sig * restrict out_mem[],
-      celt_sig * restrict overlap_mem[], int _C, int LM)
+      celt_sig * restrict overlap_mem[], int C, int LM)
 {
    int c;
-   const int C = CHANNELS(_C);
    const int N = mode->shortMdctSize<<LM;
    const int overlap = OVERLAP(mode);
    VARDECL(opus_val32, x);
@@ -454,9 +452,8 @@
    RESTORE_STACK;
 }
 
-static void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int _C, int downsample, const opus_val16 *coef, celt_sig *mem)
+static void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, const opus_val16 *coef, celt_sig *mem)
 {
-   const int C = CHANNELS(_C);
    int c;
    int count=0;
    c=0; do {
@@ -902,8 +899,8 @@
    opus_val16 *oldBandE, *oldLogE, *oldLogE2;
    int shortBlocks=0;
    int isTransient=0;
-   const int CC = CHANNELS(st->channels);
-   const int C = CHANNELS(st->stream_channels);
+   const int CC = st->channels;
+   const int C = st->stream_channels;
    int LM, M;
    int tf_select;
    int nbFilledBytes, nbAvailableBytes;
@@ -1692,7 +1689,7 @@
    if (pcm==NULL)
       return OPUS_BAD_ARG;
 
-   C = CHANNELS(st->channels);
+   C = st->channels;
    N = frame_size;
    ALLOC(in, C*N, opus_int16);
 
@@ -1719,7 +1716,7 @@
    if (pcm==NULL)
       return OPUS_BAD_ARG;
 
-   C=CHANNELS(st->channels);
+   C=st->channels;
    N=frame_size;
    ALLOC(in, C*N, celt_sig);
    for (j=0;j<C*N;j++) {
@@ -2013,7 +2010,7 @@
    int overlap = st->mode->overlap;
    opus_val16 fade = Q15ONE;
    int i, len;
-   const int C = CHANNELS(st->channels);
+   const int C = st->channels;
    int offset;
    celt_sig *out_mem[2];
    celt_sig *decode_mem[2];
@@ -2293,7 +2290,7 @@
    int shortBlocks;
    int isTransient;
    int intra_ener;
-   const int CC = CHANNELS(st->channels);
+   const int CC = st->channels;
    int LM, M;
    int effEnd;
    int codedBands;
@@ -2310,7 +2307,7 @@
    int anti_collapse_rsv;
    int anti_collapse_on=0;
    int silence;
-   int C = CHANNELS(st->stream_channels);
+   int C = st->stream_channels;
    ALLOC_STACK;
 
    frame_size *= st->downsample;
@@ -2664,7 +2661,7 @@
    if (pcm==NULL)
       return OPUS_BAD_ARG;
 
-   C = CHANNELS(st->channels);
+   C = st->channels;
    N = frame_size;
 
    ALLOC(out, C*N, opus_int16);
@@ -2694,7 +2691,7 @@
    if (pcm==NULL)
       return OPUS_BAD_ARG;
 
-   C = CHANNELS(st->channels);
+   C = st->channels;
    N = frame_size;
    ALLOC(out, C*N, celt_sig);
 
--- a/celt/celt.h
+++ b/celt/celt.h
@@ -114,4 +114,4 @@
 }
 #endif
 
-#endif /*CELT_H */
+#endif /* CELT_H */
--- a/celt/fixed_debug.h
+++ b/celt/fixed_debug.h
@@ -83,8 +83,8 @@
    return res;
 }
 
-#define EXTRACT16(x) _EXTRACT16(x, __FILE__, __LINE__)
-static inline short _EXTRACT16(int x, char *file, int line)
+#define EXTRACT16(x) EXTRACT16_(x, __FILE__, __LINE__)
+static inline short EXTRACT16_(int x, char *file, int line)
 {
    int res;
    if (!VERIFY_SHORT(x))
@@ -96,8 +96,8 @@
    return res;
 }
 
-#define EXTEND32(x) _EXTEND32(x, __FILE__, __LINE__)
-static inline int _EXTEND32(int x, char *file, int line)
+#define EXTEND32(x) EXTEND32_(x, __FILE__, __LINE__)
+static inline int EXTEND32_(int x, char *file, int line)
 {
    int res;
    if (!VERIFY_SHORT(x))
@@ -109,8 +109,8 @@
    return res;
 }
 
-#define SHR16(a, shift) _SHR16(a, shift, __FILE__, __LINE__)
-static inline short _SHR16(int a, int shift, char *file, int line)
+#define SHR16(a, shift) SHR16_(a, shift, __FILE__, __LINE__)
+static inline short SHR16_(int a, int shift, char *file, int line)
 {
    int res;
    if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift))
@@ -123,8 +123,8 @@
    celt_mips++;
    return res;
 }
-#define SHL16(a, shift) _SHL16(a, shift, __FILE__, __LINE__)
-static inline short _SHL16(int a, int shift, char *file, int line)
+#define SHL16(a, shift) SHL16_(a, shift, __FILE__, __LINE__)
+static inline short SHL16_(int a, int shift, char *file, int line)
 {
    int res;
    if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift))
@@ -179,8 +179,8 @@
 //#define SHR(a,shift) ((a) >> (shift))
 //#define SHL(a,shift) ((a) << (shift))
 
-#define ADD16(a, b) _ADD16(a, b, __FILE__, __LINE__)
-static inline short _ADD16(int a, int b, char *file, int line)
+#define ADD16(a, b) ADD16_(a, b, __FILE__, __LINE__)
+static inline short ADD16_(int a, int b, char *file, int line)
 {
    int res;
    if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
@@ -196,8 +196,8 @@
    return res;
 }
 
-#define SUB16(a, b) _SUB16(a, b, __FILE__, __LINE__)
-static inline short _SUB16(int a, int b, char *file, int line)
+#define SUB16(a, b) SUB16_(a, b, __FILE__, __LINE__)
+static inline short SUB16_(int a, int b, char *file, int line)
 {
    int res;
    if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
@@ -211,8 +211,8 @@
    return res;
 }
 
-#define ADD32(a, b) _ADD32(a, b, __FILE__, __LINE__)
-static inline int _ADD32(long long a, long long b, char *file, int line)
+#define ADD32(a, b) ADD32_(a, b, __FILE__, __LINE__)
+static inline int ADD32_(long long a, long long b, char *file, int line)
 {
    long long res;
    if (!VERIFY_INT(a) || !VERIFY_INT(b))
@@ -228,8 +228,8 @@
    return res;
 }
 
-#define SUB32(a, b) _SUB32(a, b, __FILE__, __LINE__)
-static inline int _SUB32(long long a, long long b, char *file, int line)
+#define SUB32(a, b) SUB32_(a, b, __FILE__, __LINE__)
+static inline int SUB32_(long long a, long long b, char *file, int line)
 {
    long long res;
    if (!VERIFY_INT(a) || !VERIFY_INT(b))
@@ -244,8 +244,8 @@
 }
 
 #undef UADD32
-#define UADD32(a, b) _UADD32(a, b, __FILE__, __LINE__)
-static inline unsigned int _UADD32(unsigned long long a, unsigned long long b, char *file, int line)
+#define UADD32(a, b) UADD32_(a, b, __FILE__, __LINE__)
+static inline unsigned int UADD32_(unsigned long long a, unsigned long long b, char *file, int line)
 {
    long long res;
    if (!VERIFY_UINT(a) || !VERIFY_UINT(b))
@@ -262,8 +262,8 @@
 }
 
 #undef USUB32
-#define USUB32(a, b) _USUB32(a, b, __FILE__, __LINE__)
-static inline unsigned int _USUB32(unsigned long long a, unsigned long long b, char *file, int line)
+#define USUB32(a, b) USUB32_(a, b, __FILE__, __LINE__)
+static inline unsigned int USUB32_(unsigned long long a, unsigned long long b, char *file, int line)
 {
    long long res;
    if (!VERIFY_UINT(a) || !VERIFY_UINT(b))
@@ -294,8 +294,8 @@
    return res;
 }
 
-#define MULT16_16(a, b) _MULT16_16(a, b, __FILE__, __LINE__)
-static inline int _MULT16_16(int a, int b, char *file, int line)
+#define MULT16_16(a, b) MULT16_16_(a, b, __FILE__, __LINE__)
+static inline int MULT16_16_(int a, int b, char *file, int line)
 {
    long long res;
    if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
@@ -311,8 +311,8 @@
 
 #define MAC16_16(c,a,b)     (celt_mips-=2,ADD32((c),MULT16_16((a),(b))))
 
-#define MULT16_32_QX(a, b, Q) _MULT16_32_QX(a, b, Q, __FILE__, __LINE__)
-static inline int _MULT16_32_QX(int a, long long b, int Q, char *file, int line)
+#define MULT16_32_QX(a, b, Q) MULT16_32_QX_(a, b, Q, __FILE__, __LINE__)
+static inline int MULT16_32_QX_(int a, long long b, int Q, char *file, int line)
 {
    long long res;
    if (!VERIFY_SHORT(a) || !VERIFY_INT(b))
@@ -387,8 +387,8 @@
    return res;
 }
 
-#define MULT16_16_Q15(a, b) _MULT16_16_Q15(a, b, __FILE__, __LINE__)
-static inline short _MULT16_16_Q15(int a, int b, char *file, int line)
+#define MULT16_16_Q15(a, b) MULT16_16_Q15_(a, b, __FILE__, __LINE__)
+static inline short MULT16_16_Q15_(int a, int b, char *file, int line)
 {
    long long res;
    if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
@@ -457,9 +457,9 @@
    return res;
 }
 
-#define DIV32_16(a, b) _DIV32_16(a, b, __FILE__, __LINE__)
+#define DIV32_16(a, b) DIV32_16_(a, b, __FILE__, __LINE__)
 
-static inline int _DIV32_16(long long a, long long b, char *file, int line)
+static inline int DIV32_16_(long long a, long long b, char *file, int line)
 {
    long long res;
    if (b==0)
@@ -484,8 +484,8 @@
    return res;
 }
 
-#define DIV32(a, b) _DIV32(a, b, __FILE__, __LINE__)
-static inline int _DIV32(long long a, long long b, char *file, int line)
+#define DIV32(a, b) DIV32_(a, b, __FILE__, __LINE__)
+static inline int DIV32_(long long a, long long b, char *file, int line)
 {
    long long res;
    if (b==0)
--- a/celt/modes.h
+++ b/celt/modes.h
@@ -39,14 +39,6 @@
 
 #define MAX_PERIOD 1024
 
-#ifndef CHANNELS
-# ifdef DISABLE_STEREO
-#  define CHANNELS(_C) (1)
-# else
-#  define CHANNELS(_C) (_C)
-# endif
-#endif
-
 #ifndef OVERLAP
 #define OVERLAP(mode) ((mode)->overlap)
 #endif
--- a/celt/pitch.c
+++ b/celt/pitch.c
@@ -98,13 +98,12 @@
 }
 
 void pitch_downsample(celt_sig * restrict x[], opus_val16 * restrict x_lp,
-      int len, int _C)
+      int len, int C)
 {
    int i;
    opus_val32 ac[5];
    opus_val16 tmp=Q15ONE;
    opus_val16 lpc[4], mem[4]={0,0,0,0};
-   const int C = CHANNELS(_C);
    for (i=1;i<len>>1;i++)
       x_lp[i] = SHR32(HALF32(HALF32(x[0][(2*i-1)]+x[0][(2*i+1)])+x[0][2*i]), SIG_SHIFT+3);
    x_lp[0] = SHR32(HALF32(HALF32(x[0][1])+x[0][0]), SIG_SHIFT+3);
@@ -259,7 +258,7 @@
 
 static const int second_check[16] = {0, 0, 3, 2, 3, 2, 5, 2, 3, 2, 3, 2, 5, 2, 3, 2};
 opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
-      int N, int *_T0, int prev_period, opus_val16 prev_gain)
+      int N, int *T0_, int prev_period, opus_val16 prev_gain)
 {
    int k, i, T, T0;
    opus_val16 g, g0;
@@ -273,14 +272,14 @@
    minperiod0 = minperiod;
    maxperiod /= 2;
    minperiod /= 2;
-   *_T0 /= 2;
+   *T0_ /= 2;
    prev_period /= 2;
    N /= 2;
    x += maxperiod;
-   if (*_T0>=maxperiod)
-      *_T0=maxperiod-1;
+   if (*T0_>=maxperiod)
+      *T0_=maxperiod-1;
 
-   T = T0 = *_T0;
+   T = T0 = *T0_;
    xx=xy=yy=0;
    for (i=0;i<N;i++)
    {
@@ -378,9 +377,9 @@
       offset = 0;
    if (pg > g)
       pg = g;
-   *_T0 = 2*T+offset;
+   *T0_ = 2*T+offset;
 
-   if (*_T0<minperiod0)
-      *_T0=minperiod0;
+   if (*T0_<minperiod0)
+      *T0_=minperiod0;
    return pg;
 }
--- a/celt/pitch.h
+++ b/celt/pitch.h
@@ -31,13 +31,13 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#ifndef _PITCH_H
-#define _PITCH_H
+#ifndef PITCH_H
+#define PITCH_H
 
 #include "modes.h"
 
 void pitch_downsample(celt_sig * restrict x[], opus_val16 * restrict x_lp,
-      int len, int _C);
+      int len, int C);
 
 void pitch_search(const opus_val16 * restrict x_lp, opus_val16 * restrict y,
                   int len, int max_pitch, int *pitch);
--- a/celt/quant_bands.c
+++ b/celt/quant_bands.c
@@ -157,9 +157,8 @@
       const opus_val16 *eBands, opus_val16 *oldEBands,
       opus_int32 budget, opus_int32 tell,
       const unsigned char *prob_model, opus_val16 *error, ec_enc *enc,
-      int _C, int LM, int intra, opus_val16 max_decay)
+      int C, int LM, int intra, opus_val16 max_decay)
 {
-   const int C = CHANNELS(_C);
    int i, c;
    int badness = 0;
    opus_val32 prev[2] = {0,0};
@@ -259,10 +258,9 @@
 
 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, int nbAvailableBytes,
+      opus_val16 *error, ec_enc *enc, int C, int LM, int nbAvailableBytes,
       int force_intra, opus_val32 *delayedIntra, int two_pass, int loss_rate)
 {
-   const int C = CHANNELS(_C);
    int intra;
    opus_val16 max_decay;
    VARDECL(opus_val16, oldEBands_intra);
@@ -352,10 +350,9 @@
    RESTORE_STACK;
 }
 
-void quant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, ec_enc *enc, int _C)
+void quant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, ec_enc *enc, int C)
 {
    int i, c;
-   const int C = CHANNELS(_C);
 
    /* Encode finer resolution */
    for (i=start;i<end;i++)
@@ -390,10 +387,9 @@
    }
 }
 
-void quant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int _C)
+void quant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int C)
 {
    int i, prio, c;
-   const int C = CHANNELS(_C);
 
    /* Use up the remaining bits */
    for (prio=0;prio<2;prio++)
@@ -420,7 +416,7 @@
    }
 }
 
-void unquant_coarse_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int intra, ec_dec *dec, int _C, int LM)
+void unquant_coarse_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int intra, ec_dec *dec, int C, int LM)
 {
    const unsigned char *prob_model = e_prob_model[LM][intra];
    int i, c;
@@ -427,7 +423,6 @@
    opus_val32 prev[2] = {0, 0};
    opus_val16 coef;
    opus_val16 beta;
-   const int C = CHANNELS(_C);
    opus_int32 budget;
    opus_int32 tell;
 
@@ -486,10 +481,9 @@
    }
 }
 
-void unquant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, ec_dec *dec, int _C)
+void unquant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, ec_dec *dec, int C)
 {
    int i, c;
-   const int C = CHANNELS(_C);
    /* Decode finer resolution */
    for (i=start;i<end;i++)
    {
@@ -510,10 +504,9 @@
    }
 }
 
-void unquant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant,  int *fine_priority, int bits_left, ec_dec *dec, int _C)
+void unquant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant,  int *fine_priority, int bits_left, ec_dec *dec, int C)
 {
    int i, prio, c;
-   const int C = CHANNELS(_C);
 
    /* Use up the remaining bits */
    for (prio=0;prio<2;prio++)
@@ -540,10 +533,9 @@
 }
 
 void log2Amp(const CELTMode *m, int start, int end,
-      celt_ener *eBands, const opus_val16 *oldEBands, int _C)
+      celt_ener *eBands, const opus_val16 *oldEBands, int C)
 {
    int c, i;
-   const int C = CHANNELS(_C);
    c=0;
    do {
       for (i=0;i<start;i++)
@@ -560,10 +552,9 @@
 }
 
 void amp2Log2(const CELTMode *m, int effEnd, int end,
-      celt_ener *bandE, opus_val16 *bandLogE, int _C)
+      celt_ener *bandE, opus_val16 *bandLogE, int C)
 {
    int c, i;
-   const int C = CHANNELS(_C);
    c=0;
    do {
       for (i=0;i<effEnd;i++)
--- a/celt/quant_bands.h
+++ b/celt/quant_bands.h
@@ -36,25 +36,25 @@
 #include "mathops.h"
 
 void amp2Log2(const CELTMode *m, int effEnd, int end,
-      celt_ener *bandE, opus_val16 *bandLogE, int _C);
+      celt_ener *bandE, opus_val16 *bandLogE, int C);
 
 void log2Amp(const CELTMode *m, int start, int end,
-      celt_ener *eBands, const opus_val16 *oldEBands, int _C);
+      celt_ener *eBands, const opus_val16 *oldEBands, int C);
 
 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,
+      opus_val16 *error, ec_enc *enc, int C, int LM,
       int nbAvailableBytes, int force_intra, opus_val32 *delayedIntra,
       int two_pass, int loss_rate);
 
-void quant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, ec_enc *enc, int _C);
+void quant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, ec_enc *enc, int C);
 
-void quant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int _C);
+void quant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int C);
 
-void unquant_coarse_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int intra, ec_dec *dec, int _C, int LM);
+void unquant_coarse_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int intra, ec_dec *dec, int C, int LM);
 
-void unquant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, ec_dec *dec, int _C);
+void unquant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, ec_dec *dec, int C);
 
-void unquant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int _C);
+void unquant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int C);
 
 #endif /* QUANT_BANDS */
--- a/celt/rate.c
+++ b/celt/rate.c
@@ -248,13 +248,12 @@
 static inline int interp_bits2pulses(const CELTMode *m, int start, int end, int skip_start,
       const int *bits1, const int *bits2, const int *thresh, const int *cap, opus_int32 total, opus_int32 *_balance,
       int skip_rsv, int *intensity, int intensity_rsv, int *dual_stereo, int dual_stereo_rsv, int *bits,
-      int *ebits, int *fine_priority, int _C, int LM, ec_ctx *ec, int encode, int prev)
+      int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, int prev)
 {
    opus_int32 psum;
    int lo, hi;
    int i, j;
    int logM;
-   const int C = CHANNELS(_C);
    int stereo;
    int codedBands=-1;
    int alloc_floor;
@@ -525,10 +524,9 @@
 }
 
 int compute_allocation(const CELTMode *m, int start, int end, const int *offsets, const int *cap, int alloc_trim, int *intensity, int *dual_stereo,
-      opus_int32 total, opus_int32 *balance, int *pulses, int *ebits, int *fine_priority, int _C, int LM, ec_ctx *ec, int encode, int prev)
+      opus_int32 total, opus_int32 *balance, int *pulses, int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, int prev)
 {
    int lo, hi, len, j;
-   const int C = CHANNELS(_C);
    int codedBands;
    int skip_start;
    int skip_rsv;
--- a/celt/rate.h
+++ b/celt/rate.h
@@ -96,6 +96,6 @@
  @return Total number of bits allocated
 */
 int compute_allocation(const CELTMode *m, int start, int end, const int *offsets, const int *cap, int alloc_trim, int *intensity, int *dual_stero,
-      opus_int32 total, opus_int32 *balance, int *pulses, int *ebits, int *fine_priority, int _C, int LM, ec_ctx *ec, int encode, int prev);
+      opus_int32 total, opus_int32 *balance, int *pulses, int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, int prev);
 
 #endif
--- a/celt/stack_alloc.h
+++ b/celt/stack_alloc.h
@@ -109,7 +109,7 @@
 char *global_stack=0;
 #else
 extern char *global_stack;
-#endif /*CELT_C*/
+#endif /* CELT_C */
 
 #ifdef ENABLE_VALGRIND
 
@@ -119,7 +119,7 @@
 char *global_stack_top=0;
 #else
 extern char *global_stack_top;
-#endif /*CELT_C*/
+#endif /* CELT_C */
 
 #define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
 #define PUSH(stack, size, type) (VALGRIND_MAKE_MEM_NOACCESS(stack, global_stack_top-stack),ALIGN((stack),sizeof(type)/sizeof(char)),VALGRIND_MAKE_MEM_UNDEFINED(stack, ((size)*sizeof(type)/sizeof(char))),(stack)+=(2*(size)*sizeof(type)/sizeof(char)),(type*)((stack)-(2*(size)*sizeof(type)/sizeof(char))))
@@ -133,7 +133,7 @@
 #define RESTORE_STACK (global_stack = _saved_stack)
 #define ALLOC_STACK char *_saved_stack; (global_stack = (global_stack==0) ? opus_alloc_scratch(GLOBAL_STACK_SIZE) : global_stack); _saved_stack = global_stack;
 
-#endif /*ENABLE_VALGRIND*/
+#endif /* ENABLE_VALGRIND */
 
 #include "os_support.h"
 #define VARDECL(type, var) type *var
@@ -140,6 +140,6 @@
 #define ALLOC(var, size, type) var = PUSH(global_stack, size, type)
 #define SAVE_STACK char *_saved_stack = global_stack;
 
-#endif /*VAR_ARRAYS*/
+#endif /* VAR_ARRAYS */
 
-#endif /*STACK_ALLOC_H*/
+#endif /* STACK_ALLOC_H */
--- a/include/opus_types.h
+++ b/include/opus_types.h
@@ -30,8 +30,8 @@
    @file opus_types.h
    @brief Opus reference implementation types
 */
-#ifndef _OPUS_TYPES_H
-#define _OPUS_TYPES_H
+#ifndef OPUS_TYPES_H
+#define OPUS_TYPES_H
 
 /* Use the real stdint.h if it's there (taken from Paul Hsieh's pstdint.h) */
 #if (defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) || defined (HAVE_STDINT_H))
@@ -156,4 +156,4 @@
 #define opus_uint64      unsigned long long
 #define opus_uint8       unsigned char
 
-#endif  /* _OPUS_TYPES_H */
+#endif  /* OPUS_TYPES_H */
--- a/silk/Inlines.h
+++ b/silk/Inlines.h
@@ -29,8 +29,8 @@
  *  \brief silk_Inlines.h defines inline signal processing functions.
  */
 
-#ifndef _SILK_FIX_INLINES_H_
-#define _SILK_FIX_INLINES_H_
+#ifndef SILK_FIX_INLINES_H
+#define SILK_FIX_INLINES_H
 
 #ifdef  __cplusplus
 extern "C"
@@ -185,4 +185,4 @@
 }
 #endif
 
-#endif /*_SILK_FIX_INLINES_H_*/
+#endif /* SILK_FIX_INLINES_H */
--- a/silk/MacroCount.h
+++ b/silk/MacroCount.h
@@ -25,8 +25,8 @@
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/
 
-#ifndef _SIGPROCFIX_API_MACROCOUNT_H_
-#define _SIGPROCFIX_API_MACROCOUNT_H_
+#ifndef SIGPROCFIX_API_MACROCOUNT_H
+#define SIGPROCFIX_API_MACROCOUNT_H
 #include <stdio.h>
 
 #ifdef    silk_MACRO_COUNT
--- a/silk/MacroDebug.h
+++ b/silk/MacroDebug.h
@@ -25,8 +25,8 @@
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/
 
-#ifndef _MACRO_DEBUG_H_
-#define _MACRO_DEBUG_H_
+#ifndef MACRO_DEBUG_H
+#define MACRO_DEBUG_H
 
 /* Redefine macro functions with extensive assertion in DEBUG mode.
    As functions can't be undefined, this file can't work with SigProcFIX_MacroCount.h */
@@ -566,4 +566,4 @@
 */
 
 #endif
-#endif /* _MACRO_DEBUG_H_ */
+#endif /* MACRO_DEBUG_H */
--- a/silk/SigProc_FIX.h
+++ b/silk/SigProc_FIX.h
@@ -25,8 +25,8 @@
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/
 
-#ifndef _SILK_SIGPROC_FIX_H_
-#define _SILK_SIGPROC_FIX_H_
+#ifndef SILK_SIGPROC_FIX_H
+#define SILK_SIGPROC_FIX_H
 
 #ifdef  __cplusplus
 extern "C"
@@ -591,4 +591,4 @@
 }
 #endif
 
-#endif
+#endif /* SILK_SIGPROC_FIX_H */
--- a/silk/debug.h
+++ b/silk/debug.h
@@ -25,8 +25,8 @@
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/
 
-#ifndef _SILK_DEBUG_H_
-#define _SILK_DEBUG_H_
+#ifndef SILK_DEBUG_H
+#define SILK_DEBUG_H
 
 #ifdef _WIN32
 #define _CRT_SECURE_NO_DEPRECATE    1
@@ -284,4 +284,4 @@
 }
 #endif
 
-#endif /* _SILK_DEBUG_H_ */
+#endif /* SILK_DEBUG_H */
--- a/silk/float/SigProc_FLP.h
+++ b/silk/float/SigProc_FLP.h
@@ -25,8 +25,8 @@
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/
 
-#ifndef _SILK_SIGPROC_FLP_H_
-#define _SILK_SIGPROC_FLP_H_
+#ifndef SILK_SIGPROC_FLP_H
+#define SILK_SIGPROC_FLP_H
 
 #include "SigProc_FIX.h"
 #include <math.h>
@@ -214,4 +214,4 @@
 }
 #endif
 
-#endif
+#endif /* SILK_SIGPROC_FLP_H */
--- a/silk/macros.h
+++ b/silk/macros.h
@@ -25,8 +25,8 @@
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/
 
-#ifndef _SILK_API_C_H_
-#define _SILK_API_C_H_
+#ifndef SILK_API_C_H
+#define SILK_API_C_H
 
 /* This is an inline header file for general platform. */
 
@@ -128,5 +128,5 @@
 #endif
 #define matrix_c_adr(Matrix_base_adr, row, column, M)        (Matrix_base_adr + ((row)+(M)*(column)))
 
-#endif /* _SILK_API_C_H_ */
+#endif /* SILK_API_C_H */
 
--- a/silk/resampler_private.h
+++ b/silk/resampler_private.h
@@ -83,5 +83,4 @@
 #ifdef __cplusplus
 }
 #endif
-#endif /* SILK_RESAMPLER_H*/
-
+#endif /* SILK_RESAMPLER_H */
--- a/silk/resampler_rom.h
+++ b/silk/resampler_rom.h
@@ -25,8 +25,8 @@
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/
 
-#ifndef _SILK_FIX_RESAMPLER_ROM_H_
-#define _SILK_FIX_RESAMPLER_ROM_H_
+#ifndef SILK_FIX_RESAMPLER_ROM_H
+#define SILK_FIX_RESAMPLER_ROM_H
 
 #ifdef  __cplusplus
 extern "C"
@@ -62,4 +62,4 @@
 }
 #endif
 
-#endif /* _SILK_FIX_RESAMPLER_ROM_H_*/
+#endif /* SILK_FIX_RESAMPLER_ROM_H */
--- a/silk/tuning_parameters.h
+++ b/silk/tuning_parameters.h
@@ -167,4 +167,4 @@
 }
 #endif
 
-#endif /* SILK_TUNING_PARAMETERS_H*/
+#endif /* SILK_TUNING_PARAMETERS_H */
--- a/silk/typedef.h
+++ b/silk/typedef.h
@@ -25,8 +25,8 @@
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/
 
-#ifndef _SILK_TYPEDEF_H_
-#define _SILK_TYPEDEF_H_
+#ifndef SILK_TYPEDEF_H
+#define SILK_TYPEDEF_H
 
 #include "opus_types.h"
 
@@ -99,4 +99,4 @@
 # endif
 #endif
 
-#endif
+#endif /* SILK_TYPEDEF_H */
--- a/src/opus_private.h
+++ b/src/opus_private.h
@@ -83,4 +83,4 @@
 
 int opus_repacketizer_out_range_impl(OpusRepacketizer *rp, int begin, int end, unsigned char *data, int maxlen, int self_delimited);
 
-#endif /* OPUS_PRIVATE_H_ */
+#endif /* OPUS_PRIVATE_H */