\hypertarget{HDE_8c}{
\section{HDE.c File Reference}
\label{HDE_8c}\index{HDE.c@{HDE.c}}
}
Implementation of the routines to encodes a distribution of symbols using a Huffman encoding technique. Routines are available to encode both the distribution itself and the resulting Huffman table. 

{\tt \#include \char`\"{}LDT/HDE.h\char`\"{}}\par
{\tt \#include \char`\"{}LDT/HUFF.h\char`\"{}}\par
{\tt \#include \char`\"{}LDT/BFP.h\char`\"{}}\par
{\tt \#include \char`\"{}LDT/BA.h\char`\"{}}\par
{\tt \#include \char`\"{}ffs.h\char`\"{}}\par
{\tt \#include \char`\"{}dprintf.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/TMR.h\char`\"{}}\par
{\tt \#include $<$string.h$>$}\par
\subsection*{Classes}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__HistLimits__f}{\_\-HistLimits\_\-f}
\begin{CompactList}\small\item\em Min and Max indices of a region of the histogram. \item\end{CompactList}\item 
union \hyperlink{union__HistLimits}{\_\-HistLimits}
\begin{CompactList}\small\item\em Min and Max indices of a region of the histogram as a union between and uninterpretted 32-bit integer and its field representation. \item\end{CompactList}\item 
struct \hyperlink{struct__HistCore__f}{\_\-HistCore\_\-f}
\begin{CompactList}\small\item\em Describes the result of the encoding selection process, giving the lower and upper bin limits along with the number of entries outside that region. \item\end{CompactList}\item 
union \hyperlink{union__HistCore}{\_\-HistCore}
\begin{CompactList}\small\item\em The histogram core description as a union between an uninterpretted 32-bit representation and its field representation. \item\end{CompactList}\item 
struct \hyperlink{struct__CodesSummary__f}{\_\-CodesSummary\_\-f}
\begin{CompactList}\small\item\em Lays out the structure of the return summary from codes\_\-condition. \item\end{CompactList}\item 
union \hyperlink{union__CodesSummary}{\_\-CodesSummary}
\begin{CompactList}\small\item\em Lays out the structure of the return summary from codes\_\-condition as a union between an uninterpretted 32-bit representation and its field representation. \item\end{CompactList}\item 
struct \hyperlink{struct__DeltasSummary__f}{\_\-DeltasSummary\_\-f}
\begin{CompactList}\small\item\em Summarizes the parameters describing the delta code lengths array. \item\end{CompactList}\item 
union \hyperlink{union__DeltasSummary}{\_\-DeltasSummary}
\begin{CompactList}\small\item\em Summarizes the parameters describing the delta code lengths array as a union between an uninterpretted 32-bit number and its field representation. \item\end{CompactList}\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\hypertarget{HDE_8c_1f6bd181dc181151898307b02e152499}{
\#define \textbf{BA\_\-32}}
\label{HDE_8c_1f6bd181dc181151898307b02e152499}

\item 
\hypertarget{HDE_8c_070d2ce7b6bb7e5c05602aa8c308d0c4}{
\#define \textbf{NULL}~((void $\ast$)(0))}
\label{HDE_8c_070d2ce7b6bb7e5c05602aa8c308d0c4}

\item 
\hypertarget{HDE_8c_f9e3234690b0d446412ccd697e9942f8}{
\#define \textbf{\_\-monitor\_\-declare}(statements)}
\label{HDE_8c_f9e3234690b0d446412ccd697e9942f8}

\item 
\hypertarget{HDE_8c_878e29d4403e7f9ba24064c1c252d667}{
\#define \textbf{\_\-monitor\_\-time}(\_\-mon, \_\-idx)}
\label{HDE_8c_878e29d4403e7f9ba24064c1c252d667}

\item 
\hypertarget{HDE_8c_668db1e87244a0ab87c6306d462153b1}{
\#define \textbf{\_\-monitor}(\_\-var, val)}
\label{HDE_8c_668db1e87244a0ab87c6306d462153b1}

\item 
\hypertarget{HDE_8c_2d9f7bc6a209e31608573cb2a6c0b7e0}{
\#define \textbf{monitor\_\-report}(\_\-mon)}
\label{HDE_8c_2d9f7bc6a209e31608573cb2a6c0b7e0}

\item 
\#define \textbf{\_\-CODES}(\_\-l0, \_\-c0, \_\-l1, \_\-c1, \_\-l2, \_\-c2)
\item 
\hypertarget{HDE_8c_9c7f7a069980485f63ce3224aa50ea1b}{
\#define \textbf{TOUCH}(\_\-adr, \_\-offset)}
\label{HDE_8c_9c7f7a069980485f63ce3224aa50ea1b}

\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{HDE_8c_7e332c287e51f20eea4c92f2814299de}{
typedef struct \hyperlink{struct__HistLimits__f}{\_\-HistLimits\_\-f} \hyperlink{HDE_8c_7e332c287e51f20eea4c92f2814299de}{HistLimits\_\-f}}
\label{HDE_8c_7e332c287e51f20eea4c92f2814299de}

\begin{CompactList}\small\item\em Typedef for struct \hyperlink{union__HistLimits}{\_\-HistLimits}. \item\end{CompactList}\item 
\hypertarget{HDE_8c_7607ecae9872d8953f5e83de313d1b61}{
typedef union \hyperlink{union__HistLimits}{\_\-HistLimits} \hyperlink{HDE_8c_7607ecae9872d8953f5e83de313d1b61}{HistLimits}}
\label{HDE_8c_7607ecae9872d8953f5e83de313d1b61}

\begin{CompactList}\small\item\em Typedef for union \hyperlink{union__HistLimits}{\_\-HistLimits}. \item\end{CompactList}\item 
\hypertarget{HDE_8c_2df832c471b21c2434e785bb2d6bde51}{
typedef struct \hyperlink{struct__HistCore__f}{\_\-HistCore\_\-f} \hyperlink{HDE_8c_2df832c471b21c2434e785bb2d6bde51}{HistCore\_\-f}}
\label{HDE_8c_2df832c471b21c2434e785bb2d6bde51}

\begin{CompactList}\small\item\em Typedef for struct \hyperlink{union__HistCore}{\_\-HistCore}. \item\end{CompactList}\item 
\hypertarget{HDE_8c_0ff7da2d979c4d10c5774a1434b712ee}{
typedef union \hyperlink{union__HistCore}{\_\-HistCore} \hyperlink{HDE_8c_0ff7da2d979c4d10c5774a1434b712ee}{HistCore}}
\label{HDE_8c_0ff7da2d979c4d10c5774a1434b712ee}

\begin{CompactList}\small\item\em Typedef for union \_\-HistCode. \item\end{CompactList}\item 
\hypertarget{HDE_8c_5db347959193df12079686f485aca239}{
typedef struct \hyperlink{struct__CodesSummary__f}{\_\-CodesSummary\_\-f} \hyperlink{HDE_8c_5db347959193df12079686f485aca239}{CodesSummary\_\-f}}
\label{HDE_8c_5db347959193df12079686f485aca239}

\begin{CompactList}\small\item\em Typedef for struct \_\-CodesStatus\_\-f. \item\end{CompactList}\item 
\hypertarget{HDE_8c_0f4eb6a586a166376ef1ffd25a895886}{
typedef union \hyperlink{union__CodesSummary}{\_\-CodesSummary} \hyperlink{HDE_8c_0f4eb6a586a166376ef1ffd25a895886}{CodesSummary}}
\label{HDE_8c_0f4eb6a586a166376ef1ffd25a895886}

\begin{CompactList}\small\item\em Typedef for union \hyperlink{union__CodesSummary}{\_\-CodesSummary}. \item\end{CompactList}\item 
\hypertarget{HDE_8c_7b5f6d56cfab646b53703bf0ca01c580}{
typedef struct \hyperlink{struct__DeltasSummary__f}{\_\-DeltasSummary\_\-f} \hyperlink{HDE_8c_7b5f6d56cfab646b53703bf0ca01c580}{DeltasSummary\_\-f}}
\label{HDE_8c_7b5f6d56cfab646b53703bf0ca01c580}

\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__DeltasSummary__f}{\_\-DeltasSummary\_\-f}. \item\end{CompactList}\item 
\hypertarget{HDE_8c_69cde691dacb375e2b17df0b385b14bf}{
typedef union \hyperlink{union__DeltasSummary}{\_\-DeltasSummary} \hyperlink{HDE_8c_69cde691dacb375e2b17df0b385b14bf}{DeltasSummary}}
\label{HDE_8c_69cde691dacb375e2b17df0b385b14bf}

\begin{CompactList}\small\item\em Typedef for union \hyperlink{union__DeltasSummary}{\_\-DeltasSummary}. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
static \_\-\_\-inline unsigned int \hyperlink{HDE_8c_a8641c8443d944d46cc61a72700fcf66}{hist\_\-limits\_\-findL} (const unsigned int $\ast$hist, int cnt)
\begin{CompactList}\small\item\em Finds the indices of the smallest and largest non-zero entry in the specified histogram. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned long long int \hyperlink{HDE_8c_2a4d0230e5f876df6eebc7457627a59d}{hist\_\-selectL} (const unsigned int $\ast$hist, int nentries, \hyperlink{union__HistLimits}{HistLimits} limits, int nbins)
\begin{CompactList}\small\item\em Finds the {\em nbits\/} that encompass the largest number of entries for the specified histogram. \item\end{CompactList}\item 
static \_\-\_\-inline int \hyperlink{HDE_8c_a77f349d6170f0195121640f28873d60}{hist\_\-copyL} (unsigned int $\ast$dst, const unsigned int $\ast$src, int min, int max)
\begin{CompactList}\small\item\em Copies the core of the histogram (i.e. from the first non-zero element to the last non-zero element. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{HDE_8c_33b62926f283a06a6efe67a432ce39c3}{hist\_\-limits\_\-find} (const unsigned short int $\ast$hist, int cnt)
\begin{CompactList}\small\item\em Finds the indices of the smallest and largest non-zero entry in the specified histogram. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned long long int \hyperlink{HDE_8c_3f30ddb3820b0c152d46c841792fffe9}{hist\_\-select} (const unsigned short int $\ast$hist, int nentries, \hyperlink{union__HistLimits}{HistLimits} limits, int nbins)
\begin{CompactList}\small\item\em Finds the {\em nbits\/} that encompass the largest number of entries for the specified histogram. \item\end{CompactList}\item 
static \_\-\_\-inline int \hyperlink{HDE_8c_e03b53a3ea5451d0c60d182883d9593f}{hist\_\-copy} (unsigned int $\ast$dst, const unsigned short int $\ast$src, int min, int max)
\begin{CompactList}\small\item\em Copies the core of the histogram (i.e. from the first non-zero element to the last non-zero element. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{HDE_8c_8bf198bda3b249c9aaa7af0ece934a10}{form\_\-deltas} (signed char $\ast$deltas, const \hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$codes, int ncodes, int nseed, int seed)
\begin{CompactList}\small\item\em Forms the array code lengths deltas. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{HDE_8c_d983da09d1868b3e077ef1ef5c94170a}{pack\_\-short} (unsigned int $\ast$buf, unsigned int pos, short int val)
\begin{CompactList}\small\item\em Packs the number of bits needed to contain the short integer and its value. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{HDE_8c_5660af6d8b7a5cbde91af7e05773ce68}{pack\_\-seed\_\-min\_\-max} (unsigned int $\ast$buf, unsigned int pos, int seed, int min, int max)
\item 
static \_\-\_\-inline void \hyperlink{HDE_8c_2583b3a7bcf6889e925611d0907b253f}{hist\_\-deltas} (unsigned int $\ast$hist, int min, int nbins, const signed char $\ast$deltas, int ndeltas)
\begin{CompactList}\small\item\em Histograms the delta distribution. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{HDE_8c_3d3ae7b5e61e402261380c9f11b002fe}{pack\_\-delta1} (unsigned int $\ast$buf, unsigned int pos, const signed char $\ast$deltas, int ndeltas, int min, int max\_\-means\_\-0)
\begin{CompactList}\small\item\em High efficiency routine to handle the case when all the deltas are 0 or 1. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{HDE_8c_b4158d723d8e5ccb52d86023e9d05f8c}{pack\_\-delta2} (unsigned int $\ast$buf, unsigned int pos, const signed char $\ast$deltas, int ndeltas, int min, int max\_\-means\_\-0)
\begin{CompactList}\small\item\em High efficiency routine to handle the case when all the delta range is only 2 (3 values). \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{HDE_8c_c0a4f612d86893c3852384e8ffc6c765}{pack\_\-delta\_\-huff} (unsigned int $\ast$buf, unsigned int pos, const signed char $\ast$deltas, int ndeltas, int min, int max, int max\_\-means\_\-0)
\begin{CompactList}\small\item\em Packs the delta code lengths as a huffman table. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{HDE_8c_164790f53555ffdf20a464e7dc3ba16f}{huff\_\-table\_\-encode} (unsigned int $\ast$buf, unsigned int pos, \hyperlink{union__CodesSummary}{CodesSummary} cs, const \hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$codes, const unsigned int $\ast$freq, signed char $\ast$deltas, int min, int max, unsigned int under, unsigned int over)
\begin{CompactList}\small\item\em Encodes the Huffman encoding table. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{HDE_8c_323a27ae0b959618248f07fce16918f1}{huff\_\-symbols\_\-encode} (unsigned int $\ast$buf, unsigned int pos, const \hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$codes, int min, int max, unsigned int nunderflow, unsigned int noverflow, int xsymbols, const short int $\ast$symbols, int nsymbols)
\begin{CompactList}\small\item\em Encodes the pedestal subtracted ADC values using the specified Huffman codes. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{HDE_8c_bea2fcda310989e235fca4f79d20b3c5}{direct\_\-symbols\_\-encode} (\hyperlink{struct__HDE}{HDE} $\ast$hde, unsigned int $\ast$buf, unsigned int pos, int min, int nbits, const short int $\ast$symbols, int nsymbols)
\begin{CompactList}\small\item\em Encodes the specified symbols {\em symbols\/} using the specified histogram of frequencies. Both the symbols and the histogram are presented as 16-bit values. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{HDE_8c_ffc92a15b98a49add42be6bf6f2c230b}{codes\_\-condition} (\hyperlink{struct__HUFF__code}{HUFF\_\-code} $\ast$codes, const unsigned int $\ast$freq, int ncodes)
\begin{CompactList}\small\item\em Conditions the code array by setting the code lengths of non-existent codes to the maximum code length + 1. \item\end{CompactList}\item 
\hypertarget{HDE_8c_a7c159707cbb9cfa0ee2722f566f89e8}{
\textbf{declare} (static void print\_\-nbits(const int $\ast$f, int cnt, int tot))}
\label{HDE_8c_a7c159707cbb9cfa0ee2722f566f89e8}

\item 
unsigned int \hyperlink{HDE_8c_85a7444e5c777c4ef78a349653f70742}{HDE\_\-sizeof} (unsigned int nhuff)
\begin{CompactList}\small\item\em Returns the size, in bytes, for a handle to hold a Huffman distribution of {\em huffman\_\-bins\/}. \item\end{CompactList}\item 
void $\ast$ \hyperlink{HDE_8c_6c83ab266ae7a5ba23269010817100ed}{HDE\_\-construct} (\hyperlink{struct__HDE}{HDE} $\ast$hde, unsigned int nhuff)
\begin{CompactList}\small\item\em Constructs (initializes) the specified HDE structure. \item\end{CompactList}\item 
void \hyperlink{HDE_8c_bdeab01b8fa2c20070c09a8a69c6db09}{HDE\_\-tableConstructL} (\hyperlink{struct__HDE}{HDE} $\ast$hde, unsigned int nhuff, const unsigned int $\ast$hist, int nbins, int nentries)
\begin{CompactList}\small\item\em Constructs HDE Huffman Table associated with the specified distribution. \item\end{CompactList}\item 
unsigned int \hyperlink{HDE_8c_2b7ea12756d6fd067b55c7075ded8be3}{HDE\_\-tableEncode} (\hyperlink{struct__HDE}{HDE} $\ast$hde, unsigned int $\ast$buf, unsigned int pos)
\begin{CompactList}\small\item\em Encodes a previously constructed table. \item\end{CompactList}\item 
unsigned int \hyperlink{HDE_8c_67b6e04a702dafe4cba2751d314d182e}{HDE\_\-symbolsEncodeS} (\hyperlink{struct__HDE}{HDE} $\ast$hde, unsigned int $\ast$buf, unsigned int pos, const short int $\ast$symbols, int nsymbols)
\begin{CompactList}\small\item\em Encodes the set of symbols using the encoding information in {\em hde\/}. This encoding information must have been previously setup using HDE\_\-encodeTable. \item\end{CompactList}\item 
unsigned int \hyperlink{HDE_8c_29b50799df2d19acf162eb01918a87fc}{HDE\_\-encodeSS} (\hyperlink{struct__HDE}{HDE} $\ast$hde, unsigned int $\ast$buf, unsigned int pos, unsigned int nhuff, const unsigned short int $\ast$hist, int nbins, const short int $\ast$symbols, int nsymbols)
\begin{CompactList}\small\item\em Encodes the specified symbols {\em symbols\/} using the specified histogram of frequencies. Both the symbols and the histogram are presented as 16-bit values. \item\end{CompactList}\item 
const \hyperlink{struct__HDE__assay}{HDE\_\-assay} $\ast$ \hyperlink{HDE_8c_b8506f1eb973ea19633afcac814f72f2}{HDE\_\-assayLocate} (const \hyperlink{struct__HDE}{HDE} $\ast$hde)
\begin{CompactList}\small\item\em Returns a pointer to the publically defined piece of this structure. This can be a one-time call, i.e. for any given HDE structure, this routine always returns the same value. \item\end{CompactList}\item 
void \hyperlink{HDE_8c_5ab4a5dccce0788e92054994730f53dc}{HDE\_\-histClearL} (const \hyperlink{struct__HDE}{HDE} $\ast$hde, unsigned int $\ast$hist)
\begin{CompactList}\small\item\em Clears the histogram using the active bin range stored in the HDE\_\-assay block of the HDE structure. \item\end{CompactList}\item 
void \hyperlink{HDE_8c_f8abcce9ddab452adee90afb81ca4bd1}{HDE\_\-histClearS} (const \hyperlink{struct__HDE}{HDE} $\ast$hde, unsigned short int $\ast$hist)
\begin{CompactList}\small\item\em Clears the histogram using the active bin range stored in the HDE\_\-assay block of the HDE structure. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Implementation of the routines to encodes a distribution of symbols using a Huffman encoding technique. Routines are available to encode both the distribution itself and the resulting Huffman table. 

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


\footnotesize\begin{verbatim}

   CVS $Id: HDE.c,v 1.10 2010/08/06 19:18:20 saxton Exp $
\end{verbatim}
\normalsize
 

\subsection{Define Documentation}
\hypertarget{HDE_8c_5cff2ac8692ea4d045fa4938c0fddaad}{
\index{HDE.c@{HDE.c}!_CODES@{\_\-CODES}}
\index{_CODES@{\_\-CODES}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-CODES(\_\-l0, \_\-c0, \_\-l1, \_\-c1, \_\-l2, \_\-c2)}}
\label{HDE_8c_5cff2ac8692ea4d045fa4938c0fddaad}


\textbf{Value:}

\begin{Code}\begin{verbatim}(                                         \
      (((_c2 << 2) | _l2) << 8) |             \
      (((_c1 << 2) | _l1) << 4) |             \
      (((_c0 << 2) | _l0) << 0)               \
    )
\end{verbatim}
\end{Code}


\subsection{Function Documentation}
\hypertarget{HDE_8c_ffc92a15b98a49add42be6bf6f2c230b}{
\index{HDE.c@{HDE.c}!codes_condition@{codes\_\-condition}}
\index{codes_condition@{codes\_\-condition}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int codes\_\-condition ({\bf HUFF\_\-code} $\ast$ {\em codes}, const unsigned int $\ast$ {\em freq}, int {\em ncodes})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_ffc92a15b98a49add42be6bf6f2c230b}


Conditions the code array by setting the code lengths of non-existent codes to the maximum code length + 1. 

\begin{Desc}
\item[Returns:]A packed value with the minimum code length in the low 8-bits\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em codes}]The codes to condition \item[{\em freq}]The frequency distribution. Elements with 0 entries have their corresponding codes 'conditioned' \item[{\em ncodes}]The number of codes and also, by definition, the number elements in {\em freq\/}. \end{description}
\end{Desc}
\hypertarget{HDE_8c_bea2fcda310989e235fca4f79d20b3c5}{
\index{HDE.c@{HDE.c}!direct_symbols_encode@{direct\_\-symbols\_\-encode}}
\index{direct_symbols_encode@{direct\_\-symbols\_\-encode}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned int direct\_\-symbols\_\-encode ({\bf HDE} $\ast$ {\em hde}, unsigned int $\ast$ {\em buf}, unsigned int {\em pos}, int {\em min}, int {\em nbits}, const short int $\ast$ {\em symbols}, int {\em nsymbols})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_bea2fcda310989e235fca4f79d20b3c5}


Encodes the specified symbols {\em symbols\/} using the specified histogram of frequencies. Both the symbols and the histogram are presented as 16-bit values. 

\begin{Desc}
\item[Returns:]The updated bit write position\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hde}]The HDE control structure \item[{\em buf}]The output buffer address \item[{\em pos}]The current write bit offset \item[{\em min}]The value of the smallest symbol \item[{\em nbits}]The number of bits needed to encode the widest symbol \item[{\em symbols}]The array of symbols \item[{\em nsymbols}]The number of symbols \end{description}
\end{Desc}
\hypertarget{HDE_8c_8bf198bda3b249c9aaa7af0ece934a10}{
\index{HDE.c@{HDE.c}!form_deltas@{form\_\-deltas}}
\index{form_deltas@{form\_\-deltas}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int form\_\-deltas (signed char $\ast$ {\em deltas}, const {\bf HUFF\_\-code} $\ast$ {\em codes}, int {\em ncodes}, int {\em nseed}, int {\em seed})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_8bf198bda3b249c9aaa7af0ece934a10}


Forms the array code lengths deltas. 

\begin{Desc}
\item[Returns:]A summary description, giving the min, max and seed values\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em deltas}]The array of deltas to be filled out \item[{\em codes}]The HUFF\_\-man code array to be differinated \item[{\em ncodes}]The number of codes in {\em codes\/} \item[{\em nseed}]The seed bin \item[{\em seed}]The seed value \end{description}
\end{Desc}
\hypertarget{HDE_8c_b8506f1eb973ea19633afcac814f72f2}{
\index{HDE.c@{HDE.c}!HDE_assayLocate@{HDE\_\-assayLocate}}
\index{HDE_assayLocate@{HDE\_\-assayLocate}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const {\bf HDE\_\-assay}$\ast$ HDE\_\-assayLocate (const {\bf HDE} $\ast$ {\em hde})}}
\label{HDE_8c_b8506f1eb973ea19633afcac814f72f2}


Returns a pointer to the publically defined piece of this structure. This can be a one-time call, i.e. for any given HDE structure, this routine always returns the same value. 

\begin{Desc}
\item[Returns:]Pointer to the HDE\_\-assay structure\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hde}]The HDE control structure\end{description}
\end{Desc}
The information returned is mainly of diagnostic use. However, knowing the min and max bin entry allows one to efficiently clear a previously used histogram. \hypertarget{HDE_8c_6c83ab266ae7a5ba23269010817100ed}{
\index{HDE.c@{HDE.c}!HDE_construct@{HDE\_\-construct}}
\index{HDE_construct@{HDE\_\-construct}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void$\ast$ HDE\_\-construct ({\bf HDE} $\ast$ {\em hde}, unsigned int {\em nhuff})}}
\label{HDE_8c_6c83ab266ae7a5ba23269010817100ed}


Constructs (initializes) the specified HDE structure. 

\begin{Desc}
\item[Returns:]The next address after this structure.\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hde}]The HDE control structure to construct \item[{\em nhuff}]The maximum number of Huffman encoding bins that this control structure is meant to support.\end{description}
\end{Desc}
The size of this structure should be acquired by a call to HDE\_\-sizeof. The parameter {\em huffman\_\-nbins\/} must be the same in the call to HDE\_\-sizeof and HDE\_\-construct. \hypertarget{HDE_8c_29b50799df2d19acf162eb01918a87fc}{
\index{HDE.c@{HDE.c}!HDE_encodeSS@{HDE\_\-encodeSS}}
\index{HDE_encodeSS@{HDE\_\-encodeSS}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned int HDE\_\-encodeSS ({\bf HDE} $\ast$ {\em hde}, unsigned int $\ast$ {\em buf}, unsigned int {\em pos}, unsigned int {\em nhuff}, const unsigned short int $\ast$ {\em hist}, int {\em nbins}, const short int $\ast$ {\em symbols}, int {\em nsymbols})}}
\label{HDE_8c_29b50799df2d19acf162eb01918a87fc}


Encodes the specified symbols {\em symbols\/} using the specified histogram of frequencies. Both the symbols and the histogram are presented as 16-bit values. 

\begin{Desc}
\item[Returns:]The updated bit write position\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hde}]The HDE control structure \item[{\em buf}]The output buffer address \item[{\em pos}]The current write bit offset \item[{\em nhuff}]Provides a means to limit the size of the huffman encoding region to a region that is smaller than what was specified during the HDE construction (i.e. the {\em nhuff\/} parameter) The construction value is used, if this value is 0 or larger. \item[{\em hist}]The frequency histogram. The histogram is such that it extends -/+ nbins from this pointer. That is, this is the center of the histogram. \item[{\em nbins}]The half width of the histogram \item[{\em symbols}]The array of symbols \item[{\em nsymbols}]The number of symbols \end{description}
\end{Desc}
\hypertarget{HDE_8c_5ab4a5dccce0788e92054994730f53dc}{
\index{HDE.c@{HDE.c}!HDE_histClearL@{HDE\_\-histClearL}}
\index{HDE_histClearL@{HDE\_\-histClearL}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void HDE\_\-histClearL (const {\bf HDE} $\ast$ {\em hde}, unsigned int $\ast$ {\em hist})}}
\label{HDE_8c_5ab4a5dccce0788e92054994730f53dc}


Clears the histogram using the active bin range stored in the HDE\_\-assay block of the HDE structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hde}]The HDE control handle \item[{\em hist}]The histogram to clear\end{description}
\end{Desc}
This routine must be called after HDE\_\-encodeSS has been called, since it is that routine that sets up the HDE\_\-assay block \hypertarget{HDE_8c_f8abcce9ddab452adee90afb81ca4bd1}{
\index{HDE.c@{HDE.c}!HDE_histClearS@{HDE\_\-histClearS}}
\index{HDE_histClearS@{HDE\_\-histClearS}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void HDE\_\-histClearS (const {\bf HDE} $\ast$ {\em hde}, unsigned short int $\ast$ {\em hist})}}
\label{HDE_8c_f8abcce9ddab452adee90afb81ca4bd1}


Clears the histogram using the active bin range stored in the HDE\_\-assay block of the HDE structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hde}]The HDE control handle \item[{\em hist}]The histogram to clear\end{description}
\end{Desc}
This routine must be called after HDE\_\-encodeSS has been called, since it is that routine that sets up the HDE\_\-assay block \hypertarget{HDE_8c_85a7444e5c777c4ef78a349653f70742}{
\index{HDE.c@{HDE.c}!HDE_sizeof@{HDE\_\-sizeof}}
\index{HDE_sizeof@{HDE\_\-sizeof}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned int HDE\_\-sizeof (unsigned int {\em nhuff})}}
\label{HDE_8c_85a7444e5c777c4ef78a349653f70742}


Returns the size, in bytes, for a handle to hold a Huffman distribution of {\em huffman\_\-bins\/}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em nhuff}]The maximum size of the Huffman encoding area Suggested values are small powers of 2 like 32, 64, 128. Note also up to 3 bins may be used to hold describe the underflow, overflow and exception areas. Currently these 3 are mapped into 1 bin, but this may change in a future implementation\end{description}
\end{Desc}
For the most part, this only provides a working area. On host-based workstations with expandable stacks, this memory would go on the stack, but, it is too large to do this for embedded systems. \hypertarget{HDE_8c_67b6e04a702dafe4cba2751d314d182e}{
\index{HDE.c@{HDE.c}!HDE_symbolsEncodeS@{HDE\_\-symbolsEncodeS}}
\index{HDE_symbolsEncodeS@{HDE\_\-symbolsEncodeS}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned int HDE\_\-symbolsEncodeS ({\bf HDE} $\ast$ {\em hde}, unsigned int $\ast$ {\em buf}, unsigned int {\em pos}, const short int $\ast$ {\em symbols}, int {\em nsymbols})}}
\label{HDE_8c_67b6e04a702dafe4cba2751d314d182e}


