\hypertarget{HUFF_8c}{
\section{HUFF.c File Reference}
\label{HUFF_8c}\index{HUFF.c@{HUFF.c}}
}
Huffman Encode/Decode, implementation file.  


{\tt \#include $<$limits.h$>$}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$string.h$>$}\par
{\tt \#include \char`\"{}LDT/HUFF.h\char`\"{}}\par
{\tt \#include \char`\"{}LDT/BTREE.h\char`\"{}}\par
{\tt \#include \char`\"{}LDT/HEAP.h\char`\"{}}\par


Include dependency graph for HUFF.c:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=248pt]{HUFF_8c__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{HUFF_8c_a0}{HUFF\_\-accumulate} (int $\ast$freqs, const unsigned char $\ast$original, int size)
\begin{CompactList}\small\item\em Accumulates the frequency distribution. \item\end{CompactList}\item 
int \hyperlink{HUFF_8c_a1}{HUFF\_\-build} (\hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$table, const int $\ast$freqs, int count)
\begin{CompactList}\small\item\em Builds a Huffman code table from the input frequency distribution. \item\end{CompactList}\item 
int \hyperlink{HUFF_8c_a2}{HUFF\_\-compress} (const unsigned char $\ast$original, int size, const \hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$table, unsigned char $\ast$$\ast$compressed)
\begin{CompactList}\small\item\em Compresses the input array {\em original\/} into the output array. \item\end{CompactList}\item 
int \hyperlink{HUFF_8c_a3}{HUFF\_\-uncompress} (const unsigned char $\ast$compressed, unsigned char $\ast$$\ast$original)
\begin{CompactList}\small\item\em Decompresses the input byte stream {\em compressed\/}. \item\end{CompactList}\item 
int \hyperlink{HUFF_8c_a4}{HUFF\_\-size} (const \hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$table, const int $\ast$freqs, int count)
\begin{CompactList}\small\item\em Computes the size, in bits, of the specified encode {\em freqs\/}. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Huffman Encode/Decode, implementation 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{Function Documentation}
\hypertarget{HUFF_8c_a0}{
\index{HUFF.c@{HUFF.c}!HUFF_accumulate@{HUFF\_\-accumulate}}
\index{HUFF_accumulate@{HUFF\_\-accumulate}!HUFF.c@{HUFF.c}}
\subsubsection[HUFF\_\-accumulate]{\setlength{\rightskip}{0pt plus 5cm}void HUFF\_\-accumulate (int $\ast$ {\em freqs}, const unsigned char $\ast$ {\em original}, int {\em size})}}
\label{HUFF_8c_a0}


Accumulates the frequency distribution. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em freqs}]The accumulated and appropriately scaled frequency distribution. Must be at 256 characters in width \item[{\em original}]The input set of characters. The distribution is created from this set \item[{\em size}]The number of characters in {\em original\/} \end{description}
\end{Desc}
\hypertarget{HUFF_8c_a1}{
\index{HUFF.c@{HUFF.c}!HUFF_build@{HUFF\_\-build}}
\index{HUFF_build@{HUFF\_\-build}!HUFF.c@{HUFF.c}}
\subsubsection[HUFF\_\-build]{\setlength{\rightskip}{0pt plus 5cm}int HUFF\_\-build (\hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$ {\em table}, const int $\ast$ {\em freqs}, int {\em count})}}
\label{HUFF_8c_a1}


Builds a Huffman code table from the input frequency distribution. 

\begin{Desc}
\item[Returns:]Status\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em table}]The table, must have at least {\em count\/} elements \item[{\em freqs}]The frequency distribution \item[{\em count}]The number of elements in the frequency distribution \end{description}
\end{Desc}


Here is the call graph for this function:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=316pt]{HUFF_8c_a1_cgraph}
\end{center}
\end{figure}
\hypertarget{HUFF_8c_a2}{
\index{HUFF.c@{HUFF.c}!HUFF_compress@{HUFF\_\-compress}}
\index{HUFF_compress@{HUFF\_\-compress}!HUFF.c@{HUFF.c}}
\subsubsection[HUFF\_\-compress]{\setlength{\rightskip}{0pt plus 5cm}int HUFF\_\-compress (const unsigned char $\ast$ {\em original}, int {\em size}, const \hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$ {\em table}, unsigned char $\ast$$\ast$ {\em compressed})}}
\label{HUFF_8c_a2}


Compresses the input array {\em original\/} into the output array. 

\begin{Desc}
\item[Returns:]Size of the compressed data in bytes.\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em original}]The array of bytes to compress \item[{\em size}]The number of bytes in original to compress \item[{\em table}]A previously built Huffman table used to encode the data \item[{\em compressed}]Returned as a pointer to the compressed data \end{description}
\end{Desc}
\hypertarget{HUFF_8c_a4}{
\index{HUFF.c@{HUFF.c}!HUFF_size@{HUFF\_\-size}}
\index{HUFF_size@{HUFF\_\-size}!HUFF.c@{HUFF.c}}
\subsubsection[HUFF\_\-size]{\setlength{\rightskip}{0pt plus 5cm}int HUFF\_\-size (const \hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$ {\em table}, const int $\ast$ {\em freqs}, int {\em count})}}
\label{HUFF_8c_a4}


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 table}]The table, must have at least {\em count\/} elements \item[{\em freqs}]The frequency distribution \item[{\em count}]The number of elements in the frequency distribution \end{description}
\end{Desc}
\hypertarget{HUFF_8c_a3}{
\index{HUFF.c@{HUFF.c}!HUFF_uncompress@{HUFF\_\-uncompress}}
\index{HUFF_uncompress@{HUFF\_\-uncompress}!HUFF.c@{HUFF.c}}
\subsubsection[HUFF\_\-uncompress]{\setlength{\rightskip}{0pt plus 5cm}int HUFF\_\-uncompress (const unsigned char $\ast$ {\em compressed}, unsigned char $\ast$$\ast$ {\em original})}}
\label{HUFF_8c_a3}


Decompresses the input byte stream {\em compressed\/}. 

\begin{Desc}
\item[Returns:]The number of decompressed bytes, {\em i.e\/}. the size of original\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em compressed}]The compressed bit stream \item[{\em original}]Returned as a pointer to the decompressed data \end{description}
\end{Desc}


Here is the call graph for this function:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=343pt]{HUFF_8c_a3_cgraph}
\end{center}
\end{figure}
