/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.31M | { |
35 | 1.31M | #if BITS_IN_JSAMPLE != 16 |
36 | 1.31M | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; |
37 | 1.31M | register int y, cb, cr; |
38 | 1.31M | register _JSAMPROW outptr; |
39 | 1.31M | register _JSAMPROW inptr0, inptr1, inptr2; |
40 | 1.31M | register JDIMENSION col; |
41 | 1.31M | JDIMENSION num_cols = cinfo->output_width; |
42 | | /* copy these pointers into registers if possible */ |
43 | 1.31M | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; |
44 | 1.31M | register int *Crrtab = cconvert->Cr_r_tab; |
45 | 1.31M | register int *Cbbtab = cconvert->Cb_b_tab; |
46 | 1.31M | register JLONG *Crgtab = cconvert->Cr_g_tab; |
47 | 1.31M | register JLONG *Cbgtab = cconvert->Cb_g_tab; |
48 | 1.31M | SHIFT_TEMPS |
49 | | |
50 | 4.52M | while (--num_rows >= 0) { |
51 | 3.20M | inptr0 = input_buf[0][input_row]; |
52 | 3.20M | inptr1 = input_buf[1][input_row]; |
53 | 3.20M | inptr2 = input_buf[2][input_row]; |
54 | 3.20M | input_row++; |
55 | 3.20M | outptr = *output_buf++; |
56 | 60.9M | for (col = 0; col < num_cols; col++) { |
57 | 57.7M | y = inptr0[col]; |
58 | 57.7M | cb = inptr1[col]; |
59 | 57.7M | cr = inptr2[col]; |
60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ |
61 | 57.7M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; |
62 | 57.7M | outptr[RGB_GREEN] = range_limit[y + |
63 | 57.7M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
64 | 57.7M | SCALEBITS))]; |
65 | 57.7M | 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.8M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
70 | | #endif |
71 | 57.7M | outptr += RGB_PIXELSIZE; |
72 | 57.7M | } |
73 | 3.20M | } |
74 | | #else |
75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); |
76 | | #endif |
77 | 1.31M | } jdcolor.c:ycc_extrgb_convert_internal Line | Count | Source | 34 | 813k | { | 35 | 813k | #if BITS_IN_JSAMPLE != 16 | 36 | 813k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 813k | register int y, cb, cr; | 38 | 813k | register _JSAMPROW outptr; | 39 | 813k | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 813k | register JDIMENSION col; | 41 | 813k | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 813k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 813k | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 813k | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 813k | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 813k | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 813k | SHIFT_TEMPS | 49 | | | 50 | 2.84M | while (--num_rows >= 0) { | 51 | 2.03M | inptr0 = input_buf[0][input_row]; | 52 | 2.03M | inptr1 = input_buf[1][input_row]; | 53 | 2.03M | inptr2 = input_buf[2][input_row]; | 54 | 2.03M | input_row++; | 55 | 2.03M | outptr = *output_buf++; | 56 | 45.8M | for (col = 0; col < num_cols; col++) { | 57 | 43.8M | y = inptr0[col]; | 58 | 43.8M | cb = inptr1[col]; | 59 | 43.8M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 43.8M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 43.8M | outptr[RGB_GREEN] = range_limit[y + | 63 | 43.8M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 43.8M | SCALEBITS))]; | 65 | 43.8M | 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 | 43.8M | outptr += RGB_PIXELSIZE; | 72 | 43.8M | } | 73 | 2.03M | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 813k | } |
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 | 502k | { | 35 | 502k | #if BITS_IN_JSAMPLE != 16 | 36 | 502k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 502k | register int y, cb, cr; | 38 | 502k | register _JSAMPROW outptr; | 39 | 502k | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 502k | register JDIMENSION col; | 41 | 502k | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 502k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 502k | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 502k | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 502k | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 502k | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 502k | SHIFT_TEMPS | 49 | | | 50 | 1.67M | while (--num_rows >= 0) { | 51 | 1.17M | inptr0 = input_buf[0][input_row]; | 52 | 1.17M | inptr1 = input_buf[1][input_row]; | 53 | 1.17M | inptr2 = input_buf[2][input_row]; | 54 | 1.17M | input_row++; | 55 | 1.17M | outptr = *output_buf++; | 56 | 15.0M | for (col = 0; col < num_cols; col++) { | 57 | 13.8M | y = inptr0[col]; | 58 | 13.8M | cb = inptr1[col]; | 59 | 13.8M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 13.8M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 13.8M | outptr[RGB_GREEN] = range_limit[y + | 63 | 13.8M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 13.8M | SCALEBITS))]; | 65 | 13.8M | 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.8M | #ifdef RGB_ALPHA | 69 | 13.8M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 70 | 13.8M | #endif | 71 | 13.8M | outptr += RGB_PIXELSIZE; | 72 | 13.8M | } | 73 | 1.17M | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 502k | } |
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 | 10.5M | { |
92 | 10.5M | register _JSAMPROW inptr, outptr; |
93 | 10.5M | register JDIMENSION col; |
94 | 10.5M | JDIMENSION num_cols = cinfo->output_width; |
95 | | |
96 | 30.7M | while (--num_rows >= 0) { |
97 | 20.1M | inptr = input_buf[0][input_row++]; |
98 | 20.1M | outptr = *output_buf++; |
99 | 928M | for (col = 0; col < num_cols; col++) { |
100 | 908M | 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 | 190M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
105 | | #endif |
106 | 908M | outptr += RGB_PIXELSIZE; |
107 | 908M | } |
108 | 20.1M | } |
109 | 10.5M | } jdcolor.c:gray_extrgb_convert_internal Line | Count | Source | 91 | 5.64M | { | 92 | 5.64M | register _JSAMPROW inptr, outptr; | 93 | 5.64M | register JDIMENSION col; | 94 | 5.64M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 17.7M | while (--num_rows >= 0) { | 97 | 12.0M | inptr = input_buf[0][input_row++]; | 98 | 12.0M | outptr = *output_buf++; | 99 | 706M | for (col = 0; col < num_cols; col++) { | 100 | 694M | 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 | 694M | outptr += RGB_PIXELSIZE; | 107 | 694M | } | 108 | 12.0M | } | 109 | 5.64M | } |
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal jdcolor.c:gray_extbgr_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.42M | while (--num_rows >= 0) { | 97 | 1.21M | inptr = input_buf[0][input_row++]; | 98 | 1.21M | outptr = *output_buf++; | 99 | 25.3M | for (col = 0; col < num_cols; col++) { | 100 | 24.1M | 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 | 24.1M | outptr += RGB_PIXELSIZE; | 107 | 24.1M | } | 108 | 1.21M | } | 109 | 1.21M | } |
jdcolor.c:gray_extbgrx_convert_internal Line | Count | Source | 91 | 2.79M | { | 92 | 2.79M | register _JSAMPROW inptr, outptr; | 93 | 2.79M | register JDIMENSION col; | 94 | 2.79M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 8.75M | while (--num_rows >= 0) { | 97 | 5.95M | inptr = input_buf[0][input_row++]; | 98 | 5.95M | outptr = *output_buf++; | 99 | 182M | for (col = 0; col < num_cols; col++) { | 100 | 176M | 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 | 176M | #ifdef RGB_ALPHA | 104 | 176M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 176M | #endif | 106 | 176M | outptr += RGB_PIXELSIZE; | 107 | 176M | } | 108 | 5.95M | } | 109 | 2.79M | } |
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal jdcolor.c:gray_extxrgb_convert_internal Line | Count | Source | 91 | 910k | { | 92 | 910k | register _JSAMPROW inptr, outptr; | 93 | 910k | register JDIMENSION col; | 94 | 910k | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 1.82M | while (--num_rows >= 0) { | 97 | 910k | inptr = input_buf[0][input_row++]; | 98 | 910k | outptr = *output_buf++; | 99 | 15.2M | for (col = 0; col < num_cols; col++) { | 100 | 14.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 | 14.3M | #ifdef RGB_ALPHA | 104 | 14.3M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 14.3M | #endif | 106 | 14.3M | outptr += RGB_PIXELSIZE; | 107 | 14.3M | } | 108 | 910k | } | 109 | 910k | } |
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 | 917k | { |
122 | 917k | register _JSAMPROW inptr0, inptr1, inptr2; |
123 | 917k | register _JSAMPROW outptr; |
124 | 917k | register JDIMENSION col; |
125 | 917k | JDIMENSION num_cols = cinfo->output_width; |
126 | | |
127 | 2.51M | while (--num_rows >= 0) { |
128 | 1.60M | inptr0 = input_buf[0][input_row]; |
129 | 1.60M | inptr1 = input_buf[1][input_row]; |
130 | 1.60M | inptr2 = input_buf[2][input_row]; |
131 | 1.60M | input_row++; |
132 | 1.60M | outptr = *output_buf++; |
133 | 44.5M | for (col = 0; col < num_cols; col++) { |
134 | 42.9M | outptr[RGB_RED] = inptr0[col]; |
135 | 42.9M | outptr[RGB_GREEN] = inptr1[col]; |
136 | 42.9M | 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 | 36.3M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
141 | | #endif |
142 | 42.9M | outptr += RGB_PIXELSIZE; |
143 | 42.9M | } |
144 | 1.60M | } |
145 | 917k | } 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.7k | { | 122 | 67.7k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 67.7k | register _JSAMPROW outptr; | 124 | 67.7k | register JDIMENSION col; | 125 | 67.7k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 136k | while (--num_rows >= 0) { | 128 | 68.3k | inptr0 = input_buf[0][input_row]; | 129 | 68.3k | inptr1 = input_buf[1][input_row]; | 130 | 68.3k | inptr2 = input_buf[2][input_row]; | 131 | 68.3k | input_row++; | 132 | 68.3k | outptr = *output_buf++; | 133 | 6.70M | for (col = 0; col < num_cols; col++) { | 134 | 6.63M | outptr[RGB_RED] = inptr0[col]; | 135 | 6.63M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 6.63M | 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.63M | outptr += RGB_PIXELSIZE; | 143 | 6.63M | } | 144 | 68.3k | } | 145 | 67.7k | } |
jdcolor.c:rgb_extbgrx_convert_internal Line | Count | Source | 121 | 798k | { | 122 | 798k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 798k | register _JSAMPROW outptr; | 124 | 798k | register JDIMENSION col; | 125 | 798k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 2.28M | while (--num_rows >= 0) { | 128 | 1.48M | inptr0 = input_buf[0][input_row]; | 129 | 1.48M | inptr1 = input_buf[1][input_row]; | 130 | 1.48M | inptr2 = input_buf[2][input_row]; | 131 | 1.48M | input_row++; | 132 | 1.48M | outptr = *output_buf++; | 133 | 33.9M | for (col = 0; col < num_cols; col++) { | 134 | 32.4M | outptr[RGB_RED] = inptr0[col]; | 135 | 32.4M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 32.4M | outptr[RGB_BLUE] = inptr2[col]; | 137 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ | 138 | | /* opaque alpha channel value */ | 139 | 32.4M | #ifdef RGB_ALPHA | 140 | 32.4M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 32.4M | #endif | 142 | 32.4M | outptr += RGB_PIXELSIZE; | 143 | 32.4M | } | 144 | 1.48M | } | 145 | 798k | } |
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal jdcolor.c:rgb_extxrgb_convert_internal Line | Count | Source | 121 | 50.8k | { | 122 | 50.8k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 50.8k | register _JSAMPROW outptr; | 124 | 50.8k | register JDIMENSION col; | 125 | 50.8k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 102k | while (--num_rows >= 0) { | 128 | 51.2k | inptr0 = input_buf[0][input_row]; | 129 | 51.2k | inptr1 = input_buf[1][input_row]; | 130 | 51.2k | inptr2 = input_buf[2][input_row]; | 131 | 51.2k | input_row++; | 132 | 51.2k | outptr = *output_buf++; | 133 | 3.91M | for (col = 0; col < num_cols; col++) { | 134 | 3.86M | outptr[RGB_RED] = inptr0[col]; | 135 | 3.86M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 3.86M | 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.86M | #ifdef RGB_ALPHA | 140 | 3.86M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 3.86M | #endif | 142 | 3.86M | outptr += RGB_PIXELSIZE; | 143 | 3.86M | } | 144 | 51.2k | } | 145 | 50.8k | } |
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal |