public void setGlobalData(byte[] data) {
globalData = data;
}
public void decodeJBIG2(byte[] data) throws IOException, JBIG2Exception {
reader = new StreamReader(data);
resetDecoder();
boolean validFile = checkHeader();
if (JBIG2StreamDecoder.debug)
System.out.println("validFile = " + validFile);
if (!validFile) {
/**
* Assume this is a stream from a PDF so there is no file header,
* end of page segments, or end of file segments. Organisation must
* be sequential, and the number of pages is assumed to be 1.
*/
noOfPagesKnown = true;
randomAccessOrganisation = false;
noOfPages = 1;
/** check to see if there is any global data to be read */
if (globalData != null) {
/** set the reader to read from the global data */
reader = new StreamReader(globalData);
huffmanDecoder = new HuffmanDecoder(reader);
mmrDecoder = new MMRDecoder(reader);
arithmeticDecoder = new ArithmeticDecoder(reader);
/** read in the global data segments */
readSegments();
/** set the reader back to the main data */
reader = new StreamReader(data);
} else {
/**
* There's no global data, so move the file pointer back to the
* start of the stream
*/