\hypertarget{APD_8c}{
\section{APD.c File Reference}
\label{APD_8c}\index{APD.c@{APD.c}}
}
Arithmetic Byte Decoder, implementation file.  


{\tt \#include \char`\"{}APC.h\char`\"{}}\par
{\tt \#include \char`\"{}LDT/APD.h\char`\"{}}\par


Include dependency graph for APD.c:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=83pt]{APD_8c__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{APD_8c_a0}{APD\_\-start} (\hyperlink{struct__APD__dtx}{APD\_\-dtx} $\ast$dtx, const unsigned char $\ast$in, unsigned int boff)
\begin{CompactList}\small\item\em Begins a decoding session. \item\end{CompactList}\item 
int \hyperlink{APD_8c_a1}{APD\_\-bdecompress} (unsigned char $\ast$out, int cnt, const unsigned char $\ast$in, unsigned int boff, const unsigned int $\ast$table)
\begin{CompactList}\small\item\em Convenience routine to decode a bit stream using the specified table. \item\end{CompactList}\item 
unsigned int \hyperlink{APD_8c_a2}{APD\_\-decode} (\hyperlink{struct__APD__dtx}{APD\_\-dtx} $\ast$dtx, const unsigned int $\ast$table)
\begin{CompactList}\small\item\em Decodes the next symbol. \item\end{CompactList}\item 
int \hyperlink{APD_8c_a3}{APD\_\-finish} (\hyperlink{struct__APD__dtx}{APD\_\-dtx} $\ast$dtx)
\begin{CompactList}\small\item\em Finishes the decoding, cleaning up any inprogress context. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Arithmetic Byte Decoder, implementation file. 

\begin{Desc}
\item[Author:]JJRussell - \href{mailto:russell@slac.stanford.edu}{\tt russell@slac.stanford.edu}\end{Desc}
Implementation of the routines to decode bit streams using an arithmetic probability encoding technique. To successfully decode an input stream, the encoder and decoder must agree on the modeling table. This modeling table is generally constructed from a frequency distribution derived from the actual data to be encoded or from a distribution thought to be highly representative (in a statisical sense) of the distribution to be encoded. This frequency distribution must then be transformed into the encoding/decoding modeling table.

To achieve performance goals, particularly on the encoding side, these routines must be used with a model builder that forces a particular normalization of the cumulative probability. While such tables may be constructed in a variety of ways, APM\_\-build is an example of such a routine and is anticipated to be the model table builder

\subsection{Function Documentation}
\hypertarget{APD_8c_a1}{
\index{APD.c@{APD.c}!APD_bdecompress@{APD\_\-bdecompress}}
\index{APD_bdecompress@{APD\_\-bdecompress}!APD.c@{APD.c}}
\subsubsection[APD\_\-bdecompress]{\setlength{\rightskip}{0pt plus 5cm}int APD\_\-bdecompress (unsigned char $\ast$ {\em out}, int {\em cnt}, const unsigned char $\ast$ {\em in}, unsigned int {\em boff}, const unsigned int $\ast$ {\em table})}}
\label{APD_8c_a1}


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

\begin{Desc}
\item[Returns:]The number of decoded bits\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em out}]The output buffer \item[{\em cnt}]The number of bytes in the output buffer \item[{\em in}]The input buffer \item[{\em boff}]The bit offset to start at in the input buffer \item[{\em table}]The decoding table\end{description}
\end{Desc}
This is a convenience routine, combining APD\_\-start, APD\_\-decode and APD\_\-finish. This routine can only be used if the decoding table is the same for all symbols in the input stream. 

Here is the call graph for this function:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=135pt]{APD_8c_a1_cgraph}
\end{center}
\end{figure}
\hypertarget{APD_8c_a2}{
\index{APD.c@{APD.c}!APD_decode@{APD\_\-decode}}
\index{APD_decode@{APD\_\-decode}!APD.c@{APD.c}}
\subsubsection[APD\_\-decode]{\setlength{\rightskip}{0pt plus 5cm}unsigned int APD\_\-decode (\hyperlink{struct__APD__dtx}{APD\_\-dtx} $\ast$ {\em dtx}, const unsigned int $\ast$ {\em table})}}
\label{APD_8c_a2}


Decodes the next symbol. 

\begin{Desc}
\item[Returns:]The decoded symbol\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dtx}]The decoding context \item[{\em table}]The table to use in the decoding \end{description}
\end{Desc}
\hypertarget{APD_8c_a3}{
\index{APD.c@{APD.c}!APD_finish@{APD\_\-finish}}
\index{APD_finish@{APD\_\-finish}!APD.c@{APD.c}}
\subsubsection[APD\_\-finish]{\setlength{\rightskip}{0pt plus 5cm}int APD\_\-finish (\hyperlink{struct__APD__dtx}{APD\_\-dtx} $\ast$ {\em dtx})}}
\label{APD_8c_a3}


Finishes the decoding, cleaning up any inprogress context. 

\begin{Desc}
\item[Returns:]The number of bits decoded \end{Desc}
\hypertarget{APD_8c_a0}{
\index{APD.c@{APD.c}!APD_start@{APD\_\-start}}
\index{APD_start@{APD\_\-start}!APD.c@{APD.c}}
\subsubsection[APD\_\-start]{\setlength{\rightskip}{0pt plus 5cm}void APD\_\-start (\hyperlink{struct__APD__dtx}{APD\_\-dtx} $\ast$ {\em dtx}, const unsigned char $\ast$ {\em in}, unsigned int {\em boff})}}
\label{APD_8c_a0}


Begins a decoding session. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dtx}]The decoding context to be initialized \item[{\em in}]The input bit stream \item[{\em boff}]The bit offset into the input bit stream \end{description}
\end{Desc}
