00001 #ifndef __J2K__LZH__LZHLEncoder_HPP__ 00002 #define __J2K__LZH__LZHLEncoder_HPP__ 00003 00004 class LZHLEncoder { 00005 public: 00006 enum { maxMatchOver = 517, maxRaw = 64 }; 00007 00008 private: 00009 LZHLEncoderStat* stat; 00010 HUFFINT* sstat; 00011 int& nextStat; 00012 00013 BYTE* dst; 00014 BYTE* dstBegin; 00015 UINT32 bits; 00016 int nBits; 00017 00018 public: 00019 static size_t calcMaxBuf( size_t rawSz ) { 00020 return rawSz + ( rawSz >> 1 ) + 32; 00021 } 00022 00023 public: 00024 inline LZHLEncoder( LZHLEncoderStat* stat_, BYTE* dst_ ); 00025 inline ~LZHLEncoder(); 00026 size_t flush(); 00027 00028 void putRaw( const BYTE* src, size_t sz ); 00029 void putMatch( const BYTE* src, size_t nRaw, size_t matchOver, size_t disp ); 00030 00031 private: 00032 void _callStat(); 00033 00034 inline void _put( UINT16 symbol ); 00035 inline void _put( UINT16 symbol, int codeBits, UINT32 code ); 00036 inline void _putBits( int codeBits, UINT32 code ); 00037 }; 00038 00039 #endif