/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 | 915k | { |
35 | 915k | #if BITS_IN_JSAMPLE != 16 |
36 | 915k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; |
37 | 915k | register int y, cb, cr; |
38 | 915k | register _JSAMPROW outptr; |
39 | 915k | register _JSAMPROW inptr0, inptr1, inptr2; |
40 | 915k | register JDIMENSION col; |
41 | 915k | JDIMENSION num_cols = cinfo->output_width; |
42 | | /* copy these pointers into registers if possible */ |
43 | 915k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; |
44 | 915k | register int *Crrtab = cconvert->Cr_r_tab; |
45 | 915k | register int *Cbbtab = cconvert->Cb_b_tab; |
46 | 915k | register JLONG *Crgtab = cconvert->Cr_g_tab; |
47 | 915k | register JLONG *Cbgtab = cconvert->Cb_g_tab; |
48 | 915k | SHIFT_TEMPS |
49 | | |
50 | 3.01M | while (--num_rows >= 0) { |
51 | 2.10M | inptr0 = input_buf[0][input_row]; |
52 | 2.10M | inptr1 = input_buf[1][input_row]; |
53 | 2.10M | inptr2 = input_buf[2][input_row]; |
54 | 2.10M | input_row++; |
55 | 2.10M | outptr = *output_buf++; |
56 | 89.0M | for (col = 0; col < num_cols; col++) { |
57 | 86.9M | y = inptr0[col]; |
58 | 86.9M | cb = inptr1[col]; |
59 | 86.9M | cr = inptr2[col]; |
60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ |
61 | 86.9M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; |
62 | 86.9M | outptr[RGB_GREEN] = range_limit[y + |
63 | 86.9M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
64 | 86.9M | SCALEBITS))]; |
65 | 86.9M | 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 | 10.9M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
70 | | #endif |
71 | 86.9M | outptr += RGB_PIXELSIZE; |
72 | 86.9M | } |
73 | 2.10M | } |
74 | | #else |
75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); |
76 | | #endif |
77 | 915k | } jdcolor.c:ycc_extrgb_convert_internal Line | Count | Source | 34 | 878k | { | 35 | 878k | #if BITS_IN_JSAMPLE != 16 | 36 | 878k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 878k | register int y, cb, cr; | 38 | 878k | register _JSAMPROW outptr; | 39 | 878k | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 878k | register JDIMENSION col; | 41 | 878k | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 878k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 878k | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 878k | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 878k | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 878k | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 878k | SHIFT_TEMPS | 49 | | | 50 | 2.88M | while (--num_rows >= 0) { | 51 | 2.00M | inptr0 = input_buf[0][input_row]; | 52 | 2.00M | inptr1 = input_buf[1][input_row]; | 53 | 2.00M | inptr2 = input_buf[2][input_row]; | 54 | 2.00M | input_row++; | 55 | 2.00M | outptr = *output_buf++; | 56 | 78.0M | for (col = 0; col < num_cols; col++) { | 57 | 76.0M | y = inptr0[col]; | 58 | 76.0M | cb = inptr1[col]; | 59 | 76.0M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 76.0M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 76.0M | outptr[RGB_GREEN] = range_limit[y + | 63 | 76.0M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 76.0M | SCALEBITS))]; | 65 | 76.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 | 76.0M | outptr += RGB_PIXELSIZE; | 72 | 76.0M | } | 73 | 2.00M | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 878k | } |
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 | 36.2k | { | 35 | 36.2k | #if BITS_IN_JSAMPLE != 16 | 36 | 36.2k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 36.2k | register int y, cb, cr; | 38 | 36.2k | register _JSAMPROW outptr; | 39 | 36.2k | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 36.2k | register JDIMENSION col; | 41 | 36.2k | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 36.2k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 36.2k | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 36.2k | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 36.2k | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 36.2k | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 36.2k | SHIFT_TEMPS | 49 | | | 50 | 131k | while (--num_rows >= 0) { | 51 | 95.2k | inptr0 = input_buf[0][input_row]; | 52 | 95.2k | inptr1 = input_buf[1][input_row]; | 53 | 95.2k | inptr2 = input_buf[2][input_row]; | 54 | 95.2k | input_row++; | 55 | 95.2k | outptr = *output_buf++; | 56 | 11.0M | for (col = 0; col < num_cols; col++) { | 57 | 10.9M | y = inptr0[col]; | 58 | 10.9M | cb = inptr1[col]; | 59 | 10.9M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 10.9M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 10.9M | outptr[RGB_GREEN] = range_limit[y + | 63 | 10.9M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 10.9M | SCALEBITS))]; | 65 | 10.9M | 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 | 10.9M | #ifdef RGB_ALPHA | 69 | 10.9M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 70 | 10.9M | #endif | 71 | 10.9M | outptr += RGB_PIXELSIZE; | 72 | 10.9M | } | 73 | 95.2k | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 36.2k | } |
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 | 9.46M | { |
92 | 9.46M | register _JSAMPROW inptr, outptr; |
93 | 9.46M | register JDIMENSION col; |
94 | 9.46M | JDIMENSION num_cols = cinfo->output_width; |
95 | | |
96 | 26.2M | while (--num_rows >= 0) { |
97 | 16.8M | inptr = input_buf[0][input_row++]; |
98 | 16.8M | outptr = *output_buf++; |
99 | 815M | for (col = 0; col < num_cols; col++) { |
100 | 798M | 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 | 57.1M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
105 | | #endif |
106 | 798M | outptr += RGB_PIXELSIZE; |
107 | 798M | } |
108 | 16.8M | } |
109 | 9.46M | } jdcolor.c:gray_extrgb_convert_internal Line | Count | Source | 91 | 6.14M | { | 92 | 6.14M | register _JSAMPROW inptr, outptr; | 93 | 6.14M | register JDIMENSION col; | 94 | 6.14M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 19.1M | while (--num_rows >= 0) { | 97 | 13.0M | inptr = input_buf[0][input_row++]; | 98 | 13.0M | outptr = *output_buf++; | 99 | 714M | for (col = 0; col < num_cols; col++) { | 100 | 701M | 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 | 701M | outptr += RGB_PIXELSIZE; | 107 | 701M | } | 108 | 13.0M | } | 109 | 6.14M | } |
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal jdcolor.c:gray_extbgr_convert_internal Line | Count | Source | 91 | 1.62M | { | 92 | 1.62M | register _JSAMPROW inptr, outptr; | 93 | 1.62M | register JDIMENSION col; | 94 | 1.62M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 3.25M | while (--num_rows >= 0) { | 97 | 1.62M | inptr = input_buf[0][input_row++]; | 98 | 1.62M | outptr = *output_buf++; | 99 | 41.5M | for (col = 0; col < num_cols; col++) { | 100 | 39.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 | 39.8M | outptr += RGB_PIXELSIZE; | 107 | 39.8M | } | 108 | 1.62M | } | 109 | 1.62M | } |
jdcolor.c:gray_extbgrx_convert_internal Line | Count | Source | 91 | 472k | { | 92 | 472k | register _JSAMPROW inptr, outptr; | 93 | 472k | register JDIMENSION col; | 94 | 472k | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 1.43M | while (--num_rows >= 0) { | 97 | 964k | inptr = input_buf[0][input_row++]; | 98 | 964k | outptr = *output_buf++; | 99 | 34.6M | for (col = 0; col < num_cols; col++) { | 100 | 33.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 | 33.6M | #ifdef RGB_ALPHA | 104 | 33.6M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 33.6M | #endif | 106 | 33.6M | outptr += RGB_PIXELSIZE; | 107 | 33.6M | } | 108 | 964k | } | 109 | 472k | } |
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal jdcolor.c:gray_extxrgb_convert_internal Line | Count | Source | 91 | 1.21M | { | 92 | 1.21M | register _JSAMPROW inptr, outptr; | 93 | 1.21M | register JDIMENSION col; | 94 | 1.21M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 2.43M | while (--num_rows >= 0) { | 97 | 1.21M | inptr = input_buf[0][input_row++]; | 98 | 1.21M | outptr = *output_buf++; | 99 | 24.6M | for (col = 0; col < num_cols; col++) { | 100 | 23.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 | 23.4M | #ifdef RGB_ALPHA | 104 | 23.4M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 23.4M | #endif | 106 | 23.4M | outptr += RGB_PIXELSIZE; | 107 | 23.4M | } | 108 | 1.21M | } | 109 | 1.21M | } |
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 | 181k | { |
122 | 181k | register _JSAMPROW inptr0, inptr1, inptr2; |
123 | 181k | register _JSAMPROW outptr; |
124 | 181k | register JDIMENSION col; |
125 | 181k | JDIMENSION num_cols = cinfo->output_width; |
126 | | |
127 | 419k | while (--num_rows >= 0) { |
128 | 237k | inptr0 = input_buf[0][input_row]; |
129 | 237k | inptr1 = input_buf[1][input_row]; |
130 | 237k | inptr2 = input_buf[2][input_row]; |
131 | 237k | input_row++; |
132 | 237k | outptr = *output_buf++; |
133 | 17.0M | for (col = 0; col < num_cols; col++) { |
134 | 16.8M | outptr[RGB_RED] = inptr0[col]; |
135 | 16.8M | outptr[RGB_GREEN] = inptr1[col]; |
136 | 16.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 | 8.83M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
141 | | #endif |
142 | 16.8M | outptr += RGB_PIXELSIZE; |
143 | 16.8M | } |
144 | 237k | } |
145 | 181k | } 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 | 68.1k | { | 122 | 68.1k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 68.1k | register _JSAMPROW outptr; | 124 | 68.1k | register JDIMENSION col; | 125 | 68.1k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 136k | while (--num_rows >= 0) { | 128 | 68.6k | inptr0 = input_buf[0][input_row]; | 129 | 68.6k | inptr1 = input_buf[1][input_row]; | 130 | 68.6k | inptr2 = input_buf[2][input_row]; | 131 | 68.6k | input_row++; | 132 | 68.6k | outptr = *output_buf++; | 133 | 8.03M | for (col = 0; col < num_cols; col++) { | 134 | 7.96M | outptr[RGB_RED] = inptr0[col]; | 135 | 7.96M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 7.96M | 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 | 7.96M | outptr += RGB_PIXELSIZE; | 143 | 7.96M | } | 144 | 68.6k | } | 145 | 68.1k | } |
jdcolor.c:rgb_extbgrx_convert_internal Line | Count | Source | 121 | 62.5k | { | 122 | 62.5k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 62.5k | register _JSAMPROW outptr; | 124 | 62.5k | register JDIMENSION col; | 125 | 62.5k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 179k | while (--num_rows >= 0) { | 128 | 117k | inptr0 = input_buf[0][input_row]; | 129 | 117k | inptr1 = input_buf[1][input_row]; | 130 | 117k | inptr2 = input_buf[2][input_row]; | 131 | 117k | input_row++; | 132 | 117k | outptr = *output_buf++; | 133 | 4.26M | for (col = 0; col < num_cols; col++) { | 134 | 4.15M | outptr[RGB_RED] = inptr0[col]; | 135 | 4.15M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 4.15M | outptr[RGB_BLUE] = inptr2[col]; | 137 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ | 138 | | /* opaque alpha channel value */ | 139 | 4.15M | #ifdef RGB_ALPHA | 140 | 4.15M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 4.15M | #endif | 142 | 4.15M | outptr += RGB_PIXELSIZE; | 143 | 4.15M | } | 144 | 117k | } | 145 | 62.5k | } |
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal jdcolor.c:rgb_extxrgb_convert_internal Line | Count | Source | 121 | 51.1k | { | 122 | 51.1k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 51.1k | register _JSAMPROW outptr; | 124 | 51.1k | register JDIMENSION col; | 125 | 51.1k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 102k | while (--num_rows >= 0) { | 128 | 51.5k | inptr0 = input_buf[0][input_row]; | 129 | 51.5k | inptr1 = input_buf[1][input_row]; | 130 | 51.5k | inptr2 = input_buf[2][input_row]; | 131 | 51.5k | input_row++; | 132 | 51.5k | outptr = *output_buf++; | 133 | 4.73M | for (col = 0; col < num_cols; col++) { | 134 | 4.67M | outptr[RGB_RED] = inptr0[col]; | 135 | 4.67M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 4.67M | outptr[RGB_BLUE] = inptr2[col]; | 137 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ | 138 | | /* opaque alpha channel value */ | 139 | 4.67M | #ifdef RGB_ALPHA | 140 | 4.67M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 4.67M | #endif | 142 | 4.67M | outptr += RGB_PIXELSIZE; | 143 | 4.67M | } | 144 | 51.5k | } | 145 | 51.1k | } |
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal |