DEADSOFTWARE

hopefully no more windows
[d2df-editor.git] / src / lib / vampimg / JpegLib / imjcinit.pas
1 unit imjcinit;
3 { Original: jcinit.c ; Copyright (C) 1991-1997, Thomas G. Lane. }
5 { This file contains initialization logic for the JPEG compressor.
6 This routine is in charge of selecting the modules to be executed and
7 making an initialization call to each one.
9 Logically, this code belongs in jcmaster.c. It's split out because
10 linking this routine implies linking the entire compression library.
11 For a transcoding-only application, we want to be able to use jcmaster.c
12 without linking in the whole library. }
14 interface
16 {$I imjconfig.inc}
18 uses
19 imjinclude,
20 imjdeferr,
21 imjerror,
22 imjpeglib,
23 {$ifdef C_PROGRESSIVE_SUPPORTED}
24 imjcphuff,
25 {$endif}
26 imjchuff, imjcmaster, imjccolor, imjcsample, imjcprepct,
27 imjcdctmgr, imjccoefct, imjcmainct, imjcmarker;
29 { Master selection of compression modules.
30 This is done once at the start of processing an image. We determine
31 which modules will be used and give them appropriate initialization calls. }
33 {GLOBAL}
34 procedure jinit_compress_master (cinfo : j_compress_ptr);
36 implementation
40 { Master selection of compression modules.
41 This is done once at the start of processing an image. We determine
42 which modules will be used and give them appropriate initialization calls. }
44 {GLOBAL}
45 procedure jinit_compress_master (cinfo : j_compress_ptr);
46 begin
47 { Initialize master control (includes parameter checking/processing) }
48 jinit_c_master_control(cinfo, FALSE { full compression });
50 { Preprocessing }
51 if (not cinfo^.raw_data_in) then
52 begin
53 jinit_color_converter(cinfo);
54 jinit_downsampler(cinfo);
55 jinit_c_prep_controller(cinfo, FALSE { never need full buffer here });
56 end;
57 { Forward DCT }
58 jinit_forward_dct(cinfo);
59 { Entropy encoding: either Huffman or arithmetic coding. }
60 if (cinfo^.arith_code) then
61 begin
62 ERREXIT(j_common_ptr(cinfo), JERR_ARITH_NOTIMPL);
63 end
64 else
65 begin
66 if (cinfo^.progressive_mode) then
67 begin
68 {$ifdef C_PROGRESSIVE_SUPPORTED}
69 jinit_phuff_encoder(cinfo);
70 {$else}
71 ERREXIT(j_common_ptr(cinfo), JERR_NOT_COMPILED);
72 {$endif}
73 end
74 else
75 jinit_huff_encoder(cinfo);
76 end;
78 { Need a full-image coefficient buffer in any multi-pass mode. }
79 jinit_c_coef_controller(cinfo,
80 (cinfo^.num_scans > 1) or (cinfo^.optimize_coding));
81 jinit_c_main_controller(cinfo, FALSE { never need full buffer here });
83 jinit_marker_writer(cinfo);
85 { We can now tell the memory manager to allocate virtual arrays. }
86 cinfo^.mem^.realize_virt_arrays (j_common_ptr(cinfo));
88 { Write the datastream header (SOI) immediately.
89 Frame and scan headers are postponed till later.
90 This lets application insert special markers after the SOI. }
92 cinfo^.marker^.write_file_header (cinfo);
93 end;
95 end.