\hypertarget{APD_8h}{
\section{APD.h File Reference}
\label{APD_8h}\index{APD.h@{APD.h}}
}
Arithmetic Word Decoder interface file. 

\subsection*{Classes}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__APD__dtx}{\_\-APD\_\-dtx}
\begin{CompactList}\small\item\em Decoding context. \item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
typedef struct \hyperlink{struct__APD__dtx}{\_\-APD\_\-dtx} \hyperlink{APD_8h_7836b63243cf1041db4eacaba198b8b8}{APD\_\-dtx}
\begin{CompactList}\small\item\em Typedef for struct {\em \hyperlink{struct__APD__dtx}{\_\-APD\_\-dtx}\/}. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{APD_8h_f983b541b82c13b9f7df9f99be014351}{APD\_\-start} (\hyperlink{struct__APD__dtx}{APD\_\-dtx} $\ast$dtx, const void $\ast$src, unsigned int boff)
\begin{CompactList}\small\item\em Begins a decoding session. \item\end{CompactList}\item 
unsigned int \hyperlink{APD_8h_594975d917da64f9a126b67df782562b}{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_8h_306bf6f6b2eb4ffa4c808ecac90657f7}{APD\_\-bdecompress} (unsigned char $\ast$dst, int cnt, const void $\ast$src, unsigned int boff, const unsigned int $\ast$table)
\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{APD_8h_27738f94eff996a5065e2cb6baffadbf}{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}\item 
void \hyperlink{APD_8h_e93bb3dcf2c509bf48ff4d2cc8d203d9}{APD32\_\-start} (\hyperlink{struct__APD__dtx}{APD\_\-dtx} $\ast$dtx, const void $\ast$src, unsigned int boff)
\begin{CompactList}\small\item\em Begins a decoding session. \item\end{CompactList}\item 
unsigned int \hyperlink{APD_8h_ae617d07ea78bf12c30bfc50bf45372f}{APD32\_\-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_8h_ea25cfd6889f125110dbd3811fb0762a}{APD32\_\-bdecompress} (unsigned char $\ast$dst, int cnt, const void $\ast$src, 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 
int \hyperlink{APD_8h_2095d77d704820ec4da6cc3f28c2d71c}{APD32\_\-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 Word Decoder 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: APD.h,v 1.2 2006/01/24 00:20:23 russell Exp $ \end{verbatim}
\normalsize


\begin{Desc}
\item[Overview]Interface specification for routines to decode streams using an arithmetic probability encoding technique. It is based on a 32-bit table giving the probabilities of the encoded symbols.\end{Desc}
\begin{Desc}
\item[More Info]For details on the implementation and design choices see the documentation in \hyperlink{APD_8c}{APD.c}\end{Desc}
\begin{Desc}
\item[APD vs APD32 Interface]The APD routines decode a byte stream of encoded symbols, while the APD32 routines decode a 32-bit stream of encoded symbols.\end{Desc}
\begin{Desc}
\item[Note:]The encoding side of these routines writes the encoded data as a big endian byte-stream, where the {\em big\/} endian refers to the fact that the bits within the bytes are serially accessed starting at the most significant bit to the least significant bit.\end{Desc}
\begin{Desc}
\item[APD32, Typical Usage]One application of the APD32 routines is when the input stream that the encoded symbols are embedded in is treated as a 32-bit big endian stream. Typically what one will do is byte-swap this stream on little endian machines, so that the 32-bit words are in the correct order. Once this is done, one should use APD32\_\- routines to correctly access the input stream on either big or little-endian machines.\end{Desc}
\par
 \begin{Desc}
\item[Note:]Given that the APE encoding routines write a big-endian oriented byte-stream, the APD and APD32 routines are exactly the same on big-endian machines. As an implementation note, these routines truly are the same on big-endian machines, with the equivalent names being aliased.\end{Desc}
\par
 \begin{Desc}
\item[Note:]This more than a convenience to the user. One might argue that the user could just undo the byte-swapping, but this is not true in all cases. Specifically, if the user does not know the length of the encoded symbols ({\em e.g\/}. the encoded stream itself contains the end-of-stream information, he will be unable to determine how many words to byte-swap. \end{Desc}


\subsection{Typedef Documentation}
\hypertarget{APD_8h_7836b63243cf1041db4eacaba198b8b8}{
\index{APD.h@{APD.h}!APD_dtx@{APD\_\-dtx}}
\index{APD_dtx@{APD\_\-dtx}!APD.h@{APD.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf APD\_\-dtx}}}
\label{APD_8h_7836b63243cf1041db4eacaba198b8b8}


Typedef for struct {\em \hyperlink{struct__APD__dtx}{\_\-APD\_\-dtx}\/}. 

While this is defined in the public interface, this structure should be treated like a C++ private member. All manipulation of this structure should be through the APD or APD32 routines. 

\subsection{Function Documentation}
\hypertarget{APD_8h_ea25cfd6889f125110dbd3811fb0762a}{
\index{APD.h@{APD.h}!APD32_bdecompress@{APD32\_\-bdecompress}}
\index{APD32_bdecompress@{APD32\_\-bdecompress}!APD.h@{APD.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int APD32\_\-bdecompress (unsigned char $\ast$ {\em dst}, int {\em cnt}, const void $\ast$ {\em src}, unsigned int {\em boff}, const unsigned int $\ast$ {\em table})}}
\label{APD_8h_ea25cfd6889f125110dbd3811fb0762a}


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

\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 bytes available in the output buffer \item[{\em src}]The encode source/input stream \item[{\em boff}]The bit offset to start at in the input buffer \item[{\em table}]The decoding table\end{description}
\end{Desc}
\begin{Desc}
\item[]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.\end{Desc}
\begin{Desc}
\item[]The input stream to be decoded must be 32-bit byte-swapped. See APD32\_\-bdecompress for decoding byte oriented streams. \end{Desc}
\hypertarget{APD_8h_ae617d07ea78bf12c30bfc50bf45372f}{
\index{APD.h@{APD.h}!APD32_decode@{APD32\_\-decode}}
\index{APD32_decode@{APD32\_\-decode}!APD.h@{APD.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned int APD32\_\-decode ({\bf APD\_\-dtx} $\ast$ {\em dtx}, const unsigned int $\ast$ {\em table})}}
\label{APD_8h_ae617d07ea78bf12c30bfc50bf45372f}


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}
\begin{Desc}
\item[]The input stream to be decoded must be 32-bit byte-swapped. See APD32\_\-bdecompress for decoding byte oriented streams. \end{Desc}
\hypertarget{APD_8h_2095d77d704820ec4da6cc3f28c2d71c}{
\index{APD.h@{APD.h}!APD32_finish@{APD32\_\-finish}}
\index{APD32_finish@{APD32\_\-finish}!APD.h@{APD.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int APD32\_\-finish ({\bf APD\_\-dtx} $\ast$ {\em dtx})}}
\label{APD_8h_2095d77d704820ec4da6cc3f28c2d71c}


Finishes the decoding, cleaning up any inprogress context. 

\begin{Desc}
\item[Returns:]The number of bits decoded\end{Desc}
\begin{Desc}
\item[]This routine indicates the user is finish decoding a 32-bit byte-swapped stream. See APD32\_\-finish for finishing a byte stream. \end{Desc}
\hypertarget{APD_8h_e93bb3dcf2c509bf48ff4d2cc8d203d9}{
\index{APD.h@{APD.h}!APD32_start@{APD32\_\-start}}
\index{APD32_start@{APD32\_\-start}!APD.h@{APD.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void APD32\_\-start ({\bf APD\_\-dtx} $\ast$ {\em dtx}, const void $\ast$ {\em src}, unsigned int {\em boff})}}
\label{APD_8h_e93bb3dcf2c509bf48ff4d2cc8d203d9}


Begins a decoding session. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dtx}]The decoding context to be initialized \item[{\em src}]The encoded source/input bit stream \item[{\em boff}]The bit offset into the input bit stream\end{description}
\end{Desc}
\begin{Desc}
\item[]This routine initializes a decoding context for 32-bit byte-swapped streams. See APD32\_\-start for accessing byte oriented streams. \end{Desc}
\hypertarget{APD_8h_306bf6f6b2eb4ffa4c808ecac90657f7}{
\index{APD.h@{APD.h}!APD_bdecompress@{APD\_\-bdecompress}}
\index{APD_bdecompress@{APD\_\-bdecompress}!APD.h@{APD.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int APD\_\-bdecompress (unsigned char $\ast$ {\em dst}, int {\em cnt}, const void $\ast$ {\em src}, unsigned int {\em boff}, const unsigned int $\ast$ {\em table})}}
\label{APD_8h_306bf6f6b2eb4ffa4c808ecac90657f7}


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 bytes available in the output buffer \item[{\em src}]The encoded source/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}
\begin{Desc}
\item[]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.\end{Desc}
\begin{Desc}
\item[]The input stream to be decoded must be big-endian byte. See APD32\_\-bdecompress for decoding 32-bit byte-swapped streams. \end{Desc}
\hypertarget{APD_8h_594975d917da64f9a126b67df782562b}{
\index{APD.h@{APD.h}!APD_decode@{APD\_\-decode}}
\index{APD_decode@{APD\_\-decode}!APD.h@{APD.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned int APD\_\-decode ({\bf APD\_\-dtx} $\ast$ {\em dtx}, const unsigned int $\ast$ {\em table})}}
\label{APD_8h_594975d917da64f9a126b67df782562b}


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}
\begin{Desc}
\item[]The input stream to be decoded must be big-endian byte. See APD32\_\-bdecompress for decoding 32-bit byte-swapped streams. \end{Desc}
\hypertarget{APD_8h_27738f94eff996a5065e2cb6baffadbf}{
\index{APD.h@{APD.h}!APD_finish@{APD\_\-finish}}
\index{APD_finish@{APD\_\-finish}!APD.h@{APD.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int APD\_\-finish ({\bf APD\_\-dtx} $\ast$ {\em dtx})}}
\label{APD_8h_27738f94eff996a5065e2cb6baffadbf}


Finishes the decoding, cleaning up any inprogress context. 

\begin{Desc}
\item[Returns:]The number of bits decoded\end{Desc}
\begin{Desc}
\item[]This routine indicates the user is finish decoding a byte oriented stream. See APD32\_\-finish for finishing a 32-bit byte-swapped stream. \end{Desc}
\hypertarget{APD_8h_f983b541b82c13b9f7df9f99be014351}{
\index{APD.h@{APD.h}!APD_start@{APD\_\-start}}
\index{APD_start@{APD\_\-start}!APD.h@{APD.h}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void APD\_\-start ({\bf APD\_\-dtx} $\ast$ {\em dtx}, const void $\ast$ {\em src}, unsigned int {\em boff})}}
\label{APD_8h_f983b541b82c13b9f7df9f99be014351}


Begins a decoding session. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dtx}]The decoding context to be initialized \item[{\em src}]The encoded source/input bit stream \item[{\em boff}]The bit offset into the input bit stream\end{description}
\end{Desc}
\begin{Desc}
\item[]This routine initializes a decoding context for byte-oriented encoded streams. See APD32\_\-start for accessing 32-bit byte-swapped streams. \end{Desc}