Encodes the set of symbols using the encoding information in {\em hde\/}. This encoding information must have been previously setup using HDE\_\-encodeTable. 

\begin{Desc}
\item[Returns:]The updated bit write position\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hde}]The HDE control structure \item[{\em symbols}]The array of symbols \item[{\em nsymbols}]The number of symbols \item[{\em buf}]The output buffer address \item[{\em pos}]The current write bit offset \end{description}
\end{Desc}
\hypertarget{HDE_8c_bdeab01b8fa2c20070c09a8a69c6db09}{
\index{HDE.c@{HDE.c}!HDE_tableConstructL@{HDE\_\-tableConstructL}}
\index{HDE_tableConstructL@{HDE\_\-tableConstructL}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void HDE\_\-tableConstructL ({\bf HDE} $\ast$ {\em hde}, unsigned int {\em nhuff}, const unsigned int $\ast$ {\em hist}, int {\em nbins}, int {\em nentries})}}
\label{HDE_8c_bdeab01b8fa2c20070c09a8a69c6db09}


Constructs HDE Huffman Table associated with the specified distribution. 

\begin{Desc}
\item[Returns:]The updated bit write position\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hde}]The HDE control structure \item[{\em nhuff}]Provides a means to limit the size of the huffman encoding region to a region that is smaller than what was specified during the HDE construction (i.e. the {\em nhuff\/} parameter) The construction value is used, if this value is 0 or larger. \item[{\em hist}]The frequency histogram. The histogram is such that it extends -/+ nbins from this pointer. That is, this is the center of the histogram. \item[{\em nbins}]The half width of the histogram \item[{\em nentries}]The number of entries in the histogram \end{description}
\end{Desc}
\hypertarget{HDE_8c_2b7ea12756d6fd067b55c7075ded8be3}{
\index{HDE.c@{HDE.c}!HDE_tableEncode@{HDE\_\-tableEncode}}
\index{HDE_tableEncode@{HDE\_\-tableEncode}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned int HDE\_\-tableEncode ({\bf HDE} $\ast$ {\em hde}, unsigned int $\ast$ {\em buf}, unsigned int {\em pos})}}
\label{HDE_8c_2b7ea12756d6fd067b55c7075ded8be3}


