OLD | NEW |
1 /* | 1 /* |
2 * jdcolext.c | 2 * jdcolext.c |
3 * | 3 * |
4 * This file was part of the Independent JPEG Group's software: | 4 * This file was part of the Independent JPEG Group's software: |
5 * Copyright (C) 1991-1997, Thomas G. Lane. | 5 * Copyright (C) 1991-1997, Thomas G. Lane. |
6 * libjpeg-turbo Modifications: | 6 * libjpeg-turbo Modifications: |
7 * Copyright (C) 2009, 2011, D. R. Commander. | 7 * Copyright (C) 2009, 2011, 2015, D. R. Commander. |
8 * For conditions of distribution and use, see the accompanying README file. | 8 * For conditions of distribution and use, see the accompanying README.ijg |
| 9 * file. |
9 * | 10 * |
10 * This file contains output colorspace conversion routines. | 11 * This file contains output colorspace conversion routines. |
11 */ | 12 */ |
12 | 13 |
13 | 14 |
14 /* This file is included by jdcolor.c */ | 15 /* This file is included by jdcolor.c */ |
15 | 16 |
16 | 17 |
17 /* | 18 /* |
18 * Convert some rows of samples to the output colorspace. | 19 * Convert some rows of samples to the output colorspace. |
(...skipping 15 matching lines...) Expand all Loading... |
34 my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; | 35 my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; |
35 register int y, cb, cr; | 36 register int y, cb, cr; |
36 register JSAMPROW outptr; | 37 register JSAMPROW outptr; |
37 register JSAMPROW inptr0, inptr1, inptr2; | 38 register JSAMPROW inptr0, inptr1, inptr2; |
38 register JDIMENSION col; | 39 register JDIMENSION col; |
39 JDIMENSION num_cols = cinfo->output_width; | 40 JDIMENSION num_cols = cinfo->output_width; |
40 /* copy these pointers into registers if possible */ | 41 /* copy these pointers into registers if possible */ |
41 register JSAMPLE * range_limit = cinfo->sample_range_limit; | 42 register JSAMPLE * range_limit = cinfo->sample_range_limit; |
42 register int * Crrtab = cconvert->Cr_r_tab; | 43 register int * Crrtab = cconvert->Cr_r_tab; |
43 register int * Cbbtab = cconvert->Cb_b_tab; | 44 register int * Cbbtab = cconvert->Cb_b_tab; |
44 register INT32 * Crgtab = cconvert->Cr_g_tab; | 45 register JLONG * Crgtab = cconvert->Cr_g_tab; |
45 register INT32 * Cbgtab = cconvert->Cb_g_tab; | 46 register JLONG * Cbgtab = cconvert->Cb_g_tab; |
46 SHIFT_TEMPS | 47 SHIFT_TEMPS |
47 | 48 |
48 while (--num_rows >= 0) { | 49 while (--num_rows >= 0) { |
49 inptr0 = input_buf[0][input_row]; | 50 inptr0 = input_buf[0][input_row]; |
50 inptr1 = input_buf[1][input_row]; | 51 inptr1 = input_buf[1][input_row]; |
51 inptr2 = input_buf[2][input_row]; | 52 inptr2 = input_buf[2][input_row]; |
52 input_row++; | 53 input_row++; |
53 outptr = *output_buf++; | 54 outptr = *output_buf++; |
54 for (col = 0; col < num_cols; col++) { | 55 for (col = 0; col < num_cols; col++) { |
55 y = GETJSAMPLE(inptr0[col]); | 56 y = GETJSAMPLE(inptr0[col]); |
56 cb = GETJSAMPLE(inptr1[col]); | 57 cb = GETJSAMPLE(inptr1[col]); |
57 cr = GETJSAMPLE(inptr2[col]); | 58 cr = GETJSAMPLE(inptr2[col]); |
58 /* Range-limiting is essential due to noise introduced by DCT losses. */ | 59 /* Range-limiting is essential due to noise introduced by DCT losses. */ |
59 outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 60 outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; |
60 outptr[RGB_GREEN] = range_limit[y + | 61 outptr[RGB_GREEN] = range_limit[y + |
61 » » » ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 62 ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
62 » » » » » » SCALEBITS))]; | 63 SCALEBITS))]; |
63 outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]]; | 64 outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]]; |
64 /* Set unused byte to 0xFF so it can be interpreted as an opaque */ | 65 /* Set unused byte to 0xFF so it can be interpreted as an opaque */ |
65 /* alpha channel value */ | 66 /* alpha channel value */ |
66 #ifdef RGB_ALPHA | 67 #ifdef RGB_ALPHA |
67 outptr[RGB_ALPHA] = 0xFF; | 68 outptr[RGB_ALPHA] = 0xFF; |
68 #endif | 69 #endif |
69 outptr += RGB_PIXELSIZE; | 70 outptr += RGB_PIXELSIZE; |
70 } | 71 } |
71 } | 72 } |
72 } | 73 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 outptr[RGB_BLUE] = inptr2[col]; | 134 outptr[RGB_BLUE] = inptr2[col]; |
134 /* Set unused byte to 0xFF so it can be interpreted as an opaque */ | 135 /* Set unused byte to 0xFF so it can be interpreted as an opaque */ |
135 /* alpha channel value */ | 136 /* alpha channel value */ |
136 #ifdef RGB_ALPHA | 137 #ifdef RGB_ALPHA |
137 outptr[RGB_ALPHA] = 0xFF; | 138 outptr[RGB_ALPHA] = 0xFF; |
138 #endif | 139 #endif |
139 outptr += RGB_PIXELSIZE; | 140 outptr += RGB_PIXELSIZE; |
140 } | 141 } |
141 } | 142 } |
142 } | 143 } |
OLD | NEW |