From c8fb758bc2b48f5a963cf93e9e44fc1ae9147ac0 Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 3 Feb 2012 06:55:26 +0000 Subject: [PATCH] Fix issue whereby libjpeg-turbo would report "fractional sampling not implemented" when attempting to use decompression scaling with a non-power-of-2 scaling ratio and a JPEG file that was compressed using an odd form of subsampling, such as 3x2. git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@774 632fc199-4ca6-4c93-a231-07263d6284db --- jdmaster.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/jdmaster.c b/jdmaster.c index 273b8d2..225e825 100644 --- a/jdmaster.c +++ b/jdmaster.c @@ -285,16 +285,16 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo) /* In selecting the actual DCT scaling for each component, we try to * scale up the chroma components via IDCT scaling rather than upsampling. * This saves time if the upsampler gets to use 1:1 scaling. - * Note this code assumes that the supported DCT scalings are powers of 2. + * Note this code adapts subsampling ratios which are powers of 2. */ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { int ssize = cinfo->_min_DCT_scaled_size; while (ssize < DCTSIZE && - (compptr->h_samp_factor * ssize * 2 <= - cinfo->max_h_samp_factor * cinfo->_min_DCT_scaled_size) && - (compptr->v_samp_factor * ssize * 2 <= - cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size)) { + ((cinfo->max_h_samp_factor * cinfo->_min_DCT_scaled_size) % + (compptr->h_samp_factor * ssize * 2) == 0) && + ((cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size) % + (compptr->v_samp_factor * ssize * 2) == 0)) { ssize = ssize * 2; } #if JPEG_LIB_VERSION >= 70 -- 2.49.0