shithub: opus

Download patch

ref: 18ddc02afd83b3f015c346275f29ac380ad19687
parent: 14806ab9366166a4f8df639b90be64a9b78b98a3
author: Jean-Marc Valin <[email protected]>
date: Fri Feb 22 09:24:50 EST 2008

Separating types for normalised vs. denormalised data paths

--- a/libcelt/arch.h
+++ b/libcelt/arch.h
@@ -88,11 +88,14 @@
 #endif
 
 
-#else
+#else /* FIXED_POINT */
 
 typedef float celt_word16_t;
 typedef float celt_word32_t;
 
+typedef float celt_sig_t;
+typedef float celt_norm_t;
+
 #define Q15ONE 1.0f
 #define LPC_SCALING  1.f
 #define SIG_SCALING  1.f
@@ -163,7 +166,7 @@
 #define PDIV32(a,b)     (((celt_word32_t)(a))/(celt_word32_t)(b))
 
 
-#endif
+#endif /* !FIXED_POINT */
 
 
 #if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
@@ -173,14 +176,14 @@
 #define BITS_PER_CHAR 16
 #define LOG2_BITS_PER_CHAR 4
 
-#else 
+#else /* CONFIG_TI_C54X */
 
 #define BYTES_PER_CHAR 1
 #define BITS_PER_CHAR 8
 #define LOG2_BITS_PER_CHAR 3
 
-#endif
+#endif /* !CONFIG_TI_C54X */
 
 
 
-#endif
+#endif /* ARCH_H */
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -42,7 +42,7 @@
 /** Applies a series of rotations so that pulses are spread like a two-sided
 exponential. The effect of this is to reduce the tonal noise created by the
 sparse spectrum resulting from the pulse codebook */
-static void exp_rotation(float *X, int len, float theta, int dir, int stride, int iter)
+static void exp_rotation(celt_norm_t *X, int len, float theta, int dir, int stride, int iter)
 {
    int i, k;
    float c, s;
@@ -70,7 +70,7 @@
 }
 
 /* Compute the amplitude (sqrt energy) in each of the bands */
-void compute_band_energies(const CELTMode *m, float *X, float *bank)
+void compute_band_energies(const CELTMode *m, celt_sig_t *X, float *bank)
 {
    int i, c, B, C;
    const int *eBands = m->eBands;
@@ -92,7 +92,7 @@
 }
 
 /* Normalise each band such that the energy is one. */
-void normalise_bands(const CELTMode *m, float *X, float *bank)
+void normalise_bands(const CELTMode *m, celt_sig_t *freq, celt_norm_t *X, float *bank)
 {
    int i, c, B, C;
    const int *eBands = m->eBands;
@@ -105,7 +105,7 @@
          int j;
          float g = 1.f/(1e-10+bank[i*C+c]);
          for (j=B*eBands[i];j<B*eBands[i+1];j++)
-            X[j*C+c] *= g;
+            X[j*C+c] = freq[j*C+c]*g;
       }
    }
    for (i=B*C*eBands[m->nbEBands];i<B*C*eBands[m->nbEBands+1];i++)
@@ -112,16 +112,17 @@
       X[i] = 0;
 }
 
-void renormalise_bands(const CELTMode *m, float *X)
+void renormalise_bands(const CELTMode *m, celt_norm_t *X)
 {
    VARDECL(float *tmpE);
    ALLOC(tmpE, m->nbEBands*m->nbChannels, float);
    compute_band_energies(m, X, tmpE);
-   normalise_bands(m, X, tmpE);
+   /* FIXME: This isn't right */
+   normalise_bands(m, X, X, tmpE);
 }
 
 /* De-normalise the energy to produce the synthesis from the unit-energy bands */
