/src/libjpeg-turbo.dev/src/jccolext.c
Line | Count | Source |
1 | | /* |
2 | | * jccolext.c |
3 | | * |
4 | | * This file was part of the Independent JPEG Group's software: |
5 | | * Copyright (C) 1991-1996, Thomas G. Lane. |
6 | | * libjpeg-turbo Modifications: |
7 | | * Copyright (C) 2009-2012, 2015, 2022, 2025, D. R. Commander. |
8 | | * For conditions of distribution and use, see the accompanying README.ijg |
9 | | * file. |
10 | | * |
11 | | * This file contains input colorspace conversion routines. |
12 | | */ |
13 | | |
14 | | |
15 | | /* This file is included by jccolor.c */ |
16 | | |
17 | | |
18 | | /* |
19 | | * Convert some rows of samples to the JPEG colorspace. |
20 | | * |
21 | | * Note that we change from the application's interleaved-pixel format |
22 | | * to our internal noninterleaved, one-plane-per-component format. |
23 | | * The input buffer is therefore three times as wide as the output buffer. |
24 | | * |
25 | | * A starting row offset is provided only for the output buffer. The caller |
26 | | * can easily adjust the passed input_buf value to accommodate any row |
27 | | * offset required on that side. |
28 | | */ |
29 | | |
30 | | INLINE |
31 | | LOCAL(void) |
32 | | rgb_ycc_convert(j_compress_ptr cinfo, _JSAMPARRAY input_buf, |
33 | | _JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows) |
34 | 0 | { |
35 | | #if BITS_IN_JSAMPLE != 16 |
36 | | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; |
37 | | register int r, g, b; |
38 | | register JLONG *ctab = cconvert->rgb_ycc_tab; |
39 | | register _JSAMPROW inptr; |
40 | | register _JSAMPROW outptr0, outptr1, outptr2; |
41 | | register JDIMENSION col; |
42 | | JDIMENSION num_cols = cinfo->image_width; |
43 | | |
44 | 0 | while (--num_rows >= 0) { |
45 | 0 | inptr = *input_buf++; |
46 | 0 | outptr0 = output_buf[0][output_row]; |
47 | 0 | outptr1 = output_buf[1][output_row]; |
48 | 0 | outptr2 = output_buf[2][output_row]; |
49 | 0 | output_row++; |
50 | 0 | for (col = 0; col < num_cols; col++) { |
51 | 0 | r = RANGE_LIMIT(inptr[RGB_RED]); |
52 | 0 | g = RANGE_LIMIT(inptr[RGB_GREEN]); |
53 | 0 | b = RANGE_LIMIT(inptr[RGB_BLUE]); |
54 | 0 | inptr += RGB_PIXELSIZE; |
55 | | /* If the inputs are 0.._MAXJSAMPLE, the outputs of these equations |
56 | | * must be too; we do not need an explicit range-limiting operation. |
57 | | * Hence the value being shifted is never negative, and we don't |
58 | | * need the general RIGHT_SHIFT macro. |
59 | | */ |
60 | | /* Y */ |
61 | 0 | outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] + |
62 | 0 | ctab[b + B_Y_OFF]) >> SCALEBITS); |
63 | | /* Cb */ |
64 | 0 | outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] + |
65 | 0 | ctab[b + B_CB_OFF]) >> SCALEBITS); |
66 | | /* Cr */ |
67 | 0 | outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] + |
68 | 0 | ctab[b + B_CR_OFF]) >> SCALEBITS); |
69 | 0 | } |
70 | 0 | } |
71 | | #else |
72 | 0 | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); |
73 | | #endif |
74 | 0 | } Unexecuted instantiation: jccolor-8.c:extrgb_ycc_convert Unexecuted instantiation: jccolor-8.c:extrgbx_ycc_convert Unexecuted instantiation: jccolor-8.c:extbgr_ycc_convert Unexecuted instantiation: jccolor-8.c:extbgrx_ycc_convert Unexecuted instantiation: jccolor-8.c:extxbgr_ycc_convert Unexecuted instantiation: jccolor-8.c:extxrgb_ycc_convert Unexecuted instantiation: jccolor-8.c:rgb_ycc_convert Unexecuted instantiation: jccolor-12.c:extrgb_ycc_convert Unexecuted instantiation: jccolor-12.c:extrgbx_ycc_convert Unexecuted instantiation: jccolor-12.c:extbgr_ycc_convert Unexecuted instantiation: jccolor-12.c:extbgrx_ycc_convert Unexecuted instantiation: jccolor-12.c:extxbgr_ycc_convert Unexecuted instantiation: jccolor-12.c:extxrgb_ycc_convert Unexecuted instantiation: jccolor-12.c:rgb_ycc_convert Unexecuted instantiation: jccolor-16.c:extrgb_ycc_convert Unexecuted instantiation: jccolor-16.c:extrgbx_ycc_convert Unexecuted instantiation: jccolor-16.c:extbgr_ycc_convert Unexecuted instantiation: jccolor-16.c:extbgrx_ycc_convert Unexecuted instantiation: jccolor-16.c:extxbgr_ycc_convert Unexecuted instantiation: jccolor-16.c:extxrgb_ycc_convert Unexecuted instantiation: jccolor-16.c:rgb_ycc_convert |
75 | | |
76 | | |
77 | | /**************** Cases other than RGB -> YCbCr **************/ |
78 | | |
79 | | |
80 | | /* |
81 | | * Convert some rows of samples to the JPEG colorspace. |
82 | | * This version handles RGB->grayscale conversion, which is the same |
83 | | * as the RGB->Y portion of RGB->YCbCr. |
84 | | * We assume rgb_ycc_start has been called (we only use the Y tables). |
85 | | */ |
86 | | |
87 | | INLINE |
88 | | LOCAL(void) |
89 | | rgb_gray_convert(j_compress_ptr cinfo, _JSAMPARRAY input_buf, |
90 | | _JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows) |
91 | 0 | { |
92 | | #if BITS_IN_JSAMPLE != 16 |
93 | | my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert; |
94 | | register int r, g, b; |
95 | | register JLONG *ctab = cconvert->rgb_ycc_tab; |
96 | | register _JSAMPROW inptr; |
97 | | register _JSAMPROW outptr; |
98 | | register JDIMENSION col; |
99 | | JDIMENSION num_cols = cinfo->image_width; |
100 | | |
101 | 0 | while (--num_rows >= 0) { |
102 | 0 | inptr = *input_buf++; |
103 | 0 | outptr = output_buf[0][output_row]; |
104 | 0 | output_row++; |
105 | 0 | for (col = 0; col < num_cols; col++) { |
106 | 0 | r = RANGE_LIMIT(inptr[RGB_RED]); |
107 | 0 | g = RANGE_LIMIT(inptr[RGB_GREEN]); |
108 | 0 | b = RANGE_LIMIT(inptr[RGB_BLUE]); |
109 | 0 | inptr += RGB_PIXELSIZE; |
110 | | /* Y */ |
111 | 0 | outptr[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] + |
112 | 0 | ctab[b + B_Y_OFF]) >> SCALEBITS); |
113 | 0 | } |
114 | 0 | } |
115 | | #else |
116 | 0 | ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); |
117 | | #endif |
118 | 0 | } Unexecuted instantiation: jccolor-8.c:extrgb_gray_convert Unexecuted instantiation: jccolor-8.c:extrgbx_gray_convert Unexecuted instantiation: jccolor-8.c:extbgr_gray_convert Unexecuted instantiation: jccolor-8.c:extbgrx_gray_convert Unexecuted instantiation: jccolor-8.c:extxbgr_gray_convert Unexecuted instantiation: jccolor-8.c:extxrgb_gray_convert Unexecuted instantiation: jccolor-8.c:rgb_gray_convert Unexecuted instantiation: jccolor-12.c:extrgb_gray_convert Unexecuted instantiation: jccolor-12.c:extrgbx_gray_convert Unexecuted instantiation: jccolor-12.c:extbgr_gray_convert Unexecuted instantiation: jccolor-12.c:extbgrx_gray_convert Unexecuted instantiation: jccolor-12.c:extxbgr_gray_convert Unexecuted instantiation: jccolor-12.c:extxrgb_gray_convert Unexecuted instantiation: jccolor-12.c:rgb_gray_convert Unexecuted instantiation: jccolor-16.c:extrgb_gray_convert Unexecuted instantiation: jccolor-16.c:extrgbx_gray_convert Unexecuted instantiation: jccolor-16.c:extbgr_gray_convert Unexecuted instantiation: jccolor-16.c:extbgrx_gray_convert Unexecuted instantiation: jccolor-16.c:extxbgr_gray_convert Unexecuted instantiation: jccolor-16.c:extxrgb_gray_convert Unexecuted instantiation: jccolor-16.c:rgb_gray_convert |
119 | | |
120 | | |
121 | | /* |
122 | | * Convert some rows of samples to the JPEG colorspace. |
123 | | * This version handles extended RGB->plain RGB conversion |
124 | | */ |
125 | | |
126 | | INLINE |
127 | | LOCAL(void) |
128 | | rgb_rgb_convert(j_compress_ptr cinfo, _JSAMPARRAY input_buf, |
129 | | _JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows) |
130 | 0 | { |
131 | 0 | register _JSAMPROW inptr; |
132 | 0 | register _JSAMPROW outptr0, outptr1, outptr2; |
133 | 0 | register JDIMENSION col; |
134 | 0 | JDIMENSION num_cols = cinfo->image_width; |
135 | |
|
136 | 0 | while (--num_rows >= 0) { |
137 | 0 | inptr = *input_buf++; |
138 | 0 | outptr0 = output_buf[0][output_row]; |
139 | 0 | outptr1 = output_buf[1][output_row]; |
140 | 0 | outptr2 = output_buf[2][output_row]; |
141 | 0 | output_row++; |
142 | 0 | for (col = 0; col < num_cols; col++) { |
143 | 0 | outptr0[col] = inptr[RGB_RED]; |
144 | 0 | outptr1[col] = inptr[RGB_GREEN]; |
145 | 0 | outptr2[col] = inptr[RGB_BLUE]; |
146 | 0 | inptr += RGB_PIXELSIZE; |
147 | 0 | } |
148 | 0 | } |
149 | 0 | } Unexecuted instantiation: jccolor-8.c:extrgb_rgb_convert Unexecuted instantiation: jccolor-8.c:extrgbx_rgb_convert Unexecuted instantiation: jccolor-8.c:extbgr_rgb_convert Unexecuted instantiation: jccolor-8.c:extbgrx_rgb_convert Unexecuted instantiation: jccolor-8.c:extxbgr_rgb_convert Unexecuted instantiation: jccolor-8.c:extxrgb_rgb_convert Unexecuted instantiation: jccolor-8.c:rgb_rgb_convert Unexecuted instantiation: jccolor-12.c:extrgb_rgb_convert Unexecuted instantiation: jccolor-12.c:extrgbx_rgb_convert Unexecuted instantiation: jccolor-12.c:extbgr_rgb_convert Unexecuted instantiation: jccolor-12.c:extbgrx_rgb_convert Unexecuted instantiation: jccolor-12.c:extxbgr_rgb_convert Unexecuted instantiation: jccolor-12.c:extxrgb_rgb_convert Unexecuted instantiation: jccolor-12.c:rgb_rgb_convert Unexecuted instantiation: jccolor-16.c:extrgb_rgb_convert Unexecuted instantiation: jccolor-16.c:extrgbx_rgb_convert Unexecuted instantiation: jccolor-16.c:extbgr_rgb_convert Unexecuted instantiation: jccolor-16.c:extbgrx_rgb_convert Unexecuted instantiation: jccolor-16.c:extxbgr_rgb_convert Unexecuted instantiation: jccolor-16.c:extxrgb_rgb_convert Unexecuted instantiation: jccolor-16.c:rgb_rgb_convert |