\hypertarget{classSPL_1_1BinArithEncoder}{}\section{S\+P\+L\+:\+:Bin\+Arith\+Encoder Class Reference}
\label{classSPL_1_1BinArithEncoder}\index{S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}}


Binary arithmetic encoder class.  




{\ttfamily \#include $<$arith\+Coder.\+hpp$>$}

\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classSPL_1_1BinArithEncoder_a82338540a046e4c13a195cd3102f7ee6}{Bin\+Arith\+Encoder} (int num\+Contexts, \hyperlink{classSPL_1_1OutputBitStream}{Output\+Bit\+Stream} $\ast$out=nullptr)
\begin{DoxyCompactList}\small\item\em Create an arithmetic encoder with the specified number of contexts that sends output to the given bit stream. \end{DoxyCompactList}\item 
\hyperlink{classSPL_1_1BinArithEncoder_a059bd835edd440c67a6c8f5fb1d2d628}{$\sim$\+Bin\+Arith\+Encoder} ()
\begin{DoxyCompactList}\small\item\em Destroy an arithmetic encoder. \end{DoxyCompactList}\item 
int \hyperlink{group__ArithCoder_ga09e1ee8987886cbab62ef2032c55eb55}{get\+Num\+Contexts} () const 
\begin{DoxyCompactList}\small\item\em Get the number of contexts. \end{DoxyCompactList}\item 
S\+P\+L\+\_\+\+Arith\+Coder\+\_\+ulong \hyperlink{group__ArithCoder_gafb63f84d1c15a7b7350d4b467cf930f9}{get\+Sym\+Count} () const 
\begin{DoxyCompactList}\small\item\em Get the number of symbols output so far. \end{DoxyCompactList}\item 
S\+P\+L\+\_\+\+Arith\+Coder\+\_\+ulong \hyperlink{group__ArithCoder_ga50f2d044ad72683a9e14b4204a977dc3}{get\+Bit\+Count} () const 
\begin{DoxyCompactList}\small\item\em Get the number of bits output so far. \end{DoxyCompactList}\item 
void \hyperlink{group__ArithCoder_gadd14a704c1e2fe7eea549462c79d71dc}{set\+Output} (\hyperlink{classSPL_1_1OutputBitStream}{Output\+Bit\+Stream} $\ast$out)
\begin{DoxyCompactList}\small\item\em Set the bit stream to which encoded data should be written. \end{DoxyCompactList}\item 
\hyperlink{classSPL_1_1OutputBitStream}{Output\+Bit\+Stream} $\ast$ \hyperlink{group__ArithCoder_ga2407971b23de392e808c108ad8fab6ff}{get\+Output} () const 
\begin{DoxyCompactList}\small\item\em Get the bit stream to which encoded data should be written. \end{DoxyCompactList}\item 
void \hyperlink{classSPL_1_1BinArithEncoder_afb577a2694a9061fcb3e42353ebc471d}{set\+Context\+State} (int context\+Id, Arith\+Coder\+::\+Freq one\+Freq, Arith\+Coder\+::\+Freq total\+Freq, Arith\+Coder\+::\+Freq max\+Freq, bool adaptive)
\begin{DoxyCompactList}\small\item\em Set the symbol probabilities and adaptivity for the specified context. \end{DoxyCompactList}\item 
void \hyperlink{classSPL_1_1BinArithEncoder_acef550178d6238c067a58601ccc3120b}{get\+Context\+State} (int context\+Id, Arith\+Coder\+::\+Freq \&one\+Freq, Arith\+Coder\+::\+Freq \&total\+Freq, Arith\+Coder\+::\+Freq \&max\+Freq, bool \&adaptive)
\begin{DoxyCompactList}\small\item\em Get the symbol probabilities and adaptivity for the specified context. \end{DoxyCompactList}\item 
int \hyperlink{classSPL_1_1BinArithEncoder_a5176ba876a6c0834a7f9153a5f9ec273}{start} ()
\begin{DoxyCompactList}\small\item\em Start a code word. \end{DoxyCompactList}\item 
int \hyperlink{classSPL_1_1BinArithEncoder_ab6c16f781929e0f9edf386072e92d3c0}{encode\+Regular} (int context\+Id, int bin\+Val)
\begin{DoxyCompactList}\small\item\em Encode the specified symbol in the given context. \end{DoxyCompactList}\item 
int \hyperlink{classSPL_1_1BinArithEncoder_a8fe480e5ec4541dfb4c77e50c4671b40}{encode\+Bypass} (int bin\+Val)
\begin{DoxyCompactList}\small\item\em Encode the specified symbol in bypass mode (i.\+e., using a fixed probability distribution with all symbols being equiprobable). \end{DoxyCompactList}\item 
int \hyperlink{classSPL_1_1BinArithEncoder_a660483f1e819849f8d7ab262768f9a74}{terminate} ()
\begin{DoxyCompactList}\small\item\em Terminate the code word. \end{DoxyCompactList}\item 
void \hyperlink{classSPL_1_1BinArithEncoder_af2cace1a21b10a8cb5198cd2a7541cf7}{dump} (std\+::ostream \&out) const 
\begin{DoxyCompactList}\small\item\em Dump the internal encoder state to the specified output stream for debugging purposes. \end{DoxyCompactList}\item 
void \hyperlink{classSPL_1_1BinArithEncoder_a8fe89a2298f93ee70dd088efdff5b097}{dump\+Models} (std\+::ostream \&out) const 
\begin{DoxyCompactList}\small\item\em Dump the internal encoder context state to the specified output stream for debugging purposes. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Static Public Member Functions}
\begin{DoxyCompactItemize}
\item 
static void \hyperlink{group__ArithCoder_ga74b1486fbe4ca0d2845a2206a58eefa3}{set\+Debug\+Level} (int debug\+Level)
\begin{DoxyCompactList}\small\item\em Set the debug level. \end{DoxyCompactList}\item 
static void \hyperlink{group__ArithCoder_ga0cfb56b6f52ab2cec145d929afb275e6}{set\+Debug\+Stream} (std\+::ostream \&out)
\begin{DoxyCompactList}\small\item\em Set the stream to use for debugging output. \end{DoxyCompactList}\item 
static std\+::ostream \& \hyperlink{group__ArithCoder_gac5bb19d3d3511dde13f503cfa8b45a80}{get\+Debug\+Stream} ()
\begin{DoxyCompactList}\small\item\em Get the stream used for debugging output. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Binary arithmetic encoder class. 

\subsection{Constructor \& Destructor Documentation}
\hypertarget{classSPL_1_1BinArithEncoder_a82338540a046e4c13a195cd3102f7ee6}{}\index{S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}!Bin\+Arith\+Encoder@{Bin\+Arith\+Encoder}}
\index{Bin\+Arith\+Encoder@{Bin\+Arith\+Encoder}!S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}}
\subsubsection[{Bin\+Arith\+Encoder}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+L\+::\+Bin\+Arith\+Encoder\+::\+Bin\+Arith\+Encoder (
\begin{DoxyParamCaption}
\item[{int}]{num\+Contexts, }
\item[{{\bf Output\+Bit\+Stream} $\ast$}]{out = {\ttfamily nullptr}}
\end{DoxyParamCaption}
)}\label{classSPL_1_1BinArithEncoder_a82338540a046e4c13a195cd3102f7ee6}


Create an arithmetic encoder with the specified number of contexts that sends output to the given bit stream. 


\begin{DoxyParams}{Parameters}
{\em num\+Contexts} & The number of contexts. \\
\hline
{\em out} & The output bit stream.\\
\hline
\end{DoxyParams}
This constructor creates an arithmetic encoder with the number of contexts being {\ttfamily num\+Contexts} that sends output to the bit stream {\ttfamily out}. \hypertarget{classSPL_1_1BinArithEncoder_a059bd835edd440c67a6c8f5fb1d2d628}{}\index{S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}!````~Bin\+Arith\+Encoder@{$\sim$\+Bin\+Arith\+Encoder}}
\index{````~Bin\+Arith\+Encoder@{$\sim$\+Bin\+Arith\+Encoder}!S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}}
\subsubsection[{$\sim$\+Bin\+Arith\+Encoder}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+L\+::\+Bin\+Arith\+Encoder\+::$\sim$\+Bin\+Arith\+Encoder (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classSPL_1_1BinArithEncoder_a059bd835edd440c67a6c8f5fb1d2d628}


Destroy an arithmetic encoder. 

This destructor destroys an arithmetic encoder. 

\subsection{Member Function Documentation}
\hypertarget{classSPL_1_1BinArithEncoder_af2cace1a21b10a8cb5198cd2a7541cf7}{}\index{S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}!dump@{dump}}
\index{dump@{dump}!S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}}
\subsubsection[{dump}]{\setlength{\rightskip}{0pt plus 5cm}void S\+P\+L\+::\+Bin\+Arith\+Encoder\+::dump (
\begin{DoxyParamCaption}
\item[{std\+::ostream \&}]{out}
\end{DoxyParamCaption}
) const}\label{classSPL_1_1BinArithEncoder_af2cace1a21b10a8cb5198cd2a7541cf7}


Dump the internal encoder state to the specified output stream for debugging purposes. 

\hypertarget{classSPL_1_1BinArithEncoder_a8fe89a2298f93ee70dd088efdff5b097}{}\index{S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}!dump\+Models@{dump\+Models}}
\index{dump\+Models@{dump\+Models}!S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}}
\subsubsection[{dump\+Models}]{\setlength{\rightskip}{0pt plus 5cm}void S\+P\+L\+::\+Bin\+Arith\+Encoder\+::dump\+Models (
\begin{DoxyParamCaption}
\item[{std\+::ostream \&}]{out}
\end{DoxyParamCaption}
) const}\label{classSPL_1_1BinArithEncoder_a8fe89a2298f93ee70dd088efdff5b097}


Dump the internal encoder context state to the specified output stream for debugging purposes. 

\hypertarget{classSPL_1_1BinArithEncoder_a8fe480e5ec4541dfb4c77e50c4671b40}{}\index{S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}!encode\+Bypass@{encode\+Bypass}}
\index{encode\+Bypass@{encode\+Bypass}!S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}}
\subsubsection[{encode\+Bypass}]{\setlength{\rightskip}{0pt plus 5cm}int S\+P\+L\+::\+Bin\+Arith\+Encoder\+::encode\+Bypass (
\begin{DoxyParamCaption}
\item[{int}]{bin\+Val}
\end{DoxyParamCaption}
)}\label{classSPL_1_1BinArithEncoder_a8fe480e5ec4541dfb4c77e50c4671b40}


Encode the specified symbol in bypass mode (i.\+e., using a fixed probability distribution with all symbols being equiprobable). 


\begin{DoxyParams}{Parameters}
{\em bin\+Val} & The symbol to be encoded.\\
\hline
\end{DoxyParams}
This function encodes the symbol {\ttfamily bin\+Val} in bypass mode (i.\+e., using a fixed probability distribution with all symbols being equiprobable). The symbol to be encoded must be either 0 or 1.

\begin{DoxyReturn}{Returns}
Upon success, zero is returned; otherwise, a nonzero value is returned. 
\end{DoxyReturn}
\hypertarget{classSPL_1_1BinArithEncoder_ab6c16f781929e0f9edf386072e92d3c0}{}\index{S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}!encode\+Regular@{encode\+Regular}}
\index{encode\+Regular@{encode\+Regular}!S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}}
\subsubsection[{encode\+Regular}]{\setlength{\rightskip}{0pt plus 5cm}int S\+P\+L\+::\+Bin\+Arith\+Encoder\+::encode\+Regular (
\begin{DoxyParamCaption}
\item[{int}]{context\+Id, }
\item[{int}]{bin\+Val}
\end{DoxyParamCaption}
)}\label{classSPL_1_1BinArithEncoder_ab6c16f781929e0f9edf386072e92d3c0}


Encode the specified symbol in the given context. 


\begin{DoxyParams}{Parameters}
{\em context\+Id} & The I\+D of the context to be used for encoding. \\
\hline
{\em bin\+Val} & The symbol to be encoded.\\
\hline
\end{DoxyParams}
This function encodes the symbol {\ttfamily bin\+Val} using the context specified by {\ttfamily context\+Id}. The value of {\ttfamily context\+Id} must be from 0 to n -\/ 1 (inclusive), where n is the number of contexts employed by the arithmetic encoder. The symbol to be encoded must be either 0 or 1.

\begin{DoxyReturn}{Returns}
Upon success, zero is returned; otherwise, a nonzero value is returned. 
\end{DoxyReturn}
\hypertarget{classSPL_1_1BinArithEncoder_acef550178d6238c067a58601ccc3120b}{}\index{S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}!get\+Context\+State@{get\+Context\+State}}
\index{get\+Context\+State@{get\+Context\+State}!S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}}
\subsubsection[{get\+Context\+State}]{\setlength{\rightskip}{0pt plus 5cm}void S\+P\+L\+::\+Bin\+Arith\+Encoder\+::get\+Context\+State (
\begin{DoxyParamCaption}
\item[{int}]{context\+Id, }
\item[{Arith\+Coder\+::\+Freq \&}]{one\+Freq, }
\item[{Arith\+Coder\+::\+Freq \&}]{total\+Freq, }
\item[{Arith\+Coder\+::\+Freq \&}]{max\+Freq, }
\item[{bool \&}]{adaptive}
\end{DoxyParamCaption}
)}\label{classSPL_1_1BinArithEncoder_acef550178d6238c067a58601ccc3120b}


Get the symbol probabilities and adaptivity for the specified context. 


\begin{DoxyParams}[1]{Parameters}
 & {\em context\+Id} & The I\+D of the context to query. \\
\hline
\mbox{\tt out}  & {\em one\+Freq} & The frequency count for a one symbol. \\
\hline
\mbox{\tt out}  & {\em total\+Freq} & The normalizing frequency count for all symbols. \\
\hline
\mbox{\tt out}  & {\em max\+Freq} & The maximum normalizing frequency count. \\
\hline
\mbox{\tt out}  & {\em adaptive} & The adaptivity flag.\\
\hline
\end{DoxyParams}
This function queries the state of the context with the context I\+D {\ttfamily context\+Id}, and sets the parameters {\ttfamily one\+Freq}, {\ttfamily total\+Freq}, {\ttfamily max\+Freq}, and {\ttfamily adaptive} appropriately. The probability of a one symbol is given by {\ttfamily one\+Freq} / {\ttfamily total\+Freq}, while the probability of a zero symbol is given by 1 -\/ {\ttfamily one\+Freq} / {\ttfamily total\+Freq}. \hypertarget{classSPL_1_1BinArithEncoder_afb577a2694a9061fcb3e42353ebc471d}{}\index{S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}!set\+Context\+State@{set\+Context\+State}}
\index{set\+Context\+State@{set\+Context\+State}!S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}}
\subsubsection[{set\+Context\+State}]{\setlength{\rightskip}{0pt plus 5cm}void S\+P\+L\+::\+Bin\+Arith\+Encoder\+::set\+Context\+State (
\begin{DoxyParamCaption}
\item[{int}]{context\+Id, }
\item[{Arith\+Coder\+::\+Freq}]{one\+Freq, }
\item[{Arith\+Coder\+::\+Freq}]{total\+Freq, }
\item[{Arith\+Coder\+::\+Freq}]{max\+Freq, }
\item[{bool}]{adaptive}
\end{DoxyParamCaption}
)}\label{classSPL_1_1BinArithEncoder_afb577a2694a9061fcb3e42353ebc471d}


Set the symbol probabilities and adaptivity for the specified context. 

\hypertarget{classSPL_1_1BinArithEncoder_a5176ba876a6c0834a7f9153a5f9ec273}{}\index{S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}!start@{start}}
\index{start@{start}!S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}}
\subsubsection[{start}]{\setlength{\rightskip}{0pt plus 5cm}int S\+P\+L\+::\+Bin\+Arith\+Encoder\+::start (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classSPL_1_1BinArithEncoder_a5176ba876a6c0834a7f9153a5f9ec273}


Start a code word. 

This function starts the encoding of a new code word. This function must be called before attempting to encode any symbols.

\begin{DoxyReturn}{Returns}
Upon success, zero is returned; otherwise, a nonzero value is returned. 
\end{DoxyReturn}
\hypertarget{classSPL_1_1BinArithEncoder_a660483f1e819849f8d7ab262768f9a74}{}\index{S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}!terminate@{terminate}}
\index{terminate@{terminate}!S\+P\+L\+::\+Bin\+Arith\+Encoder@{S\+P\+L\+::\+Bin\+Arith\+Encoder}}
\subsubsection[{terminate}]{\setlength{\rightskip}{0pt plus 5cm}int S\+P\+L\+::\+Bin\+Arith\+Encoder\+::terminate (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{classSPL_1_1BinArithEncoder_a660483f1e819849f8d7ab262768f9a74}


Terminate the code word. 

This function terminates the encoding of the current arithmetic code word.

\begin{DoxyReturn}{Returns}
Upon success, zero is returned; otherwise, a nonzero value is returned. 
\end{DoxyReturn}


The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
\item 
\hyperlink{arithCoder_8hpp}{arith\+Coder.\+hpp}\item 
arith\+Coder.\+cpp\end{DoxyCompactItemize}
