michael@0: /* michael@0: * jcinit.c michael@0: * michael@0: * Copyright (C) 1991-1997, Thomas G. Lane. michael@0: * This file is part of the Independent JPEG Group's software. michael@0: * For conditions of distribution and use, see the accompanying README file. michael@0: * michael@0: * This file contains initialization logic for the JPEG compressor. michael@0: * This routine is in charge of selecting the modules to be executed and michael@0: * making an initialization call to each one. michael@0: * michael@0: * Logically, this code belongs in jcmaster.c. It's split out because michael@0: * linking this routine implies linking the entire compression library. michael@0: * For a transcoding-only application, we want to be able to use jcmaster.c michael@0: * without linking in the whole library. michael@0: */ michael@0: michael@0: #define JPEG_INTERNALS michael@0: #include "jinclude.h" michael@0: #include "jpeglib.h" michael@0: michael@0: michael@0: /* michael@0: * Master selection of compression modules. michael@0: * This is done once at the start of processing an image. We determine michael@0: * which modules will be used and give them appropriate initialization calls. michael@0: */ michael@0: michael@0: GLOBAL(void) michael@0: jinit_compress_master (j_compress_ptr cinfo) michael@0: { michael@0: /* Initialize master control (includes parameter checking/processing) */ michael@0: jinit_c_master_control(cinfo, FALSE /* full compression */); michael@0: michael@0: /* Preprocessing */ michael@0: if (! cinfo->raw_data_in) { michael@0: jinit_color_converter(cinfo); michael@0: jinit_downsampler(cinfo); michael@0: jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); michael@0: } michael@0: /* Forward DCT */ michael@0: jinit_forward_dct(cinfo); michael@0: /* Entropy encoding: either Huffman or arithmetic coding. */ michael@0: if (cinfo->arith_code) { michael@0: #ifdef C_ARITH_CODING_SUPPORTED michael@0: jinit_arith_encoder(cinfo); michael@0: #else michael@0: ERREXIT(cinfo, JERR_ARITH_NOTIMPL); michael@0: #endif michael@0: } else { michael@0: if (cinfo->progressive_mode) { michael@0: #ifdef C_PROGRESSIVE_SUPPORTED michael@0: jinit_phuff_encoder(cinfo); michael@0: #else michael@0: ERREXIT(cinfo, JERR_NOT_COMPILED); michael@0: #endif michael@0: } else michael@0: jinit_huff_encoder(cinfo); michael@0: } michael@0: michael@0: /* Need a full-image coefficient buffer in any multi-pass mode. */ michael@0: jinit_c_coef_controller(cinfo, michael@0: (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); michael@0: jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); michael@0: michael@0: jinit_marker_writer(cinfo); michael@0: michael@0: /* We can now tell the memory manager to allocate virtual arrays. */ michael@0: (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); michael@0: michael@0: /* Write the datastream header (SOI) immediately. michael@0: * Frame and scan headers are postponed till later. michael@0: * This lets application insert special markers after the SOI. michael@0: */ michael@0: (*cinfo->marker->write_file_header) (cinfo); michael@0: }