[Speex-dev] Fixed-point version

Ângelo Andrade Cirino aacirino at correios.net.br
Thu Jun 1 11:25:29 PDT 2006


Hello list

I'm joining the effort to port speex to a fixed-point version, but as  
I'm a physicist used to deal only with floating point numbers (lots  
of them), I have no practice in working with fixed-point versions of  
such numbers.

For instance, in the first source I'm trying to work with, nb_celp.c,  
it is hard to see that the following two lines of code yield the same  
result:

#ifdef FIXED_POINT
       fact = SHR16(19661,SHR32(lsp_dist,LSP_SHIFT+2));
#else
       fact = .6*exp(-.2*lsp_dist);
#endif

Now, some questions.

1) When dealing with float constants, like .00001 or 0.05, to express  
them in fixed-point should I just scale them with the appropriate  
constants from arch.h?

2) If so, which scaling should I use? Taking a very specific example,  
how should I change to fixed-point the expression below?

qual_change = -.00001*st->abr_drift/(1+st->abr_count);

For example, when calculating LSPs I think I should use LSP_SCALING.  
But in the case above, which scaling must I use? The float constant  
is -1e-5, a very small value to be represented in fixed-point using a  
16 bit value, effectively yielding a zero if I just multiply it by  
the appropriate scale factor.

3) In arch.h, shouldn't LPC_SCALING, SIG_SCALING and GAIN_SCALING be  
declared floats like LSP_SCALING and GAMMA_SCALING? Or will the  
compiler handle the conversion accordingly?

Hope this questions aren't silly, or I will be very ashamed ;-) Or  
should I read Knuth's books?

Cheers to all

Angelo


More information about the Speex-dev mailing list