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
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
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
=====
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;
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;
}
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;
}