C# Class BitMiracle.LibJpeg.Classic.Internal.jpeg_decomp_master

Master control module
Show file Open project: prepare/HTML-Renderer Class Usage Examples

Public Methods

Method Description
IsDummyPass ( ) : bool
finish_output_pass ( ) : void

Finish up at end of an output pass.

jpeg_decomp_master ( jpeg_decompress_struct cinfo ) : System
prepare_for_output_pass ( ) : void

Per-pass setup. This is called at the beginning of each output pass. We determine which modules will be active during this pass and give them appropriate start_pass calls. We also set is_dummy_pass to indicate whether this is a "real" output pass or a dummy pass for color quantization. (In the latter case, we will crank the pass to completion.)

Private Methods

Method Description
master_selection ( ) : void

Master selection of decompression modules. This is done once at jpeg_start_decompress time. We determine which modules will be used and give them appropriate initialization calls. We also initialize the decompressor input side to begin consuming data. Since jpeg_read_header has finished, we know what is in the SOF and (first) SOS markers. We also have all the application parameter settings.

prepare_range_limit_table ( ) : void

Allocate and fill in the sample_range_limit table. Several decompression processes need to range-limit values to the range 0..MAXJSAMPLE; the input value may fall somewhat outside this range due to noise introduced by quantization, roundoff error, etc. These processes are inner loops and need to be as fast as possible. On most machines, particularly CPUs with pipelines or instruction prefetch, a (subscript-check-less) C table lookup x = sample_range_limit[x]; is faster than explicit tests if (x & 0) x = 0; else if (x > MAXJSAMPLE) x = MAXJSAMPLE; These processes all use a common table prepared by the routine below. For most steps we can mathematically guarantee that the initial value of x is within 2*(MAXJSAMPLE+1) of the legal range, so a table running from -2*(MAXJSAMPLE+1) to 3*MAXJSAMPLE+2 is sufficient.But for the initial limiting step(just after the IDCT), a wildly out-of-range value is possible if the input data is corrupt.To avoid any chance of indexing off the end of memory and getting a bad-pointer trap, we perform the post-IDCT limiting thus: x = (sample_range_limit - SUBSET)[(x + CENTER) & MASK]; where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit samples. Under normal circumstances this is more than enough range and a correct output will be generated; with bogus input data the mask will cause wraparound, and we will safely generate a bogus-but-in-range output. For the post-IDCT step, we want to convert the data from signed to unsigned representation by adding CENTERJSAMPLE at the same time that we limit it. This is accomplished with SUBSET = CENTER - CENTERJSAMPLE. Note that the table is allocated in near data space on PCs; it's small enough and used often enough to justify this.

Method Details

IsDummyPass() public method

public IsDummyPass ( ) : bool
return bool

finish_output_pass() public method

Finish up at end of an output pass.
public finish_output_pass ( ) : void
return void

jpeg_decomp_master() public method

public jpeg_decomp_master ( jpeg_decompress_struct cinfo ) : System
cinfo jpeg_decompress_struct
return System

prepare_for_output_pass() public method

Per-pass setup. This is called at the beginning of each output pass. We determine which modules will be active during this pass and give them appropriate start_pass calls. We also set is_dummy_pass to indicate whether this is a "real" output pass or a dummy pass for color quantization. (In the latter case, we will crank the pass to completion.)
public prepare_for_output_pass ( ) : void
return void