\hypertarget{compress_8h}{
\section{compress.h File Reference}
\label{compress_8h}\index{compress.h@{compress.h}}
}
The compression structure brings together all the tables required for the operation of the Arithmetic Probability Encoder and the various associated functions provided access to these tables. 

{\tt \#include $<$stdio.h$>$}\par


Include dependency graph for compress.h:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=96pt]{compress_8h__incl}
\end{center}
\end{figure}


This graph shows which files directly or indirectly include this file:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=219pt]{compress_8h__dep__incl}
\end{center}
\end{figure}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{compress_8h_a0}{
typedef \hyperlink{structLSEC__compression__}{LSEC\_\-compression\_\-} \hyperlink{compress_8h_a0}{LSEC\_\-compression}}
\label{compress_8h_a0}

\begin{CompactList}\small\item\em Declaration of the opaque compression structure. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ \hyperlink{compress_8h_a1}{LSEC\_\-new\-Compression} (unsigned int nbits, const char $\ast$name)
\begin{CompactList}\small\item\em Allocate and initialise a new compression structure. \item\end{CompactList}\item 
void \hyperlink{compress_8h_a2}{LSEC\_\-delete\-Compression} (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$cpr)
\begin{CompactList}\small\item\em Free the memory associated with the compression structure. \item\end{CompactList}\item 
void \hyperlink{compress_8h_a3}{LSEC\_\-clear\-Compression} (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$cpr)
\begin{CompactList}\small\item\em Clear the compression structrure of any data from a previous cycle. \item\end{CompactList}\item 
unsigned \hyperlink{compress_8h_a4}{LSEC\_\-check\-Compression} (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$cpr)
\begin{CompactList}\small\item\em Check if there were errors during the histogram or encode operations. \item\end{CompactList}\item 
void \hyperlink{compress_8h_a5}{LSEC\_\-report\-Compression} (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$cmp, FILE $\ast$fp)
\begin{CompactList}\small\item\em Describe the contents of the decompression structure in formatted ASCII send to the file {\em fp\/}. \item\end{CompactList}\item 
void \hyperlink{compress_8h_a6}{LSEC\_\-zero\-Bin} (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$cpr, unsigned int bin)
\begin{CompactList}\small\item\em Set the selected bin of the histogram to zero, indicating that this symbol will be selectively removed from the uncompressed data stream before encoding. \item\end{CompactList}\item 
unsigned int \hyperlink{compress_8h_a7}{LSEC\_\-get\-Bin} (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$cpr, unsigned int bin)
\begin{CompactList}\small\item\em Return the contents of one bin of the histogram. \item\end{CompactList}\item 
unsigned int \hyperlink{compress_8h_a8}{LSEC\_\-get\-Count} (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$cpr)
\begin{CompactList}\small\item\em Return the number of non-zero bins in the histogram. \item\end{CompactList}\item 
unsigned \hyperlink{compress_8h_a9}{LSEC\_\-process} (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$cpr)
\begin{CompactList}\small\item\em Build the lookup, frequency and probability tables required by the APE. \item\end{CompactList}\item 
unsigned $\ast$ \hyperlink{compress_8h_a10}{LSEC\_\-pack} (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$cpr, unsigned $\ast$buffer)
\begin{CompactList}\small\item\em Select sufficient data from the tables of the compression structure to be able to recreate the tables required to decompress the data, and pack it into the consignment. \item\end{CompactList}\item 
unsigned \hyperlink{compress_8h_a11}{LSEC\_\-packed\-Size32} (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$cpr)
\begin{CompactList}\small\item\em Calculate the number of 32 bit words required to hold the packed compression structure. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
The compression structure brings together all the tables required for the operation of the Arithmetic Probability Encoder and the various associated functions provided access to these tables. 

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


