Commit de787381 authored by Brad Hards's avatar Brad Hards

poppler/JArithmeticDecoder.cc

poppler/JArithmeticDecoder.h
poppler/JBIG2Stream.cc
poppler/JBIG2Stream.h: merge in some of the JBIG2 changes from xpdf 3.0.1.
parent 55952feb
2005-08-31 Brad Hards <bradh@frogmouth.net>
* poppler/JArithmeticDecoder.cc
* poppler/JArithmeticDecoder.h
* poppler/JBIG2Stream.cc
* poppler/JBIG2Stream.h: merge in some of the JBIG2 changes from
xpdf 3.0.1.
2005-08-29 Kristian Høgsberg <krh@redhat.com>
* configure.ac (HAVE_FREETYPE_H): Patch from Hiroyuki Ikezoe: Set
......
......@@ -89,24 +89,24 @@ int JArithmeticDecoder::switchTab[47] = {
JArithmeticDecoder::JArithmeticDecoder() {
str = NULL;
}
JArithmeticDecoder::~JArithmeticDecoder() {
while (dataLen > 0) {
readByte();
}
dataLen = 0;
limitStream = gFalse;
}
inline Guint JArithmeticDecoder::readByte() {
if (dataLen == 0) {
return 0xff;
}
if (dataLen > 0) {
if (limitStream) {
--dataLen;
if (dataLen < 0) {
return 0xff;
}
}
return (Guint)str->getChar() & 0xff;
}
JArithmeticDecoder::~JArithmeticDecoder() {
cleanup();
}
void JArithmeticDecoder::start() {
buf0 = readByte();
buf1 = readByte();
......@@ -119,6 +119,28 @@ void JArithmeticDecoder::start() {
a = 0x80000000;
}
void JArithmeticDecoder::restart(int dataLenA) {
int oldDataLen;
oldDataLen = dataLen;
dataLen = dataLenA;
if (oldDataLen == -1) {
buf1 = readByte();
} else if (oldDataLen <= -2) {
buf0 = readByte();
buf1 = readByte();
}
}
void JArithmeticDecoder::cleanup() {
if (limitStream) {
while (dataLen > 0) {
buf0 = buf1;
buf1 = readByte();
}
}
}
int JArithmeticDecoder::decodeBit(Guint context,
JArithmeticDecoderStats *stats) {
int bit;
......
......@@ -51,12 +51,29 @@ public:
JArithmeticDecoder();
~JArithmeticDecoder();
void setStream(Stream *strA)
{ str = strA; dataLen = -1; }
{ str = strA; dataLen = 0; limitStream = gFalse; }
void setStream(Stream *strA, int dataLenA)
{ str = strA; dataLen = dataLenA; }
{ str = strA; dataLen = dataLenA; limitStream = gTrue; }
// Start decoding on a new stream. This fills the byte buffers and
// runs INITDEC.
void start();
// Restart decoding on an interrupted stream. This refills the
// buffers if needed, but does not run INITDEC. (This is used in
// JPEG 2000 streams when codeblock data is split across multiple
// packets/layers.)
void restart(int dataLenA);
// Read any leftover data in the stream.
void cleanup();
// Decode one bit.
int decodeBit(Guint context, JArithmeticDecoderStats *stats);
// Decode eight bits.
int decodeByte(Guint context, JArithmeticDecoderStats *stats);
// Returns false for OOB, otherwise sets *<x> and returns true.
......@@ -84,6 +101,7 @@ private:
Stream *str;
int dataLen;
GBool limitStream;
};
#endif
This diff is collapsed.
......@@ -43,8 +43,8 @@ public:
private:
void readSegments();
void readSymbolDictSeg(Guint segNum, Guint length,
Guint *refSegs, Guint nRefSegs);
GBool readSymbolDictSeg(Guint segNum, Guint length,
Guint *refSegs, Guint nRefSegs);
void readTextRegionSeg(Guint segNum, GBool imm,
GBool lossless, Guint length,
Guint *refSegs, Guint nRefSegs);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment