Path: blob/master/src/java.desktop/share/native/libjavajpeg/jcinit.c
41152 views
/*1* reserved comment block2* DO NOT REMOVE OR ALTER!3*/4/*5* jcinit.c6*7* Copyright (C) 1991-1997, Thomas G. Lane.8* This file is part of the Independent JPEG Group's software.9* For conditions of distribution and use, see the accompanying README file.10*11* This file contains initialization logic for the JPEG compressor.12* This routine is in charge of selecting the modules to be executed and13* making an initialization call to each one.14*15* Logically, this code belongs in jcmaster.c. It's split out because16* linking this routine implies linking the entire compression library.17* For a transcoding-only application, we want to be able to use jcmaster.c18* without linking in the whole library.19*/2021#define JPEG_INTERNALS22#include "jinclude.h"23#include "jpeglib.h"242526/*27* Master selection of compression modules.28* This is done once at the start of processing an image. We determine29* which modules will be used and give them appropriate initialization calls.30*/3132GLOBAL(void)33jinit_compress_master (j_compress_ptr cinfo)34{35/* Initialize master control (includes parameter checking/processing) */36jinit_c_master_control(cinfo, FALSE /* full compression */);3738/* Preprocessing */39if (! cinfo->raw_data_in) {40jinit_color_converter(cinfo);41jinit_downsampler(cinfo);42jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);43}44/* Forward DCT */45jinit_forward_dct(cinfo);46/* Entropy encoding: either Huffman or arithmetic coding. */47if (cinfo->arith_code) {48ERREXIT(cinfo, JERR_ARITH_NOTIMPL);49} else {50if (cinfo->progressive_mode) {51#ifdef C_PROGRESSIVE_SUPPORTED52jinit_phuff_encoder(cinfo);53#else54ERREXIT(cinfo, JERR_NOT_COMPILED);55#endif56} else57jinit_huff_encoder(cinfo);58}5960/* Need a full-image coefficient buffer in any multi-pass mode. */61jinit_c_coef_controller(cinfo,62(boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding));63jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);6465jinit_marker_writer(cinfo);6667/* We can now tell the memory manager to allocate virtual arrays. */68(*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);6970/* Write the datastream header (SOI) immediately.71* Frame and scan headers are postponed till later.72* This lets application insert special markers after the SOI.73*/74(*cinfo->marker->write_file_header) (cinfo);75}767778