rev |
line source |
nuclear@14
|
1 /*
|
nuclear@14
|
2 * jdinput.c
|
nuclear@14
|
3 *
|
nuclear@14
|
4 * Copyright (C) 1991-1997, Thomas G. Lane.
|
nuclear@14
|
5 * This file is part of the Independent JPEG Group's software.
|
nuclear@14
|
6 * For conditions of distribution and use, see the accompanying README file.
|
nuclear@14
|
7 *
|
nuclear@14
|
8 * This file contains input control logic for the JPEG decompressor.
|
nuclear@14
|
9 * These routines are concerned with controlling the decompressor's input
|
nuclear@14
|
10 * processing (marker reading and coefficient decoding). The actual input
|
nuclear@14
|
11 * reading is done in jdmarker.c, jdhuff.c, and jdphuff.c.
|
nuclear@14
|
12 */
|
nuclear@14
|
13
|
nuclear@14
|
14 #define JPEG_INTERNALS
|
nuclear@14
|
15 #include "jinclude.h"
|
nuclear@14
|
16 #include "jpeglib.h"
|
nuclear@14
|
17
|
nuclear@14
|
18
|
nuclear@14
|
19 /* Private state */
|
nuclear@14
|
20
|
nuclear@14
|
21 typedef struct {
|
nuclear@14
|
22 struct jpeg_input_controller pub; /* public fields */
|
nuclear@14
|
23
|
nuclear@14
|
24 boolean inheaders; /* TRUE until first SOS is reached */
|
nuclear@14
|
25 } my_input_controller;
|
nuclear@14
|
26
|
nuclear@14
|
27 typedef my_input_controller * my_inputctl_ptr;
|
nuclear@14
|
28
|
nuclear@14
|
29
|
nuclear@14
|
30 /* Forward declarations */
|
nuclear@14
|
31 METHODDEF(int) consume_markers JPP((j_decompress_ptr cinfo));
|
nuclear@14
|
32
|
nuclear@14
|
33
|
nuclear@14
|
34 /*
|
nuclear@14
|
35 * Routines to calculate various quantities related to the size of the image.
|
nuclear@14
|
36 */
|
nuclear@14
|
37
|
nuclear@14
|
38 LOCAL(void)
|
nuclear@14
|
39 initial_setup (j_decompress_ptr cinfo)
|
nuclear@14
|
40 /* Called once, when first SOS marker is reached */
|
nuclear@14
|
41 {
|
nuclear@14
|
42 int ci;
|
nuclear@14
|
43 jpeg_component_info *compptr;
|
nuclear@14
|
44
|
nuclear@14
|
45 /* Make sure image isn't bigger than I can handle */
|
nuclear@14
|
46 if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION ||
|
nuclear@14
|
47 (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION)
|
nuclear@14
|
48 ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
|
nuclear@14
|
49
|
nuclear@14
|
50 /* For now, precision must match compiled-in value... */
|
nuclear@14
|
51 if (cinfo->data_precision != BITS_IN_JSAMPLE)
|
nuclear@14
|
52 ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
|
nuclear@14
|
53
|
nuclear@14
|
54 /* Check that number of components won't exceed internal array sizes */
|
nuclear@14
|
55 if (cinfo->num_components > MAX_COMPONENTS)
|
nuclear@14
|
56 ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
|
nuclear@14
|
57 MAX_COMPONENTS);
|
nuclear@14
|
58
|
nuclear@14
|
59 /* Compute maximum sampling factors; check factor validity */
|
nuclear@14
|
60 cinfo->max_h_samp_factor = 1;
|
nuclear@14
|
61 cinfo->max_v_samp_factor = 1;
|
nuclear@14
|
62 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
nuclear@14
|
63 ci++, compptr++) {
|
nuclear@14
|
64 if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR ||
|
nuclear@14
|
65 compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR)
|
nuclear@14
|
66 ERREXIT(cinfo, JERR_BAD_SAMPLING);
|
nuclear@14
|
67 cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
|
nuclear@14
|
68 compptr->h_samp_factor);
|
nuclear@14
|
69 cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,
|
nuclear@14
|
70 compptr->v_samp_factor);
|
nuclear@14
|
71 }
|
nuclear@14
|
72
|
nuclear@14
|
73 /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE.
|
nuclear@14
|
74 * In the full decompressor, this will be overridden by jdmaster.c;
|
nuclear@14
|
75 * but in the transcoder, jdmaster.c is not used, so we must do it here.
|
nuclear@14
|
76 */
|
nuclear@14
|
77 cinfo->min_DCT_scaled_size = DCTSIZE;
|
nuclear@14
|
78
|
nuclear@14
|
79 /* Compute dimensions of components */
|
nuclear@14
|
80 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
nuclear@14
|
81 ci++, compptr++) {
|
nuclear@14
|
82 compptr->DCT_scaled_size = DCTSIZE;
|
nuclear@14
|
83 /* Size in DCT blocks */
|
nuclear@14
|
84 compptr->width_in_blocks = (JDIMENSION)
|
nuclear@14
|
85 jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
|
nuclear@14
|
86 (long) (cinfo->max_h_samp_factor * DCTSIZE));
|
nuclear@14
|
87 compptr->height_in_blocks = (JDIMENSION)
|
nuclear@14
|
88 jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
|
nuclear@14
|
89 (long) (cinfo->max_v_samp_factor * DCTSIZE));
|
nuclear@14
|
90 /* downsampled_width and downsampled_height will also be overridden by
|
nuclear@14
|
91 * jdmaster.c if we are doing full decompression. The transcoder library
|
nuclear@14
|
92 * doesn't use these values, but the calling application might.
|
nuclear@14
|
93 */
|
nuclear@14
|
94 /* Size in samples */
|
nuclear@14
|
95 compptr->downsampled_width = (JDIMENSION)
|
nuclear@14
|
96 jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
|
nuclear@14
|
97 (long) cinfo->max_h_samp_factor);
|
nuclear@14
|
98 compptr->downsampled_height = (JDIMENSION)
|
nuclear@14
|
99 jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
|
nuclear@14
|
100 (long) cinfo->max_v_samp_factor);
|
nuclear@14
|
101 /* Mark component needed, until color conversion says otherwise */
|
nuclear@14
|
102 compptr->component_needed = TRUE;
|
nuclear@14
|
103 /* Mark no quantization table yet saved for component */
|
nuclear@14
|
104 compptr->quant_table = NULL;
|
nuclear@14
|
105 }
|
nuclear@14
|
106
|
nuclear@14
|
107 /* Compute number of fully interleaved MCU rows. */
|
nuclear@14
|
108 cinfo->total_iMCU_rows = (JDIMENSION)
|
nuclear@14
|
109 jdiv_round_up((long) cinfo->image_height,
|
nuclear@14
|
110 (long) (cinfo->max_v_samp_factor*DCTSIZE));
|
nuclear@14
|
111
|
nuclear@14
|
112 /* Decide whether file contains multiple scans */
|
nuclear@14
|
113 if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode)
|
nuclear@14
|
114 cinfo->inputctl->has_multiple_scans = TRUE;
|
nuclear@14
|
115 else
|
nuclear@14
|
116 cinfo->inputctl->has_multiple_scans = FALSE;
|
nuclear@14
|
117 }
|
nuclear@14
|
118
|
nuclear@14
|
119
|
nuclear@14
|
120 LOCAL(void)
|
nuclear@14
|
121 per_scan_setup (j_decompress_ptr cinfo)
|
nuclear@14
|
122 /* Do computations that are needed before processing a JPEG scan */
|
nuclear@14
|
123 /* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */
|
nuclear@14
|
124 {
|
nuclear@14
|
125 int ci, mcublks, tmp;
|
nuclear@14
|
126 jpeg_component_info *compptr;
|
nuclear@14
|
127
|
nuclear@14
|
128 if (cinfo->comps_in_scan == 1) {
|
nuclear@14
|
129
|
nuclear@14
|
130 /* Noninterleaved (single-component) scan */
|
nuclear@14
|
131 compptr = cinfo->cur_comp_info[0];
|
nuclear@14
|
132
|
nuclear@14
|
133 /* Overall image size in MCUs */
|
nuclear@14
|
134 cinfo->MCUs_per_row = compptr->width_in_blocks;
|
nuclear@14
|
135 cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
|
nuclear@14
|
136
|
nuclear@14
|
137 /* For noninterleaved scan, always one block per MCU */
|
nuclear@14
|
138 compptr->MCU_width = 1;
|
nuclear@14
|
139 compptr->MCU_height = 1;
|
nuclear@14
|
140 compptr->MCU_blocks = 1;
|
nuclear@14
|
141 compptr->MCU_sample_width = compptr->DCT_scaled_size;
|
nuclear@14
|
142 compptr->last_col_width = 1;
|
nuclear@14
|
143 /* For noninterleaved scans, it is convenient to define last_row_height
|
nuclear@14
|
144 * as the number of block rows present in the last iMCU row.
|
nuclear@14
|
145 */
|
nuclear@14
|
146 tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
nuclear@14
|
147 if (tmp == 0) tmp = compptr->v_samp_factor;
|
nuclear@14
|
148 compptr->last_row_height = tmp;
|
nuclear@14
|
149
|
nuclear@14
|
150 /* Prepare array describing MCU composition */
|
nuclear@14
|
151 cinfo->blocks_in_MCU = 1;
|
nuclear@14
|
152 cinfo->MCU_membership[0] = 0;
|
nuclear@14
|
153
|
nuclear@14
|
154 } else {
|
nuclear@14
|
155
|
nuclear@14
|
156 /* Interleaved (multi-component) scan */
|
nuclear@14
|
157 if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
|
nuclear@14
|
158 ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
|
nuclear@14
|
159 MAX_COMPS_IN_SCAN);
|
nuclear@14
|
160
|
nuclear@14
|
161 /* Overall image size in MCUs */
|
nuclear@14
|
162 cinfo->MCUs_per_row = (JDIMENSION)
|
nuclear@14
|
163 jdiv_round_up((long) cinfo->image_width,
|
nuclear@14
|
164 (long) (cinfo->max_h_samp_factor*DCTSIZE));
|
nuclear@14
|
165 cinfo->MCU_rows_in_scan = (JDIMENSION)
|
nuclear@14
|
166 jdiv_round_up((long) cinfo->image_height,
|
nuclear@14
|
167 (long) (cinfo->max_v_samp_factor*DCTSIZE));
|
nuclear@14
|
168
|
nuclear@14
|
169 cinfo->blocks_in_MCU = 0;
|
nuclear@14
|
170
|
nuclear@14
|
171 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
nuclear@14
|
172 compptr = cinfo->cur_comp_info[ci];
|
nuclear@14
|
173 /* Sampling factors give # of blocks of component in each MCU */
|
nuclear@14
|
174 compptr->MCU_width = compptr->h_samp_factor;
|
nuclear@14
|
175 compptr->MCU_height = compptr->v_samp_factor;
|
nuclear@14
|
176 compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
|
nuclear@14
|
177 compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_scaled_size;
|
nuclear@14
|
178 /* Figure number of non-dummy blocks in last MCU column & row */
|
nuclear@14
|
179 tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);
|
nuclear@14
|
180 if (tmp == 0) tmp = compptr->MCU_width;
|
nuclear@14
|
181 compptr->last_col_width = tmp;
|
nuclear@14
|
182 tmp = (int) (compptr->height_in_blocks % compptr->MCU_height);
|
nuclear@14
|
183 if (tmp == 0) tmp = compptr->MCU_height;
|
nuclear@14
|
184 compptr->last_row_height = tmp;
|
nuclear@14
|
185 /* Prepare array describing MCU composition */
|
nuclear@14
|
186 mcublks = compptr->MCU_blocks;
|
nuclear@14
|
187 if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU)
|
nuclear@14
|
188 ERREXIT(cinfo, JERR_BAD_MCU_SIZE);
|
nuclear@14
|
189 while (mcublks-- > 0) {
|
nuclear@14
|
190 cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
|
nuclear@14
|
191 }
|
nuclear@14
|
192 }
|
nuclear@14
|
193
|
nuclear@14
|
194 }
|
nuclear@14
|
195 }
|
nuclear@14
|
196
|
nuclear@14
|
197
|
nuclear@14
|
198 /*
|
nuclear@14
|
199 * Save away a copy of the Q-table referenced by each component present
|
nuclear@14
|
200 * in the current scan, unless already saved during a prior scan.
|
nuclear@14
|
201 *
|
nuclear@14
|
202 * In a multiple-scan JPEG file, the encoder could assign different components
|
nuclear@14
|
203 * the same Q-table slot number, but change table definitions between scans
|
nuclear@14
|
204 * so that each component uses a different Q-table. (The IJG encoder is not
|
nuclear@14
|
205 * currently capable of doing this, but other encoders might.) Since we want
|
nuclear@14
|
206 * to be able to dequantize all the components at the end of the file, this
|
nuclear@14
|
207 * means that we have to save away the table actually used for each component.
|
nuclear@14
|
208 * We do this by copying the table at the start of the first scan containing
|
nuclear@14
|
209 * the component.
|
nuclear@14
|
210 * The JPEG spec prohibits the encoder from changing the contents of a Q-table
|
nuclear@14
|
211 * slot between scans of a component using that slot. If the encoder does so
|
nuclear@14
|
212 * anyway, this decoder will simply use the Q-table values that were current
|
nuclear@14
|
213 * at the start of the first scan for the component.
|
nuclear@14
|
214 *
|
nuclear@14
|
215 * The decompressor output side looks only at the saved quant tables,
|
nuclear@14
|
216 * not at the current Q-table slots.
|
nuclear@14
|
217 */
|
nuclear@14
|
218
|
nuclear@14
|
219 LOCAL(void)
|
nuclear@14
|
220 latch_quant_tables (j_decompress_ptr cinfo)
|
nuclear@14
|
221 {
|
nuclear@14
|
222 int ci, qtblno;
|
nuclear@14
|
223 jpeg_component_info *compptr;
|
nuclear@14
|
224 JQUANT_TBL * qtbl;
|
nuclear@14
|
225
|
nuclear@14
|
226 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
nuclear@14
|
227 compptr = cinfo->cur_comp_info[ci];
|
nuclear@14
|
228 /* No work if we already saved Q-table for this component */
|
nuclear@14
|
229 if (compptr->quant_table != NULL)
|
nuclear@14
|
230 continue;
|
nuclear@14
|
231 /* Make sure specified quantization table is present */
|
nuclear@14
|
232 qtblno = compptr->quant_tbl_no;
|
nuclear@14
|
233 if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||
|
nuclear@14
|
234 cinfo->quant_tbl_ptrs[qtblno] == NULL)
|
nuclear@14
|
235 ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
|
nuclear@14
|
236 /* OK, save away the quantization table */
|
nuclear@14
|
237 qtbl = (JQUANT_TBL *)
|
nuclear@14
|
238 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
nuclear@14
|
239 SIZEOF(JQUANT_TBL));
|
nuclear@14
|
240 MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL));
|
nuclear@14
|
241 compptr->quant_table = qtbl;
|
nuclear@14
|
242 }
|
nuclear@14
|
243 }
|
nuclear@14
|
244
|
nuclear@14
|
245
|
nuclear@14
|
246 /*
|
nuclear@14
|
247 * Initialize the input modules to read a scan of compressed data.
|
nuclear@14
|
248 * The first call to this is done by jdmaster.c after initializing
|
nuclear@14
|
249 * the entire decompressor (during jpeg_start_decompress).
|
nuclear@14
|
250 * Subsequent calls come from consume_markers, below.
|
nuclear@14
|
251 */
|
nuclear@14
|
252
|
nuclear@14
|
253 METHODDEF(void)
|
nuclear@14
|
254 start_input_pass (j_decompress_ptr cinfo)
|
nuclear@14
|
255 {
|
nuclear@14
|
256 per_scan_setup(cinfo);
|
nuclear@14
|
257 latch_quant_tables(cinfo);
|
nuclear@14
|
258 (*cinfo->entropy->start_pass) (cinfo);
|
nuclear@14
|
259 (*cinfo->coef->start_input_pass) (cinfo);
|
nuclear@14
|
260 cinfo->inputctl->consume_input = cinfo->coef->consume_data;
|
nuclear@14
|
261 }
|
nuclear@14
|
262
|
nuclear@14
|
263
|
nuclear@14
|
264 /*
|
nuclear@14
|
265 * Finish up after inputting a compressed-data scan.
|
nuclear@14
|
266 * This is called by the coefficient controller after it's read all
|
nuclear@14
|
267 * the expected data of the scan.
|
nuclear@14
|
268 */
|
nuclear@14
|
269
|
nuclear@14
|
270 METHODDEF(void)
|
nuclear@14
|
271 finish_input_pass (j_decompress_ptr cinfo)
|
nuclear@14
|
272 {
|
nuclear@14
|
273 cinfo->inputctl->consume_input = consume_markers;
|
nuclear@14
|
274 }
|
nuclear@14
|
275
|
nuclear@14
|
276
|
nuclear@14
|
277 /*
|
nuclear@14
|
278 * Read JPEG markers before, between, or after compressed-data scans.
|
nuclear@14
|
279 * Change state as necessary when a new scan is reached.
|
nuclear@14
|
280 * Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
|
nuclear@14
|
281 *
|
nuclear@14
|
282 * The consume_input method pointer points either here or to the
|
nuclear@14
|
283 * coefficient controller's consume_data routine, depending on whether
|
nuclear@14
|
284 * we are reading a compressed data segment or inter-segment markers.
|
nuclear@14
|
285 */
|
nuclear@14
|
286
|
nuclear@14
|
287 METHODDEF(int)
|
nuclear@14
|
288 consume_markers (j_decompress_ptr cinfo)
|
nuclear@14
|
289 {
|
nuclear@14
|
290 my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl;
|
nuclear@14
|
291 int val;
|
nuclear@14
|
292
|
nuclear@14
|
293 if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */
|
nuclear@14
|
294 return JPEG_REACHED_EOI;
|
nuclear@14
|
295
|
nuclear@14
|
296 val = (*cinfo->marker->read_markers) (cinfo);
|
nuclear@14
|
297
|
nuclear@14
|
298 switch (val) {
|
nuclear@14
|
299 case JPEG_REACHED_SOS: /* Found SOS */
|
nuclear@14
|
300 if (inputctl->inheaders) { /* 1st SOS */
|
nuclear@14
|
301 initial_setup(cinfo);
|
nuclear@14
|
302 inputctl->inheaders = FALSE;
|
nuclear@14
|
303 /* Note: start_input_pass must be called by jdmaster.c
|
nuclear@14
|
304 * before any more input can be consumed. jdapimin.c is
|
nuclear@14
|
305 * responsible for enforcing this sequencing.
|
nuclear@14
|
306 */
|
nuclear@14
|
307 } else { /* 2nd or later SOS marker */
|
nuclear@14
|
308 if (! inputctl->pub.has_multiple_scans)
|
nuclear@14
|
309 ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */
|
nuclear@14
|
310 start_input_pass(cinfo);
|
nuclear@14
|
311 }
|
nuclear@14
|
312 break;
|
nuclear@14
|
313 case JPEG_REACHED_EOI: /* Found EOI */
|
nuclear@14
|
314 inputctl->pub.eoi_reached = TRUE;
|
nuclear@14
|
315 if (inputctl->inheaders) { /* Tables-only datastream, apparently */
|
nuclear@14
|
316 if (cinfo->marker->saw_SOF)
|
nuclear@14
|
317 ERREXIT(cinfo, JERR_SOF_NO_SOS);
|
nuclear@14
|
318 } else {
|
nuclear@14
|
319 /* Prevent infinite loop in coef ctlr's decompress_data routine
|
nuclear@14
|
320 * if user set output_scan_number larger than number of scans.
|
nuclear@14
|
321 */
|
nuclear@14
|
322 if (cinfo->output_scan_number > cinfo->input_scan_number)
|
nuclear@14
|
323 cinfo->output_scan_number = cinfo->input_scan_number;
|
nuclear@14
|
324 }
|
nuclear@14
|
325 break;
|
nuclear@14
|
326 case JPEG_SUSPENDED:
|
nuclear@14
|
327 break;
|
nuclear@14
|
328 }
|
nuclear@14
|
329
|
nuclear@14
|
330 return val;
|
nuclear@14
|
331 }
|
nuclear@14
|
332
|
nuclear@14
|
333
|
nuclear@14
|
334 /*
|
nuclear@14
|
335 * Reset state to begin a fresh datastream.
|
nuclear@14
|
336 */
|
nuclear@14
|
337
|
nuclear@14
|
338 METHODDEF(void)
|
nuclear@14
|
339 reset_input_controller (j_decompress_ptr cinfo)
|
nuclear@14
|
340 {
|
nuclear@14
|
341 my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl;
|
nuclear@14
|
342
|
nuclear@14
|
343 inputctl->pub.consume_input = consume_markers;
|
nuclear@14
|
344 inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */
|
nuclear@14
|
345 inputctl->pub.eoi_reached = FALSE;
|
nuclear@14
|
346 inputctl->inheaders = TRUE;
|
nuclear@14
|
347 /* Reset other modules */
|
nuclear@14
|
348 (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
|
nuclear@14
|
349 (*cinfo->marker->reset_marker_reader) (cinfo);
|
nuclear@14
|
350 /* Reset progression state -- would be cleaner if entropy decoder did this */
|
nuclear@14
|
351 cinfo->coef_bits = NULL;
|
nuclear@14
|
352 }
|
nuclear@14
|
353
|
nuclear@14
|
354
|
nuclear@14
|
355 /*
|
nuclear@14
|
356 * Initialize the input controller module.
|
nuclear@14
|
357 * This is called only once, when the decompression object is created.
|
nuclear@14
|
358 */
|
nuclear@14
|
359
|
nuclear@14
|
360 GLOBAL(void)
|
nuclear@14
|
361 jinit_input_controller (j_decompress_ptr cinfo)
|
nuclear@14
|
362 {
|
nuclear@14
|
363 my_inputctl_ptr inputctl;
|
nuclear@14
|
364
|
nuclear@14
|
365 /* Create subobject in permanent pool */
|
nuclear@14
|
366 inputctl = (my_inputctl_ptr)
|
nuclear@14
|
367 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
nuclear@14
|
368 SIZEOF(my_input_controller));
|
nuclear@14
|
369 cinfo->inputctl = (struct jpeg_input_controller *) inputctl;
|
nuclear@14
|
370 /* Initialize method pointers */
|
nuclear@14
|
371 inputctl->pub.consume_input = consume_markers;
|
nuclear@14
|
372 inputctl->pub.reset_input_controller = reset_input_controller;
|
nuclear@14
|
373 inputctl->pub.start_input_pass = start_input_pass;
|
nuclear@14
|
374 inputctl->pub.finish_input_pass = finish_input_pass;
|
nuclear@14
|
375 /* Initialize state: can't use reset_input_controller since we don't
|
nuclear@14
|
376 * want to try to reset other modules yet.
|
nuclear@14
|
377 */
|
nuclear@14
|
378 inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */
|
nuclear@14
|
379 inputctl->pub.eoi_reached = FALSE;
|
nuclear@14
|
380 inputctl->inheaders = TRUE;
|
nuclear@14
|
381 }
|