Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: jccolor.c

Issue 10386084: Update libjpeg-turbo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libjpeg_turbo/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « jccolext.c ('k') | jcdctmgr.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * jccolor.c 2 * jccolor.c
3 * 3 *
4 * Copyright (C) 1991-1996, Thomas G. Lane. 4 * Copyright (C) 1991-1996, Thomas G. Lane.
5 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB 5 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
6 * Copyright (C) 2009-2011, D. R. Commander. 6 * Copyright (C) 2009-2012, D. R. Commander.
7 * This file is part of the Independent JPEG Group's software. 7 * This file is part of the Independent JPEG Group's software.
8 * For conditions of distribution and use, see the accompanying README file. 8 * For conditions of distribution and use, see the accompanying README file.
9 * 9 *
10 * This file contains input colorspace conversion routines. 10 * This file contains input colorspace conversion routines.
11 */ 11 */
12 12
13 #define JPEG_INTERNALS 13 #define JPEG_INTERNALS
14 #include "jinclude.h" 14 #include "jinclude.h"
15 #include "jpeglib.h" 15 #include "jpeglib.h"
16 #include "jsimd.h" 16 #include "jsimd.h"
17 #include "config.h"
17 18
18 19
19 /* Private subobject */ 20 /* Private subobject */
20 21
21 typedef struct { 22 typedef struct {
22 struct jpeg_color_converter pub; /* public fields */ 23 struct jpeg_color_converter pub; /* public fields */
23 24
24 /* Private state for RGB->YCC conversion */ 25 /* Private state for RGB->YCC conversion */
25 INT32 * rgb_ycc_tab; /* => table for RGB to YCbCr conversion */ 26 INT32 * rgb_ycc_tab; /* => table for RGB to YCbCr conversion */
26 } my_color_converter; 27 } my_color_converter;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 #undef RGB_GREEN 89 #undef RGB_GREEN
89 #undef RGB_BLUE 90 #undef RGB_BLUE
90 #undef RGB_PIXELSIZE 91 #undef RGB_PIXELSIZE
91 92
92 #define RGB_RED EXT_RGB_RED 93 #define RGB_RED EXT_RGB_RED
93 #define RGB_GREEN EXT_RGB_GREEN 94 #define RGB_GREEN EXT_RGB_GREEN
94 #define RGB_BLUE EXT_RGB_BLUE 95 #define RGB_BLUE EXT_RGB_BLUE
95 #define RGB_PIXELSIZE EXT_RGB_PIXELSIZE 96 #define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
96 #define rgb_ycc_convert_internal extrgb_ycc_convert_internal 97 #define rgb_ycc_convert_internal extrgb_ycc_convert_internal
97 #define rgb_gray_convert_internal extrgb_gray_convert_internal 98 #define rgb_gray_convert_internal extrgb_gray_convert_internal
99 #define rgb_rgb_convert_internal extrgb_rgb_convert_internal
98 #include "jccolext.c" 100 #include "jccolext.c"
99 #undef RGB_RED 101 #undef RGB_RED
100 #undef RGB_GREEN 102 #undef RGB_GREEN
101 #undef RGB_BLUE 103 #undef RGB_BLUE
102 #undef RGB_PIXELSIZE 104 #undef RGB_PIXELSIZE
103 #undef rgb_ycc_convert_internal 105 #undef rgb_ycc_convert_internal
104 #undef rgb_gray_convert_internal 106 #undef rgb_gray_convert_internal
107 #undef rgb_rgb_convert_internal
105 108
106 #define RGB_RED EXT_RGBX_RED 109 #define RGB_RED EXT_RGBX_RED
107 #define RGB_GREEN EXT_RGBX_GREEN 110 #define RGB_GREEN EXT_RGBX_GREEN
108 #define RGB_BLUE EXT_RGBX_BLUE 111 #define RGB_BLUE EXT_RGBX_BLUE
109 #define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE 112 #define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
110 #define rgb_ycc_convert_internal extrgbx_ycc_convert_internal 113 #define rgb_ycc_convert_internal extrgbx_ycc_convert_internal
111 #define rgb_gray_convert_internal extrgbx_gray_convert_internal 114 #define rgb_gray_convert_internal extrgbx_gray_convert_internal
115 #define rgb_rgb_convert_internal extrgbx_rgb_convert_internal
112 #include "jccolext.c" 116 #include "jccolext.c"
113 #undef RGB_RED 117 #undef RGB_RED
114 #undef RGB_GREEN 118 #undef RGB_GREEN
115 #undef RGB_BLUE 119 #undef RGB_BLUE
116 #undef RGB_PIXELSIZE 120 #undef RGB_PIXELSIZE
117 #undef rgb_ycc_convert_internal 121 #undef rgb_ycc_convert_internal
118 #undef rgb_gray_convert_internal 122 #undef rgb_gray_convert_internal
123 #undef rgb_rgb_convert_internal
119 124
120 #define RGB_RED EXT_BGR_RED 125 #define RGB_RED EXT_BGR_RED
121 #define RGB_GREEN EXT_BGR_GREEN 126 #define RGB_GREEN EXT_BGR_GREEN
122 #define RGB_BLUE EXT_BGR_BLUE 127 #define RGB_BLUE EXT_BGR_BLUE
123 #define RGB_PIXELSIZE EXT_BGR_PIXELSIZE 128 #define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
124 #define rgb_ycc_convert_internal extbgr_ycc_convert_internal 129 #define rgb_ycc_convert_internal extbgr_ycc_convert_internal
125 #define rgb_gray_convert_internal extbgr_gray_convert_internal 130 #define rgb_gray_convert_internal extbgr_gray_convert_internal
131 #define rgb_rgb_convert_internal extbgr_rgb_convert_internal
126 #include "jccolext.c" 132 #include "jccolext.c"
127 #undef RGB_RED 133 #undef RGB_RED
128 #undef RGB_GREEN 134 #undef RGB_GREEN
129 #undef RGB_BLUE 135 #undef RGB_BLUE
130 #undef RGB_PIXELSIZE 136 #undef RGB_PIXELSIZE
131 #undef rgb_ycc_convert_internal 137 #undef rgb_ycc_convert_internal
132 #undef rgb_gray_convert_internal 138 #undef rgb_gray_convert_internal
139 #undef rgb_rgb_convert_internal
133 140
134 #define RGB_RED EXT_BGRX_RED 141 #define RGB_RED EXT_BGRX_RED
135 #define RGB_GREEN EXT_BGRX_GREEN 142 #define RGB_GREEN EXT_BGRX_GREEN
136 #define RGB_BLUE EXT_BGRX_BLUE 143 #define RGB_BLUE EXT_BGRX_BLUE
137 #define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE 144 #define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
138 #define rgb_ycc_convert_internal extbgrx_ycc_convert_internal 145 #define rgb_ycc_convert_internal extbgrx_ycc_convert_internal
139 #define rgb_gray_convert_internal extbgrx_gray_convert_internal 146 #define rgb_gray_convert_internal extbgrx_gray_convert_internal
147 #define rgb_rgb_convert_internal extbgrx_rgb_convert_internal
140 #include "jccolext.c" 148 #include "jccolext.c"
141 #undef RGB_RED 149 #undef RGB_RED
142 #undef RGB_GREEN 150 #undef RGB_GREEN
143 #undef RGB_BLUE 151 #undef RGB_BLUE
144 #undef RGB_PIXELSIZE 152 #undef RGB_PIXELSIZE
145 #undef rgb_ycc_convert_internal 153 #undef rgb_ycc_convert_internal
146 #undef rgb_gray_convert_internal 154 #undef rgb_gray_convert_internal
155 #undef rgb_rgb_convert_internal
147 156
148 #define RGB_RED EXT_XBGR_RED 157 #define RGB_RED EXT_XBGR_RED
149 #define RGB_GREEN EXT_XBGR_GREEN 158 #define RGB_GREEN EXT_XBGR_GREEN
150 #define RGB_BLUE EXT_XBGR_BLUE 159 #define RGB_BLUE EXT_XBGR_BLUE
151 #define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE 160 #define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
152 #define rgb_ycc_convert_internal extxbgr_ycc_convert_internal 161 #define rgb_ycc_convert_internal extxbgr_ycc_convert_internal
153 #define rgb_gray_convert_internal extxbgr_gray_convert_internal 162 #define rgb_gray_convert_internal extxbgr_gray_convert_internal
163 #define rgb_rgb_convert_internal extxbgr_rgb_convert_internal
154 #include "jccolext.c" 164 #include "jccolext.c"
155 #undef RGB_RED 165 #undef RGB_RED
156 #undef RGB_GREEN 166 #undef RGB_GREEN
157 #undef RGB_BLUE 167 #undef RGB_BLUE
158 #undef RGB_PIXELSIZE 168 #undef RGB_PIXELSIZE
159 #undef rgb_ycc_convert_internal 169 #undef rgb_ycc_convert_internal
160 #undef rgb_gray_convert_internal 170 #undef rgb_gray_convert_internal
171 #undef rgb_rgb_convert_internal
161 172
162 #define RGB_RED EXT_XRGB_RED 173 #define RGB_RED EXT_XRGB_RED
163 #define RGB_GREEN EXT_XRGB_GREEN 174 #define RGB_GREEN EXT_XRGB_GREEN
164 #define RGB_BLUE EXT_XRGB_BLUE 175 #define RGB_BLUE EXT_XRGB_BLUE
165 #define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE 176 #define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
166 #define rgb_ycc_convert_internal extxrgb_ycc_convert_internal 177 #define rgb_ycc_convert_internal extxrgb_ycc_convert_internal
167 #define rgb_gray_convert_internal extxrgb_gray_convert_internal 178 #define rgb_gray_convert_internal extxrgb_gray_convert_internal
179 #define rgb_rgb_convert_internal extxrgb_rgb_convert_internal
168 #include "jccolext.c" 180 #include "jccolext.c"
169 #undef RGB_RED 181 #undef RGB_RED
170 #undef RGB_GREEN 182 #undef RGB_GREEN
171 #undef RGB_BLUE 183 #undef RGB_BLUE
172 #undef RGB_PIXELSIZE 184 #undef RGB_PIXELSIZE
173 #undef rgb_ycc_convert_internal 185 #undef rgb_ycc_convert_internal
174 #undef rgb_gray_convert_internal 186 #undef rgb_gray_convert_internal
187 #undef rgb_rgb_convert_internal
175 188
176 189
177 /* 190 /*
178 * Initialize for RGB->YCC colorspace conversion. 191 * Initialize for RGB->YCC colorspace conversion.
179 */ 192 */
180 193
181 METHODDEF(void) 194 METHODDEF(void)
182 rgb_ycc_start (j_compress_ptr cinfo) 195 rgb_ycc_start (j_compress_ptr cinfo)
183 { 196 {
184 my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; 197 my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 break; 312 break;
300 default: 313 default:
301 rgb_gray_convert_internal(cinfo, input_buf, output_buf, output_row, 314 rgb_gray_convert_internal(cinfo, input_buf, output_buf, output_row,
302 num_rows); 315 num_rows);
303 break; 316 break;
304 } 317 }
305 } 318 }
306 319
307 320
308 /* 321 /*
322 * Extended RGB to plain RGB conversion
323 */
324
325 METHODDEF(void)
326 rgb_rgb_convert (j_compress_ptr cinfo,
327 JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
328 JDIMENSION output_row, int num_rows)
329 {
330 switch (cinfo->in_color_space) {
331 case JCS_EXT_RGB:
332 extrgb_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
333 num_rows);
334 break;
335 case JCS_EXT_RGBX:
336 case JCS_EXT_RGBA:
337 extrgbx_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
338 num_rows);
339 break;
340 case JCS_EXT_BGR:
341 extbgr_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
342 num_rows);
343 break;
344 case JCS_EXT_BGRX:
345 case JCS_EXT_BGRA:
346 extbgrx_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
347 num_rows);
348 break;
349 case JCS_EXT_XBGR:
350 case JCS_EXT_ABGR:
351 extxbgr_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
352 num_rows);
353 break;
354 case JCS_EXT_XRGB:
355 case JCS_EXT_ARGB:
356 extxrgb_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
357 num_rows);
358 break;
359 default:
360 rgb_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
361 num_rows);
362 break;
363 }
364 }
365
366
367 /*
309 * Convert some rows of samples to the JPEG colorspace. 368 * Convert some rows of samples to the JPEG colorspace.
310 * This version handles Adobe-style CMYK->YCCK conversion, 369 * This version handles Adobe-style CMYK->YCCK conversion,
311 * where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same 370 * where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same
312 * conversion as above, while passing K (black) unchanged. 371 * conversion as above, while passing K (black) unchanged.
313 * We assume rgb_ycc_start has been called. 372 * We assume rgb_ycc_start has been called.
314 */ 373 */
315 374
316 METHODDEF(void) 375 METHODDEF(void)
317 cmyk_ycck_convert (j_compress_ptr cinfo, 376 cmyk_ycck_convert (j_compress_ptr cinfo,
318 JSAMPARRAY input_buf, JSAMPIMAGE output_buf, 377 JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 cconvert->pub.start_pass = rgb_ycc_start; 574 cconvert->pub.start_pass = rgb_ycc_start;
516 cconvert->pub.color_convert = rgb_gray_convert; 575 cconvert->pub.color_convert = rgb_gray_convert;
517 } 576 }
518 } else if (cinfo->in_color_space == JCS_YCbCr) 577 } else if (cinfo->in_color_space == JCS_YCbCr)
519 cconvert->pub.color_convert = grayscale_convert; 578 cconvert->pub.color_convert = grayscale_convert;
520 else 579 else
521 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); 580 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
522 break; 581 break;
523 582
524 case JCS_RGB: 583 case JCS_RGB:
525 case JCS_EXT_RGB:
526 case JCS_EXT_RGBX:
527 case JCS_EXT_BGR:
528 case JCS_EXT_BGRX:
529 case JCS_EXT_XBGR:
530 case JCS_EXT_XRGB:
531 case JCS_EXT_RGBA:
532 case JCS_EXT_BGRA:
533 case JCS_EXT_ABGR:
534 case JCS_EXT_ARGB:
535 if (cinfo->num_components != 3) 584 if (cinfo->num_components != 3)
536 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); 585 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
537 if (cinfo->in_color_space == cinfo->jpeg_color_space && 586 if (rgb_red[cinfo->in_color_space] == 0 &&
538 rgb_pixelsize[cinfo->in_color_space] == 3) 587 rgb_green[cinfo->in_color_space] == 1 &&
588 rgb_blue[cinfo->in_color_space] == 2 &&
589 rgb_pixelsize[cinfo->in_color_space] == 3)
539 cconvert->pub.color_convert = null_convert; 590 cconvert->pub.color_convert = null_convert;
591 else if (cinfo->in_color_space == JCS_RGB ||
592 cinfo->in_color_space == JCS_EXT_RGB ||
593 cinfo->in_color_space == JCS_EXT_RGBX ||
594 cinfo->in_color_space == JCS_EXT_BGR ||
595 cinfo->in_color_space == JCS_EXT_BGRX ||
596 cinfo->in_color_space == JCS_EXT_XBGR ||
597 cinfo->in_color_space == JCS_EXT_XRGB ||
598 cinfo->in_color_space == JCS_EXT_RGBA ||
599 cinfo->in_color_space == JCS_EXT_BGRA ||
600 cinfo->in_color_space == JCS_EXT_ABGR ||
601 cinfo->in_color_space == JCS_EXT_ARGB)
602 cconvert->pub.color_convert = rgb_rgb_convert;
540 else 603 else
541 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); 604 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
542 break; 605 break;
543 606
544 case JCS_YCbCr: 607 case JCS_YCbCr:
545 if (cinfo->num_components != 3) 608 if (cinfo->num_components != 3)
546 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); 609 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
547 if (cinfo->in_color_space == JCS_RGB || 610 if (cinfo->in_color_space == JCS_RGB ||
548 cinfo->in_color_space == JCS_EXT_RGB || 611 cinfo->in_color_space == JCS_EXT_RGB ||
549 cinfo->in_color_space == JCS_EXT_RGBX || 612 cinfo->in_color_space == JCS_EXT_RGBX ||
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 break; 652 break;
590 653
591 default: /* allow null conversion of JCS_UNKNOWN */ 654 default: /* allow null conversion of JCS_UNKNOWN */
592 if (cinfo->jpeg_color_space != cinfo->in_color_space || 655 if (cinfo->jpeg_color_space != cinfo->in_color_space ||
593 cinfo->num_components != cinfo->input_components) 656 cinfo->num_components != cinfo->input_components)
594 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); 657 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
595 cconvert->pub.color_convert = null_convert; 658 cconvert->pub.color_convert = null_convert;
596 break; 659 break;
597 } 660 }
598 } 661 }
OLDNEW
« no previous file with comments | « jccolext.c ('k') | jcdctmgr.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698