summaryrefslogtreecommitdiff
path: root/plugins/AdvaImg/src/LibJPEG/jdmaster.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/AdvaImg/src/LibJPEG/jdmaster.c')
-rw-r--r--plugins/AdvaImg/src/LibJPEG/jdmaster.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/plugins/AdvaImg/src/LibJPEG/jdmaster.c b/plugins/AdvaImg/src/LibJPEG/jdmaster.c
index 03d4dd08b8..ed6b499607 100644
--- a/plugins/AdvaImg/src/LibJPEG/jdmaster.c
+++ b/plugins/AdvaImg/src/LibJPEG/jdmaster.c
@@ -2,7 +2,7 @@
* jdmaster.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2002-2011 by Guido Vollbeding.
+ * Modified 2002-2013 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -51,7 +51,8 @@ use_merged_upsample (j_decompress_ptr cinfo)
/* jdmerge.c only supports YCC=>RGB color conversion */
if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||
cinfo->out_color_space != JCS_RGB ||
- cinfo->out_color_components != RGB_PIXELSIZE)
+ cinfo->out_color_components != RGB_PIXELSIZE ||
+ cinfo->color_transform)
return FALSE;
/* and it only handles 2h1v or 2h2v sampling ratios */
if (cinfo->comp_info[0].h_samp_factor != 2 ||
@@ -158,9 +159,11 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
cinfo->out_color_components = 1;
break;
case JCS_RGB:
+ case JCS_BG_RGB:
cinfo->out_color_components = RGB_PIXELSIZE;
break;
case JCS_YCbCr:
+ case JCS_BG_YCC:
cinfo->out_color_components = 3;
break;
case JCS_CMYK:
@@ -273,10 +276,19 @@ master_selection (j_decompress_ptr cinfo)
long samplesperrow;
JDIMENSION jd_samplesperrow;
+ /* For now, precision must match compiled-in value... */
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
/* Initialize dimensions and other stuff */
jpeg_calc_output_dimensions(cinfo);
prepare_range_limit_table(cinfo);
+ /* Sanity check on image dimensions */
+ if (cinfo->output_height <= 0 || cinfo->output_width <= 0 ||
+ cinfo->out_color_components <= 0)
+ ERREXIT(cinfo, JERR_EMPTY_IMAGE);
+
/* Width of an output scanline must be representable as JDIMENSION. */
samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components;
jd_samplesperrow = (JDIMENSION) samplesperrow;
@@ -521,7 +533,7 @@ jinit_master_decompress (j_decompress_ptr cinfo)
master = (my_master_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_decomp_master));
- cinfo->master = (struct jpeg_decomp_master *) master;
+ cinfo->master = &master->pub;
master->pub.prepare_for_output_pass = prepare_for_output_pass;
master->pub.finish_output_pass = finish_output_pass;