[Speex-dev] Error Executing sampledec in VC++
Mo Win
mowin.dev at gmail.com
Mon Oct 17 05:05:42 PDT 2005
hey guys, I just compiled an application similar to sampledec.c (for speex
1.1.10) and it was fine but when I executed it, the app exited without doing
anything. I'm using MS VC 6.0 and this was all I got - First-chance
exception in sampledec.exe : 0xC0000005: Access Violation. Has anyone
encountered this / does anyone know how to deal with it? by the way,
sampleenc executed perfectly...
When I removed the "while" loop in sampledec, the program executed fine (I
placed printf's to check which lines were executed). I also tried running
the loop only once (erasing only the while statement and retaining the code
within it) and it worked fine again. Something seems to be happening during
loop iteration that causes the program to terminate abnormally.. any clues?
thanks very much for any tip..
In gratitude,
Mon
(Below is my code. it's almost exactly like sampleenc except I read a file
stream instead of stdin)
#include "speex/speex.h"
#include <stdio.h>
#include <iostream.h>
void main ()
{
// Definitions
#define FRAME_SIZE 160
#define FIXED_POINT
// Variable Declarations
FILE *fo, *fs;
short spx [FRAME_SIZE];
float pcm [FRAME_SIZE];
char cbits [200];
int nbBytes, n, temp;
void *decstate;
SpeexBits spxbits;
// Program starts here:
cout << "Starting spxdec...\n";
fo = fopen("samp.spx","rb");
if (fo == NULL)
cout << "Error!\n";
else
cout << "Okay!\n";
fs = fopen ("pcmfile", "wb");
if (fs == NULL)
cout << "Error creating file!\n";
else
cout << "File created!\n";
while (!(feof(fo)))
{
decstate = speex_decoder_init (&speex_nb_mode);
// Set default options for decoding:
temp = 1;
speex_decoder_ctl(decstate, SPEEX_SET_ENH, &temp);
// Initialize spxbits (structure SpeexBits)
speex_bits_init (&spxbits);
fread (&nbBytes, sizeof(int), 1, fo);
fread (cbits, 1, nbBytes, fo);
cout << "1"; // just to see whether the loop iterates
speex_bits_read_from (&spxbits, cbits, nbBytes);
speex_decode (decstate, &spxbits, pcm);
// Copy 1 frame from float pcm to short spx
for (n=0; n<FRAME_SIZE; n++)
spx [n] = pcm [n];
fwrite (spx, sizeof(short), FRAME_SIZE, fs);
}
// end of loop
// Entire file has been read, decoded and saved
speex_decoder_destroy (decstate);
speex_bits_destroy (&spxbits);
fclose (fo);
fclose (fs);
cout << "Finished processing!\n";
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20051017/4fea1d86/attachment.html
More information about the Speex-dev
mailing list