\hypertarget{HUFF_8h}{
\section{HUFF.h File Reference}
\label{HUFF_8h}\index{HUFF.h@{HUFF.h}}
}
Huffman Encode/Decode, interface file. 

{\tt \#include \char`\"{}PBI/Endianness.h\char`\"{}}\par


Include dependency graph for HUFF.h:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=65pt]{HUFF_8h__incl}
\end{center}
\end{figure}


This graph shows which files directly or indirectly include this file:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=107pt]{HUFF_8h__dep__incl}
\end{center}
\end{figure}
\subsection*{Classes}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__HUFF__code}{\_\-HUFF\_\-code}
\begin{CompactList}\small\item\em Structure to contain the Huffman code, both the bit pattern and its length. \item\end{CompactList}\item 
struct \hyperlink{struct__HUFF__symbol__bf}{\_\-HUFF\_\-symbol\_\-bf}
\begin{CompactList}\small\item\em The information associate with a decoded symbol. \item\end{CompactList}\item 
union \textbf{\_\-HUFF\_\-symbol}
\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define \hyperlink{HUFF_8h_dc6ecdb2dff57e96f84c72bae32ce50f}{HUFF\_\-N\_\-WA}(\_\-cnt)~(HUFF\_\-N\_\-HEAP(\_\-cnt) + HUFF\_\-N\_\-PARENTS(\_\-cnt))
\begin{CompactList}\small\item\em Gives the number of elements needed by the temporary {\em wa\/} array based of the number of elements in the frequency table. \item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{HUFF_8h_91dfc31a94bd0da3118bc885bfe6c041}{
typedef struct \hyperlink{struct__HUFF__dtable}{\_\-HUFF\_\-dtable} \hyperlink{HUFF_8h_91dfc31a94bd0da3118bc885bfe6c041}{HUFF\_\-dtable}}
\label{HUFF_8h_91dfc31a94bd0da3118bc885bfe6c041}

\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__HUFF__dtable}{\_\-HUFF\_\-dtable}. \item\end{CompactList}\item 
\hypertarget{HUFF_8h_c98820bb6e5ecd08134fb3b9e792f0cf}{
typedef struct \hyperlink{struct__HUFF__code}{\_\-HUFF\_\-code} \hyperlink{HUFF_8h_c98820bb6e5ecd08134fb3b9e792f0cf}{HUFF\_\-code}}
\label{HUFF_8h_c98820bb6e5ecd08134fb3b9e792f0cf}

\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__HUFF__code}{\_\-HUFF\_\-code}. \item\end{CompactList}\item 
\hypertarget{HUFF_8h_6441f4b0b03e75c3924a787ea0a7b1f6}{
typedef struct \hyperlink{struct__HUFF__symbol__bf}{\_\-HUFF\_\-symbol\_\-bf} \textbf{HUFF\_\-symbol\_\-bf}}
\label{HUFF_8h_6441f4b0b03e75c3924a787ea0a7b1f6}

\item 
\hypertarget{HUFF_8h_c745bb09771244e616843aa1e2aa2f61}{
typedef union \_\-HUFF\_\-symbol \textbf{HUFF\_\-symbol}}
\label{HUFF_8h_c745bb09771244e616843aa1e2aa2f61}

