[Speex-dev] error in decoding raw speex file

Erwin Davis erwin.davis at gmail.com
Fri Jan 23 14:39:57 PST 2009


Hi, Speex Fans,

I collected the speex raw file from flash server and tried to decode it with
samepldec.c ( I modified the code the file input) as below.
speex rate=8khz, one framesize=10 bytes in the client,

When I ran the decoding program, it kept displaying the error below and the
file genertaed is corrupt too.
Please help point out what is wrong. I also attach the raw speex file.
Thanks,


===include Partial Code =============================================
speex_bits_init(&bits);
   /*Create a new decoder state in narrowband mode*/
   state = speex_decoder_init(&speex_nb_mode);
   //state = speex_encoder_init(speex_lib_get_mode(SPEEX_MODEID_NB));
   speex_decoder_ctl(state, SPEEX_GET_FRAME_SIZE, &frame_size);
   /*Set the perceptual enhancement on*/
   tmp=1;
   speex_decoder_ctl(state, SPEEX_SET_ENH, &tmp);
   speex_bits_init(&bits);

.......

   while (1)
   {
      /*Read the size encoded by sampleenc, this part will likely be
        different in your application*/
      nbBytes = fread(cbits, sizeof(char), 10, fin);
      if (feof(fin))
         break;
      /*Read the "packet" encoded by sampleenc*/
   if (nbBytes > 0) {
   /*Copy the data into the bit-stream struct*/
   speex_bits_read_from(&bits, cbits, nbBytes);
   /*Decode the data*/
   if (speex_decode(state, &bits, output) == 0)
   {
    /*Copy from float to short (16 bits) for output*/
    for (i=0;i<frame_size;i++)
     out[i]=output[i];
    /*Write the decoded audio to file*/
    fwrite(out, sizeof(short), frame_size, fout);
   }
   }
errors:

 warning: Invalid mode encountered: corrupted stream?
warning: Invalid wideband mode encountered. Corrupted stream?
warning: Invalid wideband mode encountered. Corrupted stream?
warning: Invalid mode encountered: corrupted stream?
warning: Invalid mode encountered: corrupted stream?
warning: Invalid wideband mode encountered. Corrupted stream?
warning: Invalid wideband mode encountered: corrupted stream?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20090123/2cf52fd3/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p_speex.raw
Type: application/octet-stream
Size: 33292 bytes
Desc: not available
Url : http://lists.xiph.org/pipermail/speex-dev/attachments/20090123/2cf52fd3/attachment-0001.obj 


More information about the Speex-dev mailing list