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... | |
| OutputBitStream * | getOutput () 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... | |
Binary arithmetic encoder class.
| 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.
| numContexts | The number of contexts. |
| out | The 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.
| 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).
| binVal | The 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.
| int SPL::BinArithEncoder::encodeRegular | ( | int | contextId, |
| int | binVal | ||
| ) |
Encode the specified symbol in the given context.
| contextId | The ID of the context to be used for encoding. |
| binVal | The 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.
| 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.
| 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::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.
| int SPL::BinArithEncoder::terminate | ( | ) |
Terminate the code word.
This function terminates the encoding of the current arithmetic code word.