-void denormalise_bands(const CELTMode *m, float *X, float *bank)
+void denormalise_bands(const CELTMode *m, celt_norm_t *X, celt_sig_t *freq, float *bank)
 {
    int i, c, B, C;
    const int *eBands = m->eBands;
@@ -134,16 +135,16 @@
          int j;
          float g = bank[i*C+c];
          for (j=B*eBands[i];j<B*eBands[i+1];j++)
-            X[j*C+c] *= g;
+            freq[j*C+c] = X[j*C+c] * g;
       }
    }
    for (i=B*C*eBands[m->nbEBands];i<B*C*eBands[m->nbEBands+1];i++)
-      X[i] = 0;
+      freq[i] = 0;
 }
 
 
 /* Compute the best gain for each "pitch band" */
-void compute_pitch_gain(const CELTMode *m, float *X, float *P, float *gains, float *bank)
+void compute_pitch_gain(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float *gains, float *bank)
 {
    int i, B;
    const int *eBands = m->eBands;
@@ -191,7 +192,7 @@
 }
 
 /* Apply the (quantised) gain to each "pitch band" */
-void pitch_quant_bands(const CELTMode *m, float *X, float *P, float *gains)
+void pitch_quant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float *gains)
 {
    int i, B;
    const int *pBands = m->pBands;
@@ -209,18 +210,18 @@
 
 
 /* Quantisation of the residual */
-void quant_bands(const CELTMode *m, float *X, float *P, float *W, int total_bits, ec_enc *enc)
+void quant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float *W, int total_bits, ec_enc *enc)
 {
    int i, j, B, bits;
    const int *eBands = m->eBands;
    float alpha = .7;
-   VARDECL(float *norm);
+   VARDECL(celt_norm_t *norm);
    VARDECL(int *pulses);
    VARDECL(int *offsets);
    
    B = m->nbMdctBlocks*m->nbChannels;
    
-   ALLOC(norm, B*eBands[m->nbEBands+1], float);
+   ALLOC(norm, B*eBands[m->nbEBands+1], celt_norm_t);
    ALLOC(pulses, m->nbEBands, int);
    ALLOC(offsets, m->nbEBands, int);
 
@@ -271,18 +272,18 @@
 }
 
 /* Decoding of the residual */
-void unquant_bands(const CELTMode *m, float *X, float *P, int total_bits, ec_dec *dec)
+void unquant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, int total_bits, ec_dec *dec)
 {
    int i, j, B, bits;
    const int *eBands = m->eBands;
    float alpha = .7;
-   VARDECL(float *norm);
+   VARDECL(celt_norm_t *norm);
    VARDECL(int *pulses);
    VARDECL(int *offsets);
    
    B = m->nbMdctBlocks*m->nbChannels;
    
-   ALLOC(norm, B*eBands[m->nbEBands+1], float);
+   ALLOC(norm, B*eBands[m->nbEBands+1], celt_norm_t);
    ALLOC(pulses, m->nbEBands, int);
    ALLOC(offsets, m->nbEBands, int);
 
@@ -326,7 +327,7 @@
       X[i] = 0;
 }
 
