/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 | 956k | { |
35 | 956k | #if BITS_IN_JSAMPLE != 16 |
36 | 956k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; |
37 | 956k | register int y, cb, cr; |
38 | 956k | register _JSAMPROW outptr; |
39 | 956k | register _JSAMPROW inptr0, inptr1, inptr2; |
40 | 956k | register JDIMENSION col; |
41 | 956k | JDIMENSION num_cols = cinfo->output_width; |
42 | | /* copy these pointers into registers if possible */ |
43 | 956k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; |
44 | 956k | register int *Crrtab = cconvert->Cr_r_tab; |
45 | 956k | register int *Cbbtab = cconvert->Cb_b_tab; |
46 | 956k | register JLONG *Crgtab = cconvert->Cr_g_tab; |
47 | 956k | register JLONG *Cbgtab = cconvert->Cb_g_tab; |
48 | 956k | SHIFT_TEMPS |
49 | | |
50 | 3.53M | while (--num_rows >= 0) { |
51 | 2.57M | inptr0 = input_buf[0][input_row]; |
52 | 2.57M | inptr1 = input_buf[1][input_row]; |
53 | 2.57M | inptr2 = input_buf[2][input_row]; |
54 | 2.57M | input_row++; |
55 | 2.57M | outptr = *output_buf++; |
56 | 57.7M | for (col = 0; col < num_cols; col++) { |
57 | 55.1M | y = inptr0[col]; |
58 | 55.1M | cb = inptr1[col]; |
59 | 55.1M | cr = inptr2[col]; |
60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ |
61 | 55.1M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; |
62 | 55.1M | outptr[RGB_GREEN] = range_limit[y + |
63 | 55.1M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
64 | 55.1M | SCALEBITS))]; |
65 | 55.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 | 13.5M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
70 | | #endif |
71 | 55.1M | outptr += RGB_PIXELSIZE; |
72 | 55.1M | } |
73 | 2.57M | } |
74 | | #else |
75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); |
76 | | #endif |
77 | 956k | } jdcolor.c:ycc_extrgb_convert_internal Line | Count | Source | 34 | 581k | { | 35 | 581k | #if BITS_IN_JSAMPLE != 16 | 36 | 581k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 581k | register int y, cb, cr; | 38 | 581k | register _JSAMPROW outptr; | 39 | 581k | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 581k | register JDIMENSION col; | 41 | 581k | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 581k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 581k | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 581k | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 581k | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 581k | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 581k | SHIFT_TEMPS | 49 | | | 50 | 2.20M | while (--num_rows >= 0) { | 51 | 1.62M | inptr0 = input_buf[0][input_row]; | 52 | 1.62M | inptr1 = input_buf[1][input_row]; | 53 | 1.62M | inptr2 = input_buf[2][input_row]; | 54 | 1.62M | input_row++; | 55 | 1.62M | outptr = *output_buf++; | 56 | 43.2M | for (col = 0; col < num_cols; col++) { | 57 | 41.6M | y = inptr0[col]; | 58 | 41.6M | cb = inptr1[col]; | 59 | 41.6M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 41.6M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 41.6M | outptr[RGB_GREEN] = range_limit[y + | 63 | 41.6M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 41.6M | SCALEBITS))]; | 65 | 41.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 | 41.6M | outptr += RGB_PIXELSIZE; | 72 | 41.6M | } | 73 | 1.62M | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 581k | } |
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 | 375k | { | 35 | 375k | #if BITS_IN_JSAMPLE != 16 | 36 | 375k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 375k | register int y, cb, cr; | 38 | 375k | register _JSAMPROW outptr; | 39 | 375k | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 375k | register JDIMENSION col; | 41 | 375k | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 375k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 375k | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 375k | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 375k | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 375k | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 375k | SHIFT_TEMPS | 49 | | | 50 | 1.32M | while (--num_rows >= 0) { | 51 | 951k | inptr0 = input_buf[0][input_row]; | 52 | 951k | inptr1 = input_buf[1][input_row]; | 53 | 951k | inptr2 = input_buf[2][input_row]; | 54 | 951k | input_row++; | 55 | 951k | outptr = *output_buf++; | 56 | 14.4M | for (col = 0; col < num_cols; col++) { | 57 | 13.5M | y = inptr0[col]; | 58 | 13.5M | cb = inptr1[col]; | 59 | 13.5M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 13.5M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 13.5M | outptr[RGB_GREEN] = range_limit[y + | 63 | 13.5M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 13.5M | SCALEBITS))]; | 65 | 13.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 | 13.5M | #ifdef RGB_ALPHA | 69 | 13.5M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 70 | 13.5M | #endif | 71 | 13.5M | outptr += RGB_PIXELSIZE; | 72 | 13.5M | } | 73 | 951k | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 375k | } |
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 | 11.0M | { |
92 | 11.0M | register _JSAMPROW inptr, outptr; |
93 | 11.0M | register JDIMENSION col; |
94 | 11.0M | JDIMENSION num_cols = cinfo->output_width; |
95 | | |
96 | 31.3M | while (--num_rows >= 0) { |
97 | 20.3M | inptr = input_buf[0][input_row++]; |
98 | 20.3M | outptr = *output_buf++; |
99 | 1.01G | for (col = 0; col < num_cols; col++) { |
100 | 995M | 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 | 206M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
105 | | #endif |
106 | 995M | outptr += RGB_PIXELSIZE; |
107 | 995M | } |
108 | 20.3M | } |
109 | 11.0M | } jdcolor.c:gray_extrgb_convert_internal Line | Count | Source | 91 | 5.94M | { | 92 | 5.94M | register _JSAMPROW inptr, outptr; | 93 | 5.94M | register JDIMENSION col; | 94 | 5.94M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 18.1M | while (--num_rows >= 0) { | 97 | 12.2M | inptr = input_buf[0][input_row++]; | 98 | 12.2M | outptr = *output_buf++; | 99 | 781M | for (col = 0; col < num_cols; col++) { | 100 | 769M | 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 | 769M | outptr += RGB_PIXELSIZE; | 107 | 769M | } | 108 | 12.2M | } | 109 | 5.94M | } |
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal jdcolor.c:gray_extbgr_convert_internal Line | Count | Source | 91 | 1.24M | { | 92 | 1.24M | register _JSAMPROW inptr, outptr; | 93 | 1.24M | register JDIMENSION col; | 94 | 1.24M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 2.49M | while (--num_rows >= 0) { | 97 | 1.24M | inptr = input_buf[0][input_row++]; | 98 | 1.24M | outptr = *output_buf++; | 99 | 21.6M | for (col = 0; col < num_cols; col++) { | 100 | 20.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 | 20.4M | outptr += RGB_PIXELSIZE; | 107 | 20.4M | } | 108 | 1.24M | } | 109 | 1.24M | } |
jdcolor.c:gray_extbgrx_convert_internal Line | Count | Source | 91 | 2.91M | { | 92 | 2.91M | register _JSAMPROW inptr, outptr; | 93 | 2.91M | register JDIMENSION col; | 94 | 2.91M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 8.86M | while (--num_rows >= 0) { | 97 | 5.94M | inptr = input_buf[0][input_row++]; | 98 | 5.94M | outptr = *output_buf++; | 99 | 200M | for (col = 0; col < num_cols; col++) { | 100 | 194M | 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 | 194M | #ifdef RGB_ALPHA | 104 | 194M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 194M | #endif | 106 | 194M | outptr += RGB_PIXELSIZE; | 107 | 194M | } | 108 | 5.94M | } | 109 | 2.91M | } |
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal jdcolor.c:gray_extxrgb_convert_internal Line | Count | Source | 91 | 935k | { | 92 | 935k | register _JSAMPROW inptr, outptr; | 93 | 935k | register JDIMENSION col; | 94 | 935k | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 1.87M | while (--num_rows >= 0) { | 97 | 935k | inptr = input_buf[0][input_row++]; | 98 | 935k | outptr = *output_buf++; | 99 | 12.9M | for (col = 0; col < num_cols; col++) { | 100 | 12.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 | 12.0M | #ifdef RGB_ALPHA | 104 | 12.0M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 12.0M | #endif | 106 | 12.0M | outptr += RGB_PIXELSIZE; | 107 | 12.0M | } | 108 | 935k | } | 109 | 935k | } |
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 | 928k | { |
122 | 928k | register _JSAMPROW inptr0, inptr1, inptr2; |
123 | 928k | register _JSAMPROW outptr; |
124 | 928k | register JDIMENSION col; |
125 | 928k | JDIMENSION num_cols = cinfo->output_width; |
126 | | |
127 | 2.57M | while (--num_rows >= 0) { |
128 | 1.65M | inptr0 = input_buf[0][input_row]; |
129 | 1.65M | inptr1 = input_buf[1][input_row]; |
130 | 1.65M | inptr2 = input_buf[2][input_row]; |
131 | 1.65M | input_row++; |
132 | 1.65M | outptr = *output_buf++; |
133 | 46.6M | for (col = 0; col < num_cols; col++) { |
134 | 44.9M | outptr[RGB_RED] = inptr0[col]; |
135 | 44.9M | outptr[RGB_GREEN] = inptr1[col]; |
136 | 44.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 | 38.1M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
141 | | #endif |
142 | 44.9M | outptr += RGB_PIXELSIZE; |
143 | 44.9M | } |
144 | 1.65M | } |
145 | 928k | } 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.1k | { | 122 | 68.1k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 68.1k | register _JSAMPROW outptr; | 124 | 68.1k | register JDIMENSION col; | 125 | 68.1k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 137k | while (--num_rows >= 0) { | 128 | 69.1k | inptr0 = input_buf[0][input_row]; | 129 | 69.1k | inptr1 = input_buf[1][input_row]; | 130 | 69.1k | inptr2 = input_buf[2][input_row]; | 131 | 69.1k | input_row++; | 132 | 69.1k | outptr = *output_buf++; | 133 | 6.85M | for (col = 0; col < num_cols; col++) { | 134 | 6.78M | outptr[RGB_RED] = inptr0[col]; | 135 | 6.78M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 6.78M | 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.78M | outptr += RGB_PIXELSIZE; | 143 | 6.78M | } | 144 | 69.1k | } | 145 | 68.1k | } |
jdcolor.c:rgb_extbgrx_convert_internal Line | Count | Source | 121 | 809k | { | 122 | 809k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 809k | register _JSAMPROW outptr; | 124 | 809k | register JDIMENSION col; | 125 | 809k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 2.33M | while (--num_rows >= 0) { | 128 | 1.53M | inptr0 = input_buf[0][input_row]; | 129 | 1.53M | inptr1 = input_buf[1][input_row]; | 130 | 1.53M | inptr2 = input_buf[2][input_row]; | 131 | 1.53M | input_row++; | 132 | 1.53M | outptr = *output_buf++; | 133 | 35.7M | for (col = 0; col < num_cols; col++) { | 134 | 34.2M | outptr[RGB_RED] = inptr0[col]; | 135 | 34.2M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 34.2M | outptr[RGB_BLUE] = inptr2[col]; | 137 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ | 138 | | /* opaque alpha channel value */ | 139 | 34.2M | #ifdef RGB_ALPHA | 140 | 34.2M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 34.2M | #endif | 142 | 34.2M | outptr += RGB_PIXELSIZE; | 143 | 34.2M | } | 144 | 1.53M | } | 145 | 809k | } |
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal jdcolor.c:rgb_extxrgb_convert_internal Line | Count | Source | 121 | 51.0k | { | 122 | 51.0k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 51.0k | register _JSAMPROW outptr; | 124 | 51.0k | register JDIMENSION col; | 125 | 51.0k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 102k | while (--num_rows >= 0) { | 128 | 51.8k | inptr0 = input_buf[0][input_row]; | 129 | 51.8k | inptr1 = input_buf[1][input_row]; | 130 | 51.8k | inptr2 = input_buf[2][input_row]; | 131 | 51.8k | input_row++; | 132 | 51.8k | outptr = *output_buf++; | 133 | 4.01M | for (col = 0; col < num_cols; col++) { | 134 | 3.96M | outptr[RGB_RED] = inptr0[col]; | 135 | 3.96M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 3.96M | 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.96M | #ifdef RGB_ALPHA | 140 | 3.96M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 3.96M | #endif | 142 | 3.96M | outptr += RGB_PIXELSIZE; | 143 | 3.96M | } | 144 | 51.8k | } | 145 | 51.0k | } |
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal |