[Speex-dev] Strange Problem
Md. Merajul Islam
merajul_i at yahoo.com
Tue Oct 4 23:26:51 PDT 2005
Hi
I am facing a strange problem. I have integrated speex
codec's narrowband mode in my SIP based server. Then I
tried to integrate the wideband mode. But the program
crashes mysteriously. My encode and decode codes for
wide band mode are exact similiar to that of
narrowband, except the mode initialization, where I
put "speex_wb_mode" instead of "speex_nb_mode".
My encoding code:
bool
SPEEX16::Encode(const std::string& raw, std::string&
encoded)
{
speex_bits_reset(&bits);
speex_encode_int(state, (short*)raw.data(), &bits);
int nbytes = speex_bits_nbytes(&bits);
encoded.resize(nbytes);
speex_bits_write(&bits, (char*)encoded.data(),
nbytes);
return true;
}
Amd decoding code:
bool
SPEEX16::Decode(const std::string& encoded,
std::string& raw)
{
short output[320];
speex_bits_reset(&bits);
speex_bits_read_from(&bits, (char*)encoded.data(),
encoded.size());
speex_decode_int(state, &bits, output);
/*
raw.resize(320 * sizeof(short));
for(int i = 0; i < 320; i++)
((short*)raw.data())[i] = output[i] ;
*/
return true;
}
Here, raw = decoded output (initially empty string)
The framesize is default one: 320 bytes. The program
creates two objects of class SPEEX16 - enc and dec.
These objects should remain in memory until the user
agents hang up.
The problem that I am facing is, if I uncomment the
line:
raw.resize(320 * sizeof(short));
The program crashes. Before it crashes, it calles the
destructor. I don't see anything wrong in my code. I
used the same code for narrow band mode. Its working
properly. In that case I only kept the framesize to
160.
Please let me know what is wrong? Is this due to bug
in my code or somewhere else?????
Why cann't the raw string be resized for wideband????
Thanks
-John
______________________________________________________
Yahoo! for Good
Donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/
More information about the Speex-dev
mailing list