/src/libjpeg-turbo/jdcolext.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * jdcolext.c |
3 | | * |
4 | | * This file was part of the Independent JPEG Group's software: |
5 | | * Copyright (C) 1991-1997, Thomas G. Lane. |
6 | | * libjpeg-turbo Modifications: |
7 | | * Copyright (C) 2009, 2011, 2015, D. R. Commander. |
8 | | * For conditions of distribution and use, see the accompanying README.ijg |
9 | | * file. |
10 | | * |
11 | | * This file contains output colorspace conversion routines. |
12 | | */ |
13 | | |
14 | | |
15 | | /* This file is included by jdcolor.c */ |
16 | | |
17 | | |
18 | | /* |
19 | | * Convert some rows of samples to the output colorspace. |
20 | | * |
21 | | * Note that we change from noninterleaved, one-plane-per-component format |
22 | | * to interleaved-pixel format. The output buffer is therefore three times |
23 | | * as wide as the input buffer. |
24 | | * A starting row offset is provided only for the input buffer. The caller |
25 | | * can easily adjust the passed output_buf value to accommodate any row |
26 | | * offset required on that side. |
27 | | */ |
28 | | |
29 | | INLINE |
30 | | LOCAL(void) |
31 | | ycc_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, |
32 | | JDIMENSION input_row, JSAMPARRAY output_buf, |
33 | | int num_rows) |
34 | 0 | { |
35 | 0 | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; |
36 | 0 | register int y, cb, cr; |
37 | 0 | register JSAMPROW outptr; |
38 | 0 | register JSAMPROW inptr0, inptr1, inptr2; |
39 | 0 | register JDIMENSION col; |
40 | 0 | JDIMENSION num_cols = cinfo->output_width; |
41 | | /* copy these pointers into registers if possible */ |
42 | 0 | register JSAMPLE *range_limit = cinfo->sample_range_limit; |
43 | 0 | register int *Crrtab = cconvert->Cr_r_tab; |
44 | 0 | register int *Cbbtab = cconvert->Cb_b_tab; |
45 | 0 | register JLONG *Crgtab = cconvert->Cr_g_tab; |
46 | 0 | register JLONG *Cbgtab = cconvert->Cb_g_tab; |
47 | 0 | SHIFT_TEMPS |
48 | |
|
49 | 0 | while (--num_rows >= 0) { |
50 | 0 | inptr0 = input_buf[0][input_row]; |
51 | 0 | inptr1 = input_buf[1][input_row]; |
52 | 0 | inptr2 = input_buf[2][input_row]; |
53 | 0 | input_row++; |
54 | 0 | outptr = *output_buf++; |
55 | 0 | for (col = 0; col < num_cols; col++) { |
56 | 0 | y = inptr0[col]; |
57 | 0 | cb = inptr1[col]; |
58 | 0 | cr = inptr2[col]; |
59 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ |
60 | 0 | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; |
61 | 0 | outptr[RGB_GREEN] = range_limit[y + |
62 | 0 | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
63 | 0 | SCALEBITS))]; |
64 | 0 | outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]]; |
65 | | /* Set unused byte to 0xFF so it can be interpreted as an opaque */ |
66 | | /* alpha channel value */ |
67 | | #ifdef RGB_ALPHA |
68 | 0 | outptr[RGB_ALPHA] = 0xFF; |
69 | | #endif |
70 | 0 | outptr += RGB_PIXELSIZE; |
71 | 0 | } |
72 | 0 | } |
73 | 0 | } Unexecuted instantiation: jdcolor.c:ycc_extrgb_convert_internal Unexecuted instantiation: jdcolor.c:ycc_extrgbx_convert_internal Unexecuted instantiation: jdcolor.c:ycc_extbgr_convert_internal Unexecuted instantiation: jdcolor.c:ycc_extbgrx_convert_internal Unexecuted instantiation: jdcolor.c:ycc_extxbgr_convert_internal Unexecuted instantiation: jdcolor.c:ycc_extxrgb_convert_internal Unexecuted instantiation: jdcolor.c:ycc_rgb_convert_internal |
74 | | |
75 | | |
76 | | /* |
77 | | * Convert grayscale to RGB: just duplicate the graylevel three times. |
78 | | * This is provided to support applications that don't want to cope |
79 | | * with grayscale as a separate case. |
80 | | */ |
81 | | |
82 | | INLINE |
83 | | LOCAL(void) |
84 | | gray_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, |
85 | | JDIMENSION input_row, JSAMPARRAY output_buf, |
86 | | int num_rows) |
87 | 0 | { |
88 | 0 | register JSAMPROW inptr, outptr; |
89 | 0 | register JDIMENSION col; |
90 | 0 | JDIMENSION num_cols = cinfo->output_width; |
91 | |
|
92 | 0 | while (--num_rows >= 0) { |
93 | 0 | inptr = input_buf[0][input_row++]; |
94 | 0 | outptr = *output_buf++; |
95 | 0 | for (col = 0; col < num_cols; col++) { |
96 | 0 | outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; |
97 | | /* Set unused byte to 0xFF so it can be interpreted as an opaque */ |
98 | | /* alpha channel value */ |
99 | | #ifdef RGB_ALPHA |
100 | 0 | outptr[RGB_ALPHA] = 0xFF; |
101 | | #endif |
102 | 0 | outptr += RGB_PIXELSIZE; |
103 | 0 | } |
104 | 0 | } |
105 | 0 | } Unexecuted instantiation: jdcolor.c:gray_extrgb_convert_internal Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal Unexecuted instantiation: jdcolor.c:gray_extbgr_convert_internal Unexecuted instantiation: jdcolor.c:gray_extbgrx_convert_internal Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal Unexecuted instantiation: jdcolor.c:gray_extxrgb_convert_internal Unexecuted instantiation: jdcolor.c:gray_rgb_convert_internal |
106 | | |
107 | | |
108 | | /* |
109 | | * Convert RGB to extended RGB: just swap the order of source pixels |
110 | | */ |
111 | | |
112 | | INLINE |
113 | | LOCAL(void) |
114 | | rgb_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, |
115 | | JDIMENSION input_row, JSAMPARRAY output_buf, |
116 | | int num_rows) |
117 | 0 | { |
118 | 0 | register JSAMPROW inptr0, inptr1, inptr2; |
119 | 0 | register JSAMPROW outptr; |
120 | 0 | register JDIMENSION col; |
121 | 0 | JDIMENSION num_cols = cinfo->output_width; |
122 | |
|
123 | 0 | while (--num_rows >= 0) { |
124 | 0 | inptr0 = input_buf[0][input_row]; |
125 | 0 | inptr1 = input_buf[1][input_row]; |
126 | 0 | inptr2 = input_buf[2][input_row]; |
127 | 0 | input_row++; |
128 | 0 | outptr = *output_buf++; |
129 | 0 | for (col = 0; col < num_cols; col++) { |
130 | 0 | outptr[RGB_RED] = inptr0[col]; |
131 | 0 | outptr[RGB_GREEN] = inptr1[col]; |
132 | 0 | outptr[RGB_BLUE] = inptr2[col]; |
133 | | /* Set unused byte to 0xFF so it can be interpreted as an opaque */ |
134 | | /* alpha channel value */ |
135 | | #ifdef RGB_ALPHA |
136 | 0 | outptr[RGB_ALPHA] = 0xFF; |
137 | | #endif |
138 | 0 | outptr += RGB_PIXELSIZE; |
139 | 0 | } |
140 | 0 | } |
141 | 0 | } Unexecuted instantiation: jdcolor.c:rgb_extrgb_convert_internal Unexecuted instantiation: jdcolor.c:rgb_extrgbx_convert_internal Unexecuted instantiation: jdcolor.c:rgb_extbgr_convert_internal Unexecuted instantiation: jdcolor.c:rgb_extbgrx_convert_internal Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal Unexecuted instantiation: jdcolor.c:rgb_extxrgb_convert_internal Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal |