Doxygen Source Code Documentation
jdcolor.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
Go to the source code of this file.
Define Documentation
|
|
|
|
|
Definition at line 61 of file jdcolor.c. Referenced by build_ycc_rgb_table(). |
|
Definition at line 60 of file jdcolor.c. Referenced by build_ycc_rgb_table(), ycc_rgb_convert(), and ycck_cmyk_convert(). |
Typedef Documentation
|
|
Function Documentation
|
Definition at line 70 of file jdcolor.c. References my_color_deconverter::Cb_b_tab, my_color_deconverter::Cb_g_tab, jpeg_decompress_struct::cconvert, CENTERJSAMPLE, my_color_deconverter::Cr_g_tab, my_color_deconverter::Cr_r_tab, FIX, i, INT32, JPOOL_IMAGE, MAXJSAMPLE, ONE_HALF, RIGHT_SHIFT, SCALEBITS, and SIZEOF.
00071 { 00072 my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; 00073 int i; 00074 INT32 x; 00075 SHIFT_TEMPS 00076 00077 cconvert->Cr_r_tab = (int *) 00078 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 00079 (MAXJSAMPLE+1) * SIZEOF(int)); 00080 cconvert->Cb_b_tab = (int *) 00081 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 00082 (MAXJSAMPLE+1) * SIZEOF(int)); 00083 cconvert->Cr_g_tab = (INT32 *) 00084 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 00085 (MAXJSAMPLE+1) * SIZEOF(INT32)); 00086 cconvert->Cb_g_tab = (INT32 *) 00087 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 00088 (MAXJSAMPLE+1) * SIZEOF(INT32)); 00089 00090 for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { 00091 /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ 00092 /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ 00093 /* Cr=>R value is nearest int to 1.40200 * x */ 00094 cconvert->Cr_r_tab[i] = (int) 00095 RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); 00096 /* Cb=>B value is nearest int to 1.77200 * x */ 00097 cconvert->Cb_b_tab[i] = (int) 00098 RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); 00099 /* Cr=>G value is scaled-up -0.71414 * x */ 00100 cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x; 00101 /* Cb=>G value is scaled-up -0.34414 * x */ 00102 /* We also add in ONE_HALF so that need not do it in inner loop */ 00103 cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; 00104 } 00105 } |
|
Definition at line 217 of file jdcolor.c. References JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JSAMPROW, num_cols, num_rows, and jpeg_decompress_struct::output_width. Referenced by jinit_color_deconverter().
00220 { 00221 register JSAMPROW inptr, outptr; 00222 register JDIMENSION col; 00223 JDIMENSION num_cols = cinfo->output_width; 00224 00225 while (--num_rows >= 0) { 00226 inptr = input_buf[0][input_row++]; 00227 outptr = *output_buf++; 00228 for (col = 0; col < num_cols; col++) { 00229 /* We can dispense with GETJSAMPLE() here */ 00230 outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; 00231 outptr += RGB_PIXELSIZE; 00232 } 00233 } 00234 } |
|
Definition at line 201 of file jdcolor.c. References jcopy_sample_rows(), JDIMENSION, JSAMPARRAY, JSAMPIMAGE, num_rows, and jpeg_decompress_struct::output_width. Referenced by jinit_color_deconverter().
00204 { 00205 jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0, 00206 num_rows, cinfo->output_width); 00207 } |
|
Definition at line 304 of file jdcolor.c. References build_ycc_rgb_table(), ERREXIT, gray_rgb_convert(), grayscale_convert(), JCS_CMYK, JCS_GRAYSCALE, JCS_RGB, JCS_YCbCr, JCS_YCCK, JPOOL_IMAGE, null_convert(), SIZEOF, start_pass_dcolor(), ycc_rgb_convert(), and ycck_cmyk_convert(). Referenced by master_selection().
00305 { 00306 my_cconvert_ptr cconvert; 00307 int ci; 00308 00309 cconvert = (my_cconvert_ptr) 00310 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 00311 SIZEOF(my_color_deconverter)); 00312 cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert; 00313 cconvert->pub.start_pass = start_pass_dcolor; 00314 00315 /* Make sure num_components agrees with jpeg_color_space */ 00316 switch (cinfo->jpeg_color_space) { 00317 case JCS_GRAYSCALE: 00318 if (cinfo->num_components != 1) 00319 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); 00320 break; 00321 00322 case JCS_RGB: 00323 case JCS_YCbCr: 00324 if (cinfo->num_components != 3) 00325 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); 00326 break; 00327 00328 case JCS_CMYK: 00329 case JCS_YCCK: 00330 if (cinfo->num_components != 4) 00331 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); 00332 break; 00333 00334 default: /* JCS_UNKNOWN can be anything */ 00335 if (cinfo->num_components < 1) 00336 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); 00337 break; 00338 } 00339 00340 /* Set out_color_components and conversion method based on requested space. 00341 * Also clear the component_needed flags for any unused components, 00342 * so that earlier pipeline stages can avoid useless computation. 00343 */ 00344 00345 switch (cinfo->out_color_space) { 00346 case JCS_GRAYSCALE: 00347 cinfo->out_color_components = 1; 00348 if (cinfo->jpeg_color_space == JCS_GRAYSCALE || 00349 cinfo->jpeg_color_space == JCS_YCbCr) { 00350 cconvert->pub.color_convert = grayscale_convert; 00351 /* For color->grayscale conversion, only the Y (0) component is needed */ 00352 for (ci = 1; ci < cinfo->num_components; ci++) 00353 cinfo->comp_info[ci].component_needed = FALSE; 00354 } else 00355 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); 00356 break; 00357 00358 case JCS_RGB: 00359 cinfo->out_color_components = RGB_PIXELSIZE; 00360 if (cinfo->jpeg_color_space == JCS_YCbCr) { 00361 cconvert->pub.color_convert = ycc_rgb_convert; 00362 build_ycc_rgb_table(cinfo); 00363 } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) { 00364 cconvert->pub.color_convert = gray_rgb_convert; 00365 } else if (cinfo->jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) { 00366 cconvert->pub.color_convert = null_convert; 00367 } else 00368 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); 00369 break; 00370 00371 case JCS_CMYK: 00372 cinfo->out_color_components = 4; 00373 if (cinfo->jpeg_color_space == JCS_YCCK) { 00374 cconvert->pub.color_convert = ycck_cmyk_convert; 00375 build_ycc_rgb_table(cinfo); 00376 } else if (cinfo->jpeg_color_space == JCS_CMYK) { 00377 cconvert->pub.color_convert = null_convert; 00378 } else 00379 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); 00380 break; 00381 00382 default: 00383 /* Permit null conversion to same output space */ 00384 if (cinfo->out_color_space == cinfo->jpeg_color_space) { 00385 cinfo->out_color_components = cinfo->num_components; 00386 cconvert->pub.color_convert = null_convert; 00387 } else /* unsupported non-null conversion */ 00388 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); 00389 break; 00390 } 00391 00392 if (cinfo->quantize_colors) 00393 cinfo->output_components = 1; /* single colormapped output component */ 00394 else 00395 cinfo->output_components = cinfo->out_color_components; 00396 } |
|
Definition at line 169 of file jdcolor.c. References JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JSAMPROW, num_cols, jpeg_decompress_struct::num_components, num_rows, and jpeg_decompress_struct::output_width. Referenced by jinit_color_deconverter().
00172 { 00173 register JSAMPROW inptr, outptr; 00174 register JDIMENSION count; 00175 register int num_components = cinfo->num_components; 00176 JDIMENSION num_cols = cinfo->output_width; 00177 int ci; 00178 00179 while (--num_rows >= 0) { 00180 for (ci = 0; ci < num_components; ci++) { 00181 inptr = input_buf[ci][input_row]; 00182 outptr = output_buf[0] + ci; 00183 for (count = num_cols; count > 0; count--) { 00184 *outptr = *inptr++; /* needn't bother with GETJSAMPLE() here */ 00185 outptr += num_components; 00186 } 00187 } 00188 input_row++; 00189 output_buf++; 00190 } 00191 } |
|
Definition at line 293 of file jdcolor.c. Referenced by jinit_color_deconverter().
00294 {
00295 /* no work needed */
00296 }
|
|
Definition at line 120 of file jdcolor.c. References my_color_deconverter::Cb_b_tab, my_color_deconverter::Cb_g_tab, jpeg_decompress_struct::cconvert, my_color_deconverter::Cr_g_tab, my_color_deconverter::Cr_r_tab, GETJSAMPLE, INT32, JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JSAMPLE, JSAMPROW, num_cols, num_rows, jpeg_decompress_struct::output_width, RIGHT_SHIFT, jpeg_decompress_struct::sample_range_limit, and SCALEBITS. Referenced by jinit_color_deconverter().
00123 { 00124 my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; 00125 register int y, cb, cr; 00126 register JSAMPROW outptr; 00127 register JSAMPROW inptr0, inptr1, inptr2; 00128 register JDIMENSION col; 00129 JDIMENSION num_cols = cinfo->output_width; 00130 /* copy these pointers into registers if possible */ 00131 register JSAMPLE * range_limit = cinfo->sample_range_limit; 00132 register int * Crrtab = cconvert->Cr_r_tab; 00133 register int * Cbbtab = cconvert->Cb_b_tab; 00134 register INT32 * Crgtab = cconvert->Cr_g_tab; 00135 register INT32 * Cbgtab = cconvert->Cb_g_tab; 00136 SHIFT_TEMPS 00137 00138 while (--num_rows >= 0) { 00139 inptr0 = input_buf[0][input_row]; 00140 inptr1 = input_buf[1][input_row]; 00141 inptr2 = input_buf[2][input_row]; 00142 input_row++; 00143 outptr = *output_buf++; 00144 for (col = 0; col < num_cols; col++) { 00145 y = GETJSAMPLE(inptr0[col]); 00146 cb = GETJSAMPLE(inptr1[col]); 00147 cr = GETJSAMPLE(inptr2[col]); 00148 /* Range-limiting is essential due to noise introduced by DCT losses. */ 00149 outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; 00150 outptr[RGB_GREEN] = range_limit[y + 00151 ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], 00152 SCALEBITS))]; 00153 outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]]; 00154 outptr += RGB_PIXELSIZE; 00155 } 00156 } 00157 } |
|
Definition at line 245 of file jdcolor.c. References my_color_deconverter::Cb_b_tab, my_color_deconverter::Cb_g_tab, jpeg_decompress_struct::cconvert, my_color_deconverter::Cr_g_tab, my_color_deconverter::Cr_r_tab, GETJSAMPLE, INT32, JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JSAMPLE, JSAMPROW, MAXJSAMPLE, num_cols, num_rows, jpeg_decompress_struct::output_width, RIGHT_SHIFT, jpeg_decompress_struct::sample_range_limit, and SCALEBITS. Referenced by jinit_color_deconverter().
00248 { 00249 my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; 00250 register int y, cb, cr; 00251 register JSAMPROW outptr; 00252 register JSAMPROW inptr0, inptr1, inptr2, inptr3; 00253 register JDIMENSION col; 00254 JDIMENSION num_cols = cinfo->output_width; 00255 /* copy these pointers into registers if possible */ 00256 register JSAMPLE * range_limit = cinfo->sample_range_limit; 00257 register int * Crrtab = cconvert->Cr_r_tab; 00258 register int * Cbbtab = cconvert->Cb_b_tab; 00259 register INT32 * Crgtab = cconvert->Cr_g_tab; 00260 register INT32 * Cbgtab = cconvert->Cb_g_tab; 00261 SHIFT_TEMPS 00262 00263 while (--num_rows >= 0) { 00264 inptr0 = input_buf[0][input_row]; 00265 inptr1 = input_buf[1][input_row]; 00266 inptr2 = input_buf[2][input_row]; 00267 inptr3 = input_buf[3][input_row]; 00268 input_row++; 00269 outptr = *output_buf++; 00270 for (col = 0; col < num_cols; col++) { 00271 y = GETJSAMPLE(inptr0[col]); 00272 cb = GETJSAMPLE(inptr1[col]); 00273 cr = GETJSAMPLE(inptr2[col]); 00274 /* Range-limiting is essential due to noise introduced by DCT losses. */ 00275 outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */ 00276 outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */ 00277 ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], 00278 SCALEBITS)))]; 00279 outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */ 00280 /* K passes through unchanged */ 00281 outptr[3] = inptr3[col]; /* don't need GETJSAMPLE here */ 00282 outptr += 4; 00283 } 00284 } 00285 } |