[Speex-dev] problems decoding speex... please help
Mo Win
mowin.dev at gmail.com
Tue Dec 6 06:37:54 PST 2005
Hi all. I'm trying to decode speex using version 1.1.10's libspeex with
fixed_point enabled. copied the sample in the manual (1.1.11) with minor
revisions. While running the program, encountered this warning:
"Packet is larger than allocated buffer : 38"
when calling speex_bits_read_from (&bits, cbits, nBytes)
then my program terminated unexpectedly with errors (Unhandled exception at
0x10225e1f ( msvcr80d.dll) in sampleDEC.exe: 0xC0000005: Access violation
reading location 0x645c3a63.)
I declared cbits as char *cbits [500]. nBytes is 38, bit rate is 15000 bps.
I'm decoding a 'speex' file created using a program much like sampleENC. Can
anyone tell me what is wrong and how I can correct the problem? Thank you.
For your reference I'm attaching the code. Please feel free to ask me
questions if the information I provided is lacking. By the way, I am
compiling for Windows using VS2005 Beta2.
Thanks,
Mon
#define FIXED_POINT
int main (int argc, char ** argv)
{
printf ("sampleDEC.exe started!\n"); /**/
int nBytes, FrameSize, BitRate;
FILE *fin, *fout;
char *inFile, *outFile, *PEnhancement;
short out [500];
char cbits [500];
void *state;
SpeexBits bits;
state = speex_decoder_init (&speex_nb_mode);
speex_decoder_ctl (state, SPEEX_GET_FRAME_SIZE, &FrameSize);
inFile = argv [1];
outFile = argv [2];
PEnhancement = argv [3];
fout = fopen (outFile, "w");
if (fout == NULL)
{
printf ("Error creating file\n");
return 1;
}
printf ("Successfully opened %s for writing! \n", outFile); /**/
fin = fopen (inFile, "rb");
if (fin == NULL)
{
printf ("Error opening file\n");
return 1;
}
printf ("Successfully opened %s for decoding!\n\n", inFile); /**/
fseek (fin,(sizeof(char))*12+sizeof(int),SEEK_SET); // because of the
way I encoded a PCM file
speex_decoder_ctl (state, SPEEX_GET_BITRATE, &BitRate);
printf ("decoding... BIT RATE: %i\n",BitRate);
switch (*PEnhancement)
{ // Here I use BitRate to toggle Perceptual Enhancement
case 'Y':
BitRate = 1;
break;
case 'y':
BitRate = 1;
break;
case 'N':
BitRate = 0;
break;
case 'n':
BitRate = 0;
break;
default:
BitRate = 1;
break;
}
speex_decoder_ctl (state, SPEEX_SET_ENH, &BitRate);
BitRate = 0; // Henceforth BitRate is used to count the number of frames
decoded
while (1)
{
fread(&nBytes, sizeof(int), 1, fin);
if (feof(fin))
break;
fread(cbits, sizeof(char), nBytes, fin);
speex_bits_read_from(&bits, cbits, nBytes);
speex_decode_int(state, &bits, out);
fwrite(out, sizeof(short), FrameSize, fout);
BitRate++;
}
printf ("nBytes is %i.\n",nBytes);
printf ("Decoded %i frames\n",BitRate);
speex_encoder_destroy(state);
speex_bits_destroy(&bits);
fclose (fin);
fclose(fout);
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20051206/a588485a/attachment.html
More information about the Speex-dev
mailing list