[Speex-dev] Bug in vbr_analysis

Alex Bakaev Alex.Bakaev at citrix.com
Tue Feb 14 13:44:38 PST 2006


This was reported by me (and most likely others). Here is
the exchange about this. The reason the problem is
visible in Delphi is that Borland (C++ and Delphi)
initialize the FPU differently from other RTLs.
Also, there is another problem that will be visible with
Delphi
---------------------------------------------------------
-------------
Yes, that's definitely a bug in the vbr code, there's an
easy fix for that. Just replace:
qual += .3*log(ener/60000.0);
with
qual += .3*log((ener+1)/60000.0);

	Jean-Marc

=========================================================
===
On Mon, 2005-12-12 at 18:06 -0800, Alex Bakaev wrote:
> Hello!
> 
> I'm getting SING errors from the log() function. Here
is the code 
> inside the vbr_analysis() function.
> 
>    if (ener<60000) 
>    { 
>       if (vbr->consec_noise>2) 
>          qual-=0.5*(log(3.0 +
vbr->consec_noise)-log(3)); 
>       if (ener<10000&&vbr->consec_noise>2) 
>          qual-=0.5*(log(3.0 +
vbr->consec_noise)-log(3)); 
>       if (qual<0) 
>          qual=0; 
>       qual += .3*log(ener/60000.0); 
>    }
> 
> Inspecting the values shows that 'ener' is zero, which
leads to the 
> error.
> 
> The question I have is if the code above should
explicitly be checking 
> for zero? Or I have an issue with my compiler screwing
something up?
> 
> The error doesn't occur constantly, but frequently
enough to be a huge 
> nuissance.
> 
> Thanks in advance,
> Alex
> 

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++
> It seems that using a different compiler (I assume the
development is 
> done with MSC) uncovers various issues with the
floating point.

No, all development is done on gcc/Linux.

> Here is the second one I'm seeing - DOMAIN error from
sqrt().
> 
> In the open_loop_nbest_pitch(), this line:
> 
>           g = DIV32(corr[i-start], 10
>
+SHR32(MULT16_16(spx_sqrt(e0),spx_sqrt(energy[i-start])),
6));

change that to:

g = DIV32(corr[i-start],
10+SHR32(MULT16_16(spx_sqrt(e0),spx_sqrt(1
+energy[i-start])),6));

(note the "1+" in the spx_sqrt)

As for this appearing only on some version/compiler
configurations, the only explanation is sheer luck (order
in which the float operations are done and when it goes
to registers).

	Jean-Marc


More information about the Speex-dev mailing list