PixelArrayCCITTG4Private.mesa
Copyright Ó 1993 by Xerox Corporation. All rights reserved.
Russ Atkinson (RRA) April 24, 1993 3:08 pm PDT
DIRECTORY ImagerPixelArray, ImagerSample, IO, Rope;
PixelArrayCCITTG4Private: CEDAR DEFINITIONS = BEGIN
Data: TYPE ~ REF DataRep;
DataRep: TYPE ~ MONITORED RECORD [
scanLength: CARDINAL ¬ 0,
reverseBits: BOOL ¬ FALSE,
useFastScan: BOOL ¬ FALSE,
debug: IO.STREAM ¬ NIL, -- for debug output (NIL => none)
stream: IO.STREAM ¬ NIL,
initIndex: INT ¬ 0, -- saved index when stream = NIL
nextLineState: State ¬ none, -- used to make uncompressed-mode data span scanlines.
nextScanState: State ¬ none, -- used internally
bitBuffer: CARD ¬ 0,
goodBits: [0..32) ¬ 0,
sCurrent: INTEGER ¬ 0,
lineBufferValid: BOOL ¬ FALSE,
copyData: CopyData ¬ NIL,
lineBuffer: ImagerSample.RasterSampleMap ¬ NIL,
referenceTransitions: REF IndexSequenceRep ¬ NIL,
lineTransitions: REF IndexSequenceRep ¬ NIL,
k: INT ¬ -1,
oneDimTag: BOOL ¬ FALSE,
sSize: INTEGER ¬ -1,
end: BOOL ¬ FALSE,
roots: REF ARRAY State OF Node ¬ NIL,
data for Scan:
referenceColor: [0..1] ¬ 0,
referenceIndex: CARDINAL ¬ 0,
error indicators:
errorIndex: CARD ¬ 0,
error: ATOM ¬ NIL, -- indicates error
errorCount: CARD ¬ 0
];
State: TYPE ~ MACHINE DEPENDENT {
white(0), black(1),
hwhite(2), hblack(3),
hhwhite(4), hhblack(5),
unc, uncb1, uncb2, uncb3, uncb4, uncb5,
uncw1, uncw2, uncw3, uncw4, uncw5, eoi, none
};
IndexSequenceRep: TYPE ~ RECORD [
end: CARDINAL,
s: PACKED SEQUENCE size: CARDINAL OF INT
];
CopyData: TYPE = REF CopyDataRep;
CopyDataRep: TYPE = RECORD [SEQUENCE len: CARDINAL OF REF];
Action: TYPE ~ { null, utest, emit, scan, pass, one, zeros };
Node: TYPE = REF NodeRep;
BitCount: TYPE = [0..BITS[WORD]);
Branch: TYPE ~ RECORD [reserveBits: BitCount, node: Node];
NodeRep: TYPE ~ RECORD [
count: CARD ¬ 0,
cases: SELECT tag: * FROM
internal => [bitCount: BitCount, d: SEQUENCE size: CARDINAL OF Branch],
leaf => [new: State, action: Action, length: INT],
ENDCASE
];
TreeNode: TYPE = REF NodeRep.internal;
LeafNode: TYPE = REF NodeRep.leaf;
FromStream: PROC [st: IO.STREAM, bitsPerLine: CARDINAL] RETURNS [Data];
Creates a data object for G4 decompression given the input stream and the bitsPerLine. The input stream is considered to be private to the G4 data until such time as the G4 object is no longer used.
FillLineBuffer: PROC [data: Data, s: INTEGER, invert: BOOL ¬ FALSE];
Causes the line buffer to be filled with data corresponding to scan line s. If invert, then the bits are inverted.
MakePure: PROC [data: Data];
Forces the data to be copied in a pure, hopefully compact, form.
Close: PROC [data: Data];
Closes the data, which MUST NOT be used afterwards unless it has been copied.
G4PixelArrayFromData: PROC [data: Data, lines: CARDINAL, bitsPerLine: CARDINAL]
RETURNS [ImagerPixelArray.PixelArray];
Creates a pixel array from the given G4 object. Access to the pixel array will be properly monitored, so concurrent access is OK, but is only useful if the underlying stream can handle random access via IO.SetIndex.
DumpRoots: PROC [st: IO.STREAM, clear: BOOL];
For debugging, dumps the roots (and counts) to the given stream.
END.