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 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. I'm probably just overlooking something in the documentation. Any suggestions of where to look are welcome. Cheers Darren
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 frame2 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
Jean-Marc Valin wrote:> > > 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); > }I think I still didn't fully understand. As a test I encoded some frames (wideband, with quality set to 8), each were 70 bytes. I then did three things: - passed half of it to the decoder - passed exactly one frame to the decoder - I passed two concatenated frames to the decoder. In all cases speex_decode_int returned 0. Unless I misunderstood what you say above, I think it should have returned 0 only for the third test, -1 for the second test and perhaps -2 for the first test? Cheers Darren