[Speex-dev] First encoded byte, mode bits and wideband bit
dspcph at yahoo.dk
Mon Aug 29 09:56:40 PDT 2011
I have read the speex manual, looked at the example code, but for some reason the first encoded byte does not have the wideband bit set and the mode bits are also wrong even though I am encoding in wideband mode.
I am sure that I am doing something wrong, but I can't figure out what it is.
I have included my code below....
I would expect that the MSB of the first encoded byte is 1 (wideband) and that the next 4 bits would be 8 (because I requested mode 8)...but this is the mapping I see
here is my code
thisEncoder->speexEncoderInstance = speex_encoder_init(speex_lib_get_mode(SPEEX_MODEID_WB));
speex_encoder_ctl(thisEncoder->speexEncoderInstance, SPEEX_SET_QUALITY, &encodermode);
where encodermode = 8
thisDecoder->speexDecoderInstance = speex_decoder_init(speex_lib_get_mode(SPEEX_MODEID_WB));
speex_decoder_ctl(thisDecoder->speexDecoderInstance, SPEEX_SET_QUALITY, &decodermode);
where decodermode = 8
/* Reset bitstream */
/* PCM -> Bitstream */
speex_encode_int(thisEncoder->speexEncoderInstance, pAudiodataIn, &thisEncoder->bits);
/* Bitstream -> Byteblock */
nBytes = speex_bits_nbytes(&thisEncoder->bits);
nBytes = speex_bits_write(&thisEncoder->bits, (i8*) pEncodedAudioOut, nBytes);
firstbyte = (pEncodedAudioOut >> 3) & 15;
printf("Actual mode: %d \n", firstbyte);
wideband = (pEncodedAudioOut >> 7);
printf("Wideband: %d \n", wideband);
/* Byteblock -> Bitstream */
speex_bits_read_from(&thisDecoder->bits, (i8*) pEncodedAudioIn, (int) thisDecoder->payloadSize);
/* Bitstream -> PCM */
speex_decode_int(thisDecoder->speexDecoderInstance, &thisDecoder->bits, pDecodedAudioOut);
What am I doing wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Speex-dev