Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages | Examples

lz77decp.h

00001 //  Copyright (c) 1996-2001 by Autodesk, Inc.
00002 //
00003 //  By using this code, you are agreeing to the terms and conditions of
00004 //  the License Agreement included in the documentation for this code.
00005 //
00006 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00007 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00008 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00009 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00010 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00011 //
00012 //  Use, duplication, or disclosure by the U.S. Government is subject to
00013 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00014 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00015 //  Data and Computer Software), as applicable.
00016 //
00017 
00018 #if !defined LZ77DECP_HEADER
00019 #define LZ77DECP_HEADER
00020 
00021 #include "whiptk/whipcore.h"
00022 #include "whiptk/fifo.h"
00023 #include "whiptk/file.h"
00024 #include "whiptk/lzdefs.h"
00025 
00026 #ifdef  DWFCORE_BUILD_ZLIB
00027 #include "dwfcore/zlib/zlib.h"
00028 #else
00029 #include <zlib.h>
00030 #endif
00031 
00033 
00034 class WT_LZ_DeCompressor : public WT_DeCompressor
00035 {
00036 private:
00037     enum Decompression_State
00038     {
00039         Literal_Data,
00040         Compression_Code,
00041         Process_Compression_Length_Code,
00042         Extended_Literal_Length_Code,
00043         Extended_Compression_Length_Code,
00044         First_Offset_Code_Byte,
00045         Second_Offset_Code_Byte,
00046         Eating_Recall_Buffer_Data
00047     };
00048 
00049     WT_File &                   m_file;
00050     Decompression_State         m_next_byte;
00051     WT_Integer32                m_compression_run;
00052     WT_Integer32                m_literal_data_run;
00053     WT_Integer32                m_offset;
00054     WT_FIFO<WT_Byte>            m_recall_buffer;
00055 
00056     void preload_recall_buffer();
00057 
00058     WT_LZ_DeCompressor (WT_LZ_DeCompressor const &)
00059         : WT_DeCompressor()
00060         , m_file(_WT_File_g_none)
00061         , m_next_byte(Compression_Code)
00062         , m_compression_run(0)
00063         , m_literal_data_run(0)
00064         , m_offset(0)
00065     {
00066         WD_Complain ("cannot copy WT_LZ_DeCompressor");
00067     } // prohibited
00068 
00069 
00070     WT_LZ_DeCompressor & operator= (WT_LZ_DeCompressor const &)
00071     {
00072         WD_Complain ("cannot assign WT_LZ_DeCompressor");
00073         return *this;
00074     } // prohibited
00075 
00076 public:
00077 
00078     // Constructors, Destructors
00079 
00080     WT_LZ_DeCompressor(WT_File & file)
00081         : m_file(file)
00082         , m_next_byte(Compression_Code)
00083         , m_compression_run(0)
00084         , m_literal_data_run(0)
00085         , m_offset(0)
00086     { }
00087 
00088     ~WT_LZ_DeCompressor()
00089     { }
00090 
00091     WT_Result    start()
00092     {
00093         preload_recall_buffer();
00094         return WT_Result::Success;
00095     }
00096 
00097     WT_Result    decompress(int desired, int & actual, void * buffer);
00098 };
00099 
00100 
00102 
00103 class WT_ZLib_DeCompressor : public WT_DeCompressor
00104 {
00105 private:
00106 
00107     WT_File &                   m_file;
00108     z_stream                    m_zlib_stream; /* Zlib's decompression stream */
00109     WT_Byte                     m_compressed_data_buffer[WD_ZLIB_DECOMPRESSION_INPUT_BUFFER_SIZE];
00110 
00111     WT_ZLib_DeCompressor (WT_ZLib_DeCompressor const &)
00112         : WT_DeCompressor()
00113         , m_file(_WT_File_g_none)
00114         , m_zlib_stream()
00115     {
00116         WD_Complain ("cannot copy WT_ZLib_DeCompressor");
00117     } // prohibited
00118 
00119 
00120     WT_ZLib_DeCompressor & operator= (WT_ZLib_DeCompressor const &)
00121     {
00122         WD_Complain ("cannot assign WT_ZLib_DeCompressor");
00123         return *this;
00124     } // prohibited
00125 
00126 public:
00127 
00128     // Constructors, Destructors
00129 
00130     WT_ZLib_DeCompressor(WT_File & file)
00131         : m_file(file)
00132         , m_zlib_stream()
00133     { }
00134 
00135     ~WT_ZLib_DeCompressor()
00136     { }
00137 
00138     WT_Result    start();
00139     WT_Result    decompress(int desired, int & actual, void * buffer);
00140 };
00141 
00142 
00143 #endif // LZ77DECP_HEADER

Generated on Tue May 17 12:07:44 2005 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.1