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

Unified Diff: rdbmp.c

Issue 1953443002: Update to libjpeg_turbo 1.4.90 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@master
Patch Set: Created 4 years, 7 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 | « mac/jsimdcfg.inc ('k') | rdcolmap.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: rdbmp.c
diff --git a/rdbmp.c b/rdbmp.c
index ba9f7280e2a7d1810034388dc4510cb28308594f..eaa708645fe065a5be257ceb0c4d45878b3003f5 100644
--- a/rdbmp.c
+++ b/rdbmp.c
@@ -6,7 +6,9 @@
* Modified 2009-2010 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Modified 2011 by Siarhei Siamashka.
- * For conditions of distribution and use, see the accompanying README file.
+ * Copyright (C) 2015, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
*
* This file contains routines to read input images in Microsoft "BMP"
* format (MS Windows 3.x, OS/2 1.x, and OS/2 2.x flavors).
@@ -24,7 +26,7 @@
* This code contributed by James Arthur Boucher.
*/
-#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
+#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#ifdef BMP_SUPPORTED
@@ -33,37 +35,37 @@
#ifdef HAVE_UNSIGNED_CHAR
typedef unsigned char U_CHAR;
-#define UCH(x) ((int) (x))
+#define UCH(x) ((int) (x))
#else /* !HAVE_UNSIGNED_CHAR */
-#ifdef CHAR_IS_UNSIGNED
+#ifdef __CHAR_UNSIGNED__
typedef char U_CHAR;
-#define UCH(x) ((int) (x))
+#define UCH(x) ((int) (x))
#else
typedef char U_CHAR;
-#define UCH(x) ((int) (x) & 0xFF)
+#define UCH(x) ((int) (x) & 0xFF)
#endif
#endif /* HAVE_UNSIGNED_CHAR */
-#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len)))
+#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len)))
/* Private version of data source object */
-typedef struct _bmp_source_struct * bmp_source_ptr;
+typedef struct _bmp_source_struct *bmp_source_ptr;
typedef struct _bmp_source_struct {
struct cjpeg_source_struct pub; /* public fields */
- j_compress_ptr cinfo; /* back link saves passing separate parm */
+ j_compress_ptr cinfo; /* back link saves passing separate parm */
- JSAMPARRAY colormap; /* BMP colormap (converted to my format) */
+ JSAMPARRAY colormap; /* BMP colormap (converted to my format) */
- jvirt_sarray_ptr whole_image; /* Needed to reverse row order */
- JDIMENSION source_row; /* Current source row number */
- JDIMENSION row_width; /* Physical width of scanlines in file */
+ jvirt_sarray_ptr whole_image; /* Needed to reverse row order */
+ JDIMENSION source_row; /* Current source row number */
+ JDIMENSION row_width; /* Physical width of scanlines in file */
- int bits_per_pixel; /* remembers 8- or 24-bit format */
+ int bits_per_pixel; /* remembers 8- or 24-bit format */
} bmp_source_struct;
@@ -140,7 +142,7 @@ get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
outptr = source->pub.buffer[0];
for (col = cinfo->image_width; col > 0; col--) {
t = GETJSAMPLE(*inptr++);
- *outptr++ = colormap[0][t]; /* can omit GETJSAMPLE() safely */
+ *outptr++ = colormap[0][t]; /* can omit GETJSAMPLE() safely */
*outptr++ = colormap[1][t];
*outptr++ = colormap[2][t];
}
@@ -170,7 +172,7 @@ get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
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[2] = *inptr++; /* can omit GETJSAMPLE() safely */
outptr[1] = *inptr++;
outptr[0] = *inptr++;
outptr += 3;
@@ -200,10 +202,10 @@ get_32bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
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[2] = *inptr++; /* can omit GETJSAMPLE() safely */
outptr[1] = *inptr++;
outptr[0] = *inptr++;
- inptr++; /* skip the 4th byte (Alpha channel) */
+ inptr++; /* skip the 4th byte (Alpha channel) */
outptr += 3;
}
@@ -279,22 +281,22 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
bmp_source_ptr source = (bmp_source_ptr) sinfo;
U_CHAR bmpfileheader[14];
U_CHAR bmpinfoheader[64];
-#define GET_2B(array,offset) ((unsigned int) UCH(array[offset]) + \
- (((unsigned int) UCH(array[offset+1])) << 8))
-#define GET_4B(array,offset) ((INT32) UCH(array[offset]) + \
- (((INT32) UCH(array[offset+1])) << 8) + \
- (((INT32) UCH(array[offset+2])) << 16) + \
- (((INT32) UCH(array[offset+3])) << 24))
- INT32 bfOffBits;
- INT32 headerSize;
- INT32 biWidth;
- INT32 biHeight;
- unsigned int biPlanes;
- INT32 biCompression;
- INT32 biXPelsPerMeter,biYPelsPerMeter;
- INT32 biClrUsed = 0;
- int mapentrysize = 0; /* 0 indicates no colormap */
- INT32 bPad;
+#define GET_2B(array,offset) ((unsigned short) UCH(array[offset]) + \
+ (((unsigned short) UCH(array[offset+1])) << 8))
+#define GET_4B(array,offset) ((unsigned int) UCH(array[offset]) + \
+ (((unsigned int) UCH(array[offset+1])) << 8) + \
+ (((unsigned int) UCH(array[offset+2])) << 16) + \
+ (((unsigned int) UCH(array[offset+3])) << 24))
+ unsigned int bfOffBits;
+ unsigned int headerSize;
+ int biWidth;
+ int biHeight;
+ unsigned short biPlanes;
+ unsigned int biCompression;
+ int biXPelsPerMeter,biYPelsPerMeter;
+ unsigned int biClrUsed = 0;
+ int mapentrysize = 0; /* 0 indicates no colormap */
+ int bPad;
JDIMENSION row_width;
/* Read and verify the bitmap file header */
@@ -302,7 +304,7 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
ERREXIT(cinfo, JERR_INPUT_EOF);
if (GET_2B(bmpfileheader,0) != 0x4D42) /* 'BM' */
ERREXIT(cinfo, JERR_BMP_NOT);
- bfOffBits = (INT32) GET_4B(bmpfileheader,10);
+ bfOffBits = GET_4B(bmpfileheader,10);
/* We ignore the remaining fileheader fields */
/* The infoheader might be 12 bytes (OS/2 1.x), 40 bytes (Windows),
@@ -310,27 +312,27 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
*/
if (! ReadOK(source->pub.input_file, bmpinfoheader, 4))
ERREXIT(cinfo, JERR_INPUT_EOF);
- headerSize = (INT32) GET_4B(bmpinfoheader,0);
+ headerSize = GET_4B(bmpinfoheader,0);
if (headerSize < 12 || headerSize > 64)
ERREXIT(cinfo, JERR_BMP_BADHEADER);
if (! ReadOK(source->pub.input_file, bmpinfoheader+4, headerSize-4))
ERREXIT(cinfo, JERR_INPUT_EOF);
- switch ((int) headerSize) {
+ switch (headerSize) {
case 12:
/* Decode OS/2 1.x header (Microsoft calls this a BITMAPCOREHEADER) */
- biWidth = (INT32) GET_2B(bmpinfoheader,4);
- biHeight = (INT32) GET_2B(bmpinfoheader,6);
+ biWidth = (int) GET_2B(bmpinfoheader,4);
+ biHeight = (int) GET_2B(bmpinfoheader,6);
biPlanes = GET_2B(bmpinfoheader,8);
source->bits_per_pixel = (int) GET_2B(bmpinfoheader,10);
switch (source->bits_per_pixel) {
- case 8: /* colormapped image */
- mapentrysize = 3; /* OS/2 uses RGBTRIPLE colormap */
- TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, (int) biWidth, (int) biHeight);
+ case 8: /* colormapped image */
+ mapentrysize = 3; /* OS/2 uses RGBTRIPLE colormap */
+ TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, biWidth, biHeight);
break;
- case 24: /* RGB image */
- TRACEMS2(cinfo, 1, JTRC_BMP_OS2, (int) biWidth, (int) biHeight);
+ case 24: /* RGB image */
+ TRACEMS2(cinfo, 1, JTRC_BMP_OS2, biWidth, biHeight);
break;
default:
ERREXIT(cinfo, JERR_BMP_BADDEPTH);
@@ -341,26 +343,26 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
case 64:
/* Decode Windows 3.x header (Microsoft calls this a BITMAPINFOHEADER) */
/* or OS/2 2.x header, which has additional fields that we ignore */
- biWidth = GET_4B(bmpinfoheader,4);
- biHeight = GET_4B(bmpinfoheader,8);
+ biWidth = (int) GET_4B(bmpinfoheader,4);
+ biHeight = (int) GET_4B(bmpinfoheader,8);
biPlanes = GET_2B(bmpinfoheader,12);
source->bits_per_pixel = (int) GET_2B(bmpinfoheader,14);
biCompression = GET_4B(bmpinfoheader,16);
- biXPelsPerMeter = GET_4B(bmpinfoheader,24);
- biYPelsPerMeter = GET_4B(bmpinfoheader,28);
+ biXPelsPerMeter = (int) GET_4B(bmpinfoheader,24);
+ biYPelsPerMeter = (int) GET_4B(bmpinfoheader,28);
biClrUsed = GET_4B(bmpinfoheader,32);
/* biSizeImage, biClrImportant fields are ignored */
switch (source->bits_per_pixel) {
- case 8: /* colormapped image */
- mapentrysize = 4; /* Windows uses RGBQUAD colormap */
- TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, (int) biWidth, (int) biHeight);
+ case 8: /* colormapped image */
+ mapentrysize = 4; /* Windows uses RGBQUAD colormap */
+ TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, biWidth, biHeight);
break;
- case 24: /* RGB image */
- TRACEMS2(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight);
+ case 24: /* RGB image */
+ TRACEMS2(cinfo, 1, JTRC_BMP, biWidth, biHeight);
break;
- case 32: /* RGB image + Alpha channel */
- TRACEMS2(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight);
+ case 32: /* RGB image + Alpha channel */
+ TRACEMS2(cinfo, 1, JTRC_BMP, biWidth, biHeight);
break;
default:
ERREXIT(cinfo, JERR_BMP_BADDEPTH);
@@ -373,7 +375,7 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* Set JFIF density parameters from the BMP data */
cinfo->X_density = (UINT16) (biXPelsPerMeter/100); /* 100 cm per meter */
cinfo->Y_density = (UINT16) (biYPelsPerMeter/100);
- cinfo->density_unit = 2; /* dots/cm */
+ cinfo->density_unit = 2; /* dots/cm */
}
break;
default:
@@ -392,7 +394,7 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* Read the colormap, if any */
if (mapentrysize > 0) {
if (biClrUsed <= 0)
- biClrUsed = 256; /* assume it's 256 */
+ biClrUsed = 256; /* assume it's 256 */
else if (biClrUsed > 256)
ERREXIT(cinfo, JERR_BMP_BADCMAP);
/* Allocate space to store the colormap */
@@ -406,7 +408,7 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
}
/* Skip any remaining pad bytes */
- if (bPad < 0) /* incorrect bfOffBits value? */
+ if (bPad < 0) /* incorrect bfOffBits value? */
ERREXIT(cinfo, JERR_BMP_BADHEADER);
while (--bPad >= 0) {
(void) read_byte(source);
@@ -469,8 +471,8 @@ jinit_read_bmp (j_compress_ptr cinfo)
/* Create module interface object */
source = (bmp_source_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
- SIZEOF(bmp_source_struct));
- source->cinfo = cinfo; /* make back link for subroutines */
+ sizeof(bmp_source_struct));
+ source->cinfo = cinfo; /* make back link for subroutines */
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
source->pub.start_input = start_input_bmp;
source->pub.finish_input = finish_input_bmp;
« no previous file with comments | « mac/jsimdcfg.inc ('k') | rdcolmap.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698