3 { Original : jcapistd.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 compression half
9 of the JPEG library. These are the "standard" API routines that are
10 used in the normal full-compression case. They are not used by a
11 transcoding-only application. Note that if an application links in
12 jpeg_start_compress, it will end up linking in the entire compressor.
13 We thus must separate this file from jcapimin.c to avoid linking the
14 whole compression library into a transcoder. }
16 interface
18 {$I imjconfig.inc}
20 uses
21 imjmorecfg,
22 imjinclude,
23 imjdeferr,
24 imjerror,
25 imjpeglib,
30 { Compression initialization.
31 Before calling this, all parameters and a data destination must be set up.
33 We require a write_all_tables parameter as a failsafe check when writing
34 multiple datastreams from the same compression object. Since prior runs
35 will have left all the tables marked sent_table=TRUE, a subsequent run
36 would emit an abbreviated stream (no tables) by default. This may be what
37 is wanted, but for safety's sake it should not be the default behavior:
38 programmers should have to make a deliberate choice to emit abbreviated
39 images. Therefore the documentation and examples should encourage people
40 to pass write_all_tables=TRUE; then it will take active thought to do the
41 wrong thing. }
43 {GLOBAL}
48 { Write some scanlines of data to the JPEG compressor.
50 The return value will be the number of lines actually written.
51 This should be less than the supplied num_lines only in case that
52 the data destination module has requested suspension of the compressor,
53 or if more than image_height scanlines are passed in.
55 Note: we warn about excess calls to jpeg_write_scanlines() since
56 this likely signals an application programmer error. However,
57 excess scanlines passed in the last valid call are *silently* ignored,
58 so that the application need not adjust num_lines for end-of-image
59 when using a multiple-scanline buffer. }
61 {GLOBAL}
66 { Alternate entry point to write raw data.
67 Processes exactly one iMCU row per call, unless suspended. }
69 {GLOBAL}
74 implementation
76 { Compression initialization.
77 Before calling this, all parameters and a data destination must be set up.
79 We require a write_all_tables parameter as a failsafe check when writing
80 multiple datastreams from the same compression object. Since prior runs
81 will have left all the tables marked sent_table=TRUE, a subsequent run
82 would emit an abbreviated stream (no tables) by default. This may be what
83 is wanted, but for safety's sake it should not be the default behavior:
84 programmers should have to make a deliberate choice to emit abbreviated
85 images. Therefore the documentation and examples should encourage people
86 to pass write_all_tables=TRUE; then it will take active thought to do the
87 wrong thing. }
89 {GLOBAL}
92 begin
99 { (Re)initialize error mgr and destination modules }
102 { Perform master selection of active modules }
104 { Set up for the first pass }
106 { Ready for application to drive first pass through jpeg_write_scanlines
107 or jpeg_write_raw_data. }
112 else
117 { Write some scanlines of data to the JPEG compressor.
119 The return value will be the number of lines actually written.
120 This should be less than the supplied num_lines only in case that
121 the data destination module has requested suspension of the compressor,
122 or if more than image_height scanlines are passed in.
124 Note: we warn about excess calls to jpeg_write_scanlines() since
125 this likely signals an application programmer error. However,
126 excess scanlines passed in the last valid call are *silently* ignored,
127 so that the application need not adjust num_lines for end-of-image
128 when using a multiple-scanline buffer. }
130 {GLOBAL}
134 var
136 begin
142 { Call progress monitor hook if present }
144 begin
150 { Give master control module another chance if this is first call to
151 jpeg_write_scanlines. This lets output of the frame/scan headers be
152 delayed so that application can write COM, etc, markers between
153 jpeg_start_compress and jpeg_write_scanlines. }
157 { Ignore any extra scanlines at bottom of image. }
169 { Alternate entry point to write raw data.
170 Processes exactly one iMCU row per call, unless suspended. }
172 {GLOBAL}
176 var
178 begin
182 begin
185 exit;
188 { Call progress monitor hook if present }
190 begin
196 { Give master control module another chance if this is first call to
197 jpeg_write_raw_data. This lets output of the frame/scan headers be
198 delayed so that application can write COM, etc, markers between
199 jpeg_start_compress and jpeg_write_raw_data. }
204 { Verify that at least one iMCU row has been passed. }
209 { Directly compress the row. }
211 begin
212 { If compressor did not consume the whole row, suspend processing. }
214 exit;
217 { OK, we processed one iMCU row. }