/src/libjpeg-turbo.dev/src/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, 2025, 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(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf, |
32 | | JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows) |
33 | 0 | { |
34 | | #if BITS_IN_JSAMPLE != 16 |
35 | | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; |
36 | | register int y, cb, cr; |
37 | | register _JSAMPROW outptr; |
38 | | register _JSAMPROW inptr0, inptr1, inptr2; |
39 | | register JDIMENSION col; |
40 | | JDIMENSION num_cols = cinfo->output_width; |
41 | | /* copy these pointers into registers if possible */ |
42 | | register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit; |
43 | | register int *Crrtab = cconvert->Cr_r_tab; |
44 | | register int *Cbbtab = cconvert->Cb_b_tab; |
45 | | register JLONG *Crgtab = cconvert->Cr_g_tab; |
46 | | register JLONG *Cbgtab = cconvert->Cb_g_tab; |
47 | | SHIFT_TEMPS |
48 | | |
49 | 0 | while (--num_rows >= 0) { |
50 | 0 | inptr0 = input_buf[0][input_row]; |
51 | 0 | inptr1 = input_buf[1][input_row]; |
52 | 0 | inptr2 = input_buf[2][input_row]; |
53 | 0 | input_row++; |
54 | 0 | outptr = *output_buf++; |
55 | 0 | for (col = 0; col < num_cols; col++) { |
56 | 0 | y = inptr0[col]; |
57 | 0 | cb = inptr1[col]; |
58 | 0 | cr = inptr2[col]; |
59 | | /* Range-limiting is essential due to noise introduced by DCT losses. */ |
60 | 0 | outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; |
61 | 0 | outptr[RGB_GREEN] = range_limit[y + |
62 | 0 | ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], |
63 | 0 | SCALEBITS))]; |
64 | 0 | outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]]; |
65 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ |
66 | | /* opaque alpha channel value */ |
67 | | #ifdef RGB_ALPHA |
68 | 0 | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
69 | | #endif |
70 | 0 | outptr += RGB_PIXELSIZE; |
71 | 0 | } |
72 | 0 | } |
73 | | #else |
74 | 0 | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); |
75 | | #endif |
76 | 0 | } Unexecuted instantiation: jdcolor-8.c:ycc_extrgb_convert Unexecuted instantiation: jdcolor-8.c:ycc_extrgbx_convert Unexecuted instantiation: jdcolor-8.c:ycc_extbgr_convert Unexecuted instantiation: jdcolor-8.c:ycc_extbgrx_convert Unexecuted instantiation: jdcolor-8.c:ycc_extxbgr_convert Unexecuted instantiation: jdcolor-8.c:ycc_extxrgb_convert Unexecuted instantiation: jdcolor-8.c:ycc_rgb_convert Unexecuted instantiation: jdcolor-12.c:ycc_extrgb_convert Unexecuted instantiation: jdcolor-12.c:ycc_extrgbx_convert Unexecuted instantiation: jdcolor-12.c:ycc_extbgr_convert Unexecuted instantiation: jdcolor-12.c:ycc_extbgrx_convert Unexecuted instantiation: jdcolor-12.c:ycc_extxbgr_convert Unexecuted instantiation: jdcolor-12.c:ycc_extxrgb_convert Unexecuted instantiation: jdcolor-12.c:ycc_rgb_convert Unexecuted instantiation: jdcolor-16.c:ycc_extrgb_convert Unexecuted instantiation: jdcolor-16.c:ycc_extrgbx_convert Unexecuted instantiation: jdcolor-16.c:ycc_extbgr_convert Unexecuted instantiation: jdcolor-16.c:ycc_extbgrx_convert Unexecuted instantiation: jdcolor-16.c:ycc_extxbgr_convert Unexecuted instantiation: jdcolor-16.c:ycc_extxrgb_convert Unexecuted instantiation: jdcolor-16.c:ycc_rgb_convert |
77 | | |
78 | | |
79 | | /* |
80 | | * Convert grayscale to RGB: just duplicate the graylevel three times. |
81 | | * This is provided to support applications that don't want to cope |
82 | | * with grayscale as a separate case. |
83 | | */ |
84 | | |
85 | | INLINE |
86 | | LOCAL(void) |
87 | | gray_rgb_convert(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf, |
88 | | JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows) |
89 | 961k | { |
90 | 961k | register _JSAMPROW inptr, outptr; |
91 | 961k | register JDIMENSION col; |
92 | 961k | JDIMENSION num_cols = cinfo->output_width; |
93 | | |
94 | 1.92M | while (--num_rows >= 0) { |
95 | 961k | inptr = input_buf[0][input_row++]; |
96 | 961k | outptr = *output_buf++; |
97 | 59.3M | for (col = 0; col < num_cols; col++) { |
98 | 58.3M | outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; |
99 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ |
100 | | /* opaque alpha channel value */ |
101 | | #ifdef RGB_ALPHA |
102 | 21.5M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
103 | | #endif |
104 | 58.3M | outptr += RGB_PIXELSIZE; |
105 | 58.3M | } |
106 | 961k | } |
107 | 961k | } Unexecuted instantiation: jdcolor-8.c:gray_extrgb_convert Unexecuted instantiation: jdcolor-8.c:gray_extrgbx_convert jdcolor-8.c:gray_extbgr_convert Line | Count | Source | 89 | 549k | { | 90 | 549k | register _JSAMPROW inptr, outptr; | 91 | 549k | register JDIMENSION col; | 92 | 549k | JDIMENSION num_cols = cinfo->output_width; | 93 | | | 94 | 1.09M | while (--num_rows >= 0) { | 95 | 549k | inptr = input_buf[0][input_row++]; | 96 | 549k | outptr = *output_buf++; | 97 | 37.3M | for (col = 0; col < num_cols; col++) { | 98 | 36.8M | outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; | 99 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ | 100 | | /* opaque alpha channel value */ | 101 | | #ifdef RGB_ALPHA | 102 | | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 103 | | #endif | 104 | 36.8M | outptr += RGB_PIXELSIZE; | 105 | 36.8M | } | 106 | 549k | } | 107 | 549k | } |
Unexecuted instantiation: jdcolor-8.c:gray_extbgrx_convert Unexecuted instantiation: jdcolor-8.c:gray_extxbgr_convert jdcolor-8.c:gray_extxrgb_convert Line | Count | Source | 89 | 412k | { | 90 | 412k | register _JSAMPROW inptr, outptr; | 91 | 412k | register JDIMENSION col; | 92 | 412k | JDIMENSION num_cols = cinfo->output_width; | 93 | | | 94 | 824k | while (--num_rows >= 0) { | 95 | 412k | inptr = input_buf[0][input_row++]; | 96 | 412k | outptr = *output_buf++; | 97 | 21.9M | for (col = 0; col < num_cols; col++) { | 98 | 21.5M | outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; | 99 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ | 100 | | /* opaque alpha channel value */ | 101 | 21.5M | #ifdef RGB_ALPHA | 102 | 21.5M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 103 | 21.5M | #endif | 104 | 21.5M | outptr += RGB_PIXELSIZE; | 105 | 21.5M | } | 106 | 412k | } | 107 | 412k | } |
Unexecuted instantiation: jdcolor-8.c:gray_rgb_convert Unexecuted instantiation: jdcolor-12.c:gray_extrgb_convert Unexecuted instantiation: jdcolor-12.c:gray_extrgbx_convert Unexecuted instantiation: jdcolor-12.c:gray_extbgr_convert Unexecuted instantiation: jdcolor-12.c:gray_extbgrx_convert Unexecuted instantiation: jdcolor-12.c:gray_extxbgr_convert Unexecuted instantiation: jdcolor-12.c:gray_extxrgb_convert Unexecuted instantiation: jdcolor-12.c:gray_rgb_convert Unexecuted instantiation: jdcolor-16.c:gray_extrgb_convert Unexecuted instantiation: jdcolor-16.c:gray_extrgbx_convert Unexecuted instantiation: jdcolor-16.c:gray_extbgr_convert Unexecuted instantiation: jdcolor-16.c:gray_extbgrx_convert Unexecuted instantiation: jdcolor-16.c:gray_extxbgr_convert Unexecuted instantiation: jdcolor-16.c:gray_extxrgb_convert Unexecuted instantiation: jdcolor-16.c:gray_rgb_convert |
108 | | |
109 | | |
110 | | /* |
111 | | * Convert RGB to extended RGB: just swap the order of source pixels |
112 | | */ |
113 | | |
114 | | INLINE |
115 | | LOCAL(void) |
116 | | rgb_rgb_convert(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf, |
117 | | JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows) |
118 | 99.3k | { |
119 | 99.3k | register _JSAMPROW inptr0, inptr1, inptr2; |
120 | 99.3k | register _JSAMPROW outptr; |
121 | 99.3k | register JDIMENSION col; |
122 | 99.3k | JDIMENSION num_cols = cinfo->output_width; |
123 | | |
124 | 298k | while (--num_rows >= 0) { |
125 | 198k | inptr0 = input_buf[0][input_row]; |
126 | 198k | inptr1 = input_buf[1][input_row]; |
127 | 198k | inptr2 = input_buf[2][input_row]; |
128 | 198k | input_row++; |
129 | 198k | outptr = *output_buf++; |
130 | 10.5M | for (col = 0; col < num_cols; col++) { |
131 | 10.3M | outptr[RGB_RED] = inptr0[col]; |
132 | 10.3M | outptr[RGB_GREEN] = inptr1[col]; |
133 | 10.3M | outptr[RGB_BLUE] = inptr2[col]; |
134 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ |
135 | | /* opaque alpha channel value */ |
136 | | #ifdef RGB_ALPHA |
137 | 3.77M | outptr[RGB_ALPHA] = _MAXJSAMPLE; |
138 | | #endif |
139 | 10.3M | outptr += RGB_PIXELSIZE; |
140 | 10.3M | } |
141 | 198k | } |
142 | 99.3k | } Unexecuted instantiation: jdcolor-8.c:rgb_extrgb_convert Unexecuted instantiation: jdcolor-8.c:rgb_extrgbx_convert jdcolor-8.c:rgb_extbgr_convert Line | Count | Source | 118 | 56.7k | { | 119 | 56.7k | register _JSAMPROW inptr0, inptr1, inptr2; | 120 | 56.7k | register _JSAMPROW outptr; | 121 | 56.7k | register JDIMENSION col; | 122 | 56.7k | JDIMENSION num_cols = cinfo->output_width; | 123 | | | 124 | 170k | while (--num_rows >= 0) { | 125 | 113k | inptr0 = input_buf[0][input_row]; | 126 | 113k | inptr1 = input_buf[1][input_row]; | 127 | 113k | inptr2 = input_buf[2][input_row]; | 128 | 113k | input_row++; | 129 | 113k | outptr = *output_buf++; | 130 | 6.69M | for (col = 0; col < num_cols; col++) { | 131 | 6.58M | outptr[RGB_RED] = inptr0[col]; | 132 | 6.58M | outptr[RGB_GREEN] = inptr1[col]; | 133 | 6.58M | outptr[RGB_BLUE] = inptr2[col]; | 134 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ | 135 | | /* opaque alpha channel value */ | 136 | | #ifdef RGB_ALPHA | 137 | | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 138 | | #endif | 139 | 6.58M | outptr += RGB_PIXELSIZE; | 140 | 6.58M | } | 141 | 113k | } | 142 | 56.7k | } |
Unexecuted instantiation: jdcolor-8.c:rgb_extbgrx_convert Unexecuted instantiation: jdcolor-8.c:rgb_extxbgr_convert jdcolor-8.c:rgb_extxrgb_convert Line | Count | Source | 118 | 42.5k | { | 119 | 42.5k | register _JSAMPROW inptr0, inptr1, inptr2; | 120 | 42.5k | register _JSAMPROW outptr; | 121 | 42.5k | register JDIMENSION col; | 122 | 42.5k | JDIMENSION num_cols = cinfo->output_width; | 123 | | | 124 | 127k | while (--num_rows >= 0) { | 125 | 85.2k | inptr0 = input_buf[0][input_row]; | 126 | 85.2k | inptr1 = input_buf[1][input_row]; | 127 | 85.2k | inptr2 = input_buf[2][input_row]; | 128 | 85.2k | input_row++; | 129 | 85.2k | outptr = *output_buf++; | 130 | 3.85M | for (col = 0; col < num_cols; col++) { | 131 | 3.77M | outptr[RGB_RED] = inptr0[col]; | 132 | 3.77M | outptr[RGB_GREEN] = inptr1[col]; | 133 | 3.77M | outptr[RGB_BLUE] = inptr2[col]; | 134 | | /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */ | 135 | | /* opaque alpha channel value */ | 136 | 3.77M | #ifdef RGB_ALPHA | 137 | 3.77M | outptr[RGB_ALPHA] = _MAXJSAMPLE; | 138 | 3.77M | #endif | 139 | 3.77M | outptr += RGB_PIXELSIZE; | 140 | 3.77M | } | 141 | 85.2k | } | 142 | 42.5k | } |
Unexecuted instantiation: jdcolor-8.c:rgb_rgb_convert Unexecuted instantiation: jdcolor-12.c:rgb_extrgb_convert Unexecuted instantiation: jdcolor-12.c:rgb_extrgbx_convert Unexecuted instantiation: jdcolor-12.c:rgb_extbgr_convert Unexecuted instantiation: jdcolor-12.c:rgb_extbgrx_convert Unexecuted instantiation: jdcolor-12.c:rgb_extxbgr_convert Unexecuted instantiation: jdcolor-12.c:rgb_extxrgb_convert Unexecuted instantiation: jdcolor-12.c:rgb_rgb_convert Unexecuted instantiation: jdcolor-16.c:rgb_extrgb_convert Unexecuted instantiation: jdcolor-16.c:rgb_extrgbx_convert Unexecuted instantiation: jdcolor-16.c:rgb_extbgr_convert Unexecuted instantiation: jdcolor-16.c:rgb_extbgrx_convert Unexecuted instantiation: jdcolor-16.c:rgb_extxbgr_convert Unexecuted instantiation: jdcolor-16.c:rgb_extxrgb_convert Unexecuted instantiation: jdcolor-16.c:rgb_rgb_convert |