\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
int \hyperlink{HUFF_8h_ccfbd4f40b606da6a3a74e5f12626ca4}{HUFF\_\-build} (\hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$codes, const unsigned int $\ast$freqs, int count, unsigned int $\ast$wa)
\begin{CompactList}\small\item\em Builds the code table directly from the specified frequency array. \item\end{CompactList}\item 
int \hyperlink{HUFF_8h_58233c951f215ab20304852ce5cb49de}{HUFF\_\-buildDense} (\hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$codes, const unsigned int $\ast$freq, const unsigned int $\ast$valid, int nvalid, unsigned int $\ast$wa)
\begin{CompactList}\small\item\em Builds a dense list, that is the resulting code list is indexed in a space that is dense in the valid element numbering scheme. \item\end{CompactList}\item 
int \hyperlink{HUFF_8h_037ddc45e9c98a5407bdc8bf1e1151d3}{HUFF\_\-buildSparse} (\hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$codes, const unsigned int $\ast$freq, const unsigned int $\ast$valid, int nvalid, unsigned int $\ast$wa)
\begin{CompactList}\small\item\em Builds a sparse code list. That is the resulting code list is indexed in the same manner as the {\em frequency\/} array. Contrast this with HUFF\_\-buildDense, where the resulting code list is indexed in the same manner as the {\em valid\/} array. Note that because the non-valid elements are not filled in, it is the caller's responsibility to avoid accessing these elements. \item\end{CompactList}\item 
int \hyperlink{HUFF_8h_be84233a6da3a3de64eee523da15f053}{HUFF\_\-bcompress} (void $\ast$out, unsigned int boff, void $\ast$max, const \hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$codes, const unsigned char $\ast$in, int cnt, int $\ast$unencoded)
\begin{CompactList}\small\item\em Convenience routine to compress a byte stream. \item\end{CompactList}\item 
int \hyperlink{HUFF_8h_372f0ddbeb8ff9168a5963008d5f86af}{HUFF\_\-size} (const \hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$codes, const unsigned int $\ast$freqs, int count)
\begin{CompactList}\small\item\em Computes the size, in bits, of the specified encode {\em freqs\/}. \item\end{CompactList}\item 
int \hyperlink{HUFF_8h_15688c1c9947c4eba7ff93493c04610a}{HUFF\_\-sizeDense} (const \hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$codes, const unsigned int $\ast$freq, const unsigned int $\ast$valid, int nvalid)
\begin{CompactList}\small\item\em Sizes the given frequency array using the specified code list. the code list is a dense list of the valid members. The valid members are specified either by the non-zero elements in the frequency array or the {\em valid\/} array. \item\end{CompactList}\item 
int \hyperlink{HUFF_8h_d7eb3a733f5405409eb316733f8230f2}{HUFF\_\-sizeSparse} (const \hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$codes, const unsigned int $\ast$freq, const unsigned int $\ast$valid, int nvalid)
\begin{CompactList}\small\item\em Sizes the given frequency array using the specified code list. the code list is a sparse list of the valid members. The valid members are specified either by the non-zero elements in the frequency array or the {\em valid\/} array. \item\end{CompactList}\item 
int \hyperlink{HUFF_8h_870e1bc28de3b706de6208d6961dd65f}{HUFF\_\-dtableSizeof} (int nsymbols)
\begin{CompactList}\small\item\em Returns the size, in bytes, of the decoding table needed for the specified number of symbols. \item\end{CompactList}\item 
void \hyperlink{HUFF_8h_e4b5dc96c807fb8f3065449d1a97e8f2}{HUFF\_\-dtableBuild} (\hyperlink{struct__HUFF__dtable}{HUFF\_\-dtable} $\ast$dtable, const unsigned char $\ast$sym\_\-lens, int nsymbols)
\begin{CompactList}\small\item\em Construct a decoding table based on the lengths of symbols This constructs the huffman codes in the canonical form. \item\end{CompactList}\item 
void \hyperlink{HUFF_8h_d2e53a00098e7134ec8332cbd443d2a4}{HUFF\_\-dtableBiase} (\hyperlink{struct__HUFF__dtable}{HUFF\_\-dtable} $\ast$dtable, int biase)
\begin{CompactList}\small\item\em Biases a previously constructed table by the amount specified. That is, an unbiased symbol value of 0, will be biased to the value specified by {\em biase\/}. \item\end{CompactList}\item 
void \hyperlink{HUFF_8h_1e40321f0fa4df9be901f1db55cab4fa}{HUFF\_\-dtablePrint} (const \hyperlink{struct__HUFF__dtable}{HUFF\_\-dtable} $\ast$dtable)
\begin{CompactList}\small\item\em Provides an ASCII display of the decoding table. This is usually for debugging or diagnostic purposes. \item\end{CompactList}\item 
unsigned int \hyperlink{HUFF_8h_b4deebcc18aac7969d7e1aef18d388f2}{HUFF\_\-decode} (const \hyperlink{struct__HUFF__dtable}{HUFF\_\-dtable} $\ast$dtable, const unsigned int $\ast$src, unsigned int boff)
\begin{CompactList}\small\item\em Decodes one symbol from the input bit source. \item\end{CompactList}\item 
int \hyperlink{HUFF_8h_524bd49dc5653b1924499d439d400a8d}{HUFF\_\-decompressBytes} (unsigned char $\ast$dst, int cnt, const void $\ast$src, unsigned int boff, const \hyperlink{struct__HUFF__dtable}{HUFF\_\-dtable} $\ast$dtable)
\begin{CompactList}\small\item\em Convenience routine to decode a bit stream using the specified table into a byte array. \item\end{CompactList}\item 
int \hyperlink{HUFF_8h_94ac47ed654c7797b5bd186613834a6e}{HUFF\_\-decompressShorts} (unsigned short int $\ast$dst, int cnt, const void $\ast$src, unsigned int boff, const \hyperlink{struct__HUFF__dtable}{HUFF\_\-dtable} $\ast$dtable)
\begin{CompactList}\small\item\em Convenience routine to decode a bit stream using the specified table into a unsigned short array. \item\end{CompactList}\item 
int \hyperlink{HUFF_8h_77158e9c770689fe40d4bd7fe6a08648}{HUFF\_\-decompressLongs} (unsigned int $\ast$dst, int cnt, const void $\ast$src, unsigned int boff, const \hyperlink{struct__HUFF__dtable}{HUFF\_\-dtable} $\ast$dtable)
\begin{CompactList}\small\item\em Convenience routine to decode a bit stream using the specified table into a unsigned short array. \item\end{CompactList}\item 
void \hyperlink{HUFF_8h_1bcc57a1fabd673b396a83a13e726d77}{HUFF\_\-codesPrint} (const \hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$codes, int ncodes)
\begin{CompactList}\small\item\em Prints an ASCII display of the specified {\em codes\/}. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Huffman Encode/Decode, interface file. 

