[Speex-dev] SpeexBits ...

Marian Kechlibar marian.kechlibar at circletech.net
Wed Nov 25 11:48:28 PST 2009

Hi Mark,

I understand that this is the simplest way, but I cannot use it
straightforwardly ...

I have a code which receives audio frames from a (Symbian OS) mobile
microphone input, and decides how to pack them into RTP packets
depending on whether they are normal frames, silence information
(comfort noise) frames or silence frames. It may decide to push 3 frames
into a RTP packet, or two, or send some frames in separate packets etc.
The logic is rather complicated and designed for optimal use over
low-bandwidth connection like GPRS. The trouble is that the code looks
at the frame first, detects whether it is a regular, silence or silence
info frame, and only then decides how to build a RTP packet, if any
(previous frames, saved from previous iterations, play role in this
logic too).

This works well for the built-in (by Nokia) codecs like AMR or G.729,
which give you the encoded frame immediately, but I cannot extend it
straightforwardly to Speex; in this case, I have to record the 320-byte
PCM block and I need to compress it with speex_encode myself; only then
I know whether the result is be a normal frame, or a silence frame (if
VAD is active), or a comfort noise frame. So I need to run speex_encode
separately on each 20 ms block, then decide what to do depending on the
result of the encode operation. But I also need to pack some Speex
frames together, if the code decides to put 2 or more frames into a
single RTP packet... now you see why I need to have them separate at
first, and why I need to have the ability to combine them into a RTP
packet later.

I believe that some of the packing utilities in speex_bits can help me,
but I am not sure how to use them..

Best regards

Marian Kechlibar

Mark Schilling wrote:
> Hi Marian,
> I took a brief look at RFC 5574 and as far as I understand, you can simply do it like this:
> SpeexBits b;
> speex_encode(state, some320bytePCM1, &b);
> speex_encode(state, some320bytePCM2, &b);
> After that, get the encoded data with speex_bits_write and put it in your packet.
> Mark
> -----Original Message-----
> From: speex-dev-bounces at xiph.org [mailto:speex-dev-bounces at xiph.org] On Behalf Of Marian Kechlibar
> Subject: Re: [Speex-dev] SpeexBits ...
> Hello, is here anyone who could help me with that?
> Best regards
> Marian Kechlibar
> Marian Kechlibar napsal(a):
>> One more question:
>> Let us imagine the following code with a mono Speex NB encoder:
>> SpeexBits b1;
>> SpeexBits b2;
>> ... initialization...
>> speex_encode(state, some320bytePCM1, &b1);
>> speex_encode(state, some320bytePCM2, &b2);
>> Now, I have a single frame in the structure b1 and a single frame in the
>> structure b2. How do I "append" the frame from b1 to b2 using speex_bits
>> (while keeping the RFC 5574 format for Speex frames?) Do I have to
>> export b2 first?
>> Best regards
>> Marian Kechlibar
>> _______________________________________________
>> Speex-dev mailing list
>> Speex-dev at xiph.org
>> http://lists.xiph.org/mailman/listinfo/speex-dev
> _______________________________________________
> Speex-dev mailing list
> Speex-dev at xiph.org
> http://lists.xiph.org/mailman/listinfo/speex-dev

More information about the Speex-dev mailing list