/src/libjpeg-turbo.3.0.x/jdcolext.c
Line | Count | Source |
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 | 1.01M | { |
35 | 1.01M | #if BITS_IN_JSAMPLE != 16 |
36 | 1.01M | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; |
37 | 1.01M | register int y, cb, cr; |
38 | 1.01M | register _JSAMPROW outptr; |
39 | 1.01M | register _JSAMPROW inptr0, inptr1, inptr2; |
40 | 1.01M | register JDIMENSION col; |
41 | 1.01M | JDIMENSION num_cols = cinfo->output_width; |
42 | | /* copy these pointers into registers if possible */ |
43 | 1.01M | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; |
44 | 1.01M | register int *Crrtab = cconvert->Cr_r_tab; |
45 | 1.01M | register int *Cbbtab = cconvert->Cb_b_tab; |
46 | 1.01M | register JLONG *Crgtab = cconvert->Cr_g_tab; |
47 | 1.01M | register JLONG *Cbgtab = cconvert->Cb_g_tab; |
48 | 1.01M | SHIFT_TEMPS |
49 | | |
50 | 3.69M | while (--num_rows >= 0) { |
51 | 2.67M | inptr0 = input_buf[0][input_row]; |
52 | 2.67M | inptr1 = input_buf[1][input_row]; |
53 | 2.67M | inptr2 = input_buf[2][input_row]; |
54 | 2.67M | input_row++; |
55 | 2.67M | outptr = *output_buf++; |
56 | 56.8M | for (col = 0; col < num_cols; col++) { |
57 | 54.1M | y = inptr0[col]; |
58 | 54.1M | cb = inptr1[col]; |
59 | 54.1M | cr = inptr2[col]; |
60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ |
61 | 54.1M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; |
62 | 54.1M | outptr[RGB_GREEN] = range_limit[y + |
63 | 54.1M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
64 | 54.1M | SCALEBITS))]; |
65 | 54.1M | 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 | 13.1M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
70 | | #endif |
71 | 54.1M | outptr += RGB_PIXELSIZE; |
72 | 54.1M | } |
73 | 2.67M | } |
74 | | #else |
75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); |
76 | | #endif |
77 | 1.01M | } jdcolor.c:ycc_extrgb_convert_internal Line | Count | Source | 34 | 612k | { | 35 | 612k | #if BITS_IN_JSAMPLE != 16 | 36 | 612k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 612k | register int y, cb, cr; | 38 | 612k | register _JSAMPROW outptr; | 39 | 612k | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 612k | register JDIMENSION col; | 41 | 612k | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 612k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 612k | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 612k | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 612k | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 612k | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 612k | SHIFT_TEMPS | 49 | | | 50 | 2.29M | while (--num_rows >= 0) { | 51 | 1.68M | inptr0 = input_buf[0][input_row]; | 52 | 1.68M | inptr1 = input_buf[1][input_row]; | 53 | 1.68M | inptr2 = input_buf[2][input_row]; | 54 | 1.68M | input_row++; | 55 | 1.68M | outptr = *output_buf++; | 56 | 42.7M | for (col = 0; col < num_cols; col++) { | 57 | 41.0M | y = inptr0[col]; | 58 | 41.0M | cb = inptr1[col]; | 59 | 41.0M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 41.0M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 41.0M | outptr[RGB_GREEN] = range_limit[y + | 63 | 41.0M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 41.0M | SCALEBITS))]; | 65 | 41.0M | 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 | | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 70 | | #endif | 71 | 41.0M | outptr += RGB_PIXELSIZE; | 72 | 41.0M | } | 73 | 1.68M | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 612k | } |
Unexecuted instantiation: jdcolor.c:ycc_extrgbx_convert_internal Unexecuted instantiation: jdcolor.c:ycc_extbgr_convert_internal jdcolor.c:ycc_extbgrx_convert_internal Line | Count | Source | 34 | 403k | { | 35 | 403k | #if BITS_IN_JSAMPLE != 16 | 36 | 403k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 403k | register int y, cb, cr; | 38 | 403k | register _JSAMPROW outptr; | 39 | 403k | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 403k | register JDIMENSION col; | 41 | 403k | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 403k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 403k | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 403k | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 403k | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 403k | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 403k | SHIFT_TEMPS | 49 | | | 50 | 1.40M | while (--num_rows >= 0) { | 51 | 998k | inptr0 = input_buf[0][input_row]; | 52 | 998k | inptr1 = input_buf[1][input_row]; | 53 | 998k | inptr2 = input_buf[2][input_row]; | 54 | 998k | input_row++; | 55 | 998k | outptr = *output_buf++; | 56 | 14.1M | for (col = 0; col < num_cols; col++) { | 57 | 13.1M | y = inptr0[col]; | 58 | 13.1M | cb = inptr1[col]; | 59 | 13.1M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 13.1M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 13.1M | outptr[RGB_GREEN] = range_limit[y + | 63 | 13.1M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 13.1M | SCALEBITS))]; | 65 | 13.1M | 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 | 13.1M | #ifdef RGB_ALPHA | 69 | 13.1M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 70 | 13.1M | #endif | 71 | 13.1M | outptr += RGB_PIXELSIZE; | 72 | 13.1M | } | 73 | 998k | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 403k | } |
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 | 11.3M | { |
92 | 11.3M | register _JSAMPROW inptr, outptr; |
93 | 11.3M | register JDIMENSION col; |
94 | 11.3M | JDIMENSION num_cols = cinfo->output_width; |
95 | | |
96 | 31.8M | while (--num_rows >= 0) { |
97 | 20.4M | inptr = input_buf[0][input_row++]; |
98 | 20.4M | outptr = *output_buf++; |
99 | 988M | for (col = 0; col < num_cols; col++) { |
100 | 967M | 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 | 201M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
105 | | #endif |
106 | 967M | outptr += RGB_PIXELSIZE; |
107 | 967M | } |
108 | 20.4M | } |
109 | 11.3M | } jdcolor.c:gray_extrgb_convert_internal Line | Count | Source | 91 | 5.98M | { | 92 | 5.98M | register _JSAMPROW inptr, outptr; | 93 | 5.98M | register JDIMENSION col; | 94 | 5.98M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 18.1M | while (--num_rows >= 0) { | 97 | 12.1M | inptr = input_buf[0][input_row++]; | 98 | 12.1M | outptr = *output_buf++; | 99 | 757M | for (col = 0; col < num_cols; col++) { | 100 | 745M | 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 | 745M | outptr += RGB_PIXELSIZE; | 107 | 745M | } | 108 | 12.1M | } | 109 | 5.98M | } |
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal jdcolor.c:gray_extbgr_convert_internal Line | Count | Source | 91 | 1.33M | { | 92 | 1.33M | register _JSAMPROW inptr, outptr; | 93 | 1.33M | register JDIMENSION col; | 94 | 1.33M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 2.67M | while (--num_rows >= 0) { | 97 | 1.33M | inptr = input_buf[0][input_row++]; | 98 | 1.33M | outptr = *output_buf++; | 99 | 22.6M | for (col = 0; col < num_cols; col++) { | 100 | 21.2M | 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 | 21.2M | outptr += RGB_PIXELSIZE; | 107 | 21.2M | } | 108 | 1.33M | } | 109 | 1.33M | } |
jdcolor.c:gray_extbgrx_convert_internal Line | Count | Source | 91 | 2.97M | { | 92 | 2.97M | register _JSAMPROW inptr, outptr; | 93 | 2.97M | register JDIMENSION col; | 94 | 2.97M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 8.99M | while (--num_rows >= 0) { | 97 | 6.01M | inptr = input_buf[0][input_row++]; | 98 | 6.01M | outptr = *output_buf++; | 99 | 194M | for (col = 0; col < num_cols; col++) { | 100 | 188M | 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 | 188M | #ifdef RGB_ALPHA | 104 | 188M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 188M | #endif | 106 | 188M | outptr += RGB_PIXELSIZE; | 107 | 188M | } | 108 | 6.01M | } | 109 | 2.97M | } |
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal jdcolor.c:gray_extxrgb_convert_internal Line | Count | Source | 91 | 1.00M | { | 92 | 1.00M | register _JSAMPROW inptr, outptr; | 93 | 1.00M | register JDIMENSION col; | 94 | 1.00M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 2.00M | while (--num_rows >= 0) { | 97 | 1.00M | inptr = input_buf[0][input_row++]; | 98 | 1.00M | outptr = *output_buf++; | 99 | 13.6M | for (col = 0; col < num_cols; col++) { | 100 | 12.6M | 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 | 12.6M | #ifdef RGB_ALPHA | 104 | 12.6M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 12.6M | #endif | 106 | 12.6M | outptr += RGB_PIXELSIZE; | 107 | 12.6M | } | 108 | 1.00M | } | 109 | 1.00M | } |
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 | 905k | { |
122 | 905k | register _JSAMPROW inptr0, inptr1, inptr2; |
123 | 905k | register _JSAMPROW outptr; |
124 | 905k | register JDIMENSION col; |
125 | 905k | JDIMENSION num_cols = cinfo->output_width; |
126 | | |
127 | 2.55M | while (--num_rows >= 0) { |
128 | 1.65M | inptr0 = input_buf[0][input_row]; |
129 | 1.65M | inptr1 = input_buf[1][input_row]; |
130 | 1.65M | inptr2 = input_buf[2][input_row]; |
131 | 1.65M | input_row++; |
132 | 1.65M | outptr = *output_buf++; |
133 | 42.4M | for (col = 0; col < num_cols; col++) { |
134 | 40.8M | outptr[RGB_RED] = inptr0[col]; |
135 | 40.8M | outptr[RGB_GREEN] = inptr1[col]; |
136 | 40.8M | 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 | 34.7M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
141 | | #endif |
142 | 40.8M | outptr += RGB_PIXELSIZE; |
143 | 40.8M | } |
144 | 1.65M | } |
145 | 905k | } 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 | 67.9k | { | 122 | 67.9k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 67.9k | register _JSAMPROW outptr; | 124 | 67.9k | register JDIMENSION col; | 125 | 67.9k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 136k | while (--num_rows >= 0) { | 128 | 68.8k | inptr0 = input_buf[0][input_row]; | 129 | 68.8k | inptr1 = input_buf[1][input_row]; | 130 | 68.8k | inptr2 = input_buf[2][input_row]; | 131 | 68.8k | input_row++; | 132 | 68.8k | outptr = *output_buf++; | 133 | 6.13M | for (col = 0; col < num_cols; col++) { | 134 | 6.06M | outptr[RGB_RED] = inptr0[col]; | 135 | 6.06M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 6.06M | 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 | 6.06M | outptr += RGB_PIXELSIZE; | 143 | 6.06M | } | 144 | 68.8k | } | 145 | 67.9k | } |
jdcolor.c:rgb_extbgrx_convert_internal Line | Count | Source | 121 | 786k | { | 122 | 786k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 786k | register _JSAMPROW outptr; | 124 | 786k | register JDIMENSION col; | 125 | 786k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 2.31M | while (--num_rows >= 0) { | 128 | 1.52M | inptr0 = input_buf[0][input_row]; | 129 | 1.52M | inptr1 = input_buf[1][input_row]; | 130 | 1.52M | inptr2 = input_buf[2][input_row]; | 131 | 1.52M | input_row++; | 132 | 1.52M | outptr = *output_buf++; | 133 | 32.7M | for (col = 0; col < num_cols; col++) { | 134 | 31.2M | outptr[RGB_RED] = inptr0[col]; | 135 | 31.2M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 31.2M | outptr[RGB_BLUE] = inptr2[col]; | 137 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ | 138 | | /* opaque alpha channel value */ | 139 | 31.2M | #ifdef RGB_ALPHA | 140 | 31.2M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 31.2M | #endif | 142 | 31.2M | outptr += RGB_PIXELSIZE; | 143 | 31.2M | } | 144 | 1.52M | } | 145 | 786k | } |
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal jdcolor.c:rgb_extxrgb_convert_internal Line | Count | Source | 121 | 50.9k | { | 122 | 50.9k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 50.9k | register _JSAMPROW outptr; | 124 | 50.9k | register JDIMENSION col; | 125 | 50.9k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 102k | while (--num_rows >= 0) { | 128 | 51.6k | inptr0 = input_buf[0][input_row]; | 129 | 51.6k | inptr1 = input_buf[1][input_row]; | 130 | 51.6k | inptr2 = input_buf[2][input_row]; | 131 | 51.6k | input_row++; | 132 | 51.6k | outptr = *output_buf++; | 133 | 3.60M | for (col = 0; col < num_cols; col++) { | 134 | 3.55M | outptr[RGB_RED] = inptr0[col]; | 135 | 3.55M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 3.55M | outptr[RGB_BLUE] = inptr2[col]; | 137 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ | 138 | | /* opaque alpha channel value */ | 139 | 3.55M | #ifdef RGB_ALPHA | 140 | 3.55M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 3.55M | #endif | 142 | 3.55M | outptr += RGB_PIXELSIZE; | 143 | 3.55M | } | 144 | 51.6k | } | 145 | 50.9k | } |
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal |