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