shithub: opus

Download patch

ref: ff5f7228fda6809abf53dfd378b4a2f095a74c1d
parent: f9d14f8d77a34ea6a03f505bbfc5fdf9aef3d3f5
author: Jean-Marc Valin <[email protected]>
date: Fri Jul 29 14:59:12 EDT 2011

Renamed celt_word* to opus_val*

--- a/libcelt/arch.h
+++ b/libcelt/arch.h
@@ -90,13 +90,13 @@
 
 #ifdef FIXED_POINT
 
-typedef opus_int16 celt_word16;
-typedef opus_int32 celt_word32;
+typedef opus_int16 opus_val16;
+typedef opus_int32 opus_val32;
 
-typedef celt_word32 celt_sig;
-typedef celt_word16 celt_norm;
-typedef celt_word32 celt_ener;
-typedef celt_word32 celt_mask;
+typedef opus_val32 celt_sig;
+typedef opus_val16 celt_norm;
+typedef opus_val32 celt_ener;
+typedef opus_val32 celt_mask;
 
 #define Q15ONE 32767
 #define Q30ONE 1073741823
@@ -119,9 +119,9 @@
 
 #define EPSILON 1
 #define VERY_SMALL 0
-#define VERY_LARGE32 ((celt_word32)2147483647)
-#define VERY_LARGE16 ((celt_word16)32767)
-#define Q15_ONE ((celt_word16)32767)
+#define VERY_LARGE32 ((opus_val32)2147483647)
+#define VERY_LARGE16 ((opus_val16)32767)
+#define Q15_ONE ((opus_val16)32767)
 #define Q15_ONE_1 (1.f/32768.f)
 
 #define SCALEIN(a)	(a)
@@ -150,8 +150,8 @@
 
 #else /* FIXED_POINT */
 
-typedef float celt_word16;
-typedef float celt_word32;
+typedef float opus_val16;
+typedef float opus_val32;
 
 typedef float celt_sig;
 typedef float celt_norm;
@@ -173,8 +173,8 @@
 #define VERY_SMALL 1e-15f
 #define VERY_LARGE32 1e15f
 #define VERY_LARGE16 1e15f
-#define Q15_ONE ((celt_word16)1.f)
-#define Q15_ONE_1 ((celt_word16)1.f)
+#define Q15_ONE ((opus_val16)1.f)
+#define Q15_ONE_1 ((opus_val16)1.f)
 
 #define QCONST16(x,bits) (x)
 #define QCONST32(x,bits) (x)
@@ -207,8 +207,8 @@
 #define ADD32(a,b) ((a)+(b))
 #define SUB32(a,b) ((a)-(b))
 #define MULT16_16_16(a,b)     ((a)*(b))
-#define MULT16_16(a,b)     ((celt_word32)(a)*(celt_word32)(b))
-#define MAC16_16(c,a,b)     ((c)+(celt_word32)(a)*(celt_word32)(b))
+#define MULT16_16(a,b)     ((opus_val32)(a)*(opus_val32)(b))
+#define MAC16_16(c,a,b)     ((c)+(opus_val32)(a)*(opus_val32)(b))
 
 #define MULT16_32_Q11(a,b)     ((a)*(b))
 #define MULT16_32_Q13(a,b)     ((a)*(b))
@@ -233,10 +233,10 @@
 #define MULT16_16_P13(a,b)     ((a)*(b))
 #define MULT16_16_P14(a,b)     ((a)*(b))
 
