\hypertarget{RLE_8c}{
\section{RLE.c File Reference}
\label{RLE_8c}\index{RLE.c@{RLE.c}}
}
Encodes up to 32-bit word using a run-length encoding method. 

{\tt \#include \char`\"{}ffs.h\char`\"{}}\par
{\tt \#include \char`\"{}LDT/RLE.h\char`\"{}}\par
{\tt \#include \char`\"{}LDT/BA.h\char`\"{}}\par
{\tt \#include \char`\"{}LDT/BFP.h\char`\"{}}\par


Include dependency graph for RLE.c:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=187pt]{RLE_8c__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{CompactItemize}
\item 
unsigned int \hyperlink{RLE_8c_eb26a6be30e45df647953b820fe4885e}{RLE\_\-encode} (unsigned int $\ast$buf, unsigned int pos, unsigned int word, int cnt)
\begin{CompactList}\small\item\em Uses a run length encoding method to encode the bits in the specified word. \item\end{CompactList}\item 
int \hyperlink{RLE_8c_c3047c53328d7449b02dccc38e276b06}{RLE\_\-compare} (unsigned int word, int cnt, int max)
\begin{CompactList}\small\item\em Compares the size of the {\em max\/} with run length method and returns (almost) rle\_\-size - max. \item\end{CompactList}\item 
unsigned int \hyperlink{RLE_8c_f7be4c2257979ff2ae11d9b66fe7c3df}{RLE\_\-size} (unsigned int word, int cnt)
\begin{CompactList}\small\item\em Returns the size of the run length encoding method. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Encodes up to 32-bit word using a run-length encoding method. 

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


\footnotesize\begin{verbatim}

   CVS $Id: RLE.c,v 1.1 2009/04/30 00:31:28 russell Exp $
\end{verbatim}
\normalsize
 

\subsection{Function Documentation}
\hypertarget{RLE_8c_c3047c53328d7449b02dccc38e276b06}{
\index{RLE.c@{RLE.c}!RLE_compare@{RLE\_\-compare}}
\index{RLE_compare@{RLE\_\-compare}!RLE.c@{RLE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int RLE\_\-compare (unsigned int {\em word}, int {\em cnt}, int {\em max})}}
\label{RLE_8c_c3047c53328d7449b02dccc38e276b06}


Compares the size of the {\em max\/} with run length method and returns (almost) rle\_\-size - max. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em $>$0}]Indicates RLE encoding is larger than {\em max\/}. How much larger is not encoded, only that it is larger. \item[{\em =0}]The number of bits needed by the RLE\_\-encode is the same as max \item[{\em $<$0}]The number of bits needed by the RLE\_\-compare is less than max. In this case, {\em max\/} + return value = size of RLE encoding.\end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em word}]The word to encode \item[{\em cnt}]The maximum bit number + 1 (LSB = 0) that can be set. For example, if all 32 bits can be set, then this is 32, if only 16 bits (right-jusified) then 16. This must be a value between 1 and 32. \item[{\em max}]The maximum number of bits.\end{description}
\end{Desc}
This routine can be used to judge whether some other encoding method is better than the run length method.

\begin{Desc}
\item[Example]If one wishes to use an {\em asis\/} encoding on a 16-bit value if the run length encoding method exceeds 16 bits 

\begin{Code}\begin{verbatim}      / * Check if the run length encoding size is greater than or equal 16 * /
      if (RLE_compare (word, 16, 16) >= 0)
      {
          / * Yes, RLE method is greater than or equal to 16 bits 
              use asis encoding                                    * /
          pos = BFP_wordB (buf, pos, 1);
          pos = BFP_wordR (buf, pos, word, 16);
      }
      else
     {
          / * No, RLE_method is less than 16 bits * /
          pos = BFP_wordB  (buf, pos, 0);
          pos = RLE_encode (buf, pos, word, 16);
      }
\end{verbatim}
\end{Code}

 \end{Desc}
\hypertarget{RLE_8c_eb26a6be30e45df647953b820fe4885e}{
\index{RLE.c@{RLE.c}!RLE_encode@{RLE\_\-encode}}
\index{RLE_encode@{RLE\_\-encode}!RLE.c@{RLE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned int RLE\_\-encode (unsigned int $\ast$ {\em buf}, unsigned int {\em pos}, unsigned int {\em word}, int {\em cnt})}}
\label{RLE_8c_eb26a6be30e45df647953b820fe4885e}


Uses a run length encoding method to encode the bits in the specified word. 

\begin{Desc}
\item[Returns:]The updated bit position\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]The output buffer \item[{\em pos}]The current bit position \item[{\em word}]The word to encode \item[{\em cnt}]The maximum bit number + 1 (LSB = 0) that can be set. For example, if all 32 bits can be set, then this is 32, if only 16 bits (right-jusified) then 16. This must be a value between 1 and 32. \end{description}
\end{Desc}
\hypertarget{RLE_8c_f7be4c2257979ff2ae11d9b66fe7c3df}{
\index{RLE.c@{RLE.c}!RLE_size@{RLE\_\-size}}
\index{RLE_size@{RLE\_\-size}!RLE.c@{RLE.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned int RLE\_\-size (unsigned int {\em word}, int {\em cnt})}}
\label{RLE_8c_f7be4c2257979ff2ae11d9b66fe7c3df}


Returns the size of the run length encoding method. 

\begin{Desc}
\item[Returns:]The number of bits needed by the RLE\_\-encode\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em word}]The word to encode \item[{\em cnt}]The maximum bit number + 1 (LSB = 0) that can be set. For example, if all 32 bits can be set, then this is 32, if only 16 bits (right-jusified) then 16. This must be a value between 1 and 32. \end{description}
\end{Desc}
