On Wed, Mar 6, 2013 at 2:40 PM, David Rowe <da...@rowetel.com> wrote:
> My idea system would work like this.  You have some floating point code
> that you annotate, then pass it through a float-fixed compiler/parser.
> The code might look like:

This is how the Opus and Speex stuff works, but the "compiler/parser"
is the C macro preparser.

So you end up with code like:

   for (i=0;i<overlap;i++)
   {
      opus_val16 f;
      x0=x[i-T1+2];
      f = MULT16_16_Q15(window[i],window[i]);
      y[i] = x[i]
               + MULT16_32_Q15(MULT16_16_Q15((Q15ONE-f),g00),x[i-T0])
               +
MULT16_32_Q15(MULT16_16_Q15((Q15ONE-f),g01),ADD32(x[i-T0+1],x[i-T0-1]))

and the macros turn into NOPs (for scaling macros) or just basic
operators for add/mul etc.

Once you are used to reading and writing code like this it isn't a big
deal, but it's somewhat offensive to third parties trying to figure
out what the heck is going on.  On the plus side, one codebase does
both with minimal IFDEFs... and it all compiles with a plain C89
toolchain, including on weird DSPs.

The macros also give you places to hook in things like overflow
detection. (e.g. instead of ((a)*(b)) the macro becomes
mul_and_check_overflow((a),(b))).

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Freetel-codec2 mailing list
Freetel-codec2@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freetel-codec2

Reply via email to