Update libjpeg-turbo to v2.0.90 (2.1 beta1)
Update Chromium's copy of libjpeg-turbo to the latest upstream
release (v2.0.90) and re-apply our local changes documented in
README.chromium.
Cherry-pick two additional changes from upstream to fix bugs found
by fuzzers:
1) https://github.com/libjpeg-turbo/libjpeg-turbo/commit/ccaba5d7894ecfb5a8f11e48d3f86e1f14d5a469
2) https://github.com/libjpeg-turbo/libjpeg-turbo/commit/c7ca521bc85b57d41d3ad4963c13fc0100481084
Significant changes provided by this update:
1) A large performance boost to JPEG encoding due to an improved
Huffman encoding implementation.
2) The complete removal of Arm Neon assembly code. This allows Arm's
control-flow integrity security features (Armv8.3-A Pointer
Authentication and Armv8.5-A Branch Target Identification) to be
switched on with the appropriate compiler flags.
Bug: 922430
Bug: b/135180511
Bug: 919548, 1145581
Change-Id: I319fcdc55b3fd5b219425c07a4e4a03587f4e06d
diff --git a/rdbmp.c b/rdbmp.c
index 51af237..6ba584a 100644
--- a/rdbmp.c
+++ b/rdbmp.c
@@ -12,7 +12,7 @@
*
* 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).
- * Currently, only 8-bit and 24-bit images are supported, not 1-bit or
+ * Currently, only 8-, 24-, and 32-bit images are supported, not 1-bit or
* 4-bit (feeding such low-depth images into JPEG would be silly anyway).
* Also, we don't support RLE-compressed files.
*
@@ -34,18 +34,8 @@
/* Macros to deal with unsigned chars as efficiently as compiler allows */
-#ifdef HAVE_UNSIGNED_CHAR
typedef unsigned char U_CHAR;
#define UCH(x) ((int)(x))
-#else /* !HAVE_UNSIGNED_CHAR */
-#ifdef __CHAR_UNSIGNED__
-typedef char U_CHAR;
-#define UCH(x) ((int)(x))
-#else
-typedef char U_CHAR;
-#define UCH(x) ((int)(x) & 0xFF)
-#endif
-#endif /* HAVE_UNSIGNED_CHAR */
#define ReadOK(file, buffer, len) \
@@ -71,7 +61,7 @@
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-, 24-, or 32-bit format */
int cmap_length; /* colormap length */
boolean use_inversion_array; /* TRUE = preload the whole image, which is
@@ -179,14 +169,14 @@
outptr = source->pub.buffer[0];
if (cinfo->in_color_space == JCS_GRAYSCALE) {
for (col = cinfo->image_width; col > 0; col--) {
- t = GETJSAMPLE(*inptr++);
+ t = *inptr++;
if (t >= cmaplen)
ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
*outptr++ = colormap[0][t];
}
} else if (cinfo->in_color_space == JCS_CMYK) {
for (col = cinfo->image_width; col > 0; col--) {
- t = GETJSAMPLE(*inptr++);
+ t = *inptr++;
if (t >= cmaplen)
ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
rgb_to_cmyk(colormap[0][t], colormap[1][t], colormap[2][t], outptr,
@@ -202,7 +192,7 @@
if (aindex >= 0) {
for (col = cinfo->image_width; col > 0; col--) {
- t = GETJSAMPLE(*inptr++);
+ t = *inptr++;
if (t >= cmaplen)
ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
outptr[rindex] = colormap[0][t];
@@ -213,7 +203,7 @@
}
} else {
for (col = cinfo->image_width; col > 0; col--) {
- t = GETJSAMPLE(*inptr++);
+ t = *inptr++;
if (t >= cmaplen)
ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
outptr[rindex] = colormap[0][t];
@@ -258,7 +248,6 @@
MEMCOPY(outptr, inptr, source->row_width);
} else if (cinfo->in_color_space == JCS_CMYK) {
for (col = cinfo->image_width; col > 0; col--) {
- /* can omit GETJSAMPLE() safely */
JSAMPLE b = *inptr++, g = *inptr++, r = *inptr++;
rgb_to_cmyk(r, g, b, outptr, outptr + 1, outptr + 2, outptr + 3);
outptr += 4;
@@ -272,7 +261,7 @@
if (aindex >= 0) {
for (col = cinfo->image_width; col > 0; col--) {
- outptr[bindex] = *inptr++; /* can omit GETJSAMPLE() safely */
+ outptr[bindex] = *inptr++;
outptr[gindex] = *inptr++;
outptr[rindex] = *inptr++;
outptr[aindex] = 0xFF;
@@ -280,7 +269,7 @@
}
} else {
for (col = cinfo->image_width; col > 0; col--) {
- outptr[bindex] = *inptr++; /* can omit GETJSAMPLE() safely */
+ outptr[bindex] = *inptr++;
outptr[gindex] = *inptr++;
outptr[rindex] = *inptr++;
outptr += ps;
@@ -323,7 +312,6 @@
MEMCOPY(outptr, inptr, source->row_width);
} else if (cinfo->in_color_space == JCS_CMYK) {
for (col = cinfo->image_width; col > 0; col--) {
- /* can omit GETJSAMPLE() safely */
JSAMPLE b = *inptr++, g = *inptr++, r = *inptr++;
rgb_to_cmyk(r, g, b, outptr, outptr + 1, outptr + 2, outptr + 3);
inptr++; /* skip the 4th byte (Alpha channel) */
@@ -338,7 +326,7 @@
if (aindex >= 0) {
for (col = cinfo->image_width; col > 0; col--) {
- outptr[bindex] = *inptr++; /* can omit GETJSAMPLE() safely */
+ outptr[bindex] = *inptr++;
outptr[gindex] = *inptr++;
outptr[rindex] = *inptr++;
outptr[aindex] = *inptr++;
@@ -346,7 +334,7 @@
}
} else {
for (col = cinfo->image_width; col > 0; col--) {
- outptr[bindex] = *inptr++; /* can omit GETJSAMPLE() safely */
+ outptr[bindex] = *inptr++;
outptr[gindex] = *inptr++;
outptr[rindex] = *inptr++;
inptr++; /* skip the 4th byte (Alpha channel) */
@@ -481,7 +469,9 @@
TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, biWidth, biHeight);
break;
case 24: /* RGB image */
- TRACEMS2(cinfo, 1, JTRC_BMP_OS2, biWidth, biHeight);
+ case 32: /* RGB image + Alpha channel */
+ TRACEMS3(cinfo, 1, JTRC_BMP_OS2, biWidth, biHeight,
+ source->bits_per_pixel);
break;
default:
ERREXIT(cinfo, JERR_BMP_BADDEPTH);
@@ -508,10 +498,8 @@
TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, biWidth, biHeight);
break;
case 24: /* RGB image */
- TRACEMS2(cinfo, 1, JTRC_BMP, biWidth, biHeight);
- break;
case 32: /* RGB image + Alpha channel */
- TRACEMS2(cinfo, 1, JTRC_BMP, biWidth, biHeight);
+ TRACEMS3(cinfo, 1, JTRC_BMP, biWidth, biHeight, source->bits_per_pixel);
break;
default:
ERREXIT(cinfo, JERR_BMP_BADDEPTH);