1ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#if !defined(_FX_JPEG_TURBO_) 2ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/* 3ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * jcinit.c 4ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * 5ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Copyright (C) 1991-1997, Thomas G. Lane. 6ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * This file is part of the Independent JPEG Group's software. 7ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * For conditions of distribution and use, see the accompanying README file. 8ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * 9ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * This file contains initialization logic for the JPEG compressor. 10ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * This routine is in charge of selecting the modules to be executed and 11ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * making an initialization call to each one. 12ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * 13ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Logically, this code belongs in jcmaster.c. It's split out because 14ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * linking this routine implies linking the entire compression library. 15ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * For a transcoding-only application, we want to be able to use jcmaster.c 16ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * without linking in the whole library. 17ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 18ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 19ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define JPEG_INTERNALS 20ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#include "jinclude.h" 21ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#include "jpeglib.h" 22ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 23ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 24ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/* 25ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Master selection of compression modules. 26ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * This is done once at the start of processing an image. We determine 27ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * which modules will be used and give them appropriate initialization calls. 28ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 29ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 30ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovGLOBAL(void) 31ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovjinit_compress_master (j_compress_ptr cinfo) 32ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov{ 33ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /* Initialize master control (includes parameter checking/processing) */ 34ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov jinit_c_master_control(cinfo, FALSE /* full compression */); 35ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 36ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /* Preprocessing */ 37ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov if (! cinfo->raw_data_in) { 38ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov jinit_color_converter(cinfo); 39ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov jinit_downsampler(cinfo); 40ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); 41ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov } 42ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /* Forward DCT */ 43ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov jinit_forward_dct(cinfo); 44ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /* Entropy encoding: either Huffman or arithmetic coding. */ 45ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov if (cinfo->arith_code) { 46ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov ERREXIT(cinfo, JERR_ARITH_NOTIMPL); 47ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov } else { 48ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov if (cinfo->progressive_mode) { 49ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#ifdef C_PROGRESSIVE_SUPPORTED 50ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov jinit_phuff_encoder(cinfo); 51ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#else 52ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov ERREXIT(cinfo, JERR_NOT_COMPILED); 53ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif 54ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov } else 55ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov jinit_huff_encoder(cinfo); 56ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov } 57ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 58ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /* Need a full-image coefficient buffer in any multi-pass mode. */ 59ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov jinit_c_coef_controller(cinfo, 60ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); 61ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); 62ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 63ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov jinit_marker_writer(cinfo); 64ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 65ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /* We can now tell the memory manager to allocate virtual arrays. */ 66ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); 67ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 68ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov /* Write the datastream header (SOI) immediately. 69ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Frame and scan headers are postponed till later. 70ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * This lets application insert special markers after the SOI. 71ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */ 72ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov (*cinfo->marker->write_file_header) (cinfo); 73ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} 74ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov 75ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif //_FX_JPEG_TURBO_ 76