D:/Zythum/DinoKod/Common/Lzw.h

00001 //---------------------------------------------------------------------------------------------
00002 //      This file is a part of "DinoKod".
00003 //      Copyright © 2003 Dino Productions. All Rights Reserved.
00004 //      
00005 //      File                    : Lzw.h
00006 //      Author                  : Sebastien LEIX        sebastien.leix@wanadoo.fr
00007 //      Date                    : 01/01/2003
00008 //      Modification    :
00009 //
00010 //---------------------------------------------------------------------------------------------
00011 #ifndef __LZW_H__
00012 #define __LZW_H__
00013 
00014 #include "Common/CommonDll.h"
00015 #include "Common/Types.h"
00016 
00017 #define LZW_DICTIONNARY_SIZE    2048
00018 #define LZW_NBITS                               9
00019 #define LZW_MAX_VALUE                   ((1 << LZW_NBITS) - 1)
00020 #define LZW_MAX_CODE                    (LZW_MAX_VALUE - 1)
00021 
00022 //--------------------------------------------------------------------------------------------------------------------------
00023 class COMMON_API KLZW
00024 {
00025 protected:
00026         u8              m_pDictionnary[LZW_DICTIONNARY_SIZE];
00027         s32             m_nDictionnary;
00028         u32             m_Bit;
00029         s32             m_nBit;
00030 
00031         void    Flush();
00032         void    Output( u8* pBufferOut, s32& OutSize, s32 MaxSize, s32 Code );
00033         s32             Input( u8* pBufferIn, s32 Size, s32 &Pos );
00034         void    AddBufferToDictionnary( u8* pBuffer, s32 Size );
00035         bool    IsStringIsInDictionnary( u8* pBuffer, s32 Size );
00036         s32             GetCode( u8* pBuffer, s32 Size );
00037         s32             GetBuffer( s32 Code, u8* pBuffer );
00038 
00039 public:
00040         KLZW();
00041         ~KLZW();
00042 
00043         void    Compress( u8* pBuffer, s32 Size, u8* pOutBuffer, s32* pOutSize );
00044         void    Expand( u8* pBuffer, s32 Size, u8* pOutBuffer, s32* pOutSize );
00045 
00046 };
00047 
00048 extern COMMON_API KLZW  g_Lzw;
00049 
00050 #endif  __LZW_H__

Generated on Sun Mar 25 20:02:10 2007 for Zythum Project by  doxygen 1.5.1-p1