Encodes a previously constructed table. 

\begin{Desc}
\item[Returns:]The updated bit write position\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hde}]The HDE control structure \item[{\em buf}]The output buffer address \item[{\em pos}]The current write bit offset \end{description}
\end{Desc}
\hypertarget{HDE_8c_e03b53a3ea5451d0c60d182883d9593f}{
\index{HDE.c@{HDE.c}!hist_copy@{hist\_\-copy}}
\index{hist_copy@{hist\_\-copy}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline int hist\_\-copy (unsigned int $\ast$ {\em dst}, const unsigned short int $\ast$ {\em src}, int {\em min}, int {\em max})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_e03b53a3ea5451d0c60d182883d9593f}


Copies the core of the histogram (i.e. from the first non-zero element to the last non-zero element. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dst}]The destination histogram \item[{\em src}]The source histogram \item[{\em min}]The first non-zero histogram bin \item[{\em max}]The last non-zero histogram bin\end{description}
\end{Desc}
This routine exists solely because the HUFF build routines only take an integer (not a short integer) frequency distribution. \hypertarget{HDE_8c_a77f349d6170f0195121640f28873d60}{
\index{HDE.c@{HDE.c}!hist_copyL@{hist\_\-copyL}}
\index{hist_copyL@{hist\_\-copyL}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline int hist\_\-copyL (unsigned int $\ast$ {\em dst}, const unsigned int $\ast$ {\em src}, int {\em min}, int {\em max})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_a77f349d6170f0195121640f28873d60}


Copies the core of the histogram (i.e. from the first non-zero element to the last non-zero element. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dst}]The destination histogram \item[{\em src}]The source histogram \item[{\em min}]The first non-zero histogram bin \item[{\em max}]The last non-zero histogram bin \end{description}
\end{Desc}
\hypertarget{HDE_8c_2583b3a7bcf6889e925611d0907b253f}{
\index{HDE.c@{HDE.c}!hist_deltas@{hist\_\-deltas}}
\index{hist_deltas@{hist\_\-deltas}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline void hist\_\-deltas (unsigned int $\ast$ {\em hist}, int {\em min}, int {\em nbins}, const signed char $\ast$ {\em deltas}, int {\em ndeltas})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_2583b3a7bcf6889e925611d0907b253f}


Histograms the delta distribution. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hist}]The resulting histogram \item[{\em min}]The minimum bin number \item[{\em nbins}]The number of bins in the histogram \item[{\em deltas}]The deltas to histogram \item[{\em ndeltas}]The number of deltas to histogram \end{description}
\end{Desc}
\hypertarget{HDE_8c_33b62926f283a06a6efe67a432ce39c3}{
\index{HDE.c@{HDE.c}!hist_limits_find@{hist\_\-limits\_\-find}}
\index{hist_limits_find@{hist\_\-limits\_\-find}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int hist\_\-limits\_\-find (const unsigned short int $\ast$ {\em hist}, int {\em cnt})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_33b62926f283a06a6efe67a432ce39c3}


Finds the indices of the smallest and largest non-zero entry in the specified histogram. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hist}]The target histogram \item[{\em cnt}]The total number of entries in the histogram \end{description}
\end{Desc}
\hypertarget{HDE_8c_a8641c8443d944d46cc61a72700fcf66}{
\index{HDE.c@{HDE.c}!hist_limits_findL@{hist\_\-limits\_\-findL}}
\index{hist_limits_findL@{hist\_\-limits\_\-findL}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int hist\_\-limits\_\-findL (const unsigned int $\ast$ {\em hist}, int {\em cnt})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_a8641c8443d944d46cc61a72700fcf66}


Finds the indices of the smallest and largest non-zero entry in the specified histogram. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hist}]The target histogram \item[{\em cnt}]The total number of entries in the histogram \end{description}
\end{Desc}
\hypertarget{HDE_8c_3f30ddb3820b0c152d46c841792fffe9}{
\index{HDE.c@{HDE.c}!hist_select@{hist\_\-select}}
\index{hist_select@{hist\_\-select}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned long long int hist\_\-select (const unsigned short int $\ast$ {\em hist}, int {\em nentries}, {\bf HistLimits} {\em limits}, int {\em nbins})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_3f30ddb3820b0c152d46c841792fffe9}


Finds the {\em nbits\/} that encompass the largest number of entries for the specified histogram. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hist}]The target histogram \item[{\em nentries}]The total number of entries described by the limits \item[{\em limits}]The lower and upper bins of the histogram. These are the first and last bins with data \item[{\em nbins}]The width to select. \end{description}
\end{Desc}
\hypertarget{HDE_8c_2a4d0230e5f876df6eebc7457627a59d}{
\index{HDE.c@{HDE.c}!hist_selectL@{hist\_\-selectL}}
\index{hist_selectL@{hist\_\-selectL}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned long long int hist\_\-selectL (const unsigned int $\ast$ {\em hist}, int {\em nentries}, {\bf HistLimits} {\em limits}, int {\em nbins})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_2a4d0230e5f876df6eebc7457627a59d}


Finds the {\em nbits\/} that encompass the largest number of entries for the specified histogram. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em hist}]The target histogram \item[{\em nentries}]The total number of entries described by the limits \item[{\em limits}]The lower and upper bins of the histogram. These are the first and last bins with data \item[{\em nbins}]The width to select. \end{description}
\end{Desc}
\hypertarget{HDE_8c_323a27ae0b959618248f07fce16918f1}{
\index{HDE.c@{HDE.c}!huff_symbols_encode@{huff\_\-symbols\_\-encode}}
\index{huff_symbols_encode@{huff\_\-symbols\_\-encode}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int huff\_\-symbols\_\-encode (unsigned int $\ast$ {\em buf}, unsigned int {\em pos}, const {\bf HUFF\_\-code} $\ast$ {\em codes}, int {\em min}, int {\em max}, unsigned int {\em nunderflow}, unsigned int {\em noverflow}, int {\em xsymbols}, const short int $\ast$ {\em symbols}, int {\em nsymbols})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_323a27ae0b959618248f07fce16918f1}


Encodes the pedestal subtracted ADC values using the specified Huffman codes. 

\begin{Desc}
\item[Returns:]The updated write bit position\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]The output buffer \item[{\em pos}]The position of the next bit to fill \item[{\em codes}]The Huffman codes \item[{\em min}]The minimum symbol value for Huffman encoding \item[{\em max}]The maximum symbol value for Huffman encoding If 'p \item[{\em nunderflow}]The size of the underflow region \item[{\em noverflow}]The size of the overflow region \item[{\em xsymbols}]The number of symbols in the under/over flow regions \item[{\em symbols}]The symbols to encode \item[{\em nsymbols}]The number of symbols to encode \end{description}
\end{Desc}
\hypertarget{HDE_8c_164790f53555ffdf20a464e7dc3ba16f}{
\index{HDE.c@{HDE.c}!huff_table_encode@{huff\_\-table\_\-encode}}
\index{huff_table_encode@{huff\_\-table\_\-encode}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int huff\_\-table\_\-encode (unsigned int $\ast$ {\em buf}, unsigned int {\em pos}, {\bf CodesSummary} {\em cs}, const {\bf HUFF\_\-code} $\ast$ {\em codes}, const unsigned int $\ast$ {\em freq}, signed char $\ast$ {\em deltas}, int {\em min}, int {\em max}, unsigned int {\em under}, unsigned int {\em over})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_164790f53555ffdf20a464e7dc3ba16f}


Encodes the Huffman encoding table. 

\begin{Desc}
\item[Returns:]The updated write bit position\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]The output buffer \item[{\em pos}]The position of the next bit to fill \item[{\em cs}]The code summary status \item[{\em codes}]The Huffman codes \item[{\em freq}]The frequency distribution. This is used to determine valid members. \item[{\em deltas}]Scratch area for the code length deltas \item[{\em min}]The minimum code index \item[{\em max}]The maximum code index \item[{\em under}]The number of bins in the underflow region \item[{\em over}]The number of bins in the overflow region \end{description}
\end{Desc}
\hypertarget{HDE_8c_3d3ae7b5e61e402261380c9f11b002fe}{
\index{HDE.c@{HDE.c}!pack_delta1@{pack\_\-delta1}}
\index{pack_delta1@{pack\_\-delta1}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int pack\_\-delta1 (unsigned int $\ast$ {\em buf}, unsigned int {\em pos}, const signed char $\ast$ {\em deltas}, int {\em ndeltas}, int {\em min}, int {\em max\_\-means\_\-0})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_3d3ae7b5e61e402261380c9f11b002fe}


High efficiency routine to handle the case when all the deltas are 0 or 1. 

\begin{Desc}
\item[Returns:]The updated write bit position\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]The output buffer \item[{\em pos}]The position of the next bit to fill \item[{\em deltas}]The deltas, by defintion, these must be 0 or 1 \item[{\em ndeltas}]The number of deltas \item[{\em min}]The minimum value \item[{\em max\_\-means\_\-0}]If true, when the original code lengths restored from the deltas, the maximum code length really means 0 \end{description}
\end{Desc}
\hypertarget{HDE_8c_b4158d723d8e5ccb52d86023e9d05f8c}{
\index{HDE.c@{HDE.c}!pack_delta2@{pack\_\-delta2}}
\index{pack_delta2@{pack\_\-delta2}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int pack\_\-delta2 (unsigned int $\ast$ {\em buf}, unsigned int {\em pos}, const signed char $\ast$ {\em deltas}, int {\em ndeltas}, int {\em min}, int {\em max\_\-means\_\-0})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_b4158d723d8e5ccb52d86023e9d05f8c}


High efficiency routine to handle the case when all the delta range is only 2 (3 values). 

\begin{Desc}
\item[Returns:]The updated write bit position\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]The output buffer \item[{\em pos}]The position of the next bit to fill \item[{\em deltas}]The deltas, must have a range of only 2 \item[{\em ndeltas}]The number of deltas \item[{\em min}]The minimum value \item[{\em max\_\-means\_\-0}]If true, when the original code lengths restored from the deltas, the maximum code length really means 0\end{description}
\end{Desc}
Need just 1 or 2 bits of information to define this packing scheme\begin{enumerate}
\item 1 bit indicating that 0 is not the maximum occuring bin, and if so, another bits indicating which of the other two is the maximum occurring bin.\end{enumerate}


