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