Signal/Geometry Processing Library (SPL)  1.1.24
SPL::BinArithDecoder Class Reference

Binary arithmetic decoder class. More...

#include <arithCoder.hpp>

Public Member Functions

 BinArithDecoder (int numContexts, InputBitStream *in=nullptr)
 Create a decoder with the specified number of contexts that receives input from the given bit stream. More...
 
 ~BinArithDecoder ()
 Destroy a decoder. More...
 
SPL_ArithCoder_ulong getSymCount () const
 Get the number of symbols decoded so far. More...
 
SPL_ArithCoder_ulong getBitCount () const
 Get the number of bits read so far. More...
 
void setInput (InputBitStream *in)
 Set the bit stream from which to read encoded data. More...
 
InputBitStreamgetInput () const
 Get the bit stream from which to read encoded data. More...
 
int getNumContexts () const
 Get the number of contexts. More...
 
void setContextState (int contextId, ArithCoder::Freq oneFreq, ArithCoder::Freq totalFreq, ArithCoder::Freq maxFreq, bool adaptive)
 Set the symbol probabilities and adaptivity for the specified context. More...
 
void getContextState (int contextId, ArithCoder::Freq &oneFreq, ArithCoder::Freq &totalFreq, ArithCoder::Freq &maxFreq, bool &adaptive)
 Get the symbol probabilities and adaptivity for the specified context. More...
 
int start ()
 Start a code word. More...
 
int terminate ()
 Terminate the code word (for synchonization with the encoder). More...
 
int decodeRegular (int contextId)
 Decode a symbol in the specified context. More...
 
int decodeBypass ()
 Decode a symbol in bypass mode (i.e., using a fixed probability distribution with all symbols being equiprobable). More...
 
void dump (std::ostream &out) const
 Dump the internal decoder state to the specified stream for debugging purposes. More...
 

Static Public Member Functions

static void setDebugLevel (int debugLevel)
 Set the debug level. More...
 
static void setDebugStream (std::ostream &out)
 Set the stream to be used for debugging output. More...
 
static std::ostream & getDebugStream ()
 Get the stream used for debugging output. More...
 

Detailed Description

Binary arithmetic decoder class.

Constructor & Destructor Documentation

SPL::BinArithDecoder::BinArithDecoder ( int  numContexts,
InputBitStream in = nullptr 
)

Create a decoder with the specified number of contexts that receives input from the given bit stream.

Parameters
numContextsThe number of contexts.
inThe input bit stream.

This function creates an arithmetic decoder with the number of contexts being numContexts that receives input from the bit stream in.

SPL::BinArithDecoder::~BinArithDecoder ( )

Destroy a decoder.

This function destroys an arithmetic decoder.

Member Function Documentation

int SPL::BinArithDecoder::decodeBypass ( )

Decode a symbol in bypass mode (i.e., using a fixed probability distribution with all symbols being equiprobable).

This function decodes a symbol in bypass mode (i.e., using a fixed probability distribution with all symbols being equiprobable).

Returns
Upon success, the decoded symbol is returned (which is either 0 or 1); otherwise, a negative value is returned.
int SPL::BinArithDecoder::decodeRegular ( int  contextId)

Decode a symbol in the specified context.

Parameters
contextIdThe ID of the context to be used for decoding.

The function decodes a symbol using the context specified by contextId. The value of contextId must be from 0 to n - 1 (inclusive), where n is the number of contexts employed by the arithmetic decoder.

Returns
Upon success, the decoded symbol is returned (which is either 0 or 1); otherwise, a negative value is returned.
void SPL::BinArithDecoder::dump ( std::ostream &  out) const

Dump the internal decoder state to the specified stream for debugging purposes.

void SPL::BinArithDecoder::getContextState ( int  contextId,
ArithCoder::Freq &  oneFreq,
ArithCoder::Freq &  totalFreq,
ArithCoder::Freq &  maxFreq,
bool &  adaptive 
)

Get the symbol probabilities and adaptivity for the specified context.

Parameters
contextIdThe ID of the context to query.
[out]oneFreqThe frequency count for a one symbol.
[out]totalFreqThe normalizing frequency count for all symbols.
[out]maxFreqThe maximum normalizing frequency count.
[out]adaptiveThe adaptivity flag.

This function queries the state of the context with the context ID contextId, and sets the parameters oneFreq, totalFreq, maxFreq, and adaptive appropriately. The probability of a one symbol is given by oneFreq / totalFreq, while the probability of a zero symbol is given by 1 - oneFreq / totalFreq.

void SPL::BinArithDecoder::setContextState ( int  contextId,
ArithCoder::Freq  oneFreq,
ArithCoder::Freq  totalFreq,
ArithCoder::Freq  maxFreq,
bool  adaptive 
)

Set the symbol probabilities and adaptivity for the specified context.

int SPL::BinArithDecoder::start ( )

Start a code word.

This function starts the decoding of a new arithmetic code word. This function must be called before attempting to decode any symbols.

Returns
Upon success, zero is returned; otherwise, a nonzero value is returned.
int SPL::BinArithDecoder::terminate ( )

Terminate the code word (for synchonization with the encoder).

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

Returns
Upon success, zero is returned; otherwise, a nonzero value is returned.

The documentation for this class was generated from the following files: