2018-08-12 18:07:22 +00:00
|
|
|
#ifndef PL_LZWDECODER_HH
|
|
|
|
#define PL_LZWDECODER_HH
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
#include <qpdf/Pipeline.hh>
|
|
|
|
|
|
|
|
#include <qpdf/Buffer.hh>
|
|
|
|
#include <vector>
|
|
|
|
|
2009-10-21 00:27:24 +00:00
|
|
|
class Pl_LZWDecoder: public Pipeline
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2008-04-29 12:55:25 +00:00
|
|
|
Pl_LZWDecoder(char const* identifier, Pipeline* next,
|
|
|
|
bool early_code_change);
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2008-04-29 12:55:25 +00:00
|
|
|
virtual ~Pl_LZWDecoder();
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2012-06-20 15:20:57 +00:00
|
|
|
virtual void write(unsigned char* buf, size_t len);
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2008-04-29 12:55:25 +00:00
|
|
|
virtual void finish();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void sendNextCode();
|
|
|
|
void handleCode(int code);
|
|
|
|
unsigned char getFirstChar(int code);
|
|
|
|
void addToTable(unsigned char next);
|
|
|
|
|
|
|
|
// members used for converting bits to codes
|
|
|
|
unsigned char buf[3];
|
|
|
|
int code_size;
|
|
|
|
int next;
|
|
|
|
int byte_pos;
|
|
|
|
int bit_pos; // left to right: 01234567
|
|
|
|
int bits_available;
|
|
|
|
|
|
|
|
// members used for handle LZW decompression
|
|
|
|
bool code_change_delta;
|
|
|
|
bool eod;
|
|
|
|
std::vector<Buffer> table;
|
|
|
|
int last_code;
|
|
|
|
};
|
|
|
|
|
2018-08-12 18:07:22 +00:00
|
|
|
#endif // PL_LZWDECODER_HH
|