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