summaryrefslogtreecommitdiff
path: root/trunk/rdbmp.c
diff options
context:
space:
mode:
authordcommander <dcommander@3789f03b-4d11-0410-bbf8-ca57d06f2519>2011-04-25 22:47:44 +0000
committerdcommander <dcommander@3789f03b-4d11-0410-bbf8-ca57d06f2519>2011-04-25 22:47:44 +0000
commit76dab327f5a8f4876f1ba9176c28421d390e524f (patch)
treea30c6c475f91610e07fb0deb0a9139d0b0e8fa07 /trunk/rdbmp.c
parent1dbee5e40c05077149c8ef8831194d776cc03da2 (diff)
Eliminate excessive I/O overhead when reading BMP files in cjpeg
git-svn-id: https://libjpeg-turbo.svn.sourceforge.net/svnroot/libjpeg-turbo@594 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'trunk/rdbmp.c')
-rw-r--r--trunk/rdbmp.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/trunk/rdbmp.c b/trunk/rdbmp.c
index fd773d4..be32e43 100644
--- a/trunk/rdbmp.c
+++ b/trunk/rdbmp.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2010 by Guido Vollbeding.
+ * Modified 2011 by Siarhei Siamashka.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -220,10 +221,9 @@ preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
{
bmp_source_ptr source = (bmp_source_ptr) sinfo;
register FILE *infile = source->pub.input_file;
- register int c;
register JSAMPROW out_ptr;
JSAMPARRAY image_ptr;
- JDIMENSION row, col;
+ JDIMENSION row;
cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress;
/* Read the data into a virtual array in input-file row order. */
@@ -237,11 +237,11 @@ preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
((j_common_ptr) cinfo, source->whole_image,
row, (JDIMENSION) 1, TRUE);
out_ptr = image_ptr[0];
- for (col = source->row_width; col > 0; col--) {
- /* inline copy of read_byte() for speed */
- if ((c = getc(infile)) == EOF)
- ERREXIT(cinfo, JERR_INPUT_EOF);
- *out_ptr++ = (JSAMPLE) c;
+ if (fread(out_ptr, 1, source->row_width, infile) != source->row_width) {
+ if (feof(infile))
+ ERREXIT(cinfo, JERR_INPUT_EOF);
+ else
+ ERREXIT(cinfo, JERR_FILE_READ);
}
}
if (progress != NULL)