/src/libjpeg-turbo.main/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 | 9.80M | { |
35 | 9.80M | #if BITS_IN_JSAMPLE != 16 |
36 | 9.80M | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; |
37 | 9.80M | register int y, cb, cr; |
38 | 9.80M | register _JSAMPROW outptr; |
39 | 9.80M | register _JSAMPROW inptr0, inptr1, inptr2; |
40 | 9.80M | register JDIMENSION col; |
41 | 9.80M | JDIMENSION num_cols = cinfo->output_width; |
42 | | /* copy these pointers into registers if possible */ |
43 | 9.80M | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; |
44 | 9.80M | register int *Crrtab = cconvert->Cr_r_tab; |
45 | 9.80M | register int *Cbbtab = cconvert->Cb_b_tab; |
46 | 9.80M | register JLONG *Crgtab = cconvert->Cr_g_tab; |
47 | 9.80M | register JLONG *Cbgtab = cconvert->Cb_g_tab; |
48 | 9.80M | SHIFT_TEMPS |
49 | | |
50 | 36.6M | while (--num_rows >= 0) { |
51 | 26.8M | inptr0 = input_buf[0][input_row]; |
52 | 26.8M | inptr1 = input_buf[1][input_row]; |
53 | 26.8M | inptr2 = input_buf[2][input_row]; |
54 | 26.8M | input_row++; |
55 | 26.8M | outptr = *output_buf++; |
56 | 796M | for (col = 0; col < num_cols; col++) { |
57 | 769M | y = inptr0[col]; |
58 | 769M | cb = inptr1[col]; |
59 | 769M | cr = inptr2[col]; |
60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ |
61 | 769M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; |
62 | 769M | outptr[RGB_GREEN] = range_limit[y + |
63 | 769M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
64 | 769M | SCALEBITS))]; |
65 | 769M | 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 | 65.1M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
70 | | #endif |
71 | 769M | outptr += RGB_PIXELSIZE; |
72 | 769M | } |
73 | 26.8M | } |
74 | | #else |
75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); |
76 | | #endif |
77 | 9.80M | } jdcolor.c:ycc_extrgb_convert_internal Line | Count | Source | 34 | 8.43M | { | 35 | 8.43M | #if BITS_IN_JSAMPLE != 16 | 36 | 8.43M | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 8.43M | register int y, cb, cr; | 38 | 8.43M | register _JSAMPROW outptr; | 39 | 8.43M | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 8.43M | register JDIMENSION col; | 41 | 8.43M | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 8.43M | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 8.43M | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 8.43M | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 8.43M | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 8.43M | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 8.43M | SHIFT_TEMPS | 49 | | | 50 | 31.0M | while (--num_rows >= 0) { | 51 | 22.5M | inptr0 = input_buf[0][input_row]; | 52 | 22.5M | inptr1 = input_buf[1][input_row]; | 53 | 22.5M | inptr2 = input_buf[2][input_row]; | 54 | 22.5M | input_row++; | 55 | 22.5M | outptr = *output_buf++; | 56 | 727M | for (col = 0; col < num_cols; col++) { | 57 | 704M | y = inptr0[col]; | 58 | 704M | cb = inptr1[col]; | 59 | 704M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 704M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 704M | outptr[RGB_GREEN] = range_limit[y + | 63 | 704M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 704M | SCALEBITS))]; | 65 | 704M | 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 | 704M | outptr += RGB_PIXELSIZE; | 72 | 704M | } | 73 | 22.5M | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 8.43M | } |
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 | 1.37M | { | 35 | 1.37M | #if BITS_IN_JSAMPLE != 16 | 36 | 1.37M | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; | 37 | 1.37M | register int y, cb, cr; | 38 | 1.37M | register _JSAMPROW outptr; | 39 | 1.37M | register _JSAMPROW inptr0, inptr1, inptr2; | 40 | 1.37M | register JDIMENSION col; | 41 | 1.37M | JDIMENSION num_cols = cinfo->output_width; | 42 | | /* copy these pointers into registers if possible */ | 43 | 1.37M | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; | 44 | 1.37M | register int *Crrtab = cconvert->Cr_r_tab; | 45 | 1.37M | register int *Cbbtab = cconvert->Cb_b_tab; | 46 | 1.37M | register JLONG *Crgtab = cconvert->Cr_g_tab; | 47 | 1.37M | register JLONG *Cbgtab = cconvert->Cb_g_tab; | 48 | 1.37M | SHIFT_TEMPS | 49 | | | 50 | 5.61M | while (--num_rows >= 0) { | 51 | 4.24M | inptr0 = input_buf[0][input_row]; | 52 | 4.24M | inptr1 = input_buf[1][input_row]; | 53 | 4.24M | inptr2 = input_buf[2][input_row]; | 54 | 4.24M | input_row++; | 55 | 4.24M | outptr = *output_buf++; | 56 | 69.3M | for (col = 0; col < num_cols; col++) { | 57 | 65.1M | y = inptr0[col]; | 58 | 65.1M | cb = inptr1[col]; | 59 | 65.1M | cr = inptr2[col]; | 60 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ | 61 | 65.1M | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; | 62 | 65.1M | outptr[RGB_GREEN] = range_limit[y + | 63 | 65.1M | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], | 64 | 65.1M | SCALEBITS))]; | 65 | 65.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 | 65.1M | #ifdef RGB_ALPHA | 69 | 65.1M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 70 | 65.1M | #endif | 71 | 65.1M | outptr += RGB_PIXELSIZE; | 72 | 65.1M | } | 73 | 4.24M | } | 74 | | #else | 75 | | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); | 76 | | #endif | 77 | 1.37M | } |
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.1M | { |
92 | 11.1M | register _JSAMPROW inptr, outptr; |
93 | 11.1M | register JDIMENSION col; |
94 | 11.1M | JDIMENSION num_cols = cinfo->output_width; |
95 | | |
96 | 27.9M | while (--num_rows >= 0) { |
97 | 16.8M | inptr = input_buf[0][input_row++]; |
98 | 16.8M | outptr = *output_buf++; |
99 | 264M | for (col = 0; col < num_cols; col++) { |
100 | 247M | 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 | 20.6M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
105 | | #endif |
106 | 247M | outptr += RGB_PIXELSIZE; |
107 | 247M | } |
108 | 16.8M | } |
109 | 11.1M | } jdcolor.c:gray_extrgb_convert_internal Line | Count | Source | 91 | 10.0M | { | 92 | 10.0M | register _JSAMPROW inptr, outptr; | 93 | 10.0M | register JDIMENSION col; | 94 | 10.0M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 24.6M | while (--num_rows >= 0) { | 97 | 14.5M | inptr = input_buf[0][input_row++]; | 98 | 14.5M | outptr = *output_buf++; | 99 | 241M | for (col = 0; col < num_cols; col++) { | 100 | 226M | 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 | 226M | outptr += RGB_PIXELSIZE; | 107 | 226M | } | 108 | 14.5M | } | 109 | 10.0M | } |
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal Unexecuted instantiation: jdcolor.c:gray_extbgr_convert_internal jdcolor.c:gray_extbgrx_convert_internal Line | Count | Source | 91 | 1.07M | { | 92 | 1.07M | register _JSAMPROW inptr, outptr; | 93 | 1.07M | register JDIMENSION col; | 94 | 1.07M | JDIMENSION num_cols = cinfo->output_width; | 95 | | | 96 | 3.34M | while (--num_rows >= 0) { | 97 | 2.27M | inptr = input_buf[0][input_row++]; | 98 | 2.27M | outptr = *output_buf++; | 99 | 22.9M | for (col = 0; col < num_cols; col++) { | 100 | 20.6M | 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 | 20.6M | #ifdef RGB_ALPHA | 104 | 20.6M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 105 | 20.6M | #endif | 106 | 20.6M | outptr += RGB_PIXELSIZE; | 107 | 20.6M | } | 108 | 2.27M | } | 109 | 1.07M | } |
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal Unexecuted instantiation: jdcolor.c:gray_extxrgb_convert_internal 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 | 521k | { |
122 | 521k | register _JSAMPROW inptr0, inptr1, inptr2; |
123 | 521k | register _JSAMPROW outptr; |
124 | 521k | register JDIMENSION col; |
125 | 521k | JDIMENSION num_cols = cinfo->output_width; |
126 | | |
127 | 1.70M | while (--num_rows >= 0) { |
128 | 1.18M | inptr0 = input_buf[0][input_row]; |
129 | 1.18M | inptr1 = input_buf[1][input_row]; |
130 | 1.18M | inptr2 = input_buf[2][input_row]; |
131 | 1.18M | input_row++; |
132 | 1.18M | outptr = *output_buf++; |
133 | 25.5M | for (col = 0; col < num_cols; col++) { |
134 | 24.3M | outptr[RGB_RED] = inptr0[col]; |
135 | 24.3M | outptr[RGB_GREEN] = inptr1[col]; |
136 | 24.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 | 24.3M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
141 | | #endif |
142 | 24.3M | outptr += RGB_PIXELSIZE; |
143 | 24.3M | } |
144 | 1.18M | } |
145 | 521k | } Unexecuted instantiation: jdcolor.c:rgb_extrgb_convert_internal Unexecuted instantiation: jdcolor.c:rgb_extrgbx_convert_internal Unexecuted instantiation: jdcolor.c:rgb_extbgr_convert_internal jdcolor.c:rgb_extbgrx_convert_internal Line | Count | Source | 121 | 521k | { | 122 | 521k | register _JSAMPROW inptr0, inptr1, inptr2; | 123 | 521k | register _JSAMPROW outptr; | 124 | 521k | register JDIMENSION col; | 125 | 521k | JDIMENSION num_cols = cinfo->output_width; | 126 | | | 127 | 1.70M | while (--num_rows >= 0) { | 128 | 1.18M | inptr0 = input_buf[0][input_row]; | 129 | 1.18M | inptr1 = input_buf[1][input_row]; | 130 | 1.18M | inptr2 = input_buf[2][input_row]; | 131 | 1.18M | input_row++; | 132 | 1.18M | outptr = *output_buf++; | 133 | 25.5M | for (col = 0; col < num_cols; col++) { | 134 | 24.3M | outptr[RGB_RED] = inptr0[col]; | 135 | 24.3M | outptr[RGB_GREEN] = inptr1[col]; | 136 | 24.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 | 24.3M | #ifdef RGB_ALPHA | 140 | 24.3M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 141 | 24.3M | #endif | 142 | 24.3M | outptr += RGB_PIXELSIZE; | 143 | 24.3M | } | 144 | 1.18M | } | 145 | 521k | } |
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal Unexecuted instantiation: jdcolor.c:rgb_extxrgb_convert_internal Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal |