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