Debian Codegraph @

src/main/dither-impl.h

raw symbols SCIP
1 /*
2 * Internal implementation of dither algorithms
3 *
4 * Copyright 1997-2003 Michael Sweet ([email protected]) and
5 * Robert Krawitz ([email protected])
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 *
20 * Revision History:
21 *
22 * See ChangeLog
23 */
24
25 /*
26 * This file must include only standard C header files. The core code must
27 * compile on generic platforms that don't support glib, gimp, gtk, etc.
28 */
29
30 #ifndef GUTENPRINT_INTERNAL_DITHER_IMPL_H
31 #define GUTENPRINT_INTERNAL_DITHER_IMPL_Hcxx . . $ `src/main/dither-impl.h:31:9`!
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #include <limits.h>
38
39 #ifdef __GNUC__cxx . . $ `<built-in>:8:9`!
40 #ifndef inline
41 #define inlinecxx . . $ `src/main/dither-impl.h:41:9`! __inline__
42 #endif
43 #endif
44
45 #define D_FLOYD_HYBRIDcxx . . $ `src/main/dither-impl.h:45:9`! 0
46 #define D_ADAPTIVE_BASEcxx . . $ `src/main/dither-impl.h:46:9`! 4
47 #define D_ADAPTIVE_HYBRIDcxx . . $ `src/main/dither-impl.h:47:9`! (D_ADAPTIVE_BASEcxx . . $ `src/main/dither-impl.h:46:9`! | D_FLOYD_HYBRIDcxx . . $ `src/main/dither-impl.h:45:9`!)
48 #define D_ORDERED_BASEcxx . . $ `src/main/dither-impl.h:48:9`! 8
49 #define D_ORDEREDcxx . . $ `src/main/dither-impl.h:49:9`! (D_ORDERED_BASEcxx . . $ `src/main/dither-impl.h:48:9`!)
50 #define D_FAST_BASEcxx . . $ `src/main/dither-impl.h:50:9`! 16
51 #define D_FASTcxx . . $ `src/main/dither-impl.h:51:9`! (D_FAST_BASEcxx . . $ `src/main/dither-impl.h:50:9`!)
52 #define D_VERY_FASTcxx . . $ `src/main/dither-impl.h:52:9`! (D_FAST_BASEcxx . . $ `src/main/dither-impl.h:50:9`! + 1)
53 #define D_EVENTONEcxx . . $ `src/main/dither-impl.h:53:9`! 32
54 #define D_UNITONEcxx . . $ `src/main/dither-impl.h:54:9`! 64
55 #define D_EVENBETTERcxx . . $ `src/main/dither-impl.h:55:9`! 128
56 #define D_HYBRID_EVENTONEcxx . . $ `src/main/dither-impl.h:56:9`! (D_ORDERED_BASEcxx . . $ `src/main/dither-impl.h:48:9`! | D_EVENTONEcxx . . $ `src/main/dither-impl.h:53:9`!)
57 #define D_HYBRID_UNITONEcxx . . $ `src/main/dither-impl.h:57:9`! (D_ORDERED_BASEcxx . . $ `src/main/dither-impl.h:48:9`! | D_UNITONEcxx . . $ `src/main/dither-impl.h:54:9`!)
58 #define D_HYBRID_EVENBETTERcxx . . $ `src/main/dither-impl.h:58:9`! (D_ORDERED_BASE | D_EVENBETTER)
59 #define D_PREDITHEREDcxx . . $ `src/main/dither-impl.h:59:9`! 256
60 #define D_ORDERED_NEWcxx . . $ `src/main/dither-impl.h:60:9`! 512
61 #define D_ORDERED_SEGMENTEDcxx . . $ `src/main/dither-impl.h:61:9`! 1024
62 #define D_ORDERED_SEGMENTED_NEWcxx . . $ `src/main/dither-impl.h:62:9`! (D_ORDERED_SEGMENTEDcxx . . $ `src/main/dither-impl.h:61:9`! | D_ORDERED_NEWcxx . . $ `src/main/dither-impl.h:60:9`!)
63 #define D_INVALIDcxx . . $ `src/main/dither-impl.h:63:9`! -2
64
65 #define DITHER_FAST_STEPScxx . . $ `src/main/dither-impl.h:65:9`! (6)
66
67 typedef structcxx . . $ $anonymous_type_2f3242eb862b2f2_0#
68 {
69 const char *namecxx . . $ $anonymous_type_2f3242eb862b2f2_0#name.;
70 const char *textcxx . . $ $anonymous_type_2f3242eb862b2f2_0#text.;
71 int idcxx . . $ $anonymous_type_2f3242eb862b2f2_0#id.;
72 } stpi_dither_algorithm_tcxx . . $ stpi_dither_algorithm_t#;
73
74 #define ERROR_ROWScxx . . $ `src/main/dither-impl.h:74:9`! 2
75
76 #define MAX_SPREADcxx . . $ `src/main/dither-impl.h:76:9`! 32
77
78 typedef void stpi_ditherfunc_tcxx . . $ stpi_ditherfunc_t#(stp_vars_tcxx . . $ stp_vars_t# *, int, const unsigned short *, int,
79 int, const unsigned char *);
80
81 /*
82 * An end of a dither segment, describing one ink
83 */
84
85 typedef struct ink_defncxx . . $ ink_defn#
86 {
87 unsigned rangecxx . . $ ink_defn#range.;
88 unsigned valuecxx . . $ ink_defn#value.;
89 unsigned bitscxx . . $ ink_defn#bits.;
90 } stpi_ink_defn_tcxx . . $ stpi_ink_defn_t#;
91
92 /*
93 * A segment of the entire 0-65535 intensity range.
94 */
95
96 typedef struct dither_segmentcxx . . $ dither_segment#
97 {
98 stpi_ink_defn_tcxx . . $ stpi_ink_defn_t# *lowercxx . . $ dither_segment#lower.;
99 stpi_ink_defn_tcxx . . $ stpi_ink_defn_t# *uppercxx . . $ dither_segment#upper.;
100 unsigned range_spancxx . . $ dither_segment#range_span.;
101 unsigned value_spancxx . . $ dither_segment#value_span.;
102 int is_same_inkcxx . . $ dither_segment#is_same_ink.;
103 int is_equalcxx . . $ dither_segment#is_equal.;
104 } stpi_dither_segment_tcxx . . $ stpi_dither_segment_t#;
105
106 typedef struct dither_channelcxx . . $ dither_channel#
107 {
108 unsigned randomizercxx . . $ dither_channel#randomizer.; /* With Floyd-Steinberg dithering, control */
109 /* how much randomness is applied to the */
110 /* threshold values (0-65535). */
111 unsigned bit_maxcxx . . $ dither_channel#bit_max.;
112 unsigned signif_bitscxx . . $ dither_channel#signif_bits.;
113 unsigned densitycxx . . $ dither_channel#density.;
114 double darknesscxx . . $ dither_channel#darkness.; /* Relative darkness of this ink */
115
116 int vcxx . . $ dither_channel#v.;
117 int ocxx . . $ dither_channel#o.;
118 int bcxx . . $ dither_channel#b.;
119 int very_fastcxx . . $ dither_channel#very_fast.;
120
121 stpi_ink_defn_tcxx . . $ stpi_ink_defn_t# *ink_listcxx . . $ dither_channel#ink_list.;
122
123 int nlevelscxx . . $ dither_channel#nlevels.;
124 stpi_dither_segment_tcxx . . $ stpi_dither_segment_t# *rangescxx . . $ dither_channel#ranges.;
125
126 int error_rowscxx . . $ dither_channel#error_rows.;
127 int **errscxx . . $ dither_channel#errs.;
128
129 stp_dither_matrix_impl_tcxx . . $ stp_dither_matrix_impl_t# pickcxx . . $ dither_channel#pick.;
130 stp_dither_matrix_impl_tcxx . . $ stp_dither_matrix_impl_t# dithermatcxx . . $ dither_channel#dithermat.;
131 int row_endscxx . . $ dither_channel#row_ends.[2];
132 unsigned char *ptrcxx . . $ dither_channel#ptr.;
133 void *aux_datacxx . . $ dither_channel#aux_data.; /* aux_freefunc for dither should free this */
134 } stpi_dither_channel_tcxx . . $ stpi_dither_channel_t#;
135
136 typedef struct dithercxx . . $ dither#
137 {
138 int src_widthcxx . . $ dither#src_width.; /* Input width */
139 int dst_widthcxx . . $ dither#dst_width.; /* Output width */
140
141 int spreadcxx . . $ dither#spread.; /* With Floyd-Steinberg, how widely the */
142 int spread_maskcxx . . $ dither#spread_mask.; /* error is distributed. This should be */
143 /* between 12 (very broad distribution) and */
144 /* 19 (very narrow) */
145
146 int stpi_dither_typecxx . . $ dither#stpi_dither_type.;
147
148 int adaptive_limitcxx . . $ dither#adaptive_limit.;
149
150 int x_aspectcxx . . $ dither#x_aspect.; /* Aspect ratio numerator */
151 int y_aspectcxx . . $ dither#y_aspect.; /* Aspect ratio denominator */
152
153
154 int *offset0_tablecxx . . $ dither#offset0_table.;
155 int *offset1_tablecxx . . $ dither#offset1_table.;
156
157 int d_cutoffcxx . . $ dither#d_cutoff.;
158
159 int last_line_was_emptycxx . . $ dither#last_line_was_empty.;
160 int ptr_offsetcxx . . $ dither#ptr_offset.;
161 int error_rowscxx . . $ dither#error_rows.;
162
163 int finalizedcxx . . $ dither#finalized.; /* When dither is first called, calculate
164 * some things */
165
166 stp_dither_matrix_impl_tcxx . . $ stp_dither_matrix_impl_t# dither_matrixcxx . . $ dither#dither_matrix.;
167 stpi_dither_channel_tcxx . . $ stpi_dither_channel_t# *channelcxx . . $ dither#channel.;
168 unsigned channel_countcxx . . $ dither#channel_count.;
169 unsigned total_channel_countcxx . . $ dither#total_channel_count.;
170 unsigned *channel_indexcxx . . $ dither#channel_index.;
171 unsigned *subchannel_countcxx . . $ dither#subchannel_count.;
172
173 stpi_ditherfunc_tcxx . . $ stpi_ditherfunc_t# *ditherfunccxx . . $ dither#ditherfunc.;
174 void *aux_datacxx . . $ dither#aux_data.;
175 void (*aux_freefunccxx . . $ dither#aux_freefunc.)(struct dithercxx . . $ dither# *);
176 } stpi_dither_tcxx . . $ stpi_dither_t#;
177
178 #define CHANNELcxx . . $ `src/main/dither-impl.h:178:9`!(d, c) ((d)->channel[(c)])
179 #define CHANNEL_COUNTcxx . . $ `src/main/dither-impl.h:179:9`!(d) ((d)->total_channel_count)
180
181 #define USMINcxx . . $ `src/main/dither-impl.h:181:9`!(a, b) ((a) < (b) ? (a) : (b))
182
183
184 extern stpi_ditherfunc_tcxx . . $ stpi_ditherfunc_t# stpi_dither_preditheredcxx . . $ stpi_dither_predithered(525e4b1c00087d37).;
185 extern stpi_ditherfunc_tcxx . . $ stpi_ditherfunc_t# stpi_dither_very_fastcxx . . $ stpi_dither_very_fast(525e4b1c00087d37).;
186 extern stpi_ditherfunc_tcxx . . $ stpi_ditherfunc_t# stpi_dither_orderedcxx . . $ stpi_dither_ordered(525e4b1c00087d37).;
187 extern stpi_ditherfunc_tcxx . . $ stpi_ditherfunc_t# stpi_dither_edcxx . . $ stpi_dither_ed(525e4b1c00087d37).;
188 extern stpi_ditherfunc_tcxx . . $ stpi_ditherfunc_t# stpi_dither_etcxx . . $ stpi_dither_et(525e4b1c00087d37).;
189 extern stpi_ditherfunc_tcxx . . $ stpi_ditherfunc_t# stpi_dither_utcxx . . $ stpi_dither_ut(525e4b1c00087d37).;
190
191 extern void stpi_dither_reverse_row_endscxx . . $ stpi_dither_reverse_row_ends(eba3149742ad601b).(stpi_dither_tcxx . . $ stpi_dither_t# *d);
192 extern int stpi_dither_translate_channelcxx . . $ stpi_dither_translate_channel(5ddaaec62fc0a803).(stp_vars_tcxx . . $ stp_vars_t# *v, unsigned channel,
193 unsigned subchannel);
194 extern void stpi_dither_channel_destroycxx . . $ stpi_dither_channel_destroy(ddba87c1765ba781).(stpi_dither_channel_tcxx . . $ stpi_dither_channel_t# *channel);
195 extern void stpi_dither_finalizecxx . . $ stpi_dither_finalize(1a97b8462f9f913c).(stp_vars_tcxx . . $ stp_vars_t# *v);
196 extern int *stpi_dither_get_errlinecxx . . $ stpi_dither_get_errline(9dcb8238a6bf38ad).(stpi_dither_tcxx . . $ stpi_dither_t# *d, int row, int color);
197
198
199 #define ADVANCE_UNIDIRECTIONALcxx . . $ `src/main/dither-impl.h:199:9`!(d, bit, input, width, xerror, xstep, xmod) \
200 do \
201 { \
202 bit >>= 1; \
203 if (bit == 0) \
204 { \
205 d->ptr_offset++; \
206 bit = 128; \
207 } \
208 input += xstep; \
209 if (xmod) \
210 { \
211 xerror += xmod; \
212 if (xerror >= d->dst_width) \
213 { \
214 xerror -= d->dst_width; \
215 input += (width); \
216 } \
217 } \
218 } while (0)
219
220 #define ADVANCE_REVERSEcxx . . $ `src/main/dither-impl.h:220:9`!(d, bit, input, width, xerror, xstep, xmod) \
221 do \
222 { \
223 if (bit == 128) \
224 { \
225 d->ptr_offset--; \
226 bit = 1; \
227 } \
228 else \
229 bit <<= 1; \
230 input -= xstep; \
231 if (xmod) \
232 { \
233 xerror -= xmod; \
234 if (xerror < 0) \
235 { \
236 xerror += d->dst_width; \
237 input -= (width); \
238 } \
239 } \
240 } while (0)
241
242 #define ADVANCE_BIDIRECTIONALcxx . . $ `src/main/dither-impl.h:242:9`!(d,bit,in,dir,width,xer,xstep,xmod,err,S) \
243 do \
244 { \
245 int ii; \
246 int jj; \
247 for (ii = 0; ii < width; ii++) \
248 for (jj = 0; jj < S; jj++) \
249 err[ii][jj] += dir; \
250 if (dir == 1) \
251 ADVANCE_UNIDIRECTIONALcxx . . $ `src/main/dither-impl.h:199:9`!(d, bit, in, width, xer, xstep, xmod); \
252 else \
253 ADVANCE_REVERSEcxx . . $ `src/main/dither-impl.h:220:9`!(d, bit, in, width, xer, xstep, xmod); \
254 } while (0)
255
256 #ifdef __cplusplus
257 }
258 #endif
259
260 #endif /* GUTENPRINT_INTERNAL_DITHER_IMPL_H */