Index: poppler/Stream.cc =================================================================== --- poppler/Stream.cc (revision 74) +++ poppler/Stream.cc (working copy) @@ -90,11 +90,6 @@ void Stream::close() { } -int Stream::getRawChar() { - error(-1, "Internal: called getRawChar() on non-predictor stream"); - return EOF; -} - char *Stream::getLine(char *buf, int size) { int i; int c; @@ -424,7 +419,7 @@ // StreamPredictor //------------------------------------------------------------------------ -StreamPredictor::StreamPredictor(Stream *strA, int predictorA, +StreamPredictor::StreamPredictor(IGetRawChar *strA, int predictorA, int widthA, int nCompsA, int nBitsA) { int totalBits; @@ -1149,16 +1144,9 @@ int LZWStream::getChar() { if (pred) { return pred->getChar(); + } else { + return getRawChar(); } - if (eof) { - return EOF; - } - if (seqIndex >= seqLength) { - if (!processNextCode()) { - return EOF; - } - } - return seqBuf[seqIndex++]; } int LZWStream::lookChar() { @@ -1176,18 +1164,6 @@ return seqBuf[seqIndex]; } -int LZWStream::getRawChar() { - if (eof) { - return EOF; - } - if (seqIndex >= seqLength) { - if (!processNextCode()) { - return EOF; - } - } - return seqBuf[seqIndex++]; -} - void LZWStream::reset() { str->reset(); eof = gFalse; @@ -4073,20 +4049,11 @@ } int FlateStream::getChar() { - int c; - if (pred) { return pred->getChar(); + } else { + return getRawChar(); } - while (remain == 0) { - if (endOfBlock && eof) - return EOF; - readSome(); - } - c = buf[index]; - index = (index + 1) & flateMask; - --remain; - return c; } int FlateStream::lookChar() { @@ -4104,20 +4071,6 @@ return c; } -int FlateStream::getRawChar() { - int c; - - while (remain == 0) { - if (endOfBlock && eof) - return EOF; - readSome(); - } - c = buf[index]; - index = (index + 1) & flateMask; - --remain; - return c; -} - GooString *FlateStream::getPSFilter(int psLevel, char *indent) { GooString *s; Index: poppler/Stream.h =================================================================== --- poppler/Stream.h (revision 74) +++ poppler/Stream.h (working copy) @@ -75,10 +75,6 @@ // Peek at next char in stream. virtual int lookChar() = 0; - // Get next char from stream without using the predictor. - // This is only used by StreamPredictor. - virtual int getRawChar(); - // Get next line from stream. virtual char *getLine(char *buf, int size); @@ -232,6 +228,11 @@ int imgIdx; // current index in imgLine }; +class IGetRawChar { +public: + int getRawChar() { assert(0); return 0; } +}; + //------------------------------------------------------------------------ // StreamPredictor //------------------------------------------------------------------------ @@ -241,7 +242,7 @@ // Create a predictor object. Note that the parameters are for the // predictor, and may not match the actual image parameters. - StreamPredictor(Stream *strA, int predictorA, + StreamPredictor(IGetRawChar *strA, int predictorA, int widthA, int nCompsA, int nBitsA); ~StreamPredictor(); @@ -255,7 +256,7 @@ GBool getNextLine(); - Stream *str; // base stream + IGetRawChar *str; // base stream int predictor; // predictor int width; // pixels per line int nComps; // components per pixel @@ -445,7 +446,7 @@ // LZWStream //------------------------------------------------------------------------ -class LZWStream: public FilterStream { +class LZWStream: public FilterStream, IGetRawChar { public: LZWStream(Stream *strA, int predictor, int columns, int colors, @@ -455,10 +456,21 @@ virtual void reset(); virtual int getChar(); virtual int lookChar(); - virtual int getRawChar(); virtual GooString *getPSFilter(int psLevel, char *indent); virtual GBool isBinary(GBool last = gTrue); + int getRawChar() { + if (eof) { + return EOF; + } + if (seqIndex >= seqLength) { + if (!processNextCode()) { + return EOF; + } + } + return seqBuf[seqIndex++]; + } + private: StreamPredictor *pred; // predictor @@ -694,7 +706,7 @@ int first; // first length/distance }; -class FlateStream: public FilterStream { +class FlateStream: public FilterStream, IGetRawChar { public: FlateStream(Stream *strA, int predictor, int columns, @@ -704,7 +716,6 @@ virtual void reset(); virtual int getChar(); virtual int lookChar(); - virtual int getRawChar(); virtual GooString *getPSFilter(int psLevel, char *indent); virtual GBool isBinary(GBool last = gTrue); @@ -712,6 +723,20 @@ virtual GBool getBuf(char **bufOut, int *bufSizeOut, int maxSize); virtual void ungetBuf(int sizeToGoBack); + int FlateStream::getRawChar() { + int c; + + while (remain == 0) { + if (endOfBlock && eof) + return EOF; + readSome(); + } + c = buf[index]; + index = (index + 1) & flateMask; + --remain; + return c; + } + private: StreamPredictor *pred; // predictor Index: poppler/FlateStream.cc =================================================================== --- poppler/FlateStream.cc (revision 74) +++ poppler/FlateStream.cc (working copy) @@ -41,13 +41,6 @@ out_buf_len = 0; } -int FlateStream::getRawChar() { - if (fill_buffer()) - return EOF; - - return out_buf[out_pos++]; -} - int FlateStream::getChar() { if (pred) return pred->getChar(); Index: poppler/FlateStream.h =================================================================== --- poppler/FlateStream.h (revision 74) +++ poppler/FlateStream.h (working copy) @@ -39,7 +39,7 @@ #include } -class FlateStream: public FilterStream { +class FlateStream: public FilterStream, IGetRawChar { public: FlateStream(Stream *strA, int predictor, int columns, int colors, int bits); @@ -48,10 +48,16 @@ virtual void reset(); virtual int getChar(); virtual int lookChar(); - virtual int getRawChar(); virtual GooString *getPSFilter(int psLevel, char *indent); virtual GBool isBinary(GBool last = gTrue); + int getRawChar() { + if (fill_buffer()) + return EOF; + + return out_buf[out_pos++]; + } + private: int fill_buffer(void); z_stream d_stream;