istereo
diff libs/libjpeg/jpegint.h @ 26:862a3329a8f0
wohooo, added a shitload of code from zlib/libpng/libjpeg. When the good lord was raining shared libraries the iphone held a fucking umbrella...
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Thu, 08 Sep 2011 06:28:38 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/libjpeg/jpegint.h Thu Sep 08 06:28:38 2011 +0300 1.3 @@ -0,0 +1,392 @@ 1.4 +/* 1.5 + * jpegint.h 1.6 + * 1.7 + * Copyright (C) 1991-1997, Thomas G. Lane. 1.8 + * This file is part of the Independent JPEG Group's software. 1.9 + * For conditions of distribution and use, see the accompanying README file. 1.10 + * 1.11 + * This file provides common declarations for the various JPEG modules. 1.12 + * These declarations are considered internal to the JPEG library; most 1.13 + * applications using the library shouldn't need to include this file. 1.14 + */ 1.15 + 1.16 + 1.17 +/* Declarations for both compression & decompression */ 1.18 + 1.19 +typedef enum { /* Operating modes for buffer controllers */ 1.20 + JBUF_PASS_THRU, /* Plain stripwise operation */ 1.21 + /* Remaining modes require a full-image buffer to have been created */ 1.22 + JBUF_SAVE_SOURCE, /* Run source subobject only, save output */ 1.23 + JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */ 1.24 + JBUF_SAVE_AND_PASS /* Run both subobjects, save output */ 1.25 +} J_BUF_MODE; 1.26 + 1.27 +/* Values of global_state field (jdapi.c has some dependencies on ordering!) */ 1.28 +#define CSTATE_START 100 /* after create_compress */ 1.29 +#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */ 1.30 +#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */ 1.31 +#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */ 1.32 +#define DSTATE_START 200 /* after create_decompress */ 1.33 +#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */ 1.34 +#define DSTATE_READY 202 /* found SOS, ready for start_decompress */ 1.35 +#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/ 1.36 +#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */ 1.37 +#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */ 1.38 +#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */ 1.39 +#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */ 1.40 +#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */ 1.41 +#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */ 1.42 +#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */ 1.43 + 1.44 + 1.45 +/* Declarations for compression modules */ 1.46 + 1.47 +/* Master control module */ 1.48 +struct jpeg_comp_master { 1.49 + JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo)); 1.50 + JMETHOD(void, pass_startup, (j_compress_ptr cinfo)); 1.51 + JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); 1.52 + 1.53 + /* State variables made visible to other modules */ 1.54 + boolean call_pass_startup; /* True if pass_startup must be called */ 1.55 + boolean is_last_pass; /* True during last pass */ 1.56 +}; 1.57 + 1.58 +/* Main buffer control (downsampled-data buffer) */ 1.59 +struct jpeg_c_main_controller { 1.60 + JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); 1.61 + JMETHOD(void, process_data, (j_compress_ptr cinfo, 1.62 + JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, 1.63 + JDIMENSION in_rows_avail)); 1.64 +}; 1.65 + 1.66 +/* Compression preprocessing (downsampling input buffer control) */ 1.67 +struct jpeg_c_prep_controller { 1.68 + JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); 1.69 + JMETHOD(void, pre_process_data, (j_compress_ptr cinfo, 1.70 + JSAMPARRAY input_buf, 1.71 + JDIMENSION *in_row_ctr, 1.72 + JDIMENSION in_rows_avail, 1.73 + JSAMPIMAGE output_buf, 1.74 + JDIMENSION *out_row_group_ctr, 1.75 + JDIMENSION out_row_groups_avail)); 1.76 +}; 1.77 + 1.78 +/* Coefficient buffer control */ 1.79 +struct jpeg_c_coef_controller { 1.80 + JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); 1.81 + JMETHOD(boolean, compress_data, (j_compress_ptr cinfo, 1.82 + JSAMPIMAGE input_buf)); 1.83 +}; 1.84 + 1.85 +/* Colorspace conversion */ 1.86 +struct jpeg_color_converter { 1.87 + JMETHOD(void, start_pass, (j_compress_ptr cinfo)); 1.88 + JMETHOD(void, color_convert, (j_compress_ptr cinfo, 1.89 + JSAMPARRAY input_buf, JSAMPIMAGE output_buf, 1.90 + JDIMENSION output_row, int num_rows)); 1.91 +}; 1.92 + 1.93 +/* Downsampling */ 1.94 +struct jpeg_downsampler { 1.95 + JMETHOD(void, start_pass, (j_compress_ptr cinfo)); 1.96 + JMETHOD(void, downsample, (j_compress_ptr cinfo, 1.97 + JSAMPIMAGE input_buf, JDIMENSION in_row_index, 1.98 + JSAMPIMAGE output_buf, 1.99 + JDIMENSION out_row_group_index)); 1.100 + 1.101 + boolean need_context_rows; /* TRUE if need rows above & below */ 1.102 +}; 1.103 + 1.104 +/* Forward DCT (also controls coefficient quantization) */ 1.105 +struct jpeg_forward_dct { 1.106 + JMETHOD(void, start_pass, (j_compress_ptr cinfo)); 1.107 + /* perhaps this should be an array??? */ 1.108 + JMETHOD(void, forward_DCT, (j_compress_ptr cinfo, 1.109 + jpeg_component_info * compptr, 1.110 + JSAMPARRAY sample_data, JBLOCKROW coef_blocks, 1.111 + JDIMENSION start_row, JDIMENSION start_col, 1.112 + JDIMENSION num_blocks)); 1.113 +}; 1.114 + 1.115 +/* Entropy encoding */ 1.116 +struct jpeg_entropy_encoder { 1.117 + JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics)); 1.118 + JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data)); 1.119 + JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); 1.120 +}; 1.121 + 1.122 +/* Marker writing */ 1.123 +struct jpeg_marker_writer { 1.124 + JMETHOD(void, write_file_header, (j_compress_ptr cinfo)); 1.125 + JMETHOD(void, write_frame_header, (j_compress_ptr cinfo)); 1.126 + JMETHOD(void, write_scan_header, (j_compress_ptr cinfo)); 1.127 + JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo)); 1.128 + JMETHOD(void, write_tables_only, (j_compress_ptr cinfo)); 1.129 + /* These routines are exported to allow insertion of extra markers */ 1.130 + /* Probably only COM and APPn markers should be written this way */ 1.131 + JMETHOD(void, write_marker_header, (j_compress_ptr cinfo, int marker, 1.132 + unsigned int datalen)); 1.133 + JMETHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val)); 1.134 +}; 1.135 + 1.136 + 1.137 +/* Declarations for decompression modules */ 1.138 + 1.139 +/* Master control module */ 1.140 +struct jpeg_decomp_master { 1.141 + JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo)); 1.142 + JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo)); 1.143 + 1.144 + /* State variables made visible to other modules */ 1.145 + boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */ 1.146 +}; 1.147 + 1.148 +/* Input control module */ 1.149 +struct jpeg_input_controller { 1.150 + JMETHOD(int, consume_input, (j_decompress_ptr cinfo)); 1.151 + JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo)); 1.152 + JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); 1.153 + JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo)); 1.154 + 1.155 + /* State variables made visible to other modules */ 1.156 + boolean has_multiple_scans; /* True if file has multiple scans */ 1.157 + boolean eoi_reached; /* True when EOI has been consumed */ 1.158 +}; 1.159 + 1.160 +/* Main buffer control (downsampled-data buffer) */ 1.161 +struct jpeg_d_main_controller { 1.162 + JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); 1.163 + JMETHOD(void, process_data, (j_decompress_ptr cinfo, 1.164 + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, 1.165 + JDIMENSION out_rows_avail)); 1.166 +}; 1.167 + 1.168 +/* Coefficient buffer control */ 1.169 +struct jpeg_d_coef_controller { 1.170 + JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); 1.171 + JMETHOD(int, consume_data, (j_decompress_ptr cinfo)); 1.172 + JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo)); 1.173 + JMETHOD(int, decompress_data, (j_decompress_ptr cinfo, 1.174 + JSAMPIMAGE output_buf)); 1.175 + /* Pointer to array of coefficient virtual arrays, or NULL if none */ 1.176 + jvirt_barray_ptr *coef_arrays; 1.177 +}; 1.178 + 1.179 +/* Decompression postprocessing (color quantization buffer control) */ 1.180 +struct jpeg_d_post_controller { 1.181 + JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); 1.182 + JMETHOD(void, post_process_data, (j_decompress_ptr cinfo, 1.183 + JSAMPIMAGE input_buf, 1.184 + JDIMENSION *in_row_group_ctr, 1.185 + JDIMENSION in_row_groups_avail, 1.186 + JSAMPARRAY output_buf, 1.187 + JDIMENSION *out_row_ctr, 1.188 + JDIMENSION out_rows_avail)); 1.189 +}; 1.190 + 1.191 +/* Marker reading & parsing */ 1.192 +struct jpeg_marker_reader { 1.193 + JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo)); 1.194 + /* Read markers until SOS or EOI. 1.195 + * Returns same codes as are defined for jpeg_consume_input: 1.196 + * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. 1.197 + */ 1.198 + JMETHOD(int, read_markers, (j_decompress_ptr cinfo)); 1.199 + /* Read a restart marker --- exported for use by entropy decoder only */ 1.200 + jpeg_marker_parser_method read_restart_marker; 1.201 + 1.202 + /* State of marker reader --- nominally internal, but applications 1.203 + * supplying COM or APPn handlers might like to know the state. 1.204 + */ 1.205 + boolean saw_SOI; /* found SOI? */ 1.206 + boolean saw_SOF; /* found SOF? */ 1.207 + int next_restart_num; /* next restart number expected (0-7) */ 1.208 + unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */ 1.209 +}; 1.210 + 1.211 +/* Entropy decoding */ 1.212 +struct jpeg_entropy_decoder { 1.213 + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); 1.214 + JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, 1.215 + JBLOCKROW *MCU_data)); 1.216 + 1.217 + /* This is here to share code between baseline and progressive decoders; */ 1.218 + /* other modules probably should not use it */ 1.219 + boolean insufficient_data; /* set TRUE after emitting warning */ 1.220 +}; 1.221 + 1.222 +/* Inverse DCT (also performs dequantization) */ 1.223 +typedef JMETHOD(void, inverse_DCT_method_ptr, 1.224 + (j_decompress_ptr cinfo, jpeg_component_info * compptr, 1.225 + JCOEFPTR coef_block, 1.226 + JSAMPARRAY output_buf, JDIMENSION output_col)); 1.227 + 1.228 +struct jpeg_inverse_dct { 1.229 + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); 1.230 + /* It is useful to allow each component to have a separate IDCT method. */ 1.231 + inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS]; 1.232 +}; 1.233 + 1.234 +/* Upsampling (note that upsampler must also call color converter) */ 1.235 +struct jpeg_upsampler { 1.236 + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); 1.237 + JMETHOD(void, upsample, (j_decompress_ptr cinfo, 1.238 + JSAMPIMAGE input_buf, 1.239 + JDIMENSION *in_row_group_ctr, 1.240 + JDIMENSION in_row_groups_avail, 1.241 + JSAMPARRAY output_buf, 1.242 + JDIMENSION *out_row_ctr, 1.243 + JDIMENSION out_rows_avail)); 1.244 + 1.245 + boolean need_context_rows; /* TRUE if need rows above & below */ 1.246 +}; 1.247 + 1.248 +/* Colorspace conversion */ 1.249 +struct jpeg_color_deconverter { 1.250 + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); 1.251 + JMETHOD(void, color_convert, (j_decompress_ptr cinfo, 1.252 + JSAMPIMAGE input_buf, JDIMENSION input_row, 1.253 + JSAMPARRAY output_buf, int num_rows)); 1.254 +}; 1.255 + 1.256 +/* Color quantization or color precision reduction */ 1.257 +struct jpeg_color_quantizer { 1.258 + JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan)); 1.259 + JMETHOD(void, color_quantize, (j_decompress_ptr cinfo, 1.260 + JSAMPARRAY input_buf, JSAMPARRAY output_buf, 1.261 + int num_rows)); 1.262 + JMETHOD(void, finish_pass, (j_decompress_ptr cinfo)); 1.263 + JMETHOD(void, new_color_map, (j_decompress_ptr cinfo)); 1.264 +}; 1.265 + 1.266 + 1.267 +/* Miscellaneous useful macros */ 1.268 + 1.269 +#undef MAX 1.270 +#define MAX(a,b) ((a) > (b) ? (a) : (b)) 1.271 +#undef MIN 1.272 +#define MIN(a,b) ((a) < (b) ? (a) : (b)) 1.273 + 1.274 + 1.275 +/* We assume that right shift corresponds to signed division by 2 with 1.276 + * rounding towards minus infinity. This is correct for typical "arithmetic 1.277 + * shift" instructions that shift in copies of the sign bit. But some 1.278 + * C compilers implement >> with an unsigned shift. For these machines you 1.279 + * must define RIGHT_SHIFT_IS_UNSIGNED. 1.280 + * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity. 1.281 + * It is only applied with constant shift counts. SHIFT_TEMPS must be 1.282 + * included in the variables of any routine using RIGHT_SHIFT. 1.283 + */ 1.284 + 1.285 +#ifdef RIGHT_SHIFT_IS_UNSIGNED 1.286 +#define SHIFT_TEMPS INT32 shift_temp; 1.287 +#define RIGHT_SHIFT(x,shft) \ 1.288 + ((shift_temp = (x)) < 0 ? \ 1.289 + (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \ 1.290 + (shift_temp >> (shft))) 1.291 +#else 1.292 +#define SHIFT_TEMPS 1.293 +#define RIGHT_SHIFT(x,shft) ((x) >> (shft)) 1.294 +#endif 1.295 + 1.296 + 1.297 +/* Short forms of external names for systems with brain-damaged linkers. */ 1.298 + 1.299 +#ifdef NEED_SHORT_EXTERNAL_NAMES 1.300 +#define jinit_compress_master jICompress 1.301 +#define jinit_c_master_control jICMaster 1.302 +#define jinit_c_main_controller jICMainC 1.303 +#define jinit_c_prep_controller jICPrepC 1.304 +#define jinit_c_coef_controller jICCoefC 1.305 +#define jinit_color_converter jICColor 1.306 +#define jinit_downsampler jIDownsampler 1.307 +#define jinit_forward_dct jIFDCT 1.308 +#define jinit_huff_encoder jIHEncoder 1.309 +#define jinit_phuff_encoder jIPHEncoder 1.310 +#define jinit_marker_writer jIMWriter 1.311 +#define jinit_master_decompress jIDMaster 1.312 +#define jinit_d_main_controller jIDMainC 1.313 +#define jinit_d_coef_controller jIDCoefC 1.314 +#define jinit_d_post_controller jIDPostC 1.315 +#define jinit_input_controller jIInCtlr 1.316 +#define jinit_marker_reader jIMReader 1.317 +#define jinit_huff_decoder jIHDecoder 1.318 +#define jinit_phuff_decoder jIPHDecoder 1.319 +#define jinit_inverse_dct jIIDCT 1.320 +#define jinit_upsampler jIUpsampler 1.321 +#define jinit_color_deconverter jIDColor 1.322 +#define jinit_1pass_quantizer jI1Quant 1.323 +#define jinit_2pass_quantizer jI2Quant 1.324 +#define jinit_merged_upsampler jIMUpsampler 1.325 +#define jinit_memory_mgr jIMemMgr 1.326 +#define jdiv_round_up jDivRound 1.327 +#define jround_up jRound 1.328 +#define jcopy_sample_rows jCopySamples 1.329 +#define jcopy_block_row jCopyBlocks 1.330 +#define jzero_far jZeroFar 1.331 +#define jpeg_zigzag_order jZIGTable 1.332 +#define jpeg_natural_order jZAGTable 1.333 +#endif /* NEED_SHORT_EXTERNAL_NAMES */ 1.334 + 1.335 + 1.336 +/* Compression module initialization routines */ 1.337 +EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo)); 1.338 +EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo, 1.339 + boolean transcode_only)); 1.340 +EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo, 1.341 + boolean need_full_buffer)); 1.342 +EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo, 1.343 + boolean need_full_buffer)); 1.344 +EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo, 1.345 + boolean need_full_buffer)); 1.346 +EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo)); 1.347 +EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo)); 1.348 +EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo)); 1.349 +EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo)); 1.350 +EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo)); 1.351 +EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo)); 1.352 +/* Decompression module initialization routines */ 1.353 +EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo)); 1.354 +EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo, 1.355 + boolean need_full_buffer)); 1.356 +EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo, 1.357 + boolean need_full_buffer)); 1.358 +EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo, 1.359 + boolean need_full_buffer)); 1.360 +EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo)); 1.361 +EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo)); 1.362 +EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo)); 1.363 +EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo)); 1.364 +EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo)); 1.365 +EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo)); 1.366 +EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo)); 1.367 +EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo)); 1.368 +EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo)); 1.369 +EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo)); 1.370 +/* Memory manager initialization */ 1.371 +EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo)); 1.372 + 1.373 +/* Utility routines in jutils.c */ 1.374 +EXTERN(long) jdiv_round_up JPP((long a, long b)); 1.375 +EXTERN(long) jround_up JPP((long a, long b)); 1.376 +EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row, 1.377 + JSAMPARRAY output_array, int dest_row, 1.378 + int num_rows, JDIMENSION num_cols)); 1.379 +EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row, 1.380 + JDIMENSION num_blocks)); 1.381 +EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero)); 1.382 +/* Constant tables in jutils.c */ 1.383 +#if 0 /* This table is not actually needed in v6a */ 1.384 +extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */ 1.385 +#endif 1.386 +extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */ 1.387 + 1.388 +/* Suppress undefined-structure complaints if necessary. */ 1.389 + 1.390 +#ifdef INCOMPLETE_TYPES_BROKEN 1.391 +#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */ 1.392 +struct jvirt_sarray_control { long dummy; }; 1.393 +struct jvirt_barray_control { long dummy; }; 1.394 +#endif 1.395 +#endif /* INCOMPLETE_TYPES_BROKEN */