Chromium Code Reviews| Index: jdcolor.c |
| =================================================================== |
| --- jdcolor.c (revision 83675) |
| +++ jdcolor.c (working copy) |
| @@ -22,10 +22,10 @@ |
| struct jpeg_color_deconverter pub; /* public fields */ |
| /* Private state for YCC->RGB conversion */ |
| - int * Cr_r_tab; /* => table for Cr to R conversion */ |
| - int * Cb_b_tab; /* => table for Cb to B conversion */ |
| - INT32 * Cr_g_tab; /* => table for Cr to G conversion */ |
| - INT32 * Cb_g_tab; /* => table for Cb to G conversion */ |
| + int * Cr_r_tab; /* => table for Cr to R conversion */ |
| + int * Cb_b_tab; /* => table for Cb to B conversion */ |
| + INT32 * Cr_g_tab; /* => table for Cr to G conversion */ |
| + INT32 * Cb_g_tab; /* => table for Cb to G conversion */ |
| } my_color_deconverter; |
| typedef my_color_deconverter * my_cconvert_ptr; |
| @@ -37,9 +37,9 @@ |
| * YCbCr is defined per CCIR 601-1, except that Cb and Cr are |
| * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. |
| * The conversion equations to be implemented are therefore |
| - * R = Y + 1.40200 * Cr |
| - * G = Y - 0.34414 * Cb - 0.71414 * Cr |
| - * B = Y + 1.77200 * Cb |
| + * R = Y + 1.40200 * Cr |
| + * G = Y - 0.34414 * Cb - 0.71414 * Cr |
| + * B = Y + 1.77200 * Cb |
| * where Cb and Cr represent the incoming values less CENTERJSAMPLE. |
| * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) |
| * |
| @@ -60,9 +60,9 @@ |
| * together before rounding. |
| */ |
| -#define SCALEBITS 16 /* speediest right-shift on some machines */ |
| -#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) |
| -#define FIX(x) ((INT32) ((x) * (1L<<SCALEBITS) + 0.5)) |
| +#define SCALEBITS 16 /* speediest right-shift on some machines */ |
| +#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) |
| +#define FIX(x) ((INT32) ((x) * (1L<<SCALEBITS) + 0.5)) |
| /* |
| @@ -79,26 +79,26 @@ |
| cconvert->Cr_r_tab = (int *) |
| (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| - (MAXJSAMPLE+1) * SIZEOF(int)); |
| + (MAXJSAMPLE+1) * SIZEOF(int)); |
| cconvert->Cb_b_tab = (int *) |
| (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| - (MAXJSAMPLE+1) * SIZEOF(int)); |
| + (MAXJSAMPLE+1) * SIZEOF(int)); |
| cconvert->Cr_g_tab = (INT32 *) |
| (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| - (MAXJSAMPLE+1) * SIZEOF(INT32)); |
| + (MAXJSAMPLE+1) * SIZEOF(INT32)); |
| cconvert->Cb_g_tab = (INT32 *) |
| (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| - (MAXJSAMPLE+1) * SIZEOF(INT32)); |
| + (MAXJSAMPLE+1) * SIZEOF(INT32)); |
| for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { |
| /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ |
| /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ |
| /* Cr=>R value is nearest int to 1.40200 * x */ |
| cconvert->Cr_r_tab[i] = (int) |
| - RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); |
| + RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); |
| /* Cb=>B value is nearest int to 1.77200 * x */ |
| cconvert->Cb_b_tab[i] = (int) |
| - RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); |
| + RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); |
| /* Cr=>G value is scaled-up -0.71414 * x */ |
| cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x; |
| /* Cb=>G value is scaled-up -0.34414 * x */ |
| @@ -121,8 +121,8 @@ |
| METHODDEF(void) |
| ycc_rgb_convert (j_decompress_ptr cinfo, |
| - JSAMPIMAGE input_buf, JDIMENSION input_row, |
| - JSAMPARRAY output_buf, int num_rows) |
| + JSAMPIMAGE input_buf, JDIMENSION input_row, |
| + JSAMPARRAY output_buf, int num_rows) |
| { |
| my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; |
| register int y, cb, cr; |
| @@ -151,8 +151,8 @@ |
| /* Range-limiting is essential due to noise introduced by DCT losses. */ |
| outptr[rgb_red[cinfo->out_color_space]] = range_limit[y + Crrtab[cr]]; |
| outptr[rgb_green[cinfo->out_color_space]] = range_limit[y + |
| - ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
| - SCALEBITS))]; |
| + ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
| + SCALEBITS))]; |
| outptr[rgb_blue[cinfo->out_color_space]] = range_limit[y + Cbbtab[cb]]; |
| outptr += rgb_pixelsize[cinfo->out_color_space]; |
| } |
| @@ -170,8 +170,8 @@ |
| METHODDEF(void) |
| null_convert (j_decompress_ptr cinfo, |
| - JSAMPIMAGE input_buf, JDIMENSION input_row, |
| - JSAMPARRAY output_buf, int num_rows) |
| + JSAMPIMAGE input_buf, JDIMENSION input_row, |
| + JSAMPARRAY output_buf, int num_rows) |
| { |
| register JSAMPROW inptr, outptr; |
| register JDIMENSION count; |
| @@ -184,8 +184,8 @@ |
| inptr = input_buf[ci][input_row]; |
| outptr = output_buf[0] + ci; |
| for (count = num_cols; count > 0; count--) { |
| - *outptr = *inptr++; /* needn't bother with GETJSAMPLE() here */ |
| - outptr += num_components; |
| + *outptr = *inptr++; /* needn't bother with GETJSAMPLE() here */ |
| + outptr += num_components; |
| } |
| } |
| input_row++; |
| @@ -202,11 +202,11 @@ |
| METHODDEF(void) |
| grayscale_convert (j_decompress_ptr cinfo, |
| - JSAMPIMAGE input_buf, JDIMENSION input_row, |
| - JSAMPARRAY output_buf, int num_rows) |
| + JSAMPIMAGE input_buf, JDIMENSION input_row, |
| + JSAMPARRAY output_buf, int num_rows) |
| { |
| jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0, |
| - num_rows, cinfo->output_width); |
| + num_rows, cinfo->output_width); |
| } |
| @@ -218,12 +218,11 @@ |
| METHODDEF(void) |
| gray_rgb_convert (j_decompress_ptr cinfo, |
| - JSAMPIMAGE input_buf, JDIMENSION input_row, |
| - JSAMPARRAY output_buf, int num_rows) |
| + JSAMPIMAGE input_buf, JDIMENSION input_row, |
| + JSAMPARRAY output_buf, int num_rows) |
| { |
| register JSAMPROW inptr, outptr; |
| JSAMPLE *maxinptr; |
| - register JDIMENSION col; |
|
fbarchard
2011/07/08 08:11:03
This is the real change
|
| JDIMENSION num_cols = cinfo->output_width; |
| int rindex = rgb_red[cinfo->out_color_space]; |
| int gindex = rgb_green[cinfo->out_color_space]; |
| @@ -251,8 +250,8 @@ |
| METHODDEF(void) |
| ycck_cmyk_convert (j_decompress_ptr cinfo, |
| - JSAMPIMAGE input_buf, JDIMENSION input_row, |
| - JSAMPARRAY output_buf, int num_rows) |
| + JSAMPIMAGE input_buf, JDIMENSION input_row, |
| + JSAMPARRAY output_buf, int num_rows) |
| { |
| my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; |
| register int y, cb, cr; |
| @@ -280,13 +279,13 @@ |
| cb = GETJSAMPLE(inptr1[col]); |
| cr = GETJSAMPLE(inptr2[col]); |
| /* Range-limiting is essential due to noise introduced by DCT losses. */ |
| - outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */ |
| - outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */ |
| - ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
| - SCALEBITS)))]; |
| - outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */ |
| + outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */ |
| + outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */ |
| + ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
| + SCALEBITS)))]; |
| + outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */ |
| /* K passes through unchanged */ |
| - outptr[3] = inptr3[col]; /* don't need GETJSAMPLE here */ |
| + outptr[3] = inptr3[col]; /* don't need GETJSAMPLE here */ |
| outptr += 4; |
| } |
| } |
| @@ -316,7 +315,7 @@ |
| cconvert = (my_cconvert_ptr) |
| (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| - SIZEOF(my_color_deconverter)); |
| + SIZEOF(my_color_deconverter)); |
| cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert; |
| cconvert->pub.start_pass = start_pass_dcolor; |
| @@ -339,7 +338,7 @@ |
| ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); |
| break; |
| - default: /* JCS_UNKNOWN can be anything */ |
| + default: /* JCS_UNKNOWN can be anything */ |
| if (cinfo->num_components < 1) |
| ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); |
| break; |
| @@ -354,11 +353,11 @@ |
| case JCS_GRAYSCALE: |
| cinfo->out_color_components = 1; |
| if (cinfo->jpeg_color_space == JCS_GRAYSCALE || |
| - cinfo->jpeg_color_space == JCS_YCbCr) { |
| + cinfo->jpeg_color_space == JCS_YCbCr) { |
| cconvert->pub.color_convert = grayscale_convert; |
| /* For color->grayscale conversion, only the Y (0) component is needed */ |
| for (ci = 1; ci < cinfo->num_components; ci++) |
| - cinfo->comp_info[ci].component_needed = FALSE; |
| + cinfo->comp_info[ci].component_needed = FALSE; |
| } else |
| ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); |
| break; |
| @@ -403,7 +402,7 @@ |
| if (cinfo->out_color_space == cinfo->jpeg_color_space) { |
| cinfo->out_color_components = cinfo->num_components; |
| cconvert->pub.color_convert = null_convert; |
| - } else /* unsupported non-null conversion */ |
| + } else /* unsupported non-null conversion */ |
| ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); |
| break; |
| } |