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 );
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) {
451 InitDecoder(num_bytes);
452 DoWorkDecode( out_data );
Definition of class SequenceHeaderByteIO.
Definition: accessunit_byteio.h:52
Class ByteIO - top-level class for reading/writing bytes to a stream.
Definition: byteio.h:73
void WriteBit(const bool &bit)
Outputs a bit.
Definition: arith_codec.h:65
void Update(bool symbol)
Updates context counts.
Definition: arith_codec.h:82
Context()
Default Constructor.
Definition: arith_codec.h:93
int m_prob0
Definition: arith_codec.h:89
unsigned int GetScaledProb0() const
Returns estimate of probability of 0 (false) scaled to 2**16.
Definition: arith_codec.h:79
static const unsigned int lut[256]
Definition: arith_codec.h:90
Definition: arith_codec.h:95
char * m_data_ptr
A point to the byte currently being read.
Definition: arith_codec.h:191
unsigned int m_range
Length of the current code range.
Definition: arith_codec.h:177
std::vector< Context > m_context_list
List of contexts.
Definition: arith_codec.h:148
void InitEncoder()
Initialises the Encoder.
bool InputBit()
Read in a bit of data.
Definition: arith_codec.h:455
unsigned int m_low_code
Start of the current code range.
Definition: arith_codec.h:174
ByteIO * m_byteio
Input/output stream of Dirac-format bytes.
Definition: arith_codec.h:180
char * m_decode_data_ptr
A pointer to the data for reading in.
Definition: arith_codec.h:188
int m_input_bits_left
The index of the bit of the byte being read.
Definition: arith_codec.h:194
unsigned int m_scount
Definition: arith_codec.h:171
ArithCodecBase(const ArithCodecBase &cpy)
private, bodyless copy constructor: class should not be copied
ArithCodecBase(ByteIO *p_byteio, size_t number_of_contexts)
Constructor.
int DecodeSInt(const int bin1, const int max_bin)
Definition: arith_codec.h:270
int m_underflow
Number of underflow bits.
Definition: arith_codec.h:185
void EncodeSInt(const int value, const int bin1, const int max_bin)
Definition: arith_codec.h:357
void ReadAllData(int num_bytes)
Read all the data in.
virtual ~ArithCodecBase()
Destructor.
ArithCodecBase & operator=(const ArithCodecBase &rhs)
private, bodyless copy operator=: class should not be assigned
unsigned int m_code
The present input code.
Definition: arith_codec.h:197
void EncodeSymbol(const bool symbol, const int context_num)
encodes a symbol and writes to output
Definition: arith_codec.h:280
void InitDecoder(int num_bytes)
Initialise the Decoder.
unsigned int DecodeUInt(const int bin1, const int max_bin)
Definition: arith_codec.h:257
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
bool DecodeSymbol(int context_num)
Decodes a symbol given a context number.
Definition: arith_codec.h:202
Abstract binary arithmetic coding class.
Definition: arith_codec.h:376
int Compress(T &in_data)
Compresses the input and returns the number of bits written.
Definition: arith_codec.h:440
virtual void DoWorkCode(T &in_data)=0
Does the work of actually coding the data.
virtual ~ArithCodec()
Destructor.
Definition: arith_codec.h:393
virtual void DoWorkDecode(T &out_data)=0
virtual decode-only functions
void Decompress(T &out_data, const int num_bytes)
Decompresses the bitstream and writes into the output.
Definition: arith_codec.h:449
ArithCodec(ByteIO *p_byteio, size_t number_of_contexts)
Constructor for encoding.
Definition: arith_codec.h:434