[Speex-dev] Multiple frames in packet

jonathan blais jonathanblais at gmail.com
Fri Feb 10 07:10:45 PST 2006


Hi, what is the good way to encode / decode multiple frames in packet ? I
read that I must do multiple call to encode and thats it. But when I'm
trying to decode,, it doesn't work. Maybe, the problem is my decode
function.

Here is my encode function

void ms_speex_enc_process(MSSpeexEnc *obj)
{
    ....

    Do I need to increase gran value to 640 or read / encode (2 times)
    ms_fifo_get_read_ptr(inf,gran,(void**)&input);   (gran = 320)
    g_return_if_fail(input!=NULL);
    /* encode */
    speex_bits_reset(&obj->bits);

    speex_encode_int(obj->speex_state,(short*)input,&obj->bits);

    m=ms_message_new(speex_bits_nbytes(&obj->bits));
    //speex_bits_insert_terminator(&obj->bits);
    m->size=speex_bits_write(&obj->bits,m->data,m->size);
    ms_queue_put(outq,m);
}

And my decode function

void ms_speex_dec_process(MSSpeexDec *obj)
{
    ....

    m=ms_queue_get(inq);
    g_return_if_fail(m!=NULL);
    speex_bits_reset(&obj->bits);
    ms_fifo_get_write_ptr(outf,gran,(void**)&output);
    g_return_if_fail(output!=NULL);
    if (m->data!=NULL){

        speex_bits_read_from(&obj->bits,m->data,m->size);
        /* decode */
        int ret = 1;
        while( ret != -1 && speex_bits_remaining(&obj->bits) > 0 )
        {
               ret =
speex_decode_int(obj->speex_state,&obj->bits,(short*)output);
        }

    }else{
        /* we have a missing packet */
        speex_decode_int(obj->speex_state,NULL,(short*)output);
    }
    ms_message_destroy(m);

}

Jonathan Blais
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20060210/6fb413d7/attachment.htm


More information about the Speex-dev mailing list