Review Board 1.7.16


dsp.c optimize goerztzel sample loops, in dtmf_detect, mf_detect and tone_detect

Review Request #2093 - Created Sept. 1, 2012 and submitted

Alec Davis
1.8 to trunk
Reviewers
asterisk-dev
Asterisk
the dmtf_detector had to recalc the address from the amp[] for each of 8 calls to goerztzel_sample()
Now use similar optimization as was already done in tone_detect().

If we're counting just lines of code executed, originally for each of the 160 samples was 80, now 53. 

created code looked like this;
this code is repeated 8 times in dtmf_detect, at 8000 times a second.
677:dsp.c         ****                         goertzel_sample(s->td.dtmf.row_out, amp[j]);
 14299                  .loc 1 677 0
 14300 0d21 8B45E0      movl -32(%ebp),%eax
 14301 0d24 01C0        addl %eax,%eax
 14302 0d26 034510      addl 16(%ebp),%eax
 14303 0d29 0FB700      movzwl (%eax),%eax
 14304 0d2c 98          cwtl
 14305 0d2d 8B550C      movl 12(%ebp),%edx
 14306 0d30 81C29402    addl $660,%edx
 14306      0000

 14307 0d36 89442404    movl %eax,4(%esp)
 14308 0d3a 891424      movl %edx,(%esp)
 14309 0d3d E8EEF2FF    call goertzel_sample

=============================================================
Now this code is add once
 675:dsp.c         ****                         samp = amp[j];
 14281                  .loc 1 675 0
 14282 0cf1 8B45DC      movl -36(%ebp),%eax
 14283 0cf4 01C0        addl %eax,%eax
 14284 0cf6 034510      addl 16(%ebp),%eax
 14285 0cf9 0FB700      movzwl (%eax),%eax
 14286 0cfc 668945E6    movw %ax,-26(%ebp)
Now this code is repeated 8 times. 
 679:dsp.c         ****                         goertzel_sample(s->td.dtmf.row_out, samp);
 14298                  .loc 1 679 0
 14299 0d25 0FBF45E6    movswl -26(%ebp),%eax
 14300 0d29 8B550C      movl 12(%ebp),%edx
 14301 0d2c 81C29402    addl $660,%edx
 14301      0000
 14302 0d32 89442404    movl %eax,4(%esp)
 14303 0d36 891424      movl %edx,(%esp)
 14304 0d39 E8F2F2FF    call goertzel_sample
Yes, DTMF anyway, still able for recognise digits dialled. 

Verified with spandsp 0.0.6 if SPANDSP_USE_FIXED_POINT is chosen
Ship it!
Posted (Sept. 4, 2012, 9:46 a.m.)
These changes are straight forward.
trunk/main/dsp.c (Diff revision 1)
 
 
Might as well fix the typo: suqare

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.