Debian Codegraph @

src/main/dither-ordered.c

raw symbols SCIP
1 /*
2 *
3 * Ordered dither algorithm
4 *
5 * Copyright 1997-2003 Michael Sweet ([email protected]) and
6 * Robert Krawitz ([email protected])
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 *
21 * Revision History:
22 *
23 * See ChangeLog
24 */
25
26 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`!
27 #include <config.h>cxx . . $ `<file>/config.h`/
28 #endif
29 #include <gutenprint/gutenprint.h>cxx . . $ `<file>/include/gutenprint/gutenprint.h`/
30 #include "gutenprint-internal.h"cxx . . $ `<file>/src/main/gutenprint-internal.h`/
31 #include <gutenprint/gutenprint-intl-internal.h>cxx . . $ `<file>/include/gutenprint/gutenprint-intl-internal.h`/
32 #include "dither-impl.h"cxx . . $ `<file>/src/main/dither-impl.h`/
33 #include "dither-inlined-functions.h"cxx . . $ `<file>/src/main/dither-inlined-functions.h`/
34
35
36 typedef structcxx . . $ $anonymous_type_59b42585814323c8_0# {
37 size_tcxx . . $ size_t# channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels.;
38 double *dropscxx . . $ $anonymous_type_59b42585814323c8_0#drops.;
39 unsigned short *lutcxx . . $ $anonymous_type_59b42585814323c8_0#lut.;
40 } stpi_new_ordered_tcxx . . $ stpi_new_ordered_t#;
41
42 typedef structcxx . . $ $anonymous_type_59b42585814323c8_1# {
43 unsigned short shiftcxx . . $ $anonymous_type_59b42585814323c8_1#shift.;
44 unsigned short maskcxx . . $ $anonymous_type_59b42585814323c8_1#mask.;
45 unsigned short x_maskcxx . . $ $anonymous_type_59b42585814323c8_1#x_mask.;
46 stpi_new_ordered_tcxx . . $ stpi_new_ordered_t# *ord_newcxx . . $ $anonymous_type_59b42585814323c8_1#ord_new.;
47 } stpi_ordered_tcxx . . $ stpi_ordered_t#;
48
49 static int
50 compare_channelscxx . . $ compare_channels(367837b2e2d3e609).(const stpi_dither_channel_tcxx . . $ stpi_dither_channel_t# *dc1,
51 const stpi_dither_channel_tcxx . . $ stpi_dither_channel_t# *dc2)
52 {
53 int i;
54 if (dc1->nlevelscxx . . $ dither_channel#nlevels. != dc2->nlevelscxx . . $ dither_channel#nlevels.)
55 return 0;
56 for (i = 0; i < dc1->nlevelscxx . . $ dither_channel#nlevels.; i++)
57 if (dc1->rangescxx . . $ dither_channel#ranges.[i].uppercxx . . $ dither_segment#upper.->valuecxx . . $ ink_defn#value. != dc2->rangescxx . . $ dither_channel#ranges.[i].uppercxx . . $ dither_segment#upper.->valuecxx . . $ ink_defn#value.)
58 return 0;
59 return 1;
60 }
61
62 static const double dp_fractioncxx . . $ dp_fraction. = 0.5;
63
64 static void
65 init_dither_channel_newcxx . . $ init_dither_channel_new(3326964035780666).(stpi_dither_channel_tcxx . . $ stpi_dither_channel_t# *dc, stp_vars_tcxx . . $ stp_vars_t# *v)
66 {
67 int i, j, k;
68 double bp = 0;
69 double lbp = 0;
70 double lower_bottom = 0;
71 double lower_middle = 0;
72 double lower_top = 0;
73 double upper_bottom = 0;
74 double upper_middle = 0;
75 double upper_top = 0;
76
77 double *breakpoints;
78 double *val;
79 unsigned short *data;
80 stpi_new_ordered_tcxx . . $ stpi_new_ordered_t# *ord = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(stpi_new_ordered_tcxx . . $ stpi_new_ordered_t#));
81 ((stpi_ordered_tcxx . . $ stpi_ordered_t# *) (dc->aux_datacxx . . $ dither_channel#aux_data.))->ord_newcxx . . $ $anonymous_type_59b42585814323c8_1#ord_new. = ord;
82 ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels. = dc->nlevelscxx . . $ dither_channel#nlevels. - 1;
83 ord->dropscxx . . $ $anonymous_type_59b42585814323c8_0#drops. = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(double) * (ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels. + 1));
84 breakpoints = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(double) * (ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels. + 1));
85 val = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(double) * ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels.);
86 data = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(unsigned short) * 65536 * ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels.);
87 ord->lutcxx . . $ $anonymous_type_59b42585814323c8_0#lut. = data;
88 for (j = 0; j < ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels.; j++)
89 {
90 stpi_dither_segment_tcxx . . $ stpi_dither_segment_t# *dd = &(dc->rangescxx . . $ dither_channel#ranges.[j]);
91 ord->dropscxx . . $ $anonymous_type_59b42585814323c8_0#drops.[j] = (double) dd->uppercxx . . $ dither_segment#upper.->valuecxx . . $ ink_defn#value. / 65535.0;
92 }
93 ord->dropscxx . . $ $anonymous_type_59b42585814323c8_0#drops.[ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels.] = 1;
94 for (j = 0; j < ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels.; j++)
95 {
96 if (j == 0)
97 breakpoints[j] = 65535 * ord->dropscxx . . $ $anonymous_type_59b42585814323c8_0#drops.[j] * dp_fractioncxx . . $ dp_fraction.;
98 else
99 breakpoints[j] = 65535 * ((ord->dropscxx . . $ $anonymous_type_59b42585814323c8_0#drops.[j] * dp_fractioncxx . . $ dp_fraction.) +
100 (ord->dropscxx . . $ $anonymous_type_59b42585814323c8_0#drops.[j - 1] * (1.0 - dp_fractioncxx . . $ dp_fraction.)));
101 stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_INKcxx . . $ `include/gutenprint/util.h:168:9`!, v, " size %.3f bp %5.0f\n",
102 ord->dropscxx . . $ $anonymous_type_59b42585814323c8_0#drops.[j], breakpoints[j]);
103 }
104 breakpoints[ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels.] = 65535;
105 j = 0;
106 for (i = 0; i <= ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels.; i++)
107 {
108 lbp = bp;
109 bp = breakpoints[i];
110 lower_bottom = upper_middle;
111 upper_bottom = 0;
112 lower_middle = upper_top;
113 lower_top = 0;
114 if (i == ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels.)
115 upper_top = 0;
116 else
117 upper_top = 65535 * dp_fractioncxx . . $ dp_fraction.;
118 if (i > 0)
119 upper_middle = 65535 - upper_top;
120 while (j <= bp)
121 {
122 double range_point = (j - lbp) / (bp - lbp);
123 double uv, mv, lv;
124 int total_ink = 0;
125 for (k = 0; k < ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels.; k++)
126 val[k] = 0;
127 uv = lower_top + (upper_top - lower_top) * range_point;
128 mv = lower_middle + (upper_middle - lower_middle) * range_point;
129 lv = lower_bottom + (upper_bottom - lower_bottom) * range_point;
130
131 if (i < ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels.)
132 val[i] = (unsigned short) uv;
133 if (i > 0)
134 val[i - 1] = (unsigned short) mv;
135 if (i > 1)
136 val[i - 2] = (unsigned short) lv;
137 for (k = ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels. - 1; k >= 0; k--)
138 {
139 total_ink += val[k];
140 if (total_ink > 65535)
141 total_ink = 65535;
142 data[k] = total_ink;
143 }
144 if ((stp_get_debug_levelcxx . . $ stp_get_debug_level(f708dce9a8856c70).() & STP_DBG_INKcxx . . $ `include/gutenprint/util.h:168:9`!) && (j % 257 == 0))
145 {
146 stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_INKcxx . . $ `include/gutenprint/util.h:168:9`!, v, " %5d:", j);
147 for (k = 0; k < ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels.; k++)
148 stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_INKcxx . . $ `include/gutenprint/util.h:168:9`!, v, " %9.3f", val[k]);
149 stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_INKcxx . . $ `include/gutenprint/util.h:168:9`!, v, " ");
150 for (k = 0; k < ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels.; k++)
151 stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_INKcxx . . $ `include/gutenprint/util.h:168:9`!, v, " %9.3f", breakpoints[k]);
152 stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_INKcxx . . $ `include/gutenprint/util.h:168:9`!, v, " ");
153 for (k = 0; k < ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels.; k++)
154 stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_INKcxx . . $ `include/gutenprint/util.h:168:9`!, v, " %5d", data[k]);
155 stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_INKcxx . . $ `include/gutenprint/util.h:168:9`!, v, "\n");
156 }
157 data += ord->channelscxx . . $ $anonymous_type_59b42585814323c8_0#channels.;
158 j++;
159 }
160 }
161 stp_freecxx . . $ stp_free(5d22bdacc48458e8).(breakpoints);
162 stp_freecxx . . $ stp_free(5d22bdacc48458e8).(val);
163 }
164
165 static inlinecxx . . $ `src/main/dither-impl.h:41:9`! void
166 print_color_ordered_newcxx . . $ print_color_ordered_new(c556e4b2f71eefc7).(const stpi_dither_tcxx . . $ stpi_dither_t# *d, stpi_dither_channel_tcxx . . $ stpi_dither_channel_t# *dc,
167 int val, int x, int y, unsigned char bit, int length)
168 {
169 int i;
170 int j;
171 unsigned bits;
172 int levels = dc->nlevelscxx . . $ dither_channel#nlevels. - 1;
173 unsigned dpoint = ditherpointcxx . . $ ditherpoint(44214aea3cf6f5be).(d, &(dc->dithermatcxx . . $ dither_channel#dithermat.), x);
174 const stpi_ordered_tcxx . . $ stpi_ordered_t# *o = (const stpi_ordered_tcxx . . $ stpi_ordered_t# *) dc->aux_datacxx . . $ dither_channel#aux_data.;
175 const stpi_new_ordered_tcxx . . $ stpi_new_ordered_t# *ord = (const stpi_new_ordered_tcxx . . $ stpi_new_ordered_t# *) o->ord_newcxx . . $ $anonymous_type_59b42585814323c8_1#ord_new.;
176 unsigned short swhere = (unsigned short) val;
177 unsigned short *where = ord ? ord->lutcxx . . $ $anonymous_type_59b42585814323c8_0#lut. + (val * levels) : &swhere;
178 (void)y;
179
180 /*
181 * Look for the appropriate range into which the input value falls.
182 */
183 for (i = levels - 1; i >= 0; i--)
184 {
185 if (dpoint < where[i])
186 {
187 stpi_dither_segment_tcxx . . $ stpi_dither_segment_t# *dd = &(dc->rangescxx . . $ dither_channel#ranges.[i]);
188 bits = dd->uppercxx . . $ dither_segment#upper.->bitscxx . . $ ink_defn#bits.;
189 if (bits)
190 {
191 unsigned char *tptr = dc->ptrcxx . . $ dither_channel#ptr. + d->ptr_offsetcxx . . $ dither#ptr_offset.;
192
193 /*
194 * Lay down all of the bits in the pixel.
195 */
196 set_row_endscxx . . $ set_row_ends(64d265e6bb66a9f0).(dc, x);
197 for (j = 1; j <= bits; j += j, tptr += length)
198 {
199 if (j & bits)
200 tptr[0] |= bit;
201 }
202
203 }
204 return;
205 }
206 }
207 }
208
209 static inlinecxx . . $ `src/main/dither-impl.h:41:9`! void
210 print_color_orderedcxx . . $ print_color_ordered(c556e4b2f71eefc7).(const stpi_dither_tcxx . . $ stpi_dither_t# *d, stpi_dither_channel_tcxx . . $ stpi_dither_channel_t# *dc, int val,
211 int x, int y, unsigned char bit, int length)
212 {
213 int i;
214 int j;
215 unsigned bits;
216 int levels = dc->nlevelscxx . . $ dither_channel#nlevels. - 1;
217 (void)y;
218
219 /*
220 * Look for the appropriate range into which the input value falls.
221 */
222 for (i = levels; i >= 0; i--)
223 {
224 stpi_dither_segment_tcxx . . $ stpi_dither_segment_t# *dd = &(dc->rangescxx . . $ dither_channel#ranges.[i]);
225
226 if (val > dd->lowercxx . . $ dither_segment#lower.->valuecxx . . $ ink_defn#value.)
227 {
228 /*
229 * Where are we within the range.
230 */
231
232 unsigned rangepoint = val - dd->lowercxx . . $ dither_segment#lower.->valuecxx . . $ ink_defn#value.;
233 if (dd->value_spancxx . . $ dither_segment#value_span. < 65535)
234 rangepoint = rangepoint * 65535 / dd->value_spancxx . . $ dither_segment#value_span.;
235
236 if (rangepoint >= ditherpointcxx . . $ ditherpoint(44214aea3cf6f5be).(d, &(dc->dithermatcxx . . $ dither_channel#dithermat.), x))
237 bits = dd->uppercxx . . $ dither_segment#upper.->bitscxx . . $ ink_defn#bits.;
238 else
239 bits = dd->lowercxx . . $ dither_segment#lower.->bitscxx . . $ ink_defn#bits.;
240
241 if (bits)
242 {
243 unsigned char *tptr = dc->ptrcxx . . $ dither_channel#ptr. + d->ptr_offsetcxx . . $ dither#ptr_offset.;
244
245 /*
246 * Lay down all of the bits in the pixel.
247 */
248 set_row_endscxx . . $ set_row_ends(64d265e6bb66a9f0).(dc, x);
249 for (j = 1; j <= bits; j += j, tptr += length)
250 {
251 if (j & bits)
252 tptr[0] |= bit;
253 }
254
255 }
256 return;
257 }
258 }
259 }
260
261 static void
262 free_dither_orderedcxx . . $ free_dither_ordered(eba3149742ad601b).(stpi_dither_tcxx . . $ stpi_dither_t# *d)
263 {
264 int i;
265 stpi_dither_channel_tcxx . . $ stpi_dither_channel_t# *dc0 = &CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, 0);
266 stpi_ordered_tcxx . . $ stpi_ordered_t# *o0 = dc0->aux_datacxx . . $ dither_channel#aux_data.;
267 stpi_new_ordered_tcxx . . $ stpi_new_ordered_t# *no0 = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
268 if (o0)
269 no0 = o0->ord_newcxx . . $ $anonymous_type_59b42585814323c8_1#ord_new.;
270 for (i = CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d) - 1; i >= 0 ; i--)
271 {
272 stpi_dither_channel_tcxx . . $ stpi_dither_channel_t# *dc = &CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i);
273 if (dc->aux_datacxx . . $ dither_channel#aux_data.)
274 {
275 stpi_ordered_tcxx . . $ stpi_ordered_t# *ord = (stpi_ordered_tcxx . . $ stpi_ordered_t# *) dc->aux_datacxx . . $ dither_channel#aux_data.;
276 if (ord->ord_newcxx . . $ $anonymous_type_59b42585814323c8_1#ord_new. && (i == 0 || ord->ord_newcxx . . $ $anonymous_type_59b42585814323c8_1#ord_new. != no0))
277 {
278 stpi_new_ordered_tcxx . . $ stpi_new_ordered_t# *no = (stpi_new_ordered_tcxx . . $ stpi_new_ordered_t# *) ord->ord_newcxx . . $ $anonymous_type_59b42585814323c8_1#ord_new.;
279 if (no->dropscxx . . $ $anonymous_type_59b42585814323c8_0#drops.)
280 stp_freecxx . . $ stp_free(5d22bdacc48458e8).(no->dropscxx . . $ $anonymous_type_59b42585814323c8_0#drops.);
281 if (no->lutcxx . . $ $anonymous_type_59b42585814323c8_0#lut.)
282 stp_freecxx . . $ stp_free(5d22bdacc48458e8).(no->lutcxx . . $ $anonymous_type_59b42585814323c8_0#lut.);
283 stp_freecxx . . $ stp_free(5d22bdacc48458e8).(no);
284 }
285 stp_freecxx . . $ stp_free(5d22bdacc48458e8).(dc->aux_datacxx . . $ dither_channel#aux_data.);
286 dc->aux_datacxx . . $ dither_channel#aux_data. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
287 }
288 }
289 stp_freecxx . . $ stp_free(5d22bdacc48458e8).(d->aux_datacxx . . $ dither#aux_data.);
290 }
291
292 static void
293 init_dither_orderedcxx . . $ init_dither_ordered(8387cf6d221718ba).(stpi_dither_tcxx . . $ stpi_dither_t# *d, stp_vars_tcxx . . $ stp_vars_t# *v)
294 {
295 int i;
296 d->aux_datacxx . . $ dither#aux_data. = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(1);
297 d->aux_freefunccxx . . $ dither#aux_freefunc. = &free_dither_orderedcxx . . $ free_dither_ordered(eba3149742ad601b).;
298 stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_INKcxx . . $ `include/gutenprint/util.h:168:9`!, v, "init_dither_ordered\n");
299 for (i = 0; i < CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d); i++)
300 {
301 stpi_dither_channel_tcxx . . $ stpi_dither_channel_t# *dc = &CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i);
302 stpi_ordered_tcxx . . $ stpi_ordered_t# *s;
303 dc->aux_datacxx . . $ dither_channel#aux_data. = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(stpi_ordered_tcxx . . $ stpi_ordered_t#));
304 s = (stpi_ordered_tcxx . . $ stpi_ordered_t# *) dc->aux_datacxx . . $ dither_channel#aux_data.;
305 s->ord_newcxx . . $ $anonymous_type_59b42585814323c8_1#ord_new. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
306 if (d->stpi_dither_typecxx . . $ dither#stpi_dither_type. & D_ORDERED_SEGMENTEDcxx . . $ `src/main/dither-impl.h:61:9`!)
307 {
308 s->shiftcxx . . $ $anonymous_type_59b42585814323c8_1#shift. = 16 - dc->signif_bitscxx . . $ dither_channel#signif_bits.;
309 s->maskcxx . . $ $anonymous_type_59b42585814323c8_1#mask. = ((1 << dc->signif_bitscxx . . $ dither_channel#signif_bits.) - 1) << s->shiftcxx . . $ $anonymous_type_59b42585814323c8_1#shift.;
310 s->x_maskcxx . . $ $anonymous_type_59b42585814323c8_1#x_mask. = ~(s->maskcxx . . $ $anonymous_type_59b42585814323c8_1#mask.);
311 stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_INKcxx . . $ `include/gutenprint/util.h:168:9`!, v, " channel %d: shift %d mask 0x%x x_mask 0x%x\n",
312 i, s->shiftcxx . . $ $anonymous_type_59b42585814323c8_1#shift., s->maskcxx . . $ $anonymous_type_59b42585814323c8_1#mask., s->x_maskcxx . . $ $anonymous_type_59b42585814323c8_1#x_mask.);
313 }
314 if (d->stpi_dither_typecxx . . $ dither#stpi_dither_type. & D_ORDERED_NEWcxx . . $ `src/main/dither-impl.h:60:9`!)
315 {
316 if (dc->nlevelscxx . . $ dither_channel#nlevels. < 2)
317 stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_INKcxx . . $ `include/gutenprint/util.h:168:9`!, v, " channel %d ignored\n", i);
318 else if (i == 0 || !compare_channelscxx . . $ compare_channels(367837b2e2d3e609).(&CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, 0), dc))
319 {
320 stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_INKcxx . . $ `include/gutenprint/util.h:168:9`!, v, " channel %d\n", i);
321 init_dither_channel_newcxx . . $ init_dither_channel_new(3326964035780666).(dc, v);
322 }
323 else
324 {
325 stp_dprintfcxx . . $ stp_dprintf(13526ca24396f6ac).(STP_DBG_INKcxx . . $ `include/gutenprint/util.h:168:9`!, v, " channel %d duplicated from channel 0\n", i);
326 s->ord_newcxx . . $ $anonymous_type_59b42585814323c8_1#ord_new. = ((stpi_ordered_tcxx . . $ stpi_ordered_t# *) (CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, 0).aux_datacxx . . $ dither_channel#aux_data.))->ord_newcxx . . $ $anonymous_type_59b42585814323c8_1#ord_new.;
327 }
328 }
329 }
330 }
331
332 void
333 stpi_dither_orderedcxx . . $ stpi_dither_ordered(525e4b1c00087d37).(stp_vars_tcxx . . $ stp_vars_t# *v,
334 int row,
335 const unsigned short *raw,
336 int duplicate_line,
337 int zero_mask,
338 const unsigned char *mask)
339 {
340 stpi_dither_tcxx . . $ stpi_dither_t# *d = (stpi_dither_tcxx . . $ stpi_dither_t# *) stp_get_component_datacxx . . $ stp_get_component_data(2bc0070dfdce2f04).(v, "Dither");
341 int x,
342 length;
343 unsigned char bit;
344 int i;
345 int one_bit_only = 1;
346 int one_level_only = 1;
347
348 int xerror, xstep, xmod;
349 (void)duplicate_line;
350
351 if ((zero_mask & ((1 << CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d)) - 1)) ==
352 ((1 << CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d)) - 1))
353 return;
354
355 length = (d->dst_widthcxx . . $ dither#dst_width. + 7) / 8;
356
357 bit = 128;
358 xstep = CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d) * (d->src_widthcxx . . $ dither#src_width. / d->dst_widthcxx . . $ dither#dst_width.);
359 xmod = d->src_widthcxx . . $ dither#src_width. % d->dst_widthcxx . . $ dither#dst_width.;
360 xerror = 0;
361
362 for (i = 0; i < CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d); i++)
363 {
364 stpi_dither_channel_tcxx . . $ stpi_dither_channel_t# *dc = &(CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i));
365 if (dc->nlevelscxx . . $ dither_channel#nlevels. != 1)
366 one_level_only = 0;
367 if (dc->nlevelscxx . . $ dither_channel#nlevels. != 1 || dc->rangescxx . . $ dither_channel#ranges.[0].uppercxx . . $ dither_segment#upper.->bitscxx . . $ ink_defn#bits. != 1)
368 one_bit_only = 0;
369 }
370 if (! one_bit_only && ! d->aux_datacxx . . $ dither#aux_data. &&
371 (d->stpi_dither_typecxx . . $ dither#stpi_dither_type. & (D_ORDERED_SEGMENTEDcxx . . $ `src/main/dither-impl.h:61:9`! | D_ORDERED_NEWcxx . . $ `src/main/dither-impl.h:60:9`!)))
372 init_dither_orderedcxx . . $ init_dither_ordered(8387cf6d221718ba).(d, v);
373
374 if (one_bit_only)
375 {
376 for (x = 0; x < d->dst_widthcxx . . $ dither#dst_width.; x ++)
377 {
378 if (!mask || (*(mask + d->ptr_offsetcxx . . $ dither#ptr_offset.) & bit))
379 {
380 for (i = 0; i < CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d); i++)
381 {
382 if (raw[i] &&
383 raw[i] >= ditherpointcxx . . $ ditherpoint(44214aea3cf6f5be).(d, &(CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i).dithermatcxx . . $ dither_channel#dithermat.), x))
384 {
385 set_row_endscxx . . $ set_row_ends(64d265e6bb66a9f0).(&(CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i)), x);
386 CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i).ptrcxx . . $ dither_channel#ptr.[d->ptr_offsetcxx . . $ dither#ptr_offset.] |= bit;
387 }
388 }
389 }
390 ADVANCE_UNIDIRECTIONALcxx . . $ `src/main/dither-impl.h:199:9`!(d, bit, raw, CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d),
391 xerror, xstep, xmod);
392 }
393 }
394 else if (d->stpi_dither_typecxx . . $ dither#stpi_dither_type. & D_ORDERED_SEGMENTEDcxx . . $ `src/main/dither-impl.h:61:9`!)
395 {
396 for (x = 0; x < d->dst_widthcxx . . $ dither#dst_width.; x ++)
397 {
398 if (!mask || (*(mask + d->ptr_offsetcxx . . $ dither#ptr_offset.) & bit))
399 {
400 for (i = 0; i < CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d); i++)
401 {
402 stpi_dither_channel_tcxx . . $ stpi_dither_channel_t# *dc = &CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i);
403 stpi_ordered_tcxx . . $ stpi_ordered_t# *s = (stpi_ordered_tcxx . . $ stpi_ordered_t# *) dc->aux_datacxx . . $ dither_channel#aux_data.;
404 unsigned short bits = raw[i] >> s->shiftcxx . . $ $anonymous_type_59b42585814323c8_1#shift.;
405 unsigned short val = raw[i] << dc->signif_bitscxx . . $ dither_channel#signif_bits.;
406 val |= val >> s->shiftcxx . . $ $anonymous_type_59b42585814323c8_1#shift.;
407
408 if (bits)
409 {
410 if (val &&
411 val >= ditherpointcxx . . $ ditherpoint(44214aea3cf6f5be).(d, &(CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i).dithermatcxx . . $ dither_channel#dithermat.), x))
412 {
413 int j;
414 unsigned char *tptr = dc->ptrcxx . . $ dither_channel#ptr. + d->ptr_offsetcxx . . $ dither#ptr_offset.;
415 set_row_endscxx . . $ set_row_ends(64d265e6bb66a9f0).(dc, x);
416 for (j = 1; j <= bits; j += j, tptr += length)
417 {
418 if (j & bits)
419 tptr[0] |= bit;
420 }
421 }
422 }
423 else if (CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i).ptrcxx . . $ dither_channel#ptr. && val)
424 {
425 if (d->stpi_dither_typecxx . . $ dither#stpi_dither_type. & D_ORDERED_NEWcxx . . $ `src/main/dither-impl.h:60:9`!)
426 print_color_ordered_newcxx . . $ print_color_ordered_new(c556e4b2f71eefc7).(d, &(CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i)), val, x,
427 row, bit, length);
428 else
429 print_color_orderedcxx . . $ print_color_ordered(c556e4b2f71eefc7).(d, &(CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i)), val, x,
430 row, bit, length);
431 }
432 }
433 }
434 ADVANCE_UNIDIRECTIONALcxx . . $ `src/main/dither-impl.h:199:9`!(d, bit, raw, CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d),
435 xerror, xstep, xmod);
436 }
437 }
438 else if (one_level_only || !(d->stpi_dither_typecxx . . $ dither#stpi_dither_type. == D_ORDERED_NEWcxx . . $ `src/main/dither-impl.h:60:9`!))
439 {
440 for (x = 0; x != d->dst_widthcxx . . $ dither#dst_width.; x ++)
441 {
442 if (!mask || (*(mask + d->ptr_offsetcxx . . $ dither#ptr_offset.) & bit))
443 {
444 for (i = 0; i < CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d); i++)
445 {
446 if (CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i).ptrcxx . . $ dither_channel#ptr. && raw[i])
447 print_color_orderedcxx . . $ print_color_ordered(c556e4b2f71eefc7).(d, &(CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i)), raw[i], x, row,
448 bit, length);
449 }
450 }
451 ADVANCE_UNIDIRECTIONALcxx . . $ `src/main/dither-impl.h:199:9`!(d, bit, raw, CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d), xerror,
452 xstep, xmod);
453 }
454 }
455 else
456 {
457 for (x = 0; x != d->dst_widthcxx . . $ dither#dst_width.; x ++)
458 {
459 if (!mask || (*(mask + d->ptr_offsetcxx . . $ dither#ptr_offset.) & bit))
460 {
461 for (i = 0; i < CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d); i++)
462 {
463 if (CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i).ptrcxx . . $ dither_channel#ptr. && raw[i])
464 print_color_ordered_newcxx . . $ print_color_ordered_new(c556e4b2f71eefc7).(d, &(CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, i)), raw[i], x,
465 row, bit, length);
466 }
467 }
468 ADVANCE_UNIDIRECTIONALcxx . . $ `src/main/dither-impl.h:199:9`!(d, bit, raw, CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d), xerror,
469 xstep, xmod);
470 }
471 }
472 }