Path: blob/master/3rdparty/libjpeg-turbo/src/jcinit.c
16337 views
/*1* jcinit.c2*3* Copyright (C) 1991-1997, Thomas G. Lane.4* This file is part of the Independent JPEG Group's software.5* For conditions of distribution and use, see the accompanying README.ijg6* file.7*8* This file contains initialization logic for the JPEG compressor.9* This routine is in charge of selecting the modules to be executed and10* making an initialization call to each one.11*12* Logically, this code belongs in jcmaster.c. It's split out because13* linking this routine implies linking the entire compression library.14* For a transcoding-only application, we want to be able to use jcmaster.c15* without linking in the whole library.16*/1718#define JPEG_INTERNALS19#include "jinclude.h"20#include "jpeglib.h"212223/*24* Master selection of compression modules.25* This is done once at the start of processing an image. We determine26* which modules will be used and give them appropriate initialization calls.27*/2829GLOBAL(void)30jinit_compress_master (j_compress_ptr cinfo)31{32/* Initialize master control (includes parameter checking/processing) */33jinit_c_master_control(cinfo, FALSE /* full compression */);3435/* Preprocessing */36if (! cinfo->raw_data_in) {37jinit_color_converter(cinfo);38jinit_downsampler(cinfo);39jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);40}41/* Forward DCT */42jinit_forward_dct(cinfo);43/* Entropy encoding: either Huffman or arithmetic coding. */44if (cinfo->arith_code) {45#ifdef C_ARITH_CODING_SUPPORTED46jinit_arith_encoder(cinfo);47#else48ERREXIT(cinfo, JERR_ARITH_NOTIMPL);49#endif50} else {51if (cinfo->progressive_mode) {52#ifdef C_PROGRESSIVE_SUPPORTED53jinit_phuff_encoder(cinfo);54#else55ERREXIT(cinfo, JERR_NOT_COMPILED);56#endif57} else58jinit_huff_encoder(cinfo);59}6061/* Need a full-image coefficient buffer in any multi-pass mode. */62jinit_c_coef_controller(cinfo,63(boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding));64jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);6566jinit_marker_writer(cinfo);6768/* We can now tell the memory manager to allocate virtual arrays. */69(*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);7071/* Write the datastream header (SOI) immediately.72* Frame and scan headers are postponed till later.73* This lets application insert special markers after the SOI.74*/75(*cinfo->marker->write_file_header) (cinfo);76}777879