46 #ifndef _ARITH_CODEC_H_
47 #define _ARITH_CODEC_H_
90 static const unsigned int lut[256];
123 void EncodeSymbol(
const bool symbol,
const int context_num);
125 void EncodeUInt(
const unsigned int value,
const int bin1,
const int max_bin);
127 void EncodeSInt(
const int value,
const int bin1,
const int max_bin);
143 unsigned int DecodeUInt(
const int bin1,
const int max_bin);
145 int DecodeSInt(
const int bin1,
const int max_bin);
214 const bool symbol = ( count >= range_x_prob );
219 m_low_code += range_x_prob;
232 if( ( (m_low_code+
m_range-1)^m_low_code)>=0x8000 )
239 m_low_code ^= 0x4000;
245 m_low_code &= 0xFFFF;
258 const int info_ctx = (max_bin+1);
260 unsigned int value = 1;
264 if (bin<max_bin) bin+=1;
272 const int magnitude =
DecodeUInt(bin1, max_bin);
275 else value=magnitude;
333 const int bin1,
const int max_bin) {
334 const int value = (the_int+1);
335 const int info_ctx = (max_bin+1);
340 while (value>max_value) {
346 bool stop = (top_bit==1);
351 if ( bin < max_bin) bin+=1;
358 const int bin1,
const int max_bin) {
415 void Decompress(T & out_data,
const int num_bytes);
451 InitDecoder(num_bytes);
452 DoWorkDecode( out_data );
ArithCodec(ByteIO *p_byteio, size_t number_of_contexts)
Constructor for encoding.
Definition: arith_codec.h:434
unsigned int m_code
The present input code.
Definition: arith_codec.h:197
void InitEncoder()
Initialises the Encoder.
unsigned int GetScaledProb0() const
Returns estimate of probability of 0 (false) scaled to 2**16.
Definition: arith_codec.h:79
unsigned int DecodeUInt(const int bin1, const int max_bin)
Definition: arith_codec.h:257
virtual ~ArithCodecBase()
Destructor.
Abstract binary arithmetic coding class.
Definition: arith_codec.h:374
char * m_decode_data_ptr
A pointer to the data for reading in.
Definition: arith_codec.h:188
bool DecodeSymbol(int context_num)
Decodes a symbol given a context number.
Definition: arith_codec.h:202
unsigned int m_low_code
Start of the current code range.
Definition: arith_codec.h:174
bool InputBit()
Read in a bit of data.
Definition: arith_codec.h:455
virtual ~ArithCodec()
Destructor.
Definition: arith_codec.h:393
void InitDecoder(int num_bytes)
Initialise the Decoder.
int m_underflow
Number of underflow bits.
Definition: arith_codec.h:185
int DecodeSInt(const int bin1, const int max_bin)
Definition: arith_codec.h:270
ArithCodecBase & operator=(const ArithCodecBase &rhs)
private, bodyless copy operator=: class should not be assigned
void Decompress(T &out_data, const int num_bytes)
Decompresses the bitstream and writes into the output.
Definition: arith_codec.h:449
int Compress(T &in_data)
Compresses the input and returns the number of bits written.
Definition: arith_codec.h:440
virtual void DoWorkDecode(T &out_data)=0
virtual decode-only functions
Definition: arith_codec.h:65
std::vector< Context > m_context_list
List of contexts.
Definition: arith_codec.h:148
ArithCodecBase(ByteIO *p_byteio, size_t number_of_contexts)
Constructor.
unsigned int m_range
Length of the current code range.
Definition: arith_codec.h:177
Context()
Default Constructor.
Definition: arith_codec.h:93
void ReadAllData(int num_bytes)
Read all the data in.
void EncodeSInt(const int value, const int bin1, const int max_bin)
Definition: arith_codec.h:357
int m_input_bits_left
The index of the bit of the byte being read.
Definition: arith_codec.h:194
virtual void DoWorkCode(T &in_data)=0
Does the work of actually coding the data.
void FlushEncoder()
flushes the output of the encoder.
void EncodeUInt(const unsigned int value, const int bin1, const int max_bin)
Definition: arith_codec.h:332
Definition of class SequenceHeaderByteIO.
Definition: accessunit_byteio.h:51
int m_prob0
Definition: arith_codec.h:89
char * m_data_ptr
A point to the byte currently being read.
Definition: arith_codec.h:191
Class ByteIO - top-level class for reading/writing bytes to a stream.
Definition: byteio.h:72
void EncodeSymbol(const bool symbol, const int context_num)
encodes a symbol and writes to output
Definition: arith_codec.h:280
void Update(bool symbol)
Updates context counts.
Definition: arith_codec.h:82
Definition: arith_codec.h:95
static const unsigned int lut[256]
Definition: arith_codec.h:90
void WriteBit(const bool &bit)
Outputs a bit.
ByteIO * m_byteio
Input/output stream of Dirac-format bytes.
Definition: arith_codec.h:180
unsigned int m_scount
Definition: arith_codec.h:171