-#define DIV32_16(a,b)     (((celt_word32)(a))/(celt_word16)(b))
-#define PDIV32_16(a,b)     (((celt_word32)(a))/(celt_word16)(b))
-#define DIV32(a,b)     (((celt_word32)(a))/(celt_word32)(b))
-#define PDIV32(a,b)     (((celt_word32)(a))/(celt_word32)(b))
+#define DIV32_16(a,b)     (((opus_val32)(a))/(opus_val16)(b))
+#define PDIV32_16(a,b)     (((opus_val32)(a))/(opus_val16)(b))
+#define DIV32(a,b)     (((opus_val32)(a))/(opus_val32)(b))
+#define PDIV32(a,b)     (((opus_val32)(a))/(opus_val32)(b))
 
 #define SCALEIN(a)	((a)*CELT_SIG_SCALE)
 #define SCALEOUT(a)	((a)*(1/CELT_SIG_SCALE))
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -87,8 +87,8 @@
       for (i=0;i<end;i++)
       {
          int j;
-         celt_word32 maxval=0;
-         celt_word32 sum = 0;
+         opus_val32 maxval=0;
+         opus_val32 sum = 0;
          
          j=M*eBands[i]; do {
             maxval = MAX32(maxval, X[j+c*N]);
@@ -123,9 +123,9 @@
    N = M*m->shortMdctSize;
    c=0; do {
       i=0; do {
-         celt_word16 g;
+         opus_val16 g;
          int j,shift;
-         celt_word16 E;
+         opus_val16 E;
          shift = celt_zlog2(bank[i+c*m->nbEBands])-13;
          E = VSHR32(bank[i+c*m->nbEBands], shift);
          g = EXTRACT16(celt_rcp(SHL32(E,3)));
@@ -148,7 +148,7 @@
       for (i=0;i<end;i++)
       {
          int j;
-         celt_word32 sum = 1e-27f;
+         opus_val32 sum = 1e-27f;
          for (j=M*eBands[i];j<M*eBands[i+1];j++)
             sum += X[j+c*N]*X[j+c*N];
          bank[i+c*m->nbEBands] = celt_sqrt(sum);
@@ -169,7 +169,7 @@
       for (i=0;i<end;i++)
       {
          int j;
-         celt_word16 g = 1.f/(1e-27f+bank[i+c*m->nbEBands]);
+         opus_val16 g = 1.f/(1e-27f+bank[i+c*m->nbEBands]);
          for (j=M*eBands[i];j<M*eBands[i+1];j++)
             X[j+c*N] = freq[j+c*N]*g;
       }
@@ -194,7 +194,7 @@
       for (i=0;i<end;i++)
       {
          int j, band_end;
-         celt_word32 g = SHR32(bank[i+c*m->nbEBands],1);
+         opus_val32 g = SHR32(bank[i+c*m->nbEBands],1);
          j=M*eBands[i];
          band_end = M*eBands[i+1];
          do {
@@ -209,14 +209,14 @@
 
 /* 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,
-      int start, int end, celt_word16 *logE, celt_word16 *prev1logE,
-      celt_word16 *prev2logE, int *pulses, opus_uint32 seed)
+      int start, int end, opus_val16 *logE, opus_val16 *prev1logE,
+      opus_val16 *prev2logE, int *pulses, opus_uint32 seed)
 {
    int c, i, j, k;
    for (i=start;i<end;i++)
    {
       int N0;
-      celt_word16 thresh, sqrt_1;
+      opus_val16 thresh, sqrt_1;
       int depth;
 #ifdef FIXED_POINT
       int shift;
@@ -229,7 +229,7 @@
 #ifdef FIXED_POINT
       thresh = MULT16_32_Q15(QCONST16(0.5f, 15), MIN32(32767,SHR32(celt_exp2(-SHL16(depth, 10-BITRES)),1) ));
       {
-         celt_word32 t;
+         opus_val32 t;
          t = N0<<LM;
          shift = celt_ilog2(t)>>1;
          t = SHL32(t, (7-shift)<<1);
@@ -243,10 +243,10 @@
       c=0; do
       {
          celt_norm *X;
-         celt_word16 prev1;
-         celt_word16 prev2;
-         celt_word16 Ediff;
-         celt_word16 r;
+         opus_val16 prev1;
+         opus_val16 prev2;
+         opus_val16 Ediff;
+         opus_val16 r;
          int renormalize=0;
          prev1 = prev1logE[c*m->nbEBands+i];
          prev2 = prev2logE[c*m->nbEBands+i];
@@ -304,9 +304,9 @@
 {
    int i = bandID;
    int j;
-   celt_word16 a1, a2;
-   celt_word16 left, right;
-   celt_word16 norm;
+   opus_val16 a1, a2;
+   opus_val16 left, right;
+   opus_val16 norm;
 #ifdef FIXED_POINT
    int shift = celt_zlog2(MAX32(bank[i], bank[i+m->nbEBands]))-13;
 #endif
@@ -338,16 +338,16 @@
    }
 }
 
-static void stereo_merge(celt_norm *X, celt_norm *Y, celt_word16 mid, int N)
+static void stereo_merge(celt_norm *X, celt_norm *Y, opus_val16 mid, int N)
 {
    int j;
-   celt_word32 xp=0, side=0;
-   celt_word32 El, Er;
-   celt_word16 mid2;
+   opus_val32 xp=0, side=0;
+   opus_val32 El, Er;
+   opus_val16 mid2;
 #ifdef FIXED_POINT
    int kl, kr;
 #endif
-   celt_word32 t, lgain, rgain;
+   opus_val32 t, lgain, rgain;
 
    /* Compute the norm of X+Y and X-Y as |X|^2 + |Y|^2 +/- sum(xy) */
    for (j=0;j<N;j++)
@@ -423,7 +423,7 @@
          /* Compute rough CDF of |x[j]| */
          for (j=0;j<N;j++)
          {
-            celt_word32 x2N; /* Q13 */
+            opus_val32 x2N; /* Q13 */
 
             x2N = MULT16_16(MULT16_16_Q15(x[j], x[j]), N);
             if (x2N < QCONST16(0.25f,13))
@@ -634,7 +634,7 @@
 static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, celt_norm *Y,
       int N, int b, int spread, int B, int intensity, int tf_change, celt_norm *lowband, int resynth, ec_ctx *ec,
       opus_int32 *remaining_bits, int LM, celt_norm *lowband_out, const celt_ener *bandE, int level,
-      opus_uint32 *seed, celt_word16 gain, celt_norm *lowband_scratch, int fill)
+      opus_uint32 *seed, opus_val16 gain, celt_norm *lowband_scratch, int fill)
 {
    const unsigned char *cache;
    int q;
@@ -648,7 +648,7 @@
    int time_divide=0;
    int recombine=0;
    int inv = 0;
-   celt_word16 mid=0, side=0;
+   opus_val16 mid=0, side=0;
    int longBlocks;
    unsigned cm=0;
 
@@ -1085,7 +1085,7 @@
                   /* Folded spectrum */
                   for (j=0;j<N;j++)
                   {
-                     celt_word16 tmp;
+                     opus_val16 tmp;
                      *seed = lcg_rand(*seed);
                      /* About 48 dB below the "normal" folding level */
                      tmp = QCONST16(1.0f/256, 10);
@@ -1147,7 +1147,7 @@
          if (lowband_out)
          {
             int j;
-            celt_word16 n;
+            opus_val16 n;
             n = celt_sqrt(SHL32(EXTEND32(N0),22));
             for (j=0;j<N0;j++)
                lowband_out[j] = MULT16_16_Q15(n,X[j]);
--- a/libcelt/bands.h
+++ b/libcelt/bands.h
@@ -43,7 +43,7 @@
  */
 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 celt_word16 *tonality, celt_ener *bank);*/
+/*void compute_noise_energies(const CELTMode *m, const celt_sig *X, const opus_val16 *tonality, celt_ener *bank);*/
 
 /** Normalise each band of X such that the energy in each band is 
     equal to 1
@@ -90,8 +90,8 @@
 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, celt_word16 *logE, celt_word16 *prev1logE,
-      celt_word16 *prev2logE, int *pulses, opus_uint32 seed);
+      int start, int end, opus_val16 *logE, opus_val16 *prev1logE,
+      opus_val16 *prev2logE, int *pulses, opus_uint32 seed);
 
 opus_uint32 lcg_rand(opus_uint32 seed);
 
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -146,7 +146,7 @@
 
    opus_uint32 rng;
    int spread_decision;
-   celt_word32 delayedIntra;
+   opus_val32 delayedIntra;
    int tonal_average;
    int lastCodedBands;
    int hf_average;
@@ -153,11 +153,11 @@
    int tapset_decision;
 
    int prefilter_period;
-   celt_word16 prefilter_gain;
+   opus_val16 prefilter_gain;
    int prefilter_tapset;
 #ifdef RESYNTH
    int prefilter_period_old;
-   celt_word16 prefilter_gain_old;
+   opus_val16 prefilter_gain_old;
    int prefilter_tapset_old;
 #endif
    int consec_transient;
@@ -168,8 +168,8 @@
    opus_int32 vbr_offset;
    opus_int32 vbr_count;
 
-   celt_word32 preemph_memE[2];
-   celt_word32 preemph_memD[2];
+   opus_val32 preemph_memE[2];
+   opus_val32 preemph_memD[2];
 
 #ifdef RESYNTH
    celt_sig syn_mem[2][2*MAX_PERIOD];
@@ -178,7 +178,7 @@
    celt_sig in_mem[1]; /* Size = channels*mode->overlap */
    /* celt_sig prefilter_mem[],  Size = channels*COMBFILTER_PERIOD */
    /* celt_sig overlap_mem[],  Size = channels*mode->overlap */
-   /* celt_word16 oldEBands[], Size = 2*channels*mode->nbEBands */
+   /* opus_val16 oldEBands[], Size = 2*channels*mode->nbEBands */
 };
 
 int celt_encoder_get_size(int channels)
@@ -192,7 +192,7 @@
    int size = sizeof(struct CELTEncoder)
          + (2*channels*mode->overlap-1)*sizeof(celt_sig)
          + channels*COMBFILTER_MAXPERIOD*sizeof(celt_sig)
-         + 3*channels*mode->nbEBands*sizeof(celt_word16);
+         + 3*channels*mode->nbEBands*sizeof(opus_val16);
    return size;
 }
 
@@ -291,7 +291,7 @@
    return (opus_int16)float2int(x);
 }
 
-static inline celt_word16 SIG2WORD16(celt_sig x)
+static inline opus_val16 SIG2WORD16(celt_sig x)
 {
 #ifdef FIXED_POINT
    x = PSHR32(x, SIG_SHIFT);
@@ -299,26 +299,26 @@
    x = MIN32(x, 32767);
    return EXTRACT16(x);
 #else
-   return (celt_word16)x;
+   return (opus_val16)x;
 #endif
 }
 
-static int transient_analysis(const celt_word32 * restrict in, int len, int C,
+static int transient_analysis(const opus_val32 * restrict in, int len, int C,
                               int overlap)
 {
    int i;
-   VARDECL(celt_word16, tmp);
-   celt_word32 mem0=0,mem1=0;
+   VARDECL(opus_val16, tmp);
+   opus_val32 mem0=0,mem1=0;
    int is_transient = 0;
    int block;
    int N;
-   VARDECL(celt_word16, bins);
+   VARDECL(opus_val16, bins);
    SAVE_STACK;
-   ALLOC(tmp, len, celt_word16);
+   ALLOC(tmp, len, opus_val16);
 
    block = overlap/2;
    N=len/block;
-   ALLOC(bins, N, celt_word16);
+   ALLOC(bins, N, opus_val16);
    if (C==1)
    {
       for (i=0;i<len;i++)
@@ -331,7 +331,7 @@
    /* High-pass filter: (1 - 2*z^-1 + z^-2) / (1 - z^-1 + .5*z^-2) */
    for (i=0;i<len;i++)
    {
-      celt_word32 x,y;
+      opus_val32 x,y;
       x = tmp[i];
       y = ADD32(mem0, x);
 #ifdef FIXED_POINT
@@ -350,7 +350,7 @@
    for (i=0;i<N;i++)
    {
       int j;
-      celt_word16 max_abs=0;
+      opus_val16 max_abs=0;
       for (j=0;j<block;j++)
          max_abs = MAX16(max_abs, ABS16(tmp[i*block+j]));
       bins[i] = max_abs;
@@ -359,7 +359,7 @@
    {
       int j;
       int conseq=0;
-      celt_word16 t1, t2, t3;
+      opus_val16 t1, t2, t3;
 
       t1 = MULT16_16_Q15(QCONST16(.15f, 15), bins[i]);
       t2 = MULT16_16_Q15(QCONST16(.4f, 15), bins[i]);
@@ -404,7 +404,7 @@
       int N = mode->shortMdctSize<<LM;
       int B = 1;
       int b, c;
-      VARDECL(celt_word32, tmp);
+      VARDECL(opus_val32, tmp);
       SAVE_STACK;
       if (shortBlocks)
       {
@@ -412,7 +412,7 @@
          N = mode->shortMdctSize;
          B = shortBlocks;
       }
-      ALLOC(tmp, N, celt_word32);
+      ALLOC(tmp, N, opus_val32);
       c=0; do {
          for (b=0;b<B;b++)
          {
@@ -439,15 +439,15 @@
    const int overlap = OVERLAP(mode);
    c=0; do {
       int j;
-         VARDECL(celt_word32, x);
-         VARDECL(celt_word32, tmp);
+         VARDECL(opus_val32, x);
+         VARDECL(opus_val32, tmp);
          int b;
          int N2 = N;
          int B = 1;
          SAVE_STACK;
          
-         ALLOC(x, N+overlap, celt_word32);
-         ALLOC(tmp, N, celt_word32);
+         ALLOC(x, N+overlap, opus_val32);
+         ALLOC(tmp, N, opus_val32);
 
          if (shortBlocks)
          {
@@ -475,7 +475,7 @@
    } while (++c<C);
 }
 
-static void deemphasis(celt_sig *in[], celt_word16 *pcm, int N, int _C, int downsample, const celt_word16 *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;
@@ -483,7 +483,7 @@
    c=0; do {
       int j;
       celt_sig * restrict x;
-      celt_word16  * restrict y;
+      opus_val16  * restrict y;
       celt_sig m = mem[c];
       x =in[c];
       y = pcm+c;
@@ -507,14 +507,14 @@
    } while (++c<C);
 }
 
-static void comb_filter(celt_word32 *y, celt_word32 *x, int T0, int T1, int N,
-      celt_word16 g0, celt_word16 g1, int tapset0, int tapset1,
-      const celt_word16 *window, int overlap)
+static void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N,
+      opus_val16 g0, opus_val16 g1, int tapset0, int tapset1,
+      const opus_val16 *window, int overlap)
 {
    int i;
    /* printf ("%d %d %f %f\n", T0, T1, g0, g1); */
-   celt_word16 g00, g01, g02, g10, g11, g12;
-   static const celt_word16 gains[3][3] = {
+   opus_val16 g00, g01, g02, g10, g11, g12;
+   static const opus_val16 gains[3][3] = {
          {QCONST16(0.3066406250f, 15), QCONST16(0.2170410156f, 15), QCONST16(0.1296386719f, 15)},
          {QCONST16(0.4638671875f, 15), QCONST16(0.2680664062f, 15), QCONST16(0.f, 15)},
          {QCONST16(0.7998046875f, 15), QCONST16(0.1000976562f, 15), QCONST16(0.f, 15)}};
@@ -526,7 +526,7 @@
    g12 = MULT16_16_Q15(g1, gains[tapset1][2]);
    for (i=0;i<overlap;i++)
    {
-      celt_word16 f;
+      opus_val16 f;
       f = MULT16_16_Q15(window[i],window[i]);
       y[i] = x[i]
                + MULT16_32_Q15(MULT16_16_Q15((Q15ONE-f),g00),x[i-T0])
@@ -557,16 +557,16 @@
       {0, -2, 0, -3,    3, 0, 1,-1},
 };
 
-static celt_word32 l1_metric(const celt_norm *tmp, int N, int LM, int width)
+static opus_val32 l1_metric(const celt_norm *tmp, int N, int LM, int width)
 {
    int i, j;
-   static const celt_word16 sqrtM_1[4] = {Q15ONE, QCONST16(.70710678f,15), QCONST16(0.5f,15), QCONST16(0.35355339f,15)};
-   celt_word32 L1;
-   celt_word16 bias;
+   static const opus_val16 sqrtM_1[4] = {Q15ONE, QCONST16(.70710678f,15), QCONST16(0.5f,15), QCONST16(0.35355339f,15)};
+   opus_val32 L1;
+   opus_val16 bias;
    L1=0;
    for (i=0;i<1<<LM;i++)
    {
-      celt_word32 L2 = 0;
+      opus_val32 L2 = 0;
       for (j=0;j<N>>LM;j++)
          L2 = MAC16_16(L2, tmp[(j<<LM)+i], tmp[(j<<LM)+i]);
       L1 += celt_sqrt(L2);
@@ -582,7 +582,7 @@
    return L1;
 }
 
-static int tf_analysis(const CELTMode *m, celt_word16 *bandLogE, celt_word16 *oldBandE,
+static int tf_analysis(const CELTMode *m, opus_val16 *bandLogE, opus_val16 *oldBandE,
       int len, int C, int isTransient, int *tf_res, int nbCompressedBytes, celt_norm *X,
       int N0, int LM, int *tf_sum)
 {
@@ -622,7 +622,7 @@
    for (i=0;i<len;i++)
    {
       int j, k, N;
-      celt_word32 L1, best_L1;
+      opus_val32 L1, best_L1;
       int best_level=0;
       N = (m->eBands[i+1]-m->eBands[i])<<LM;
       for (j=0;j<N;j++)
@@ -803,20 +803,20 @@
 }
 
 static int alloc_trim_analysis(const CELTMode *m, const celt_norm *X,
-      const celt_word16 *bandLogE, int end, int LM, int C, int N0)
+      const opus_val16 *bandLogE, int end, int LM, int C, int N0)
 {
    int i;
-   celt_word32 diff=0;
+   opus_val32 diff=0;
    int c;
    int trim_index = 5;
    if (C==2)
    {
-      celt_word16 sum = 0; /* Q10 */
+      opus_val16 sum = 0; /* Q10 */
       /* Compute inter-channel correlation for low frequencies */
       for (i=0;i<8;i++)
       {
          int j;
-         celt_word32 partial = 0;
+         opus_val32 partial = 0;
          for (j=m->eBands[i]<<LM;j<m->eBands[i+1]<<LM;j++)
             partial = MAC16_16(partial, X[j], X[N0+j]);
          sum = ADD16(sum, EXTRACT16(SHR32(partial, 18)));
@@ -863,7 +863,7 @@
 {
    int i;
    int thetas;
-   celt_word32 sumLR = EPSILON, sumMS = EPSILON;
+   opus_val32 sumLR = EPSILON, sumMS = EPSILON;
 
    /* Use the L1 norm to model the entropy of the L/R signal vs the M/S signal */
    for (i=0;i<13;i++)
@@ -871,7 +871,7 @@
       int j;
       for (j=m->eBands[i]<<LM;j<m->eBands[i+1]<<LM;j++)
       {
-         celt_word16 L, R, M, S;
+         opus_val16 L, R, M, S;
          L = X[j];
          R = X[N0+j];
          M = L+R;
@@ -905,9 +905,9 @@
    VARDECL(celt_sig, freq);
    VARDECL(celt_norm, X);
    VARDECL(celt_ener, bandE);
-   VARDECL(celt_word16, bandLogE);
+   VARDECL(opus_val16, bandLogE);
    VARDECL(int, fine_quant);
-   VARDECL(celt_word16, error);
+   VARDECL(opus_val16, error);
    VARDECL(int, pulses);
    VARDECL(int, cap);
    VARDECL(int, offsets);
@@ -915,7 +915,7 @@
    VARDECL(int, tf_res);
    VARDECL(unsigned char, collapse_masks);
    celt_sig *prefilter_mem;
-   celt_word16 *oldBandE, *oldLogE, *oldLogE2;
+   opus_val16 *oldBandE, *oldLogE, *oldLogE2;
    int shortBlocks=0;
    int isTransient=0;
    int resynth;
@@ -929,11 +929,11 @@
    int tf_sum;
    int alloc_trim;
    int pitch_index=COMBFILTER_MINPERIOD;
-   celt_word16 gain1 = 0;
+   opus_val16 gain1 = 0;
    int intensity=0;
    int dual_stereo=0;
    int effectiveBytes;
-   celt_word16 pf_threshold;
+   opus_val16 pf_threshold;
    int dynalloc_logp;
    opus_int32 vbr_rate;
    opus_int32 total_bits;
@@ -960,7 +960,7 @@
    N = M*st->mode->shortMdctSize;
 
    prefilter_mem = st->in_mem+CC*(st->overlap);
-   oldBandE = (celt_word16*)(st->in_mem+CC*(2*st->overlap+COMBFILTER_MAXPERIOD));
+   oldBandE = (opus_val16*)(st->in_mem+CC*(2*st->overlap+COMBFILTER_MAXPERIOD));
    oldLogE = oldBandE + CC*st->mode->nbEBands;
    oldLogE2 = oldLogE + CC*st->mode->nbEBands;
 
@@ -1067,7 +1067,7 @@
       silence = 1;
       c=0; do {
          int count = 0;
-         const celt_word16 * restrict pcmp = pcm+c;
+         const opus_val16 * restrict pcmp = pcm+c;
          celt_sig * restrict inp = in+c*(N+st->overlap)+st->overlap;
 
          for (i=0;i<N;i++)
@@ -1121,8 +1121,8 @@
       }
       if (nbAvailableBytes>12*C && st->start==0 && !silence && !st->disable_pf && st->complexity >= 5)
       {
-         VARDECL(celt_word16, pitch_buf);
-         ALLOC(pitch_buf, (COMBFILTER_MAXPERIOD+N)>>1, celt_word16);
+         VARDECL(opus_val16, pitch_buf);
+         ALLOC(pitch_buf, (COMBFILTER_MAXPERIOD+N)>>1, opus_val16);
 
          pitch_downsample(pre, pitch_buf, COMBFILTER_MAXPERIOD+N, CC);
          pitch_search(pitch_buf+(COMBFILTER_MAXPERIOD>>1), pitch_buf, N,
@@ -1247,7 +1247,7 @@
 
    ALLOC(freq, CC*N, celt_sig); /**< Interleaved signal MDCTs */
    ALLOC(bandE,st->mode->nbEBands*CC, celt_ener);
-   ALLOC(bandLogE,st->mode->nbEBands*CC, celt_word16);
+   ALLOC(bandLogE,st->mode->nbEBands*CC, opus_val16);
    /* Compute MDCTs */
    compute_mdcts(st->mode, shortBlocks, in, freq, CC, LM);
 
@@ -1282,7 +1282,7 @@
    for (i=effEnd;i<st->end;i++)
       tf_res[i] = tf_res[effEnd-1];
 
-   ALLOC(error, C*st->mode->nbEBands, celt_word16);
+   ALLOC(error, C*st->mode->nbEBands, opus_val16);
    quant_coarse_energy(st->mode, st->start, st->end, effEnd, bandLogE,
          oldBandE, total_bits, error, enc,
          C, LM, nbAvailableBytes, st->force_intra,
@@ -1326,7 +1326,7 @@
       }
       for (i=st->start+1;i<st->end-1;i++)
       {
-         celt_word32 d2;
+         opus_val32 d2;
          d2 = 2*bandLogE[i]-bandLogE[i-1]-bandLogE[i+1];
          if (C==2)
             d2 = HALF32(d2 + 2*bandLogE[i+st->mode->nbEBands]-
@@ -1383,7 +1383,7 @@
    /* Variable bitrate */
    if (vbr_rate>0)
    {
-     celt_word16 alpha;
+     opus_val16 alpha;
      opus_int32 delta;
      /* The target rate in 8th bits per frame */
      opus_int32 target;
@@ -1603,7 +1603,7 @@
                   st->mode->window, st->mode->overlap);
       } while (++c<CC);
 
-      deemphasis(out_mem, (celt_word16*)pcm, N, CC, st->upsample, st->mode->preemph, st->preemph_memD);
+      deemphasis(out_mem, (opus_val16*)pcm, N, CC, st->upsample, st->mode->preemph, st->preemph_memD);
       st->prefilter_period_old = st->prefilter_period;
       st->prefilter_gain_old = st->prefilter_gain;
       st->prefilter_tapset_old = st->prefilter_tapset;
@@ -1886,8 +1886,8 @@
    int loss_count;
    int postfilter_period;
    int postfilter_period_old;
-   celt_word16 postfilter_gain;
-   celt_word16 postfilter_gain_old;
+   opus_val16 postfilter_gain;
+   opus_val16 postfilter_gain_old;
    int postfilter_tapset;
    int postfilter_tapset_old;
 
@@ -1894,11 +1894,11 @@
    celt_sig preemph_memD[2];
    
    celt_sig _decode_mem[1]; /* Size = channels*(DECODE_BUFFER_SIZE+mode->overlap) */
-   /* celt_word16 lpc[],  Size = channels*LPC_ORDER */
-   /* celt_word16 oldEBands[], Size = 2*mode->nbEBands */
-   /* celt_word16 oldLogE[], Size = 2*mode->nbEBands */
-   /* celt_word16 oldLogE2[], Size = 2*mode->nbEBands */
-   /* celt_word16 backgroundLogE[], Size = 2*mode->nbEBands */
+   /* opus_val16 lpc[],  Size = channels*LPC_ORDER */
+   /* opus_val16 oldEBands[], Size = 2*mode->nbEBands */
+   /* opus_val16 oldLogE[], Size = 2*mode->nbEBands */
+   /* opus_val16 oldLogE2[], Size = 2*mode->nbEBands */
+   /* opus_val16 backgroundLogE[], Size = 2*mode->nbEBands */
 };
 
 int celt_decoder_get_size(int channels)
@@ -1911,8 +1911,8 @@
 {
    int size = sizeof(struct CELTDecoder)
             + (channels*(DECODE_BUFFER_SIZE+mode->overlap)-1)*sizeof(celt_sig)
-            + channels*LPC_ORDER*sizeof(celt_word16)
-            + 4*2*mode->nbEBands*sizeof(celt_word16);
+            + channels*LPC_ORDER*sizeof(opus_val16)
+            + 4*2*mode->nbEBands*sizeof(opus_val16);
    return size;
 }
 
@@ -1991,12 +1991,12 @@
    celt_free(st);
 }
 
-static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict pcm, int N, int LM)
+static void celt_decode_lost(CELTDecoder * restrict st, opus_val16 * restrict pcm, int N, int LM)
 {
    int c;
    int pitch_index;
    int overlap = st->mode->overlap;
-   celt_word16 fade = Q15ONE;
+   opus_val16 fade = Q15ONE;
    int i, len;
    const int C = CHANNELS(st->channels);
    int offset;
@@ -2003,9 +2003,9 @@
    celt_sig *out_mem[2];
    celt_sig *decode_mem[2];
    celt_sig *overlap_mem[2];
-   celt_word16 *lpc;
-   celt_word32 *out_syn[2];
-   celt_word16 *oldBandE, *oldLogE2, *backgroundLogE;
+   opus_val16 *lpc;
+   opus_val32 *out_syn[2];
+   opus_val16 *oldBandE, *oldLogE2, *backgroundLogE;
    int plc=1;
    SAVE_STACK;
    
@@ -2014,7 +2014,7 @@
       out_mem[c] = decode_mem[c]+DECODE_BUFFER_SIZE-MAX_PERIOD;
       overlap_mem[c] = decode_mem[c]+DECODE_BUFFER_SIZE;
    } while (++c<C);
-   lpc = (celt_word16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+st->overlap)*C);
+   lpc = (opus_val16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+st->overlap)*C);
    oldBandE = lpc+C*LPC_ORDER;
    oldLogE2 = oldBandE + C*st->mode->nbEBands;
    backgroundLogE = oldLogE2  + C*st->mode->nbEBands;
@@ -2084,7 +2084,7 @@
       plc = 0;
    } else if (st->loss_count == 0)
    {
-      celt_word16 pitch_buf[DECODE_BUFFER_SIZE>>1];
+      opus_val16 pitch_buf[DECODE_BUFFER_SIZE>>1];
       /* Corresponds to a min pitch of 67 Hz. It's possible to save CPU in this
          search by using only part of the decode buffer */
       int poffset = 720;
@@ -2102,14 +2102,14 @@
    if (plc)
    {
       c=0; do {
-         VARDECL(celt_word32, e);
-         celt_word16 exc[MAX_PERIOD];
-         celt_word32 ac[LPC_ORDER+1];
-         celt_word16 decay = 1;
-         celt_word32 S1=0;
-         celt_word16 mem[LPC_ORDER]={0};
+         VARDECL(opus_val32, e);
+         opus_val16 exc[MAX_PERIOD];
+         opus_val32 ac[LPC_ORDER+1];
+         opus_val16 decay = 1;
+         opus_val32 S1=0;
+         opus_val16 mem[LPC_ORDER]={0};
 
-         ALLOC(e, MAX_PERIOD+2*st->mode->overlap, celt_word32);
+         ALLOC(e, MAX_PERIOD+2*st->mode->overlap, opus_val32);
 
          offset = MAX_PERIOD-pitch_index;
          for (i=0;i<MAX_PERIOD;i++)
@@ -2145,7 +2145,7 @@
          /*for (i=0;i<MAX_PERIOD;i++)printf("%d ", exc[i]); printf("\n");*/
          /* Check if the waveform is decaying (and if so how fast) */
          {
-            celt_word32 E1=1, E2=1;
+            opus_val32 E1=1, E2=1;
             int period;
             if (pitch_index <= MAX_PERIOD/2)
                period = pitch_index;
@@ -2164,7 +2164,7 @@
          /* Copy excitation, taking decay into account */
          for (i=0;i<len+st->mode->overlap;i++)
          {
-            celt_word16 tmp;
+            opus_val16 tmp;
             if (offset+i >= MAX_PERIOD)
             {
                offset -= pitch_index;
@@ -2181,10 +2181,10 @@
          iir(e, lpc+c*LPC_ORDER, e, len+st->mode->overlap, LPC_ORDER, mem);
 
          {
-            celt_word32 S2=0;
+            opus_val32 S2=0;
             for (i=0;i<len+overlap;i++)
             {
-               celt_word16 tmp = ROUND16(e[i],SIG_SHIFT);
+               opus_val16 tmp = ROUND16(e[i],SIG_SHIFT);
                S2 += SHR32(MULT16_16(tmp,tmp),8);
             }
             /* This checks for an "explosion" in the synthesis */
@@ -2199,7 +2199,7 @@
                      e[i] = 0;
                } else if (S1 < S2)
                {
-                  celt_word16 ratio = celt_sqrt(frac_div32(SHR32(S1,1)+1,S2+1));
+                  opus_val16 ratio = celt_sqrt(frac_div32(SHR32(S1,1)+1,S2+1));
                   for (i=0;i<len+overlap;i++)
                      e[i] = MULT16_32_Q15(ratio, e[i]);
                }
@@ -2217,7 +2217,7 @@
          previous and next frames */
          for (i=0;i<overlap/2;i++)
          {
-            celt_word32 tmp;
+            opus_val32 tmp;
             tmp = MULT16_32_Q15(st->mode->window[i],           e[N+overlap-1-i]) +
                   MULT16_32_Q15(st->mode->window[overlap-i-1], e[N+i          ]);
             out_mem[c][MAX_PERIOD+i] = MULT16_32_Q15(st->mode->window[overlap-i-1], tmp);
@@ -2269,8 +2269,8 @@
    celt_sig *decode_mem[2];
    celt_sig *overlap_mem[2];
    celt_sig *out_syn[2];
-   celt_word16 *lpc;
-   celt_word16 *oldBandE, *oldLogE, *oldLogE2, *backgroundLogE;
+   opus_val16 *lpc;
+   opus_val16 *oldBandE, *oldLogE, *oldLogE2, *backgroundLogE;
 
    int shortBlocks;
    int isTransient;
@@ -2281,7 +2281,7 @@
    int codedBands;
    int alloc_trim;
    int postfilter_pitch;
-   celt_word16 postfilter_gain;
+   opus_val16 postfilter_gain;
    int intensity=0;
    int dual_stereo=0;
    opus_int32 total_bits;
@@ -2302,7 +2302,7 @@
       out_mem[c] = decode_mem[c]+DECODE_BUFFER_SIZE-MAX_PERIOD;
       overlap_mem[c] = decode_mem[c]+DECODE_BUFFER_SIZE;
    } while (++c<CC);
-   lpc = (celt_word16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+st->overlap)*CC);
+   lpc = (opus_val16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+st->overlap)*CC);
    oldBandE = lpc+LPC_ORDER;
    oldLogE = oldBandE + 2*st->mode->nbEBands;
    oldLogE2 = oldLogE + 2*st->mode->nbEBands;
--- a/libcelt/dump_modes.c
+++ b/libcelt/dump_modes.c
@@ -83,7 +83,7 @@
       
       fprintf(file, "#ifndef DEF_WINDOW%d\n", mode->overlap);
       fprintf(file, "#define DEF_WINDOW%d\n", mode->overlap);
-      fprintf (file, "static const celt_word16 window%d[%d] = {\n", mode->overlap, mode->overlap);
+      fprintf (file, "static const opus_val16 window%d[%d] = {\n", mode->overlap, mode->overlap);
       for (j=0;j<mode->overlap;j++)
          fprintf (file, WORD16 ", ", mode->window[j]);
       fprintf (file, "};\n");
@@ -188,7 +188,7 @@
       /* MDCT twiddles */
       fprintf(file, "#ifndef MDCT_TWIDDLES%d\n", mdctSize);
       fprintf(file, "#define MDCT_TWIDDLES%d\n", mdctSize);
-      fprintf (file, "static const celt_word16 mdct_twiddles%d[%d] = {\n",
+      fprintf (file, "static const opus_val16 mdct_twiddles%d[%d] = {\n",
             mdctSize, mode->mdct.n/4+1);
       for (j=0;j<=mode->mdct.n/4;j++)
          fprintf (file, WORD16 ", ", mode->mdct.trig[j]);
--- a/libcelt/fixed_c5x.h
+++ b/libcelt/fixed_c5x.h
@@ -78,7 +78,7 @@
 #define OVERRIDE_CELT_MAXABS16
 
 #define OVERRIDE_FIND_MAX16
-static inline int find_max16(celt_word16 *x, int len)
+static inline int find_max16(opus_val16 *x, int len)
 {
    DATA max_corr16 = -VERY_LARGE16;
    DATA pitch16 = 0;
--- a/libcelt/fixed_c6x.h
+++ b/libcelt/fixed_c6x.h
@@ -68,7 +68,7 @@
 #define OVERRIDE_CELT_MAXABS16
 
 #define OVERRIDE_FIND_MAX16
-static inline int find_max16(celt_word16 *x, int len)
+static inline int find_max16(opus_val16 *x, int len)
 {
    DATA max_corr16 = -VERY_LARGE16;
    DATA pitch16 = 0;
--- a/libcelt/fixed_debug.h
+++ b/libcelt/fixed_debug.h
@@ -42,14 +42,14 @@
 
 #define MIPS_INC celt_mips++,
 
-#define MULT16_16SU(a,b) ((celt_word32)(celt_word16)(a)*(celt_word32)(opus_uint16)(b))
+#define MULT16_16SU(a,b) ((opus_val32)(opus_val16)(a)*(opus_val32)(opus_uint16)(b))
 #define MULT32_32_Q31(a,b) ADD32(ADD32(SHL32(MULT16_16(SHR32((a),16),SHR((b),16)),1), SHR32(MULT16_16SU(SHR32((a),16),((b)&0x0000ffff)),15)), SHR32(MULT16_16SU(SHR32((b),16),((a)&0x0000ffff)),15))
 
 /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */
 #define MULT16_32_Q16(a,b) ADD32(MULT16_16((a),SHR32((b),16)), SHR32(MULT16_16SU((a),((b)&0x0000ffff)),16))
 
-#define QCONST16(x,bits) ((celt_word16)(.5+(x)*(((celt_word32)1)<<(bits))))
-#define QCONST32(x,bits) ((celt_word32)(.5+(x)*(((celt_word32)1)<<(bits))))
+#define QCONST16(x,bits) ((opus_val16)(.5+(x)*(((opus_val32)1)<<(bits))))
+#define QCONST32(x,bits) ((opus_val32)(.5+(x)*(((opus_val32)1)<<(bits))))
 
 
 #define VERIFY_SHORT(x) ((x)<=32767&&(x)>=-32768)
@@ -173,7 +173,7 @@
 }
 
 #define PSHR16(a,shift) (celt_mips--,SHR16(ADD16((a),((1<<((shift))>>1))),shift))
-#define PSHR32(a,shift) (celt_mips--,SHR32(ADD32((a),(((celt_word32)(1)<<((shift))>>1))),shift))
+#define PSHR32(a,shift) (celt_mips--,SHR32(ADD32((a),(((opus_val32)(1)<<((shift))>>1))),shift))
 #define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift)))
 
 #define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
@@ -332,7 +332,7 @@
    {
       fprintf (stderr, "MULT16_32_Q%d: inputs are not short+int: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line);
    }
-   if (ABS32(b)>=((celt_word32)(1)<<(15+Q)))
+   if (ABS32(b)>=((opus_val32)(1)<<(15+Q)))
       fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line);      
    res = (((long long)a)*(long long)b) >> Q;
    if (!VERIFY_INT(res))
@@ -351,9 +351,9 @@
    {
       fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d\n", Q, (int)a, (int)b);
    }
-   if (ABS32(b)>=((celt_word32)(1)<<(15+Q)))
+   if (ABS32(b)>=((opus_val32)(1)<<(15+Q)))
       fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d\n", Q, (int)a, (int)b);      
-   res = ((((long long)a)*(long long)b) + (((celt_word32)(1)<<Q)>>1))>> Q;
+   res = ((((long long)a)*(long long)b) + (((opus_val32)(1)<<Q)>>1))>> Q;
    if (!VERIFY_INT(res))
       fprintf (stderr, "MULT16_32_P%d: output is not int: %d*%d=%d\n", Q, (int)a, (int)b,(int)res);
    if (Q==15)
--- a/libcelt/fixed_generic.h
+++ b/libcelt/fixed_generic.h
@@ -34,7 +34,7 @@
 #define FIXED_GENERIC_H
 
 /** Multiply a 16-bit signed value by a 16-bit unsigned value. The result is a 32-bit signed value */
-#define MULT16_16SU(a,b) ((celt_word32)(celt_word16)(a)*(celt_word32)(opus_uint16)(b))
+#define MULT16_16SU(a,b) ((opus_val32)(opus_val16)(a)*(opus_val32)(opus_uint16)(b))
 
 /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */
 #define MULT16_32_Q16(a,b) ADD32(MULT16_16((a),SHR((b),16)), SHR(MULT16_16SU((a),((b)&0x0000ffff)),16))
@@ -49,9 +49,9 @@
 #define MULT32_32_Q32(a,b) ADD32(ADD32(MULT16_16(SHR((a),16),SHR((b),16)), SHR(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),16)), SHR(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),16))
 
 /** Compile-time conversion of float constant to 16-bit value */
-#define QCONST16(x,bits) ((celt_word16)(.5+(x)*(((celt_word32)1)<<(bits))))
+#define QCONST16(x,bits) ((opus_val16)(.5+(x)*(((opus_val32)1)<<(bits))))
 /** Compile-time conversion of float constant to 32-bit value */
-#define QCONST32(x,bits) ((celt_word32)(.5+(x)*(((celt_word32)1)<<(bits))))
+#define QCONST32(x,bits) ((opus_val32)(.5+(x)*(((opus_val32)1)<<(bits))))
 
 /** Negate a 16-bit value */
 #define NEG16(x) (-(x))
@@ -59,9 +59,9 @@
 #define NEG32(x) (-(x))
 
 /** Change a 32-bit value into a 16-bit value. The value is assumed to fit in 16-bit, otherwise the result is undefined */
-#define EXTRACT16(x) ((celt_word16)(x))
+#define EXTRACT16(x) ((opus_val16)(x))
 /** Change a 16-bit value into a 32-bit value */
-#define EXTEND32(x) ((celt_word32)(x))
+#define EXTEND32(x) ((opus_val32)(x))
 
 /** Arithmetic shift-right of a 16-bit value */
 #define SHR16(a,shift) ((a) >> (shift))
@@ -70,7 +70,7 @@
 /** Arithmetic shift-right of a 32-bit value */
 #define SHR32(a,shift) ((a) >> (shift))
 /** Arithmetic shift-left of a 32-bit value */
-#define SHL32(a,shift) ((celt_word32)(a) << (shift))
+#define SHL32(a,shift) ((opus_val32)(a) << (shift))
 
 /** 16-bit arithmetic shift right with rounding-to-nearest instead of rounding down */
 #define PSHR16(a,shift) (SHR16((a)+((1<<((shift))>>1)),shift))
@@ -86,7 +86,7 @@
 
 /** "RAW" macros, should not be used outside of this header file */
 #define SHR(a,shift) ((a) >> (shift))
-#define SHL(a,shift) ((celt_word32)(a) << (shift))
+#define SHL(a,shift) ((opus_val32)(a) << (shift))
 #define PSHR(a,shift) (SHR((a)+((EXTEND32(1)<<((shift))>>1)),shift))
 #define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
 
@@ -97,21 +97,21 @@
 #define HALF32(x)  (SHR32(x,1))
 
 /** Add two 16-bit values */
-#define ADD16(a,b) ((celt_word16)((celt_word16)(a)+(celt_word16)(b)))
+#define ADD16(a,b) ((opus_val16)((opus_val16)(a)+(opus_val16)(b)))
 /** Subtract two 16-bit values */
-#define SUB16(a,b) ((celt_word16)(a)-(celt_word16)(b))
+#define SUB16(a,b) ((opus_val16)(a)-(opus_val16)(b))
 /** Add two 32-bit values */
-#define ADD32(a,b) ((celt_word32)(a)+(celt_word32)(b))
+#define ADD32(a,b) ((opus_val32)(a)+(opus_val32)(b))
 /** Subtract two 32-bit values */
-#define SUB32(a,b) ((celt_word32)(a)-(celt_word32)(b))
+#define SUB32(a,b) ((opus_val32)(a)-(opus_val32)(b))
 
 
 /** 16x16 multiplication where the result fits in 16 bits */
-#define MULT16_16_16(a,b)     ((((celt_word16)(a))*((celt_word16)(b))))
+#define MULT16_16_16(a,b)     ((((opus_val16)(a))*((opus_val16)(b))))
 
-/* (celt_word32)(celt_word16) gives TI compiler a hint that it's 16x16->32 multiply */
+/* (opus_val32)(opus_val16) gives TI compiler a hint that it's 16x16->32 multiply */
 /** 16x16 multiplication where the result fits in 32 bits */
-#define MULT16_16(a,b)     (((celt_word32)(celt_word16)(a))*((celt_word32)(celt_word16)(b)))
+#define MULT16_16(a,b)     (((opus_val32)(opus_val16)(a))*((opus_val32)(opus_val16)(b)))
 
 /** 16x16 multiply-add where the result fits in 32 bits */
 #define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b))))
@@ -147,12 +147,12 @@
 #define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15))
 
 /** Divide a 32-bit value by a 16-bit value. Result fits in 16 bits */
-#define DIV32_16(a,b) ((celt_word16)(((celt_word32)(a))/((celt_word16)(b))))
+#define DIV32_16(a,b) ((opus_val16)(((opus_val32)(a))/((opus_val16)(b))))
 /** Divide a 32-bit value by a 16-bit value and round to nearest. Result fits in 16 bits */
-#define PDIV32_16(a,b) ((celt_word16)(((celt_word32)(a)+((celt_word16)(b)>>1))/((celt_word16)(b))))
+#define PDIV32_16(a,b) ((opus_val16)(((opus_val32)(a)+((opus_val16)(b)>>1))/((opus_val16)(b))))
 /** Divide a 32-bit value by a 32-bit value. Result fits in 32 bits */
-#define DIV32(a,b) (((celt_word32)(a))/((celt_word32)(b)))
+#define DIV32(a,b) (((opus_val32)(a))/((opus_val32)(b)))
 /** Divide a 32-bit value by a 32-bit value and round to nearest. Result fits in 32 bits */
-#define PDIV32(a,b) (((celt_word32)(a)+((celt_word16)(b)>>1))/((celt_word32)(b)))
+#define PDIV32(a,b) (((opus_val32)(a)+((opus_val16)(b)>>1))/((opus_val32)(b)))
 
 #endif
--- a/libcelt/kiss_fft.c
+++ b/libcelt/kiss_fft.c
@@ -570,7 +570,7 @@
    int i;
 #ifdef FIXED_POINT
    for (i=0;i<nfft;++i) {
-      celt_word32 phase = -i;
+      opus_val32 phase = -i;
       kf_cexp2(twiddles+i, DIV32(SHL32(phase,17),nfft));
    }
 #else
--- a/libcelt/mathops.c
+++ b/libcelt/mathops.c
@@ -66,10 +66,10 @@
 
 #ifdef FIXED_POINT
 
-celt_word32 frac_div32(celt_word32 a, celt_word32 b)
+opus_val32 frac_div32(opus_val32 a, opus_val32 b)
 {
-   celt_word16 rcp;
-   celt_word32 result, rem;
+   opus_val16 rcp;
+   opus_val32 result, rem;
    int shift = celt_ilog2(b)-29;
    a = VSHR32(a,shift);
    b = VSHR32(b,shift);
@@ -82,12 +82,12 @@
 }
 
 /** Reciprocal sqrt approximation in the range [0.25,1) (Q16 in, Q14 out) */
-celt_word16 celt_rsqrt_norm(celt_word32 x)
+opus_val16 celt_rsqrt_norm(opus_val32 x)
 {
-   celt_word16 n;
-   celt_word16 r;
-   celt_word16 r2;
-   celt_word16 y;
+   opus_val16 n;
+   opus_val16 r;
+   opus_val16 r2;
+   opus_val16 y;
    /* Range of n is [-16384,32767] ([-0.5,1) in Q15). */
    n = x-32768;
    /* Get a rough initial guess for the root.
@@ -110,12 +110,12 @@
 }
 
 /** Sqrt approximation (QX input, QX/2 output) */
-celt_word32 celt_sqrt(celt_word32 x)
+opus_val32 celt_sqrt(opus_val32 x)
 {
    int k;
-   celt_word16 n;
-   celt_word32 rt;
-   static const celt_word16 C[5] = {23175, 11561, -3011, 1699, -664};
+   opus_val16 n;
+   opus_val32 rt;
+   static const opus_val16 C[5] = {23175, 11561, -3011, 1699, -664};
    if (x==0)
       return 0;
    k = (celt_ilog2(x)>>1)-7;
@@ -132,9 +132,9 @@
 #define L3 8277
 #define L4 -626
 
-static inline celt_word16 _celt_cos_pi_2(celt_word16 x)
+static inline opus_val16 _celt_cos_pi_2(opus_val16 x)
 {
-   celt_word16 x2;
+   opus_val16 x2;
 
    x2 = MULT16_16_P15(x,x);
    return ADD16(1,MIN16(32766,ADD32(SUB16(L1,x2), MULT16_16_P15(x2, ADD32(L2, MULT16_16_P15(x2, ADD32(L3, MULT16_16_P15(L4, x2
@@ -146,7 +146,7 @@
 #undef L3
 #undef L4
 
-celt_word16 celt_cos_norm(celt_word32 x)
+opus_val16 celt_cos_norm(opus_val32 x)
 {
    x = x&0x0001ffff;
    if (x>SHL32(EXTEND32(1), 16))
@@ -170,11 +170,11 @@
 }
 
 /** Reciprocal approximation (Q15 input, Q16 output) */
-celt_word32 celt_rcp(celt_word32 x)
+opus_val32 celt_rcp(opus_val32 x)
 {
    int i;
-   celt_word16 n;
-   celt_word16 r;
+   opus_val16 n;
+   opus_val16 r;
    celt_assert2(x>0, "celt_rcp() only defined for positive values");
    i = celt_ilog2(x);
    /* n is Q15 with range [0,1). */
--- a/libcelt/mathops.h
+++ b/libcelt/mathops.h
@@ -123,10 +123,10 @@
 
 
 #ifndef OVERRIDE_CELT_MAXABS16
-static inline celt_word16 celt_maxabs16(celt_word16 *x, int len)
+static inline opus_val16 celt_maxabs16(opus_val16 *x, int len)
 {
    int i;
-   celt_word16 maxval = 0;
+   opus_val16 maxval = 0;
    for (i=0;i<len;i++)
       maxval = MAX16(maxval, ABS16(x[i]));
    return maxval;
@@ -134,25 +134,25 @@
 #endif
 
 /** Integer log in base2. Defined for zero, but not for negative numbers */
-static inline opus_int16 celt_zlog2(celt_word32 x)
+static inline opus_int16 celt_zlog2(opus_val32 x)
 {
    return x <= 0 ? 0 : celt_ilog2(x);
 }
 
-celt_word16 celt_rsqrt_norm(celt_word32 x);
+opus_val16 celt_rsqrt_norm(opus_val32 x);
 
-celt_word32 celt_sqrt(celt_word32 x);
+opus_val32 celt_sqrt(opus_val32 x);
 
-celt_word16 celt_cos_norm(celt_word32 x);
+opus_val16 celt_cos_norm(opus_val32 x);
 
 
-static inline celt_word16 celt_log2(celt_word32 x)
+static inline opus_val16 celt_log2(opus_val32 x)
 {
    int i;
-   celt_word16 n, frac;
+   opus_val16 n, frac;
    /* -0.41509302963303146, 0.9609890551383969, -0.31836011537636605,
        0.15530808010959576, -0.08556153059057618 */
-   static const celt_word16 C[5] = {-6801+(1<<13-DB_SHIFT), 15746, -5217, 2545, -1401};
+   static const opus_val16 C[5] = {-6801+(1<<13-DB_SHIFT), 15746, -5217, 2545, -1401};
    if (x==0)
       return -32767;
    i = celt_ilog2(x);
@@ -172,10 +172,10 @@
 #define D2 14819
 #define D3 10204
 /** Base-2 exponential approximation (2^x). (Q10 input, Q16 output) */
-static inline celt_word32 celt_exp2(celt_word16 x)
+static inline opus_val32 celt_exp2(opus_val16 x)
 {
    int integer;
-   celt_word16 frac;
+   opus_val16 frac;
    integer = SHR16(x,10);
    if (integer>14)
       return 0x7f000000;
@@ -186,11 +186,11 @@
    return VSHR32(EXTEND32(frac), -integer-2);
 }
 
-celt_word32 celt_rcp(celt_word32 x);
+opus_val32 celt_rcp(opus_val32 x);
 
-#define celt_div(a,b) MULT32_32_Q31((celt_word32)(a),celt_rcp(b))
+#define celt_div(a,b) MULT32_32_Q31((opus_val32)(a),celt_rcp(b))
 
-celt_word32 frac_div32(celt_word32 a, celt_word32 b);
+opus_val32 frac_div32(opus_val32 a, opus_val32 b);
 
 #define M1 32767
 #define M2 -21
@@ -199,7 +199,7 @@
 
 /* Atan approximation using a 4th order polynomial. Input is in Q15 format
    and normalized by pi/4. Output is in Q15 format */
-static inline celt_word16 celt_atan01(celt_word16 x)
+static inline opus_val16 celt_atan01(opus_val16 x)
 {
    return MULT16_16_P15(x, ADD32(M1, MULT16_16_P15(x, ADD32(M2, MULT16_16_P15(x, ADD32(M3, MULT16_16_P15(M4, x)))))));
 }
@@ -210,17 +210,17 @@
 #undef M4
 
 /* atan2() approximation valid for positive input values */
-static inline celt_word16 celt_atan2p(celt_word16 y, celt_word16 x)
+static inline opus_val16 celt_atan2p(opus_val16 y, opus_val16 x)
 {
    if (y < x)
    {
-      celt_word32 arg;
+      opus_val32 arg;
       arg = celt_div(SHL32(EXTEND32(y),15),x);
       if (arg >= 32767)
          arg = 32767;
       return SHR16(celt_atan01(EXTRACT16(arg)),1);
    } else {
-      celt_word32 arg;
+      opus_val32 arg;
       arg = celt_div(SHL32(EXTEND32(x),15),y);
       if (arg >= 32767)
          arg = 32767;
--- a/libcelt/mdct.c
+++ b/libcelt/mdct.c
@@ -103,7 +103,7 @@
 
 #endif /* CUSTOM_MODES */
 
-void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const celt_word16 *window, int overlap, int shift)
+void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const opus_val16 *window, int overlap, int shift)
 {
    int i;
    int N, N2, N4;
@@ -129,8 +129,8 @@
       const kiss_fft_scalar * restrict xp1 = in+(overlap>>1);
       const kiss_fft_scalar * restrict xp2 = in+N2-1+(overlap>>1);
       kiss_fft_scalar * restrict yp = out;
-      const celt_word16 * restrict wp1 = window+(overlap>>1);
-      const celt_word16 * restrict wp2 = window+(overlap>>1)-1;
+      const opus_val16 * restrict wp1 = window+(overlap>>1);
+      const opus_val16 * restrict wp2 = window+(overlap>>1)-1;
       for(i=0;i<(overlap>>2);i++)
       {
          /* Real part arranged as -d-cR, Imag part arranged as -b+aR*/
@@ -207,7 +207,7 @@
 }
 
 
-void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const celt_word16 * restrict window, int overlap, int shift)
+void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const opus_val16 * restrict window, int overlap, int shift)
 {
    int i;
    int N, N2, N4;
@@ -288,8 +288,8 @@
       kiss_fft_scalar * restrict fp1 = f2+N4-1;
       kiss_fft_scalar * restrict xp1 = out+N2-1;
       kiss_fft_scalar * restrict yp1 = out+N4-overlap/2;
-      const celt_word16 * restrict wp1 = window;
-      const celt_word16 * restrict wp2 = window+overlap-1;
+      const opus_val16 * restrict wp1 = window;
+      const opus_val16 * restrict wp2 = window+overlap-1;
       for(i = 0; i< N4-overlap/2; i++)
       {
          *xp1 = *fp1;
@@ -310,8 +310,8 @@
       kiss_fft_scalar * restrict fp2 = f2+N4;
       kiss_fft_scalar * restrict xp2 = out+N2;
       kiss_fft_scalar * restrict yp2 = out+N-1-(N4-overlap/2);
-      const celt_word16 * restrict wp1 = window;
-      const celt_word16 * restrict wp2 = window+overlap-1;
+      const opus_val16 * restrict wp1 = window;
+      const opus_val16 * restrict wp2 = window+overlap-1;
       for(i = 0; i< N4-overlap/2; i++)
       {
          *xp2 = *fp2;
--- a/libcelt/mdct.h
+++ b/libcelt/mdct.h
@@ -56,10 +56,10 @@
 void clt_mdct_clear(mdct_lookup *l);
 
 /** Compute a forward MDCT and scale by 4/N */
-void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const celt_word16 *window, int overlap, int shift);
+void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const opus_val16 *window, int overlap, int shift);
 
 /** Compute a backward MDCT (no scaling) and performs weighted overlap-add 
     (scales implicitly by 1/2) */
-void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const celt_word16 * restrict window, int overlap, int shift);
+void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const opus_val16 * restrict window, int overlap, int shift);
 
 #endif
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -227,7 +227,7 @@
 #ifdef CUSTOM_MODES
    CELTMode *mode=NULL;
    int res;
-   celt_word16 *window;
+   opus_val16 *window;
    opus_int16 *logN;
    int LM;
    ALLOC_STACK;
@@ -358,7 +358,7 @@
    if (mode->allocVectors==NULL)
       goto failure;
    
-   window = (celt_word16*)celt_alloc(mode->overlap*sizeof(celt_word16));
+   window = (opus_val16*)celt_alloc(mode->overlap*sizeof(opus_val16));
    if (window==NULL)
       goto failure;
 
@@ -416,7 +416,7 @@
    celt_free((opus_int16*)mode->eBands);
    celt_free((opus_int16*)mode->allocVectors);
    
-   celt_free((celt_word16*)mode->window);
+   celt_free((opus_val16*)mode->window);
    celt_free((opus_int16*)mode->logN);
 
    celt_free((opus_int16*)mode->cache.index);
--- a/libcelt/modes.h
+++ b/libcelt/modes.h
@@ -73,7 +73,7 @@
 
    int          nbEBands;
    int          effEBands;
-   celt_word16    preemph[4];
+   opus_val16    preemph[4];
    const opus_int16   *eBands;   /**< Definition for each "pseudo-critical band" */
    
    int          nbAllocVectors; /**< Number of lines in the matrix below */
@@ -82,7 +82,7 @@
    /* Stuff that could go in the {en,de}coder, but we save space this way */
    mdct_lookup mdct;
 
-   const celt_word16 *window;
+   const opus_val16 *window;
 
    int         maxLM;
    int         nbShortMdcts;
--- a/libcelt/pitch.c
+++ b/libcelt/pitch.c
@@ -42,13 +42,13 @@
 #include "stack_alloc.h"
 #include "mathops.h"
 
-static void find_best_pitch(celt_word32 *xcorr, celt_word32 maxcorr, celt_word16 *y,
+static void find_best_pitch(opus_val32 *xcorr, opus_val32 maxcorr, opus_val16 *y,
                             int yshift, int len, int max_pitch, int best_pitch[2])
 {
    int i, j;
-   celt_word32 Syy=1;
-   celt_word16 best_num[2];
-   celt_word32 best_den[2];
+   opus_val32 Syy=1;
+   opus_val16 best_num[2];
+   opus_val32 best_den[2];
 #ifdef FIXED_POINT
    int xshift;
 
@@ -67,8 +67,8 @@
    {
       if (xcorr[i]>0)
       {
-         celt_word16 num;
-         celt_word32 xcorr16;
+         opus_val16 num;
+         opus_val32 xcorr16;
          xcorr16 = EXTRACT16(VSHR32(xcorr[i], xshift));
          num = MULT16_16_Q15(xcorr16,xcorr16);
          if (MULT16_32_Q15(num,best_den[1]) > MULT16_32_Q15(best_num[1],Syy))
@@ -94,13 +94,13 @@
 }
 
 #include "plc.h"
-void pitch_downsample(celt_sig * restrict x[], celt_word16 * restrict x_lp,
+void pitch_downsample(celt_sig * restrict x[], opus_val16 * restrict x_lp,
       int len, int _C)
 {
    int i;
-   celt_word32 ac[5];
-   celt_word16 tmp=Q15ONE;
-   celt_word16 lpc[4], mem[4]={0,0,0,0};
+   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);
@@ -146,16 +146,16 @@
 
 }
 
-void pitch_search(const celt_word16 * restrict x_lp, celt_word16 * restrict y,
+void pitch_search(const opus_val16 * restrict x_lp, opus_val16 * restrict y,
                   int len, int max_pitch, int *pitch)
 {
    int i, j;
    int lag;
    int best_pitch[2]={0};
-   VARDECL(celt_word16, x_lp4);
-   VARDECL(celt_word16, y_lp4);
-   VARDECL(celt_word32, xcorr);
-   celt_word32 maxcorr=1;
+   VARDECL(opus_val16, x_lp4);
+   VARDECL(opus_val16, y_lp4);
+   VARDECL(opus_val32, xcorr);
+   opus_val32 maxcorr=1;
    int offset;
    int shift=0;
 
@@ -163,9 +163,9 @@
 
    lag = len+max_pitch;
 
-   ALLOC(x_lp4, len>>2, celt_word16);
-   ALLOC(y_lp4, lag>>2, celt_word16);
-   ALLOC(xcorr, max_pitch>>1, celt_word32);
+   ALLOC(x_lp4, len>>2, opus_val16);
+   ALLOC(y_lp4, lag>>2, opus_val16);
+   ALLOC(xcorr, max_pitch>>1, opus_val32);
 
    /* Downsample by 2 again */
    for (j=0;j<len>>2;j++)
@@ -192,7 +192,7 @@
 
    for (i=0;i<max_pitch>>2;i++)
    {
-      celt_word32 sum = 0;
+      opus_val32 sum = 0;
       for (j=0;j<len>>2;j++)
          sum = MAC16_16(sum, x_lp4[j],y_lp4[i+j]);
       xcorr[i] = MAX32(-1, sum);
@@ -204,7 +204,7 @@
    maxcorr=1;
    for (i=0;i<max_pitch>>1;i++)
    {
-      celt_word32 sum=0;
+      opus_val32 sum=0;
       xcorr[i] = 0;
       if (abs(i-2*best_pitch[0])>2 && abs(i-2*best_pitch[1])>2)
          continue;
@@ -218,7 +218,7 @@
    /* Refine by pseudo-interpolation */
    if (best_pitch[0]>0 && best_pitch[0]<(max_pitch>>1)-1)
    {
-      celt_word32 a, b, c;
+      opus_val32 a, b, c;
       a = xcorr[best_pitch[0]-1];
       b = xcorr[best_pitch[0]];
       c = xcorr[best_pitch[0]+1];
@@ -237,15 +237,15 @@
 }
 
 static const int second_check[16] = {0, 0, 3, 2, 3, 2, 5, 2, 3, 2, 3, 2, 5, 2, 3, 2};
-celt_word16 remove_doubling(celt_word16 *x, int maxperiod, int minperiod,
-      int N, int *_T0, int prev_period, celt_word16 prev_gain)
+opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
+      int N, int *_T0, int prev_period, opus_val16 prev_gain)
 {
    int k, i, T, T0;
-   celt_word16 g, g0;
-   celt_word16 pg;
-   celt_word32 xy,xx,yy;
-   celt_word32 xcorr[3];
-   celt_word32 best_xy, best_yy;
+   opus_val16 g, g0;
+   opus_val16 pg;
+   opus_val32 xy,xx,yy;
+   opus_val32 xcorr[3];
+   opus_val32 best_xy, best_yy;
    int offset;
    int minperiod0;
 
@@ -271,7 +271,7 @@
    best_yy = yy;
 #ifdef FIXED_POINT
       {
-         celt_word32 x2y2;
+         opus_val32 x2y2;
          int sh, t;
          x2y2 = 1+HALF32(MULT32_32_Q31(xx,yy));
          sh = celt_ilog2(x2y2)>>1;
@@ -285,8 +285,8 @@
    for (k=2;k<=15;k++)
    {
       int T1, T1b;
-      celt_word16 g1;
-      celt_word16 cont=0;
+      opus_val16 g1;
+      opus_val16 cont=0;
       T1 = (2*T0+k)/(2*k);
       if (T1 < minperiod)
          break;
@@ -312,7 +312,7 @@
       }
 #ifdef FIXED_POINT
       {
-         celt_word32 x2y2;
+         opus_val32 x2y2;
          int sh, t;
          x2y2 = 1+MULT32_32_Q31(xx,yy);
          sh = celt_ilog2(x2y2)>>1;
--- a/libcelt/pitch.h
+++ b/libcelt/pitch.h
@@ -37,13 +37,13 @@
 
 #include "modes.h"
 
-void pitch_downsample(celt_sig * restrict x[], celt_word16 * restrict x_lp,
+void pitch_downsample(celt_sig * restrict x[], opus_val16 * restrict x_lp,
       int len, int _C);
 
-void pitch_search(const celt_word16 * restrict x_lp, celt_word16 * restrict y,
+void pitch_search(const opus_val16 * restrict x_lp, opus_val16 * restrict y,
                   int len, int max_pitch, int *pitch);
 
-celt_word16 remove_doubling(celt_word16 *x, int maxperiod, int minperiod,
-      int N, int *T0, int prev_period, celt_word16 prev_gain);
+opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
+      int N, int *T0, int prev_period, opus_val16 prev_gain);
 
 #endif
--- a/libcelt/plc.c
+++ b/libcelt/plc.c
@@ -37,16 +37,16 @@
 
 
 void _celt_lpc(
-      celt_word16       *_lpc, /* out: [0...p-1] LPC coefficients      */
-const celt_word32 *ac,  /* in:  [0...p] autocorrelation values  */
+      opus_val16       *_lpc, /* out: [0...p-1] LPC coefficients      */
+const opus_val32 *ac,  /* in:  [0...p] autocorrelation values  */
 int          p
 )
 {
    int i, j;  
-   celt_word32 r;
-   celt_word32 error = ac[0];
+   opus_val32 r;
+   opus_val32 error = ac[0];
 #ifdef FIXED_POINT
-   celt_word32 lpc[LPC_ORDER];
+   opus_val32 lpc[LPC_ORDER];
 #else
    float *lpc = _lpc;
 #endif
@@ -57,7 +57,7 @@
    {
       for (i = 0; i < p; i++) {
          /* Sum up this iteration's reflection coefficient */
-         celt_word32 rr = 0;
+         opus_val32 rr = 0;
          for (j = 0; j < i; j++)
             rr += MULT32_32_Q31(lpc[j],ac[i - j]);
          rr += SHR32(ac[i + 1],3);
@@ -66,7 +66,7 @@
          lpc[i] = SHR32(r,3);
          for (j = 0; j < (i+1)>>1; j++)
          {
-            celt_word32 tmp1, tmp2;
+            opus_val32 tmp1, tmp2;
             tmp1 = lpc[j];
             tmp2 = lpc[i-1-j];
             lpc[j]     = tmp1 + MULT32_32_Q31(r,tmp2);
@@ -90,18 +90,18 @@
 #endif
 }
 
-void fir(const celt_word16 *x,
-         const celt_word16 *num,
-         celt_word16 *y,
+void fir(const opus_val16 *x,
+         const opus_val16 *num,
+         opus_val16 *y,
          int N,
          int ord,
-         celt_word16 *mem)
+         opus_val16 *mem)
 {
    int i,j;
 
    for (i=0;i<N;i++)
    {
-      celt_word32 sum = SHL32(EXTEND32(x[i]), SIG_SHIFT);
+      opus_val32 sum = SHL32(EXTEND32(x[i]), SIG_SHIFT);
       for (j=0;j<ord;j++)
       {
          sum += MULT16_16(num[j],mem[j]);
@@ -115,17 +115,17 @@
    }
 }
 
-void iir(const celt_word32 *x,
-         const celt_word16 *den,
-         celt_word32 *y,
+void iir(const opus_val32 *x,
+         const opus_val16 *den,
+         opus_val32 *y,
          int N,
          int ord,
-         celt_word16 *mem)
+         opus_val16 *mem)
 {
    int i,j;
    for (i=0;i<N;i++)
    {
-      celt_word32 sum = x[i];
+      opus_val32 sum = x[i];
       for (j=0;j<ord;j++)
       {
          sum -= MULT16_16(den[j],mem[j]);
@@ -140,19 +140,19 @@
 }
 
 void _celt_autocorr(
-                   const celt_word16 *x,   /*  in: [0...n-1] samples x   */
-                   celt_word32       *ac,  /* out: [0...lag-1] ac values */
-                   const celt_word16       *window,
+                   const opus_val16 *x,   /*  in: [0...n-1] samples x   */
+                   opus_val32       *ac,  /* out: [0...lag-1] ac values */
+                   const opus_val16       *window,
                    int          overlap,
                    int          lag, 
                    int          n
                   )
 {
-   celt_word32 d;
+   opus_val32 d;
    int i;
-   VARDECL(celt_word16, xx);
+   VARDECL(opus_val16, xx);
    SAVE_STACK;
-   ALLOC(xx, n, celt_word16);
+   ALLOC(xx, n, opus_val16);
    for (i=0;i<n;i++)
       xx[i] = x[i];
    for (i=0;i<overlap;i++)
@@ -162,7 +162,7 @@
    }
 #ifdef FIXED_POINT
    {
-      celt_word32 ac0=0;
+      opus_val32 ac0=0;
       int shift;
       for(i=0;i<n;i++)
          ac0 += SHR32(MULT16_16(xx[i],xx[i]),8);
--- a/libcelt/plc.h
+++ b/libcelt/plc.h
@@ -32,24 +32,24 @@
 
 #define LPC_ORDER 24
 
-void _celt_lpc(celt_word16 *_lpc, const celt_word32 *ac, int p);
+void _celt_lpc(opus_val16 *_lpc, const opus_val32 *ac, int p);
 
-void fir(const celt_word16 *x,
-         const celt_word16 *num,
-         celt_word16 *y,
+void fir(const opus_val16 *x,
+         const opus_val16 *num,
+         opus_val16 *y,
          int N,
          int ord,
-         celt_word16 *mem);
+         opus_val16 *mem);
 
-void iir(const celt_word32 *x,
-         const celt_word16 *den,
-         celt_word32 *y,
+void iir(const opus_val32 *x,
+         const opus_val16 *den,
+         opus_val32 *y,
          int N,
          int ord,
-         celt_word16 *mem);
+         opus_val16 *mem);
 
 
-void _celt_autocorr(const celt_word16 *x, celt_word32 *ac, const celt_word16 *window, int overlap, int lag, int n);
+void _celt_autocorr(const opus_val16 *x, opus_val32 *ac, const opus_val16 *window, int overlap, int lag, int n);
 
 
 #endif /* PLC_H */
--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -50,7 +50,7 @@
 };
 #else
 /* Mean energy in each band quantized in Q6 and converted back to float */
-static const celt_word16 eMeans[25] = {
+static const opus_val16 eMeans[25] = {
       6.437500f, 6.250000f, 5.750000f, 5.312500f, 5.062500f,
       4.812500f, 4.500000f, 4.375000f, 4.875000f, 4.687500f,
       4.562500f, 4.437500f, 4.875000f, 4.625000f, 4.312500f,
@@ -60,13 +60,13 @@
 #endif
 /* prediction coefficients: 0.9, 0.8, 0.65, 0.5 */
 #ifdef FIXED_POINT
-static const celt_word16 pred_coef[4] = {29440, 26112, 21248, 16384};
-static const celt_word16 beta_coef[4] = {30147, 22282, 12124, 6554};
-static const celt_word16 beta_intra = 4915;
+static const opus_val16 pred_coef[4] = {29440, 26112, 21248, 16384};
+static const opus_val16 beta_coef[4] = {30147, 22282, 12124, 6554};
+static const opus_val16 beta_intra = 4915;
 #else
-static const celt_word16 pred_coef[4] = {29440/32768., 26112/32768., 21248/32768., 16384/32768.};
-static const celt_word16 beta_coef[4] = {30147/32768., 22282/32768., 12124/32768., 6554/32768.};
-static const celt_word16 beta_intra = 4915/32768.;
+static const opus_val16 pred_coef[4] = {29440/32768., 26112/32768., 21248/32768., 16384/32768.};
+static const opus_val16 beta_coef[4] = {30147/32768., 22282/32768., 12124/32768., 6554/32768.};
+static const opus_val16 beta_intra = 4915/32768.;
 #endif
 
 /*Parameters of the Laplace-like probability models used for the coarse energy.
@@ -139,14 +139,14 @@
 
 static const unsigned char small_energy_icdf[3]={2,1,0};
 
-static celt_word32 loss_distortion(const celt_word16 *eBands, celt_word16 *oldEBands, int start, int end, int len, int C)
+static opus_val32 loss_distortion(const opus_val16 *eBands, opus_val16 *oldEBands, int start, int end, int len, int C)
 {
    int c, i;
-   celt_word32 dist = 0;
+   opus_val32 dist = 0;
    c=0; do {
       for (i=start;i<end;i++)
       {
-         celt_word16 d = SHR16(SUB16(eBands[i+c*len], oldEBands[i+c*len]),2);
+         opus_val16 d = SHR16(SUB16(eBands[i+c*len], oldEBands[i+c*len]),2);
          dist = MAC16_16(dist, d,d);
       }
    } while (++c<C);
@@ -154,17 +154,17 @@
 }
 
 static int quant_coarse_energy_impl(const CELTMode *m, int start, int end,
-      const celt_word16 *eBands, celt_word16 *oldEBands,
+      const opus_val16 *eBands, opus_val16 *oldEBands,
       opus_int32 budget, opus_int32 tell,
-      const unsigned char *prob_model, celt_word16 *error, ec_enc *enc,
-      int _C, int LM, int intra, celt_word16 max_decay)
+      const unsigned char *prob_model, opus_val16 *error, ec_enc *enc,
+      int _C, int LM, int intra, opus_val16 max_decay)
 {
    const int C = CHANNELS(_C);
    int i, c;
    int badness = 0;
-   celt_word32 prev[2] = {0,0};
-   celt_word16 coef;
-   celt_word16 beta;
+   opus_val32 prev[2] = {0,0};
+   opus_val16 coef;
+   opus_val16 beta;
 
    if (tell+3 <= budget)
       ec_enc_bit_logp(enc, intra, 3);
@@ -184,11 +184,11 @@
       do {
          int bits_left;
          int qi, qi0;
-         celt_word32 q;
-         celt_word16 x;
-         celt_word32 f, tmp;
-         celt_word16 oldE;
-         celt_word16 decay_bound;
+         opus_val32 q;
+         opus_val16 x;
+         opus_val32 f, tmp;
+         opus_val16 oldE;
+         opus_val16 decay_bound;
          x = eBands[i+c*m->nbEBands];
          oldE = MAX16(-QCONST16(9.f,DB_SHIFT), oldEBands[i+c*m->nbEBands]);
 #ifdef FIXED_POINT
@@ -196,7 +196,7 @@
          /* Rounding to nearest integer here is really important! */
          qi = (f+QCONST32(.5f,DB_SHIFT+7))>>(DB_SHIFT+7);
          decay_bound = EXTRACT16(MAX32(-QCONST16(28.f,DB_SHIFT),
-               SUB32((celt_word32)oldEBands[i+c*m->nbEBands],max_decay)));
+               SUB32((opus_val32)oldEBands[i+c*m->nbEBands],max_decay)));
 #else
          f = x-coef*oldE-prev[c];
          /* Rounding to nearest integer here is really important! */
@@ -258,20 +258,20 @@
 }
 
 void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
-      const celt_word16 *eBands, celt_word16 *oldEBands, opus_uint32 budget,
-      celt_word16 *error, ec_enc *enc, int _C, int LM, int nbAvailableBytes,
-      int force_intra, celt_word32 *delayedIntra, int two_pass, int loss_rate)
+      const opus_val16 *eBands, opus_val16 *oldEBands, opus_uint32 budget,
+      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;
-   celt_word16 max_decay;
-   VARDECL(celt_word16, oldEBands_intra);
-   VARDECL(celt_word16, error_intra);
+   opus_val16 max_decay;
+   VARDECL(opus_val16, oldEBands_intra);
+   VARDECL(opus_val16, error_intra);
    ec_enc enc_start_state;
    opus_uint32 tell;
    int badness1=0;
    opus_int32 intra_bias;
-   celt_word32 new_distortion;
+   opus_val32 new_distortion;
    SAVE_STACK;
 
    intra = force_intra || (!two_pass && *delayedIntra>2*C*(end-start) && nbAvailableBytes > (end-start)*C);
@@ -293,8 +293,8 @@
 
    enc_start_state = *enc;
 
-   ALLOC(oldEBands_intra, C*m->nbEBands, celt_word16);
-   ALLOC(error_intra, C*m->nbEBands, celt_word16);
+   ALLOC(oldEBands_intra, C*m->nbEBands, opus_val16);
+   ALLOC(error_intra, C*m->nbEBands, opus_val16);
    CELT_COPY(oldEBands_intra, oldEBands, C*m->nbEBands);
 
    if (two_pass || intra)
@@ -353,7 +353,7 @@
    RESTORE_STACK;
 }
 
-void quant_fine_energy(const CELTMode *m, int start, int end, celt_word16 *oldEBands, celt_word16 *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);
@@ -367,7 +367,7 @@
       c=0;
       do {
          int q2;
-         celt_word16 offset;
+         opus_val16 offset;
 #ifdef FIXED_POINT
          /* Has to be without rounding */
          q2 = (error[i+c*m->nbEBands]+QCONST16(.5f,DB_SHIFT))>>(DB_SHIFT-fine_quant[i]);
@@ -391,7 +391,7 @@
    }
 }
 
-void quant_energy_finalise(const CELTMode *m, int start, int end, celt_word16 *oldEBands, celt_word16 *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);
@@ -406,7 +406,7 @@
          c=0;
          do {
             int q2;
-            celt_word16 offset;
+            opus_val16 offset;
             q2 = error[i+c*m->nbEBands]<0 ? 0 : 1;
             ec_enc_bits(enc, q2, 1);
 #ifdef FIXED_POINT
@@ -421,13 +421,13 @@
    }
 }
 
-void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_word16 *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;
-   celt_word32 prev[2] = {0, 0};
-   celt_word16 coef;
-   celt_word16 beta;
+   opus_val32 prev[2] = {0, 0};
+   opus_val16 coef;
+   opus_val16 beta;
    const int C = CHANNELS(_C);
    opus_int32 budget;
    opus_int32 tell;
@@ -450,8 +450,8 @@
       c=0;
       do {
          int qi;
-         celt_word32 q;
-         celt_word32 tmp;
+         opus_val32 q;
+         opus_val32 tmp;
          tell = ec_tell(dec);
          if(budget-tell>=15)
          {
@@ -484,7 +484,7 @@
    }
 }
 
-void unquant_fine_energy(const CELTMode *m, int start, int end, celt_word16 *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);
@@ -496,7 +496,7 @@
       c=0; 
       do {
          int q2;
-         celt_word16 offset;
+         opus_val16 offset;
          q2 = ec_dec_bits(dec, fine_quant[i]);
 #ifdef FIXED_POINT
          offset = SUB16(SHR32(SHL32(EXTEND32(q2),DB_SHIFT)+QCONST16(.5f,DB_SHIFT),fine_quant[i]),QCONST16(.5f,DB_SHIFT));
@@ -508,7 +508,7 @@
    }
 }
 
-void unquant_energy_finalise(const CELTMode *m, int start, int end, celt_word16 *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);
@@ -523,7 +523,7 @@
          c=0;
          do {
             int q2;
-            celt_word16 offset;
+            opus_val16 offset;
             q2 = ec_dec_bits(dec, 1);
 #ifdef FIXED_POINT
             offset = SHR16(SHL16(q2,DB_SHIFT)-QCONST16(.5f,DB_SHIFT),fine_quant[i]+1);
@@ -538,7 +538,7 @@
 }
 
 void log2Amp(const CELTMode *m, int start, int end,
-      celt_ener *eBands, celt_word16 *oldEBands, int _C)
+      celt_ener *eBands, opus_val16 *oldEBands, int _C)
 {
    int c, i;
    const int C = CHANNELS(_C);
@@ -548,8 +548,8 @@
          eBands[i+c*m->nbEBands] = 0;
       for (;i<end;i++)
       {
-         celt_word16 lg = ADD16(oldEBands[i+c*m->nbEBands],
-                         SHL16((celt_word16)eMeans[i],6));
+         opus_val16 lg = ADD16(oldEBands[i+c*m->nbEBands],
+                         SHL16((opus_val16)eMeans[i],6));
          eBands[i+c*m->nbEBands] = PSHR32(celt_exp2(lg),4);
       }
       for (;i<m->nbEBands;i++)
@@ -558,7 +558,7 @@
 }
 
 void amp2Log2(const CELTMode *m, int effEnd, int end,
-      celt_ener *bandE, celt_word16 *bandLogE, int _C)
+      celt_ener *bandE, opus_val16 *bandLogE, int _C)
 {
    int c, i;
    const int C = CHANNELS(_C);
@@ -567,7 +567,7 @@
       for (i=0;i<effEnd;i++)
          bandLogE[i+c*m->nbEBands] =
                celt_log2(SHL32(bandE[i+c*m->nbEBands],2))
-               - SHL16((celt_word16)eMeans[i],6);
+               - SHL16((opus_val16)eMeans[i],6);
       for (i=effEnd;i<end;i++)
          bandLogE[c*m->nbEBands+i] = -QCONST16(14.f,DB_SHIFT);
    } while (++c < C);
--- a/libcelt/quant_bands.h
+++ b/libcelt/quant_bands.h
@@ -36,28 +36,28 @@
 #include "mathops.h"
 
 void amp2Log2(const CELTMode *m, int effEnd, int end,
-      celt_ener *bandE, celt_word16 *bandLogE, int _C);
+      celt_ener *bandE, opus_val16 *bandLogE, int _C);
 
 void log2Amp(const CELTMode *m, int start, int end,
-      celt_ener *eBands, celt_word16 *oldEBands, int _C);
+      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 celt_word16 *eBands, celt_word16 *oldEBands, opus_uint32 budget,
-      celt_word16 *error, ec_enc *enc, int _C, int LM,
-      int nbAvailableBytes, int force_intra, celt_word32 *delayedIntra,
+      const opus_val16 *eBands, opus_val16 *oldEBands, opus_uint32 budget,
+      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, celt_word16 *oldEBands, celt_word16 *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, celt_word16 *oldEBands, celt_word16 *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, celt_word16 *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, celt_word16 *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, celt_word16 *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/libcelt/static_modes_fixed.c
+++ b/libcelt/static_modes_fixed.c
@@ -5,7 +5,7 @@
 
 #ifndef DEF_WINDOW120
 #define DEF_WINDOW120
-static const celt_word16 window120[120] = {
+static const opus_val16 window120[120] = {
 2, 20, 55, 108, 178, 266, 372, 494, 635, 792, 966, 1157, 1365, 1590, 1831, 2089, 2362, 2651, 2956, 3276, 3611, 3961, 4325, 4703, 5094, 5499, 5916, 6346, 6788, 7241, 7705, 8179, 8663, 9156, 9657, 10167, 10684, 11207, 11736, 12271, 12810, 13353, 13899, 14447, 14997, 15547, 16098, 16648, 17197, 17744, 18287, 18827, 19363, 19893, 20418, 20936, 21447, 21950, 22445, 22931, 23407, 23874, 24330, 24774, 25208, 25629, 26039, 26435, 26819, 27190, 27548, 27893, 28224, 28541, 28845, 29135, 29411, 29674, 29924, 30160, 30384, 30594, 30792, 30977, 31151, 31313, 31463, 31602, 31731, 31849, 31958, 32057, 32148, 32229, 32303, 32370, 32429, 32481, 32528, 32568, 32604, 32634, 32661, 32683, 32701, 32717, 32729, 32740, 32748, 32754, 32758, 32762, 32764, 32766, 32767, 32767, 32767, 32767, 32767, 32767, };
 #endif
 
@@ -101,7 +101,7 @@
  403, 73, 193, 313, 433, 103, 223, 343, 463, 28, 148, 268, 388, 58, 178, 298, 418, 88, 208, 328, 448, 118, 238, 358, 478, 4, 124, 244, 364, 34, 154, 274, 394, 64, 184, 304, 424, 94, 214, 334, 454, 19, 139, 259, 379, 49, 169, 289, 409, 79, 199, 319, 439, 109, 229, 349, 469, 9, 129, 249, 369, 39, 159, 279, 399, 69, 189, 309, 429, 99, 219, 339, 459, 24, 144, 264, 384, 54, 174, 294, 414, 84, 204, 324, 444, 114, 234, 354, 474, 14, 134, 254, 374, 44, 164, 284, 404, 74, 194, 314, 434, 104, 224, 344, 464, 29, 149, 269, 389, 59, 179, 299, 419, 89, 209, 329, 449, 119, 239, 359, 479, };
 #endif
 
-8, 268, 388, 58, 178, 298, 418, 88, 208, 328, 448, 118, 238, 358, 478, 4, 124, 244, 364, 34, 154, 274, 394, 64, 184, 304, 424, 94, 214, 334, 454, 19, 139, 259, 379, 49, 169, 289, 409, 79, 199, 319, 439, 109, 229, 349, 469, 9, 129, 249, 369, 39, 159, 279, 399, 69, 189, 309, 429, 99, 219, 339, 459, 24, 144, 264, 384, 54, 174, 294, 414, 84, 204, 324, 444, 114, 234, 354, 474, 14, 134, 254, 374, 44, 164, 284, 404, 74, 194, 314, 434, 104, 224, 344, 464, 29, 149, 269, 389, 59, 179, 299, 419, 89, 209, 329, 449, 119, 239, 359, 479, };
+8, 268, 388, 58, 178, 298, 418, 88, 208, 328, 448, 118, 238, 358, 478, 4, 124, 244, 364, 34, 154, 274, 394, 64, 184, 304, 424, 94, 214, 334, 454, 19, 139, 259, 379, 49, 169, 289, 409, 79, 199, 319, 439, 109, 229, 349, 469, 9, 129, 249, 369, 39, 159, 279, 399, 69, 189, 309, 429, 99, 219, 339, 459, 24, 144, 264, 384, 54, 174, 294, 414, 84, 204, 324, 444, 114, 234, 354, 474, 14, 134, 254, 374, 44, 164, 284, 404, 74, 194, 314, 434, 104, 224, 344, 464, 29, 149, 269, 389, 59, 179, 299, 419, 89, 209, 329, 449, 119, 239, 359, 479, };
 118, 238, 358, 478, 4, 124, 244, 364, 34, 154, 274, 394, 64, 184, 304, 424, 94, 214, 334, 454, 19, 139, 259, 379, 49, 169, 289, 409, 79, 199, 319, 439, 109, 229, 349, 469, 9, 129, 249, 369, 39, 159, 279, 399, 69, 189, 309, 429, 99, 219, 339, 459, 24, 144, 264, 384, 54, 174, 294, 414, 84, 204, 324, 444, 114, 234, 354, 474, 14, 134, 254, 374, 44, 164, 284, 404, 74, 194, 314, 434, 104, 224, 344, 464, 29, 149, 269, 389, 59, 179, 299, 419, 89, 209, 329, 449, 119, 239, 359, 479, };
 #endif
 
--- a/libcelt/static_modes_float.c
+++ b/libcelt/static_modes_float.c
@@ -5,7 +5,7 @@
 
 #ifndef DEF_WINDOW120
 #define DEF_WINDOW120
-static const celt_word16 window120[120] = {
+static const opus_val16 window120[120] = {
 0.000067, 0.000606, 0.001682, 0.003295, 0.005444, 0.008128, 0.011344, 0.015091, 0.019365, 0.024164, 0.029483, 0.035320, 0.041669, 0.048525, 0.055884, 0.063738, 0.072082, 0.080907, 0.090208, 0.099974, 0.110198, 0.120869, 0.131977, 0.143512, 0.155462, 0.167814, 0.180555, 0.193673, 0.207152, 0.220977, 0.235132, 0.249602, 0.264369, 0.279414, 0.294720, 0.310268, 0.326038, 0.342009, 0.358162, 0.374474, 0.390925, 0.407491, 0.424152, 0.440884, 0.457665, 0.474471, 0.491280, 0.508068, 0.524813, 0.541491, 0.558080, 0.574557, 0.590900, 0.607088, 0.623100, 0.638913, 0.654509, 0.669868, 0.684971, 0.699800, 0.714339, 0.728571, 0.742480, 0.756054, 0.769279, 0.782143, 0.794634, 0.806744, 0.818465, 0.829787, 0.840707, 0.851218, 0.861317, 0.871002, 0.880271, 0.889125, 0.897564, 0.905591, 0.913209, 0.920423, 0.927237, 0.933660, 0.939697, 0.945357, 0.950649, 0.955584, 0.960171, 0.964422, 0.968349, 0.971963, 0.975279, 0.978309, 0.981066, 0.983565, 0.985819, 0.987842, 0.989649, 0.991253, 0.992669, 0.993910, 0.994990, 0.995923, 0.996722, 0.997399, 0.997967, 0.998437, 0.998822, 0.999132, 0.999376, 0.999565, 0.999708, 0.999812, 0.999886, 0.999936, 0.999967, 0.999985, 0.999995, 0.999999, 1.000000, 1.000000, };
 #endif
 
@@ -105,7 +105,7 @@
 751840, 0.659346}, {0.760406, 0.649448}, {0.768842, 0.639439}, {0.777146, 0.629320}, {0.785317, 0.619094}, {0.793353, 0.608761}, {0.801254, 0.598325}, {0.809017, 0.587785}, {0.816642, 0.577145}, {0.824126, 0.566406}, {0.831470, 0.555570}, {0.838671, 0.544639}, {0.845728, 0.533615}, {0.852640, 0.522499}, {0.859406, 0.511293}, {0.866025, 0.500000}, {0.872496, 0.488621}, {0.878817, 0.477159}, {0.884988, 0.465615}, {0.891007, 0.453990}, {0.896873, 0.442289}, {0.902585, 0.430511}, {0.908143, 0.418660}, {0.913545, 0.406737}, {0.918791, 0.394744}, {0.923880, 0.382683}, {0.928810, 0.370557}, {0.933580, 0.358368}, {0.938191, 0.346117}, {0.942641, 0.333807}, {0.946930, 0.321439}, {0.951057, 0.309017}, {0.955020, 0.296542}, {0.958820, 0.284015}, {0.962455, 0.271440}, {0.965926, 0.258819}, {0.969231, 0.246153}, {0.972370, 0.233445}, {0.975342, 0.220697}, {0.978148, 0.207912}, {0.980785, 0.195090}, {0.983255, 0.182236}, {0.985556, 0.169350}, {0.987688, 0.156434}, {0.989651, 0.143493}, {0.991445, 0.130526}, {0.993068, 0.117537}, {0.994522, 0.104528}, {0.995805, 0.091502}, {0.996917, 0.078459}, {0.997859, 0.065403}, {0.998630, 0.052336}, {0.999229, 0.039260}, {0.999657, 0.026177}, {0.999914, 0.013090}, };
 #ifndef FFT_BITREV480
 #define FFT_BITREV480
- 0.639439}, {0.777146, 0.629320}, {0.785317, 0.619094}, {0.793353, 0.608761}, {0.801254, 0.598325}, {0.809017, 0.587785}, {0.816642, 0.577145}, {0.824126, 0.566406}, {0.831470, 0.555570}, {0.838671, 0.544639}, {0.845728, 0.533615}, {0.852640, 0.522499}, {0.859406, 0.511293}, {0.866025, 0.500000}, {0.872496, 0.488621}, {0.878817, 0.477159}, {0.884988, 0.465615}, {0.891007, 0.453990}, {0.896873, 0.442289}, {0.902585, 0.430511}, {0.908143, 0.418660}, {0.913545, 0.406737}, {0.918791, 0.394744}, {0.923880, 0.382683}, {0.928810, 0.370557}, {0.933580, 0.358368}, {0.938191, 0.346117}, {0.942641, 0.333807}, {0.946930, 0.321439}, {0.951057, 0.309017}, {0.955020, 0.296542}, {0.958820, 0.284015}, {0.962455, 0.271440}, {0.965926, 0.258819}, {0.969231, 0.246153}, {0.972370, 0.233445}, {0.975342, 0.220697}, {0.978148, 0.207912}, {0.980785, 0.195090}, {0.983255, 0.182236}, {0.985556, 0.169350}, {0.987688, 0.156434}, {0.989651, 0.143493}, {0.991445, 0.130526}, {0.993068, 0.117537}, {0.994522, 0.104528}, {0.995805, 0.091502}, {0.996917, 0.078459}, {0.997859, 0.065403}, {0.998630, 0.052336}, {0.999229, 0.039260}, {0.999657, 0.026177}, {0.999914, 0.013090}, };
+ 0.639439}, {0.777146, 0.629320}, {0.785317, 0.619094}, {0.793353, 0.608761}, {0.801254, 0.598325}, {0.809017, 0.587785}, {0.816642, 0.577145}, {0.824126, 0.566406}, {0.831470, 0.555570}, {0.838671, 0.544639}, {0.845728, 0.533615}, {0.852640, 0.522499}, {0.859406, 0.511293}, {0.866025, 0.500000}, {0.872496, 0.488621}, {0.878817, 0.477159}, {0.884988, 0.465615}, {0.891007, 0.453990}, {0.896873, 0.442289}, {0.902585, 0.430511}, {0.908143, 0.418660}, {0.913545, 0.406737}, {0.918791, 0.394744}, {0.923880, 0.382683}, {0.928810, 0.370557}, {0.933580, 0.358368}, {0.938191, 0.346117}, {0.942641, 0.333807}, {0.946930, 0.321439}, {0.951057, 0.309017}, {0.955020, 0.296542}, {0.958820, 0.284015}, {0.962455, 0.271440}, {0.965926, 0.258819}, {0.969231, 0.246153}, {0.972370, 0.233445}, {0.975342, 0.220697}, {0.978148, 0.207912}, {0.980785, 0.195090}, {0.983255, 0.182236}, {0.985556, 0.169350}, {0.987688, 0.156434}, {0.989651, 0.143493}, {0.991445, 0.130526}, {0.993068, 0.117537}, {0.994522, 0.104528}, {0.995805, 0.091502}, {0.996917, 0.078459}, {0.997859, 0.065403}, {0.998630, 0.052336}, {0.999229, 0.039260}, {0.999657, 0.026177}, {0.999914, 0.013090}, };
 94}, {0.793353, 0.608761}, {0.801254, 0.598325}, {0.809017, 0.587785}, {0.816642, 0.577145}, {0.824126, 0.566406}, {0.831470, 0.555570}, {0.838671, 0.544639}, {0.845728, 0.533615}, {0.852640, 0.522499}, {0.859406, 0.511293}, {0.866025, 0.500000}, {0.872496, 0.488621}, {0.878817, 0.477159}, {0.884988, 0.465615}, {0.891007, 0.453990}, {0.896873, 0.442289}, {0.902585, 0.430511}, {0.908143, 0.418660}, {0.913545, 0.406737}, {0.918791, 0.394744}, {0.923880, 0.382683}, {0.928810, 0.370557}, {0.933580, 0.358368}, {0.938191, 0.346117}, {0.942641, 0.333807}, {0.946930, 0.321439}, {0.951057, 0.309017}, {0.955020, 0.296542}, {0.958820, 0.284015}, {0.962455, 0.271440}, {0.965926, 0.258819}, {0.969231, 0.246153}, {0.972370, 0.233445}, {0.975342, 0.220697}, {0.978148, 0.207912}, {0.980785, 0.195090}, {0.983255, 0.182236}, {0.985556, 0.169350}, {0.987688, 0.156434}, {0.989651, 0.143493}, {0.991445, 0.130526}, {0.993068, 0.117537}, {0.994522, 0.104528}, {0.995805, 0.091502}, {0.996917, 0.078459}, {0.997859, 0.065403}, {0.998630, 0.052336}, {0.999229, 0.039260}, {0.999657, 0.026177}, {0.999914, 0.013090}, };
 #ifndef FFT_BITREV480
 #define FFT_BITREV480
--- a/libcelt/tests/mathops-test.c
+++ b/libcelt/tests/mathops-test.c
@@ -24,7 +24,7 @@
    for (i=1;i<=327670;i++)
    {
       double prod;
-      celt_word32 val;
+      opus_val32 val;
       val = celt_rcp(i);
 #ifdef FIXED_POINT
       prod = (1./32768./65526.)*val*i;
@@ -45,7 +45,7 @@
    for (i=1;i<=1000000000;i++)
    {
       double ratio;
-      celt_word16 val;
+      opus_val16 val;
       val = celt_sqrt(i);
       ratio = val/sqrt(i);
       if (fabs(ratio - 1) > .0005 && fabs(val-sqrt(i)) > 2)
@@ -102,7 +102,7 @@
 #else
 void testlog2(void)
 {
-   celt_word32 x;
+   opus_val32 x;
    for (x=8;x<1073741824;x+=(x>>3))
    {
       float error = fabs((1.442695040888963387*log(x/16384.0))-celt_log2(x)/1024.0);
@@ -116,7 +116,7 @@
 
 void testexp2(void)
 {
-   celt_word16 x;
+   opus_val16 x;
    for (x=-32768;x<-30720;x++)
    {
       float error1 = fabs(x/2048.0-(1.442695040888963387*log(celt_exp2(x)/65536.0)));
@@ -131,7 +131,7 @@
 
 void testexp2log2(void)
 {
-   celt_word32 x;
+   opus_val32 x;
    for (x=8;x<65536;x+=(x>>3))
    {
       float error = fabs(x-0.25*celt_exp2(celt_log2(x)<<1))/16384;
@@ -145,10 +145,10 @@
 
 void testilog2(void)
 {
-   celt_word32 x;
+   opus_val32 x;
    for (x=1;x<=268435455;x+=127)
    {
-      celt_word32 error = abs(celt_ilog2(x)-(int)floor(log2(x)));
+      opus_val32 error = abs(celt_ilog2(x)-(int)floor(log2(x)));
       if (error!=0)
       {
          printf("celt_ilog2 failed: celt_ilog2(x)!=floor(log2(x)) (x = %d, error = %d)\n",x,error);
--- a/libcelt/tests/mdct-test.c
+++ b/libcelt/tests/mdct-test.c
@@ -94,7 +94,7 @@
 
     kiss_fft_scalar  * in = (kiss_fft_scalar*)malloc(buflen);
     kiss_fft_scalar  * out= (kiss_fft_scalar*)malloc(buflen);
-    celt_word16  * window= (celt_word16*)malloc(sizeof(celt_word16)*nfft/2);
+    opus_val16  * window= (opus_val16*)malloc(sizeof(opus_val16)*nfft/2);
     int k;
 
     clt_mdct_init(&cfg, nfft, 0);
--- a/libcelt/tests/rotation-test.c
+++ b/libcelt/tests/rotation-test.c
@@ -14,8 +14,8 @@
 {
    int i;
    double err = 0, ener = 0, snr, snr0;
-   celt_word16 x0[MAX_SIZE];
-   celt_word16 x1[MAX_SIZE];
+   opus_val16 x0[MAX_SIZE];
+   opus_val16 x1[MAX_SIZE];
    int nb_rotations = (N+4*K)/(8*K);
    for (i=0;i<N;i++)
       x1[i] = x0[i] = rand()%32767-16384;
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -42,7 +42,7 @@
 #define M_PI 3.141592653
 #endif
 
-static void exp_rotation1(celt_norm *X, int len, int stride, celt_word16 c, celt_word16 s)
+static void exp_rotation1(celt_norm *X, int len, int stride, opus_val16 c, opus_val16 s)
 {
    int i;
    celt_norm *Xptr;
@@ -70,8 +70,8 @@
 {
    static const int SPREAD_FACTOR[3]={15,10,5};
    int i;
-   celt_word16 c, s;
-   celt_word16 gain, theta;
+   opus_val16 c, s;
+   opus_val16 gain, theta;
    int stride2=0;
    int factor;
    /*int i;
@@ -86,7 +86,7 @@
       return;
    factor = SPREAD_FACTOR[spread-1];
 
-   gain = celt_div((celt_word32)MULT16_16(Q15_ONE,len),(celt_word32)(len+factor*K));
+   gain = celt_div((opus_val32)MULT16_16(Q15_ONE,len),(opus_val32)(len+factor*K));
    theta = HALF16(MULT16_16_Q15(gain,gain));
 
    c = celt_cos_norm(EXTEND32(theta));
@@ -129,14 +129,14 @@
 /** Takes the pitch vector and the decoded residual vector, computes the gain
     that will give ||p+g*y||=1 and mixes the residual with the pitch. */
 static void normalise_residual(int * restrict iy, celt_norm * restrict X,
-      int N, celt_word32 Ryy, celt_word16 gain)
+      int N, opus_val32 Ryy, opus_val16 gain)
 {
    int i;
 #ifdef FIXED_POINT
    int k;
 #endif
-   celt_word32 t;
-   celt_word16 g;
+   opus_val32 t;
+   opus_val16 g;
 
 #ifdef FIXED_POINT
    k = celt_ilog2(Ryy)>>1;
@@ -171,17 +171,17 @@
 }
 
 unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B,
-      int resynth, ec_enc *enc, celt_word16 gain)
+      int resynth, ec_enc *enc, opus_val16 gain)
 {
    VARDECL(celt_norm, y);
    VARDECL(int, iy);
-   VARDECL(celt_word16, signx);
+   VARDECL(opus_val16, signx);
    int i, j;
-   celt_word16 s;
+   opus_val16 s;
    int pulsesLeft;
-   celt_word32 sum;
-   celt_word32 xy;
-   celt_word16 yy;
+   opus_val32 sum;
+   opus_val32 xy;
+   opus_val16 yy;
    unsigned collapse_mask;
    SAVE_STACK;
 
@@ -189,7 +189,7 @@
 
    ALLOC(y, N, celt_norm);
    ALLOC(iy, N, int);
-   ALLOC(signx, N, celt_word16);
+   ALLOC(signx, N, opus_val16);
    
    exp_rotation(X, N, 1, B, K, spread);
 
@@ -213,7 +213,7 @@
    /* Do a pre-search by projecting on the pyramid */
    if (K > (N>>1))
    {
-      celt_word16 rcp;
+      opus_val16 rcp;
       j=0; do {
          sum += X[j];
       }  while (++j<N);
@@ -258,7 +258,7 @@
 #endif
    if (pulsesLeft > N+3)
    {
-      celt_word16 tmp = pulsesLeft;
+      opus_val16 tmp = pulsesLeft;
       yy = MAC16_16(yy, tmp, tmp);
       yy = MAC16_16(yy, tmp, y[0]);
       iy[0] += pulsesLeft;
@@ -269,8 +269,8 @@
    for (i=0;i<pulsesLeft;i++)
    {
       int best_id;
-      celt_word32 best_num = -VERY_LARGE16;
-      celt_word16 best_den = 0;
+      opus_val32 best_num = -VERY_LARGE16;
+      opus_val16 best_den = 0;
 #ifdef FIXED_POINT
       int rshift;
 #endif
@@ -283,7 +283,7 @@
       yy = ADD32(yy, 1);
       j=0;
       do {
-         celt_word16 Rxy, Ryy;
+         opus_val16 Rxy, Ryy;
          /* Temporary sums of the new pulse(s) */
          Rxy = EXTRACT16(SHR32(ADD32(xy, EXTEND32(X[j])),rshift));
          /* We're multiplying y[j] by two so we don't have to do it here */
@@ -337,10 +337,10 @@
 /** Decode pulse vector and combine the result with the pitch vector to produce
     the final normalised signal in the current band. */
 unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B,
-      ec_dec *dec, celt_word16 gain)
+      ec_dec *dec, opus_val16 gain)
 {
    int i;
-   celt_word32 Ryy;
+   opus_val32 Ryy;
    unsigned collapse_mask;
    VARDECL(int, iy);
    SAVE_STACK;
@@ -360,15 +360,15 @@
    return collapse_mask;
 }
 
-void renormalise_vector(celt_norm *X, int N, celt_word16 gain)
+void renormalise_vector(celt_norm *X, int N, opus_val16 gain)
 {
    int i;
 #ifdef FIXED_POINT
    int k;
 #endif
-   celt_word32 E = EPSILON;
-   celt_word16 g;
-   celt_word32 t;
+   opus_val32 E = EPSILON;
+   opus_val16 g;
+   opus_val32 t;
    celt_norm *xptr = X;
    for (i=0;i<N;i++)
    {
@@ -394,8 +394,8 @@
 {
    int i;
    int itheta;
-   celt_word16 mid, side;
-   celt_word32 Emid, Eside;
+   opus_val16 mid, side;
+   opus_val32 Emid, Eside;
 
    Emid = Eside = EPSILON;
    if (stereo)
--- a/libcelt/vq.h
+++ b/libcelt/vq.h
@@ -49,7 +49,7 @@
  * @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,
-      int resynth, ec_enc *enc, celt_word16 gain);
+      int resynth, ec_enc *enc, opus_val16 gain);
 
 /** Algebraic pulse decoder
  * @param x Decoded normalised spectrum (returned)
@@ -60,9 +60,9 @@
  * @ret A mask indicating which blocks in the band received pulses
  */
 unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B,
-      ec_dec *dec, celt_word16 gain);
+      ec_dec *dec, opus_val16 gain);
 
-void renormalise_vector(celt_norm *X, int N, celt_word16 gain);
+void renormalise_vector(celt_norm *X, int N, opus_val16 gain);
 
 int stereo_itheta(celt_norm *X, celt_norm *Y, int stereo, int N);
 
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -112,7 +112,7 @@
 }
 
 static void smooth_fade(const short *in1, const short *in2, short *out,
-        int overlap, int channels, const celt_word16 *window, int Fs)
+        int overlap, int channels, const opus_val16 *window, int Fs)
 {
 	int i, c;
 	int inc = 48000/Fs;
@@ -120,7 +120,7 @@
 	{
 		for (i=0;i<overlap;i++)
 		{
-		    celt_word16 w = MULT16_16_Q15(window[i*inc], window[i*inc]);
+		    opus_val16 w = MULT16_16_Q15(window[i*inc], window[i*inc]);
 		    out[i*channels+c] = SHR32(MAC16_16(MULT16_16(w,in2[i*channels+c]),
 		            Q15ONE-w, in1[i*channels+c]), 15);
 		}
@@ -165,7 +165,7 @@
     short redundant_audio[240*2];
     int c;
     int F2_5, F5, F10, F20;
-    const celt_word16 *window;
+    const opus_val16 *window;
 
     silk_dec = (char*)st+st->silk_dec_offset;
     celt_dec = (CELTDecoder*)((char*)st+st->celt_dec_offset);
--- a/win32/config.h
+++ b/win32/config.h
@@ -16,7 +16,7 @@
 /* Get rid of the CELT VS compile warnings */
 #if 1
 #pragma warning(disable : 4018)// signed/unsigned mismatch
-#pragma warning(disable : 4244)// conversion from 'double' to 'celt_word16', possible loss of data
+#pragma warning(disable : 4244)// conversion from 'double' to 'opus_val16', possible loss of data
 #pragma warning(disable : 4267)// conversion from 'size_t' to 'int', possible loss of data
 #pragma warning(disable : 4305)// truncation from 'double' to 'const float'
 #pragma warning(disable : 4311)// pointer truncation from 'char *' to 'long'