-void stereo_mix(const CELTMode *m, float *X, float *bank, int dir)
+void stereo_mix(const CELTMode *m, celt_norm_t *X, float *bank, int dir)
 {
    int i, B, C;
    const int *eBands = m->eBands;
--- a/libcelt/bands.h
+++ b/libcelt/bands.h
@@ -32,7 +32,7 @@
 #ifndef BANDS_H
 #define BANDS_H
 
-
+#include "arch.h"
 #include "modes.h"
 #include "entenc.h"
 #include "entdec.h"
@@ -43,7 +43,7 @@
  * @param X Spectrum
  * @param bands Square root of the energy for each band (returned)
  */
-void compute_band_energies(const CELTMode *m, float *X, float *bands);
+void compute_band_energies(const CELTMode *m, celt_sig_t *X, float *bands);
 
 /** Normalise each band of X such that the energy in each band is 
     equal to 1
@@ -51,9 +51,9 @@
  * @param X Spectrum (returned normalised)
  * @param bands Square root of the energy for each band
  */
-void normalise_bands(const CELTMode *m, float *X, float *bands);
+void normalise_bands(const CELTMode *m, celt_sig_t *freq, celt_norm_t *X, float *bands);
 
-void renormalise_bands(const CELTMode *m, float *X);
+void renormalise_bands(const CELTMode *m, celt_norm_t *X);
 
 /** Denormalise each band of X to restore full amplitude
  * @param m Mode data 
@@ -60,7 +60,7 @@
  * @param X Spectrum (returned de-normalised)
  * @param bands Square root of the energy for each band
  */
-void denormalise_bands(const CELTMode *m, float *X, float *bands);
+void denormalise_bands(const CELTMode *m, celt_norm_t *X, celt_sig_t *freq, float *bands);
 
 /** Compute the pitch predictor gain for each pitch band
  * @param m Mode data 
@@ -69,9 +69,9 @@
  * @param gains Gain computed for each pitch band (returned)
  * @param bank Square root of the energy for each band
  */
-void compute_pitch_gain(const CELTMode *m, float *X, float *P, float *gains, float *bank);
+void compute_pitch_gain(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float *gains, float *bank);
 
-void pitch_quant_bands(const CELTMode *m, float *X, float *P, float *gains);
+void pitch_quant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float *gains);
 
 /** Quantisation/encoding of the residual spectrum
  * @param m Mode data 
@@ -81,7 +81,7 @@
  * @param total_bits Total number of bits that can be used for the frame (including the ones already spent)
  * @param enc Entropy encoder
  */
-void quant_bands(const CELTMode *m, float *X, float *P, float *W, int total_bits, ec_enc *enc);
+void quant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float *W, int total_bits, ec_enc *enc);
 
 /** Decoding of the residual spectrum
  * @param m Mode data 
@@ -90,8 +90,8 @@
  * @param total_bits Total number of bits that can be used for the frame (including the ones already spent)
  * @param dec Entropy decoder
 */
-void unquant_bands(const CELTMode *m, float *X, float *P, int total_bits, ec_dec *dec);
+void unquant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, int total_bits, ec_dec *dec);
 
-void stereo_mix(const CELTMode *m, float *X, float *bank, int dir);
+void stereo_mix(const CELTMode *m, celt_norm_t *X, float *bank, int dir);
 
 #endif /* BANDS_H */
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -76,9 +76,9 @@
    struct PsyDecay psy;
    
    float *window;
-   float *in_mem;
-   float *mdct_overlap;
-   float *out_mem;
+   celt_sig_t *in_mem;
+   celt_sig_t *mdct_overlap;
+   celt_sig_t *out_mem;
 
    float *oldBandE;
 };
@@ -113,9 +113,9 @@
    psydecay_init(&st->psy, MAX_PERIOD*C/2, st->mode->Fs);
    
    st->window = celt_alloc(2*N*sizeof(float));
-   st->in_mem = celt_alloc(N*C*sizeof(float));
-   st->mdct_overlap = celt_alloc(N*C*sizeof(float));
-   st->out_mem = celt_alloc(MAX_PERIOD*C*sizeof(float));
+   st->in_mem = celt_alloc(N*C*sizeof(celt_sig_t));
+   st->mdct_overlap = celt_alloc(N*C*sizeof(celt_sig_t));
+   st->out_mem = celt_alloc(MAX_PERIOD*C*sizeof(celt_sig_t));
    for (i=0;i<2*N;i++)
       st->window[i] = 0;
    for (i=0;i<st->overlap;i++)
@@ -162,14 +162,14 @@
 }
 
 /** Apply window and compute the MDCT for all sub-frames and all channels in a frame */
