/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.06M | { |
35 | 1.06M | #if BITS_IN_JSAMPLE != 16 |
36 | 1.06M | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; |
37 | 1.06M | register int y, cb, cr; |
38 | 1.06M | register _JSAMPROW outptr; |
39 | 1.06M | register _JSAMPROW inptr0, inptr1, inptr2; |
40 | 1.06M | register JDIMENSION col; |
41 | 1.06M | JDIMENSION num_cols = cinfo->output_width; |
42 | | /* copy these pointers into registers if possible */ |
43 | 1.06M | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; |
44 | 1.06M | register int *Crrtab = cconvert->Cr_r_tab; |
45 | 1.06M | register int *Cbbtab = cconvert->Cb_b_tab; |
46 | 1.06M | register JLONG *Crgtab = cconvert->Cr_g_tab; |
47 | 1.06M | register JLONG *Cbgtab = cconvert->Cb_g_tab; |
48 | 1.06M | SHIFT_TEMPS |
49 | | |
50 | 3.18M | while (--num_rows >= 0) { |
51 | 2.12M | inptr0 = input_buf[0][input_row]; |
52 | 2.12M | inptr1 = input_buf[1][input_row]; |
53 | 2.12M | inptr2 = input_buf[2][input_row]; |
54 | 2.12M | input_row++; |
55 | 2.12M | outptr = *output_buf++; |
56 | 117M | for (col = 0; col < num_cols; col++) { |
57 | 115M | y = inptr0[col]; |
58 | 115M | cb = inptr1[col]; |
59 | 115M | cr = inptr2[col]; |
60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ |
61 | 115M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; |
62 | 115M | outptr[RGB_GREEN] = range_limit[y + |
63 | 115M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
64 | 115M | SCALEBITS))]; |
65 | 115M | 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.6M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
70 | | #endif |
71 | 115M | outptr += RGB_PIXELSIZE; |
72 | 115M | } |
73 | 2.12M | } |
74 | | #else |
75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); |
76 | | #endif |
77 | 1.06M | } jdcolor.c:ycc_extrgb_convert_internal Line | Count | Source | 34 | 1.00M | { | 35 | 1.00M | #if BITS_IN_JSAMPLE != 16 | 36 | 1.00M | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 1.00M | register int y, cb, cr; | 38 | 1.00M | register _JSAMPROW outptr; | 39 | 1.00M | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 1.00M | register JDIMENSION col; | 41 | 1.00M | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 1.00M | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 1.00M | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 1.00M | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 1.00M | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 1.00M | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 1.00M | SHIFT_TEMPS | 49 | | | 50 | 3.01M | 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 | 100M | for (col = 0; col < num_cols; col++) { | 57 | 98.5M | y = inptr0[col]; | 58 | 98.5M | cb = inptr1[col]; | 59 | 98.5M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 98.5M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 98.5M | outptr[RGB_GREEN] = range_limit[y + | 63 | 98.5M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 98.5M | SCALEBITS))]; | 65 | 98.5M | 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 | 98.5M | outptr += RGB_PIXELSIZE; | 72 | 98.5M | } | 73 | 2.00M | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 1.00M | } |
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 | 51.9k | { | 35 | 51.9k | #if BITS_IN_JSAMPLE != 16 | 36 | 51.9k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 51.9k | register int y, cb, cr; | 38 | 51.9k | register _JSAMPROW outptr; | 39 | 51.9k | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 51.9k | register JDIMENSION col; | 41 | 51.9k | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 51.9k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 51.9k | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 51.9k | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 51.9k | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 51.9k | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 51.9k | SHIFT_TEMPS | 49 | | | 50 | 167k | while (--num_rows >= 0) { | 51 | 115k | inptr0 = input_buf[0][input_row]; | 52 | 115k | inptr1 = input_buf[1][input_row]; | 53 | 115k | inptr2 = input_buf[2][input_row]; | 54 | 115k | input_row++; | 55 | 115k | outptr = *output_buf++; | 56 | 16.7M | for (col = 0; col < num_cols; col++) { | 57 | 16.6M | y = inptr0[col]; | 58 | 16.6M | cb = inptr1[col]; | 59 | 16.6M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 16.6M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 16.6M | outptr[RGB_GREEN] = range_limit[y + | 63 | 16.6M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 16.6M | SCALEBITS))]; | 65 | 16.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 | 16.6M | #ifdef RGB_ALPHA | 69 | 16.6M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 70 | 16.6M | #endif | 71 | 16.6M | outptr += RGB_PIXELSIZE; | 72 | 16.6M | } | 73 | 115k | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 51.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.31M | { |
92 | 9.31M | register _JSAMPROW inptr, outptr; |
93 | 9.31M | register JDIMENSION col; |
94 | 9.31M | JDIMENSION num_cols = cinfo->output_width; |
95 | | |
96 | 26.4M | while (--num_rows >= 0) { |
97 | 17.1M | inptr = input_buf[0][input_row++]; |
98 | 17.1M | outptr = *output_buf++; |
99 | 805M | for (col = 0; col < num_cols; col++) { |
100 | 788M | 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.3M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
105 | | #endif |
106 | 788M | outptr += RGB_PIXELSIZE; |
107 | 788M | } |
108 | 17.1M | } |
109 | 9.31M | } jdcolor.c:gray_extrgb_convert_internal Line | Count | Source | 91 | 5.90M | { | 92 | 5.90M | register _JSAMPROW inptr, outptr; | 93 | 5.90M | register JDIMENSION col; | 94 | 5.90M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 19.3M | while (--num_rows >= 0) { | 97 | 13.4M | inptr = input_buf[0][input_row++]; | 98 | 13.4M | outptr = *output_buf++; | 99 | 709M | for (col = 0; col < num_cols; col++) { | 100 | 696M | 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 | 696M | outptr += RGB_PIXELSIZE; | 107 | 696M | } | 108 | 13.4M | } | 109 | 5.90M | } |
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal jdcolor.c:gray_extbgr_convert_internal Line | Count | Source | 91 | 1.81M | { | 92 | 1.81M | register _JSAMPROW inptr, outptr; | 93 | 1.81M | register JDIMENSION col; | 94 | 1.81M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 3.63M | while (--num_rows >= 0) { | 97 | 1.81M | inptr = input_buf[0][input_row++]; | 98 | 1.81M | outptr = *output_buf++; | 99 | 41.2M | for (col = 0; col < num_cols; col++) { | 100 | 39.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 | | #ifdef RGB_ALPHA | 104 | | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | | #endif | 106 | 39.4M | outptr += RGB_PIXELSIZE; | 107 | 39.4M | } | 108 | 1.81M | } | 109 | 1.81M | } |
jdcolor.c:gray_extbgrx_convert_internal Line | Count | Source | 91 | 229k | { | 92 | 229k | register _JSAMPROW inptr, outptr; | 93 | 229k | register JDIMENSION col; | 94 | 229k | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 711k | while (--num_rows >= 0) { | 97 | 481k | inptr = input_buf[0][input_row++]; | 98 | 481k | outptr = *output_buf++; | 99 | 29.6M | for (col = 0; col < num_cols; col++) { | 100 | 29.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 | 29.1M | #ifdef RGB_ALPHA | 104 | 29.1M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 29.1M | #endif | 106 | 29.1M | outptr += RGB_PIXELSIZE; | 107 | 29.1M | } | 108 | 481k | } | 109 | 229k | } |
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal jdcolor.c:gray_extxrgb_convert_internal Line | Count | Source | 91 | 1.36M | { | 92 | 1.36M | register _JSAMPROW inptr, outptr; | 93 | 1.36M | register JDIMENSION col; | 94 | 1.36M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 2.72M | while (--num_rows >= 0) { | 97 | 1.36M | inptr = input_buf[0][input_row++]; | 98 | 1.36M | outptr = *output_buf++; | 99 | 24.5M | for (col = 0; col < num_cols; col++) { | 100 | 23.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 | 23.1M | #ifdef RGB_ALPHA | 104 | 23.1M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 23.1M | #endif | 106 | 23.1M | outptr += RGB_PIXELSIZE; | 107 | 23.1M | } | 108 | 1.36M | } | 109 | 1.36M | } |
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 | 273k | { |
122 | 273k | register _JSAMPROW inptr0, inptr1, inptr2; |
123 | 273k | register _JSAMPROW outptr; |
124 | 273k | register JDIMENSION col; |
125 | 273k | JDIMENSION num_cols = cinfo->output_width; |
126 | | |
127 | 646k | while (--num_rows >= 0) { |
128 | 373k | inptr0 = input_buf[0][input_row]; |
129 | 373k | inptr1 = input_buf[1][input_row]; |
130 | 373k | inptr2 = input_buf[2][input_row]; |
131 | 373k | input_row++; |
132 | 373k | outptr = *output_buf++; |
133 | 17.9M | for (col = 0; col < num_cols; col++) { |
134 | 17.6M | outptr[RGB_RED] = inptr0[col]; |
135 | 17.6M | outptr[RGB_GREEN] = inptr1[col]; |
136 | 17.6M | 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.54M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
141 | | #endif |
142 | 17.6M | outptr += RGB_PIXELSIZE; |
143 | 17.6M | } |
144 | 373k | } |
145 | 273k | } 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 | 109k | { | 122 | 109k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 109k | register _JSAMPROW outptr; | 124 | 109k | register JDIMENSION col; | 125 | 109k | 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 | 9.18M | for (col = 0; col < num_cols; col++) { | 134 | 9.06M | outptr[RGB_RED] = inptr0[col]; | 135 | 9.06M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 9.06M | 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.06M | outptr += RGB_PIXELSIZE; | 143 | 9.06M | } | 144 | 114k | } | 145 | 109k | } |
jdcolor.c:rgb_extbgrx_convert_internal Line | Count | Source | 121 | 82.6k | { | 122 | 82.6k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 82.6k | register _JSAMPROW outptr; | 124 | 82.6k | register JDIMENSION col; | 125 | 82.6k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 255k | while (--num_rows >= 0) { | 128 | 172k | inptr0 = input_buf[0][input_row]; | 129 | 172k | inptr1 = input_buf[1][input_row]; | 130 | 172k | inptr2 = input_buf[2][input_row]; | 131 | 172k | input_row++; | 132 | 172k | outptr = *output_buf++; | 133 | 3.50M | for (col = 0; col < num_cols; col++) { | 134 | 3.33M | outptr[RGB_RED] = inptr0[col]; | 135 | 3.33M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 3.33M | 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.33M | #ifdef RGB_ALPHA | 140 | 3.33M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 3.33M | #endif | 142 | 3.33M | outptr += RGB_PIXELSIZE; | 143 | 3.33M | } | 144 | 172k | } | 145 | 82.6k | } |
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal jdcolor.c:rgb_extxrgb_convert_internal Line | Count | Source | 121 | 81.8k | { | 122 | 81.8k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 81.8k | register _JSAMPROW outptr; | 124 | 81.8k | register JDIMENSION col; | 125 | 81.8k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 167k | while (--num_rows >= 0) { | 128 | 85.8k | inptr0 = input_buf[0][input_row]; | 129 | 85.8k | inptr1 = input_buf[1][input_row]; | 130 | 85.8k | inptr2 = input_buf[2][input_row]; | 131 | 85.8k | input_row++; | 132 | 85.8k | outptr = *output_buf++; | 133 | 5.29M | for (col = 0; col < num_cols; col++) { | 134 | 5.20M | outptr[RGB_RED] = inptr0[col]; | 135 | 5.20M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 5.20M | 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.20M | #ifdef RGB_ALPHA | 140 | 5.20M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 5.20M | #endif | 142 | 5.20M | outptr += RGB_PIXELSIZE; | 143 | 5.20M | } | 144 | 85.8k | } | 145 | 81.8k | } |
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal |