/src/libjpeg-turbo.main/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, 2022-2023, 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 | #if BITS_IN_JSAMPLE != 16 |
36 | 0 | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; |
37 | 0 | register int y, cb, cr; |
38 | 0 | register _JSAMPROW outptr; |
39 | 0 | register _JSAMPROW inptr0, inptr1, inptr2; |
40 | 0 | register JDIMENSION col; |
41 | 0 | JDIMENSION num_cols = cinfo->output_width; |
42 | | /* copy these pointers into registers if possible */ |
43 | 0 | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; |
44 | 0 | register int *Crrtab = cconvert->Cr_r_tab; |
45 | 0 | register int *Cbbtab = cconvert->Cb_b_tab; |
46 | 0 | register JLONG *Crgtab = cconvert->Cr_g_tab; |
47 | 0 | register JLONG *Cbgtab = cconvert->Cb_g_tab; |
48 | 0 | SHIFT_TEMPS |
49 | |
|
50 | 0 | while (--num_rows >= 0) { |
51 | 0 | inptr0 = input_buf[0][input_row]; |
52 | 0 | inptr1 = input_buf[1][input_row]; |
53 | 0 | inptr2 = input_buf[2][input_row]; |
54 | 0 | input_row++; |
55 | 0 | outptr = *output_buf++; |
56 | 0 | for (col = 0; col < num_cols; col++) { |
57 | 0 | y = inptr0[col]; |
58 | 0 | cb = inptr1[col]; |
59 | 0 | cr = inptr2[col]; |
60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ |
61 | 0 | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; |
62 | 0 | outptr[RGB_GREEN] = range_limit[y + |
63 | 0 | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
64 | 0 | SCALEBITS))]; |
65 | 0 | outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]]; |
66 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ |
67 | | /* opaque alpha channel value */ |
68 | | #ifdef RGB_ALPHA |
69 | 0 | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
70 | | #endif |
71 | 0 | outptr += RGB_PIXELSIZE; |
72 | 0 | } |
73 | 0 | } |
74 | | #else |
75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); |
76 | | #endif |
77 | 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 |
78 | | |
79 | | |
80 | | /* |
81 | | * Convert grayscale to RGB: just duplicate the graylevel three times. |
82 | | * This is provided to support applications that don't want to cope |
83 | | * with grayscale as a separate case. |
84 | | */ |
85 | | |
86 | | INLINE |
87 | | LOCAL(void) |
88 | | gray_rgb_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf, |
89 | | JDIMENSION input_row, _JSAMPARRAY output_buf, |
90 | | int num_rows) |
91 | 582k | { |
92 | 582k | register _JSAMPROW inptr, outptr; |
93 | 582k | register JDIMENSION col; |
94 | 582k | JDIMENSION num_cols = cinfo->output_width; |
95 | | |
96 | 1.16M | while (--num_rows >= 0) { |
97 | 582k | inptr = input_buf[0][input_row++]; |
98 | 582k | outptr = *output_buf++; |
99 | 50.9M | for (col = 0; col < num_cols; col++) { |
100 | 50.3M | outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; |
101 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ |
102 | | /* opaque alpha channel value */ |
103 | | #ifdef RGB_ALPHA |
104 | 18.4M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
105 | | #endif |
106 | 50.3M | outptr += RGB_PIXELSIZE; |
107 | 50.3M | } |
108 | 582k | } |
109 | 582k | } Unexecuted instantiation: jdcolor.c:gray_extrgb_convert_internal Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal jdcolor.c:gray_extbgr_convert_internal Line | Count | Source | 91 | 332k | { | 92 | 332k | register _JSAMPROW inptr, outptr; | 93 | 332k | register JDIMENSION col; | 94 | 332k | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 665k | while (--num_rows >= 0) { | 97 | 332k | inptr = input_buf[0][input_row++]; | 98 | 332k | outptr = *output_buf++; | 99 | 32.2M | for (col = 0; col < num_cols; col++) { | 100 | 31.8M | outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; | 101 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ | 102 | | /* opaque alpha channel value */ | 103 | | #ifdef RGB_ALPHA | 104 | | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | | #endif | 106 | 31.8M | outptr += RGB_PIXELSIZE; | 107 | 31.8M | } | 108 | 332k | } | 109 | 332k | } |
Unexecuted instantiation: jdcolor.c:gray_extbgrx_convert_internal Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal jdcolor.c:gray_extxrgb_convert_internal Line | Count | Source | 91 | 249k | { | 92 | 249k | register _JSAMPROW inptr, outptr; | 93 | 249k | register JDIMENSION col; | 94 | 249k | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 499k | while (--num_rows >= 0) { | 97 | 249k | inptr = input_buf[0][input_row++]; | 98 | 249k | outptr = *output_buf++; | 99 | 18.7M | for (col = 0; col < num_cols; col++) { | 100 | 18.4M | outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; | 101 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ | 102 | | /* opaque alpha channel value */ | 103 | 18.4M | #ifdef RGB_ALPHA | 104 | 18.4M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 18.4M | #endif | 106 | 18.4M | outptr += RGB_PIXELSIZE; | 107 | 18.4M | } | 108 | 249k | } | 109 | 249k | } |
Unexecuted instantiation: jdcolor.c:gray_rgb_convert_internal |
110 | | |
111 | | |
112 | | /* |
113 | | * Convert RGB to extended RGB: just swap the order of source pixels |
114 | | */ |
115 | | |
116 | | INLINE |
117 | | LOCAL(void) |
118 | | rgb_rgb_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf, |
119 | | JDIMENSION input_row, _JSAMPARRAY output_buf, |
120 | | int num_rows) |
121 | 44.6k | { |
122 | 44.6k | register _JSAMPROW inptr0, inptr1, inptr2; |
123 | 44.6k | register _JSAMPROW outptr; |
124 | 44.6k | register JDIMENSION col; |
125 | 44.6k | JDIMENSION num_cols = cinfo->output_width; |
126 | | |
127 | 148k | while (--num_rows >= 0) { |
128 | 103k | inptr0 = input_buf[0][input_row]; |
129 | 103k | inptr1 = input_buf[1][input_row]; |
130 | 103k | inptr2 = input_buf[2][input_row]; |
131 | 103k | input_row++; |
132 | 103k | outptr = *output_buf++; |
133 | 6.83M | for (col = 0; col < num_cols; col++) { |
134 | 6.73M | outptr[RGB_RED] = inptr0[col]; |
135 | 6.73M | outptr[RGB_GREEN] = inptr1[col]; |
136 | 6.73M | outptr[RGB_BLUE] = inptr2[col]; |
137 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ |
138 | | /* opaque alpha channel value */ |
139 | | #ifdef RGB_ALPHA |
140 | 2.48M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
141 | | #endif |
142 | 6.73M | outptr += RGB_PIXELSIZE; |
143 | 6.73M | } |
144 | 103k | } |
145 | 44.6k | } Unexecuted instantiation: jdcolor.c:rgb_extrgb_convert_internal Unexecuted instantiation: jdcolor.c:rgb_extrgbx_convert_internal jdcolor.c:rgb_extbgr_convert_internal Line | Count | Source | 121 | 25.5k | { | 122 | 25.5k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 25.5k | register _JSAMPROW outptr; | 124 | 25.5k | register JDIMENSION col; | 125 | 25.5k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 84.7k | while (--num_rows >= 0) { | 128 | 59.2k | inptr0 = input_buf[0][input_row]; | 129 | 59.2k | inptr1 = input_buf[1][input_row]; | 130 | 59.2k | inptr2 = input_buf[2][input_row]; | 131 | 59.2k | input_row++; | 132 | 59.2k | outptr = *output_buf++; | 133 | 4.31M | for (col = 0; col < num_cols; col++) { | 134 | 4.25M | outptr[RGB_RED] = inptr0[col]; | 135 | 4.25M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 4.25M | outptr[RGB_BLUE] = inptr2[col]; | 137 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ | 138 | | /* opaque alpha channel value */ | 139 | | #ifdef RGB_ALPHA | 140 | | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | | #endif | 142 | 4.25M | outptr += RGB_PIXELSIZE; | 143 | 4.25M | } | 144 | 59.2k | } | 145 | 25.5k | } |
Unexecuted instantiation: jdcolor.c:rgb_extbgrx_convert_internal Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal jdcolor.c:rgb_extxrgb_convert_internal Line | Count | Source | 121 | 19.1k | { | 122 | 19.1k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 19.1k | register _JSAMPROW outptr; | 124 | 19.1k | register JDIMENSION col; | 125 | 19.1k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 63.5k | while (--num_rows >= 0) { | 128 | 44.4k | inptr0 = input_buf[0][input_row]; | 129 | 44.4k | inptr1 = input_buf[1][input_row]; | 130 | 44.4k | inptr2 = input_buf[2][input_row]; | 131 | 44.4k | input_row++; | 132 | 44.4k | outptr = *output_buf++; | 133 | 2.52M | for (col = 0; col < num_cols; col++) { | 134 | 2.48M | outptr[RGB_RED] = inptr0[col]; | 135 | 2.48M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 2.48M | outptr[RGB_BLUE] = inptr2[col]; | 137 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ | 138 | | /* opaque alpha channel value */ | 139 | 2.48M | #ifdef RGB_ALPHA | 140 | 2.48M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 2.48M | #endif | 142 | 2.48M | outptr += RGB_PIXELSIZE; | 143 | 2.48M | } | 144 | 44.4k | } | 145 | 19.1k | } |
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal |