[xiph-commits] r14886 - trunk/speex/libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Thu May 15 02:50:56 PDT 2008
Author: jm
Date: 2008-05-15 02:50:56 -0700 (Thu, 15 May 2008)
New Revision: 14886
Modified:
trunk/speex/libspeex/mdf.c
Log:
better saturation handling in the echo canceller (prevent overflows and
removed unnecessary muting)
Modified: trunk/speex/libspeex/mdf.c
===================================================================
--- trunk/speex/libspeex/mdf.c 2008-05-15 04:59:27 UTC (rev 14885)
+++ trunk/speex/libspeex/mdf.c 2008-05-15 09:50:56 UTC (rev 14886)
@@ -88,6 +88,12 @@
#define WEIGHT_SHIFT 0
#endif
+#ifdef FIXED_POINT
+#define WORD2INT(x) ((x) < -32767 ? -32768 : ((x) > 32766 ? 32767 : (x)))
+#else
+#define WORD2INT(x) ((x) < -32767.5f ? -32768 : ((x) > 32766.5f ? 32767 : floor(.5+(x))))
+#endif
+
/* If enabled, the AEC will use a foreground filter and a background filter to be more robust to double-talk
and difficult signals in general. The cost is an extra FFT and a matrix-vector multiply */
#define TWO_PATH
@@ -877,11 +883,6 @@
#else
tmp_out = SUB32(EXTEND32(st->input[i]), EXTEND32(st->y[i+st->frame_size]));
#endif
- /* Saturation */
- if (tmp_out>32767)
- tmp_out = 32767;
- else if (tmp_out<-32768)
- tmp_out = -32768;
tmp_out = ADD32(tmp_out, EXTEND32(MULT16_16_P15(st->preemph, st->memE)));
/* This is an arbitrary test for saturation in the microphone signal */
if (in[i] <= -32000 || in[i] >= 32000)
@@ -890,7 +891,7 @@
if (st->saturated == 0)
st->saturated = 1;
}
- out[i] = (spx_int16_t)tmp_out;
+ out[i] = WORD2INT(tmp_out);
st->memE = tmp_out;
}
More information about the commits
mailing list