/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
*
* Copyright (C) 1994-1998, 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 application interface code for the decompression half
* of the JPEG library. These are the "minimum" API routines that may be
* needed in either the normal full-decompression case or the
* transcoding-only case.
*
* Most of the routines intended to be called directly by an application
* are in this file or in jdapistd.c. But also see jcomapi.c for routines
* shared by compression and decompression, and jdtrans.c for the transcoding
* case.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
/*
* Initialization of a JPEG decompression object.
* The error manager must already be set up (in case memory manager fails).
*/
GLOBAL(void)
{
int i;
/* Guard against version mismatches between library and caller. */
if (version != JPEG_LIB_VERSION)
/* For debugging purposes, we zero the whole master structure.
* But the application has already set the err pointer, and may have set
* client_data, so we have to save and restore those fields.
* Note: if application hasn't set client_data, tools like Purify may
* complain here.
*/
{
}
/* Initialize a memory manager instance for this object */
/* Zero out pointers to permanent structures. */
for (i = 0; i < NUM_QUANT_TBLS; i++)
for (i = 0; i < NUM_HUFF_TBLS; i++) {
}
/* Initialize marker processor so application can override methods
* for COM, APPn markers before calling jpeg_read_header.
*/
/* And initialize the overall input controller. */
/* OK, I'm ready */
}
/*
* Destruction of a JPEG decompression object
*/
GLOBAL(void)
{
}
/*
* Abort processing of a JPEG decompression operation,
* but don't destroy the object itself.
*/
GLOBAL(void)
{
}
/*
* Set default decompression parameters.
*/
LOCAL(void)
{
/* Guess the input colorspace, and set output colorspace accordingly. */
/* (Wish JPEG committee had provided a real way to specify this...) */
/* Note application may override our guesses. */
switch (cinfo->num_components) {
case 1:
break;
case 3:
if (cinfo->saw_JFIF_marker) {
} else if (cinfo->saw_Adobe_marker) {
switch (cinfo->Adobe_transform) {
case 0:
break;
case 1:
break;
default:
break;
}
} else {
/* Saw no special markers, try to guess from the component IDs */
else {
}
}
/* Always guess RGB is proper output colorspace. */
break;
case 4:
if (cinfo->saw_Adobe_marker) {
switch (cinfo->Adobe_transform) {
case 0:
break;
case 2:
break;
default:
break;
}
} else {
/* No special markers, assume straight CMYK. */
}
break;
default:
break;
}
/* Set defaults for other decompression parameters. */
/* We set these in case application only sets quantize_colors. */
#ifdef QUANT_2PASS_SUPPORTED
#else
#endif
/* Initialize for no mode change in buffered-image mode. */
}
/*
* Decompression startup: read start of JPEG datastream to see what's there.
* Need only initialize JPEG object and supply a data source before calling.
*
* This routine will read as far as the first SOS marker (ie, actual start of
* compressed data), and will save all tables and parameters in the JPEG
* object. It will also initialize the decompression parameters to default
* values, and finally return JPEG_HEADER_OK. On return, the application may
* adjust the decompression parameters and then call jpeg_start_decompress.
* (Or, if the application only wanted to determine the image parameters,
* the data need not be decompressed. In that case, call jpeg_abort or
* jpeg_destroy to release any temporary space.)
* If an abbreviated (tables only) datastream is presented, the routine will
* return JPEG_HEADER_TABLES_ONLY upon reaching EOI. The application may then
* re-use the JPEG object to read the abbreviated image datastream(s).
* It is unnecessary (but OK) to call jpeg_abort in this case.
* The JPEG_SUSPENDED return code only occurs if the data source module
* requests suspension of the decompressor. In this case the application
* should load more source data and then re-call jpeg_read_header to resume
* processing.
* If a non-suspending data source is used and require_image is TRUE, then the
* return code need not be inspected since only JPEG_HEADER_OK is possible.
*
* This routine is now just a front end to jpeg_consume_input, with some
* extra error checking.
*/
GLOBAL(int)
{
int retcode;
switch (retcode) {
case JPEG_REACHED_SOS:
break;
case JPEG_REACHED_EOI:
if (require_image) /* Complain if application wanted an image */
/* Reset to start state; it would be safer to require the application to
* call jpeg_abort, but we can't change it now for compatibility reasons.
* A side effect is to free any temporary memory (there shouldn't be any).
*/
break;
case JPEG_SUSPENDED:
/* no work */
break;
}
return retcode;
}
/*
* Consume data in advance of what the decompressor requires.
* This can be called at any time once the decompressor object has
* been created and a data source has been set up.
*
* This routine is essentially a state machine that handles a couple
* of critical state-transition actions, namely initial setup and
* transition from header scanning to ready-for-start_decompress.
* All the actual input is done via the input controller's consume_input
* method.
*/
GLOBAL(int)
{
/* NB: every possible DSTATE value should be listed in this switch */
switch (cinfo->global_state) {
case DSTATE_START:
/* Start-of-datastream actions: reset appropriate modules */
/* Initialize application's data source module */
/*FALLTHROUGH*/
case DSTATE_INHEADER:
/* Set up default parameters based on header data */
/* Set global state: ready for start_decompress */
}
break;
case DSTATE_READY:
/* Can't advance past first SOS until start_decompress is called */
break;
case DSTATE_PRELOAD:
case DSTATE_PRESCAN:
case DSTATE_SCANNING:
case DSTATE_RAW_OK:
case DSTATE_BUFIMAGE:
case DSTATE_BUFPOST:
case DSTATE_STOPPING:
break;
default:
}
return retcode;
}
/*
* Have we finished reading the input file?
*/
{
/* Check for valid jpeg object */
}
/*
* Is there more than one scan?
*/
{
/* Only valid after jpeg_read_header completes */
}
/*
* Finish JPEG decompression.
*
* This will normally just verify the file trailer and release temp storage.
*
* Returns FALSE if suspended. The return value need be inspected only if
* a suspending data source is used.
*/
{
/* Terminate final pass of non-buffered mode */
/* Finishing after a buffered-image operation */
/* STOPPING = repeat call after a suspension, anything else is error */
}
/* Read until EOI */
return FALSE; /* Suspend, come back later */
}
/* Do final cleanup */
/* We can use jpeg_abort to release memory and reset global_state */
return TRUE;
}