"L. Spiro Engine"
|
00001 00017 #ifndef __LSI_LZWDICTIONARY_H__ 00018 #define __LSI_LZWDICTIONARY_H__ 00019 00020 #include "../LSIImageLib.h" 00021 #include "Vector/LSTLVectorPoD.h" 00022 00023 namespace lsi { 00024 00031 class CLzwDictionary { 00032 public : 00033 // == Various constructors. 00034 LSE_CALLCTOR CLzwDictionary(); 00035 LSE_CALLCTOR ~CLzwDictionary(); 00036 00037 00038 // == Types. 00042 typedef LSUINT16 LSI_LZW_CODE; 00043 00047 typedef struct LSI_LZW_DICT_ENTRY_DECOMPRESS { 00053 LSUINT32 lcBaseCode : 12; 00054 00059 LSUINT32 ui8Char : 8; 00060 } * LPLSI_LZW_DICT_ENTRY_DECOMPRESS, * const LPCLSI_LZW_DICT_ENTRY_DECOMPRESS; 00061 00062 00063 // == Functions. 00070 LSVOID LSE_CALL SetAllocator( CAllocator * _paAllocator ); 00071 00080 LSBOOL LSE_CALL InitializeDictionary( LSUINT32 _ui32Len, LSUINT32 _ui32MaxBits ); 00081 00088 LSBOOL LSE_CALL IsClearCode( LSI_LZW_CODE _lcCode ) const; 00089 00096 LSBOOL LSE_CALL IsEndOfInputCode( LSI_LZW_CODE _lcCode ) const; 00097 00103 LSUINT32 LSE_CALL GetTotal() const; 00104 00111 LSUINT32 LSE_CALL GetEntryIndex( LSI_LZW_CODE _lcCode ) const; 00112 00118 LSE_INLINE LSUINT32 LSE_CALL GetBitsNeeded() const; 00119 00126 LSVOID LSE_CALL AddCode( LSI_LZW_CODE _lcCode, LSUINT8 _ui8Char ); 00127 00136 LSUINT32 LSE_CALL GetString( LSI_LZW_CODE _lcCode, LSUINT8 * _pui8String ) const; 00137 00146 static LSUINT32 LSE_CALL GetBits( const LSUINT8 * _pui8Stream, LSUINT64 &_ui64BitIndex, LSUINT32 _ui32Total ); 00147 00148 protected : 00149 // == Members. 00153 CVectorPoD<LSI_LZW_DICT_ENTRY_DECOMPRESS, LSUINT32> 00154 m_vDecompDictionary; 00155 00159 LSUINT32 m_ui32MaxSize; 00160 00164 LSUINT32 m_ui32MaxBits; 00165 00169 LSUINT32 m_ui32ClearCode; 00170 00174 LSUINT32 m_ui32EndOfInput; 00175 00179 LSUINT32 m_ui32BitsNeeded; 00180 00181 00182 // == Functions. 00189 LSBOOL LSE_CALL Alloc( LSUINT32 _ui32Total ); 00190 00194 LSVOID LSE_CALL Reset(); 00195 00201 LSUINT32 LSE_CALL DeriveBitsNeeded() const; 00202 }; 00203 00204 00205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00206 // DEFINITIONS 00207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00208 // == Functions. 00214 LSE_INLINE LSUINT32 LSE_CALL CLzwDictionary::GetBitsNeeded() const { 00215 return CStd::Min<LSUINT32>( m_ui32BitsNeeded, m_ui32MaxBits ); 00216 } 00217 00218 } // namespace lsi 00219 00220 #endif // __LSI_LZWDICTIONARY_H__