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