[speex-dev] decode in ppc 2003

Jean-Marc Valin Jean-Marc.Valin at USherbrooke.ca
Wed Jan 21 16:17:39 PST 2004


Please start from sampleenc.c and sampledec.c. That'll be easier.

        Jean-Marc

Le mer 21/01/2004 à 18:17, Rodrigo Parra M a écrit :
> Hi, 
> My problem is at the second fread function,
> fread(&nbBytes, sizeof(int), 1, fin); //the first fread 
> fread(cbits,1, nbBytes, fin);// the second fread.
> 
> When I'm debugging always nbytes is greater than cbits. This give me a
> execution error.
> 
> Thanks.
> Rodrigo.
> 
> 
> 
> 
> -----Mensaje original-----
> De: owner-speex-dev at xiph.org [mailto:owner-speex-dev at xiph.org] En nombre de
> Jean-Marc Valin
> Enviado el: Miércoles, 21 de Enero de 2004 18:28
> Para: speex
> Asunto: Re: [speex-dev] decode in ppc 2003
> 
> 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/61881141/signature-0001.pgp


More information about the Speex-dev mailing list