
	Copyright (C) Wickerhauser Consulting.  All Rights Reserved.
	Contains information proprietary to Wickerhauser Consulting.


			   WSQ Decoding Algorithm
			   ======================

While SOI marker
	[Read marked tables and miscellaneous marked segments]
	If EOI marker then
		Announce ``abbreviated format''
		Continue
	Else 
		Read SOF marker and frame header
		Announce ``interchange format''
		Fall through
	Sanity-test frame parameters
	Write frame parameters to log file
	Re-allocate memory to transform this input

	Until EOI marker:
		[Read marked tables and miscellaneous marked segments]

		While SOB marker
			Test if all needed parameters are defined
			If restart is enabled then
				Read ECS until RST or SOB or EOI
				If RST then
					Test for expected RST number
				Decode ECS to bin indices, in WSQ order
				Test for expected number of bin indices
			Else
				Read ECS until SOB or EOI
				Decode ECS to bin indices, in WSQ order
			Continue

	Test if all needed parameters are defined
	Unquantize bin indices to real-valued coefficients in AWA order
	Invert the WSQ custom wavelet packet transform
	Rescale, shift, and truncate to integers
	Write the image to the output file
	Continue


			Buffer Usage
			============

	Entropy Coded Segments in `bytes0[]'
		\
		wsqrecs()
		/
	Quantization Bin Indices in `words1[]'
		\
		wsqunq()
		/
	Wavelet Coefficients in `words0[]'
		\
		rbwp2()		-- transposition done in `words1[]'
		/
	Real Gray Values in `words0[]'
		\
		wsqr2b()
		/
	Pixels in `bytes0[]'



			       Usage Help Page
			       ===============


Usage:  iWSQ [options] [-ooutfile] [-llogfile] infile1[.wsq] [...]

Options:                                      (default is shown in parentheses)

 -v | -v0 | -v1 | -v2 | -v3 | -v4 :  set verbosity level.                 (-v0)
   -v0: decompress and log only fatal errors;
   -v1: like 0, but also logs warning messages;
   -v2: like 1, but also mentions normal events;
   -v3: like 2, but also logs parameter values (same as -v);
   -v4: like 3, but also logs WSQ subbands in ASCII.

 -t | -r | -d | -ccmpfile : set output file type.                          (-t)
    -t ==> write the output in baseline grayscale TIFF 6.0.
    -r ==> write the output as raw 8-bit grayscale, no header.
    -d ==> debugging mode; write diagnostic log messages only.
    -c ==> compliance test; extract DQT to file `cmpfile.dqt' and
           quantization bin indices from subbands 0--59 to file
           `cmpfile.qbi' as ASCII text numbers for compliance testing.
           This implies debugging mode, too.  `cmpfile' is required.

 -ooutfile ==> write output to successive files named `outfile-XXXX.ext'
     where `XXXX' is 0000 to 9999 and `ext' is `tif' or `raw'.         (stdout)

 -llogfile ==> log diagnostic messages to `logfile.log'.               (stderr)

 infile1[.wsq] ==> read input from `infile1.wsq',....  Use - to read stdin.



			   Input File Assumptions
			   ======================

(1) More than one SOI-XXX-EOI block may be concatenated in the input stream,
	but following each EOI marker must be either SOI or end-of-file.

(2) Concatenated SOI-XXX-EOI blocks may be either interchange or abbreviated
	format.

(3) Parameters used for Huffman decoding an ECS will be those in place when
	the first bit of the ECS is read.

(4) Parameters used for inverting the quantization and the WSQ custom wavelet
	packet transform will be those in place when the EOI marker for that
	image is read.


			Remarks on the Implementation
			=============================

If each of the three ECS blocks has a different DQT, which one is used to
un-quantize each ECS block? If each of the three ECS blocks has a different
DTT, which filters should be used for reconstruction?  Which filters will
determine the sizes of the subbands?

	>>> Unquantization from bin indices takes place after all blocks
	in the frame have been scanned, using the latest installed DQT
	from the input stream.  Likewise, the inverse wavelet packet
	transform is applied after all blocks in the frame have been
	scanned, using the latest DTT.  This prevents the use of
	different filters at different levels.  All symmetric and
	antisymmetric filters produce the same subband sizes.

Must a DHT for an ECS block be defined when the block header's `Td'
parameter is encountered?  Can it be defined in a subsequent DHT, in the
next SOB segment?

	>>> The DHT used by an ECS must be defined before the ECS is read
	from the input stream.  This makes it possible to decode the ECS `on
	the fly' rather than forcing its storage for an indeterminate time.
