diff options
author | dcommander <dcommander@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2011-04-25 22:53:44 +0000 |
---|---|---|
committer | dcommander <dcommander@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2011-04-25 22:53:44 +0000 |
commit | 7e365dbfcba7103bc89748e3af5b1ea9fc279f2d (patch) | |
tree | 0e8a54749fb453cab35da92150348f7c23ec1940 /branches | |
parent | 76dab327f5a8f4876f1ba9176c28421d390e524f (diff) |
Eliminate excessive I/O overhead when reading BMP files in cjpeg
git-svn-id: https://libjpeg-turbo.svn.sourceforge.net/svnroot/libjpeg-turbo@595 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'branches')
-rw-r--r-- | branches/1.0.x/ChangeLog.txt | 3 | ||||
-rw-r--r-- | branches/1.0.x/rdbmp.c | 14 |
2 files changed, 10 insertions, 7 deletions
diff --git a/branches/1.0.x/ChangeLog.txt b/branches/1.0.x/ChangeLog.txt index 2a76ac5..6c3b935 100644 --- a/branches/1.0.x/ChangeLog.txt +++ b/branches/1.0.x/ChangeLog.txt @@ -34,6 +34,9 @@ underscore when building with MinGW64. This means that, when building libjpeg-turbo with older versions of MinGW64, you will now have to add -fno-leading-underscore to the CFLAGS. +[6] Eliminated excessive I/O overhead that occurred when reading BMP files in +cjpeg. + 1.0.1 ===== diff --git a/branches/1.0.x/rdbmp.c b/branches/1.0.x/rdbmp.c index b05fe2a..f22dfa6 100644 --- a/branches/1.0.x/rdbmp.c +++ b/branches/1.0.x/rdbmp.c @@ -2,6 +2,7 @@ * rdbmp.c * * Copyright (C) 1994-1996, Thomas G. Lane. + * 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. * @@ -188,10 +189,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. */ @@ -205,11 +205,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) |