\hypertarget{compress_8c}{
\section{compress.c File Reference}
\label{compress_8c}\index{compress.c@{compress.c}}
}
Routines acting upon the compression structure. 

{\tt \#include \char`\"{}LSEC/LSEC\_\-msgs.h\char`\"{}}\par
{\tt \#include \char`\"{}compress\_\-p.h\char`\"{}}\par
{\tt \#include \char`\"{}LDT/APM.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/MBA.h\char`\"{}}\par
{\tt \#include \char`\"{}MSG/MSG\_\-pubdefs.h\char`\"{}}\par
{\tt \#include $<$string.h$>$}\par


Include dependency graph for compress.c:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=240pt]{compress_8c__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{CompactItemize}
\item 
static unsigned $\ast$ \hyperlink{compress_8c_a0}{addwrd} (unsigned $\ast$buffer, unsigned $\ast$bcnt, unsigned word, unsigned nbits)
\begin{CompactList}\small\item\em Add bits to a buffer. \item\end{CompactList}\item 
\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ \hyperlink{compress_8c_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_8c_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_8c_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_8c_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_8c_a5}{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_8c_a6}{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_8c_a7}{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_8c_a8}{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_8c_a9}{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 
size\_\-t \hyperlink{compress_8c_a10}{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}\item 
void \hyperlink{compress_8c_a11}{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}\end{CompactItemize}


\subsection{Detailed Description}
Routines acting upon the compression structure. 

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


\subsection{Function Documentation}
\hypertarget{compress_8c_a0}{
\index{compress.c@{compress.c}!addwrd@{addwrd}}
\index{addwrd@{addwrd}!compress.c@{compress.c}}
\subsubsection[addwrd]{\setlength{\rightskip}{0pt plus 5cm}unsigned $\ast$ addwrd (unsigned $\ast$ {\em buffer}, unsigned $\ast$ {\em bcnt}, unsigned {\em word}, unsigned {\em nbits})\hspace{0.3cm}{\tt  \mbox{[}inline, static\mbox{]}}}}
\label{compress_8c_a0}


Add bits to a buffer. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buffer}]Pointer to the current word in the buffer \item[{\em bcnt}]Number of bits already used in the current word \item[{\em word}]Word to add to the buffer \item[{\em nbits}]Number of bits from the word to add to the buffer \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to the next word to use in the buffer\end{Desc}
\hypertarget{compress_8c_a4}{
\index{compress.c@{compress.c}!LSEC_checkCompression@{LSEC\_\-checkCompression}}
\index{LSEC_checkCompression@{LSEC\_\-checkCompression}!compress.c@{compress.c}}
\subsubsection[LSEC\_\-checkCompression]{\setlength{\rightskip}{0pt plus 5cm}unsigned LSEC\_\-check\-Compression (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ {\em cpr})}}
\label{compress_8c_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_8c_a3}{
\index{compress.c@{compress.c}!LSEC_clearCompression@{LSEC\_\-clearCompression}}
\index{LSEC_clearCompression@{LSEC\_\-clearCompression}!compress.c@{compress.c}}
\subsubsection[LSEC\_\-clearCompression]{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-clear\-Compression (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ {\em cpr})}}
\label{compress_8c_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_8c_a2}{
\index{compress.c@{compress.c}!LSEC_deleteCompression@{LSEC\_\-deleteCompression}}
\index{LSEC_deleteCompression@{LSEC\_\-deleteCompression}!compress.c@{compress.c}}
\subsubsection[LSEC\_\-deleteCompression]{\setlength{\rightskip}{0pt plus 5cm}void LSEC\_\-delete\-Compression (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ {\em cpr})}}
\label{compress_8c_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_8c_a6}{
\index{compress.c@{compress.c}!LSEC_getBin@{LSEC\_\-getBin}}
\index{LSEC_getBin@{LSEC\_\-getBin}!compress.c@{compress.c}}
\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_8c_a6}


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_8c_a7}{
\index{compress.c@{compress.c}!LSEC_getCount@{LSEC\_\-getCount}}
\index{LSEC_getCount@{LSEC\_\-getCount}!compress.c@{compress.c}}
\subsubsection[LSEC\_\-getCount]{\setlength{\rightskip}{0pt plus 5cm}unsigned int LSEC\_\-get\-Count (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ {\em cpr})}}
\label{compress_8c_a7}


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_8c_a1}{
\index{compress.c@{compress.c}!LSEC_newCompression@{LSEC\_\-newCompression}}
\index{LSEC_newCompression@{LSEC\_\-newCompression}!compress.c@{compress.c}}
\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_8c_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_8c_a9}{
\index{compress.c@{compress.c}!LSEC_pack@{LSEC\_\-pack}}
\index{LSEC_pack@{LSEC\_\-pack}!compress.c@{compress.c}}
\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_8c_a9}


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_8c_a10}{
\index{compress.c@{compress.c}!LSEC_packedSize32@{LSEC\_\-packedSize32}}
\index{LSEC_packedSize32@{LSEC\_\-packedSize32}!compress.c@{compress.c}}
\subsubsection[LSEC\_\-packedSize32]{\setlength{\rightskip}{0pt plus 5cm}size\_\-t LSEC\_\-packed\-Size32 (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ {\em cpr})}}
\label{compress_8c_a10}


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_8c_a8}{
\index{compress.c@{compress.c}!LSEC_process@{LSEC\_\-process}}
\index{LSEC_process@{LSEC\_\-process}!compress.c@{compress.c}}
\subsubsection[LSEC\_\-process]{\setlength{\rightskip}{0pt plus 5cm}unsigned LSEC\_\-process (\hyperlink{structLSEC__compression__}{LSEC\_\-compression} $\ast$ {\em cpr})}}
\label{compress_8c_a8}


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_8c_a11}{
\index{compress.c@{compress.c}!LSEC_reportCompression@{LSEC\_\-reportCompression}}
\index{LSEC_reportCompression@{LSEC\_\-reportCompression}!compress.c@{compress.c}}
\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_8c_a11}


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_8c_a5}{
\index{compress.c@{compress.c}!LSEC_zeroBin@{LSEC\_\-zeroBin}}
\index{LSEC_zeroBin@{LSEC\_\-zeroBin}!compress.c@{compress.c}}
\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_8c_a5}


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}
