Doxygen Source Code Documentation
jccolor.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
Go to the source code of this file.
Define Documentation
|
Definition at line 74 of file jccolor.c. Referenced by cmyk_ycck_convert(), rgb_ycc_convert(), and rgb_ycc_start(). |
|
Definition at line 77 of file jccolor.c. Referenced by cmyk_ycck_convert(), rgb_ycc_convert(), and rgb_ycc_start(). |
|
Definition at line 71 of file jccolor.c. Referenced by cmyk_ycck_convert(), rgb_gray_convert(), rgb_ycc_convert(), and rgb_ycc_start(). |
|
Definition at line 59 of file jccolor.c. Referenced by rgb_ycc_start(). |
|
Definition at line 61 of file jccolor.c. Referenced by build_ycc_rgb_table(), and rgb_ycc_start(). |
|
Definition at line 73 of file jccolor.c. Referenced by cmyk_ycck_convert(), rgb_ycc_convert(), and rgb_ycc_start(). |
|
Definition at line 76 of file jccolor.c. Referenced by cmyk_ycck_convert(), rgb_ycc_convert(), and rgb_ycc_start(). |
|
Definition at line 70 of file jccolor.c. Referenced by cmyk_ycck_convert(), rgb_gray_convert(), rgb_ycc_convert(), and rgb_ycc_start(). |
|
|
|
Definition at line 60 of file jccolor.c. Referenced by rgb_ycc_start(). |
|
Definition at line 72 of file jccolor.c. Referenced by cmyk_ycck_convert(), rgb_ycc_convert(), and rgb_ycc_start(). |
|
Definition at line 75 of file jccolor.c. Referenced by cmyk_ycck_convert(), and rgb_ycc_convert(). |
|
Definition at line 69 of file jccolor.c. Referenced by cmyk_ycck_convert(), rgb_gray_convert(), rgb_ycc_convert(), and rgb_ycc_start(). |
|
Definition at line 58 of file jccolor.c. Referenced by cmyk_ycck_convert(), rgb_gray_convert(), and rgb_ycc_convert(). |
|
Definition at line 78 of file jccolor.c. Referenced by rgb_ycc_start(). |
Typedef Documentation
|
|
Function Documentation
|
Definition at line 225 of file jccolor.c. References B_CB_OFF, B_CR_OFF, B_Y_OFF, jpeg_compress_struct::cconvert, G_CB_OFF, G_CR_OFF, G_Y_OFF, GETJSAMPLE, jpeg_compress_struct::image_width, INT32, JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JSAMPROW, MAXJSAMPLE, num_cols, num_rows, output_row, r, R_CB_OFF, R_CR_OFF, R_Y_OFF, and SCALEBITS. Referenced by jinit_color_converter().
00228 { 00229 my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; 00230 register int r, g, b; 00231 register INT32 * ctab = cconvert->rgb_ycc_tab; 00232 register JSAMPROW inptr; 00233 register JSAMPROW outptr0, outptr1, outptr2, outptr3; 00234 register JDIMENSION col; 00235 JDIMENSION num_cols = cinfo->image_width; 00236 00237 while (--num_rows >= 0) { 00238 inptr = *input_buf++; 00239 outptr0 = output_buf[0][output_row]; 00240 outptr1 = output_buf[1][output_row]; 00241 outptr2 = output_buf[2][output_row]; 00242 outptr3 = output_buf[3][output_row]; 00243 output_row++; 00244 for (col = 0; col < num_cols; col++) { 00245 r = MAXJSAMPLE - GETJSAMPLE(inptr[0]); 00246 g = MAXJSAMPLE - GETJSAMPLE(inptr[1]); 00247 b = MAXJSAMPLE - GETJSAMPLE(inptr[2]); 00248 /* K passes through as-is */ 00249 outptr3[col] = inptr[3]; /* don't need GETJSAMPLE here */ 00250 inptr += 4; 00251 /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations 00252 * must be too; we do not need an explicit range-limiting operation. 00253 * Hence the value being shifted is never negative, and we don't 00254 * need the general RIGHT_SHIFT macro. 00255 */ 00256 /* Y */ 00257 outptr0[col] = (JSAMPLE) 00258 ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) 00259 >> SCALEBITS); 00260 /* Cb */ 00261 outptr1[col] = (JSAMPLE) 00262 ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) 00263 >> SCALEBITS); 00264 /* Cr */ 00265 outptr2[col] = (JSAMPLE) 00266 ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) 00267 >> SCALEBITS); 00268 } 00269 } 00270 } |
|
Definition at line 280 of file jccolor.c. References jpeg_compress_struct::image_width, jpeg_compress_struct::input_components, JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JSAMPROW, num_cols, num_rows, and output_row. Referenced by jinit_color_converter().
00283 { 00284 register JSAMPROW inptr; 00285 register JSAMPROW outptr; 00286 register JDIMENSION col; 00287 JDIMENSION num_cols = cinfo->image_width; 00288 int instride = cinfo->input_components; 00289 00290 while (--num_rows >= 0) { 00291 inptr = *input_buf++; 00292 outptr = output_buf[0][output_row]; 00293 output_row++; 00294 for (col = 0; col < num_cols; col++) { 00295 outptr[col] = inptr[0]; /* don't need GETJSAMPLE() here */ 00296 inptr += instride; 00297 } 00298 } 00299 } |
|
Definition at line 352 of file jccolor.c. References cmyk_ycck_convert(), ERREXIT, grayscale_convert(), JCS_CMYK, JCS_GRAYSCALE, JCS_RGB, JCS_YCbCr, JCS_YCCK, JPOOL_IMAGE, null_convert(), null_method(), rgb_gray_convert(), rgb_ycc_convert(), rgb_ycc_start(), and SIZEOF. Referenced by jinit_compress_master().
00353 { 00354 my_cconvert_ptr cconvert; 00355 00356 cconvert = (my_cconvert_ptr) 00357 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 00358 SIZEOF(my_color_converter)); 00359 cinfo->cconvert = (struct jpeg_color_converter *) cconvert; 00360 /* set start_pass to null method until we find out differently */ 00361 cconvert->pub.start_pass = null_method; 00362 00363 /* Make sure input_components agrees with in_color_space */ 00364 switch (cinfo->in_color_space) { 00365 case JCS_GRAYSCALE: 00366 if (cinfo->input_components != 1) 00367 ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); 00368 break; 00369 00370 case JCS_RGB: 00371 #if RGB_PIXELSIZE != 3 00372 if (cinfo->input_components != RGB_PIXELSIZE) 00373 ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); 00374 break; 00375 #endif /* else share code with YCbCr */ 00376 00377 case JCS_YCbCr: 00378 if (cinfo->input_components != 3) 00379 ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); 00380 break; 00381 00382 case JCS_CMYK: 00383 case JCS_YCCK: 00384 if (cinfo->input_components != 4) 00385 ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); 00386 break; 00387 00388 default: /* JCS_UNKNOWN can be anything */ 00389 if (cinfo->input_components < 1) 00390 ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); 00391 break; 00392 } 00393 00394 /* Check num_components, set conversion method based on requested space */ 00395 switch (cinfo->jpeg_color_space) { 00396 case JCS_GRAYSCALE: 00397 if (cinfo->num_components != 1) 00398 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); 00399 if (cinfo->in_color_space == JCS_GRAYSCALE) 00400 cconvert->pub.color_convert = grayscale_convert; 00401 else if (cinfo->in_color_space == JCS_RGB) { 00402 cconvert->pub.start_pass = rgb_ycc_start; 00403 cconvert->pub.color_convert = rgb_gray_convert; 00404 } else if (cinfo->in_color_space == JCS_YCbCr) 00405 cconvert->pub.color_convert = grayscale_convert; 00406 else 00407 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); 00408 break; 00409 00410 case JCS_RGB: 00411 if (cinfo->num_components != 3) 00412 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); 00413 if (cinfo->in_color_space == JCS_RGB && RGB_PIXELSIZE == 3) 00414 cconvert->pub.color_convert = null_convert; 00415 else 00416 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); 00417 break; 00418 00419 case JCS_YCbCr: 00420 if (cinfo->num_components != 3) 00421 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); 00422 if (cinfo->in_color_space == JCS_RGB) { 00423 cconvert->pub.start_pass = rgb_ycc_start; 00424 cconvert->pub.color_convert = rgb_ycc_convert; 00425 } else if (cinfo->in_color_space == JCS_YCbCr) 00426 cconvert->pub.color_convert = null_convert; 00427 else 00428 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); 00429 break; 00430 00431 case JCS_CMYK: 00432 if (cinfo->num_components != 4) 00433 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); 00434 if (cinfo->in_color_space == JCS_CMYK) 00435 cconvert->pub.color_convert = null_convert; 00436 else 00437 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); 00438 break; 00439 00440 case JCS_YCCK: 00441 if (cinfo->num_components != 4) 00442 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); 00443 if (cinfo->in_color_space == JCS_CMYK) { 00444 cconvert->pub.start_pass = rgb_ycc_start; 00445 cconvert->pub.color_convert = cmyk_ycck_convert; 00446 } else if (cinfo->in_color_space == JCS_YCCK) 00447 cconvert->pub.color_convert = null_convert; 00448 else 00449 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); 00450 break; 00451 00452 default: /* allow null conversion of JCS_UNKNOWN */ 00453 if (cinfo->jpeg_color_space != cinfo->in_color_space || 00454 cinfo->num_components != cinfo->input_components) 00455 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); 00456 cconvert->pub.color_convert = null_convert; 00457 break; 00458 } 00459 } |
|
Definition at line 309 of file jccolor.c. References jpeg_compress_struct::image_width, JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JSAMPROW, nc, num_cols, jpeg_compress_struct::num_components, num_rows, and output_row. Referenced by jinit_color_converter().
00312 { 00313 register JSAMPROW inptr; 00314 register JSAMPROW outptr; 00315 register JDIMENSION col; 00316 register int ci; 00317 int nc = cinfo->num_components; 00318 JDIMENSION num_cols = cinfo->image_width; 00319 00320 while (--num_rows >= 0) { 00321 /* It seems fastest to make a separate pass for each component. */ 00322 for (ci = 0; ci < nc; ci++) { 00323 inptr = *input_buf; 00324 outptr = output_buf[ci][output_row]; 00325 for (col = 0; col < num_cols; col++) { 00326 outptr[col] = inptr[ci]; /* don't need GETJSAMPLE() here */ 00327 inptr += nc; 00328 } 00329 } 00330 input_buf++; 00331 output_row++; 00332 } 00333 } |
|
Definition at line 341 of file jccolor.c. Referenced by jinit_color_converter().
00342 {
00343 /* no work needed */
00344 }
|
|
Definition at line 186 of file jccolor.c. References B_Y_OFF, jpeg_compress_struct::cconvert, G_Y_OFF, GETJSAMPLE, jpeg_compress_struct::image_width, INT32, JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JSAMPROW, num_cols, num_rows, output_row, r, R_Y_OFF, and SCALEBITS. Referenced by jinit_color_converter().
00189 { 00190 my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; 00191 register int r, g, b; 00192 register INT32 * ctab = cconvert->rgb_ycc_tab; 00193 register JSAMPROW inptr; 00194 register JSAMPROW outptr; 00195 register JDIMENSION col; 00196 JDIMENSION num_cols = cinfo->image_width; 00197 00198 while (--num_rows >= 0) { 00199 inptr = *input_buf++; 00200 outptr = output_buf[0][output_row]; 00201 output_row++; 00202 for (col = 0; col < num_cols; col++) { 00203 r = GETJSAMPLE(inptr[RGB_RED]); 00204 g = GETJSAMPLE(inptr[RGB_GREEN]); 00205 b = GETJSAMPLE(inptr[RGB_BLUE]); 00206 inptr += RGB_PIXELSIZE; 00207 /* Y */ 00208 outptr[col] = (JSAMPLE) 00209 ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) 00210 >> SCALEBITS); 00211 } 00212 } 00213 } |
|
Definition at line 130 of file jccolor.c. References B_CB_OFF, B_CR_OFF, B_Y_OFF, jpeg_compress_struct::cconvert, G_CB_OFF, G_CR_OFF, G_Y_OFF, GETJSAMPLE, jpeg_compress_struct::image_width, INT32, JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JSAMPROW, num_cols, num_rows, output_row, r, R_CB_OFF, R_CR_OFF, R_Y_OFF, and SCALEBITS. Referenced by jinit_color_converter().
00133 { 00134 my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; 00135 register int r, g, b; 00136 register INT32 * ctab = cconvert->rgb_ycc_tab; 00137 register JSAMPROW inptr; 00138 register JSAMPROW outptr0, outptr1, outptr2; 00139 register JDIMENSION col; 00140 JDIMENSION num_cols = cinfo->image_width; 00141 00142 while (--num_rows >= 0) { 00143 inptr = *input_buf++; 00144 outptr0 = output_buf[0][output_row]; 00145 outptr1 = output_buf[1][output_row]; 00146 outptr2 = output_buf[2][output_row]; 00147 output_row++; 00148 for (col = 0; col < num_cols; col++) { 00149 r = GETJSAMPLE(inptr[RGB_RED]); 00150 g = GETJSAMPLE(inptr[RGB_GREEN]); 00151 b = GETJSAMPLE(inptr[RGB_BLUE]); 00152 inptr += RGB_PIXELSIZE; 00153 /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations 00154 * must be too; we do not need an explicit range-limiting operation. 00155 * Hence the value being shifted is never negative, and we don't 00156 * need the general RIGHT_SHIFT macro. 00157 */ 00158 /* Y */ 00159 outptr0[col] = (JSAMPLE) 00160 ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) 00161 >> SCALEBITS); 00162 /* Cb */ 00163 outptr1[col] = (JSAMPLE) 00164 ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) 00165 >> SCALEBITS); 00166 /* Cr */ 00167 outptr2[col] = (JSAMPLE) 00168 ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) 00169 >> SCALEBITS); 00170 } 00171 } 00172 } |
|
Definition at line 86 of file jccolor.c. References B_CB_OFF, B_CR_OFF, B_Y_OFF, CBCR_OFFSET, jpeg_compress_struct::cconvert, FIX, G_CB_OFF, G_CR_OFF, G_Y_OFF, i, INT32, JPOOL_IMAGE, MAXJSAMPLE, ONE_HALF, R_CB_OFF, R_Y_OFF, SIZEOF, and TABLE_SIZE. Referenced by jinit_color_converter().
00087 { 00088 my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; 00089 INT32 * rgb_ycc_tab; 00090 INT32 i; 00091 00092 /* Allocate and fill in the conversion tables. */ 00093 cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *) 00094 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 00095 (TABLE_SIZE * SIZEOF(INT32))); 00096 00097 for (i = 0; i <= MAXJSAMPLE; i++) { 00098 rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i; 00099 rgb_ycc_tab[i+G_Y_OFF] = FIX(0.58700) * i; 00100 rgb_ycc_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF; 00101 rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.16874)) * i; 00102 rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.33126)) * i; 00103 /* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr. 00104 * This ensures that the maximum output will round to MAXJSAMPLE 00105 * not MAXJSAMPLE+1, and thus that we don't have to range-limit. 00106 */ 00107 rgb_ycc_tab[i+B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; 00108 /* B=>Cb and R=>Cr tables are the same 00109 rgb_ycc_tab[i+R_CR_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; 00110 */ 00111 rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.41869)) * i; 00112 rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.08131)) * i; 00113 } 00114 } |