1 #if !defined(_FX_JPEG_TURBO_)
2 /*
3 * jcinit.c
4 *
5 * Copyright (C) 1991-1997, Thomas G. Lane.
6 * This file is part of the Independent JPEG Group's software.
7 * For conditions of distribution and use, see the accompanying README file.
8 *
9 * This file contains initialization logic for the JPEG compressor.
10 * This routine is in charge of selecting the modules to be executed and
11 * making an initialization call to each one.
12 *
13 * Logically, this code belongs in jcmaster.c. It's split out because
14 * linking this routine implies linking the entire compression library.
15 * For a transcoding-only application, we want to be able to use jcmaster.c
16 * without linking in the whole library.
17 */
18
19 #define JPEG_INTERNALS
20 #include "jinclude.h"
21 #include "jpeglib.h"
22
23
24 /*
25 * Master selection of compression modules.
26 * This is done once at the start of processing an image. We determine
27 * which modules will be used and give them appropriate initialization calls.
28 */
29
30 GLOBAL(void)
jinit_compress_master(j_compress_ptr cinfo)31 jinit_compress_master (j_compress_ptr cinfo)
32 {
33 /* Initialize master control (includes parameter checking/processing) */
34 jinit_c_master_control(cinfo, FALSE /* full compression */);
35
36 /* Preprocessing */
37 if (! cinfo->raw_data_in) {
38 jinit_color_converter(cinfo);
39 jinit_downsampler(cinfo);
40 jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);
41 }
42 /* Forward DCT */
43 jinit_forward_dct(cinfo);
44 /* Entropy encoding: either Huffman or arithmetic coding. */
45 if (cinfo->arith_code) {
46 ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
47 } else {
48 if (cinfo->progressive_mode) {
49 #ifdef C_PROGRESSIVE_SUPPORTED
50 jinit_phuff_encoder(cinfo);
51 #else
52 ERREXIT(cinfo, JERR_NOT_COMPILED);
53 #endif
54 } else
55 jinit_huff_encoder(cinfo);
56 }
57
58 /* Need a full-image coefficient buffer in any multi-pass mode. */
59 jinit_c_coef_controller(cinfo,
60 (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding));
61 jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
62
63 jinit_marker_writer(cinfo);
64
65 /* We can now tell the memory manager to allocate virtual arrays. */
66 (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
67
68 /* Write the datastream header (SOI) immediately.
69 * Frame and scan headers are postponed till later.
70 * This lets application insert special markers after the SOI.
71 */
72 (*cinfo->marker->write_file_header) (cinfo);
73 }
74
75 #endif //_FX_JPEG_TURBO_
76