-static float compute_mdcts(mdct_lookup *mdct_lookup, float *window, float *in, float *out, int N, int B, int C)
+static float compute_mdcts(mdct_lookup *mdct_lookup, float *window, celt_sig_t *in, celt_sig_t *out, int N, int B, int C)
 {
    int i, c;
    float E = 1e-15;
-   VARDECL(float *x);
-   VARDECL(float *tmp);
-   ALLOC(x, 2*N, float);
-   ALLOC(tmp, N, float);
+   VARDECL(celt_sig_t *x);
+   VARDECL(celt_sig_t *tmp);
+   ALLOC(x, 2*N, celt_sig_t);
+   ALLOC(tmp, N, celt_sig_t);
    for (c=0;c<C;c++)
    {
       for (i=0;i<B;i++)
@@ -190,13 +190,13 @@
 }
 
 /** Compute the IMDCT and apply window for all sub-frames and all channels in a frame */
-static void compute_inv_mdcts(mdct_lookup *mdct_lookup, float *window, float *X, float *out_mem, float *mdct_overlap, int N, int overlap, int B, int C)
+static void compute_inv_mdcts(mdct_lookup *mdct_lookup, float *window, celt_sig_t *X, celt_sig_t *out_mem, celt_sig_t *mdct_overlap, int N, int overlap, int B, int C)
 {
    int i, c, N4;
-   VARDECL(float *x);
-   VARDECL(float *tmp);
-   ALLOC(x, 2*N, float);
-   ALLOC(tmp, N, float);
+   VARDECL(celt_sig_t *x);
+   VARDECL(celt_sig_t *tmp);
+   ALLOC(x, 2*N, celt_sig_t);
+   ALLOC(tmp, N, celt_sig_t);
    N4 = (N-overlap)/2;
    for (c=0;c<C;c++)
    {
@@ -225,9 +225,10 @@
    int has_pitch;
    int pitch_index;
    float curr_power, pitch_power;
-   VARDECL(float *in);
-   VARDECL(float *X);
-   VARDECL(float *P);
+   VARDECL(celt_sig_t *in);
+   VARDECL(celt_sig_t *freq);
+   VARDECL(celt_norm_t *X);
+   VARDECL(celt_norm_t *P);
    VARDECL(float *mask);
    VARDECL(float *bandE);
    VARDECL(float *gains);
@@ -238,9 +239,10 @@
    N = st->block_size;
    B = st->nb_blocks;
    C = st->mode->nbChannels;
-   ALLOC(in, (B+1)*C*N, float);
-   ALLOC(X, B*C*N, float);         /**< Interleaved signal MDCTs */
-   ALLOC(P, B*C*N, float);         /**< Interleaved pitch MDCTs*/
+   ALLOC(in, (B+1)*C*N, celt_sig_t);
+   ALLOC(freq, B*C*N, celt_sig_t); /**< Interleaved signal MDCTs */
+   ALLOC(X, B*C*N, celt_norm_t);         /**< Interleaved normalised MDCTs */
+   ALLOC(P, B*C*N, celt_norm_t);         /**< Interleaved normalised pitch MDCTs*/
    ALLOC(mask, B*C*N, float);      /**< Masking curve */
    ALLOC(bandE,st->mode->nbEBands*C, float);
    ALLOC(gains,st->mode->nbPBands, float);
@@ -266,7 +268,7 @@
    }
    /*for (i=0;i<(B+1)*C*N;i++) printf ("%f(%d) ", in[i], i); printf ("\n");*/
    /* Compute MDCTs */
-   curr_power = compute_mdcts(&st->mdct_lookup, st->window, in, X, N, B, C);
+   curr_power = compute_mdcts(&st->mdct_lookup, st->window, in, freq, N, B, C);
 
 #if 0 /* Mask disabled until it can be made to do something useful */
    compute_mdct_masking(X, mask, B*C*N, st->Fs);
@@ -291,9 +293,6 @@
    }
    find_spectral_pitch(st->fft, &st->psy, in, st->out_mem, MAX_PERIOD, (B+1)*N, C, &pitch_index);
    
-   /* Compute MDCTs of the pitch part */
-   pitch_power = compute_mdcts(&st->mdct_lookup, st->window, st->out_mem+pitch_index*C, P, N, B, C);
-   
    /*printf ("%f %f\n", curr_power, pitch_power);*/
    /*int j;
    for (j=0;j<B*N;j++)
@@ -303,11 +302,15 @@
    printf ("\n");*/
 
    /* Band normalisation */
-   compute_band_energies(st->mode, X, bandE);
-   normalise_bands(st->mode, X, bandE);
+   compute_band_energies(st->mode, freq, bandE);
+   normalise_bands(st->mode, freq, X, bandE);
    /*for (i=0;i<st->mode->nbEBands;i++)printf("%f ", bandE[i]);printf("\n");*/
    /*for (i=0;i<N*B*C;i++)printf("%f ", X[i]);printf("\n");*/
 
+   /* Compute MDCTs of the pitch part */
+   pitch_power = compute_mdcts(&st->mdct_lookup, st->window, st->out_mem+pitch_index*C, freq, N, B, C);
+   
+
    quant_energy(st->mode, bandE, st->oldBandE, nbCompressedBytes*8/3, &st->enc);
 
    if (C==2)
@@ -321,8 +324,8 @@
       /* Normalise the pitch vector as well (discard the energies) */
       VARDECL(float *bandEp);
       ALLOC(bandEp, st->mode->nbEBands*st->mode->nbChannels, float);
-      compute_band_energies(st->mode, P, bandEp);
-      normalise_bands(st->mode, P, bandEp);
+      compute_band_energies(st->mode, freq, bandEp);
+      normalise_bands(st->mode, freq, P, bandEp);
 
       if (C==2)
          stereo_mix(st->mode, P, bandE, 1);
@@ -360,16 +363,17 @@
    quant_bands(st->mode, X, P, mask, nbCompressedBytes*8, &st->enc);
    
    if (C==2)
+   {
       stereo_mix(st->mode, X, bandE, -1);
-
-   renormalise_bands(st->mode, X);
+      renormalise_bands(st->mode, X);
+   }
    /* Synthesis */
-   denormalise_bands(st->mode, X, bandE);
+   denormalise_bands(st->mode, X, freq, bandE);
 
 
    CELT_MOVE(st->out_mem, st->out_mem+C*B*N, C*(MAX_PERIOD-B*N));
 
-   compute_inv_mdcts(&st->mdct_lookup, st->window, X, st->out_mem, st->mdct_overlap, N, st->overlap, B, C);
+   compute_inv_mdcts(&st->mdct_lookup, st->window, freq, st->out_mem, st->mdct_overlap, N, st->overlap, B, C);
    /* De-emphasis and put everything back at the right place in the synthesis history */
    for (c=0;c<C;c++)
    {
@@ -449,8 +453,8 @@
    mdct_lookup mdct_lookup;
    
    float *window;
-   float *mdct_overlap;
-   float *out_mem;
+   celt_sig_t *mdct_overlap;
+   celt_sig_t *out_mem;
 
    float *oldBandE;
    
@@ -481,8 +485,8 @@
    mdct_init(&st->mdct_lookup, 2*N);
    
    st->window = celt_alloc(2*N*sizeof(float));
-   st->mdct_overlap = celt_alloc(N*C*sizeof(float));
-   st->out_mem = celt_alloc(MAX_PERIOD*C*sizeof(float));
+   st->mdct_overlap = celt_alloc(N*C*sizeof(celt_sig_t));
+   st->out_mem = celt_alloc(MAX_PERIOD*C*sizeof(celt_sig_t));
 
    for (i=0;i<2*N;i++)
       st->window[i] = 0;
@@ -530,20 +534,20 @@
 {
    int i, c, N, B, C;
    int pitch_index;
-   VARDECL(float *X);
+   VARDECL(celt_sig_t *freq);
    N = st->block_size;
    B = st->nb_blocks;
    C = st->mode->nbChannels;
-   ALLOC(X,C*B*N, float);         /**< Interleaved signal MDCTs */
+   ALLOC(freq,C*B*N, celt_sig_t);         /**< Interleaved signal MDCTs */
    
    pitch_index = st->last_pitch_index;
    
    /* Use the pitch MDCT as the "guessed" signal */
-   compute_mdcts(&st->mdct_lookup, st->window, st->out_mem+pitch_index*C, X, N, B, C);
+   compute_mdcts(&st->mdct_lookup, st->window, st->out_mem+pitch_index*C, freq, N, B, C);
 
    CELT_MOVE(st->out_mem, st->out_mem+C*B*N, C*(MAX_PERIOD-B*N));
    /* Compute inverse MDCTs */
-   compute_inv_mdcts(&st->mdct_lookup, st->window, X, st->out_mem, st->mdct_overlap, N, st->overlap, B, C);
+   compute_inv_mdcts(&st->mdct_lookup, st->window, freq, st->out_mem, st->mdct_overlap, N, st->overlap, B, C);
 
    for (c=0;c<C;c++)
    {
@@ -569,8 +573,9 @@
    int pitch_index;
    ec_dec dec;
    ec_byte_buffer buf;
-   VARDECL(float *X);
-   VARDECL(float *P);
+   VARDECL(celt_sig_t *freq);
+   VARDECL(celt_norm_t *X);
+   VARDECL(celt_norm_t *P);
    VARDECL(float *bandE);
    VARDECL(float *gains);
 
@@ -581,8 +586,9 @@
    B = st->nb_blocks;
    C = st->mode->nbChannels;
    
-   ALLOC(X, C*B*N, float);         /**< Interleaved signal MDCTs */
-   ALLOC(P, C*B*N, float);         /**< Interleaved pitch MDCTs*/
+   ALLOC(freq, C*B*N, celt_sig_t); /**< Interleaved signal MDCTs */
+   ALLOC(X, C*B*N, celt_norm_t);         /**< Interleaved normalised MDCTs */
+   ALLOC(P, C*B*N, celt_norm_t);         /**< Interleaved normalised pitch MDCTs*/
    ALLOC(bandE, st->mode->nbEBands*C, float);
    ALLOC(gains, st->mode->nbPBands, float);
    
@@ -614,13 +620,13 @@
    }
    
    /* Pitch MDCT */
-   compute_mdcts(&st->mdct_lookup, st->window, st->out_mem+pitch_index*C, P, N, B, C);
+   compute_mdcts(&st->mdct_lookup, st->window, st->out_mem+pitch_index*C, freq, N, B, C);
 
    {
       VARDECL(float *bandEp);
       ALLOC(bandEp, st->mode->nbEBands*C, float);
-      compute_band_energies(st->mode, P, bandEp);
-      normalise_bands(st->mode, P, bandEp);
+      compute_band_energies(st->mode, freq, bandEp);
+      normalise_bands(st->mode, freq, P, bandEp);
    }
 
    if (C==2)
@@ -633,17 +639,17 @@
    unquant_bands(st->mode, X, P, len*8, &dec);
 
    if (C==2)
+   {
       stereo_mix(st->mode, X, bandE, -1);
-
-   renormalise_bands(st->mode, X);
-   
+      renormalise_bands(st->mode, X);
+   }
    /* Synthesis */
-   denormalise_bands(st->mode, X, bandE);
+   denormalise_bands(st->mode, X, freq, bandE);
 
 
    CELT_MOVE(st->out_mem, st->out_mem+C*B*N, C*(MAX_PERIOD-B*N));
    /* Compute inverse MDCTs */
-   compute_inv_mdcts(&st->mdct_lookup, st->window, X, st->out_mem, st->mdct_overlap, N, st->overlap, B, C);
+   compute_inv_mdcts(&st->mdct_lookup, st->window, freq, st->out_mem, st->mdct_overlap, N, st->overlap, B, C);
 
    for (c=0;c<C;c++)
    {
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -70,7 +70,7 @@
    float yp;
 };
 
-void alg_quant(float *x, float *W, int N, int K, float *p, float alpha, ec_enc *enc)
+void alg_quant(celt_norm_t *x, float *W, int N, int K, celt_norm_t *p, float alpha, ec_enc *enc)
 {
    int L = 3;
    VARDECL(float *_y);
@@ -306,7 +306,7 @@
 
 /** Decode pulse vector and combine the result with the pitch vector to produce
     the final normalised signal in the current band. */
-void alg_unquant(float *x, int N, int K, float *p, float alpha, ec_dec *dec)
+void alg_unquant(celt_norm_t *x, int N, int K, celt_norm_t *p, float alpha, ec_dec *dec)
 {
    int i;
    float Rpp=0, Ryp=0, Ryy=0;
@@ -347,7 +347,7 @@
 
 static const float pg[11] = {1.f, .75f, .65f, 0.6f, 0.6f, .6f, .55f, .55f, .5f, .5f, .5f};
 
-void intra_prediction(float *x, float *W, int N, int K, float *Y, float *P, int B, int N0, ec_enc *enc)
+void intra_prediction(celt_norm_t *x, float *W, int N, int K, celt_norm_t *Y, celt_norm_t *P, int B, int N0, ec_enc *enc)
 {
    int i,j;
    int best=0;
@@ -416,7 +416,7 @@
 
 }
 
-void intra_unquant(float *x, int N, int K, float *Y, float *P, int B, int N0, ec_dec *dec)
+void intra_unquant(celt_norm_t *x, int N, int K, celt_norm_t *Y, celt_norm_t *P, int B, int N0, ec_dec *dec)
 {
    int j;
    int sign;
@@ -457,7 +457,7 @@
    }
 }
 
-void intra_fold(float *x, int N, float *Y, float *P, int B, int N0, int Nmax)
+void intra_fold(celt_norm_t *x, int N, celt_norm_t *Y, celt_norm_t *P, int B, int N0, int Nmax)
 {
    int i, j;
    float E;
--- a/libcelt/vq.h
+++ b/libcelt/vq.h
@@ -51,7 +51,7 @@
  * @param alpha compression factor to apply in the pitch direction (magic!)
  * @param enc Entropy encoder state
 */
-void alg_quant(float *x, float *W, int N, int K, float *p, float alpha, ec_enc *enc);
+void alg_quant(celt_norm_t *x, float *W, int N, int K, celt_norm_t *p, float alpha, ec_enc *enc);
 
 /** Algebraic pulse decoder
  * @param x Decoded normalised spectrum (returned)
@@ -61,7 +61,7 @@
  * @param alpha compression factor in the pitch direction (magic!)
  * @param dec Entropy decoder state
  */
-void alg_unquant(float *x, int N, int K, float *p, float alpha, ec_dec *dec);
+void alg_unquant(celt_norm_t *x, int N, int K, celt_norm_t *p, float alpha, ec_dec *dec);
 
 /** Intra-frame predictor that matches a section of the current frame (at lower
  * frequencies) to encode the current band.
@@ -75,11 +75,11 @@
  * @param N0 Number of valid offsets
  * @param enc Entropy encoder state
  */
-void intra_prediction(float *x, float *W, int N, int K, float *Y, float *P, int B, int N0, ec_enc *enc);
+void intra_prediction(celt_norm_t *x, float *W, int N, int K, celt_norm_t *Y, celt_norm_t *P, int B, int N0, ec_enc *enc);
 
-void intra_unquant(float *x, int N, int K, float *Y, float *P, int B, int N0, ec_dec *dec);
+void intra_unquant(celt_norm_t *x, int N, int K, celt_norm_t *Y, celt_norm_t *P, int B, int N0, ec_dec *dec);
 
 /** Encode the entire band as a "fold" from other parts of the spectrum. No bits required (only use is case of an emergency!) */
-void intra_fold(float *x, int N, float *Y, float *P, int B, int N0, int Nmax);
+void intra_fold(celt_norm_t *x, int N, celt_norm_t *Y, celt_norm_t *P, int B, int N0, int Nmax);
 
 #endif /* VQ_H */