3 { Original : jdapistd.c ; Copyright (C) 1994-1996, Thomas G. Lane. }
5 { This file is part of the Independent JPEG Group's software.
6 For conditions of distribution and use, see the accompanying README file.
8 This file contains application interface code for the decompression half
9 of the JPEG library. These are the "standard" API routines that are
10 used in the normal full-decompression case. They are not used by a
11 transcoding-only application. Note that if an application links in
12 jpeg_start_decompress, it will end up linking in the entire decompressor.
13 We thus must separate this file from jdapimin.c to avoid linking the
14 whole decompression library into a transcoder. }
16 interface
18 {$I imjconfig.inc}
20 uses
21 imjmorecfg,
22 imjinclude,
23 imjdeferr,
24 imjerror,
25 imjpeglib,
26 imjdmaster;
28 { Read some scanlines of data from the JPEG decompressor.
30 The return value will be the number of lines actually read.
31 This may be less than the number requested in several cases,
32 including bottom of image, data source suspension, and operating
33 modes that emit multiple scanlines at a time.
35 Note: we warn about excess calls to jpeg_read_scanlines() since
36 this likely signals an application programmer error. However,
37 an oversize buffer (max_lines > scanlines remaining) is not an error. }
39 {GLOBAL}
45 { Alternate entry point to read raw data.
46 Processes exactly one iMCU row per call, unless suspended. }
48 {GLOBAL}
53 {$ifdef D_MULTISCAN_FILES_SUPPORTED}
55 { Initialize for an output pass in buffered-image mode. }
57 {GLOBAL}
61 { Finish up after an output pass in buffered-image mode.
63 Returns FALSE if suspended. The return value need be inspected only if
64 a suspending data source is used. }
66 {GLOBAL}
71 { Decompression initialization.
72 jpeg_read_header must be completed before calling this.
74 If a multipass operating mode was selected, this will do all but the
75 last pass, and thus may take a great deal of time.
77 Returns FALSE if suspended. The return value need be inspected only if
78 a suspending data source is used. }
80 {GLOBAL}
84 implementation
86 { Forward declarations }
87 {LOCAL}
90 { Decompression initialization.
91 jpeg_read_header must be completed before calling this.
93 If a multipass operating mode was selected, this will do all but the
94 last pass, and thus may take a great deal of time.
96 Returns FALSE if suspended. The return value need be inspected only if
97 a suspending data source is used. }
99 {GLOBAL}
101 var
103 begin
105 begin
106 { First call: initialize master control, select active modules }
109 begin
110 { No more work here; expecting jpeg_start_output next }
113 exit;
118 begin
119 { If file has multiple scans, absorb them all into the coef buffer }
121 begin
122 {$ifdef D_MULTISCAN_FILES_SUPPORTED}
124 begin
126 { Call progress monitor hook if present }
129 { Absorb some more input }
132 begin
134 exit;
137 break;
138 { Advance progress counter if appropriate }
141 begin
144 begin
145 { jdmaster underestimated number of scans; ratchet up one scan }
150 {$else}
155 end
156 else
159 { Perform any dummy output passes, and set up for the final pass }
164 { Set up for an output pass, and perform any dummy pass(es) needed.
165 Common subroutine for jpeg_start_decompress and jpeg_start_output.
166 Entry: global_state := DSTATE_PRESCAN only if previously suspended.
167 Exit: If done, returns TRUE and sets global_state for proper output mode.
168 If suspended, returns FALSE and sets global_state := DSTATE_PRESCAN. }
170 {LOCAL}
172 var
174 begin
176 begin
177 { First call: do pass setup }
182 { Loop over any required dummy passes }
184 begin
185 {$ifdef QUANT_2PASS_SUPPORTED}
186 { Crank through the dummy pass }
188 begin
189 { Call progress monitor hook if present }
191 begin
196 { Process some data }
202 begin
204 exit;
207 { Finish up dummy pass, and set up for another one }
211 {$else}
215 { Ready for application to drive output pass through
216 jpeg_read_scanlines or jpeg_read_raw_data. }
219 else
225 { Read some scanlines of data from the JPEG decompressor.
227 The return value will be the number of lines actually read.
228 This may be less than the number requested in several cases,
229 including bottom of image, data source suspension, and operating
230 modes that emit multiple scanlines at a time.
232 Note: we warn about excess calls to jpeg_read_scanlines() since
233 this likely signals an application programmer error. However,
234 an oversize buffer (max_lines > scanlines remaining) is not an error. }
236 {GLOBAL}
240 var
242 begin
246 begin
249 exit;
252 { Call progress monitor hook if present }
254 begin
260 { Process some data }
268 { Alternate entry point to read raw data.
269 Processes exactly one iMCU row per call, unless suspended. }
271 {GLOBAL}
275 var
277 begin
281 begin
284 exit;
287 { Call progress monitor hook if present }
289 begin
295 { Verify that at least one iMCU row can be returned. }
300 { Decompress directly into user's buffer. }
302 begin
304 exit;
307 { OK, we processed one iMCU row. }
313 { Additional entry points for buffered-image mode. }
315 {$ifdef D_MULTISCAN_FILES_SUPPORTED}
317 { Initialize for an output pass in buffered-image mode. }
319 {GLOBAL}
322 begin
326 { Limit scan number to valid range }
333 { Perform any dummy output passes, and set up for the real pass }
338 { Finish up after an output pass in buffered-image mode.
340 Returns FALSE if suspended. The return value need be inspected only if
341 a suspending data source is used. }
343 {GLOBAL}
345 begin
348 begin
349 { Terminate this pass. }
350 { We do not require the whole pass to have been completed. }
353 end
354 else
356 begin
357 { BUFPOST := repeat call after a suspension, anything else is error }
360 { Read markers looking for SOS or EOI }
363 begin
365 begin
367 exit;