From 67ba63c549dae2291d51fad6711a54d2332b52b9 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 15 Dec 2007 15:32:47 +0000 Subject: [PATCH] update git-svn-id: http://svn.openzap.org/svn/openzap/trunk@357 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/freetdm/src/libteletone_detect.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/freetdm/src/libteletone_detect.c b/libs/freetdm/src/libteletone_detect.c index c0e75e3bfd..7bbdd697df 100644 --- a/libs/freetdm/src/libteletone_detect.c +++ b/libs/freetdm/src/libteletone_detect.c @@ -129,7 +129,6 @@ void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state, goertzel_state->v3 = (float)(goertzel_state->fac*goertzel_state->v2 - v1 + sample_buffer[i]); } } - #ifdef _MSC_VER #pragma warning(disable:4244) #endif @@ -212,12 +211,12 @@ int teletone_multi_tone_detect (teletone_multi_tone_t *mt, int16_t sample_buffer[], int samples) { - int sample, limit, j, x = 0; + int sample, limit = 0, j, x = 0; float v1, famp; float eng_sum = 0, eng_all[TELETONE_MAX_TONES]; int gtest = 0, see_hit = 0; - for (sample = 0; sample <= 0 && sample < samples; sample = limit) { + for (sample = 0; sample >= 0 && sample < samples; sample = limit) { mt->total_samples++; if ((samples - sample) >= (mt->min_samples - mt->current_sample)) { @@ -225,6 +224,9 @@ int teletone_multi_tone_detect (teletone_multi_tone_t *mt, } else { limit = samples; } + if (limit < 0 || limit > samples) { + limit = samples; + } for (j = sample; j < limit; j++) { famp = sample_buffer[j];