Sometimes the sampling factors in grayscale images can be > 1 (for instance, if compressing using 'cjpeg -sample 2x2 -grayscale'.) Technically, sampling factors have no meaning with grayscale JPEGs, and the libjpeg decompressor ignores them in that case. Thus, the TurboJPEG decompressor should ignore them as well.
git-svn-id: svn://svn.code.sf.net/p/libjpeg-turbo/code/trunk@1417 632fc199-4ca6-4c93-a231-07263d6284db
This commit is contained in:
@@ -23,6 +23,15 @@ caused an exception to be thrown during finalization, if the close() method had
|
|||||||
already been called. The exception was caught, but it was still an expensive
|
already been called. The exception was caught, but it was still an expensive
|
||||||
operation.
|
operation.
|
||||||
|
|
||||||
|
[7] The TurboJPEG API previously generated an error ("Could not determine
|
||||||
|
subsampling type for JPEG image") when attempting to decompress grayscale JPEG
|
||||||
|
images that were compressed with a sampling factor other than 1 (for instance,
|
||||||
|
with 'cjpeg -grayscale -sample 2x2'). Subsampling technically has no meaning
|
||||||
|
with grayscale JPEGs, and thus the horizontal and vertical sampling factors
|
||||||
|
for such images are ignored by the decompressor. However, the TurboJPEG API
|
||||||
|
was being too rigid and was expecting the sampling factors to be equal to 1
|
||||||
|
before it treated the image as a grayscale JPEG.
|
||||||
|
|
||||||
|
|
||||||
1.3.90 (1.4 beta1)
|
1.3.90 (1.4 beta1)
|
||||||
==================
|
==================
|
||||||
|
|||||||
@@ -316,6 +316,14 @@ static int setDecompDefaults(struct jpeg_decompress_struct *dinfo,
|
|||||||
static int getSubsamp(j_decompress_ptr dinfo)
|
static int getSubsamp(j_decompress_ptr dinfo)
|
||||||
{
|
{
|
||||||
int retval=-1, i, k;
|
int retval=-1, i, k;
|
||||||
|
|
||||||
|
/* The sampling factors actually have no meaning with grayscale JPEG files,
|
||||||
|
and in fact it's possible to generate grayscale JPEGs with sampling
|
||||||
|
factors > 1 (even though those sampling factors are ignored by the
|
||||||
|
decompressor.) Thus, we need to treat grayscale as a special case. */
|
||||||
|
if(dinfo->num_components==1 && dinfo->jpeg_color_space==JCS_GRAYSCALE)
|
||||||
|
return TJSAMP_GRAY;
|
||||||
|
|
||||||
for(i=0; i<NUMSUBOPT; i++)
|
for(i=0; i<NUMSUBOPT; i++)
|
||||||
{
|
{
|
||||||
if(dinfo->num_components==pixelsize[i]
|
if(dinfo->num_components==pixelsize[i]
|
||||||
|
|||||||
Reference in New Issue
Block a user