DSPRelated.com
Forums

decoding more than one channel with speex_encode_int()

Started by "mas...@tin.it" May 24, 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);
Now compleated this first step I have to decode the encoded
stream and insert the obteined samples in another
buffer 160 element
wide called "TBuffer[]" in this way:
speex_bits_read_from
(&bits2, cbits, nbBytes);
speex_decode_int(decState, &bits2,
(spx_int16_t*)&TBuffer[0]);
Clearly the two SpeexBits structure
called "bits1" and "bits2" are initialized at the beginning in the
main()
with this speex function: "speex_bits_init()".

This structure
of the program works well. The problems begins when I introduce others
decode.
To simulate two or three 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]);
Clearly now the other SpeexBits structure called "bits3" and "bits4"
are initialized at the beginning in the main().

The problem I
encountered is that the suond is bad and the presence of the last two
decode functions disturbs the first.

I suppose that the content of
"bits2", "bits3", "bits4" should be the same because the reading is
done from the same "cbits"
but it doesn't work in this way....
The
pecularity is that "bits2" and "bits3" are different, and "bits4" is
null.

What I'm induced to think is that this functions have memory
because whit the same input (cbits) give back different
structures
(bits2, bits3, bits4).

Someone knows how can I resolve this problem?
What happen in this function?

Thanks a lot....
m...@tin.it wrote:

>
> The problem I met consist of two or more decode each one of them
> belong to a different channel.

You need a separate decoder states, not just bits structures.
--
Phil Frisbie, Jr.
Hawk Software
http://www.hawksoft.com