]> git.saurik.com Git - wxWidgets.git/blame - src/jpeg/jpegint.h
compilation fix for wxUSE_INTL == 0 (patch 646466)
[wxWidgets.git] / src / jpeg / jpegint.h
CommitLineData
e1929140
RR
1/*
2 * jpegint.h
3 *
4 * Copyright (C) 1991-1997, Thomas G. Lane.
5 * This file is part of the Independent JPEG Group's software.
6 * For conditions of distribution and use, see the accompanying README file.
7 *
8 * This file provides common declarations for the various JPEG modules.
9 * These declarations are considered internal to the JPEG library; most
10 * applications using the library shouldn't need to include this file.
11 */
12
13
14/* Declarations for both compression & decompression */
15
16typedef enum { /* Operating modes for buffer controllers */
17 JBUF_PASS_THRU, /* Plain stripwise operation */
18 /* Remaining modes require a full-image buffer to have been created */
19 JBUF_SAVE_SOURCE, /* Run source subobject only, save output */
20 JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */
21 JBUF_SAVE_AND_PASS /* Run both subobjects, save output */
22} J_BUF_MODE;
23
24/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
25#define CSTATE_START 100 /* after create_compress */
26#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */
27#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */
28#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */
29#define DSTATE_START 200 /* after create_decompress */
30#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */
31#define DSTATE_READY 202 /* found SOS, ready for start_decompress */
32#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/
33#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */
34#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */
35#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */
36#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */
37#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */
38#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */
39#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */
40
41
42/* Declarations for compression modules */
43
44/* Master control module */
45struct jpeg_comp_master {
46 JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo));
47 JMETHOD(void, pass_startup, (j_compress_ptr cinfo));
48 JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
49
50 /* State variables made visible to other modules */
51 boolean call_pass_startup; /* True if pass_startup must be called */
52 boolean is_last_pass; /* True during last pass */
53};
54
55/* Main buffer control (downsampled-data buffer) */
56struct jpeg_c_main_controller {
57 JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
58 JMETHOD(void, process_data, (j_compress_ptr cinfo,
59 JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
60 JDIMENSION in_rows_avail));
61};
62
63/* Compression preprocessing (downsampling input buffer control) */
64struct jpeg_c_prep_controller {
65 JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
66 JMETHOD(void, pre_process_data, (j_compress_ptr cinfo,
67 JSAMPARRAY input_buf,
68 JDIMENSION *in_row_ctr,
69 JDIMENSION in_rows_avail,
70 JSAMPIMAGE output_buf,
71 JDIMENSION *out_row_group_ctr,
72 JDIMENSION out_row_groups_avail));
73};
74
75/* Coefficient buffer control */
76struct jpeg_c_coef_controller {
77 JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
78 JMETHOD(boolean, compress_data, (j_compress_ptr cinfo,
79 JSAMPIMAGE input_buf));
80};
81
82/* Colorspace conversion */
83struct jpeg_color_converter {
84 JMETHOD(void, start_pass, (j_compress_ptr cinfo));
85 JMETHOD(void, color_convert, (j_compress_ptr cinfo,
86 JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
87 JDIMENSION output_row, int num_rows));
88};
89
90/* Downsampling */
91struct jpeg_downsampler {
92 JMETHOD(void, start_pass, (j_compress_ptr cinfo));
93 JMETHOD(void, downsample, (j_compress_ptr cinfo,
94 JSAMPIMAGE input_buf, JDIMENSION in_row_index,
95 JSAMPIMAGE output_buf,
96 JDIMENSION out_row_group_index));
97
98 boolean need_context_rows; /* TRUE if need rows above & below */
99};
100
101/* Forward DCT (also controls coefficient quantization) */
102struct jpeg_forward_dct {
103 JMETHOD(void, start_pass, (j_compress_ptr cinfo));
104 /* perhaps this should be an array??? */
105 JMETHOD(void, forward_DCT, (j_compress_ptr cinfo,
106 jpeg_component_info * compptr,
107 JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
108 JDIMENSION start_row, JDIMENSION start_col,
109 JDIMENSION num_blocks));
110};
111
112/* Entropy encoding */
113struct jpeg_entropy_encoder {
114 JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics));
115 JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data));
116 JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
117};
118
119/* Marker writing */
120struct jpeg_marker_writer {
121 JMETHOD(void, write_file_header, (j_compress_ptr cinfo));
122 JMETHOD(void, write_frame_header, (j_compress_ptr cinfo));
123 JMETHOD(void, write_scan_header, (j_compress_ptr cinfo));
124 JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo));
125 JMETHOD(void, write_tables_only, (j_compress_ptr cinfo));
126 /* These routines are exported to allow insertion of extra markers */
127 /* Probably only COM and APPn markers should be written this way */
128 JMETHOD(void, write_marker_header, (j_compress_ptr cinfo, int marker,
129 unsigned int datalen));
130 JMETHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val));
131};
132
133
134/* Declarations for decompression modules */
135
136/* Master control module */
137struct jpeg_decomp_master {
138 JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo));
139 JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo));
140
141 /* State variables made visible to other modules */
142 boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */
143};
144
7bfbbc0e
DW
145#if defined(__VISAGECPP__)
146/* Visual Age fixups for multiple declarations */
147# define start_input_pass start_input_pass2 /* already in jcmaint.c */
148#endif
149
e1929140
RR
150/* Input control module */
151struct jpeg_input_controller {
152 JMETHOD(int, consume_input, (j_decompress_ptr cinfo));
153 JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo));
154 JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));
155 JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo));
156
157 /* State variables made visible to other modules */
158 boolean has_multiple_scans; /* True if file has multiple scans */
159 boolean eoi_reached; /* True when EOI has been consumed */
160};
161
7bfbbc0e
DW
162#if defined(__VISAGECPP__)
163# ifdef start_input_pass2
164# undef start_input_pass2
165# endif
166#endif
167
e1929140
RR
168/* Main buffer control (downsampled-data buffer) */
169struct jpeg_d_main_controller {
170 JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
171 JMETHOD(void, process_data, (j_decompress_ptr cinfo,
172 JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
173 JDIMENSION out_rows_avail));
174};
175
176/* Coefficient buffer control */
177struct jpeg_d_coef_controller {
2b5f62a0
VZ
178#if defined(__VISAGECPP__)
179 /* the start input pass in jdcoeft must have a different name than the
180 // one in jdtrans under VisualAge or else we get a dup symbol error
181 */
182 JMETHOD(void, start_input_pass2, (j_decompress_ptr cinfo));
183#else
e1929140 184 JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));
2b5f62a0
VZ
185#endif
186
e1929140
RR
187 JMETHOD(int, consume_data, (j_decompress_ptr cinfo));
188 JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo));
189 JMETHOD(int, decompress_data, (j_decompress_ptr cinfo,
190 JSAMPIMAGE output_buf));
191 /* Pointer to array of coefficient virtual arrays, or NULL if none */
192 jvirt_barray_ptr *coef_arrays;
193};
194
195/* Decompression postprocessing (color quantization buffer control) */
196struct jpeg_d_post_controller {
197 JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
198 JMETHOD(void, post_process_data, (j_decompress_ptr cinfo,
199 JSAMPIMAGE input_buf,
200 JDIMENSION *in_row_group_ctr,
201 JDIMENSION in_row_groups_avail,
202 JSAMPARRAY output_buf,
203 JDIMENSION *out_row_ctr,
204 JDIMENSION out_rows_avail));
205};
206
207/* Marker reading & parsing */
208struct jpeg_marker_reader {
209 JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo));
210 /* Read markers until SOS or EOI.
211 * Returns same codes as are defined for jpeg_consume_input:
212 * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
213 */
214 JMETHOD(int, read_markers, (j_decompress_ptr cinfo));
215 /* Read a restart marker --- exported for use by entropy decoder only */
216 jpeg_marker_parser_method read_restart_marker;
217
218 /* State of marker reader --- nominally internal, but applications
219 * supplying COM or APPn handlers might like to know the state.
220 */
221 boolean saw_SOI; /* found SOI? */
222 boolean saw_SOF; /* found SOF? */
223 int next_restart_num; /* next restart number expected (0-7) */
224 unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */
225};
226
227/* Entropy decoding */
228struct jpeg_entropy_decoder {
229 JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
230 JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo,
231 JBLOCKROW *MCU_data));
232
233 /* This is here to share code between baseline and progressive decoders; */
234 /* other modules probably should not use it */
235 boolean insufficient_data; /* set TRUE after emitting warning */
236};
237
238/* Inverse DCT (also performs dequantization) */
239typedef JMETHOD(void, inverse_DCT_method_ptr,
240 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
241 JCOEFPTR coef_block,
242 JSAMPARRAY output_buf, JDIMENSION output_col));
243
244struct jpeg_inverse_dct {
245 JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
246 /* It is useful to allow each component to have a separate IDCT method. */
247 inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];
248};
249
250/* Upsampling (note that upsampler must also call color converter) */
251struct jpeg_upsampler {
252 JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
253 JMETHOD(void, upsample, (j_decompress_ptr cinfo,
254 JSAMPIMAGE input_buf,
255 JDIMENSION *in_row_group_ctr,
256 JDIMENSION in_row_groups_avail,
257 JSAMPARRAY output_buf,
258 JDIMENSION *out_row_ctr,
259 JDIMENSION out_rows_avail));
260
261 boolean need_context_rows; /* TRUE if need rows above & below */
262};
263
264/* Colorspace conversion */
265struct jpeg_color_deconverter {
266 JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
267 JMETHOD(void, color_convert, (j_decompress_ptr cinfo,
268 JSAMPIMAGE input_buf, JDIMENSION input_row,
269 JSAMPARRAY output_buf, int num_rows));
270};
271
272/* Color quantization or color precision reduction */
273struct jpeg_color_quantizer {
274 JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan));
275 JMETHOD(void, color_quantize, (j_decompress_ptr cinfo,
276 JSAMPARRAY input_buf, JSAMPARRAY output_buf,
277 int num_rows));
278 JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
279 JMETHOD(void, new_color_map, (j_decompress_ptr cinfo));
280};
281
282
283/* Miscellaneous useful macros */
284
285#undef MAX
286#define MAX(a,b) ((a) > (b) ? (a) : (b))
287#undef MIN
288#define MIN(a,b) ((a) < (b) ? (a) : (b))
289
290
291/* We assume that right shift corresponds to signed division by 2 with
292 * rounding towards minus infinity. This is correct for typical "arithmetic
293 * shift" instructions that shift in copies of the sign bit. But some
294 * C compilers implement >> with an unsigned shift. For these machines you
295 * must define RIGHT_SHIFT_IS_UNSIGNED.
296 * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity.
297 * It is only applied with constant shift counts. SHIFT_TEMPS must be
298 * included in the variables of any routine using RIGHT_SHIFT.
299 */
300
301#ifdef RIGHT_SHIFT_IS_UNSIGNED
39c2d6bd 302#define SHIFT_TEMPS JPEG_INT32 shift_temp;
e1929140
RR
303#define RIGHT_SHIFT(x,shft) \
304 ((shift_temp = (x)) < 0 ? \
39c2d6bd 305 (shift_temp >> (shft)) | ((~((JPEG_INT32) 0)) << (32-(shft))) : \
e1929140
RR
306 (shift_temp >> (shft)))
307#else
308#define SHIFT_TEMPS
309#define RIGHT_SHIFT(x,shft) ((x) >> (shft))
310#endif
311
312
313/* Short forms of external names for systems with brain-damaged linkers. */
314
315#ifdef NEED_SHORT_EXTERNAL_NAMES
316#define jinit_compress_master jICompress
317#define jinit_c_master_control jICMaster
318#define jinit_c_main_controller jICMainC
319#define jinit_c_prep_controller jICPrepC
320#define jinit_c_coef_controller jICCoefC
321#define jinit_color_converter jICColor
322#define jinit_downsampler jIDownsampler
323#define jinit_forward_dct jIFDCT
324#define jinit_huff_encoder jIHEncoder
325#define jinit_phuff_encoder jIPHEncoder
326#define jinit_marker_writer jIMWriter
327#define jinit_master_decompress jIDMaster
328#define jinit_d_main_controller jIDMainC
329#define jinit_d_coef_controller jIDCoefC
330#define jinit_d_post_controller jIDPostC
331#define jinit_input_controller jIInCtlr
332#define jinit_marker_reader jIMReader
333#define jinit_huff_decoder jIHDecoder
334#define jinit_phuff_decoder jIPHDecoder
335#define jinit_inverse_dct jIIDCT
336#define jinit_upsampler jIUpsampler
337#define jinit_color_deconverter jIDColor
338#define jinit_1pass_quantizer jI1Quant
339#define jinit_2pass_quantizer jI2Quant
340#define jinit_merged_upsampler jIMUpsampler
341#define jinit_memory_mgr jIMemMgr
342#define jdiv_round_up jDivRound
343#define jround_up jRound
344#define jcopy_sample_rows jCopySamples
345#define jcopy_block_row jCopyBlocks
346#define jzero_far jZeroFar
347#define jpeg_zigzag_order jZIGTable
348#define jpeg_natural_order jZAGTable
349#endif /* NEED_SHORT_EXTERNAL_NAMES */
350
351
352/* Compression module initialization routines */
353EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo));
354EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo,
355 boolean transcode_only));
356EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo,
357 boolean need_full_buffer));
358EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo,
359 boolean need_full_buffer));
360EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo,
361 boolean need_full_buffer));
362EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo));
363EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo));
364EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo));
365EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo));
366EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo));
367EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo));
368/* Decompression module initialization routines */
369EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo));
370EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo,
371 boolean need_full_buffer));
372EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo,
373 boolean need_full_buffer));
374EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo,
375 boolean need_full_buffer));
376EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo));
377EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo));
378EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo));
379EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo));
380EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo));
381EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo));
382EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo));
383EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo));
384EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo));
385EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo));
386/* Memory manager initialization */
387EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo));
388
389/* Utility routines in jutils.c */
390EXTERN(long) jdiv_round_up JPP((long a, long b));
391EXTERN(long) jround_up JPP((long a, long b));
392EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row,
393 JSAMPARRAY output_array, int dest_row,
394 int num_rows, JDIMENSION num_cols));
395EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row,
396 JDIMENSION num_blocks));
397EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero));
398/* Constant tables in jutils.c */
399#if 0 /* This table is not actually needed in v6a */
400extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
401#endif
402extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
403
404/* Suppress undefined-structure complaints if necessary. */
405
406#ifdef INCOMPLETE_TYPES_BROKEN
407#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */
408struct jvirt_sarray_control { long dummy; };
409struct jvirt_barray_control { long dummy; };
410#endif
411#endif /* INCOMPLETE_TYPES_BROKEN */