From 36edad7a4e37999ac6c3b2cf9d2d51f385f4b626 Mon Sep 17 00:00:00 2001 From: DRC Date: Wed, 7 Sep 2011 02:32:02 +0000 Subject: [PATCH] Back out CMYK-to-RGB conversions. There is really no way to properly do CMYK-to-RGB conversion without color management, which is out of scope for libjpeg-turbo. Applications wishing to do a trivial conversion, such as was implemented in these routines, can simply request CMYK output and do the trivial conversion themselves (or, even better, use an OSS color management library.) We should not encourage the use of in-library CMYK-to-RGB conversion as a substitute for color management. git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@695 632fc199-4ca6-4c93-a231-07263d6284db --- ChangeLog.txt | 2 - jdcolor.c | 103 -------------------------------------------------- 2 files changed, 105 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 63790b1..b202309 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -60,8 +60,6 @@ worst-case JPEG size based on the level of chrominance subsampling. [16] Fixed 32-bit supplementary package for amd64 Debian systems which was broken by enhancements to the packaging system in 1.1. -[17] Support for decoding JPEG images that use the CMYK or YCCK colorspaces. - 1.1.1 ===== diff --git a/jdcolor.c b/jdcolor.c index f8b176e..0af024c 100644 --- a/jdcolor.c +++ b/jdcolor.c @@ -107,104 +107,6 @@ build_ycc_rgb_table (j_decompress_ptr cinfo) } } -/* - * Convert inverted CMYK to RGB - */ -METHODDEF(void) -cmyk_rgb_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - JSAMPLE cyan, magenta, yellow, black; - register JSAMPROW outptr; - register JSAMPROW inptr0, inptr1, inptr2, inptr3; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - int rindex = rgb_red[cinfo->out_color_space]; - int gindex = rgb_green[cinfo->out_color_space]; - int bindex = rgb_blue[cinfo->out_color_space]; - int rgbstride = rgb_pixelsize[cinfo->out_color_space]; - - while (--num_rows >= 0) { - inptr0 = input_buf[0][input_row]; - inptr1 = input_buf[1][input_row]; - inptr2 = input_buf[2][input_row]; - inptr3 = input_buf[3][input_row]; - input_row++; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - cyan = GETJSAMPLE(inptr0[col]); - magenta = GETJSAMPLE(inptr1[col]); - yellow = GETJSAMPLE(inptr2[col]); - black = GETJSAMPLE(inptr3[col]); - - outptr[rindex] = (JSAMPLE)((int)cyan * (int)black / MAXJSAMPLE); - outptr[gindex] = (JSAMPLE)((int)magenta * (int)black / MAXJSAMPLE); - outptr[bindex] = (JSAMPLE)((int)yellow * (int)black / MAXJSAMPLE); - outptr += rgbstride; - } - } -} - -/* - * Convert YCCK to RGB - */ -METHODDEF(void) -ycck_rgb_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - JSAMPLE cyan, magenta, yellow, black; - register int y, cb, cr; - register JSAMPROW outptr; - register JSAMPROW inptr0, inptr1, inptr2, inptr3; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - int rindex = rgb_red[cinfo->out_color_space]; - int gindex = rgb_green[cinfo->out_color_space]; - int bindex = rgb_blue[cinfo->out_color_space]; - int rgbstride = rgb_pixelsize[cinfo->out_color_space]; - - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - register int * Crrtab = cconvert->Cr_r_tab; - register int * Cbbtab = cconvert->Cb_b_tab; - register INT32 * Crgtab = cconvert->Cr_g_tab; - register INT32 * Cbgtab = cconvert->Cb_g_tab; - SHIFT_TEMPS - - while (--num_rows >= 0) { - inptr0 = input_buf[0][input_row]; - inptr1 = input_buf[1][input_row]; - inptr2 = input_buf[2][input_row]; - inptr3 = input_buf[3][input_row]; - input_row++; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - - /********* Read YCCK Pixel **********/ - y = GETJSAMPLE(inptr0[col]); - cb = GETJSAMPLE(inptr1[col]); - cr = GETJSAMPLE(inptr2[col]); - black = GETJSAMPLE(inptr3[col]); - - /********* Convert YCCK to CMYK **********/ - /* Range-limiting is essential due to noise introduced by DCT losses. */ - cyan = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; - magenta = range_limit[MAXJSAMPLE - (y + - ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], - SCALEBITS)))]; - yellow = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; - - /********* Convert CMYK to RGB **********/ - outptr[rindex] = (JSAMPLE)((int)cyan * (int)black / MAXJSAMPLE); - outptr[gindex] = (JSAMPLE)((int)magenta * (int)black / MAXJSAMPLE); - outptr[bindex] = (JSAMPLE)((int)yellow * (int)black / MAXJSAMPLE); - outptr += rgbstride; - } - } -} /* * Convert some rows of samples to the output colorspace. @@ -484,11 +386,6 @@ jinit_color_deconverter (j_decompress_ptr cinfo) } else if (cinfo->jpeg_color_space == cinfo->out_color_space && rgb_pixelsize[cinfo->out_color_space] == 3) { cconvert->pub.color_convert = null_convert; - } else if (cinfo->jpeg_color_space == JCS_CMYK) { - cconvert->pub.color_convert = cmyk_rgb_convert; - } else if (cinfo->jpeg_color_space == JCS_YCCK) { - cconvert->pub.color_convert = ycck_rgb_convert; - build_ycc_rgb_table(cinfo); } else ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); break; -- 2.40.0