jpegint.h (27226B)
1 /* 2 * jpegint.h 3 * 4 * This file was part of the Independent JPEG Group's software: 5 * Copyright (C) 1991-1997, Thomas G. Lane. 6 * Modified 1997-2009 by Guido Vollbeding. 7 * Lossless JPEG Modifications: 8 * Copyright (C) 1999, Ken Murchison. 9 * libjpeg-turbo Modifications: 10 * Copyright (C) 2015-2017, 2019, 2021-2022, 2024, D. R. Commander. 11 * Copyright (C) 2015, Google, Inc. 12 * Copyright (C) 2021, Alex Richardson. 13 * For conditions of distribution and use, see the accompanying README.ijg 14 * file. 15 * 16 * This file provides common declarations for the various JPEG modules. 17 * These declarations are considered internal to the JPEG library; most 18 * applications using the library shouldn't need to include this file. 19 */ 20 21 22 /* Representation of a spatial difference value. 23 * This should be a signed value of at least 16 bits; int is usually OK. 24 */ 25 26 typedef int JDIFF; 27 28 typedef JDIFF FAR *JDIFFROW; /* pointer to one row of difference values */ 29 typedef JDIFFROW *JDIFFARRAY; /* ptr to some rows (a 2-D diff array) */ 30 typedef JDIFFARRAY *JDIFFIMAGE; /* a 3-D diff array: top index is color */ 31 32 33 /* Declarations for both compression & decompression */ 34 35 typedef enum { /* Operating modes for buffer controllers */ 36 JBUF_PASS_THRU, /* Plain stripwise operation */ 37 /* Remaining modes require a full-image buffer to have been created */ 38 JBUF_SAVE_SOURCE, /* Run source subobject only, save output */ 39 JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */ 40 JBUF_SAVE_AND_PASS /* Run both subobjects, save output */ 41 } J_BUF_MODE; 42 43 /* Values of global_state field (jdapi.c has some dependencies on ordering!) */ 44 #define CSTATE_START 100 /* after create_compress */ 45 #define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */ 46 #define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */ 47 #define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */ 48 #define DSTATE_START 200 /* after create_decompress */ 49 #define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */ 50 #define DSTATE_READY 202 /* found SOS, ready for start_decompress */ 51 #define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/ 52 #define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */ 53 #define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */ 54 #define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */ 55 #define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */ 56 #define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */ 57 #define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */ 58 #define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */ 59 60 61 /* JLONG must hold at least signed 32-bit values. */ 62 typedef long JLONG; 63 64 /* JUINTPTR must hold pointer values. */ 65 #ifdef __UINTPTR_TYPE__ 66 /* 67 * __UINTPTR_TYPE__ is GNU-specific and available in GCC 4.6+ and Clang 3.0+. 68 * Fortunately, that is sufficient to support the few architectures for which 69 * sizeof(void *) != sizeof(size_t). The only other options would require C99 70 * or Clang-specific builtins. 71 */ 72 typedef __UINTPTR_TYPE__ JUINTPTR; 73 #else 74 typedef size_t JUINTPTR; 75 #endif 76 77 #define IsExtRGB(cs) \ 78 (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB)) 79 80 /* 81 * Left shift macro that handles a negative operand without causing any 82 * sanitizer warnings 83 */ 84 85 #define LEFT_SHIFT(a, b) ((JLONG)((unsigned long)(a) << (b))) 86 87 88 /* Declarations for compression modules */ 89 90 /* Master control module */ 91 struct jpeg_comp_master { 92 void (*prepare_for_pass) (j_compress_ptr cinfo); 93 void (*pass_startup) (j_compress_ptr cinfo); 94 void (*finish_pass) (j_compress_ptr cinfo); 95 96 /* State variables made visible to other modules */ 97 boolean call_pass_startup; /* True if pass_startup must be called */ 98 boolean is_last_pass; /* True during last pass */ 99 boolean lossless; /* True if lossless mode is enabled */ 100 }; 101 102 /* Main buffer control (downsampled-data buffer) */ 103 struct jpeg_c_main_controller { 104 void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode); 105 void (*process_data) (j_compress_ptr cinfo, JSAMPARRAY input_buf, 106 JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail); 107 void (*process_data_12) (j_compress_ptr cinfo, J12SAMPARRAY input_buf, 108 JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail); 109 #ifdef C_LOSSLESS_SUPPORTED 110 void (*process_data_16) (j_compress_ptr cinfo, J16SAMPARRAY input_buf, 111 JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail); 112 #endif 113 }; 114 115 /* Compression preprocessing (downsampling input buffer control) */ 116 struct jpeg_c_prep_controller { 117 void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode); 118 void (*pre_process_data) (j_compress_ptr cinfo, JSAMPARRAY input_buf, 119 JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail, 120 JSAMPIMAGE output_buf, 121 JDIMENSION *out_row_group_ctr, 122 JDIMENSION out_row_groups_avail); 123 void (*pre_process_data_12) (j_compress_ptr cinfo, J12SAMPARRAY input_buf, 124 JDIMENSION *in_row_ctr, 125 JDIMENSION in_rows_avail, 126 J12SAMPIMAGE output_buf, 127 JDIMENSION *out_row_group_ctr, 128 JDIMENSION out_row_groups_avail); 129 #ifdef C_LOSSLESS_SUPPORTED 130 void (*pre_process_data_16) (j_compress_ptr cinfo, J16SAMPARRAY input_buf, 131 JDIMENSION *in_row_ctr, 132 JDIMENSION in_rows_avail, 133 J16SAMPIMAGE output_buf, 134 JDIMENSION *out_row_group_ctr, 135 JDIMENSION out_row_groups_avail); 136 #endif 137 }; 138 139 /* Lossy mode: Coefficient buffer control 140 * Lossless mode: Difference buffer control 141 */ 142 struct jpeg_c_coef_controller { 143 void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode); 144 boolean (*compress_data) (j_compress_ptr cinfo, JSAMPIMAGE input_buf); 145 boolean (*compress_data_12) (j_compress_ptr cinfo, J12SAMPIMAGE input_buf); 146 #ifdef C_LOSSLESS_SUPPORTED 147 boolean (*compress_data_16) (j_compress_ptr cinfo, J16SAMPIMAGE input_buf); 148 #endif 149 }; 150 151 /* Colorspace conversion */ 152 struct jpeg_color_converter { 153 void (*start_pass) (j_compress_ptr cinfo); 154 void (*color_convert) (j_compress_ptr cinfo, JSAMPARRAY input_buf, 155 JSAMPIMAGE output_buf, JDIMENSION output_row, 156 int num_rows); 157 void (*color_convert_12) (j_compress_ptr cinfo, J12SAMPARRAY input_buf, 158 J12SAMPIMAGE output_buf, JDIMENSION output_row, 159 int num_rows); 160 #ifdef C_LOSSLESS_SUPPORTED 161 void (*color_convert_16) (j_compress_ptr cinfo, J16SAMPARRAY input_buf, 162 J16SAMPIMAGE output_buf, JDIMENSION output_row, 163 int num_rows); 164 #endif 165 }; 166 167 /* Downsampling */ 168 struct jpeg_downsampler { 169 void (*start_pass) (j_compress_ptr cinfo); 170 void (*downsample) (j_compress_ptr cinfo, JSAMPIMAGE input_buf, 171 JDIMENSION in_row_index, JSAMPIMAGE output_buf, 172 JDIMENSION out_row_group_index); 173 void (*downsample_12) (j_compress_ptr cinfo, J12SAMPIMAGE input_buf, 174 JDIMENSION in_row_index, J12SAMPIMAGE output_buf, 175 JDIMENSION out_row_group_index); 176 #ifdef C_LOSSLESS_SUPPORTED 177 void (*downsample_16) (j_compress_ptr cinfo, J16SAMPIMAGE input_buf, 178 JDIMENSION in_row_index, J16SAMPIMAGE output_buf, 179 JDIMENSION out_row_group_index); 180 #endif 181 182 boolean need_context_rows; /* TRUE if need rows above & below */ 183 }; 184 185 /* Lossy mode: Forward DCT (also controls coefficient quantization) 186 * Lossless mode: Prediction, sample differencing, and point transform 187 */ 188 struct jpeg_forward_dct { 189 void (*start_pass) (j_compress_ptr cinfo); 190 191 /* Lossy mode */ 192 /* perhaps this should be an array??? */ 193 void (*forward_DCT) (j_compress_ptr cinfo, jpeg_component_info *compptr, 194 JSAMPARRAY sample_data, JBLOCKROW coef_blocks, 195 JDIMENSION start_row, JDIMENSION start_col, 196 JDIMENSION num_blocks); 197 void (*forward_DCT_12) (j_compress_ptr cinfo, jpeg_component_info *compptr, 198 J12SAMPARRAY sample_data, JBLOCKROW coef_blocks, 199 JDIMENSION start_row, JDIMENSION start_col, 200 JDIMENSION num_blocks); 201 }; 202 203 /* Entropy encoding */ 204 struct jpeg_entropy_encoder { 205 void (*start_pass) (j_compress_ptr cinfo, boolean gather_statistics); 206 207 /* Lossy mode */ 208 boolean (*encode_mcu) (j_compress_ptr cinfo, JBLOCKROW *MCU_data); 209 /* Lossless mode */ 210 JDIMENSION (*encode_mcus) (j_compress_ptr cinfo, JDIFFIMAGE diff_buf, 211 JDIMENSION MCU_row_num, JDIMENSION MCU_col_num, 212 JDIMENSION nMCU); 213 214 void (*finish_pass) (j_compress_ptr cinfo); 215 }; 216 217 /* Marker writing */ 218 struct jpeg_marker_writer { 219 void (*write_file_header) (j_compress_ptr cinfo); 220 void (*write_frame_header) (j_compress_ptr cinfo); 221 void (*write_scan_header) (j_compress_ptr cinfo); 222 void (*write_file_trailer) (j_compress_ptr cinfo); 223 void (*write_tables_only) (j_compress_ptr cinfo); 224 /* These routines are exported to allow insertion of extra markers */ 225 /* Probably only COM and APPn markers should be written this way */ 226 void (*write_marker_header) (j_compress_ptr cinfo, int marker, 227 unsigned int datalen); 228 void (*write_marker_byte) (j_compress_ptr cinfo, int val); 229 }; 230 231 232 /* Declarations for decompression modules */ 233 234 /* Master control module */ 235 struct jpeg_decomp_master { 236 void (*prepare_for_output_pass) (j_decompress_ptr cinfo); 237 void (*finish_output_pass) (j_decompress_ptr cinfo); 238 239 /* State variables made visible to other modules */ 240 boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */ 241 boolean lossless; /* True if decompressing a lossless image */ 242 243 /* Partial decompression variables */ 244 JDIMENSION first_iMCU_col; 245 JDIMENSION last_iMCU_col; 246 JDIMENSION first_MCU_col[MAX_COMPONENTS]; 247 JDIMENSION last_MCU_col[MAX_COMPONENTS]; 248 boolean jinit_upsampler_no_alloc; 249 250 /* Last iMCU row that was successfully decoded */ 251 JDIMENSION last_good_iMCU_row; 252 253 /* Tail of list of saved markers */ 254 jpeg_saved_marker_ptr marker_list_end; 255 }; 256 257 /* Input control module */ 258 struct jpeg_input_controller { 259 int (*consume_input) (j_decompress_ptr cinfo); 260 void (*reset_input_controller) (j_decompress_ptr cinfo); 261 void (*start_input_pass) (j_decompress_ptr cinfo); 262 void (*finish_input_pass) (j_decompress_ptr cinfo); 263 264 /* State variables made visible to other modules */ 265 boolean has_multiple_scans; /* True if file has multiple scans */ 266 boolean eoi_reached; /* True when EOI has been consumed */ 267 }; 268 269 /* Main buffer control (downsampled-data buffer) */ 270 struct jpeg_d_main_controller { 271 void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode); 272 void (*process_data) (j_decompress_ptr cinfo, JSAMPARRAY output_buf, 273 JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail); 274 void (*process_data_12) (j_decompress_ptr cinfo, J12SAMPARRAY output_buf, 275 JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail); 276 #ifdef D_LOSSLESS_SUPPORTED 277 void (*process_data_16) (j_decompress_ptr cinfo, J16SAMPARRAY output_buf, 278 JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail); 279 #endif 280 }; 281 282 /* Lossy mode: Coefficient buffer control 283 * Lossless mode: Difference buffer control 284 */ 285 struct jpeg_d_coef_controller { 286 void (*start_input_pass) (j_decompress_ptr cinfo); 287 int (*consume_data) (j_decompress_ptr cinfo); 288 void (*start_output_pass) (j_decompress_ptr cinfo); 289 int (*decompress_data) (j_decompress_ptr cinfo, JSAMPIMAGE output_buf); 290 int (*decompress_data_12) (j_decompress_ptr cinfo, J12SAMPIMAGE output_buf); 291 #ifdef D_LOSSLESS_SUPPORTED 292 int (*decompress_data_16) (j_decompress_ptr cinfo, J16SAMPIMAGE output_buf); 293 #endif 294 295 /* These variables keep track of the current location of the input side. */ 296 /* cinfo->input_iMCU_row is also used for this. */ 297 JDIMENSION MCU_ctr; /* counts MCUs processed in current row */ 298 int MCU_vert_offset; /* counts MCU rows within iMCU row */ 299 int MCU_rows_per_iMCU_row; /* number of such rows needed */ 300 301 /* The output side's location is represented by cinfo->output_iMCU_row. */ 302 303 /* Lossy mode */ 304 /* Pointer to array of coefficient virtual arrays, or NULL if none */ 305 jvirt_barray_ptr *coef_arrays; 306 }; 307 308 /* Decompression postprocessing (color quantization buffer control) */ 309 struct jpeg_d_post_controller { 310 void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode); 311 void (*post_process_data) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf, 312 JDIMENSION *in_row_group_ctr, 313 JDIMENSION in_row_groups_avail, 314 JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, 315 JDIMENSION out_rows_avail); 316 void (*post_process_data_12) (j_decompress_ptr cinfo, J12SAMPIMAGE input_buf, 317 JDIMENSION *in_row_group_ctr, 318 JDIMENSION in_row_groups_avail, 319 J12SAMPARRAY output_buf, 320 JDIMENSION *out_row_ctr, 321 JDIMENSION out_rows_avail); 322 #ifdef D_LOSSLESS_SUPPORTED 323 void (*post_process_data_16) (j_decompress_ptr cinfo, J16SAMPIMAGE input_buf, 324 JDIMENSION *in_row_group_ctr, 325 JDIMENSION in_row_groups_avail, 326 J16SAMPARRAY output_buf, 327 JDIMENSION *out_row_ctr, 328 JDIMENSION out_rows_avail); 329 #endif 330 }; 331 332 /* Marker reading & parsing */ 333 struct jpeg_marker_reader { 334 void (*reset_marker_reader) (j_decompress_ptr cinfo); 335 /* Read markers until SOS or EOI. 336 * Returns same codes as are defined for jpeg_consume_input: 337 * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. 338 */ 339 int (*read_markers) (j_decompress_ptr cinfo); 340 /* Read a restart marker --- exported for use by entropy decoder only */ 341 jpeg_marker_parser_method read_restart_marker; 342 343 /* State of marker reader --- nominally internal, but applications 344 * supplying COM or APPn handlers might like to know the state. 345 */ 346 boolean saw_SOI; /* found SOI? */ 347 boolean saw_SOF; /* found SOF? */ 348 int next_restart_num; /* next restart number expected (0-7) */ 349 unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */ 350 }; 351 352 /* Entropy decoding */ 353 struct jpeg_entropy_decoder { 354 void (*start_pass) (j_decompress_ptr cinfo); 355 356 /* Lossy mode */ 357 boolean (*decode_mcu) (j_decompress_ptr cinfo, JBLOCKROW *MCU_data); 358 /* Lossless mode */ 359 JDIMENSION (*decode_mcus) (j_decompress_ptr cinfo, JDIFFIMAGE diff_buf, 360 JDIMENSION MCU_row_num, JDIMENSION MCU_col_num, 361 JDIMENSION nMCU); 362 boolean (*process_restart) (j_decompress_ptr cinfo); 363 364 /* This is here to share code between baseline and progressive decoders; */ 365 /* other modules probably should not use it */ 366 boolean insufficient_data; /* set TRUE after emitting warning */ 367 }; 368 369 /* Lossy mode: Inverse DCT (also performs dequantization) 370 * Lossless mode: Prediction, sample undifferencing, point transform, and 371 * sample size scaling 372 */ 373 typedef void (*inverse_DCT_method_ptr) (j_decompress_ptr cinfo, 374 jpeg_component_info *compptr, 375 JCOEFPTR coef_block, 376 JSAMPARRAY output_buf, 377 JDIMENSION output_col); 378 typedef void (*inverse_DCT_12_method_ptr) (j_decompress_ptr cinfo, 379 jpeg_component_info *compptr, 380 JCOEFPTR coef_block, 381 J12SAMPARRAY output_buf, 382 JDIMENSION output_col); 383 384 struct jpeg_inverse_dct { 385 void (*start_pass) (j_decompress_ptr cinfo); 386 387 /* Lossy mode */ 388 /* It is useful to allow each component to have a separate IDCT method. */ 389 inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS]; 390 inverse_DCT_12_method_ptr inverse_DCT_12[MAX_COMPONENTS]; 391 }; 392 393 /* Upsampling (note that upsampler must also call color converter) */ 394 struct jpeg_upsampler { 395 void (*start_pass) (j_decompress_ptr cinfo); 396 void (*upsample) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf, 397 JDIMENSION *in_row_group_ctr, 398 JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf, 399 JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail); 400 void (*upsample_12) (j_decompress_ptr cinfo, J12SAMPIMAGE input_buf, 401 JDIMENSION *in_row_group_ctr, 402 JDIMENSION in_row_groups_avail, J12SAMPARRAY output_buf, 403 JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail); 404 #ifdef D_LOSSLESS_SUPPORTED 405 void (*upsample_16) (j_decompress_ptr cinfo, J16SAMPIMAGE input_buf, 406 JDIMENSION *in_row_group_ctr, 407 JDIMENSION in_row_groups_avail, J16SAMPARRAY output_buf, 408 JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail); 409 #endif 410 411 boolean need_context_rows; /* TRUE if need rows above & below */ 412 }; 413 414 /* Colorspace conversion */ 415 struct jpeg_color_deconverter { 416 void (*start_pass) (j_decompress_ptr cinfo); 417 void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf, 418 JDIMENSION input_row, JSAMPARRAY output_buf, 419 int num_rows); 420 void (*color_convert_12) (j_decompress_ptr cinfo, J12SAMPIMAGE input_buf, 421 JDIMENSION input_row, J12SAMPARRAY output_buf, 422 int num_rows); 423 #ifdef D_LOSSLESS_SUPPORTED 424 void (*color_convert_16) (j_decompress_ptr cinfo, J16SAMPIMAGE input_buf, 425 JDIMENSION input_row, J16SAMPARRAY output_buf, 426 int num_rows); 427 #endif 428 }; 429 430 /* Color quantization or color precision reduction */ 431 struct jpeg_color_quantizer { 432 void (*start_pass) (j_decompress_ptr cinfo, boolean is_pre_scan); 433 void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf, 434 JSAMPARRAY output_buf, int num_rows); 435 void (*color_quantize_12) (j_decompress_ptr cinfo, J12SAMPARRAY input_buf, 436 J12SAMPARRAY output_buf, int num_rows); 437 void (*finish_pass) (j_decompress_ptr cinfo); 438 void (*new_color_map) (j_decompress_ptr cinfo); 439 }; 440 441 442 /* Miscellaneous useful macros */ 443 444 #undef MAX 445 #define MAX(a, b) ((a) > (b) ? (a) : (b)) 446 #undef MIN 447 #define MIN(a, b) ((a) < (b) ? (a) : (b)) 448 449 #ifdef ZERO_BUFFERS 450 #define MALLOC(size) calloc(1, size) 451 #else 452 #define MALLOC(size) malloc(size) 453 #endif 454 455 456 /* We assume that right shift corresponds to signed division by 2 with 457 * rounding towards minus infinity. This is correct for typical "arithmetic 458 * shift" instructions that shift in copies of the sign bit. But some 459 * C compilers implement >> with an unsigned shift. For these machines you 460 * must define RIGHT_SHIFT_IS_UNSIGNED. 461 * RIGHT_SHIFT provides a proper signed right shift of a JLONG quantity. 462 * It is only applied with constant shift counts. SHIFT_TEMPS must be 463 * included in the variables of any routine using RIGHT_SHIFT. 464 */ 465 466 #ifdef RIGHT_SHIFT_IS_UNSIGNED 467 #define SHIFT_TEMPS JLONG shift_temp; 468 #define RIGHT_SHIFT(x, shft) \ 469 ((shift_temp = (x)) < 0 ? \ 470 (shift_temp >> (shft)) | ((~((JLONG)0)) << (32 - (shft))) : \ 471 (shift_temp >> (shft))) 472 #else 473 #define SHIFT_TEMPS 474 #define RIGHT_SHIFT(x, shft) ((x) >> (shft)) 475 #endif 476 477 478 /* Compression module initialization routines */ 479 EXTERN(void) jinit_compress_master(j_compress_ptr cinfo); 480 EXTERN(void) jinit_c_master_control(j_compress_ptr cinfo, 481 boolean transcode_only); 482 EXTERN(void) jinit_c_main_controller(j_compress_ptr cinfo, 483 boolean need_full_buffer); 484 EXTERN(void) j12init_c_main_controller(j_compress_ptr cinfo, 485 boolean need_full_buffer); 486 EXTERN(void) jinit_c_prep_controller(j_compress_ptr cinfo, 487 boolean need_full_buffer); 488 EXTERN(void) j12init_c_prep_controller(j_compress_ptr cinfo, 489 boolean need_full_buffer); 490 EXTERN(void) jinit_c_coef_controller(j_compress_ptr cinfo, 491 boolean need_full_buffer); 492 EXTERN(void) j12init_c_coef_controller(j_compress_ptr cinfo, 493 boolean need_full_buffer); 494 EXTERN(void) jinit_color_converter(j_compress_ptr cinfo); 495 EXTERN(void) j12init_color_converter(j_compress_ptr cinfo); 496 EXTERN(void) jinit_downsampler(j_compress_ptr cinfo); 497 EXTERN(void) j12init_downsampler(j_compress_ptr cinfo); 498 EXTERN(void) jinit_forward_dct(j_compress_ptr cinfo); 499 EXTERN(void) j12init_forward_dct(j_compress_ptr cinfo); 500 EXTERN(void) jinit_huff_encoder(j_compress_ptr cinfo); 501 EXTERN(void) jinit_phuff_encoder(j_compress_ptr cinfo); 502 EXTERN(void) jinit_arith_encoder(j_compress_ptr cinfo); 503 EXTERN(void) jinit_marker_writer(j_compress_ptr cinfo); 504 #ifdef C_LOSSLESS_SUPPORTED 505 EXTERN(void) j16init_c_main_controller(j_compress_ptr cinfo, 506 boolean need_full_buffer); 507 EXTERN(void) j16init_c_prep_controller(j_compress_ptr cinfo, 508 boolean need_full_buffer); 509 EXTERN(void) j16init_color_converter(j_compress_ptr cinfo); 510 EXTERN(void) j16init_downsampler(j_compress_ptr cinfo); 511 EXTERN(void) jinit_c_diff_controller(j_compress_ptr cinfo, 512 boolean need_full_buffer); 513 EXTERN(void) j12init_c_diff_controller(j_compress_ptr cinfo, 514 boolean need_full_buffer); 515 EXTERN(void) j16init_c_diff_controller(j_compress_ptr cinfo, 516 boolean need_full_buffer); 517 EXTERN(void) jinit_lhuff_encoder(j_compress_ptr cinfo); 518 EXTERN(void) jinit_lossless_compressor(j_compress_ptr cinfo); 519 EXTERN(void) j12init_lossless_compressor(j_compress_ptr cinfo); 520 EXTERN(void) j16init_lossless_compressor(j_compress_ptr cinfo); 521 #endif 522 523 /* Decompression module initialization routines */ 524 EXTERN(void) jinit_master_decompress(j_decompress_ptr cinfo); 525 EXTERN(void) jinit_d_main_controller(j_decompress_ptr cinfo, 526 boolean need_full_buffer); 527 EXTERN(void) j12init_d_main_controller(j_decompress_ptr cinfo, 528 boolean need_full_buffer); 529 EXTERN(void) jinit_d_coef_controller(j_decompress_ptr cinfo, 530 boolean need_full_buffer); 531 EXTERN(void) j12init_d_coef_controller(j_decompress_ptr cinfo, 532 boolean need_full_buffer); 533 EXTERN(void) jinit_d_post_controller(j_decompress_ptr cinfo, 534 boolean need_full_buffer); 535 EXTERN(void) j12init_d_post_controller(j_decompress_ptr cinfo, 536 boolean need_full_buffer); 537 EXTERN(void) jinit_input_controller(j_decompress_ptr cinfo); 538 EXTERN(void) jinit_marker_reader(j_decompress_ptr cinfo); 539 EXTERN(void) jinit_huff_decoder(j_decompress_ptr cinfo); 540 EXTERN(void) jinit_phuff_decoder(j_decompress_ptr cinfo); 541 EXTERN(void) jinit_arith_decoder(j_decompress_ptr cinfo); 542 EXTERN(void) jinit_inverse_dct(j_decompress_ptr cinfo); 543 EXTERN(void) j12init_inverse_dct(j_decompress_ptr cinfo); 544 EXTERN(void) jinit_upsampler(j_decompress_ptr cinfo); 545 EXTERN(void) j12init_upsampler(j_decompress_ptr cinfo); 546 EXTERN(void) jinit_color_deconverter(j_decompress_ptr cinfo); 547 EXTERN(void) j12init_color_deconverter(j_decompress_ptr cinfo); 548 EXTERN(void) jinit_1pass_quantizer(j_decompress_ptr cinfo); 549 EXTERN(void) j12init_1pass_quantizer(j_decompress_ptr cinfo); 550 EXTERN(void) jinit_2pass_quantizer(j_decompress_ptr cinfo); 551 EXTERN(void) j12init_2pass_quantizer(j_decompress_ptr cinfo); 552 EXTERN(void) jinit_merged_upsampler(j_decompress_ptr cinfo); 553 EXTERN(void) j12init_merged_upsampler(j_decompress_ptr cinfo); 554 #ifdef D_LOSSLESS_SUPPORTED 555 EXTERN(void) j16init_d_main_controller(j_decompress_ptr cinfo, 556 boolean need_full_buffer); 557 EXTERN(void) j16init_d_post_controller(j_decompress_ptr cinfo, 558 boolean need_full_buffer); 559 EXTERN(void) j16init_upsampler(j_decompress_ptr cinfo); 560 EXTERN(void) j16init_color_deconverter(j_decompress_ptr cinfo); 561 EXTERN(void) jinit_d_diff_controller(j_decompress_ptr cinfo, 562 boolean need_full_buffer); 563 EXTERN(void) j12init_d_diff_controller(j_decompress_ptr cinfo, 564 boolean need_full_buffer); 565 EXTERN(void) j16init_d_diff_controller(j_decompress_ptr cinfo, 566 boolean need_full_buffer); 567 EXTERN(void) jinit_lhuff_decoder(j_decompress_ptr cinfo); 568 EXTERN(void) jinit_lossless_decompressor(j_decompress_ptr cinfo); 569 EXTERN(void) j12init_lossless_decompressor(j_decompress_ptr cinfo); 570 EXTERN(void) j16init_lossless_decompressor(j_decompress_ptr cinfo); 571 #endif 572 573 /* Memory manager initialization */ 574 EXTERN(void) jinit_memory_mgr(j_common_ptr cinfo); 575 576 /* Utility routines in jutils.c */ 577 EXTERN(long) jdiv_round_up(long a, long b); 578 EXTERN(long) jround_up(long a, long b); 579 EXTERN(void) jcopy_sample_rows(JSAMPARRAY input_array, int source_row, 580 JSAMPARRAY output_array, int dest_row, 581 int num_rows, JDIMENSION num_cols); 582 EXTERN(void) j12copy_sample_rows(J12SAMPARRAY input_array, int source_row, 583 J12SAMPARRAY output_array, int dest_row, 584 int num_rows, JDIMENSION num_cols); 585 #if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED) 586 EXTERN(void) j16copy_sample_rows(J16SAMPARRAY input_array, int source_row, 587 J16SAMPARRAY output_array, int dest_row, 588 int num_rows, JDIMENSION num_cols); 589 #endif 590 EXTERN(void) jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row, 591 JDIMENSION num_blocks); 592 EXTERN(void) jzero_far(void *target, size_t bytestozero); 593 /* Constant tables in jutils.c */ 594 #if 0 /* This table is not actually needed in v6a */ 595 extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */ 596 #endif 597 extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */ 598 599 /* Arithmetic coding probability estimation tables in jaricom.c */ 600 extern const JLONG jpeg_aritab[];