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