DSPRelated.com
Forums

Decoding two channel

Started by "mas...@tin.it" June 15, 2006
The problem I met consist of two or more decode each one of them belong
to a different channel.

I'm implementig a easy routine in which a
buffer 160 element wide is create (called RBuffer[]) and fill of sample
described by 16 bit.
Once the "RBuffer[]" is full the buffer is passed
to the encode function of speex like this:
speex_bits_reset
(&bits1);
speex_encode_int(encState,(spx_int16_t*)&RBuffer[0],
&bits1);
nbBytes = speex_bits_write(&bits1, cbits, 200);

This
structure of the program works well. The problems begins when I
introduce an other decode.
To simulate two decode I take coefficients
from the same "cbits" and insert the first decoded samples in "TBuffer
[]" like in the previos example, while the second and third in a
temporary buffer called "TBufferTemp[]":
speex_bits_read_from
(&bits3, cbits, nbBytes);
speex_decode_int(decState, &bits3,
(spx_int16_t*)&TBufferTemp[0]);

speex_bits_read_from(&bits4,
cbits, nbBytes);
speex_decode_int(decState, &bits4, (spx_int16_t*)
&TBufferTemp[0]);
The problem I encountered is that the suond is bad
and the presence of the second decode functions disturbs the first.

To
resolve this problem I tryed creating a second decState like this:

decState = speex_decoder_init(&speex_nb_mode);
decState2 speex_decoder_init(&speex_nb_mode);

but in this case the function
speex_bits_read_from(&bits2, cbits, nbBytes) can't write in *bits and
*bits2 (are NULL) and the output buffer is fixed to 0.

Someone knows
how can I create and initialize a second encoder state? Or the problem
is the frequency of CCLK of the processor?

Thanks....