[xiph-commits] r11971 - trunk/speex/libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Mon Oct 30 05:12:20 PST 2006
Author: jm
Date: 2006-10-30 05:12:18 -0800 (Mon, 30 Oct 2006)
New Revision: 11971
Modified:
trunk/speex/libspeex/preprocess.c
Log:
Re-converted window to fixed-point
Modified: trunk/speex/libspeex/preprocess.c
===================================================================
--- trunk/speex/libspeex/preprocess.c 2006-10-30 13:00:04 UTC (rev 11970)
+++ trunk/speex/libspeex/preprocess.c 2006-10-30 13:12:18 UTC (rev 11971)
@@ -195,7 +195,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 */
float *noise; /**< Noise estimate */
spx_word32_t *reverb_estimate; /**< Estimate of reverb energy */
spx_word32_t *old_ps; /**< Power spectrum for last frame */
@@ -232,11 +232,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)
@@ -253,10 +254,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(.9999f,15)*sqrt(tmp);
}
}
@@ -345,7 +346,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));
@@ -372,7 +373,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(.9999f,15);
if (N4>0)
{
@@ -532,7 +533,7 @@
/* Windowing */
for (i=0;i<2*N;i++)
- st->frame[i] *= st->window[i];
+ st->frame[i] = MULT16_16_Q15(st->frame[i], st->window[i]);
#ifdef FIXED_POINT
{
@@ -840,7 +841,7 @@
}
for (i=0;i<2*N;i++)
- st->frame[i] *= st->window[i];
+ st->frame[i] = MULT16_16_Q15(st->frame[i], st->window[i]);
/* Perform overlap and add */
for (i=0;i<N3;i++)
@@ -895,7 +896,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