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