| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Speex
Revision: 14886
Author: jm
Date: 15 May 2008 05:50:56
Changes:better saturation handling in the echo canceller (prevent overflows and
removed unnecessary muting)
| ... | ...@@ -88,6 +88,12 @@ | |
| 88 | 88 | #define WEIGHT_SHIFT 0 |
| 89 | 89 | #endif |
| 90 | 90 | |
| 91 | #ifdef FIXED_POINT | |
| 92 | #define WORD2INT(x) ((x) < -32767 ? -32768 : ((x) > 32766 ? 32767 : (x))) | |
| 93 | #else | |
| 94 | #define WORD2INT(x) ((x) < -32767.5f ? -32768 : ((x) > 32766.5f ? 32767 : floor(.5+(x)))) | |
| 95 | #endif | |
| 96 | ||
| 91 | 97 | /* If enabled, the AEC will use a foreground filter and a background filter to be more robust to double-talk |
| 92 | 98 | and difficult signals in general. The cost is an extra FFT and a matrix-vector multiply */ |
| 93 | 99 | #define TWO_PATH |
| ... | ...@@ -877,11 +883,6 @@ | |
| 877 | 883 | #else |
| 878 | 884 | tmp_out = SUB32(EXTEND32(st->input[i]), EXTEND32(st->y[i+st->frame_size])); |
| 879 | 885 | #endif |
| 880 | /* Saturation */ | |
| 881 | if (tmp_out>32767) | |
| 882 | tmp_out = 32767; | |
| 883 | else if (tmp_out<-32768) | |
| 884 | tmp_out = -32768; | |
| 885 | 886 | tmp_out = ADD32(tmp_out, EXTEND32(MULT16_16_P15(st->preemph, st->memE))); |
| 886 | 887 | /* This is an arbitrary test for saturation in the microphone signal */ |
| 887 | 888 | if (in[i] <= -32000 || in[i] >= 32000) |
| ... | ...@@ -890,7 +891,7 @@ | |
| 890 | 891 | if (st->saturated == 0) |
| 891 | 892 | st->saturated = 1; |
| 892 | 893 | } |
| 893 | out[i] = (spx_int16_t)tmp_out; | |
| 894 | out[i] = WORD2INT(tmp_out); | |
| 894 | 895 | st->memE = tmp_out; |
| 895 | 896 | } |
| 896 | 897 |