/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.10M | { |
35 | 1.10M | #if BITS_IN_JSAMPLE != 16 |
36 | 1.10M | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; |
37 | 1.10M | register int y, cb, cr; |
38 | 1.10M | register _JSAMPROW outptr; |
39 | 1.10M | register _JSAMPROW inptr0, inptr1, inptr2; |
40 | 1.10M | register JDIMENSION col; |
41 | 1.10M | JDIMENSION num_cols = cinfo->output_width; |
42 | | /* copy these pointers into registers if possible */ |
43 | 1.10M | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; |
44 | 1.10M | register int *Crrtab = cconvert->Cr_r_tab; |
45 | 1.10M | register int *Cbbtab = cconvert->Cb_b_tab; |
46 | 1.10M | register JLONG *Crgtab = cconvert->Cr_g_tab; |
47 | 1.10M | register JLONG *Cbgtab = cconvert->Cb_g_tab; |
48 | 1.10M | SHIFT_TEMPS |
49 | | |
50 | 3.17M | while (--num_rows >= 0) { |
51 | 2.06M | inptr0 = input_buf[0][input_row]; |
52 | 2.06M | inptr1 = input_buf[1][input_row]; |
53 | 2.06M | inptr2 = input_buf[2][input_row]; |
54 | 2.06M | input_row++; |
55 | 2.06M | outptr = *output_buf++; |
56 | 110M | for (col = 0; col < num_cols; col++) { |
57 | 108M | y = inptr0[col]; |
58 | 108M | cb = inptr1[col]; |
59 | 108M | cr = inptr2[col]; |
60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ |
61 | 108M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; |
62 | 108M | outptr[RGB_GREEN] = range_limit[y + |
63 | 108M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
64 | 108M | SCALEBITS))]; |
65 | 108M | 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 | 16.3M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
70 | | #endif |
71 | 108M | outptr += RGB_PIXELSIZE; |
72 | 108M | } |
73 | 2.06M | } |
74 | | #else |
75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); |
76 | | #endif |
77 | 1.10M | } jdcolor.c:ycc_extrgb_convert_internal Line | Count | Source | 34 | 1.03M | { | 35 | 1.03M | #if BITS_IN_JSAMPLE != 16 | 36 | 1.03M | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 1.03M | register int y, cb, cr; | 38 | 1.03M | register _JSAMPROW outptr; | 39 | 1.03M | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 1.03M | register JDIMENSION col; | 41 | 1.03M | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 1.03M | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 1.03M | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 1.03M | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 1.03M | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 1.03M | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 1.03M | SHIFT_TEMPS | 49 | | | 50 | 2.93M | while (--num_rows >= 0) { | 51 | 1.90M | inptr0 = input_buf[0][input_row]; | 52 | 1.90M | inptr1 = input_buf[1][input_row]; | 53 | 1.90M | inptr2 = input_buf[2][input_row]; | 54 | 1.90M | input_row++; | 55 | 1.90M | outptr = *output_buf++; | 56 | 94.0M | for (col = 0; col < num_cols; col++) { | 57 | 92.1M | y = inptr0[col]; | 58 | 92.1M | cb = inptr1[col]; | 59 | 92.1M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 92.1M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 92.1M | outptr[RGB_GREEN] = range_limit[y + | 63 | 92.1M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 92.1M | SCALEBITS))]; | 65 | 92.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 | | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 70 | | #endif | 71 | 92.1M | outptr += RGB_PIXELSIZE; | 72 | 92.1M | } | 73 | 1.90M | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 1.03M | } |
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 | 73.9k | { | 35 | 73.9k | #if BITS_IN_JSAMPLE != 16 | 36 | 73.9k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 73.9k | register int y, cb, cr; | 38 | 73.9k | register _JSAMPROW outptr; | 39 | 73.9k | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 73.9k | register JDIMENSION col; | 41 | 73.9k | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 73.9k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 73.9k | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 73.9k | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 73.9k | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 73.9k | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 73.9k | SHIFT_TEMPS | 49 | | | 50 | 233k | while (--num_rows >= 0) { | 51 | 160k | inptr0 = input_buf[0][input_row]; | 52 | 160k | inptr1 = input_buf[1][input_row]; | 53 | 160k | inptr2 = input_buf[2][input_row]; | 54 | 160k | input_row++; | 55 | 160k | outptr = *output_buf++; | 56 | 16.4M | for (col = 0; col < num_cols; col++) { | 57 | 16.3M | y = inptr0[col]; | 58 | 16.3M | cb = inptr1[col]; | 59 | 16.3M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 16.3M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 16.3M | outptr[RGB_GREEN] = range_limit[y + | 63 | 16.3M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 16.3M | SCALEBITS))]; | 65 | 16.3M | 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 | 16.3M | #ifdef RGB_ALPHA | 69 | 16.3M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 70 | 16.3M | #endif | 71 | 16.3M | outptr += RGB_PIXELSIZE; | 72 | 16.3M | } | 73 | 160k | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 73.9k | } |
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.04M | { |
92 | 9.04M | register _JSAMPROW inptr, outptr; |
93 | 9.04M | register JDIMENSION col; |
94 | 9.04M | JDIMENSION num_cols = cinfo->output_width; |
95 | | |
96 | 25.8M | while (--num_rows >= 0) { |
97 | 16.7M | inptr = input_buf[0][input_row++]; |
98 | 16.7M | outptr = *output_buf++; |
99 | 803M | for (col = 0; col < num_cols; col++) { |
100 | 786M | 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 | 52.5M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
105 | | #endif |
106 | 786M | outptr += RGB_PIXELSIZE; |
107 | 786M | } |
108 | 16.7M | } |
109 | 9.04M | } jdcolor.c:gray_extrgb_convert_internal Line | Count | Source | 91 | 5.89M | { | 92 | 5.89M | register _JSAMPROW inptr, outptr; | 93 | 5.89M | register JDIMENSION col; | 94 | 5.89M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 19.2M | while (--num_rows >= 0) { | 97 | 13.3M | inptr = input_buf[0][input_row++]; | 98 | 13.3M | outptr = *output_buf++; | 99 | 708M | for (col = 0; col < num_cols; col++) { | 100 | 695M | 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 | 695M | outptr += RGB_PIXELSIZE; | 107 | 695M | } | 108 | 13.3M | } | 109 | 5.89M | } |
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal jdcolor.c:gray_extbgr_convert_internal Line | Count | Source | 91 | 1.67M | { | 92 | 1.67M | register _JSAMPROW inptr, outptr; | 93 | 1.67M | register JDIMENSION col; | 94 | 1.67M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 3.34M | while (--num_rows >= 0) { | 97 | 1.67M | inptr = input_buf[0][input_row++]; | 98 | 1.67M | outptr = *output_buf++; | 99 | 40.1M | for (col = 0; col < num_cols; col++) { | 100 | 38.5M | 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 | 38.5M | outptr += RGB_PIXELSIZE; | 107 | 38.5M | } | 108 | 1.67M | } | 109 | 1.67M | } |
jdcolor.c:gray_extbgrx_convert_internal Line | Count | Source | 91 | 224k | { | 92 | 224k | register _JSAMPROW inptr, outptr; | 93 | 224k | register JDIMENSION col; | 94 | 224k | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 703k | while (--num_rows >= 0) { | 97 | 479k | inptr = input_buf[0][input_row++]; | 98 | 479k | outptr = *output_buf++; | 99 | 30.3M | for (col = 0; col < num_cols; col++) { | 100 | 29.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 | 29.8M | #ifdef RGB_ALPHA | 104 | 29.8M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 29.8M | #endif | 106 | 29.8M | outptr += RGB_PIXELSIZE; | 107 | 29.8M | } | 108 | 479k | } | 109 | 224k | } |
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal jdcolor.c:gray_extxrgb_convert_internal Line | Count | Source | 91 | 1.25M | { | 92 | 1.25M | register _JSAMPROW inptr, outptr; | 93 | 1.25M | register JDIMENSION col; | 94 | 1.25M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 2.50M | while (--num_rows >= 0) { | 97 | 1.25M | inptr = input_buf[0][input_row++]; | 98 | 1.25M | outptr = *output_buf++; | 99 | 23.9M | for (col = 0; col < num_cols; col++) { | 100 | 22.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 | 22.6M | #ifdef RGB_ALPHA | 104 | 22.6M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 22.6M | #endif | 106 | 22.6M | outptr += RGB_PIXELSIZE; | 107 | 22.6M | } | 108 | 1.25M | } | 109 | 1.25M | } |
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 | 278k | { |
122 | 278k | register _JSAMPROW inptr0, inptr1, inptr2; |
123 | 278k | register _JSAMPROW outptr; |
124 | 278k | register JDIMENSION col; |
125 | 278k | JDIMENSION num_cols = cinfo->output_width; |
126 | | |
127 | 665k | while (--num_rows >= 0) { |
128 | 387k | inptr0 = input_buf[0][input_row]; |
129 | 387k | inptr1 = input_buf[1][input_row]; |
130 | 387k | inptr2 = input_buf[2][input_row]; |
131 | 387k | input_row++; |
132 | 387k | outptr = *output_buf++; |
133 | 17.1M | for (col = 0; col < num_cols; col++) { |
134 | 16.7M | outptr[RGB_RED] = inptr0[col]; |
135 | 16.7M | outptr[RGB_GREEN] = inptr1[col]; |
136 | 16.7M | 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.45M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
141 | | #endif |
142 | 16.7M | outptr += RGB_PIXELSIZE; |
143 | 16.7M | } |
144 | 387k | } |
145 | 278k | } 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 | 108k | { | 122 | 108k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 108k | register _JSAMPROW outptr; | 124 | 108k | register JDIMENSION col; | 125 | 108k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 223k | while (--num_rows >= 0) { | 128 | 114k | inptr0 = input_buf[0][input_row]; | 129 | 114k | inptr1 = input_buf[1][input_row]; | 130 | 114k | inptr2 = input_buf[2][input_row]; | 131 | 114k | input_row++; | 132 | 114k | outptr = *output_buf++; | 133 | 8.41M | for (col = 0; col < num_cols; col++) { | 134 | 8.30M | outptr[RGB_RED] = inptr0[col]; | 135 | 8.30M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 8.30M | 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 | 8.30M | outptr += RGB_PIXELSIZE; | 143 | 8.30M | } | 144 | 114k | } | 145 | 108k | } |
jdcolor.c:rgb_extbgrx_convert_internal Line | Count | Source | 121 | 87.5k | { | 122 | 87.5k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 87.5k | register _JSAMPROW outptr; | 124 | 87.5k | register JDIMENSION col; | 125 | 87.5k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 275k | while (--num_rows >= 0) { | 128 | 187k | inptr0 = input_buf[0][input_row]; | 129 | 187k | inptr1 = input_buf[1][input_row]; | 130 | 187k | inptr2 = input_buf[2][input_row]; | 131 | 187k | input_row++; | 132 | 187k | outptr = *output_buf++; | 133 | 3.87M | for (col = 0; col < num_cols; col++) { | 134 | 3.68M | outptr[RGB_RED] = inptr0[col]; | 135 | 3.68M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 3.68M | 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.68M | #ifdef RGB_ALPHA | 140 | 3.68M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 3.68M | #endif | 142 | 3.68M | outptr += RGB_PIXELSIZE; | 143 | 3.68M | } | 144 | 187k | } | 145 | 87.5k | } |
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal jdcolor.c:rgb_extxrgb_convert_internal Line | Count | Source | 121 | 81.6k | { | 122 | 81.6k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 81.6k | register _JSAMPROW outptr; | 124 | 81.6k | register JDIMENSION col; | 125 | 81.6k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 167k | while (--num_rows >= 0) { | 128 | 85.6k | inptr0 = input_buf[0][input_row]; | 129 | 85.6k | inptr1 = input_buf[1][input_row]; | 130 | 85.6k | inptr2 = input_buf[2][input_row]; | 131 | 85.6k | input_row++; | 132 | 85.6k | outptr = *output_buf++; | 133 | 4.85M | for (col = 0; col < num_cols; col++) { | 134 | 4.76M | outptr[RGB_RED] = inptr0[col]; | 135 | 4.76M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 4.76M | 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.76M | #ifdef RGB_ALPHA | 140 | 4.76M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 4.76M | #endif | 142 | 4.76M | outptr += RGB_PIXELSIZE; | 143 | 4.76M | } | 144 | 85.6k | } | 145 | 81.6k | } |
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal |