0N/A * reserved comment block 0N/A * DO NOT REMOVE OR ALTER! 0N/A * Copyright (C) 1991-1997, 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 input control logic for the JPEG decompressor. 0N/A * These routines are concerned with controlling the decompressor's input 0N/A * processing (marker reading and coefficient decoding). The actual input 0N/A/* Forward declarations */ 0N/A * Routines to calculate various quantities related to the size of the image. 0N/A/* Called once, when first SOS marker is reached */ 0N/A /* Make sure image isn't bigger than I can handle */ 0N/A /* For now, precision must match compiled-in value... */ 0N/A /* Check that number of components won't exceed internal array sizes */ 0N/A /* Compute maximum sampling factors; check factor validity */ 0N/A /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE. 0N/A * In the full decompressor, this will be overridden by jdmaster.c; 0N/A * but in the transcoder, jdmaster.c is not used, so we must do it here. 0N/A /* Compute dimensions of components */ 0N/A /* Size in DCT blocks */ 0N/A /* downsampled_width and downsampled_height will also be overridden by 0N/A * jdmaster.c if we are doing full decompression. The transcoder library 0N/A * doesn't use these values, but the calling application might. 0N/A /* Size in samples */ 0N/A /* Mark component needed, until color conversion says otherwise */ 0N/A /* Mark no quantization table yet saved for component */ 0N/A /* Compute number of fully interleaved MCU rows. */ 0N/A /* Decide whether file contains multiple scans */ 0N/A/* Do computations that are needed before processing a JPEG scan */ 0N/A/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */ 0N/A /* Noninterleaved (single-component) scan */ 0N/A /* Overall image size in MCUs */ 0N/A /* For noninterleaved scan, always one block per MCU */ 0N/A /* For noninterleaved scans, it is convenient to define last_row_height 0N/A * as the number of block rows present in the last iMCU row. 0N/A /* Prepare array describing MCU composition */ 0N/A /* Interleaved (multi-component) scan */ 0N/A /* Overall image size in MCUs */ 0N/A /* Sampling factors give # of blocks of component in each MCU */ 0N/A /* Figure number of non-dummy blocks in last MCU column & row */ 0N/A /* Prepare array describing MCU composition */ 0N/A * Save away a copy of the Q-table referenced by each component present 0N/A * in the current scan, unless already saved during a prior scan. 0N/A * In a multiple-scan JPEG file, the encoder could assign different components 0N/A * the same Q-table slot number, but change table definitions between scans 0N/A * so that each component uses a different Q-table. (The IJG encoder is not 0N/A * currently capable of doing this, but other encoders might.) Since we want 0N/A * to be able to dequantize all the components at the end of the file, this 0N/A * means that we have to save away the table actually used for each component. 0N/A * We do this by copying the table at the start of the first scan containing 0N/A * The JPEG spec prohibits the encoder from changing the contents of a Q-table 0N/A * slot between scans of a component using that slot. If the encoder does so 0N/A * anyway, this decoder will simply use the Q-table values that were current 0N/A * at the start of the first scan for the component. 0N/A * The decompressor output side looks only at the saved quant tables, 0N/A * not at the current Q-table slots. 0N/A /* No work if we already saved Q-table for this component */ 0N/A /* Make sure specified quantization table is present */ 0N/A /* OK, save away the quantization table */ 0N/A * Initialize the input modules to read a scan of compressed data. 0N/A * The first call to this is done by jdmaster.c after initializing 0N/A * the entire decompressor (during jpeg_start_decompress). 0N/A * Subsequent calls come from consume_markers, below. 0N/A * Finish up after inputting a compressed-data scan. 0N/A * This is called by the coefficient controller after it's read all 0N/A * the expected data of the scan. 0N/A * Read JPEG markers before, between, or after compressed-data scans. 0N/A * Change state as necessary when a new scan is reached. 0N/A * Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. 0N/A * The consume_input method pointer points either here or to the 0N/A * coefficient controller's consume_data routine, depending on whether 0N/A * we are reading a compressed data segment or inter-segment markers. 0N/A * responsible for enforcing this sequencing. 0N/A }
else {
/* 2nd or later SOS marker */ 0N/A /* Prevent infinite loop in coef ctlr's decompress_data routine 0N/A * if user set output_scan_number larger than number of scans. 0N/A * Reset state to begin a fresh datastream. 0N/A /* Reset other modules */ 0N/A /* Reset progression state -- would be cleaner if entropy decoder did this */ 0N/A * Initialize the input controller module. 0N/A * This is called only once, when the decompression object is created. 0N/A /* Create subobject in permanent pool */ 0N/A /* Initialize method pointers */ 0N/A /* Initialize state: can't use reset_input_controller since we don't 0N/A * want to try to reset other modules yet.