\begin{Desc}
\item[Author:]JJRussell - \href{mailto:russell@slac.stanford.edu}{\tt russell@slac.stanford.edu}\end{Desc}


\footnotesize\begin{verbatim}

CVS $Id
\end{verbatim}
\normalsize


\begin{Desc}
\item[Warning:]In their current state, these routines are not fit for Flight use. They can be used to determine compression factors and, in general, study the properties of Huffman encoding/decoding. However, they malloc all over the place and involve recursive calling techniques, neither of is appropriate for Flight code. \end{Desc}


\subsection{Define Documentation}
\hypertarget{HUFF_8h_dc6ecdb2dff57e96f84c72bae32ce50f}{
\index{HUFF.h@{HUFF.h}!HUFF_N_WA@{HUFF\_\-N\_\-WA}}
\index{HUFF_N_WA@{HUFF\_\-N\_\-WA}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define HUFF\_\-N\_\-WA(\_\-cnt)~(HUFF\_\-N\_\-HEAP(\_\-cnt) + HUFF\_\-N\_\-PARENTS(\_\-cnt))}}
\label{HUFF_8h_dc6ecdb2dff57e96f84c72bae32ce50f}


Gives the number of elements needed by the temporary {\em wa\/} array based of the number of elements in the frequency table. 

\begin{Desc}
\item[Returns:]The number of elements needed by the temporary {\em wa\/} array\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-cnt}]The number of elements in the frequency table. \end{description}
\end{Desc}


\subsection{Function Documentation}
\hypertarget{HUFF_8h_be84233a6da3a3de64eee523da15f053}{
\index{HUFF.h@{HUFF.h}!HUFF_bcompress@{HUFF\_\-bcompress}}
\index{HUFF_bcompress@{HUFF\_\-bcompress}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int HUFF\_\-bcompress (void $\ast$ {\em out}, unsigned int {\em boff}, void $\ast$ {\em max}, const {\bf HUFF\_\-code} $\ast$ {\em codes}, const unsigned char $\ast$ {\em in}, int {\em cnt}, int $\ast$ {\em unencoded})}}
\label{HUFF_8h_be84233a6da3a3de64eee523da15f053}


