Coverage Report

Created: 2024-06-09 08:56

/src/libjpeg-turbo.main/jpegint.h
Line
Count
Source (jump to first uncovered line)
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, 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
0
#define CSTATE_START     100    /* after create_compress */
45
0
#define CSTATE_SCANNING  101    /* start_compress done, write_scanlines OK */
46
0
#define CSTATE_RAW_OK    102    /* start_compress done, write_raw_data OK */
47
0
#define CSTATE_WRCOEFS   103    /* jpeg_write_coefficients done */
48
1.79M
#define DSTATE_START     200    /* after create_decompress */
49
861k
#define DSTATE_INHEADER  201    /* reading header markers, no SOS yet */
50
672k
#define DSTATE_READY     202    /* found SOS, ready for start_decompress */
51
351k
#define DSTATE_PRELOAD   203    /* reading multiscan file in start_decompress*/
52
272k
#define DSTATE_PRESCAN   204    /* performing dummy pass for 2-pass quant */
53
98.3M
#define DSTATE_SCANNING  205    /* start_decompress done, read_scanlines OK */
54
0
#define DSTATE_RAW_OK    206    /* start_decompress done, read_raw_data OK */
55
0
#define DSTATE_BUFIMAGE  207    /* expecting jpeg_start_output */
56
0
#define DSTATE_BUFPOST   208    /* looking for SOS/EOI in jpeg_finish_output */
57
0
#define DSTATE_RDCOEFS   209    /* reading file in jpeg_read_coefficients */
58
125k
#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
0
  (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
545M
#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
254
/* Input control module */
255
struct jpeg_input_controller {
256
  int (*consume_input) (j_decompress_ptr cinfo);
257
  void (*reset_input_controller) (j_decompress_ptr cinfo);
258
  void (*start_input_pass) (j_decompress_ptr cinfo);
259
  void (*finish_input_pass) (j_decompress_ptr cinfo);
260
261
  /* State variables made visible to other modules */
262
  boolean has_multiple_scans;   /* True if file has multiple scans */
263
  boolean eoi_reached;          /* True when EOI has been consumed */
264
};
265
266
/* Main buffer control (downsampled-data buffer) */
267
struct jpeg_d_main_controller {
268
  void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode);
269
  void (*process_data) (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
270
                        JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
271
  void (*process_data_12) (j_decompress_ptr cinfo, J12SAMPARRAY output_buf,
272
                           JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
273
#ifdef D_LOSSLESS_SUPPORTED
274
  void (*process_data_16) (j_decompress_ptr cinfo, J16SAMPARRAY output_buf,
275
                           JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
276
#endif
277
};
278
279
/* Lossy mode: Coefficient buffer control
280
 * Lossless mode: Difference buffer control
281
 */
282
struct jpeg_d_coef_controller {
283
  void (*start_input_pass) (j_decompress_ptr cinfo);
284
  int (*consume_data) (j_decompress_ptr cinfo);
285
  void (*start_output_pass) (j_decompress_ptr cinfo);
286
  int (*decompress_data) (j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
287
  int (*decompress_data_12) (j_decompress_ptr cinfo, J12SAMPIMAGE output_buf);
288
#ifdef D_LOSSLESS_SUPPORTED
289
  int (*decompress_data_16) (j_decompress_ptr cinfo, J16SAMPIMAGE output_buf);
290
#endif
291
292
  /* These variables keep track of the current location of the input side. */
293
  /* cinfo->input_iMCU_row is also used for this. */
294
  JDIMENSION MCU_ctr;           /* counts MCUs processed in current row */
295
  int MCU_vert_offset;          /* counts MCU rows within iMCU row */
296
  int MCU_rows_per_iMCU_row;    /* number of such rows needed */
297
298
  /* The output side's location is represented by cinfo->output_iMCU_row. */
299
300
  /* Lossy mode */
301
  /* Pointer to array of coefficient virtual arrays, or NULL if none */
302
  jvirt_barray_ptr *coef_arrays;
303
};
304
305
/* Decompression postprocessing (color quantization buffer control) */
306
struct jpeg_d_post_controller {
307
  void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode);
308
  void (*post_process_data) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
309
                             JDIMENSION *in_row_group_ctr,
310
                             JDIMENSION in_row_groups_avail,
311
                             JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
312
                             JDIMENSION out_rows_avail);
313
  void (*post_process_data_12) (j_decompress_ptr cinfo, J12SAMPIMAGE input_buf,
314
                                JDIMENSION *in_row_group_ctr,
315
                                JDIMENSION in_row_groups_avail,
316
                                J12SAMPARRAY output_buf,
317
                                JDIMENSION *out_row_ctr,
318
                                JDIMENSION out_rows_avail);
319
#ifdef D_LOSSLESS_SUPPORTED
320
  void (*post_process_data_16) (j_decompress_ptr cinfo, J16SAMPIMAGE input_buf,
321
                                JDIMENSION *in_row_group_ctr,
322
                                JDIMENSION in_row_groups_avail,
323
                                J16SAMPARRAY output_buf,
324
                                JDIMENSION *out_row_ctr,
325
                                JDIMENSION out_rows_avail);
326
#endif
327
};
328
329
/* Marker reading & parsing */
330
struct jpeg_marker_reader {
331
  void (*reset_marker_reader) (j_decompress_ptr cinfo);
332
  /* Read markers until SOS or EOI.
333
   * Returns same codes as are defined for jpeg_consume_input:
334
   * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
335
   */
336
  int (*read_markers) (j_decompress_ptr cinfo);
337
  /* Read a restart marker --- exported for use by entropy decoder only */
338
  jpeg_marker_parser_method read_restart_marker;
339
340
  /* State of marker reader --- nominally internal, but applications
341
   * supplying COM or APPn handlers might like to know the state.
342
   */
343
  boolean saw_SOI;              /* found SOI? */
344
  boolean saw_SOF;              /* found SOF? */
345
  int next_restart_num;         /* next restart number expected (0-7) */
346
  unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */
347
};
348
349
/* Entropy decoding */
350
struct jpeg_entropy_decoder {
351
  void (*start_pass) (j_decompress_ptr cinfo);
352
353
  /* Lossy mode */
354
  boolean (*decode_mcu) (j_decompress_ptr cinfo, JBLOCKROW *MCU_data);
355
  /* Lossless mode */
356
  JDIMENSION (*decode_mcus) (j_decompress_ptr cinfo, JDIFFIMAGE diff_buf,
357
                             JDIMENSION MCU_row_num, JDIMENSION MCU_col_num,
358
                             JDIMENSION nMCU);
359
  boolean (*process_restart) (j_decompress_ptr cinfo);
360
361
  /* This is here to share code between baseline and progressive decoders; */
362
  /* other modules probably should not use it */
363
  boolean insufficient_data;    /* set TRUE after emitting warning */
364
};
365
366
/* Lossy mode: Inverse DCT (also performs dequantization)
367
 * Lossless mode: Prediction, sample undifferencing, point transform, and
368
 * sample size scaling
369
 */
370
typedef void (*inverse_DCT_method_ptr) (j_decompress_ptr cinfo,
371
                                        jpeg_component_info *compptr,
372
                                        JCOEFPTR coef_block,
373
                                        JSAMPARRAY output_buf,
374
                                        JDIMENSION output_col);
375
typedef void (*inverse_DCT_12_method_ptr) (j_decompress_ptr cinfo,
376
                                           jpeg_component_info *compptr,
377
                                           JCOEFPTR coef_block,
378
                                           J12SAMPARRAY output_buf,
379
                                           JDIMENSION output_col);
380
381
struct jpeg_inverse_dct {
382
  void (*start_pass) (j_decompress_ptr cinfo);
383
384
  /* Lossy mode */
385
  /* It is useful to allow each component to have a separate IDCT method. */
386
  inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];
387
  inverse_DCT_12_method_ptr inverse_DCT_12[MAX_COMPONENTS];
388
};
389
390
/* Upsampling (note that upsampler must also call color converter) */
391
struct jpeg_upsampler {
392
  void (*start_pass) (j_decompress_ptr cinfo);
393
  void (*upsample) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
394
                    JDIMENSION *in_row_group_ctr,
395
                    JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
396
                    JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
397
  void (*upsample_12) (j_decompress_ptr cinfo, J12SAMPIMAGE input_buf,
398
                       JDIMENSION *in_row_group_ctr,
399
                       JDIMENSION in_row_groups_avail, J12SAMPARRAY output_buf,
400
                       JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
401
#ifdef D_LOSSLESS_SUPPORTED
402
  void (*upsample_16) (j_decompress_ptr cinfo, J16SAMPIMAGE input_buf,
403
                       JDIMENSION *in_row_group_ctr,
404
                       JDIMENSION in_row_groups_avail, J16SAMPARRAY output_buf,
405
                       JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
406
#endif
407
408
  boolean need_context_rows;    /* TRUE if need rows above & below */
409
};
410
411
/* Colorspace conversion */
412
struct jpeg_color_deconverter {
413
  void (*start_pass) (j_decompress_ptr cinfo);
414
  void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
415
                         JDIMENSION input_row, JSAMPARRAY output_buf,
416
                         int num_rows);
417
  void (*color_convert_12) (j_decompress_ptr cinfo, J12SAMPIMAGE input_buf,
418
                            JDIMENSION input_row, J12SAMPARRAY output_buf,
419
                            int num_rows);
420
#ifdef D_LOSSLESS_SUPPORTED
421
  void (*color_convert_16) (j_decompress_ptr cinfo, J16SAMPIMAGE input_buf,
422
                            JDIMENSION input_row, J16SAMPARRAY output_buf,
423
                            int num_rows);
424
#endif
425
};
426
427
/* Color quantization or color precision reduction */
428
struct jpeg_color_quantizer {
429
  void (*start_pass) (j_decompress_ptr cinfo, boolean is_pre_scan);
430
  void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
431
                          JSAMPARRAY output_buf, int num_rows);
432
  void (*color_quantize_12) (j_decompress_ptr cinfo, J12SAMPARRAY input_buf,
433
                             J12SAMPARRAY output_buf, int num_rows);
434
  void (*finish_pass) (j_decompress_ptr cinfo);
435
  void (*new_color_map) (j_decompress_ptr cinfo);
436
};
437
438
439
/* Miscellaneous useful macros */
440
441
#undef MAX
442
19.1M
#define MAX(a, b)       ((a) > (b) ? (a) : (b))
443
#undef MIN
444
2.00M
#define MIN(a, b)       ((a) < (b) ? (a) : (b))
445
446
447
/* We assume that right shift corresponds to signed division by 2 with
448
 * rounding towards minus infinity.  This is correct for typical "arithmetic
449
 * shift" instructions that shift in copies of the sign bit.  But some
450
 * C compilers implement >> with an unsigned shift.  For these machines you
451
 * must define RIGHT_SHIFT_IS_UNSIGNED.
452
 * RIGHT_SHIFT provides a proper signed right shift of a JLONG quantity.
453
 * It is only applied with constant shift counts.  SHIFT_TEMPS must be
454
 * included in the variables of any routine using RIGHT_SHIFT.
455
 */
456
457
#ifdef RIGHT_SHIFT_IS_UNSIGNED
458
#define SHIFT_TEMPS     JLONG shift_temp;
459
#define RIGHT_SHIFT(x, shft) \
460
  ((shift_temp = (x)) < 0 ? \
461
   (shift_temp >> (shft)) | ((~((JLONG)0)) << (32 - (shft))) : \
462
   (shift_temp >> (shft)))
463
#else
464
#define SHIFT_TEMPS
465
2.88G
#define RIGHT_SHIFT(x, shft)    ((x) >> (shft))
466
#endif
467
468
469
/* Compression module initialization routines */
470
EXTERN(void) jinit_compress_master(j_compress_ptr cinfo);
471
EXTERN(void) jinit_c_master_control(j_compress_ptr cinfo,
472
                                    boolean transcode_only);
473
EXTERN(void) jinit_c_main_controller(j_compress_ptr cinfo,
474
                                     boolean need_full_buffer);
475
EXTERN(void) j12init_c_main_controller(j_compress_ptr cinfo,
476
                                       boolean need_full_buffer);
477
EXTERN(void) jinit_c_prep_controller(j_compress_ptr cinfo,
478
                                     boolean need_full_buffer);
479
EXTERN(void) j12init_c_prep_controller(j_compress_ptr cinfo,
480
                                       boolean need_full_buffer);
481
EXTERN(void) jinit_c_coef_controller(j_compress_ptr cinfo,
482
                                     boolean need_full_buffer);
483
EXTERN(void) j12init_c_coef_controller(j_compress_ptr cinfo,
484
                                       boolean need_full_buffer);
485
EXTERN(void) jinit_color_converter(j_compress_ptr cinfo);
486
EXTERN(void) j12init_color_converter(j_compress_ptr cinfo);
487
EXTERN(void) jinit_downsampler(j_compress_ptr cinfo);
488
EXTERN(void) j12init_downsampler(j_compress_ptr cinfo);
489
EXTERN(void) jinit_forward_dct(j_compress_ptr cinfo);
490
EXTERN(void) j12init_forward_dct(j_compress_ptr cinfo);
491
EXTERN(void) jinit_huff_encoder(j_compress_ptr cinfo);
492
EXTERN(void) jinit_phuff_encoder(j_compress_ptr cinfo);
493
EXTERN(void) jinit_arith_encoder(j_compress_ptr cinfo);
494
EXTERN(void) jinit_marker_writer(j_compress_ptr cinfo);
495
#ifdef C_LOSSLESS_SUPPORTED
496
EXTERN(void) j16init_c_main_controller(j_compress_ptr cinfo,
497
                                       boolean need_full_buffer);
498
EXTERN(void) j16init_c_prep_controller(j_compress_ptr cinfo,
499
                                       boolean need_full_buffer);
500
EXTERN(void) j16init_color_converter(j_compress_ptr cinfo);
501
EXTERN(void) j16init_downsampler(j_compress_ptr cinfo);
502
EXTERN(void) jinit_c_diff_controller(j_compress_ptr cinfo,
503
                                     boolean need_full_buffer);
504
EXTERN(void) j12init_c_diff_controller(j_compress_ptr cinfo,
505
                                       boolean need_full_buffer);
506
EXTERN(void) j16init_c_diff_controller(j_compress_ptr cinfo,
507
                                       boolean need_full_buffer);
508
EXTERN(void) jinit_lhuff_encoder(j_compress_ptr cinfo);
509
EXTERN(void) jinit_lossless_compressor(j_compress_ptr cinfo);
510
EXTERN(void) j12init_lossless_compressor(j_compress_ptr cinfo);
511
EXTERN(void) j16init_lossless_compressor(j_compress_ptr cinfo);
512
#endif
513
514
/* Decompression module initialization routines */
515
EXTERN(void) jinit_master_decompress(j_decompress_ptr cinfo);
516
EXTERN(void) jinit_d_main_controller(j_decompress_ptr cinfo,
517
                                     boolean need_full_buffer);
518
EXTERN(void) j12init_d_main_controller(j_decompress_ptr cinfo,
519
                                       boolean need_full_buffer);
520
EXTERN(void) jinit_d_coef_controller(j_decompress_ptr cinfo,
521
                                     boolean need_full_buffer);
522
EXTERN(void) j12init_d_coef_controller(j_decompress_ptr cinfo,
523
                                       boolean need_full_buffer);
524
EXTERN(void) jinit_d_post_controller(j_decompress_ptr cinfo,
525
                                     boolean need_full_buffer);
526
EXTERN(void) j12init_d_post_controller(j_decompress_ptr cinfo,
527
                                       boolean need_full_buffer);
528
EXTERN(void) jinit_input_controller(j_decompress_ptr cinfo);
529
EXTERN(void) jinit_marker_reader(j_decompress_ptr cinfo);
530
EXTERN(void) jinit_huff_decoder(j_decompress_ptr cinfo);
531
EXTERN(void) jinit_phuff_decoder(j_decompress_ptr cinfo);
532
EXTERN(void) jinit_arith_decoder(j_decompress_ptr cinfo);
533
EXTERN(void) jinit_inverse_dct(j_decompress_ptr cinfo);
534
EXTERN(void) j12init_inverse_dct(j_decompress_ptr cinfo);
535
EXTERN(void) jinit_upsampler(j_decompress_ptr cinfo);
536
EXTERN(void) j12init_upsampler(j_decompress_ptr cinfo);
537
EXTERN(void) jinit_color_deconverter(j_decompress_ptr cinfo);
538
EXTERN(void) j12init_color_deconverter(j_decompress_ptr cinfo);
539
EXTERN(void) jinit_1pass_quantizer(j_decompress_ptr cinfo);
540
EXTERN(void) j12init_1pass_quantizer(j_decompress_ptr cinfo);
541
EXTERN(void) jinit_2pass_quantizer(j_decompress_ptr cinfo);
542
EXTERN(void) j12init_2pass_quantizer(j_decompress_ptr cinfo);
543
EXTERN(void) jinit_merged_upsampler(j_decompress_ptr cinfo);
544
EXTERN(void) j12init_merged_upsampler(j_decompress_ptr cinfo);
545
#ifdef D_LOSSLESS_SUPPORTED
546
EXTERN(void) j16init_d_main_controller(j_decompress_ptr cinfo,
547
                                       boolean need_full_buffer);
548
EXTERN(void) j16init_d_post_controller(j_decompress_ptr cinfo,
549
                                       boolean need_full_buffer);
550
EXTERN(void) j16init_upsampler(j_decompress_ptr cinfo);
551
EXTERN(void) j16init_color_deconverter(j_decompress_ptr cinfo);
552
EXTERN(void) jinit_d_diff_controller(j_decompress_ptr cinfo,
553
                                     boolean need_full_buffer);
554
EXTERN(void) j12init_d_diff_controller(j_decompress_ptr cinfo,
555
                                       boolean need_full_buffer);
556
EXTERN(void) j16init_d_diff_controller(j_decompress_ptr cinfo,
557
                                       boolean need_full_buffer);
558
EXTERN(void) jinit_lhuff_decoder(j_decompress_ptr cinfo);
559
EXTERN(void) jinit_lossless_decompressor(j_decompress_ptr cinfo);
560
EXTERN(void) j12init_lossless_decompressor(j_decompress_ptr cinfo);
561
EXTERN(void) j16init_lossless_decompressor(j_decompress_ptr cinfo);
562
#endif
563
564
/* Memory manager initialization */
565
EXTERN(void) jinit_memory_mgr(j_common_ptr cinfo);
566
567
/* Utility routines in jutils.c */
568
EXTERN(long) jdiv_round_up(long a, long b);
569
EXTERN(long) jround_up(long a, long b);
570
EXTERN(void) jcopy_sample_rows(JSAMPARRAY input_array, int source_row,
571
                               JSAMPARRAY output_array, int dest_row,
572
                               int num_rows, JDIMENSION num_cols);
573
EXTERN(void) j12copy_sample_rows(J12SAMPARRAY input_array, int source_row,
574
                                 J12SAMPARRAY output_array, int dest_row,
575
                                 int num_rows, JDIMENSION num_cols);
576
#if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED)
577
EXTERN(void) j16copy_sample_rows(J16SAMPARRAY input_array, int source_row,
578
                                 J16SAMPARRAY output_array, int dest_row,
579
                                 int num_rows, JDIMENSION num_cols);
580
#endif
581
EXTERN(void) jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row,
582
                             JDIMENSION num_blocks);
583
EXTERN(void) jzero_far(void *target, size_t bytestozero);
584
/* Constant tables in jutils.c */
585
#if 0                           /* This table is not actually needed in v6a */
586
extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
587
#endif
588
extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
589
590
/* Arithmetic coding probability estimation tables in jaricom.c */
591
extern const JLONG jpeg_aritab[];