summaryrefslogtreecommitdiff
path: root/mg2ec.h
diff options
context:
space:
mode:
authormattf <mattf@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-05-08 11:17:43 +0000
committermattf <mattf@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-05-08 11:17:43 +0000
commit0174c3bcca1cd5c465ff5d25e2d74dfc1a9c5011 (patch)
tree74188fb76c1809d43daeee6c3dfb14753572c14f /mg2ec.h
parentd89a13a276d0bc8faaba42aabc8e53e8de071b87 (diff)
Improve CPU performance of MG2 by using a counter instead of a history
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1025 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'mg2ec.h')
-rw-r--r--mg2ec.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/mg2ec.h b/mg2ec.h
index fca3c21..a1d691e 100644
--- a/mg2ec.h
+++ b/mg2ec.h
@@ -158,8 +158,8 @@ struct echo_can_state {
int avg_Lu_i_toolow;
int avg_Lu_i_ok;
#endif
- short lastsig[256];
- int lastpos;
+ short lastsig;
+ int lastcount;
int backup;
#ifdef DC_NORMALIZE
int dc_estimate;
@@ -327,18 +327,18 @@ static inline short echo_can_update(struct echo_can_state *ec, short iref, short
ec->N_d);
rs >>= 15;
- ec->lastsig[ec->lastpos++] = isig;
- if (ec->lastpos >= 256)
- ec->lastpos = 0;
-
- for (k=0; k < 256; k++) {
- if (isig != ec->lastsig[k])
- break;
+ if (ec->lastsig == isig) {
+ ec->lastcount++;
+ } else {
+ ec->lastcount = 0;
+ ec->lastsig = isig;
}
if (isig == 0) {
u = 0;
- } else if (k == 256) {
+ } else if (ec->lastcount > 255) {
+ /* We have seen the same input-signal more than 255 times,
+ * we should pass it through uncancelled, as we are likely on hold */
u = isig;
} else {
if (rs < -32768) {