]> granicus.if.org Git - libjpeg-turbo/commitdiff
TurboJPEG: Handle CMYK JPEGs w/ subsampled M, Y
authorDRC <information@libjpeg-turbo.org>
Thu, 26 Apr 2018 23:01:52 +0000 (18:01 -0500)
committerDRC <information@libjpeg-turbo.org>
Thu, 26 Apr 2018 23:20:55 +0000 (18:20 -0500)
Arguably it doesn't make much sense for non-chroma components to be
subsampled (which is why this type of image was overlooked in
cd7c3e6672cce3779450c6dd10d0d70b0c2278b2-- I didn't realize it was a
thing), but certain Adobe applications apparently generate these images.

Fixes #236

ChangeLog.md
tjbench.c
turbojpeg.c

index d6998d8cc96cd90df1bcf57fc07328a1d28483fc..bf63eb2dce8f9a5f12f3039103d8bf5a10d8f41d 100644 (file)
@@ -1,6 +1,8 @@
 1.5.4
 =====
 
+### Significant changes relative to 1.5.3:
+
 1. Fixed two signed integer overflows in the arithmetic decoder, detected by
 the Clang undefined behavior sanitizer, that could be triggered by attempting
 to decompress a specially-crafted malformed JPEG image.  These issues did not
@@ -14,6 +16,14 @@ now produces bitwise-identical results to the unmerged algorithms.
 3. Fixed a build error when building with older MinGW releases (regression
 caused by 1.5.1[7].)
 
+4. The TurboJPEG API can now decompress CMYK JPEG images that have subsampled M
+and Y components (not to be confused with YCCK JPEG images, in which the C/M/Y
+components have been transformed into luma and chroma.)   Previously, an error
+was generated ("Could not determine subsampling type for JPEG image") when such
+an image was passed to `tjDecompressHeader3()`, `tjTransform()`,
+`tjDecompressToYUVPlanes()`, `tjDecompressToYUV2()`, or the equivalent Java
+methods.
+
 
 1.5.3
 =====
index 76b61cdf2fe22f0944da145d9edd116f70920f09..1cf1cb14ca9dc9017cb0d59302a4076928290a80 100644 (file)
--- a/tjbench.c
+++ b/tjbench.c
@@ -70,7 +70,7 @@ double benchtime=5.0, warmup=1.0;
 char *formatName(int subsamp, int cs, char *buf)
 {
        if(cs==TJCS_YCbCr) return (char *)subNameLong[subsamp];
-       else if(cs==TJCS_YCCK)
+       else if(cs==TJCS_YCCK || cs==TJCS_CMYK)
        {
                snprintf(buf, 80, "%s %s", csName[cs], subNameLong[subsamp]);
                return buf;
index df907b09e6c4232a6b85fa2c9fda1249af8deac7..2aa05791c944bc2df9592664ea1f012904b19770 100644 (file)
@@ -355,7 +355,8 @@ static int getSubsamp(j_decompress_ptr dinfo)
                                for(k=1; k<dinfo->num_components; k++)
                                {
                                        int href=1, vref=1;
-                                       if(dinfo->jpeg_color_space==JCS_YCCK && k==3)
+                                       if((dinfo->jpeg_color_space==JCS_YCCK
+                                               || dinfo->jpeg_color_space==JCS_CMYK) && k==3)
                                        {
                                                href=tjMCUWidth[i]/8;  vref=tjMCUHeight[i]/8;
                                        }
@@ -378,7 +379,8 @@ static int getSubsamp(j_decompress_ptr dinfo)
                                for(k=1; k<dinfo->num_components; k++)
                                {
                                        int href=tjMCUHeight[i]/8, vref=tjMCUWidth[i]/8;
-                                       if(dinfo->jpeg_color_space==JCS_YCCK && k==3)
+                                       if((dinfo->jpeg_color_space==JCS_YCCK
+                                               || dinfo->jpeg_color_space==JCS_CMYK) && k==3)
                                        {
                                                href=vref=2;
                                        }