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... | |
InputBitStream * | getInput () 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... | |
Binary arithmetic decoder class.
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.
numContexts | The number of contexts. |
in | The 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.
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).
int SPL::BinArithDecoder::decodeRegular | ( | int | contextId | ) |
Decode a symbol in the specified context.
contextId | The 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.
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.
contextId | The ID of the context to query. | |
[out] | oneFreq | The frequency count for a one symbol. |
[out] | totalFreq | The normalizing frequency count for all symbols. |
[out] | maxFreq | The maximum normalizing frequency count. |
[out] | adaptive | The 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.
int SPL::BinArithDecoder::terminate | ( | ) |
Terminate the code word (for synchonization with the encoder).
This function terminates the decoding of the current arithmetic code word.