dsp.c: Fix erroneous fax tone detection.

The Goertzel calculations get less accurate the lower the signal level
being worked with becomes because there is less resolution remaining.
If it is too low we can erroneously detect a tone where none really
exists.  The searched for fax frequencies not only need to be so much
stronger than the background noise they must also be a minimum strength.

* Add needed minimum threshold test to tone_detect().

* Set TONE_THRESHOLD to allow low volume frequency spread detection.

ASTERISK-26237 #close
Reported by: Richard Mudgett

Change-Id: I84dbba7f7628fa13720add6a88eae3b129e066fc
This commit is contained in:
Richard Mudgett 2016-07-21 22:28:25 -05:00
parent e2bfcb3e58
commit 49461f37b7
1 changed files with 3 additions and 5 deletions

View File

@ -171,8 +171,7 @@ enum gsamp_thresh {
*/
#define DTMF_THRESHOLD 8.0e7
#define FAX_THRESHOLD 8.0e7
#define FAX_2ND_HARMONIC 2.0 /* 4dB */
#define TONE_THRESHOLD 7.8e7
#define DEF_DTMF_NORMAL_TWIST 6.31 /* 8.0dB */
#define DEF_RELAX_DTMF_NORMAL_TWIST 6.31 /* 8.0dB */
@ -187,8 +186,6 @@ enum gsamp_thresh {
#define DTMF_RELATIVE_PEAK_ROW 6.3 /* 8dB */
#define DTMF_RELATIVE_PEAK_COL 6.3 /* 8dB */
#define DTMF_2ND_HARMONIC_ROW (relax ? 1.7 : 2.5) /* 4dB normal */
#define DTMF_2ND_HARMONIC_COL 63.1 /* 18dB */
#define DTMF_TO_TOTAL_ENERGY 42.0
#define BELL_MF_THRESHOLD 1.6e9
@ -583,7 +580,8 @@ static int tone_detect(struct ast_dsp *dsp, tone_detect_state_t *s, int16_t *amp
ast_debug(10, "tone %d, Ew=%.2E, Et=%.2E, s/n=%10.2f\n", s->freq, tone_energy, s->energy, tone_energy / (s->energy - tone_energy));
hit = 0;
if (tone_energy > s->energy * s->threshold) {
if (TONE_THRESHOLD <= tone_energy
&& tone_energy > s->energy * s->threshold) {
ast_debug(10, "Hit! count=%d\n", s->hit_count);
hit = 1;
}