/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 | 740k | { |
35 | 740k | #if BITS_IN_JSAMPLE != 16 |
36 | 740k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; |
37 | 740k | register int y, cb, cr; |
38 | 740k | register _JSAMPROW outptr; |
39 | 740k | register _JSAMPROW inptr0, inptr1, inptr2; |
40 | 740k | register JDIMENSION col; |
41 | 740k | JDIMENSION num_cols = cinfo->output_width; |
42 | | /* copy these pointers into registers if possible */ |
43 | 740k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; |
44 | 740k | register int *Crrtab = cconvert->Cr_r_tab; |
45 | 740k | register int *Cbbtab = cconvert->Cb_b_tab; |
46 | 740k | register JLONG *Crgtab = cconvert->Cr_g_tab; |
47 | 740k | register JLONG *Cbgtab = cconvert->Cb_g_tab; |
48 | 740k | SHIFT_TEMPS |
49 | | |
50 | 2.60M | while (--num_rows >= 0) { |
51 | 1.86M | inptr0 = input_buf[0][input_row]; |
52 | 1.86M | inptr1 = input_buf[1][input_row]; |
53 | 1.86M | inptr2 = input_buf[2][input_row]; |
54 | 1.86M | input_row++; |
55 | 1.86M | outptr = *output_buf++; |
56 | 49.2M | for (col = 0; col < num_cols; col++) { |
57 | 47.3M | y = inptr0[col]; |
58 | 47.3M | cb = inptr1[col]; |
59 | 47.3M | cr = inptr2[col]; |
60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ |
61 | 47.3M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; |
62 | 47.3M | outptr[RGB_GREEN] = range_limit[y + |
63 | 47.3M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
64 | 47.3M | SCALEBITS))]; |
65 | 47.3M | 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 | 11.5M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
70 | | #endif |
71 | 47.3M | outptr += RGB_PIXELSIZE; |
72 | 47.3M | } |
73 | 1.86M | } |
74 | | #else |
75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); |
76 | | #endif |
77 | 740k | } jdcolor.c:ycc_extrgb_convert_internal Line | Count | Source | 34 | 421k | { | 35 | 421k | #if BITS_IN_JSAMPLE != 16 | 36 | 421k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 421k | register int y, cb, cr; | 38 | 421k | register _JSAMPROW outptr; | 39 | 421k | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 421k | register JDIMENSION col; | 41 | 421k | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 421k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 421k | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 421k | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 421k | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 421k | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 421k | SHIFT_TEMPS | 49 | | | 50 | 1.56M | while (--num_rows >= 0) { | 51 | 1.14M | inptr0 = input_buf[0][input_row]; | 52 | 1.14M | inptr1 = input_buf[1][input_row]; | 53 | 1.14M | inptr2 = input_buf[2][input_row]; | 54 | 1.14M | input_row++; | 55 | 1.14M | outptr = *output_buf++; | 56 | 36.9M | for (col = 0; col < num_cols; col++) { | 57 | 35.8M | y = inptr0[col]; | 58 | 35.8M | cb = inptr1[col]; | 59 | 35.8M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 35.8M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 35.8M | outptr[RGB_GREEN] = range_limit[y + | 63 | 35.8M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 35.8M | SCALEBITS))]; | 65 | 35.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 | 35.8M | outptr += RGB_PIXELSIZE; | 72 | 35.8M | } | 73 | 1.14M | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 421k | } |
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 | 319k | { | 35 | 319k | #if BITS_IN_JSAMPLE != 16 | 36 | 319k | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 319k | register int y, cb, cr; | 38 | 319k | register _JSAMPROW outptr; | 39 | 319k | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 319k | register JDIMENSION col; | 41 | 319k | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 319k | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 319k | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 319k | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 319k | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 319k | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 319k | SHIFT_TEMPS | 49 | | | 50 | 1.04M | while (--num_rows >= 0) { | 51 | 724k | inptr0 = input_buf[0][input_row]; | 52 | 724k | inptr1 = input_buf[1][input_row]; | 53 | 724k | inptr2 = input_buf[2][input_row]; | 54 | 724k | input_row++; | 55 | 724k | outptr = *output_buf++; | 56 | 12.2M | for (col = 0; col < num_cols; col++) { | 57 | 11.5M | y = inptr0[col]; | 58 | 11.5M | cb = inptr1[col]; | 59 | 11.5M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 11.5M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 11.5M | outptr[RGB_GREEN] = range_limit[y + | 63 | 11.5M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 11.5M | SCALEBITS))]; | 65 | 11.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 | 11.5M | #ifdef RGB_ALPHA | 69 | 11.5M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 70 | 11.5M | #endif | 71 | 11.5M | outptr += RGB_PIXELSIZE; | 72 | 11.5M | } | 73 | 724k | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 319k | } |
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.8M | { |
92 | 10.8M | register _JSAMPROW inptr, outptr; |
93 | 10.8M | register JDIMENSION col; |
94 | 10.8M | JDIMENSION num_cols = cinfo->output_width; |
95 | | |
96 | 29.6M | while (--num_rows >= 0) { |
97 | 18.7M | inptr = input_buf[0][input_row++]; |
98 | 18.7M | outptr = *output_buf++; |
99 | 970M | for (col = 0; col < num_cols; col++) { |
100 | 951M | 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 | 196M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
105 | | #endif |
106 | 951M | outptr += RGB_PIXELSIZE; |
107 | 951M | } |
108 | 18.7M | } |
109 | 10.8M | } jdcolor.c:gray_extrgb_convert_internal Line | Count | Source | 91 | 6.49M | { | 92 | 6.49M | register _JSAMPROW inptr, outptr; | 93 | 6.49M | register JDIMENSION col; | 94 | 6.49M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 18.3M | while (--num_rows >= 0) { | 97 | 11.8M | inptr = input_buf[0][input_row++]; | 98 | 11.8M | outptr = *output_buf++; | 99 | 750M | for (col = 0; col < num_cols; col++) { | 100 | 738M | 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 | 738M | outptr += RGB_PIXELSIZE; | 107 | 738M | } | 108 | 11.8M | } | 109 | 6.49M | } |
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal jdcolor.c:gray_extbgr_convert_internal Line | Count | Source | 91 | 633k | { | 92 | 633k | register _JSAMPROW inptr, outptr; | 93 | 633k | register JDIMENSION col; | 94 | 633k | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 1.26M | while (--num_rows >= 0) { | 97 | 633k | inptr = input_buf[0][input_row++]; | 98 | 633k | outptr = *output_buf++; | 99 | 16.5M | for (col = 0; col < num_cols; col++) { | 100 | 15.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 | | #ifdef RGB_ALPHA | 104 | | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | | #endif | 106 | 15.8M | outptr += RGB_PIXELSIZE; | 107 | 15.8M | } | 108 | 633k | } | 109 | 633k | } |
jdcolor.c:gray_extbgrx_convert_internal Line | Count | Source | 91 | 3.22M | { | 92 | 3.22M | register _JSAMPROW inptr, outptr; | 93 | 3.22M | register JDIMENSION col; | 94 | 3.22M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 9.07M | while (--num_rows >= 0) { | 97 | 5.84M | inptr = input_buf[0][input_row++]; | 98 | 5.84M | outptr = *output_buf++; | 99 | 193M | for (col = 0; col < num_cols; col++) { | 100 | 187M | 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 | 187M | #ifdef RGB_ALPHA | 104 | 187M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 187M | #endif | 106 | 187M | outptr += RGB_PIXELSIZE; | 107 | 187M | } | 108 | 5.84M | } | 109 | 3.22M | } |
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal jdcolor.c:gray_extxrgb_convert_internal Line | Count | Source | 91 | 475k | { | 92 | 475k | register _JSAMPROW inptr, outptr; | 93 | 475k | register JDIMENSION col; | 94 | 475k | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 950k | while (--num_rows >= 0) { | 97 | 475k | inptr = input_buf[0][input_row++]; | 98 | 475k | outptr = *output_buf++; | 99 | 9.84M | for (col = 0; col < num_cols; col++) { | 100 | 9.36M | 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 | 9.36M | #ifdef RGB_ALPHA | 104 | 9.36M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 9.36M | #endif | 106 | 9.36M | outptr += RGB_PIXELSIZE; | 107 | 9.36M | } | 108 | 475k | } | 109 | 475k | } |
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 | 792k | { |
122 | 792k | register _JSAMPROW inptr0, inptr1, inptr2; |
123 | 792k | register _JSAMPROW outptr; |
124 | 792k | register JDIMENSION col; |
125 | 792k | JDIMENSION num_cols = cinfo->output_width; |
126 | | |
127 | 2.13M | while (--num_rows >= 0) { |
128 | 1.34M | inptr0 = input_buf[0][input_row]; |
129 | 1.34M | inptr1 = input_buf[1][input_row]; |
130 | 1.34M | inptr2 = input_buf[2][input_row]; |
131 | 1.34M | input_row++; |
132 | 1.34M | outptr = *output_buf++; |
133 | 40.1M | for (col = 0; col < num_cols; col++) { |
134 | 38.7M | outptr[RGB_RED] = inptr0[col]; |
135 | 38.7M | outptr[RGB_GREEN] = inptr1[col]; |
136 | 38.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 | 32.9M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
141 | | #endif |
142 | 38.7M | outptr += RGB_PIXELSIZE; |
143 | 38.7M | } |
144 | 1.34M | } |
145 | 792k | } 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.9k | { | 122 | 67.9k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 67.9k | register _JSAMPROW outptr; | 124 | 67.9k | register JDIMENSION col; | 125 | 67.9k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 136k | while (--num_rows >= 0) { | 128 | 68.7k | inptr0 = input_buf[0][input_row]; | 129 | 68.7k | inptr1 = input_buf[1][input_row]; | 130 | 68.7k | inptr2 = input_buf[2][input_row]; | 131 | 68.7k | input_row++; | 132 | 68.7k | outptr = *output_buf++; | 133 | 5.86M | for (col = 0; col < num_cols; col++) { | 134 | 5.79M | outptr[RGB_RED] = inptr0[col]; | 135 | 5.79M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 5.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 | | #ifdef RGB_ALPHA | 140 | | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | | #endif | 142 | 5.79M | outptr += RGB_PIXELSIZE; | 143 | 5.79M | } | 144 | 68.7k | } | 145 | 67.9k | } |
jdcolor.c:rgb_extbgrx_convert_internal Line | Count | Source | 121 | 674k | { | 122 | 674k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 674k | register _JSAMPROW outptr; | 124 | 674k | register JDIMENSION col; | 125 | 674k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 1.89M | while (--num_rows >= 0) { | 128 | 1.22M | inptr0 = input_buf[0][input_row]; | 129 | 1.22M | inptr1 = input_buf[1][input_row]; | 130 | 1.22M | inptr2 = input_buf[2][input_row]; | 131 | 1.22M | input_row++; | 132 | 1.22M | outptr = *output_buf++; | 133 | 30.8M | for (col = 0; col < num_cols; col++) { | 134 | 29.5M | outptr[RGB_RED] = inptr0[col]; | 135 | 29.5M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 29.5M | outptr[RGB_BLUE] = inptr2[col]; | 137 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ | 138 | | /* opaque alpha channel value */ | 139 | 29.5M | #ifdef RGB_ALPHA | 140 | 29.5M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 29.5M | #endif | 142 | 29.5M | outptr += RGB_PIXELSIZE; | 143 | 29.5M | } | 144 | 1.22M | } | 145 | 674k | } |
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal jdcolor.c:rgb_extxrgb_convert_internal Line | Count | Source | 121 | 50.9k | { | 122 | 50.9k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 50.9k | register _JSAMPROW outptr; | 124 | 50.9k | register JDIMENSION col; | 125 | 50.9k | 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 | 3.43M | for (col = 0; col < num_cols; col++) { | 134 | 3.38M | outptr[RGB_RED] = inptr0[col]; | 135 | 3.38M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 3.38M | 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.38M | #ifdef RGB_ALPHA | 140 | 3.38M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 3.38M | #endif | 142 | 3.38M | outptr += RGB_PIXELSIZE; | 143 | 3.38M | } | 144 | 51.6k | } | 145 | 50.9k | } |
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal |