Back to index

plt-scheme  4.2.1
jcinit.c
Go to the documentation of this file.
00001 /*
00002  * jcinit.c
00003  *
00004  * Copyright (C) 1991-1997, Thomas G. Lane.
00005  * This file is part of the Independent JPEG Group's software.
00006  * For conditions of distribution and use, see the accompanying README file.
00007  *
00008  * This file contains initialization logic for the JPEG compressor.
00009  * This routine is in charge of selecting the modules to be executed and
00010  * making an initialization call to each one.
00011  *
00012  * Logically, this code belongs in jcmaster.c.  It's split out because
00013  * linking this routine implies linking the entire compression library.
00014  * For a transcoding-only application, we want to be able to use jcmaster.c
00015  * without linking in the whole library.
00016  */
00017 
00018 #define JPEG_INTERNALS
00019 #include "jinclude.h"
00020 #include "jpeglib.h"
00021 
00022 
00023 /*
00024  * Master selection of compression modules.
00025  * This is done once at the start of processing an image.  We determine
00026  * which modules will be used and give them appropriate initialization calls.
00027  */
00028 
00029 GLOBAL(void)
00030 jinit_compress_master (j_compress_ptr cinfo)
00031 {
00032   /* Initialize master control (includes parameter checking/processing) */
00033   jinit_c_master_control(cinfo, FALSE /* full compression */);
00034 
00035   /* Preprocessing */
00036   if (! cinfo->raw_data_in) {
00037     jinit_color_converter(cinfo);
00038     jinit_downsampler(cinfo);
00039     jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);
00040   }
00041   /* Forward DCT */
00042   jinit_forward_dct(cinfo);
00043   /* Entropy encoding: either Huffman or arithmetic coding. */
00044   if (cinfo->arith_code) {
00045     ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
00046   } else {
00047     if (cinfo->progressive_mode) {
00048 #ifdef C_PROGRESSIVE_SUPPORTED
00049       jinit_phuff_encoder(cinfo);
00050 #else
00051       ERREXIT(cinfo, JERR_NOT_COMPILED);
00052 #endif
00053     } else
00054       jinit_huff_encoder(cinfo);
00055   }
00056 
00057   /* Need a full-image coefficient buffer in any multi-pass mode. */
00058   jinit_c_coef_controller(cinfo,
00059               (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding));
00060   jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
00061 
00062   jinit_marker_writer(cinfo);
00063 
00064   /* We can now tell the memory manager to allocate virtual arrays. */
00065   (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
00066 
00067   /* Write the datastream header (SOI) immediately.
00068    * Frame and scan headers are postponed till later.
00069    * This lets application insert special markers after the SOI.
00070    */
00071   (*cinfo->marker->write_file_header) (cinfo);
00072 }