lz77decp.h

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

Generated on Tue Jan 6 22:41:13 2009 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.5