diff options
author | Shaun Ruffell <sruffell@digium.com> | 2009-04-29 18:24:04 +0000 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2009-04-29 18:24:04 +0000 |
commit | 5f94a3b91de2c3835d6852d59cab9f6876177156 (patch) | |
tree | 4c25956b6ecdcd5b902ac80b40237bc3e938be44 /drivers/dahdi/ecdis.h | |
parent | 4a192a3e8f16ed6143377b5726e1fb53b446f5e9 (diff) |
echocan: Improve interface for echo cancelers.
Echo cancelers are now able to report if they are able to automatically disable
their NLP portions in the presence of tones in the audio stream. Also, the
interface is changed to allow user space to just disable the NLP portion of the
echo canceler. These changes improve fax and modem handling in DAHDI.
This commit merges in the changes on
http://svn.digium.com/svn/dahdi/linux/team/kpfleming/echocan_work
Patch by: kpfleming
Also contains improvements to CED tone detection.
(closes issue #13286)
Reported by: viniciusfontes
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@6529 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/ecdis.h')
-rw-r--r-- | drivers/dahdi/ecdis.h | 66 |
1 files changed, 32 insertions, 34 deletions
diff --git a/drivers/dahdi/ecdis.h b/drivers/dahdi/ecdis.h index 205b2e3..e8083fe 100644 --- a/drivers/dahdi/ecdis.h +++ b/drivers/dahdi/ecdis.h @@ -53,10 +53,10 @@ static inline void echo_can_disable_detector_init (echo_can_disable_detector_sta /*- End of function --------------------------------------------------------*/ static inline int echo_can_disable_detector_update (echo_can_disable_detector_state_t *det, - int16_t amp) + int16_t amp) { - int16_t notched; - + int16_t notched; + notched = biquad2 (&det->notch, amp); /* Estimate the overall energy in the channel, and the energy in the notch (i.e. overall channel energy - tone energy => noise). @@ -66,40 +66,38 @@ static inline int echo_can_disable_detector_update (echo_can_disable_detector_st blip every time the phase reverses */ det->channel_level += ((abs(amp) - det->channel_level) >> 5); det->notch_level += ((abs(notched) - det->notch_level) >> 4); - if (det->channel_level > 280) - { - /* There is adequate energy in the channel. Is it mostly at 2100Hz? */ - if (det->notch_level*6 < det->channel_level) - { - /* The notch says yes, so we have the tone. */ - if (!det->tone_present) - { - /* Do we get a kick every 450+-25ms? */ - if (det->tone_cycle_duration >= 425*8 - && - det->tone_cycle_duration <= 475*8) - { - det->good_cycles++; - if (det->good_cycles > 2) - det->hit = TRUE; - } - det->tone_cycle_duration = 0; + if (det->channel_level >= 70) { + /* There is adequate energy in the channel. Is it mostly at 2100Hz? */ + if (det->notch_level*6 < det->channel_level) { + det->tone_cycle_duration++; + /* The notch says yes, so we have the tone. */ + if (!det->tone_present) { + /* Do we get a kick every 450+-25ms? */ + if ((det->tone_cycle_duration >= (425 * 8)) && + (det->tone_cycle_duration <= (475 * 8))) { + /* It's ANS/PR (CED with polarity reversals), so wait + for at least three cycles before returning a hit. */ + det->good_cycles++; + if (det->good_cycles > 2) + det->hit = TRUE; + } + det->tone_cycle_duration = 0; + det->tone_present = TRUE; + } else if (det->tone_cycle_duration >= 600 * 8) { + /* It's ANS (CED without polarity reversals) + so return a hit. */ + det->hit = TRUE; + } + } else { + det->tone_present = FALSE; } - det->tone_present = TRUE; - } - else - { + } else { det->tone_present = FALSE; - } - det->tone_cycle_duration++; - } - else - { - det->tone_present = FALSE; - det->tone_cycle_duration = 0; - det->good_cycles = 0; + det->tone_cycle_duration = 0; + det->good_cycles = 0; } - return det->hit; + + return det->hit; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ |