blob: a0c35c49fb2996bb7f1b76ab4de2a13082d5d151 (
plain) (
tree)
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>lzsscomprs.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.17 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> </center>
<hr><h1>lzsscomprs.h</h1><div class="fragment"><pre>00001 <span class="comment">/******************************************************************************</span>
00002 <span class="comment"> * lzsscomprs.h - definition of Class SWCompress used for data compression</span>
00003 <span class="comment"> *</span>
00004 <span class="comment"> * $Id: lzsscomprs_8h-source.html,v 1.9 2002/10/31 11:30:15 joachim Exp $</span>
00005 <span class="comment"> *</span>
00006 <span class="comment"> * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)</span>
00007 <span class="comment"> * CrossWire Bible Society</span>
00008 <span class="comment"> * P. O. Box 2528</span>
00009 <span class="comment"> * Tempe, AZ 85280-2528</span>
00010 <span class="comment"> *</span>
00011 <span class="comment"> * This program is free software; you can redistribute it and/or modify it</span>
00012 <span class="comment"> * under the terms of the GNU General Public License as published by the</span>
00013 <span class="comment"> * Free Software Foundation version 2.</span>
00014 <span class="comment"> *</span>
00015 <span class="comment"> * This program is distributed in the hope that it will be useful, but</span>
00016 <span class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</span>
00017 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
00018 <span class="comment"> * General Public License for more details.</span>
00019 <span class="comment"> *</span>
00020 <span class="comment"> */</span>
00021
00022 <span class="preprocessor">#ifndef LZSSCOMPRS_H</span>
00023 <span class="preprocessor"></span><span class="preprocessor">#define LZSSCOMPRS_H</span>
00024 <span class="preprocessor"></span>
00025 <span class="preprocessor">#include <swcomprs.h></span>
00026
00027 <span class="preprocessor">#include <defs.h></span>
00028
00029 SWORD_NAMESPACE_START
00030
00031 <span class="comment">// The following are constant sizes used by the compression algorithm.</span>
00032 <span class="comment">//</span>
00033 <span class="comment">// N - This is the size of the ring buffer. It is set</span>
00034 <span class="comment">// to 4K. It is important to note that a position</span>
00035 <span class="comment">// within the ring buffer requires 12 bits. </span>
00036 <span class="comment">//</span>
00037 <span class="comment">// F - This is the maximum length of a character sequence</span>
00038 <span class="comment">// that can be taken from the ring buffer. It is set</span>
00039 <span class="comment">// to 18. Note that a length must be 3 before it is</span>
00040 <span class="comment">// worthwhile to store a position/length pair, so the</span>
00041 <span class="comment">// length can be encoded in only 4 bits. Or, put yet</span>
00042 <span class="comment">// another way, it is not necessary to encode a length</span>
00043 <span class="comment">// of 0-18, it is necessary to encode a length of</span>
00044 <span class="comment">// 3-18, which requires 4 bits.</span>
00045 <span class="comment">// </span>
00046 <span class="comment">// THRESHOLD - It takes 2 bytes to store an offset and</span>
00047 <span class="comment">// a length. If a character sequence only</span>
00048 <span class="comment">// requires 1 or 2 characters to store </span>
00049 <span class="comment">// uncompressed, then it is better to store</span>
00050 <span class="comment">// it uncompressed than as an offset into</span>
00051 <span class="comment">// the ring buffer.</span>
00052 <span class="comment">//</span>
00053 <span class="comment">// Note that the 12 bits used to store the position and the 4 bits</span>
00054 <span class="comment">// used to store the length equal a total of 16 bits, or 2 bytes.</span>
00055
00056 <span class="preprocessor">#define N 4096</span>
00057 <span class="preprocessor"></span><span class="preprocessor">#define F 18</span>
00058 <span class="preprocessor"></span><span class="preprocessor">#define THRESHOLD 3</span>
00059 <span class="preprocessor"></span><span class="preprocessor">#define NOT_USED N</span>
00060 <span class="preprocessor"></span>
00061
00062
00063 <span class="keyword">class </span>SWDLLEXPORT LZSSCompress:<span class="keyword">public</span> SWCompress
00064 {
00065 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> m_ring_buffer[N + F - 1];
00066 <span class="keyword">static</span> <span class="keywordtype">short</span> <span class="keywordtype">int</span> m_match_position;
00067 <span class="keyword">static</span> <span class="keywordtype">short</span> <span class="keywordtype">int</span> m_match_length;
00068 <span class="keyword">static</span> <span class="keywordtype">short</span> <span class="keywordtype">int</span> m_lson[N + 1];
00069 <span class="keyword">static</span> <span class="keywordtype">short</span> <span class="keywordtype">int</span> m_rson[N + 257];
00070 <span class="keyword">static</span> <span class="keywordtype">short</span> <span class="keywordtype">int</span> m_dad[N + 1];
00071 <span class="keywordtype">void</span> InitTree ();
00072 <span class="keywordtype">void</span> InsertNode (<span class="keywordtype">short</span> <span class="keywordtype">int</span> Pos);
00073 <span class="keywordtype">void</span> DeleteNode (<span class="keywordtype">short</span> <span class="keywordtype">int</span> Node);
00074 <span class="keyword">public</span>:
00075 LZSSCompress ();
00076 <span class="keyword">virtual</span> ~ LZSSCompress ();
00077 <span class="keyword">virtual</span> <span class="keywordtype">void</span> Encode (<span class="keywordtype">void</span>);
00078 <span class="keyword">virtual</span> <span class="keywordtype">void</span> Decode (<span class="keywordtype">void</span>);
00079 };
00080
00081 SWORD_NAMESPACE_END
00082 <span class="preprocessor">#endif</span>
</pre></div><hr><address style="align: right;"><small>Generated on Thu Oct 31 12:11:28 2002 for The Sword Project by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0
width=110 height=53></a>1.2.17 </small></address>
</body>
</html>
|