[speex-dev] decode in ppc 2003

Jean-Marc Valin Jean-Marc.Valin at USherbrooke.ca
Wed Jan 21 13:28:05 PST 2004


Note that FIXED_POINT is only related to compiling speex, not your
application. Also, in 1.1.x, the output and output format for audio
changed to 'short' (instead of float).

        Jean-Marc

Le lun 19/01/2004 à 05:19, Rodrigo Parra M a écrit :
> Hi all,
> 
> Please a moment to look my source code, this is very similar to
> example of the documentation. I added FIXED_POINT flag. My source code
> compile and build but not decode correctly (the error may be in the
> while). I work with eVC 4.0 and pocket pc 2003. Someone know what is
> the error?
> 
> Thanks.
> 
> Rodrigo.
> 
>  
> 
> #include "speex.h"
> 
> #define FRAME_SIZE 160
> 
>  
> 
> void CPlayerDlg::OnButton3() 
> 
> {
> 
>             char infile[]="test.spx";
> 
>             char outfile[]="test.wav";
> 
>             char *outFile;
> 
>             char *inFile;
> 
>             FILE *fout; // output file
> 
>             FILE *fin;   // input file
> 
>  
> 
>             short out[FRAME_SIZE];
> 
>  
> 
>             short output[FRAME_SIZE];
> 
>             char cbits[200];
> 
>             int nbBytes;
> 
>  
> 
>             void *state;
> 
>  
> 
>             SpeexBits bits;
> 
>             int i, tmp;
> 
>  
> 
>             state = speex_decoder_init(&speex_nb_mode);
> 
>  
> 
>             tmp=1;
> 
>             speex_decoder_ctl(state, SPEEX_SET_ENH, &tmp);
> 
>  
> 
>             outFile = outfile;
> 
>             fout = fopen(outFile, "w");
> 
>  
> 
>             inFile = infile;
> 
>             fin = fopen(inFile,"r");
> 
>  
> 
>             speex_bits_init(&bits);
> 
>             while (1)
> 
>             {
> 
>                         
> 
>                         fread(&nbBytes, sizeof(int), 1, fin);
> 
>             fprintf (stderr, "nbBytes: %d\n", nbBytes);
> 
>                         if (feof(fin))
> 
>                                   break;
> 
>       
> 
>                         /*Read the "packet" encoded by sampleenc*/
> 
>                         fread(cbits, 1, nbBytes, fin);
> 
>                         /*Copy the data into the bit-stream struct*/
> 
>                         speex_bits_read_from(&bits, cbits, nbBytes);
> 
>  
> 
>                         /*Decode the data*/
> 
>                         speex_decode(state, &bits, output);
> 
>  
> 
>                         /*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);
> 
>             }
> 
>  
> 
>             /*Destroy the decoder state*/
> 
>              speex_decoder_destroy(state);
> 
>              /*Destroy the bit-stream truct*/
> 
>             speex_bits_destroy(&bits);
> 
>             fclose(fout);
> 
>             //return 0;
> 
> }

-- 
Jean-Marc Valin, M.Sc.A., ing. jr.
LABORIUS (http://www.gel.usherb.ca/laborius)
Université de Sherbrooke, Québec, Canada


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: Ceci est une partie de message numériquement signée.
Url : http://lists.xiph.org/pipermail/speex-dev/attachments/20040121/e6018a50/signature.pgp


More information about the Speex-dev mailing list