1 #ifndef COMPRESSER_H_ 2 # define COMPRESSER_H_ 3 4 # ifdef LZO2 5 # include "lzo/lzo1x.h" 6 # include "lzo/lzo1c.h" 7 # else 8 # include "lzo1x.h" 9 # include "lzo1c.h" 10 # endif 11 12 class EncodeBuffer; 13 struct cEntry; 14 15 typedef enum 16 { NO_STREAM_COMPRESSION = 0, LZO_COMPRESSION = 1 } CompressionType; 17 18 // Number of bits needed to hold an enum value. 19 # define COMPRESSION_TYPE_BITS 1 20 21 22 23 class Compresser 24 { 25 public: 26 27 Compresser(int compressionLevel); 28 ~Compresser(); 29 30 CompressionType compressBuffer(const unsigned char *buffer, 31 const unsigned int size, 32 EncodeBuffer & encodeBuffer); 33 34 // These next two things really belong in a factory class that 35 // builds compressers & decompressers based on the compression 36 // level. But I'm lazy. 37 static int isValidCompressionLevel(int compressionLevel); 38 static lzo_decompress_t getDecompresser(int compressionLevel); 39 40 private: 41 lzo_byte * lzoCompressionWorkspace; 42 lzo_byte *lzoCompressionBuffer; 43 lzo_uint lzoCompressionBufferSize; 44 lzo_compress_t compressionFnc; 45 static cEntry *getCEntry(int compressionLevel); 46 }; 47 48 #endif 49