Decode Lost Packets Bug

Aug 11, 2011 at 7:05 PM
Edited Aug 11, 2011 at 8:28 PM

I think I may have found an error in the decoder. In the event that encoded frames are lost and null is passed to the decoder, packet loss concealment should kick in.

It looks like the decoder is generating data,  but the result (decodedData) is never copied to the output buffer (outData).

The results of the decode are lost and the caller of Decode doesn't have valid data to read.

 

 

 

//SpeexDecoder.cs
public int Decode(byte[] inData, int inOffset, int inCount, short[] outData, int outOffset, bool lostFrame)
{
   if(lostFrame || inData==null)
   {
      decoder.Decode(null, decodedData);
      return frameSize;
   }
   // ...
}


Aug 11, 2011 at 8:28 PM

Correction, outData is a short[] so the floats in decodedData will need to be converted.

for(int i=0; i<frameSize; i++)
{
   outData[i] = (decodedData[i] > 0) ?
        (short)(decodedData[i] + 0.5d) :
        (short)(decodedData[i] - 0.5d);
}

Coordinator
Aug 12, 2011 at 7:03 PM

Thanks zmb99,

Will look into it!

Christoph

Am 11.08.2011 21:28 schrieb "zmb99" <notifications@codeplex.com>:
> From: zmb99
>
> Correction, outData is a short[] so the floats in decodedData will need to be converted.for(int i=0; i<frameSize; i++){ outData[i] = (decodedData[i] > 0) ? (short)(decodedData[i] + 0.5d) : (short)(decodedData[i] - 0.5d);}
>
>