[Speex-dev] Decoding multiple encoded frames

Jean-Marc Valin jean-marc.valin at usherbrooke.ca
Tue Oct 7 16:02:53 PDT 2008



Darren Longhorn a écrit :
> Hi,
> 
> I've been looking at using speex over RTP. Section 3.3 of
> draft-ietf-avt-rtp-speex-05 states that:
> 
> "For the purposes of packetizing the bit stream in RTP, it is only
> necessary to consider the sequence of bits as output by the Speex
> encoder [speex_manual], and present the same sequence to the decoder."
> 
> So, I assume that I just pass the whole contents of the RTP packet (less
> the RTP header) to the decoder, regardless of whether it contains
> multiple frames of encoded data. I can then see two alternatives:
> 
> 	1. the decoder decodes all of the data in one go
> 	2. the decoder must it be called repetitively for each frame

2 is the correct answer.

> If 1, then I can't see how to calculate how much space to allocate for
> the output buffer, since I don't know the number of frames contained
> within the encoded data.
> 
> If 2, then I can't see how it can be determined how many bytes the
> decoder has consumed, and hence how many remain in the input buffer.

The decoder will return -1 if it can't decode anything else, so you just
do something like:

while(1) {
   err = speex_decode_int(state, bits, pcm);
   if (err==-1)
      break;
   output_data(pcm);
}


Cheers,

	Jean-Marc


More information about the Speex-dev mailing list