Convenience routine to compress a byte stream. 

\begin{Desc}
\item[Returns:]The number of bits needed to encoded the byte stream. If negative the all the symbols could not be encoded and {\em unencoded\/} should be checked for the count of those symbols not encoded. This number will represent negative the number of bits used to encode the symbols that would fit.\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em out}]The output buffer \item[{\em boff}]The current bit offset \item[{\em max}]The maximum output address (actually 1 byte past it) \item[{\em codes}]The array of codes \item[{\em in}]The input buffer of symbols. \item[{\em cnt}]The number of input symbols. \item[{\em unencoded}]The number of input symbols left to encode. If successful this will be 0. \end{description}
\end{Desc}
\hypertarget{HUFF_8h_ccfbd4f40b606da6a3a74e5f12626ca4}{
\index{HUFF.h@{HUFF.h}!HUFF_build@{HUFF\_\-build}}
\index{HUFF_build@{HUFF\_\-build}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int HUFF\_\-build ({\bf HUFF\_\-code} $\ast$ {\em codes}, const unsigned int $\ast$ {\em freq}, int {\em cnt}, unsigned int $\ast$ {\em wa})}}
\label{HUFF_8h_ccfbd4f40b606da6a3a74e5f12626ca4}


Builds the code table directly from the specified frequency array. 

\begin{Desc}
\item[Returns:]The number of valid codes. If this number $<$= 1, no valid code array exist. This happens if the input distribution has only 0 or 1 valid entries. Such a distribution has 0 entropy, and, therefore, needs no bits to encode.\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em codes}]The code table to be populated.\item[{\em freq}]The frequency table.\item[{\em cnt}]The number of entries in the frequency table and, by implication, the code table.\item[{\em wa}]A temporary work area of size with at least \hyperlink{HUFF_8h_dc6ecdb2dff57e96f84c72bae32ce50f}{HUFF\_\-N\_\-WA(nvalid)} elements available where nvalid is the number of non-zero entries in the frequency table. For documentation and planning purposes, this is 2 $\ast$ nvalid elements. To keep your code compile-time safe, please use the macro.\end{description}
\end{Desc}
\begin{Desc}
\item[Note:]Any 0 count elements in the frequency table will be considered to be invalid. While the code array will be dimensioned from 0 ot {\em cnt\/}, only those elements that correspond to non-zero elements in the frequency table will have valid entries. If the user wishes to fill these code values with 0, he may do so, but only {\em after\/} the codes have been filled in. (This routine reserves the right to use the code array as a temporary working area in order to decrease memory requirements.\end{Desc}
\begin{Desc}
\item[]If one has an array that gives the valid elements, consider using HUFF\_\-buildSparse. If has a reverse lookup table, (i.e. an array that gives an index that is dense in the valid element number space, consider using HUFF\_\-buildDense. This will produce a table that number in the dense space of only valid elements. Doing this can save a lookup during the encoding process.\end{Desc}
\begin{Desc}
\item[]Typical usage would be\end{Desc}


\begin{Code}\begin{verbatim}  //
  // If some elements of the frequency array are 0, the working area
  // may be dimensioned smaller, however, by specifying the maximum 
  // possible, one can do this a compile-time, avoiding run-time 
  // allocations.
  //
  int        freq[30];
  HUFF_code codes[30];
  int          wa[HUFF_N_WA(30)];

  accumulate (freqs, ....);
  dcnt = HUFF_build (codes, freq, 30, wa);
\end{verbatim}
\end{Code}

 \hypertarget{HUFF_8h_58233c951f215ab20304852ce5cb49de}{
\index{HUFF.h@{HUFF.h}!HUFF_buildDense@{HUFF\_\-buildDense}}
\index{HUFF_buildDense@{HUFF\_\-buildDense}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int HUFF\_\-buildDense ({\bf HUFF\_\-code} $\ast$ {\em codes}, const unsigned int $\ast$ {\em freq}, const unsigned int $\ast$ {\em valid}, int {\em nvalid}, unsigned int $\ast$ {\em wa})}}
\label{HUFF_8h_58233c951f215ab20304852ce5cb49de}


Builds a dense list, that is the resulting code list is indexed in a space that is dense in the valid element numbering scheme. 

\begin{Desc}
\item[Returns:]The number of elements populated in the code array. If {\em valid\/} \begin{itemize}
\item NULL, then 0 count elements in the frequency array are considered invalid, and the count of non-0 frequency elements is returned.\item non-NULL, then the return value will be {\em nvalid\/}.\end{itemize}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em codes}]The code table to be populated.\item[{\em freq}]The frequency table. This area generally contains the number of elements specified by {\em nvalid\/} or the largest index in {\em valid\/}.\item[{\em valid}]An array of {\em nvalid\/} elements, giving the indices of the valid elements in the frequency array. If this is specified as NULL, although no storage is actually used, this routine's behaviour is as if this array contained indices to only the non-zero elements. Note that, if specified, no element of {\em valid\/} may reference a 0 count element in the frequency table.\item[{\em nvalid}]The number of entries in the {\em valid\/} table. If {\em valid\/} if specified as NULL, then this is taken to be the number values in the frequency table.\item[{\em wa}]A temporary work area of size with at least HUFF\_\-N\_\-WA({\em nvalid\/}) elements available. For documentation and planning purposes, this is 2 $\ast$ {\em nvalid\/} elements. To keep your code compile-time safe, please use the macros. \end{description}
\end{Desc}
\begin{Desc}
\item[]See the examples in HUFF\_\-build, which are identical with the exception of adding the {\em valid\/} array argument. \end{Desc}
\hypertarget{HUFF_8h_037ddc45e9c98a5407bdc8bf1e1151d3}{
\index{HUFF.h@{HUFF.h}!HUFF_buildSparse@{HUFF\_\-buildSparse}}
\index{HUFF_buildSparse@{HUFF\_\-buildSparse}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int HUFF\_\-buildSparse ({\bf HUFF\_\-code} $\ast$ {\em codes}, const unsigned int $\ast$ {\em freq}, const unsigned int $\ast$ {\em valid}, int {\em nvalid}, unsigned int $\ast$ {\em wa})}}
\label{HUFF_8h_037ddc45e9c98a5407bdc8bf1e1151d3}


Builds a sparse code list. That is the resulting code list is indexed in the same manner as the {\em frequency\/} array. Contrast this with HUFF\_\-buildDense, where the resulting code list is indexed in the same manner as the {\em valid\/} array. Note that because the non-valid elements are not filled in, it is the caller's responsibility to avoid accessing these elements. 

\begin{Desc}
\item[Returns:]The number of valid elements in the code array. If {\em valid\/} is specified as\begin{itemize}
\item NULL, then this is the number of non-zero elements in the frequency array.\item non-NULL, then this is nvalid.\end{itemize}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em codes}]The code table to be populated. Only those elements indexed by the valid table are populated.\item[{\em freq}]The frequency table. This array must contains the number of elements specified by {\em nvalid\/} or, if {\em valid\/} is non-NULL, the largest index in {\em valid\/}.\item[{\em valid}]An array of {\em nvalid\/} elements, giving the indices of the valid elements in the frequency array. If this is specified as NULL, although no storage is actually used, this routine's behaviour is as if this array contained indices to only the non-zero elements.\item[{\em nvalid}]The number of entries in the valid table. If {\em valid\/} is specified as NULL, then this value must be the total number elements in the {\em freq\/} array.\item[{\em wa}]A temporary work area of size with at least HUFF\_\-N\_\-WA({\em nvalid\/}) elements available. For documentation and planning purposes, this is 2 $\ast${\em nvalid\/} elements. To keep your code compile-time safe, please use the macros. \end{description}
\end{Desc}
\begin{Desc}
\item[]See the examples in HUFF\_\-build, which are identical with the exception of adding the {\em valid\/} array argument \end{Desc}
\hypertarget{HUFF_8h_1bcc57a1fabd673b396a83a13e726d77}{
\index{HUFF.h@{HUFF.h}!HUFF_codesPrint@{HUFF\_\-codesPrint}}
\index{HUFF_codesPrint@{HUFF\_\-codesPrint}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void HUFF\_\-codesPrint (const {\bf HUFF\_\-code} $\ast$ {\em codes}, int {\em ncodes})}}
\label{HUFF_8h_1bcc57a1fabd673b396a83a13e726d77}