\subsection{Function Documentation}
\hypertarget{compress_8h_a4}{
\index{compress.h@{compress.h}!LSEC_checkCompression@{LSEC\_\-checkCompression}}
\index{LSEC_checkCompression@{LSEC\_\-checkCompression}!compress.h@{compress.h}}
\subsubsection[LSEC\_\-checkCompression]{\setlength{\rightskip}{0pt plus 5cm}unsigned LSEC\_\-check\-Compression (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ {\em cpr})}}
\label{compress_8h_a4}


Check if there were errors during the histogram or encode operations. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpr}]Pointer to a compression structure \end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LSEC\_\-SYMOOR}]If any of the symbols histogrammed or encoded by this compression structure were out of range \item[{\em LSEC\_\-AWEFAIL}]If there were any error during the encoding \item[{\em LSEC\_\-SUCCESS}]If there were no errors\end{description}
\end{Desc}
\hypertarget{compress_8h_a3}{
\index{compress.h@{compress.h}!LSEC_clearCompression@{LSEC\_\-clearCompression}}
\index{LSEC_clearCompression@{LSEC\_\-clearCompression}!compress.h@{compress.h}}
\subsubsection[LSEC\_\-clearCompression]{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-clear\-Compression (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ {\em cpr})}}
\label{compress_8h_a3}


Clear the compression structrure of any data from a previous cycle. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpr}]Pointer to an allocated, initialised, compression structure\end{description}
\end{Desc}
\hypertarget{compress_8h_a2}{
\index{compress.h@{compress.h}!LSEC_deleteCompression@{LSEC\_\-deleteCompression}}
\index{LSEC_deleteCompression@{LSEC\_\-deleteCompression}!compress.h@{compress.h}}
\subsubsection[LSEC\_\-deleteCompression]{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-delete\-Compression (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ {\em cpr})}}
\label{compress_8h_a2}


Free the memory associated with the compression structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpr}]Pointer to an allocated compression structure\end{description}
\end{Desc}
\hypertarget{compress_8h_a7}{
\index{compress.h@{compress.h}!LSEC_getBin@{LSEC\_\-getBin}}
\index{LSEC_getBin@{LSEC\_\-getBin}!compress.h@{compress.h}}
\subsubsection[LSEC\_\-getBin]{\setlength{\rightskip}{0pt plus 5cm}unsigned int LSEC\_\-get\-Bin (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ {\em cpr}, unsigned int {\em bin})}}
\label{compress_8h_a7}


Return the contents of one bin of the histogram. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpr}]Pointer to an allocated, initialised, populated, compression structure \item[{\em bin}]ID of one of the bins of the histogram \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Contents of the bin\end{Desc}
\hypertarget{compress_8h_a8}{
\index{compress.h@{compress.h}!LSEC_getCount@{LSEC\_\-getCount}}
\index{LSEC_getCount@{LSEC\_\-getCount}!compress.h@{compress.h}}
\subsubsection[LSEC\_\-getCount]{\setlength{\rightskip}{0pt plus 5cm}unsigned int LSEC\_\-get\-Count (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ {\em cpr})}}
\label{compress_8h_a8}


Return the number of non-zero bins in the histogram. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpr}]Pointer to a compression structure \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Number of non-zero bins in the histogram\end{Desc}
\hypertarget{compress_8h_a1}{
\index{compress.h@{compress.h}!LSEC_newCompression@{LSEC\_\-newCompression}}
\index{LSEC_newCompression@{LSEC\_\-newCompression}!compress.h@{compress.h}}
\subsubsection[LSEC\_\-newCompression]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{structLSEC__compression__}{LSEC\_\-compression}$\ast$ LSEC\_\-new\-Compression (unsigned int {\em nbits}, const char $\ast$ {\em name})}}
\label{compress_8h_a1}


