[Speex-dev] Bug in vbr_analysis

Aymeric Moizard jack at atosc.org
Tue Feb 14 08:20:18 PST 2006

Hi Jean-Marc,

I used the following code after init of the encoder to
get the frame size of my RTP packets.

       char pcm_data[3200];
       char speex_data[3200];
       SpeexBits bits;
       memset(pcm_data, '\0', 3200);
       memset(speex_data, '\0', 3200);
       speex_encode_int(codec_info->enc, (short*)pcm_data, &bits);
       codec->enc_frame_size = speex_bits_write(&bits, speex_data, frame_size);

I never run into problems using either speex on linux or windows until one
used my dll and speex through delphi on windows: he gets division by zero.

I found that "ener" is 0 around line 253: (version 1.1.11)

    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 += .3*log(ener/60000.0);

I think this is a side effect of the fact that my pcm_data is
initialized to '\0'....

I have no fix except something like: (which is working!)

   if (ener!=0) qual += .3*log(ener/60000.0);

I still don't understand why this seems to happen only when
running inside a delphi program...

I hope to get a better fix!
Thanks for all.

http://sip.antisip.com   --  Free Telephony account.

More information about the Speex-dev mailing list