Prints an ASCII display of the specified {\em codes\/}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em codes}]The array of codes to print \item[{\em ncodes}]The number of codes to print \end{description}
\end{Desc}
\hypertarget{HUFF_8h_b4deebcc18aac7969d7e1aef18d388f2}{
\index{HUFF.h@{HUFF.h}!HUFF_decode@{HUFF\_\-decode}}
\index{HUFF_decode@{HUFF\_\-decode}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\_\-\_\-inline unsigned int HUFF\_\-decode (const {\bf HUFF\_\-dtable} $\ast$ {\em dtable}, const unsigned int $\ast$ {\em src}, unsigned int {\em boff})}}
\label{HUFF_8h_b4deebcc18aac7969d7e1aef18d388f2}


Decodes one symbol from the input bit source. 

\begin{Desc}
\item[Returns:]A descriptor of the decoded symbol consisting of the value and the number of bits consumed from the bit string\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dtable}]The decoding table \item[{\em src}]The source buffer \item[{\em boff}]The bit offset into the source buffer \end{description}
\end{Desc}
\hypertarget{HUFF_8h_524bd49dc5653b1924499d439d400a8d}{
\index{HUFF.h@{HUFF.h}!HUFF_decompressBytes@{HUFF\_\-decompressBytes}}
\index{HUFF_decompressBytes@{HUFF\_\-decompressBytes}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int HUFF\_\-decompressBytes (unsigned char $\ast$ {\em dst}, int {\em cnt}, const void $\ast$ {\em src}, unsigned int {\em boff}, const {\bf HUFF\_\-dtable} $\ast$ {\em dtable})}}
\label{HUFF_8h_524bd49dc5653b1924499d439d400a8d}


Convenience routine to decode a bit stream using the specified table into a byte array. 

\begin{Desc}
\item[Returns:]The number of bits that were decoded\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dst}]The destination/output buffer \item[{\em cnt}]The number of symbols to decode \item[{\em src}]The encoded source/input buffer \item[{\em boff}]The bit offset to start at in the input buffer \item[{\em dtable}]The decoding table \end{description}
\end{Desc}
\hypertarget{HUFF_8h_77158e9c770689fe40d4bd7fe6a08648}{
\index{HUFF.h@{HUFF.h}!HUFF_decompressLongs@{HUFF\_\-decompressLongs}}
\index{HUFF_decompressLongs@{HUFF\_\-decompressLongs}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int HUFF\_\-decompressLongs (unsigned int $\ast$ {\em dst}, int {\em cnt}, const void $\ast$ {\em src}, unsigned int {\em boff}, const {\bf HUFF\_\-dtable} $\ast$ {\em dtable})}}
\label{HUFF_8h_77158e9c770689fe40d4bd7fe6a08648}


Convenience routine to decode a bit stream using the specified table into a unsigned short array. 

\begin{Desc}
\item[Returns:]The number of bits that were decoded\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dst}]The destination/output buffer \item[{\em cnt}]The number of symbols to decode \item[{\em src}]The encoded source/input buffer \item[{\em boff}]The bit offset to start at in the input buffer \item[{\em dtable}]The decoding table \end{description}
\end{Desc}
\hypertarget{HUFF_8h_94ac47ed654c7797b5bd186613834a6e}{
\index{HUFF.h@{HUFF.h}!HUFF_decompressShorts@{HUFF\_\-decompressShorts}}
\index{HUFF_decompressShorts@{HUFF\_\-decompressShorts}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int HUFF\_\-decompressShorts (unsigned short int $\ast$ {\em dst}, int {\em cnt}, const void $\ast$ {\em src}, unsigned int {\em boff}, const {\bf HUFF\_\-dtable} $\ast$ {\em dtable})}}
\label{HUFF_8h_94ac47ed654c7797b5bd186613834a6e}


