/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
*
* Copyright (C) 1994-1996, 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 "standard" API routines that are
* used in the normal full-decompression case. They are not used by a
* transcoding-only application. Note that if an application links in
* jpeg_start_decompress, it will end up linking in the entire decompressor.
* We thus must separate this file from jdapimin.c to avoid linking the
* whole decompression library into a transcoder.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
/* Forward declarations */
/*
* Decompression initialization.
* jpeg_read_header must be completed before calling this.
*
* If a multipass operating mode was selected, this will do all but the
* last pass, and thus may take a great deal of time.
*
* Returns FALSE if suspended. The return value need be inspected only if
* a suspending data source is used.
*/
{
/* First call: initialize master control, select active modules */
if (cinfo->buffered_image) {
/* No more work here; expecting jpeg_start_output next */
return TRUE;
}
}
/* If file has multiple scans, absorb them all into the coef buffer */
#ifdef D_MULTISCAN_FILES_SUPPORTED
for (;;) {
int retcode;
/* Call progress monitor hook if present */
/* Absorb some more input */
if (retcode == JPEG_SUSPENDED)
return FALSE;
if (retcode == JPEG_REACHED_EOI)
break;
/* Advance progress counter if appropriate */
/* jdmaster underestimated number of scans; ratchet up one scan */
}
}
}
#else
#endif /* D_MULTISCAN_FILES_SUPPORTED */
}
/* Perform any dummy output passes, and set up for the final pass */
return output_pass_setup(cinfo);
}
/*
* Set up for an output pass, and perform any dummy pass(es) needed.
* Common subroutine for jpeg_start_decompress and jpeg_start_output.
* Entry: global_state = DSTATE_PRESCAN only if previously suspended.
* Exit: If done, returns TRUE and sets global_state for proper output mode.
* If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN.
*/
{
/* First call: do pass setup */
cinfo->output_scanline = 0;
}
/* Loop over any required dummy passes */
#ifdef QUANT_2PASS_SUPPORTED
/* Crank through the dummy pass */
/* Call progress monitor hook if present */
}
/* Process some data */
return FALSE; /* No progress made, must suspend */
}
/* Finish up dummy pass, and set up for another one */
cinfo->output_scanline = 0;
#else
#endif /* QUANT_2PASS_SUPPORTED */
}
/* Ready for application to drive output pass through
* jpeg_read_scanlines or jpeg_read_raw_data.
*/
return TRUE;
}
/*
* Read some scanlines of data from the JPEG decompressor.
*
* The return value will be the number of lines actually read.
* This may be less than the number requested in several cases,
* including bottom of image, data source suspension, and operating
* modes that emit multiple scanlines at a time.
*
* Note: we warn about excess calls to jpeg_read_scanlines() since
* this likely signals an application programmer error. However,
* an oversize buffer (max_lines > scanlines remaining) is not an error.
*/
{
return 0;
}
/* Call progress monitor hook if present */
}
/* Process some data */
row_ctr = 0;
return row_ctr;
}
/*
* Alternate entry point to read raw data.
* Processes exactly one iMCU row per call, unless suspended.
*/
{
return 0;
}
/* Call progress monitor hook if present */
}
/* Verify that at least one iMCU row can be returned. */
if (max_lines < lines_per_iMCU_row)
/* Decompress directly into user's buffer. */
return 0; /* suspension forced, can do nothing more */
/* OK, we processed one iMCU row. */
return lines_per_iMCU_row;
}
/* Additional entry points for buffered-image mode. */
#ifdef D_MULTISCAN_FILES_SUPPORTED
/*
* Initialize for an output pass in buffered-image mode.
*/
{
/* Limit scan number to valid range */
if (scan_number <= 0)
scan_number = 1;
/* Perform any dummy output passes, and set up for the real pass */
return output_pass_setup(cinfo);
}
/*
* Finish up after an output pass in buffered-image mode.
*
* Returns FALSE if suspended. The return value need be inspected only if
* a suspending data source is used.
*/
{
/* Terminate this pass. */
/* We do not require the whole pass to have been completed. */
/* BUFPOST = repeat call after a suspension, anything else is error */
}
/* Read markers looking for SOS or EOI */
return FALSE; /* Suspend, come back later */
}
return TRUE;
}
#endif /* D_MULTISCAN_FILES_SUPPORTED */