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

Side by Side Diff: jdcolor.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 | « jdcolext.c ('k') | jdct.h » ('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 * jdcolor.c 2 * jdcolor.c
3 * 3 *
4 * Copyright (C) 1991-1997, Thomas G. Lane. 4 * Copyright (C) 1991-1997, 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, 2011-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 output colorspace conversion routines. 10 * This file contains output 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_deconverter pub; /* public fields */ 23 struct jpeg_color_deconverter pub; /* public fields */
23 24
24 /* Private state for YCC->RGB conversion */ 25 /* Private state for YCC->RGB conversion */
25 int * Cr_r_tab; /* => table for Cr to R conversion */ 26 int * Cr_r_tab; /* => table for Cr to R conversion */
26 int * Cb_b_tab; /* => table for Cb to B conversion */ 27 int * Cb_b_tab; /* => table for Cb to B conversion */
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #undef RGB_GREEN 73 #undef RGB_GREEN
73 #undef RGB_BLUE 74 #undef RGB_BLUE
74 #undef RGB_PIXELSIZE 75 #undef RGB_PIXELSIZE
75 76
76 #define RGB_RED EXT_RGB_RED 77 #define RGB_RED EXT_RGB_RED
77 #define RGB_GREEN EXT_RGB_GREEN 78 #define RGB_GREEN EXT_RGB_GREEN
78 #define RGB_BLUE EXT_RGB_BLUE 79 #define RGB_BLUE EXT_RGB_BLUE
79 #define RGB_PIXELSIZE EXT_RGB_PIXELSIZE 80 #define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
80 #define ycc_rgb_convert_internal ycc_extrgb_convert_internal 81 #define ycc_rgb_convert_internal ycc_extrgb_convert_internal
81 #define gray_rgb_convert_internal gray_extrgb_convert_internal 82 #define gray_rgb_convert_internal gray_extrgb_convert_internal
83 #define rgb_rgb_convert_internal rgb_extrgb_convert_internal
82 #include "jdcolext.c" 84 #include "jdcolext.c"
83 #undef RGB_RED 85 #undef RGB_RED
84 #undef RGB_GREEN 86 #undef RGB_GREEN
85 #undef RGB_BLUE 87 #undef RGB_BLUE
86 #undef RGB_PIXELSIZE 88 #undef RGB_PIXELSIZE
87 #undef ycc_rgb_convert_internal 89 #undef ycc_rgb_convert_internal
88 #undef gray_rgb_convert_internal 90 #undef gray_rgb_convert_internal
91 #undef rgb_rgb_convert_internal
89 92
90 #define RGB_RED EXT_RGBX_RED 93 #define RGB_RED EXT_RGBX_RED
91 #define RGB_GREEN EXT_RGBX_GREEN 94 #define RGB_GREEN EXT_RGBX_GREEN
92 #define RGB_BLUE EXT_RGBX_BLUE 95 #define RGB_BLUE EXT_RGBX_BLUE
93 #define RGB_ALPHA 3 96 #define RGB_ALPHA 3
94 #define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE 97 #define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
95 #define ycc_rgb_convert_internal ycc_extrgbx_convert_internal 98 #define ycc_rgb_convert_internal ycc_extrgbx_convert_internal
96 #define gray_rgb_convert_internal gray_extrgbx_convert_internal 99 #define gray_rgb_convert_internal gray_extrgbx_convert_internal
100 #define rgb_rgb_convert_internal rgb_extrgbx_convert_internal
97 #include "jdcolext.c" 101 #include "jdcolext.c"
98 #undef RGB_RED 102 #undef RGB_RED
99 #undef RGB_GREEN 103 #undef RGB_GREEN
100 #undef RGB_BLUE 104 #undef RGB_BLUE
101 #undef RGB_ALPHA 105 #undef RGB_ALPHA
102 #undef RGB_PIXELSIZE 106 #undef RGB_PIXELSIZE
103 #undef ycc_rgb_convert_internal 107 #undef ycc_rgb_convert_internal
104 #undef gray_rgb_convert_internal 108 #undef gray_rgb_convert_internal
109 #undef rgb_rgb_convert_internal
105 110
106 #define RGB_RED EXT_BGR_RED 111 #define RGB_RED EXT_BGR_RED
107 #define RGB_GREEN EXT_BGR_GREEN 112 #define RGB_GREEN EXT_BGR_GREEN
108 #define RGB_BLUE EXT_BGR_BLUE 113 #define RGB_BLUE EXT_BGR_BLUE
109 #define RGB_PIXELSIZE EXT_BGR_PIXELSIZE 114 #define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
110 #define ycc_rgb_convert_internal ycc_extbgr_convert_internal 115 #define ycc_rgb_convert_internal ycc_extbgr_convert_internal
111 #define gray_rgb_convert_internal gray_extbgr_convert_internal 116 #define gray_rgb_convert_internal gray_extbgr_convert_internal
117 #define rgb_rgb_convert_internal rgb_extbgr_convert_internal
112 #include "jdcolext.c" 118 #include "jdcolext.c"
113 #undef RGB_RED 119 #undef RGB_RED
114 #undef RGB_GREEN 120 #undef RGB_GREEN
115 #undef RGB_BLUE 121 #undef RGB_BLUE
116 #undef RGB_PIXELSIZE 122 #undef RGB_PIXELSIZE
117 #undef ycc_rgb_convert_internal 123 #undef ycc_rgb_convert_internal
118 #undef gray_rgb_convert_internal 124 #undef gray_rgb_convert_internal
125 #undef rgb_rgb_convert_internal
119 126
120 #define RGB_RED EXT_BGRX_RED 127 #define RGB_RED EXT_BGRX_RED
121 #define RGB_GREEN EXT_BGRX_GREEN 128 #define RGB_GREEN EXT_BGRX_GREEN
122 #define RGB_BLUE EXT_BGRX_BLUE 129 #define RGB_BLUE EXT_BGRX_BLUE
123 #define RGB_ALPHA 3 130 #define RGB_ALPHA 3
124 #define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE 131 #define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
125 #define ycc_rgb_convert_internal ycc_extbgrx_convert_internal 132 #define ycc_rgb_convert_internal ycc_extbgrx_convert_internal
126 #define gray_rgb_convert_internal gray_extbgrx_convert_internal 133 #define gray_rgb_convert_internal gray_extbgrx_convert_internal
134 #define rgb_rgb_convert_internal rgb_extbgrx_convert_internal
127 #include "jdcolext.c" 135 #include "jdcolext.c"
128 #undef RGB_RED 136 #undef RGB_RED
129 #undef RGB_GREEN 137 #undef RGB_GREEN
130 #undef RGB_BLUE 138 #undef RGB_BLUE
131 #undef RGB_ALPHA 139 #undef RGB_ALPHA
132 #undef RGB_PIXELSIZE 140 #undef RGB_PIXELSIZE
133 #undef ycc_rgb_convert_internal 141 #undef ycc_rgb_convert_internal
134 #undef gray_rgb_convert_internal 142 #undef gray_rgb_convert_internal
143 #undef rgb_rgb_convert_internal
135 144
136 #define RGB_RED EXT_XBGR_RED 145 #define RGB_RED EXT_XBGR_RED
137 #define RGB_GREEN EXT_XBGR_GREEN 146 #define RGB_GREEN EXT_XBGR_GREEN
138 #define RGB_BLUE EXT_XBGR_BLUE 147 #define RGB_BLUE EXT_XBGR_BLUE
139 #define RGB_ALPHA 0 148 #define RGB_ALPHA 0
140 #define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE 149 #define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
141 #define ycc_rgb_convert_internal ycc_extxbgr_convert_internal 150 #define ycc_rgb_convert_internal ycc_extxbgr_convert_internal
142 #define gray_rgb_convert_internal gray_extxbgr_convert_internal 151 #define gray_rgb_convert_internal gray_extxbgr_convert_internal
152 #define rgb_rgb_convert_internal rgb_extxbgr_convert_internal
143 #include "jdcolext.c" 153 #include "jdcolext.c"
144 #undef RGB_RED 154 #undef RGB_RED
145 #undef RGB_GREEN 155 #undef RGB_GREEN
146 #undef RGB_BLUE 156 #undef RGB_BLUE
147 #undef RGB_ALPHA 157 #undef RGB_ALPHA
148 #undef RGB_PIXELSIZE 158 #undef RGB_PIXELSIZE
149 #undef ycc_rgb_convert_internal 159 #undef ycc_rgb_convert_internal
150 #undef gray_rgb_convert_internal 160 #undef gray_rgb_convert_internal
161 #undef rgb_rgb_convert_internal
151 162
152 #define RGB_RED EXT_XRGB_RED 163 #define RGB_RED EXT_XRGB_RED
153 #define RGB_GREEN EXT_XRGB_GREEN 164 #define RGB_GREEN EXT_XRGB_GREEN
154 #define RGB_BLUE EXT_XRGB_BLUE 165 #define RGB_BLUE EXT_XRGB_BLUE
155 #define RGB_ALPHA 0 166 #define RGB_ALPHA 0
156 #define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE 167 #define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
157 #define ycc_rgb_convert_internal ycc_extxrgb_convert_internal 168 #define ycc_rgb_convert_internal ycc_extxrgb_convert_internal
158 #define gray_rgb_convert_internal gray_extxrgb_convert_internal 169 #define gray_rgb_convert_internal gray_extxrgb_convert_internal
170 #define rgb_rgb_convert_internal rgb_extxrgb_convert_internal
159 #include "jdcolext.c" 171 #include "jdcolext.c"
160 #undef RGB_RED 172 #undef RGB_RED
161 #undef RGB_GREEN 173 #undef RGB_GREEN
162 #undef RGB_BLUE 174 #undef RGB_BLUE
163 #undef RGB_ALPHA 175 #undef RGB_ALPHA
164 #undef RGB_PIXELSIZE 176 #undef RGB_PIXELSIZE
165 #undef ycc_rgb_convert_internal 177 #undef ycc_rgb_convert_internal
166 #undef gray_rgb_convert_internal 178 #undef gray_rgb_convert_internal
179 #undef rgb_rgb_convert_internal
167 180
168 181
169 /* 182 /*
170 * Initialize tables for YCC->RGB colorspace conversion. 183 * Initialize tables for YCC->RGB colorspace conversion.
171 */ 184 */
172 185
173 LOCAL(void) 186 LOCAL(void)
174 build_ycc_rgb_table (j_decompress_ptr cinfo) 187 build_ycc_rgb_table (j_decompress_ptr cinfo)
175 { 188 {
176 my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; 189 my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 break; 358 break;
346 default: 359 default:
347 gray_rgb_convert_internal(cinfo, input_buf, input_row, output_buf, 360 gray_rgb_convert_internal(cinfo, input_buf, input_row, output_buf,
348 num_rows); 361 num_rows);
349 break; 362 break;
350 } 363 }
351 } 364 }
352 365
353 366
354 /* 367 /*
368 * Convert plain RGB to extended RGB
369 */
370
371 METHODDEF(void)
372 rgb_rgb_convert (j_decompress_ptr cinfo,
373 JSAMPIMAGE input_buf, JDIMENSION input_row,
374 JSAMPARRAY output_buf, int num_rows)
375 {
376 switch (cinfo->out_color_space) {
377 case JCS_EXT_RGB:
378 rgb_extrgb_convert_internal(cinfo, input_buf, input_row, output_buf,
379 num_rows);
380 break;
381 case JCS_EXT_RGBX:
382 case JCS_EXT_RGBA:
383 rgb_extrgbx_convert_internal(cinfo, input_buf, input_row, output_buf,
384 num_rows);
385 break;
386 case JCS_EXT_BGR:
387 rgb_extbgr_convert_internal(cinfo, input_buf, input_row, output_buf,
388 num_rows);
389 break;
390 case JCS_EXT_BGRX:
391 case JCS_EXT_BGRA:
392 rgb_extbgrx_convert_internal(cinfo, input_buf, input_row, output_buf,
393 num_rows);
394 break;
395 case JCS_EXT_XBGR:
396 case JCS_EXT_ABGR:
397 rgb_extxbgr_convert_internal(cinfo, input_buf, input_row, output_buf,
398 num_rows);
399 break;
400 case JCS_EXT_XRGB:
401 case JCS_EXT_ARGB:
402 rgb_extxrgb_convert_internal(cinfo, input_buf, input_row, output_buf,
403 num_rows);
404 break;
405 default:
406 rgb_rgb_convert_internal(cinfo, input_buf, input_row, output_buf,
407 num_rows);
408 break;
409 }
410 }
411
412 /*
355 * Adobe-style YCCK->CMYK conversion. 413 * Adobe-style YCCK->CMYK conversion.
356 * We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same 414 * We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same
357 * conversion as above, while passing K (black) unchanged. 415 * conversion as above, while passing K (black) unchanged.
358 * We assume build_ycc_rgb_table has been called. 416 * We assume build_ycc_rgb_table has been called.
359 */ 417 */
360 418
361 METHODDEF(void) 419 METHODDEF(void)
362 ycck_cmyk_convert (j_decompress_ptr cinfo, 420 ycck_cmyk_convert (j_decompress_ptr cinfo,
363 JSAMPIMAGE input_buf, JDIMENSION input_row, 421 JSAMPIMAGE input_buf, JDIMENSION input_row,
364 JSAMPARRAY output_buf, int num_rows) 422 JSAMPARRAY output_buf, int num_rows)
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space]; 544 cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
487 if (cinfo->jpeg_color_space == JCS_YCbCr) { 545 if (cinfo->jpeg_color_space == JCS_YCbCr) {
488 if (jsimd_can_ycc_rgb()) 546 if (jsimd_can_ycc_rgb())
489 cconvert->pub.color_convert = jsimd_ycc_rgb_convert; 547 cconvert->pub.color_convert = jsimd_ycc_rgb_convert;
490 else { 548 else {
491 cconvert->pub.color_convert = ycc_rgb_convert; 549 cconvert->pub.color_convert = ycc_rgb_convert;
492 build_ycc_rgb_table(cinfo); 550 build_ycc_rgb_table(cinfo);
493 } 551 }
494 } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) { 552 } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) {
495 cconvert->pub.color_convert = gray_rgb_convert; 553 cconvert->pub.color_convert = gray_rgb_convert;
496 } else if (cinfo->jpeg_color_space == cinfo->out_color_space && 554 } else if (cinfo->jpeg_color_space == JCS_RGB) {
497 rgb_pixelsize[cinfo->out_color_space] == 3) { 555 if (rgb_red[cinfo->out_color_space] == 0 &&
498 cconvert->pub.color_convert = null_convert; 556 rgb_green[cinfo->out_color_space] == 1 &&
557 rgb_blue[cinfo->out_color_space] == 2 &&
558 rgb_pixelsize[cinfo->out_color_space] == 3)
559 cconvert->pub.color_convert = null_convert;
560 else
561 cconvert->pub.color_convert = rgb_rgb_convert;
499 } else 562 } else
500 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); 563 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
501 break; 564 break;
502 565
503 case JCS_CMYK: 566 case JCS_CMYK:
504 cinfo->out_color_components = 4; 567 cinfo->out_color_components = 4;
505 if (cinfo->jpeg_color_space == JCS_YCCK) { 568 if (cinfo->jpeg_color_space == JCS_YCCK) {
506 cconvert->pub.color_convert = ycck_cmyk_convert; 569 cconvert->pub.color_convert = ycck_cmyk_convert;
507 build_ycc_rgb_table(cinfo); 570 build_ycc_rgb_table(cinfo);
508 } else if (cinfo->jpeg_color_space == JCS_CMYK) { 571 } else if (cinfo->jpeg_color_space == JCS_CMYK) {
(...skipping 10 matching lines...) Expand all
519 } else /* unsupported non-null conversion */ 582 } else /* unsupported non-null conversion */
520 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); 583 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
521 break; 584 break;
522 } 585 }
523 586
524 if (cinfo->quantize_colors) 587 if (cinfo->quantize_colors)
525 cinfo->output_components = 1; /* single colormapped output component */ 588 cinfo->output_components = 1; /* single colormapped output component */
526 else 589 else
527 cinfo->output_components = cinfo->out_color_components; 590 cinfo->output_components = cinfo->out_color_components;
528 } 591 }
OLDNEW
« no previous file with comments | « jdcolext.c ('k') | jdct.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698