Convenience routine to decode a bit stream using the specified table into a unsigned short array. 

\begin{Desc}
\item[Returns:]The number of bits that were decoded\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dst}]The destination/output buffer \item[{\em cnt}]The number of symbols to decode \item[{\em src}]The encoded source/input buffer \item[{\em boff}]The bit offset to start at in the input buffer \item[{\em dtable}]The decoding table \end{description}
\end{Desc}
\hypertarget{HUFF_8h_d2e53a00098e7134ec8332cbd443d2a4}{
\index{HUFF.h@{HUFF.h}!HUFF_dtableBiase@{HUFF\_\-dtableBiase}}
\index{HUFF_dtableBiase@{HUFF\_\-dtableBiase}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void HUFF\_\-dtableBiase ({\bf HUFF\_\-dtable} $\ast$ {\em dtable}, int {\em biase})}}
\label{HUFF_8h_d2e53a00098e7134ec8332cbd443d2a4}


Biases a previously constructed table by the amount specified. That is, an unbiased symbol value of 0, will be biased to the value specified by {\em biase\/}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dtable}]The decoding table to be built \item[{\em biase}]The biase value\end{description}
\end{Desc}
It is fairly common that the original symbols where encoded into a space from \mbox{[}0, nsymbols) from an original space \mbox{[}biase, nsymbols+biase). This routine allows the caller to reapply that biase so that the returned symbol value is in the original space, without looping over all the decoded symbols and reapplying the biase. \hypertarget{HUFF_8h_e4b5dc96c807fb8f3065449d1a97e8f2}{
\index{HUFF.h@{HUFF.h}!HUFF_dtableBuild@{HUFF\_\-dtableBuild}}
\index{HUFF_dtableBuild@{HUFF\_\-dtableBuild}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void HUFF\_\-dtableBuild ({\bf HUFF\_\-dtable} $\ast$ {\em dtable}, const unsigned char $\ast$ {\em sym\_\-lens}, int {\em nsym\_\-lens})}}
\label{HUFF_8h_e4b5dc96c807fb8f3065449d1a97e8f2}


Construct a decoding table based on the lengths of symbols This constructs the huffman codes in the canonical form. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dtable}]The decoding table to be built \item[{\em sym\_\-lens}]An array representing the lengths of each symbol \item[{\em nsym\_\-lens}]The number of symbol lengths \end{description}
\end{Desc}
\hypertarget{HUFF_8h_1e40321f0fa4df9be901f1db55cab4fa}{
\index{HUFF.h@{HUFF.h}!HUFF_dtablePrint@{HUFF\_\-dtablePrint}}
\index{HUFF_dtablePrint@{HUFF\_\-dtablePrint}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void HUFF\_\-dtablePrint (const {\bf HUFF\_\-dtable} $\ast$ {\em dtable})}}
\label{HUFF_8h_1e40321f0fa4df9be901f1db55cab4fa}


Provides an ASCII display of the decoding table. This is usually for debugging or diagnostic purposes. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dtable}]The decoding table to display \end{description}
\end{Desc}
\hypertarget{HUFF_8h_870e1bc28de3b706de6208d6961dd65f}{
\index{HUFF.h@{HUFF.h}!HUFF_dtableSizeof@{HUFF\_\-dtableSizeof}}
\index{HUFF_dtableSizeof@{HUFF\_\-dtableSizeof}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int HUFF\_\-dtableSizeof (int {\em nsymbols})}}
\label{HUFF_8h_870e1bc28de3b706de6208d6961dd65f}


Returns the size, in bytes, of the decoding table needed for the specified number of symbols. 

\begin{Desc}
\item[Returns:]The size, in bytes, of the decoding table needed for the specified number of symbols\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em nsymbols}]The number of symbols \end{description}
\end{Desc}
\hypertarget{HUFF_8h_372f0ddbeb8ff9168a5963008d5f86af}{
\index{HUFF.h@{HUFF.h}!HUFF_size@{HUFF\_\-size}}
\index{HUFF_size@{HUFF\_\-size}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int HUFF\_\-size (const {\bf HUFF\_\-code} $\ast$ {\em codes}, const unsigned int $\ast$ {\em freqs}, int {\em count})}}
\label{HUFF_8h_372f0ddbeb8ff9168a5963008d5f86af}


