/*
 * jcmaster.c
 *
 * Copyright (C) 1991, 1992, Thomas G. Lane.
 * This file is part of the Independent JPEG Group's software.
 * For conditions of distribution and use, see the accompanying README file.
 *
 * This file contains the main control for the JPEG compressor.
 * The system-dependent (user interface) code should call jpeg_compress()
 * after doing appropriate setup of the compress_info_struct parameter.
 */

#include "jinclude.h"

extern void my_pipeline(compress_info_ptr cinfo);

METHODDEF void
    c_per_scan_method_selection(compress_info_ptr cinfo)
/* Central point for per-scan method selection */
{
}


LOCAL void
    c_initial_method_selection(compress_info_ptr cinfo)
/* Central point for initial method selection */
{
   /* Input image reading method selection is already done. */
   /* So is output file header formatting (both are done by user interface). */

   /* Overall control (that's me!) */
   cinfo->methods->c_per_scan_method_selection = c_per_scan_method_selection;
}


LOCAL void
    initial_setup(compress_info_ptr cinfo)
/* Do computations that are needed before initial method selection */
{

}


/*
 * This is the main entry point to the JPEG compressor.
 */


GLOBAL void
    other_decompress(compress_info_ptr cinfo)
{
   /* Init pass counts to 0 --- total_passes is adjusted in method selection */
   cinfo->total_passes = 0;
   cinfo->completed_passes = 0;

   /*
      Read the input file header: determine image size & component count.
      NOTE: the user interface must have initialized the input_init method
      pointer (eg, by calling jselrppm) before calling me. The other file
      reading methods (get_input_row etc.) were probably set at the same
      time, but could be set up by input_init itself, or by
      c_ui_method_selection.
   */
   (*cinfo->methods->input_init) (cinfo);

   /* Give UI a chance to adjust compression parameters and select */
   /* output file format based on results of input_init. */
   (*cinfo->methods->c_ui_method_selection) (cinfo);

   /* Now select methods for compression steps. */
   initial_setup(cinfo);
   c_initial_method_selection(cinfo);

   /* Initialize the output file & other modules as needed */
   (*cinfo->methods->output_init) (cinfo);

   /* And let the pipeline controller do the rest. */
   my_pipeline(cinfo);

   /* Finish output file, release working storage, etc */
   (*cinfo->methods->output_term) (cinfo);
   (*cinfo->methods->input_term) (cinfo);

   (*cinfo->emethods->free_all) ();

   /* My, that was easy, wasn't it? */
}
