[xiph-cvs] cvs commit: speex/libspeex preprocess.c
Jean-Marc Valin
jm at xiph.org
Tue Sep 16 13:39:58 PDT 2003
jm 03/09/16 16:39:56
Modified: libspeex preprocess.c
Log:
added MCRA noise estimation, fixed stupid bug in a priori SNR adaptation
Revision Changes Path
1.4 +47 -1 speex/libspeex/preprocess.c
Index: preprocess.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/preprocess.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- preprocess.c 16 Sep 2003 19:36:17 -0000 1.3
+++ preprocess.c 16 Sep 2003 20:39:56 -0000 1.4
@@ -136,6 +136,11 @@
st->outbuf = (float*)speex_alloc(N3*sizeof(float));
st->echo_noise = (float*)speex_alloc(N*sizeof(float));
+ st->S = (float*)speex_alloc(N*sizeof(float));
+ st->Smin = (float*)speex_alloc(N*sizeof(float));
+ st->Stmp = (float*)speex_alloc(N*sizeof(float));
+ st->update_prob = (float*)speex_alloc(N*sizeof(float));
+
st->noise_bands = (float*)speex_alloc(NB_BANDS*sizeof(float));
st->noise_bands2 = (float*)speex_alloc(NB_BANDS*sizeof(float));
st->speech_bands = (float*)speex_alloc(NB_BANDS*sizeof(float));
@@ -213,6 +218,11 @@
speex_free(st->loudness_weight);
speex_free(st->echo_noise);
+ speex_free(st->S);
+ speex_free(st->Smin);
+ speex_free(st->Stmp);
+ speex_free(st->update_prob);
+
speex_free(st->noise_bands);
speex_free(st->noise_bands2);
speex_free(st->speech_bands);
@@ -528,6 +538,38 @@
for (i=1;i<N;i++)
ps[i]=1+st->frame[2*i-1]*st->frame[2*i-1] + st->frame[2*i]*st->frame[2*i];
+ for (i=1;i<N-1;i++)
+ st->S[i] = 100+ .8*st->S[i] + .05*ps[i-1]+.1*ps[i]+.05*ps[i+1];
+
+ if (st->nb_preprocess<1)
+ {
+ for (i=1;i<N-1;i++)
+ st->Smin[i] = st->Stmp[i] = st->S[i]+100;
+ }
+
+ if (st->nb_preprocess%80==0)
+ {
+ for (i=1;i<N-1;i++)
+ {
+ st->Smin[i] = min(st->Stmp[i], st->S[i]);
+ st->Stmp[i] = st->S[i];
+ }
+ } else {
+ for (i=1;i<N-1;i++)
+ {
+ st->Smin[i] = min(st->Smin[i], st->S[i]);
+ st->Stmp[i] = min(st->Stmp[i], st->S[i]);
+ }
+ }
+ for (i=1;i<N-1;i++)
+ {
+ st->update_prob[i] *= .2;
+ if (st->S[i] > 5*st->Smin[i])
+ st->update_prob[i] += .8;
+ /*fprintf (stderr, "%f ", st->S[i]/st->Smin[i]);*/
+ /*fprintf (stderr, "%f ", st->update_prob[i]);*/
+ }
+ /*fprintf (stderr, "\n");*/
energy=0;
for (i=1;i<N;i++)
energy += log(100+ps[i]);
@@ -607,7 +649,6 @@
if (min_gamma<.01)
min_gamma = .01;
#endif
- min_gamma = .6;
if (gamma<min_gamma)
gamma=min_gamma;
@@ -670,6 +711,11 @@
st->last_update=0;
} else {
st->last_update++;
+ for (i=1;i<N-1;i++)
+ {
+ if (st->update_prob[i]<.5)
+ st->noise[i] = .90*st->noise[i] + .1*st->ps[i];
+ }
}
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list