Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: third_party/libjpeg_turbo/rdbmp.c

Issue 7554002: Updates libjpeg-turbo to 1.1.90 (r677) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libjpeg_turbo/libjpeg.gyp ('k') | third_party/libjpeg_turbo/rdjpgcom.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/libjpeg_turbo/rdbmp.c
===================================================================
--- third_party/libjpeg_turbo/rdbmp.c (revision 95020)
+++ third_party/libjpeg_turbo/rdbmp.c (working copy)
@@ -2,6 +2,8 @@
* rdbmp.c
*
* 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.
*
@@ -177,10 +179,41 @@
}
+METHODDEF(JDIMENSION)
+get_32bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
+/* This version is for reading 32-bit pixels */
+{
+ bmp_source_ptr source = (bmp_source_ptr) sinfo;
+ JSAMPARRAY image_ptr;
+ register JSAMPROW inptr, outptr;
+ register JDIMENSION col;
+
+ /* Fetch next row from virtual array */
+ source->source_row--;
+ image_ptr = (*cinfo->mem->access_virt_sarray)
+ ((j_common_ptr) cinfo, source->whole_image,
+ source->source_row, (JDIMENSION) 1, FALSE);
+ /* Transfer data. Note source values are in BGR order
+ * (even though Microsoft's own documents say the opposite).
+ */
+ inptr = image_ptr[0];
+ outptr = source->pub.buffer[0];
+ for (col = cinfo->image_width; col > 0; col--) {
+ outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */
+ outptr[1] = *inptr++;
+ outptr[0] = *inptr++;
+ inptr++; /* skip the 4th byte (Alpha channel) */
+ outptr += 3;
+ }
+
+ return 1;
+}
+
+
/*
* This method loads the image into whole_image during the first call on
* get_pixel_rows. The get_pixel_rows pointer is then adjusted to call
- * get_8bit_row or get_24bit_row on subsequent calls.
+ * get_8bit_row, get_24bit_row, or get_32bit_row on subsequent calls.
*/
METHODDEF(JDIMENSION)
@@ -188,10 +221,9 @@
{
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 +237,11 @@
((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)
@@ -223,6 +255,9 @@
case 24:
source->pub.get_pixel_rows = get_24bit_row;
break;
+ case 32:
+ source->pub.get_pixel_rows = get_32bit_row;
+ break;
default:
ERREXIT(cinfo, JERR_BMP_BADDEPTH);
}
@@ -251,8 +286,8 @@
(((INT32) UCH(array[offset+3])) << 24))
INT32 bfOffBits;
INT32 headerSize;
- INT32 biWidth = 0; /* initialize to avoid compiler warning */
- INT32 biHeight = 0;
+ INT32 biWidth;
+ INT32 biHeight;
unsigned int biPlanes;
INT32 biCompression;
INT32 biXPelsPerMeter,biYPelsPerMeter;
@@ -300,8 +335,6 @@
ERREXIT(cinfo, JERR_BMP_BADDEPTH);
break;
}
- if (biPlanes != 1)
- ERREXIT(cinfo, JERR_BMP_BADPLANES);
break;
case 40:
case 64:
@@ -325,12 +358,13 @@
case 24: /* RGB image */
TRACEMS2(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight);
break;
+ case 32: /* RGB image + Alpha channel */
+ TRACEMS2(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight);
+ break;
default:
ERREXIT(cinfo, JERR_BMP_BADDEPTH);
break;
}
- if (biPlanes != 1)
- ERREXIT(cinfo, JERR_BMP_BADPLANES);
if (biCompression != 0)
ERREXIT(cinfo, JERR_BMP_COMPRESSED);
@@ -343,9 +377,14 @@
break;
default:
ERREXIT(cinfo, JERR_BMP_BADHEADER);
- break;
+ return;
}
+ if (biWidth <= 0 || biHeight <= 0)
+ ERREXIT(cinfo, JERR_BMP_EMPTY);
+ if (biPlanes != 1)
+ ERREXIT(cinfo, JERR_BMP_BADPLANES);
+
/* Compute distance to bitmap data --- will adjust for colormap below */
bPad = bfOffBits - (headerSize + 14);
@@ -375,6 +414,8 @@
/* Compute row width in file, including padding to 4-byte boundary */
if (source->bits_per_pixel == 24)
row_width = (JDIMENSION) (biWidth * 3);
+ else if (source->bits_per_pixel == 32)
+ row_width = (JDIMENSION) (biWidth * 4);
else
row_width = (JDIMENSION) biWidth;
while ((row_width & 3) != 0) row_width++;
« no previous file with comments | « third_party/libjpeg_turbo/libjpeg.gyp ('k') | third_party/libjpeg_turbo/rdjpgcom.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698