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

Binary arithmetic encoder class. More...

#include <arithCoder.hpp>

Public Member Functions

 BinArithEncoder (int numContexts, OutputBitStream *out=nullptr)
 Create an arithmetic encoder with the specified number of contexts that sends output to the given bit stream. More...
 
 ~BinArithEncoder ()
 Destroy an arithmetic encoder. More...
 
int getNumContexts () const
 Get the number of contexts. More...
 
SPL_ArithCoder_ulong getSymCount () const
 Get the number of symbols output so far. More...
 
SPL_ArithCoder_ulong getBitCount () const
 Get the number of bits output so far. More...
 
void setOutput (OutputBitStream *out)
 Set the bit stream to which encoded data should be written. More...
 
OutputBitStreamgetOutput () const
 Get the bit stream to which encoded data should be written. 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 encodeRegular (int contextId, int binVal)
 Encode the specified symbol in the given context. More...
 
int encodeBypass (int binVal)
 Encode the specified symbol in bypass mode (i.e., using a fixed probability distribution with all symbols being equiprobable). More...
 
int terminate ()
 Terminate the code word. More...
 
void dump (std::ostream &out) const
 Dump the internal encoder state to the specified output stream for debugging purposes. More...
 
void dumpModels (std::ostream &out) const
 Dump the internal encoder context state to the specified output 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 use for debugging output. More...
 
static std::ostream & getDebugStream ()
 Get the stream used for debugging output. More...
 

Detailed Description

Binary arithmetic encoder class.

Constructor & Destructor Documentation

SPL::BinArithEncoder::BinArithEncoder ( int  numContexts,
OutputBitStream out = nullptr 
)

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

Parameters
numContextsThe number of contexts.
outThe output bit stream.

This constructor creates an arithmetic encoder with the number of contexts being numContexts that sends output to the bit stream out.

SPL::BinArithEncoder::~BinArithEncoder ( )

Destroy an arithmetic encoder.

This destructor destroys an arithmetic encoder.

Member Function Documentation

void SPL::BinArithEncoder::dump ( std::ostream &  out) const

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

void SPL::BinArithEncoder::dumpModels ( std::ostream &  out) const

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

int SPL::BinArithEncoder::encodeBypass ( int  binVal)

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

Parameters
binValThe symbol to be encoded.

This function encodes the symbol binVal 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.

Returns
Upon success, zero is returned; otherwise, a nonzero value is returned.
int SPL::BinArithEncoder::encodeRegular ( int  contextId,
int  binVal 
)

Encode the specified symbol in the given context.

Parameters
contextIdThe ID of the context to be used for encoding.
binValThe symbol to be encoded.

This function encodes the symbol binVal 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 encoder. The symbol to be encoded must be either 0 or 1.

Returns
Upon success, zero is returned; otherwise, a nonzero value is returned.
void SPL::BinArithEncoder::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::BinArithEncoder::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::BinArithEncoder::start ( )

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.

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

Terminate the code word.

This function terminates the encoding 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: