[This email is either empty or too large to be displayed at this time]
Software Engineer
2011-Aug-29 16:56 UTC
[Speex-dev] First encoded byte, mode bits and wideband bit
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 ? ? Init Encoder: speex_bits_init(&thisEncoder->bits); thisEncoder->speexEncoderInstance = speex_encoder_init(speex_lib_get_mode(SPEEX_MODEID_WB)); speex_encoder_ctl(thisEncoder->speexEncoderInstance, SPEEX_SET_QUALITY, &encodermode); ? where encodermode = 8 ? ? Init Decoder: thisDecoder->speexDecoderInstance = speex_decoder_init(speex_lib_get_mode(SPEEX_MODEID_WB)); speex_decoder_ctl(thisDecoder->speexDecoderInstance, SPEEX_SET_QUALITY, &decodermode); speex_bits_init(&thisDecoder->bits); ? where decodermode = 8 ? ? Encode: /* Reset bitstream */ speex_bits_reset(&thisEncoder->bits); /* 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[0] >> 3) & 15; printf("Actual mode: %d \n", firstbyte); wideband = (pEncodedAudioOut[0] >> 7); printf("Wideband: %d \n", wideband); ? ? Decode: /* Byteblock -> Bitstream */ speex_bits_read_from(&thisDecoder->bits, (i8*) pEncodedAudioIn, (int) thisDecoder->payloadSize); /* Bitstream -> PCM */ speex_decode_int(thisDecoder->speexDecoderInstance, &thisDecoder->bits, pDecodedAudioOut); speex_bits_reset(&thisDecoder->bits); ? ? ? What am I doing wrong?? ? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20110829/52c39b24/attachment.htm
Hi, ? Is there anybody out there who can tell me how to solve the following problem: ? An RTP payload of encoded speex data is received. The length of the payload is N bytes. The length corresponds to 20ms * K of encoded audio where K is an unknown integer. The audio was encoded by an encoder in wideband mode. ? How do I partition the payload when I don't know which bitrate mode of the encoder? I want to hand over 20ms of encoded audio to the decoder, but to be able to do that I need to know how many bytes of the payload corresponds to 20ms. ? I read that the bitrate mode and the wideband bit is embedded in the first byte, but that is not what I actually see. What I see is that the MSB of the first encoded byte is 0 and the following bits do not correspond to the bitrate mode that was used when encoding the audio. ? So I am wondering what I am doing wrong. ? Is it because the first part of the payload is a narrowband bitstream ? And I need to extract the narrowband bitrate mode first,?figure out how many bytes (M) that mode corresponds to?and skip?M?bytes ahead to get the wideband bitrate mode? ? Or is there a quicker way of doing it? ? Can somebody please shed some light on this?? ? Thank you!! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20110830/edf51a0d/attachment.htm