Discussion:
using libjpeg.a : "Output file write error"
(too old to reply)
JR
2009-12-23 12:16:35 UTC
Permalink
Hi all,

I'm experiencing a problem using the libjpeg.a (version 7.0) when i
execute a small application of mine that converts a bpm file into jpg
format.
when writing the jpg output to file, the libjpeg complains:

"Output file write error --- out of disk space?"

OK.
1.) yes i have enough disk space left.
2.) my platform is CYGWIN_NT-5.1
3.) inside the libjpeg, i traced the error to the function jdatadst.c,
this is the code fragment that causes the trouble:

/* Write any data remaining in the buffer */
if (datacount > 0) {
if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount)
{
printf("location 2\n"); fflush(stdout);
ERREXIT(cinfo, JERR_FILE_WRITE);
}
}
4.) the code fragment that calls 3.) looks as follows:
for (y=0; y<height; ++y) {
*rp = (str + y*x);
jpeg_write_scanlines( &cinfo, rp, 1 );
}
with x being the size of a row.


Did anybody experience (and pro'ly solve) this problem before?
TIA,

Jorg.
Ben Bacarisse
2009-12-23 12:40:15 UTC
Permalink
Post by JR
I'm experiencing a problem using the libjpeg.a (version 7.0) when i
execute a small application of mine that converts a bpm file into jpg
format.
"Output file write error --- out of disk space?"
<snip>
Post by JR
/* Write any data remaining in the buffer */
if (datacount > 0) {
if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount)
{
printf("location 2\n"); fflush(stdout);
ERREXIT(cinfo, JERR_FILE_WRITE);
}
}
<snip>
Post by JR
Did anybody experience (and pro'ly solve) this problem before?
Did you open the output stream in binary mode? It is possible that
whatever code lies behind JFWRITE might be counting bytes output
rather than elements written (as C's fwrite is obliged to do) and it
is therefore getting confused by a \n to \r\n translation.

Not likely, I admit, but it seems worth checking that first off.
--
Ben.
Barry Schwarz
2009-12-23 13:03:35 UTC
Permalink
Post by JR
Hi all,
I'm experiencing a problem using the libjpeg.a (version 7.0) when i
execute a small application of mine that converts a bpm file into jpg
format.
"Output file write error --- out of disk space?"
OK.
1.) yes i have enough disk space left.
2.) my platform is CYGWIN_NT-5.1
3.) inside the libjpeg, i traced the error to the function jdatadst.c,
/* Write any data remaining in the buffer */
if (datacount > 0) {
if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount)
{
printf("location 2\n"); fflush(stdout);
ERREXIT(cinfo, JERR_FILE_WRITE);
}
}
If JFWRITE calls fwrite and returns its return value, there are other
reasons than lack of disk space which can cause this error message.
That is the significance of the "?" at the end of the error message.

Are you certain the output file was opened successfully? Do you have
permission to write to the file? Could another task have the file
locked? Have you checked your disk for bad sectors?

Considerations raised by a brief google search: Have you successfully
used this version libjpeg before? Are you sure you built it correctly
after downloading it? Did you recently convert from version 6.2?

You might want to perform a more thorough review of google hits.
--
Remove del for email
JR
2009-12-23 13:27:55 UTC
Permalink
Post by Barry Schwarz
Are you certain the output file was opened successfully?
yes, certainly checked it before
Post by Barry Schwarz
Do you have
permission to write to the file?  
yes
Post by Barry Schwarz
Could another task have the file
locked?
no
Post by Barry Schwarz
Have you checked your disk for bad sectors?
:-) by now, yes. it is OK
Post by Barry Schwarz
Considerations raised by a brief google search: Have you successfully
used this version libjpeg before?
no, i used 6.2 and upgraded after i experienced the same problem w/
6.2
Post by Barry Schwarz
Are you sure you built it correctly
after downloading it?  
yes! (-> "make test")

thank you for the suggestions anyway.

as suggested by Ben, i will now go into jfwrite and implement some
checks and output there.