Computes the size, in bits, of the specified encode {\em freqs\/}. 

\begin{Desc}
\item[Returns:]The size in bits.\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em codes}]The code table, must be {\em count\/} in length \item[{\em freqs}]The frequency distribution, must be {\em count\/} in length \item[{\em count}]The number of elements in the frequency distribution and the code table. \end{description}
\end{Desc}
\hypertarget{HUFF_8h_15688c1c9947c4eba7ff93493c04610a}{
\index{HUFF.h@{HUFF.h}!HUFF_sizeDense@{HUFF\_\-sizeDense}}
\index{HUFF_sizeDense@{HUFF\_\-sizeDense}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int HUFF\_\-sizeDense (const {\bf HUFF\_\-code} $\ast$ {\em codes}, const unsigned int $\ast$ {\em freq}, const unsigned int $\ast$ {\em valid}, int {\em nvalid})}}
\label{HUFF_8h_15688c1c9947c4eba7ff93493c04610a}


Sizes the given frequency array using the specified code list. the code list is a dense list of the valid members. The valid members are specified either by the non-zero elements in the frequency array or the {\em valid\/} array. 

\begin{Desc}
\item[Returns:]The size, in bits, of the encoded distribution\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em codes}]The code table to use\item[{\em freq}]The frequency table.\end{description}
\end{Desc}
If {\em valid\/} array is non-zero, then this array is indexed by the validity array

If {\em valid\/} array is specified as NULL, then only the non-zero elements of {\em freq\/} are considered valid.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em valid}]An array of {\em nvalid\/} elements, giving the indices of the valid elements in the frequency array. This may be specified as NULL, in which case, only the non-zero elements of {\em freq\/} are considered valid and {\em nvalid\/} gives the length, not of the validity array, but of the frequency distribution.\item[{\em nvalid}]If {\em valid\/} is\begin{itemize}
\item Non-NULL, then this is the number of entries in the {\em valid\/} array.\par
\item NULL, then this is the number of elements in the frequency array. \end{itemize}
\end{description}
\end{Desc}
\hypertarget{HUFF_8h_d7eb3a733f5405409eb316733f8230f2}{
\index{HUFF.h@{HUFF.h}!HUFF_sizeSparse@{HUFF\_\-sizeSparse}}
\index{HUFF_sizeSparse@{HUFF\_\-sizeSparse}!HUFF.h@{HUFF.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int HUFF\_\-sizeSparse (const {\bf HUFF\_\-code} $\ast$ {\em codes}, const unsigned int $\ast$ {\em freq}, const unsigned int $\ast$ {\em valid}, int {\em nvalid})}}
\label{HUFF_8h_d7eb3a733f5405409eb316733f8230f2}


Sizes the given frequency array using the specified code list. the code list is a sparse list of the valid members. The valid members are specified either by the non-zero elements in the frequency array or the {\em valid\/} array. 

\begin{Desc}
\item[Returns:]The size, in bits, of the encoded distribution\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em codes}]The code table to use\item[{\em freq}]The frequency table.\end{description}
\end{Desc}
If {\em valid\/} array is non-zero, then this array is indexed by the validity array

If {\em valid\/} array is specified as NULL, then only the non-zero elements of {\em freq\/} are considered valid.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em valid}]An array of {\em nvalid\/} elements, giving the indices of the valid elements in the frequency array. This may be specified as NULL, in which case, only the non-zero elements of {\em freq\/} are considered valid and {\em nvalid\/} gives the length, not of the validity array, but of the frequency distribution.\item[{\em nvalid}]If {\em valid\/} is\begin{itemize}
\item Non-NULL, then this is the number of entries in the {\em valid\/} array.\item NULL, then this is the number of elements in the frequency array. \end{itemize}
\end{description}
\end{Desc}