Allocate and initialise a new compression structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em name}]String used in the reporting of error to identify a compression structure \item[{\em nbits}]Number of symbols in the complete range of possible symbols (including excluded internal sub-ranges), hence the number of bins in the histogram and frequency tables \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to an allocated and initialised LSEC\_\-compression structure\end{Desc}
The order of calling the functions presented here should be LSEC\_\-new\-Compression LSEC\_\-histogram - Repeat as necessary LSEC\_\-process LSEC\_\-pack LSEC\_\-compress - Repeat as necessary LSEC\_\-clear\-Compression : repeat as necessary : LSEC\_\-delete\-Compression\hypertarget{compress_8h_a10}{
\index{compress.h@{compress.h}!LSEC_pack@{LSEC\_\-pack}}
\index{LSEC_pack@{LSEC\_\-pack}!compress.h@{compress.h}}
\subsubsection[LSEC\_\-pack]{\setlength{\rightskip}{0pt plus 5cm}unsigned$\ast$ LSEC\_\-pack (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ {\em cpr}, unsigned $\ast$ {\em buffer})}}
\label{compress_8h_a10}


Select sufficient data from the tables of the compression structure to be able to recreate the tables required to decompress the data, and pack it into the consignment. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buffer}]Pointer to the start of the buffer to place the packed structure \item[{\em cpr}]Pointer to an initialised, populated and processed compression structure \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to the word after this compresion structure after packing\end{Desc}
\hypertarget{compress_8h_a11}{
\index{compress.h@{compress.h}!LSEC_packedSize32@{LSEC\_\-packedSize32}}
\index{LSEC_packedSize32@{LSEC\_\-packedSize32}!compress.h@{compress.h}}
\subsubsection[LSEC\_\-packedSize32]{\setlength{\rightskip}{0pt plus 5cm}unsigned LSEC\_\-packed\-Size32 (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ {\em cpr})}}
\label{compress_8h_a11}


Calculate the number of 32 bit words required to hold the packed compression structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpr}]Pointer to a compression structure \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Size of the packed compression structure\end{Desc}
\hypertarget{compress_8h_a9}{
\index{compress.h@{compress.h}!LSEC_process@{LSEC\_\-process}}
\index{LSEC_process@{LSEC\_\-process}!compress.h@{compress.h}}
\subsubsection[LSEC\_\-process]{\setlength{\rightskip}{0pt plus 5cm}unsigned LSEC\_\-process (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ {\em cpr})}}
\label{compress_8h_a9}


Build the lookup, frequency and probability tables required by the APE. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpr}]Pointer to an allocated, initialised, populated, compression structure \end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em LSEC\_\-SUCCESS}]If the processing goes well\end{description}
\end{Desc}
\hypertarget{compress_8h_a5}{
\index{compress.h@{compress.h}!LSEC_reportCompression@{LSEC\_\-reportCompression}}
\index{LSEC_reportCompression@{LSEC\_\-reportCompression}!compress.h@{compress.h}}
\subsubsection[LSEC\_\-reportCompression]{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-report\-Compression (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ {\em cmp}, FILE $\ast$ {\em fp})}}
\label{compress_8h_a5}


Describe the contents of the decompression structure in formatted ASCII send to the file {\em fp\/}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmp}]Pointer to the compression structure \item[{\em fp}]Pointer to the file used as the destination\end{description}
\end{Desc}
\hypertarget{compress_8h_a6}{
\index{compress.h@{compress.h}!LSEC_zeroBin@{LSEC\_\-zeroBin}}
\index{LSEC_zeroBin@{LSEC\_\-zeroBin}!compress.h@{compress.h}}
\subsubsection[LSEC\_\-zeroBin]{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-zero\-Bin (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ {\em cpr}, unsigned int {\em bin})}}
\label{compress_8h_a6}


Set the selected bin of the histogram to zero, indicating that this symbol will be selectively removed from the uncompressed data stream before encoding. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cpr}]Pointer to an allocated, initialised, populated, compression structure \item[{\em bin}]ID of one of the bins of the histogram\end{description}
\end{Desc}
