Hi Steve, thanks for the advice. I placed the appropriate functions outside
the while statement but I still get this error at the while loop:
First-chance exception at 0x004010fa in SPXDEC.exe: 0xC0000005: Access
violation reading location 0x0000000c.
Unhandled exception at 0x004010fa in SPXDEC.exe: 0xC0000005: Access
violation reading location 0x0000000c.
It looks like the same error. I've attached the code below
Thanks,
Mon
Portion of the revised code:
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);
while (!(feof(fo))) // this is where the problem starts
{
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";
}
On 10/18/05, Steve Russell <srussell@innernet.net>
wrote:>
> Mon,
> Here is feedback that I got concerning the access violation, i.e. the
> failure of the while loop below. Does this solve the problem?
> Steve
> My guess is that speex_decoder_init() should be outside the while()..
> loop
> as speex_decoder_destroy() is also outside.
>
> ----- Original Message -----
> *From:* Mo Win <mowin.dev@gmail.com>
> *To:* speex-dev@xiph.org
> *Sent:* Monday, October 17, 2005 8:05 AM
> *Subject:* [Speex-dev] Error Executing sampledec in VC++
>
> 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";
> }
>
> ------------------------------
>
> _______________________________________________
> Speex-dev mailing list
> Speex-dev@xiph.org
> http://lists.xiph.org/mailman/listinfo/speex-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.xiph.org/pipermail/speex-dev/attachments/20051018/11754124/attachment.html
You should really do a check to make sure
nbBytes isn't larger than 200, otherwise you're going to read past the
end
of your char array.
fread (&nbBytes, sizeof(int), 1, fo);
_____
From: speex-dev-bounces@xiph.org [mailto:speex-dev-bounces@xiph.org] On
Behalf Of Mo Win
Sent: Monday, October 17, 2005 7:31 PM
To: speex-dev@xiph.org
Subject: Re: [Speex-dev] Error Executing sampledec in VC++
Hi Steve, thanks for the advice. I placed the appropriate functions outside
the while statement but I still get this error at the while loop:
First-chance exception at 0x004010fa in SPXDEC.exe: 0xC0000005: Access
violation reading location 0x0000000c.
Unhandled exception at 0x004010fa in SPXDEC.exe: 0xC0000005: Access
violation reading location 0x0000000c.
It looks like the same error. I've attached the code below
Thanks,
Mon
Portion of the revised code:
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);
while (!(feof(fo))) // this is where the problem starts
{
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";
}
On 10/18/05, Steve Russell <srussell@innernet.net> wrote:
Mon,
Here is feedback that I got concerning the access violation, i.e. the
failure of the while loop below. Does this solve the problem?
Steve
My guess is that speex_decoder_init() should be outside the while().. loop
as speex_decoder_destroy() is also outside.
----- Original Message -----
From: Mo <mailto:mowin.dev@gmail.com> Win
To: speex-dev@xiph.org
Sent: Monday, October 17, 2005 8:05 AM
Subject: [Speex-dev] Error Executing sampledec in VC++
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";
}
_____
_______________________________________________
Speex-dev mailing list
Speex-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/speex-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.xiph.org/pipermail/speex-dev/attachments/20051017/54dc7dba/attachment.html
Mon,
Here is an additional post that came to me regarding your trouble. In the
meantime, I will take your latest comments and see what more feedback we can
get. I don't know what it is, and I haven't taken the time in the last
few months to try again to get Speex going inside C++, but something about it
has been much more difficult for me to grasp than both mmio and Ogg Vorbis.
(That's not a criticism! I appreciate all the "free" efforts
involved.)
Steve
steve,
your speex decoding code looks ok, only you have to be sure that you have
the spx file encoded correctly as well. the point is the problem could also
be caused by the source file being read and if you are at all reading it
correctly.
what i'll probably do here is:
1. check the encoding code to validate the integrity of the spx file
2. check the decoding code if the sizes are being read correctly.
the spx file here shows a certain formatting structure where each item
size+data, so i assume this is a variable bitrate (VBR) encoding where item
sizes could be of any value. to make it easier you can also do CBR, where
your speex data are encoded on a constant bitrate. this will make debugging
easier for starters until you know what the problem is.
regards,
ronald
----- Original Message -----
From: Mo Win
To: speex-dev@xiph.org
Cc: Steve Russell
Sent: Monday, October 17, 2005 10:31 PM
Subject: Re: [Speex-dev] Error Executing sampledec in VC++
Hi Steve, thanks for the advice. I placed the appropriate functions outside
the while statement but I still get this error at the while loop:
First-chance exception at 0x004010fa in SPXDEC.exe: 0xC0000005: Access
violation reading location 0x0000000c.
Unhandled exception at 0x004010fa in SPXDEC.exe: 0xC0000005: Access violation
reading location 0x0000000c.
It looks like the same error. I've attached the code below
Thanks,
Mon
Portion of the revised code:
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);
while (!(feof(fo))) // this is where the problem starts
{
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";
}
On 10/18/05, Steve Russell <srussell@innernet.net> wrote:
Mon,
Here is feedback that I got concerning the access violation, i.e. the
failure of the while loop below. Does this solve the problem?
Steve
My guess is that speex_decoder_init() should be outside the while().. loop
as speex_decoder_destroy() is also outside.
----- Original Message -----
From: Mo Win
To: speex-dev@xiph.org
Sent: Monday, October 17, 2005 8:05 AM
Subject: [Speex-dev] Error Executing sampledec in VC++
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";
}
--------------------------------------------------------------------------
_______________________________________________
Speex-dev mailing list
Speex-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/speex-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.xiph.org/pipermail/speex-dev/attachments/20051017/38ce337c/attachment-0001.htm
Mon, Since the buffer check was mentioned, I will pass on the bulk of another post which has comments interwoven with your sample. This person admitted to not knowing Speex, but at least points out your buffer overflow possibility and maybe something else helpful. Steve> // Program starts here: > cout << "Starting spxdec...\n"; > fo = fopen("samp.spx","rb"); > > if (fo == NULL) > cout << "Error!\n";if its not open why continue?> else > cout << "Okay!\n"; > > fs = fopen ("pcmfile", "wb"); > > if (fs == NULL) > cout << "Error creating file!\n";again, why continue?> else > cout << "File created!\n"; > > > while (!(feof(fo))) > { > decstate = speex_decoder_init (&speex_nb_mode);maybe the decoder init doesn't like getting called multiple times?> > // Set default options for decoding: > temp = 1; > speex_decoder_ctl(decstate, SPEEX_SET_ENH, &temp);maybe the decoder ctl doesn't like getting called multiple times?> > > // Initialize spxbits (structure SpeexBits) > speex_bits_init (&spxbits);maybe the bits init doesn't like getting called multiple times?> > > fread (&nbBytes, sizeof(int), 1, fo); > fread (cbits, 1, nbBytes, fo);nbBytes could be >200 thus overflowing the buffer... all buffer sizes should be checked before being used.> > 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"; > }----------- ----- Original Message ----- From: Duane Storey To: 'Mo Win' ; speex-dev@xiph.org Sent: Monday, October 17, 2005 10:40 PM Subject: RE: [Speex-dev] Error Executing sampledec in VC++ You should really do a check to make sure nbBytes isn't larger than 200, otherwise you're going to read past the end of your char array. fread (&nbBytes, sizeof(int), 1, fo); ------------------------------------------------------------------------------ From: speex-dev-bounces@xiph.org [mailto:speex-dev-bounces@xiph.org] On Behalf Of Mo Win Sent: Monday, October 17, 2005 7:31 PM To: speex-dev@xiph.org Subject: Re: [Speex-dev] Error Executing sampledec in VC++ Hi Steve, thanks for the advice. I placed the appropriate functions outside the while statement but I still get this error at the while loop: First-chance exception at 0x004010fa in SPXDEC.exe: 0xC0000005: Access violation reading location 0x0000000c. Unhandled exception at 0x004010fa in SPXDEC.exe: 0xC0000005: Access violation reading location 0x0000000c. It looks like the same error. I've attached the code below Thanks, Mon Portion of the revised code: 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); while (!(feof(fo))) // this is where the problem starts { 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"; } On 10/18/05, Steve Russell <srussell@innernet.net> wrote: Mon, Here is feedback that I got concerning the access violation, i.e. the failure of the while loop below. Does this solve the problem? Steve My guess is that speex_decoder_init() should be outside the while().. loop as speex_decoder_destroy() is also outside. ----- Original Message ----- From: Mo Win To: speex-dev@xiph.org Sent: Monday, October 17, 2005 8:05 AM Subject: [Speex-dev] Error Executing sampledec in VC++ 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"; } ---------------------------------------------------------------------------- _______________________________________________ Speex-dev mailing list Speex-dev@xiph.org http://lists.xiph.org/mailman/listinfo/speex-dev ------------------------------------------------------------------------------ _______________________________________________ Speex-dev mailing list Speex-dev@xiph.org http://lists.xiph.org/mailman/listinfo/speex-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20051017/8932a35d/attachment-0001.html
Mon,
You should be calling speex_bits_reset inside the loop. This resets some
pointers to the beginning of the bit buffer. If you don't do this, the
pointers will grow indefinitely. Look at testenc.c, or at the modified versions
that I posted yesterday for the TI DSPs. You might want to get the example to
run first, then modify it as you need.
- Jim
----- Original Message -----
From: Mo Win
To: speex-dev@xiph.org
Sent: Monday, October 17, 2005 10:31 PM
Subject: Re: [Speex-dev] Error Executing sampledec in VC++
Hi Steve, thanks for the advice. I placed the appropriate functions outside
the while statement but I still get this error at the while loop:
First-chance exception at 0x004010fa in SPXDEC.exe: 0xC0000005: Access
violation reading location 0x0000000c.
Unhandled exception at 0x004010fa in SPXDEC.exe: 0xC0000005: Access violation
reading location 0x0000000c.
It looks like the same error. I've attached the code below
Thanks,
Mon
Portion of the revised code:
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);
while (!(feof(fo))) // this is where the problem starts
{
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";
}
On 10/18/05, Steve Russell <srussell@innernet.net> wrote:
Mon,
Here is feedback that I got concerning the access violation, i.e. the
failure of the while loop below. Does this solve the problem?
Steve
My guess is that speex_decoder_init() should be outside the while().. loop
as speex_decoder_destroy() is also outside.
----- Original Message -----
From: Mo Win
To: speex-dev@xiph.org
Sent: Monday, October 17, 2005 8:05 AM
Subject: [Speex-dev] Error Executing sampledec in VC++
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";
}
--------------------------------------------------------------------------
_______________________________________________
Speex-dev mailing list
Speex-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/speex-dev
------------------------------------------------------------------------------
_______________________________________________
Speex-dev mailing list
Speex-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/speex-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.xiph.org/pipermail/speex-dev/attachments/20051018/3e08b8b2/attachment.htm
One more bit of counsel I received that may or may not be needed by now, Mon --
Use the debug build of speex if you can. Break in the debugger and go up
the call stack to locate where in your code it is faulting. Trace line by
line if you have to.
----- Original Message -----
From: Mo Win
To: speex-dev@xiph.org
Cc: Steve Russell
Sent: Monday, October 17, 2005 10:31 PM
Subject: Re: [Speex-dev] Error Executing sampledec in VC++
Hi Steve, thanks for the advice. I placed the appropriate functions outside
the while statement but I still get this error at the while loop:
First-chance exception at 0x004010fa in SPXDEC.exe: 0xC0000005: Access
violation reading location 0x0000000c.
Unhandled exception at 0x004010fa in SPXDEC.exe: 0xC0000005: Access violation
reading location 0x0000000c.
It looks like the same error. I've attached the code below
Thanks,
Mon
Portion of the revised code:
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);
while (!(feof(fo))) // this is where the problem starts
{
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";
}
On 10/18/05, Steve Russell <srussell@innernet.net> wrote:
Mon,
Here is feedback that I got concerning the access violation, i.e. the
failure of the while loop below. Does this solve the problem?
Steve
My guess is that speex_decoder_init() should be outside the while().. loop
as speex_decoder_destroy() is also outside.
----- Original Message -----
From: Mo Win
To: speex-dev@xiph.org
Sent: Monday, October 17, 2005 8:05 AM
Subject: [Speex-dev] Error Executing sampledec in VC++
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";
}
--------------------------------------------------------------------------
_______________________________________________
Speex-dev mailing list
Speex-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/speex-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.xiph.org/pipermail/speex-dev/attachments/20051018/8034544a/attachment.htm
Mon,
How did your decoder inside Visual Studio turn out? Are you going to share the
results?
Steve Russell
----- Original Message -----
From: Mo Win
To: speex-dev@xiph.org
Cc: Steve Russell
Sent: Monday, October 17, 2005 10:31 PM
Subject: Re: [Speex-dev] Error Executing sampledec in VC++
Hi Steve, thanks for the advice. I placed the appropriate functions outside
the while statement but I still get this error at the while loop:
First-chance exception at 0x004010fa in SPXDEC.exe: 0xC0000005: Access
violation reading location 0x0000000c.
Unhandled exception at 0x004010fa in SPXDEC.exe: 0xC0000005: Access violation
reading location 0x0000000c.
It looks like the same error. I've attached the code below
Thanks,
Mon
Portion of the revised code:
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);
while (!(feof(fo))) // this is where the problem starts
{
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";
}
On 10/18/05, Steve Russell <srussell@innernet.net> wrote:
Mon,
Here is feedback that I got concerning the access violation, i.e. the
failure of the while loop below. Does this solve the problem?
Steve
My guess is that speex_decoder_init() should be outside the while().. loop
as speex_decoder_destroy() is also outside.
----- Original Message -----
From: Mo Win
To: speex-dev@xiph.org
Sent: Monday, October 17, 2005 8:05 AM
Subject: [Speex-dev] Error Executing sampledec in VC++
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";
}
--------------------------------------------------------------------------
_______________________________________________
Speex-dev mailing list
Speex-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/speex-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.xiph.org/pipermail/speex-dev/attachments/20051025/abf32609/attachment.html