@@ -539,7 +539,8 @@ main (int argc, char **argv)
/* Adjust default decompression parameters by re-parsing the options */
file_index = parse_switches(&cinfo, argc, argv, 0, TRUE);
- if (cinfo.jpeg_color_space == JCS_CMYK) {
+ if ((cinfo.jpeg_color_space == JCS_CMYK) ||
+ (cinfo.jpeg_color_space == JCS_YCCK)) {
cinfo.out_color_space = JCS_RGB;
}
old mode 100755
new mode 100644
@@ -195,6 +195,70 @@ cmyk_rgb_convert (j_decompress_ptr cinfo,
}
}
+/*
+ * 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;
+ double 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;
+
+ /* 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 = (double)GETJSAMPLE(inptr3[col]);
+
+ /********* Convert YCCK to CMYK **********/
+ /* Range-limiting is essential due to noise introduced by DCT
losses. */
+ outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])];
+ outptr[1] = range_limit[MAXJSAMPLE - (y +
+ ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS)))];
+ outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])];
+ /* K passes through unchanged */
+ outptr[3] = inptr3[col]; /* don't need GETJSAMPLE here */
+
+ cyan = (double)GETJSAMPLE(outptr[0]);
+ magenta = (double)GETJSAMPLE(outptr[1]);
+ yellow = (double)GETJSAMPLE(outptr[2]);
+ //Black is same as in YCCK input
+
+ /********* Convert CMYK to RGB **********/
+ outptr[RGB_RED] = (JSAMPLE)(cyan*black/255);
+ outptr[RGB_GREEN] = (JSAMPLE)(magenta*black/255);
+ outptr[RGB_BLUE] = (JSAMPLE)(yellow*black/255);
+
+ outptr += RGB_PIXELSIZE;
+ }
+ }
+}
+
/**************** Cases other than YCbCr -> RGB **************/
From 956e469c1fa2bb20f9782cd3674857eb08ec12a7 Mon Sep 17 00:00:00 2001 From: Mandeep Kumar <mandeep.kumar@linaro.org> Date: Wed, 4 May 2011 11:54:12 -0500 Subject: [PATCH] Added YCCK to RGB color conversion routines. --- djpeg.c | 3 +- jdcolor.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletions(-) mode change 100755 => 100644 jdcolor.c @@ -415,6 +479,9 @@ jinit_color_deconverter (j_decompress_ptr cinfo) } } 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 if (cinfo->jpeg_color_space == JCS_GRAYSCALE) { cconvert->pub.color_convert = gray_rgb_convert; } else if (cinfo->jpeg_color_space == cinfo->out_color_space &&