Jorg
Barry Schwarz
2009-12-23 14:41:53 UTC
Permalink
Post by JR
Post by Barry Schwarz
Are you certain the output file was opened successfully?
yes, certainly checked it before
Post by Barry Schwarz
Do you have
permission to write to the file?  
yes
Post by Barry Schwarz
Could another task have the file
locked?
no
Post by Barry Schwarz
Have you checked your disk for bad sectors?
:-) by now, yes. it is OK
Post by Barry Schwarz
Considerations raised by a brief google search: Have you successfully
used this version libjpeg before?
no, i used 6.2 and upgraded after i experienced the same problem w/
6.2
The first couple of google hits are about problems converting from 6.2
to 7.0.
--
Remove del for email
JR
2009-12-23 20:06:52 UTC
Permalink
OK folks,
here's the solution.

Manager's summary: Barry's guess was best ("there are other reasons
than lack of disk space...")

my code was:

for (y=0; y<height; ++y) {
*rp = (str + y*x);
jpeg_write_scanlines( &cinfo, rp, 1 );
} ,
where jpeg_write_scanlines is a function which does not directly
convert data into jpg format and write these. instead, a buffer is
filled with raw image data.
The libjpeg converts this buffer to the target format and writes it to
the destination file only when the compression is executed with
jpeg_finish_compress(&cinfo).
This is how my code continued:

<begin original code>
// -- clean up
fclose(fp);
jpeg_finish_compress(&cinfo);
jpeg_destroy_compress(&cinfo);
<end original code>

This is certainly f**ed up because fp is closed before the compression
is executed and the jpg buffer is written. it must be

<begin corrected code>
// -- clean up
jpeg_finish_compress(&cinfo);
jpeg_destroy_compress(&cinfo);
fclose(fp);
<end corrected code>

So, the 7.0 is fine (so far), the reason is me being braindead.
Annoys me. At least, where there's pain, there must still be life.
Thank you to all of you, and have a merry christmas.

Jorg.
jacob navia
2009-12-23 14:22:35 UTC
Permalink
Post by JR
Hi all,
I'm experiencing a problem using the libjpeg.a (version 7.0) when i
execute a small application of mine that converts a bpm file into jpg
format.
"Output file write error --- out of disk space?"
OK.
1.) yes i have enough disk space left.
2.) my platform is CYGWIN_NT-5.1
3.) inside the libjpeg, i traced the error to the function jdatadst.c,
/* Write any data remaining in the buffer */
if (datacount > 0) {
if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount)
{
printf("location 2\n"); fflush(stdout);
ERREXIT(cinfo, JERR_FILE_WRITE);
}
}
for (y=0; y<height; ++y) {
*rp = (str + y*x);
jpeg_write_scanlines( &cinfo, rp, 1 );
}
with x being the size of a row.
Did anybody experience (and pro'ly solve) this problem before?
TIA,
Jorg.
could be that your file is bigger than 2gigs and that your
fwrite is 32 bits?
BGB / cr88192
2009-12-23 20:12:12 UTC
Permalink
Post by jacob navia
Post by JR
Hi all,
I'm experiencing a problem using the libjpeg.a (version 7.0) when i
execute a small application of mine that converts a bpm file into jpg
format.
"Output file write error --- out of disk space?"
OK.
1.) yes i have enough disk space left.
2.) my platform is CYGWIN_NT-5.1
3.) inside the libjpeg, i traced the error to the function jdatadst.c,
/* Write any data remaining in the buffer */
if (datacount > 0) {
if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount)
{
printf("location 2\n"); fflush(stdout);
ERREXIT(cinfo, JERR_FILE_WRITE);
}
}
for (y=0; y<height; ++y) {
*rp = (str + y*x);
jpeg_write_scanlines( &cinfo, rp, 1 );
}
with x being the size of a row.
Did anybody experience (and pro'ly solve) this problem before?
TIA,
Jorg.
could be that your file is bigger than 2gigs and that your
fwrite is 32 bits?
if writing a JPEG does this, then one has BIGGER problems...


oddly, I don't use libjpeg, as I instead just beat together a JPEG
reader/writer based of of T.81 and JFIF... (it does not directly read/write
files, rather encode/decode images in memory buffers...).

I also used it before to beat together a "motion JPEG" output video codec
for my 3D renderer, but alas many people seem unable to play the files due
to not going and downloading CCCP or similar.

well, that, and the files are large, and it was difficult to get real-time
video-capture to work without too severe of a framerate impact.

Loading...