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