<html> <head> <title>Camstream: CamStream API documentation</title> <link rel="stylesheet" href="../../tech.css" type="text/css"> </head> <body> <!-- Generated by Doxygen 1.2.6 --> <center> <a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center> <hr><h1>CAdaptiveHuffman Class Reference</h1>An adaptive Huffman encoder in C++. <a href="#_details">More...</a> <p> <code>#include <<a class="el" href="adaptivehuffman_h-source.html">AdaptiveHuffman.h</a>></code> <p> <a href="class_cadaptivehuffman-members.html">List of all members.</a><h2>Public Types</h2> <ul> <li>enum { <a class="el" href="class_cadaptivehuffman.html#s3s0">ValueOutOfBounds</a> = -1, <a class="el" href="class_cadaptivehuffman.html#s3s1">BufferFull</a> = -2, <a class="el" href="class_cadaptivehuffman.html#s3s2">EndOfFile</a> = -3 } </ul> <h2>Public Methods</h2> <ul> <li><a class="el" href="class_cadaptivehuffman.html#a0">CAdaptiveHuffman</a> (int max_value) <li><a class="el" href="class_cadaptivehuffman.html#a1">~CAdaptiveHuffman</a> () <li>void <a class="el" href="class_cadaptivehuffman.html#a2">InitCompressor</a> (int buffer_size, char use_marks) <li>int <a class="el" href="class_cadaptivehuffman.html#a3">AddValue</a> (int v) <li>void <a class="el" href="class_cadaptivehuffman.html#a4">Mark</a> () <li>int <a class="el" href="class_cadaptivehuffman.html#a5">GetBits</a> () const <li>const char* <a class="el" href="class_cadaptivehuffman.html#a6">GetBuffer</a> () const <li>void <a class="el" href="class_cadaptivehuffman.html#a7">InitDecompressor</a> (int bits, const char *buffer) <li>int <a class="el" href="class_cadaptivehuffman.html#a8">GetValue</a> () <li>void <a class="el" href="class_cadaptivehuffman.html#a9">PrintTree</a> () <li>void <a class="el" href="class_cadaptivehuffman.html#a10">PrintAncestors</a> () </ul> <hr><a name="_details"></a><h2>Detailed Description</h2> An adaptive Huffman encoder in C++. <p> <p> This probably isn't the fastest implementation around, but at least this code is (hopefully) a lot easier to understand than, for example, the JPEG Huffman encoder (which is static anyway). <p> This class has an extra for the compressor: it allows you to set marks in the compressed bitstream. This is useful if you want to add a group of values that belong together, but you don't know a priori if they will fit in the remaining bufferspace. By setting a mark after each succesfull group you can be assured you don't end up with half groups (and you don't waste space in the buffer either). <p> <hr><h2>Member Enumeration Documentation</h2> <a name="s3" doxytag="CAdaptiveHuffman::@5"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> anonymous enum </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> <dl compact><dt> <b>Enumeration values:</b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><a name="s3s0" doxytag="ValueOutOfBounds"></a><em>ValueOutOfBounds</em> </td><td> </td></tr> <tr><td valign=top><a name="s3s1" doxytag="BufferFull"></a><em>BufferFull</em> </td><td> </td></tr> <tr><td valign=top><a name="s3s2" doxytag="EndOfFile"></a><em>EndOfFile</em> </td><td> </td></tr> </table> </dl> </td> </tr> </table> <hr><h2>Constructor & Destructor Documentation</h2> <a name="a0" doxytag="CAdaptiveHuffman::CAdaptiveHuffman"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> CAdaptiveHuffman::CAdaptiveHuffman ( </b></td> <td valign="bottom"><b> int <em>max_values</em> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> constructor. <p> <dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>max_values</em> </td><td> The number of values being used for compression <p> </td></tr> </table> </dl>This initializes the encoder/decoder. With \i max_values you specify the maximum number of different symbols you want to encode. This number cannot be changed later! </td> </tr> </table> <a name="a1" doxytag="CAdaptiveHuffman::~CAdaptiveHuffman"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> CAdaptiveHuffman::~CAdaptiveHuffman ( </b></td> <td valign="bottom"><b> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <hr><h2>Member Function Documentation</h2> <a name="a3" doxytag="CAdaptiveHuffman::AddValue"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> int CAdaptiveHuffman::AddValue ( </b></td> <td valign="bottom"><b> int <em>v</em> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <a name="a5" doxytag="CAdaptiveHuffman::GetBits"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> int CAdaptiveHuffman::GetBits ( </b></td> <td valign="bottom"><b> ) const </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Return number of bits in (marked) buffer. <p> <p> This returns the number of <b>bits</b> that are used in the buffer. In case of marks, returns the number in the buffer at the last call to <a class="el" href="class_cadaptivehuffman.html#a4">Mark</a>(). </td> </tr> </table> <a name="a6" doxytag="CAdaptiveHuffman::GetBuffer"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> const char* CAdaptiveHuffman::GetBuffer ( </b></td> <td valign="bottom"><b> ) const </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <a name="a8" doxytag="CAdaptiveHuffman::GetValue"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> int CAdaptiveHuffman::GetValue ( </b></td> <td valign="bottom"><b> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <a name="a2" doxytag="CAdaptiveHuffman::InitCompressor"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> void CAdaptiveHuffman::InitCompressor ( </b></td> <td valign="bottom"><b> int <em>buffer_size</em>, </b></td> </tr> <tr> <td></td> <td><b> char <em>use_marks</em> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> <dl compact><dt> <b>Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>buffer_size</em> </td><td> Size in <b>bytes</b> </td></tr> <tr><td valign=top><em>use_marks</em> </td><td> flag: use marks in bitstream <p> </td></tr> </table> </dl>When the <b>use_marks</b> parameter is set to non-zero, the Compressor uses marks in the stream. Each time you call <a class="el" href="class_cadaptivehuffman.html#a4">Mark</a>() the internal bitpointer is advanced to the current bit position. When <b>use_marks</b> is 0, no marking is done and the bitpointer is always at the end of the buffer. </td> </tr> </table> <a name="a7" doxytag="CAdaptiveHuffman::InitDecompressor"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> void CAdaptiveHuffman::InitDecompressor ( </b></td> <td valign="bottom"><b> int <em>bits</em>, </b></td> </tr> <tr> <td></td> <td><b> const char * <em>buffer</em> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <a name="a4" doxytag="CAdaptiveHuffman::Mark"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> void CAdaptiveHuffman::Mark ( </b></td> <td valign="bottom"><b> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Set bit position marker. <p> </td> </tr> </table> <a name="a10" doxytag="CAdaptiveHuffman::PrintAncestors"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> void CAdaptiveHuffman::PrintAncestors ( </b></td> <td valign="bottom"><b> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <a name="a9" doxytag="CAdaptiveHuffman::PrintTree"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td nowrap valign="top"><b> void CAdaptiveHuffman::PrintTree ( </b></td> <td valign="bottom"><b> ) </b></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <hr>The documentation for this class was generated from the following files:<ul> <li><a class="el" href="adaptivehuffman_cc.html">AdaptiveHuffman.cc</a><li><a class="el" href="adaptivehuffman_h-source.html">AdaptiveHuffman.h</a></ul> <hr><address><small>Generated at Sat May 18 02:56:55 2002 for Camstream by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.gif" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.6 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>, © 1997-2001</small></address> </body> </html>