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