/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.15M | while (--num_rows >= 0) { |
51 | 2.14M | inptr0 = input_buf[0][input_row]; |
52 | 2.14M | inptr1 = input_buf[1][input_row]; |
53 | 2.14M | inptr2 = input_buf[2][input_row]; |
54 | 2.14M | input_row++; |
55 | 2.14M | outptr = *output_buf++; |
56 | 109M | for (col = 0; col < num_cols; col++) { |
57 | 106M | y = inptr0[col]; |
58 | 106M | cb = inptr1[col]; |
59 | 106M | cr = inptr2[col]; |
60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ |
61 | 106M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; |
62 | 106M | outptr[RGB_GREEN] = range_limit[y + |
63 | 106M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
64 | 106M | SCALEBITS))]; |
65 | 106M | 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 | 14.1M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
70 | | #endif |
71 | 106M | outptr += RGB_PIXELSIZE; |
72 | 106M | } |
73 | 2.14M | } |
74 | | #else |
75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); |
76 | | #endif |
77 | 1.01M | } jdcolor.c:ycc_extrgb_convert_internal Line | Count | Source | 34 | 973k | { | 35 | 973k | #if BITS_IN_JSAMPLE != 16 | 36 | 973k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 973k | register int y, cb, cr; | 38 | 973k | register _JSAMPROW outptr; | 39 | 973k | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 973k | register JDIMENSION col; | 41 | 973k | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 973k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 973k | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 973k | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 973k | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 973k | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 973k | SHIFT_TEMPS | 49 | | | 50 | 3.00M | 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 | 94.8M | for (col = 0; col < num_cols; col++) { | 57 | 92.8M | y = inptr0[col]; | 58 | 92.8M | cb = inptr1[col]; | 59 | 92.8M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 92.8M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 92.8M | outptr[RGB_GREEN] = range_limit[y + | 63 | 92.8M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 92.8M | SCALEBITS))]; | 65 | 92.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 | 92.8M | outptr += RGB_PIXELSIZE; | 72 | 92.8M | } | 73 | 2.03M | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 973k | } |
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 | 41.1k | { | 35 | 41.1k | #if BITS_IN_JSAMPLE != 16 | 36 | 41.1k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 41.1k | register int y, cb, cr; | 38 | 41.1k | register _JSAMPROW outptr; | 39 | 41.1k | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 41.1k | register JDIMENSION col; | 41 | 41.1k | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 41.1k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 41.1k | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 41.1k | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 41.1k | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 41.1k | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 41.1k | SHIFT_TEMPS | 49 | | | 50 | 151k | while (--num_rows >= 0) { | 51 | 110k | inptr0 = input_buf[0][input_row]; | 52 | 110k | inptr1 = input_buf[1][input_row]; | 53 | 110k | inptr2 = input_buf[2][input_row]; | 54 | 110k | input_row++; | 55 | 110k | outptr = *output_buf++; | 56 | 14.2M | for (col = 0; col < num_cols; col++) { | 57 | 14.1M | y = inptr0[col]; | 58 | 14.1M | cb = inptr1[col]; | 59 | 14.1M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 14.1M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 14.1M | outptr[RGB_GREEN] = range_limit[y + | 63 | 14.1M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 14.1M | SCALEBITS))]; | 65 | 14.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 | 14.1M | #ifdef RGB_ALPHA | 69 | 14.1M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 70 | 14.1M | #endif | 71 | 14.1M | outptr += RGB_PIXELSIZE; | 72 | 14.1M | } | 73 | 110k | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 41.1k | } |
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.48M | { |
92 | 9.48M | register _JSAMPROW inptr, outptr; |
93 | 9.48M | register JDIMENSION col; |
94 | 9.48M | JDIMENSION num_cols = cinfo->output_width; |
95 | | |
96 | 26.6M | while (--num_rows >= 0) { |
97 | 17.1M | inptr = input_buf[0][input_row++]; |
98 | 17.1M | outptr = *output_buf++; |
99 | 833M | for (col = 0; col < num_cols; col++) { |
100 | 816M | 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 | 55.9M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
105 | | #endif |
106 | 816M | outptr += RGB_PIXELSIZE; |
107 | 816M | } |
108 | 17.1M | } |
109 | 9.48M | } jdcolor.c:gray_extrgb_convert_internal Line | Count | Source | 91 | 5.79M | { | 92 | 5.79M | register _JSAMPROW inptr, outptr; | 93 | 5.79M | register JDIMENSION col; | 94 | 5.79M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 18.9M | while (--num_rows >= 0) { | 97 | 13.1M | inptr = input_buf[0][input_row++]; | 98 | 13.1M | outptr = *output_buf++; | 99 | 732M | for (col = 0; col < num_cols; col++) { | 100 | 719M | 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 | 719M | outptr += RGB_PIXELSIZE; | 107 | 719M | } | 108 | 13.1M | } | 109 | 5.79M | } |
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal jdcolor.c:gray_extbgr_convert_internal Line | Count | Source | 91 | 1.92M | { | 92 | 1.92M | register _JSAMPROW inptr, outptr; | 93 | 1.92M | register JDIMENSION col; | 94 | 1.92M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 3.85M | while (--num_rows >= 0) { | 97 | 1.92M | inptr = input_buf[0][input_row++]; | 98 | 1.92M | outptr = *output_buf++; | 99 | 42.4M | for (col = 0; col < num_cols; col++) { | 100 | 40.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 | 40.5M | outptr += RGB_PIXELSIZE; | 107 | 40.5M | } | 108 | 1.92M | } | 109 | 1.92M | } |
jdcolor.c:gray_extbgrx_convert_internal Line | Count | Source | 91 | 307k | { | 92 | 307k | register _JSAMPROW inptr, outptr; | 93 | 307k | register JDIMENSION col; | 94 | 307k | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 988k | while (--num_rows >= 0) { | 97 | 681k | inptr = input_buf[0][input_row++]; | 98 | 681k | outptr = *output_buf++; | 99 | 32.7M | for (col = 0; col < num_cols; col++) { | 100 | 32.0M | 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 | 32.0M | #ifdef RGB_ALPHA | 104 | 32.0M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 32.0M | #endif | 106 | 32.0M | outptr += RGB_PIXELSIZE; | 107 | 32.0M | } | 108 | 681k | } | 109 | 307k | } |
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal jdcolor.c:gray_extxrgb_convert_internal Line | Count | Source | 91 | 1.44M | { | 92 | 1.44M | register _JSAMPROW inptr, outptr; | 93 | 1.44M | register JDIMENSION col; | 94 | 1.44M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 2.89M | while (--num_rows >= 0) { | 97 | 1.44M | inptr = input_buf[0][input_row++]; | 98 | 1.44M | outptr = *output_buf++; | 99 | 25.3M | for (col = 0; col < num_cols; col++) { | 100 | 23.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 | 23.8M | #ifdef RGB_ALPHA | 104 | 23.8M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 23.8M | #endif | 106 | 23.8M | outptr += RGB_PIXELSIZE; | 107 | 23.8M | } | 108 | 1.44M | } | 109 | 1.44M | } |
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 | 204k | { |
122 | 204k | register _JSAMPROW inptr0, inptr1, inptr2; |
123 | 204k | register _JSAMPROW outptr; |
124 | 204k | register JDIMENSION col; |
125 | 204k | JDIMENSION num_cols = cinfo->output_width; |
126 | | |
127 | 488k | while (--num_rows >= 0) { |
128 | 284k | inptr0 = input_buf[0][input_row]; |
129 | 284k | inptr1 = input_buf[1][input_row]; |
130 | 284k | inptr2 = input_buf[2][input_row]; |
131 | 284k | input_row++; |
132 | 284k | outptr = *output_buf++; |
133 | 18.6M | for (col = 0; col < num_cols; col++) { |
134 | 18.3M | outptr[RGB_RED] = inptr0[col]; |
135 | 18.3M | outptr[RGB_GREEN] = inptr1[col]; |
136 | 18.3M | 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.77M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
141 | | #endif |
142 | 18.3M | outptr += RGB_PIXELSIZE; |
143 | 18.3M | } |
144 | 284k | } |
145 | 204k | } 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 | 71.2k | { | 122 | 71.2k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 71.2k | register _JSAMPROW outptr; | 124 | 71.2k | register JDIMENSION col; | 125 | 71.2k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 147k | while (--num_rows >= 0) { | 128 | 76.4k | inptr0 = input_buf[0][input_row]; | 129 | 76.4k | inptr1 = input_buf[1][input_row]; | 130 | 76.4k | inptr2 = input_buf[2][input_row]; | 131 | 76.4k | input_row++; | 132 | 76.4k | outptr = *output_buf++; | 133 | 9.63M | for (col = 0; col < num_cols; col++) { | 134 | 9.55M | outptr[RGB_RED] = inptr0[col]; | 135 | 9.55M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 9.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 | | #ifdef RGB_ALPHA | 140 | | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | | #endif | 142 | 9.55M | outptr += RGB_PIXELSIZE; | 143 | 9.55M | } | 144 | 76.4k | } | 145 | 71.2k | } |
jdcolor.c:rgb_extbgrx_convert_internal Line | Count | Source | 121 | 79.5k | { | 122 | 79.5k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 79.5k | register _JSAMPROW outptr; | 124 | 79.5k | register JDIMENSION col; | 125 | 79.5k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 230k | while (--num_rows >= 0) { | 128 | 150k | inptr0 = input_buf[0][input_row]; | 129 | 150k | inptr1 = input_buf[1][input_row]; | 130 | 150k | inptr2 = input_buf[2][input_row]; | 131 | 150k | input_row++; | 132 | 150k | outptr = *output_buf++; | 133 | 3.41M | for (col = 0; col < num_cols; col++) { | 134 | 3.26M | outptr[RGB_RED] = inptr0[col]; | 135 | 3.26M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 3.26M | 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.26M | #ifdef RGB_ALPHA | 140 | 3.26M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 3.26M | #endif | 142 | 3.26M | outptr += RGB_PIXELSIZE; | 143 | 3.26M | } | 144 | 150k | } | 145 | 79.5k | } |
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal jdcolor.c:rgb_extxrgb_convert_internal Line | Count | Source | 121 | 53.4k | { | 122 | 53.4k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 53.4k | register _JSAMPROW outptr; | 124 | 53.4k | register JDIMENSION col; | 125 | 53.4k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 110k | while (--num_rows >= 0) { | 128 | 57.3k | inptr0 = input_buf[0][input_row]; | 129 | 57.3k | inptr1 = input_buf[1][input_row]; | 130 | 57.3k | inptr2 = input_buf[2][input_row]; | 131 | 57.3k | input_row++; | 132 | 57.3k | outptr = *output_buf++; | 133 | 5.57M | for (col = 0; col < num_cols; col++) { | 134 | 5.51M | outptr[RGB_RED] = inptr0[col]; | 135 | 5.51M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 5.51M | outptr[RGB_BLUE] = inptr2[col]; | 137 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ | 138 | | /* opaque alpha channel value */ | 139 | 5.51M | #ifdef RGB_ALPHA | 140 | 5.51M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 5.51M | #endif | 142 | 5.51M | outptr += RGB_PIXELSIZE; | 143 | 5.51M | } | 144 | 57.3k | } | 145 | 53.4k | } |
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal |