11 #define JPEG_INTERNALS 26 } my_color_deconverter;
61 #define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) 62 #define FIX(x) ((INT32) ((x) * (1L<<SCALEBITS) + 0.5)) 77 cconvert->Cr_r_tab = (
int *)
80 cconvert->Cb_b_tab = (
int *)
81 (*cinfo->mem->alloc_small) ((
j_common_ptr) cinfo, JPOOL_IMAGE,
83 cconvert->Cr_g_tab = (
INT32 *)
84 (*cinfo->mem->alloc_small) ((
j_common_ptr) cinfo, JPOOL_IMAGE,
86 cconvert->Cb_g_tab = (
INT32 *)
87 (*cinfo->mem->alloc_small) ((
j_common_ptr) cinfo, JPOOL_IMAGE,
94 cconvert->Cr_r_tab[
i] = (
int)
97 cconvert->Cb_b_tab[
i] = (
int)
100 cconvert->Cr_g_tab[
i] = (-
FIX(0.71414)) *
x;
103 cconvert->Cb_g_tab[
i] = (-
FIX(0.34414)) *
x + ONE_HALF;
125 register int y, cb, cr;
127 register JSAMPROW inptr0, inptr1, inptr2;
131 register JSAMPLE * range_limit = cinfo->sample_range_limit;
132 register int * Crrtab = cconvert->Cr_r_tab;
133 register int * Cbbtab = cconvert->Cb_b_tab;
134 register INT32 * Crgtab = cconvert->Cr_g_tab;
135 register INT32 * Cbgtab = cconvert->Cb_g_tab;
139 inptr0 = input_buf[0][input_row];
140 inptr1 = input_buf[1][input_row];
141 inptr2 = input_buf[2][input_row];
144 for (col = 0; col <
num_cols; col++) {
149 outptr[RGB_RED] = range_limit[
y + Crrtab[cr]];
150 outptr[RGB_GREEN] = range_limit[
y +
153 outptr[RGB_BLUE] = range_limit[
y + Cbbtab[cb]];
154 outptr += RGB_PIXELSIZE;
175 register int num_components = cinfo->num_components;
180 for (ci = 0; ci < num_components; ci++) {
181 inptr = input_buf[ci][input_row];
185 outptr += num_components;
226 inptr = input_buf[0][input_row++];
228 for (col = 0; col <
num_cols; col++) {
230 outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col];
231 outptr += RGB_PIXELSIZE;
250 register int y, cb, cr;
252 register JSAMPROW inptr0, inptr1, inptr2, inptr3;
256 register JSAMPLE * range_limit = cinfo->sample_range_limit;
257 register int * Crrtab = cconvert->Cr_r_tab;
258 register int * Cbbtab = cconvert->Cb_b_tab;
259 register INT32 * Crgtab = cconvert->Cr_g_tab;
260 register INT32 * Cbgtab = cconvert->Cb_g_tab;
264 inptr0 = input_buf[0][input_row];
265 inptr1 = input_buf[1][input_row];
266 inptr2 = input_buf[2][input_row];
267 inptr3 = input_buf[3][input_row];
270 for (col = 0; col <
num_cols; col++) {
275 outptr[0] = range_limit[
MAXJSAMPLE - (
y + Crrtab[cr])];
279 outptr[2] = range_limit[
MAXJSAMPLE - (
y + Cbbtab[cb])];
281 outptr[3] = inptr3[col];
311 SIZEOF(my_color_deconverter));
316 switch (cinfo->jpeg_color_space) {
318 if (cinfo->num_components != 1)
319 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
324 if (cinfo->num_components != 3)
325 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
330 if (cinfo->num_components != 4)
331 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
335 if (cinfo->num_components < 1)
336 ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
345 switch (cinfo->out_color_space) {
347 cinfo->out_color_components = 1;
352 for (ci = 1; ci < cinfo->num_components; ci++)
353 cinfo->comp_info[ci].component_needed =
FALSE;
355 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
359 cinfo->out_color_components = RGB_PIXELSIZE;
360 if (cinfo->jpeg_color_space ==
JCS_YCbCr) {
365 }
else if (cinfo->jpeg_color_space ==
JCS_RGB && RGB_PIXELSIZE == 3) {
368 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
372 cinfo->out_color_components = 4;
373 if (cinfo->jpeg_color_space ==
JCS_YCCK) {
376 }
else if (cinfo->jpeg_color_space ==
JCS_CMYK) {
379 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
384 if (cinfo->out_color_space == cinfo->jpeg_color_space) {
385 cinfo->out_color_components = cinfo->num_components;
388 ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
392 if (cinfo->quantize_colors)
393 cinfo->output_components = 1;
395 cinfo->output_components = cinfo->out_color_components;
GLint GLint GLint GLint GLint GLint y
struct jpeg_common_struct * j_common_ptr
my_color_converter * my_cconvert_ptr
#define GETJSAMPLE(value)
#define ERREXIT(cinfo, code)
GLint GLint GLint GLint GLint x
jinit_color_deconverter(j_decompress_ptr cinfo)
ycck_cmyk_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
int JSAMPARRAY int int num_rows
my_color_deconverter * my_cconvert_ptr
null_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
int JSAMPARRAY int int JDIMENSION num_cols
start_pass_dcolor(j_decompress_ptr cinfo)
#define RIGHT_SHIFT(x, shft)
ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
build_ycc_rgb_table(j_decompress_ptr cinfo)
GLuint GLuint GLsizei count
jpeg_component_info JCOEFPTR JSAMPARRAY output_buf
jcopy_sample_rows(JSAMPARRAY input_array, int source_row, JSAMPARRAY output_array, int dest_row, int num_rows, JDIMENSION num_cols)
gray_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
grayscale_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)