From patchwork Thu Jun 2 13:32:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mandeep Kumar X-Patchwork-Id: 1726 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:54:58 -0000 Delivered-To: patches@linaro.org Received: by 10.52.181.10 with SMTP id ds10cs369975vdc; Thu, 2 Jun 2011 06:32:38 -0700 (PDT) Received: by 10.42.144.199 with SMTP id c7mr1420720icv.384.1307021558477; Thu, 02 Jun 2011 06:32:38 -0700 (PDT) Received: from mail-pw0-f50.google.com (mail-pw0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id z6si3197953icw.153.2011.06.02.06.32.36 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 02 Jun 2011 06:32:38 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of mandeep.kumar@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of mandeep.kumar@linaro.org) smtp.mail=mandeep.kumar@linaro.org Received: by pwi3 with SMTP id 3so585081pwi.37 for ; Thu, 02 Jun 2011 06:32:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.36.199 with SMTP id s7mr286365pbj.131.1307021556471; Thu, 02 Jun 2011 06:32:36 -0700 (PDT) Received: by 10.142.143.8 with HTTP; Thu, 2 Jun 2011 06:32:36 -0700 (PDT) Date: Thu, 2 Jun 2011 08:32:36 -0500 Message-ID: Subject: [PATCH] Added YCCK to RGB color conversion routines. From: Mandeep Kumar To: Kurt Taylor , Rob Clark , Rony Nandy , Kan Hu , Feng Wei , Vishal Raj , Benjamin Gaignard , Sudip Jain Cc: Patch Tracking >From 956e469c1fa2bb20f9782cd3674857eb08ec12a7 Mon Sep 17 00:00:00 2001 From: Mandeep Kumar 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 && diff --git a/djpeg.c b/djpeg.c index 4c8545e..b24694b 100755 --- a/djpeg.c +++ b/djpeg.c @@ -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; } diff --git a/jdcolor.c b/jdcolor.c old mode 100755 new mode 100644 index 4678467..9269ab6 --- a/jdcolor.c +++ b/jdcolor.c @@ -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 **************/