40 #ifndef SPL_mCoder_hpp
41 #define SPL_mCoder_hpp
47 #include <SPL/config.hpp>
74 static const unsigned char rangeTabLPS[64][4];
75 static const unsigned char transIdxLPS[64];
76 static const unsigned char transIdxMPS[64];
80 struct MCoder::Context {
82 unsigned char valMPS_;
85 unsigned char pStateIdx_;
204 void dump(std::ostream& out)
const;
208 static int debugLevel_;
209 static std::ostream* debugStream_;
211 int encodeTerminate(
int binVal);
215 int writeBits(
int v,
int n);
229 std::vector<Context> contexts_;
232 unsigned char firstBitFlag_;
235 unsigned short codILow_;
238 unsigned short codIRange_;
241 unsigned long bitsOutstanding_;
261 return bitCount_ + bitsOutstanding_;
265 return contexts_.size();
379 void dump(std::ostream& out)
const;
398 static int debugLevel_;
399 static std::ostream* debugStream_;
400 int decodeTerminate();
416 unsigned short codIRange_;
419 unsigned short codIOffset_;
422 std::vector<Context> contexts_;
425 unsigned long bitCount_;
428 unsigned long symCount_;
444 return contexts_.size();
static void setDebugLevel(int debugLevel)
Set the debug level.
Definition: mCoder.cpp:385
static std::ostream & getDebugStream()
Get the stream used for debugging output.
Definition: mCoder.cpp:395
static void setDebugLevel(int debugLevel)
Set the debug level.
Definition: mCoder.cpp:620
int decodeRegular(int contextId)
Decode a symbol in the specified context.
Definition: mCoder.cpp:475
InputBitStream * getInput() const
Get the input bit stream (i.e., the bit stream from which encoded data is to be read).
Definition: mCoder.hpp:447
void clearContexts()
Clear the state of all of the contexts.
Definition: mCoder.cpp:179
void dump(std::ostream &out) const
Dump the internal state of the encoder for debugging.
Definition: mCoder.cpp:374
int start()
Prepare to decode an arithmetic code word.
Definition: mCoder.cpp:456
Definition: Arcball.hpp:48
int decodeBypass()
Decode a symbol in bypass mode (i.e., assuming both symbols are equiprobable).
Definition: mCoder.cpp:512
The M-Coder (binary) arithmetic encoder class.
Definition: mCoder.hpp:96
int terminate()
Terminate the arithmetic code word.
Definition: mCoder.cpp:541
int encodeBypass(int binVal)
Encode a symbol in bypass mode (i.e., assuming that both symbols are equiprobable).
Definition: mCoder.cpp:235
static void setDebugStream(std::ostream &debugStream)
Set the stream for debugging output.
Definition: mCoder.cpp:390
long getBitCount() const
Get the number of bits read so far.
Definition: mCoder.hpp:435
void setNumContexts(int numContexts)
Set the number of contexts.
Definition: mCoder.cpp:172
static void setDebugStream(std::ostream &debugStream)
Set the stream to use for debugging output.
Definition: mCoder.cpp:625
Output bit stream class.
Definition: bitStream.hpp:372
The M-Coder (binary) arithmetic decoder class.
Definition: mCoder.hpp:284
~MDecoder()
Destroy a decoder.
Definition: mCoder.cpp:433
long getSymCount() const
Get the number of symbols decoded so far.
Definition: mCoder.hpp:439
void setOutput(OutputBitStream *out)
Set the bit stream to use for output.
Definition: mCoder.hpp:272
int getNumContexts() const
Get the number of contexts.
Definition: mCoder.hpp:443
OutputBitStream * getOutput() const
Get the bit stream being used for output.
Definition: mCoder.hpp:268
void setNumContexts(int numContexts)
Set the number of contexts.
Definition: mCoder.cpp:441
void setInput(InputBitStream *in)
Set the input bit stream (i.e., the bit stream from which encoded data is to be read).
Definition: mCoder.hpp:451
~MEncoder()
Destroy an encoder.
Definition: mCoder.cpp:164
long getSymCount() const
Get the number of symbols that have been encoded so far.
Definition: mCoder.hpp:254
int encodeRegular(int contextId, int binVal)
Encode a symbol in the specified context.
Definition: mCoder.cpp:202
MEncoder(int numContexts=0, OutputBitStream *out=0)
Create an encoder with a specified number of contexts that sends output to a given bit stream...
Definition: mCoder.cpp:149
int getNumContexts() const
Get the number of contexts.
Definition: mCoder.hpp:264
void dump(std::ostream &out) const
Dump the internal state information for the decoder to a stream (for debugging).
Definition: mCoder.cpp:608
void clearContexts()
Clear the state of all of the contexts.
Definition: mCoder.cpp:448
long getBitCount() const
Get the number of bits (of encoded data) that have been output to the underlying bit stream so far...
Definition: mCoder.hpp:259
MDecoder(int numContexts=0, InputBitStream *in=0)
Create a decoder with the specified number of contexts that reads input from the given bit stream...
Definition: mCoder.cpp:422
void start()
Start the arithmetic code word.
Definition: mCoder.cpp:187
int terminate()
Terminate the arithmetic code word.
Definition: mCoder.cpp:268
static std::ostream & getDebugStream()
Get the stream used for debugging output.
Definition: mCoder.cpp:630