In practice here are the assignments

If max is Bin0 Bin1 Bin2 Len:Code Len:Code Lne:Code Min == -1 2,3 1,0 2,2 Min != -1 1:0 2,2 2,3 \hypertarget{HDE_8c_c0a4f612d86893c3852384e8ffc6c765}{
\index{HDE.c@{HDE.c}!pack_delta_huff@{pack\_\-delta\_\-huff}}
\index{pack_delta_huff@{pack\_\-delta\_\-huff}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int pack\_\-delta\_\-huff (unsigned int $\ast$ {\em buf}, unsigned int {\em pos}, const signed char $\ast$ {\em deltas}, int {\em ndeltas}, int {\em min}, int {\em max}, int {\em max\_\-means\_\-0})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_c0a4f612d86893c3852384e8ffc6c765}


Packs the delta code lengths as a huffman table. 

\begin{Desc}
\item[Returns:]The updated write bit position\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]The output buffer \item[{\em pos}]The position of the next bit to fill \item[{\em deltas}]The deltas to pack \item[{\em ndeltas}]The number of deltas to pack \item[{\em min}]The minimum delta value \item[{\em max}]The maximum delta value \item[{\em max\_\-means\_\-0}]If true, when the original code lengths restored from the deltas, the maximum code length really means 0 \end{description}
\end{Desc}
\hypertarget{HDE_8c_5660af6d8b7a5cbde91af7e05773ce68}{
\index{HDE.c@{HDE.c}!pack_seed_min_max@{pack\_\-seed\_\-min\_\-max}}
\index{pack_seed_min_max@{pack\_\-seed\_\-min\_\-max}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int pack\_\-seed\_\-min\_\-max (unsigned int $\ast$ {\em buf}, unsigned int {\em pos}, int {\em seed}, int {\em min}, int {\em max})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_5660af6d8b7a5cbde91af7e05773ce68}


\begin{Desc}
\item[Returns:]The updated write bit position\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]The output buffer \item[{\em pos}]The position of the next bit to fill \item[{\em seed}]The seed value \item[{\em min}]The minimum delta value \item[{\em max}]The maximum delta value\end{description}
\end{Desc}
Wish to make an optimization when all three values are small, as they are likely to be (usually 3 bits or less). A code giving the number of bits each is pack in is output. This code is\begin{itemize}
\item 0 for 2 bits\item 1 for 3 bits\item 2 for 4 bits\item 3 for 6 bits \end{itemize}
\hypertarget{HDE_8c_d983da09d1868b3e077ef1ef5c94170a}{
\index{HDE.c@{HDE.c}!pack_short@{pack\_\-short}}
\index{pack_short@{pack\_\-short}!HDE.c@{HDE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int pack\_\-short (unsigned int $\ast$ {\em buf}, unsigned int {\em pos}, short int {\em val})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{HDE_8c_d983da09d1868b3e077ef1ef5c94170a}


Packs the number of bits needed to contain the short integer and its value. 

\begin{Desc}
\item[Returns:]The update bit write position\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]The output buffer \item[{\em pos}]The position of the next bit to fill \item[{\em val}]The value to pack \end{description}
\end{Desc}
