[xiph-commits] r11962 - trunk/speex/libspeex

jm at svn.xiph.org jm at svn.xiph.org
Fri Oct 27 06:40:23 PDT 2006


Author: jm
Date: 2006-10-27 06:40:21 -0700 (Fri, 27 Oct 2006)
New Revision: 11962

Modified:
   trunk/speex/libspeex/preprocess.c
Log:
window is now spx_word16_t


Modified: trunk/speex/libspeex/preprocess.c
===================================================================
--- trunk/speex/libspeex/preprocess.c	2006-10-27 13:24:47 UTC (rev 11961)
+++ trunk/speex/libspeex/preprocess.c	2006-10-27 13:40:21 UTC (rev 11962)
@@ -117,7 +117,7 @@
    spx_word32_t *ps;         /**< Current power spectrum */
    float *gain2;             /**< Adjusted gains */
    float *gain_floor;        /**< Minimum gain allowed */
-   float *window;            /**< Analysis/Synthesis window */
+   spx_word16_t *window;     /**< Analysis/Synthesis window */
    spx_word32_t *noise;      /**< Noise estimate */
    spx_word32_t *reverb_estimate; /**< Estimate of reverb energy */
    spx_word32_t *old_ps;     /**< Power spectrum for last frame */
@@ -152,11 +152,12 @@
 };
 
 
-static void conj_window(float *w, int len)
+static void conj_window(spx_word16_t *w, int len)
 {
    int i;
    for (i=0;i<len;i++)
    {
+      float tmp;
       float x=4*((float)i)/len;
       int inv=0;
       if (x<1)
@@ -173,10 +174,10 @@
          x=4-x;
       }
       x*=1.9979;
-      w[i]=(.5-.5*cos(x))*(.5-.5*cos(x));
+      tmp=(.5-.5*cos(x))*(.5-.5*cos(x));
       if (inv)
-         w[i]=1-w[i];
-      w[i]=sqrt(w[i]);
+         tmp=1-tmp;
+      w[i]=QCONST16(.999,15)*sqrt(tmp);
    }
 }
 
@@ -265,7 +266,7 @@
    st->bank = filterbank_new(M, sampling_rate, N, 1);
    
    st->frame = (spx_word16_t*)speex_alloc(2*N*sizeof(float));
-   st->window = (float*)speex_alloc(2*N*sizeof(float));
+   st->window = (spx_word16_t*)speex_alloc(2*N*sizeof(float));
    st->ft = (spx_word16_t*)speex_alloc(2*N*sizeof(float));
    
    st->ps = (spx_word32_t*)speex_alloc((N+M)*sizeof(float));
@@ -292,7 +293,7 @@
 
    conj_window(st->window, 2*N3);
    for (i=2*N3;i<2*st->ps_size;i++)
-      st->window[i]=1;
+      st->window[i]=QCONST16(.999,15);
    
    if (N4>0)
    {
@@ -452,7 +453,7 @@
 
    /* Windowing */
    for (i=0;i<2*N;i++)
-      st->frame[i] *= st->window[i];
+      st->frame[i] = MULT16_16_Q15(st->window[i], st->frame[i]);
 
    /* Perform FFT */
    spx_fft(st->fft_lookup, st->frame, st->ft);
@@ -745,7 +746,7 @@
    }
 
    for (i=0;i<2*N;i++)
-      st->frame[i] *= st->window[i];
+      st->frame[i] = MULT16_16_Q15(st->window[i], st->frame[i]);
 
    /* Perform overlap and add */
    for (i=0;i<N3;i++)
@@ -800,7 +801,7 @@
    }
 
    for (i=0;i<N3;i++)
-      st->outbuf[i] = x[st->frame_size-N3+i]*st->window[st->frame_size+i];
+      st->outbuf[i] = MULT16_16_Q15(x[st->frame_size-N3+i],st->window[st->frame_size+i]);
 
    /* Save old power spectrum */
    for (i=0;i<N+M;i++)



More information about the commits mailing list