/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 | 946k | { |
35 | 946k | #if BITS_IN_JSAMPLE != 16 |
36 | 946k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; |
37 | 946k | register int y, cb, cr; |
38 | 946k | register _JSAMPROW outptr; |
39 | 946k | register _JSAMPROW inptr0, inptr1, inptr2; |
40 | 946k | register JDIMENSION col; |
41 | 946k | JDIMENSION num_cols = cinfo->output_width; |
42 | | /* copy these pointers into registers if possible */ |
43 | 946k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; |
44 | 946k | register int *Crrtab = cconvert->Cr_r_tab; |
45 | 946k | register int *Cbbtab = cconvert->Cb_b_tab; |
46 | 946k | register JLONG *Crgtab = cconvert->Cr_g_tab; |
47 | 946k | register JLONG *Cbgtab = cconvert->Cb_g_tab; |
48 | 946k | SHIFT_TEMPS |
49 | | |
50 | 2.93M | while (--num_rows >= 0) { |
51 | 1.99M | inptr0 = input_buf[0][input_row]; |
52 | 1.99M | inptr1 = input_buf[1][input_row]; |
53 | 1.99M | inptr2 = input_buf[2][input_row]; |
54 | 1.99M | input_row++; |
55 | 1.99M | outptr = *output_buf++; |
56 | 93.6M | for (col = 0; col < num_cols; col++) { |
57 | 91.6M | y = inptr0[col]; |
58 | 91.6M | cb = inptr1[col]; |
59 | 91.6M | cr = inptr2[col]; |
60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ |
61 | 91.6M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; |
62 | 91.6M | outptr[RGB_GREEN] = range_limit[y + |
63 | 91.6M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
64 | 91.6M | SCALEBITS))]; |
65 | 91.6M | 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 | 12.0M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
70 | | #endif |
71 | 91.6M | outptr += RGB_PIXELSIZE; |
72 | 91.6M | } |
73 | 1.99M | } |
74 | | #else |
75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); |
76 | | #endif |
77 | 946k | } jdcolor.c:ycc_extrgb_convert_internal Line | Count | Source | 34 | 906k | { | 35 | 906k | #if BITS_IN_JSAMPLE != 16 | 36 | 906k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 906k | register int y, cb, cr; | 38 | 906k | register _JSAMPROW outptr; | 39 | 906k | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 906k | register JDIMENSION col; | 41 | 906k | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 906k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 906k | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 906k | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 906k | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 906k | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 906k | SHIFT_TEMPS | 49 | | | 50 | 2.79M | while (--num_rows >= 0) { | 51 | 1.89M | inptr0 = input_buf[0][input_row]; | 52 | 1.89M | inptr1 = input_buf[1][input_row]; | 53 | 1.89M | inptr2 = input_buf[2][input_row]; | 54 | 1.89M | input_row++; | 55 | 1.89M | outptr = *output_buf++; | 56 | 81.5M | for (col = 0; col < num_cols; col++) { | 57 | 79.6M | y = inptr0[col]; | 58 | 79.6M | cb = inptr1[col]; | 59 | 79.6M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 79.6M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 79.6M | outptr[RGB_GREEN] = range_limit[y + | 63 | 79.6M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 79.6M | SCALEBITS))]; | 65 | 79.6M | 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 | 79.6M | outptr += RGB_PIXELSIZE; | 72 | 79.6M | } | 73 | 1.89M | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 906k | } |
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 | 39.8k | { | 35 | 39.8k | #if BITS_IN_JSAMPLE != 16 | 36 | 39.8k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 39.8k | register int y, cb, cr; | 38 | 39.8k | register _JSAMPROW outptr; | 39 | 39.8k | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 39.8k | register JDIMENSION col; | 41 | 39.8k | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 39.8k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 39.8k | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 39.8k | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 39.8k | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 39.8k | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 39.8k | SHIFT_TEMPS | 49 | | | 50 | 140k | while (--num_rows >= 0) { | 51 | 100k | inptr0 = input_buf[0][input_row]; | 52 | 100k | inptr1 = input_buf[1][input_row]; | 53 | 100k | inptr2 = input_buf[2][input_row]; | 54 | 100k | input_row++; | 55 | 100k | outptr = *output_buf++; | 56 | 12.1M | for (col = 0; col < num_cols; col++) { | 57 | 12.0M | y = inptr0[col]; | 58 | 12.0M | cb = inptr1[col]; | 59 | 12.0M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 12.0M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 12.0M | outptr[RGB_GREEN] = range_limit[y + | 63 | 12.0M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 12.0M | SCALEBITS))]; | 65 | 12.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 | 12.0M | #ifdef RGB_ALPHA | 69 | 12.0M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 70 | 12.0M | #endif | 71 | 12.0M | outptr += RGB_PIXELSIZE; | 72 | 12.0M | } | 73 | 100k | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 39.8k | } |
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 | 8.92M | { |
92 | 8.92M | register _JSAMPROW inptr, outptr; |
93 | 8.92M | register JDIMENSION col; |
94 | 8.92M | JDIMENSION num_cols = cinfo->output_width; |
95 | | |
96 | 24.8M | while (--num_rows >= 0) { |
97 | 15.8M | inptr = input_buf[0][input_row++]; |
98 | 15.8M | outptr = *output_buf++; |
99 | 788M | for (col = 0; col < num_cols; col++) { |
100 | 772M | 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 | 53.9M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
105 | | #endif |
106 | 772M | outptr += RGB_PIXELSIZE; |
107 | 772M | } |
108 | 15.8M | } |
109 | 8.92M | } jdcolor.c:gray_extrgb_convert_internal Line | Count | Source | 91 | 5.57M | { | 92 | 5.57M | register _JSAMPROW inptr, outptr; | 93 | 5.57M | register JDIMENSION col; | 94 | 5.57M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 17.7M | while (--num_rows >= 0) { | 97 | 12.1M | inptr = input_buf[0][input_row++]; | 98 | 12.1M | outptr = *output_buf++; | 99 | 689M | for (col = 0; col < num_cols; col++) { | 100 | 677M | 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 | 677M | outptr += RGB_PIXELSIZE; | 107 | 677M | } | 108 | 12.1M | } | 109 | 5.57M | } |
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal jdcolor.c:gray_extbgr_convert_internal Line | Count | Source | 91 | 1.71M | { | 92 | 1.71M | register _JSAMPROW inptr, outptr; | 93 | 1.71M | register JDIMENSION col; | 94 | 1.71M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 3.43M | while (--num_rows >= 0) { | 97 | 1.71M | inptr = input_buf[0][input_row++]; | 98 | 1.71M | outptr = *output_buf++; | 99 | 42.9M | for (col = 0; col < num_cols; col++) { | 100 | 41.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 | 41.2M | outptr += RGB_PIXELSIZE; | 107 | 41.2M | } | 108 | 1.71M | } | 109 | 1.71M | } |
jdcolor.c:gray_extbgrx_convert_internal Line | Count | Source | 91 | 338k | { | 92 | 338k | register _JSAMPROW inptr, outptr; | 93 | 338k | register JDIMENSION col; | 94 | 338k | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 1.06M | while (--num_rows >= 0) { | 97 | 723k | inptr = input_buf[0][input_row++]; | 98 | 723k | outptr = *output_buf++; | 99 | 30.4M | for (col = 0; col < num_cols; col++) { | 100 | 29.7M | 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.7M | #ifdef RGB_ALPHA | 104 | 29.7M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 29.7M | #endif | 106 | 29.7M | outptr += RGB_PIXELSIZE; | 107 | 29.7M | } | 108 | 723k | } | 109 | 338k | } |
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal jdcolor.c:gray_extxrgb_convert_internal Line | Count | Source | 91 | 1.28M | { | 92 | 1.28M | register _JSAMPROW inptr, outptr; | 93 | 1.28M | register JDIMENSION col; | 94 | 1.28M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 2.57M | while (--num_rows >= 0) { | 97 | 1.28M | inptr = input_buf[0][input_row++]; | 98 | 1.28M | outptr = *output_buf++; | 99 | 25.5M | for (col = 0; col < num_cols; col++) { | 100 | 24.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 | 24.2M | #ifdef RGB_ALPHA | 104 | 24.2M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 24.2M | #endif | 106 | 24.2M | outptr += RGB_PIXELSIZE; | 107 | 24.2M | } | 108 | 1.28M | } | 109 | 1.28M | } |
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 | 15.9M | for (col = 0; col < num_cols; col++) { |
134 | 15.7M | outptr[RGB_RED] = inptr0[col]; |
135 | 15.7M | outptr[RGB_GREEN] = inptr1[col]; |
136 | 15.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.20M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
141 | | #endif |
142 | 15.7M | outptr += RGB_PIXELSIZE; |
143 | 15.7M | } |
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.2k | { | 122 | 68.2k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 68.2k | register _JSAMPROW outptr; | 124 | 68.2k | register JDIMENSION col; | 125 | 68.2k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 137k | 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 | 7.62M | for (col = 0; col < num_cols; col++) { | 134 | 7.55M | outptr[RGB_RED] = inptr0[col]; | 135 | 7.55M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 7.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 | 7.55M | outptr += RGB_PIXELSIZE; | 143 | 7.55M | } | 144 | 68.8k | } | 145 | 68.2k | } |
jdcolor.c:rgb_extbgrx_convert_internal Line | Count | Source | 121 | 62.4k | { | 122 | 62.4k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 62.4k | register _JSAMPROW outptr; | 124 | 62.4k | register JDIMENSION col; | 125 | 62.4k | 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 | 3.91M | for (col = 0; col < num_cols; col++) { | 134 | 3.79M | outptr[RGB_RED] = inptr0[col]; | 135 | 3.79M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 3.79M | 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.79M | #ifdef RGB_ALPHA | 140 | 3.79M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 3.79M | #endif | 142 | 3.79M | outptr += RGB_PIXELSIZE; | 143 | 3.79M | } | 144 | 117k | } | 145 | 62.4k | } |
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.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 | 4.46M | for (col = 0; col < num_cols; col++) { | 134 | 4.41M | outptr[RGB_RED] = inptr0[col]; | 135 | 4.41M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 4.41M | 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.41M | #ifdef RGB_ALPHA | 140 | 4.41M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 4.41M | #endif | 142 | 4.41M | outptr += RGB_PIXELSIZE; | 143 | 4.41M | } | 144 | 51.6k | } | 145 | 51.1k | } |
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal |