Dirac - A Video Codec
Created by the British Broadcasting Corporation.
Go to the documentation of this file.
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) {
415 void Decompress(T & out_data,
const int num_bytes);
451 InitDecoder(num_bytes);
452 DoWorkDecode( out_data );
455 inline bool ArithCodecBase::InputBit()
457 if (m_input_bits_left == 0)
460 m_input_bits_left = 8;
464 return bool( ( (*m_data_ptr) >> m_input_bits_left ) & 1 );
void InitDecoder(int num_bytes)
Initialise the Decoder.
int Compress(T &in_data)
Compresses the input and returns the number of bits written.
Definition: arith_codec.h:440
int m_underflow
Number of underflow bits.
Definition: arith_codec.h:185
unsigned int m_range
Length of the current code range.
Definition: arith_codec.h:177
ArithCodecBase(ByteIO *p_byteio, size_t number_of_contexts)
Constructor.
virtual void DoWorkCode(T &in_data)=0
Does the work of actually coding the data.
void EncodeSInt(const int value, const int bin1, const int max_bin)
Definition: arith_codec.h:357
int DecodeSInt(const int bin1, const int max_bin)
Definition: arith_codec.h:270
Definition of class SequenceHeaderByteIO.
Definition: accessunit_byteio.h:51
int m_prob0
Definition: arith_codec.h:89
void WriteBit(const bool &bit)
Outputs a bit.
ArithCodecBase & operator=(const ArithCodecBase &rhs)
private, bodyless copy operator=: class should not be assigned
static const unsigned int lut[256]
Definition: arith_codec.h:90
void Update(bool symbol)
Updates context counts.
Definition: arith_codec.h:82
virtual ~ArithCodecBase()
Destructor.
virtual void DoWorkDecode(T &out_data)=0
virtual decode-only functions
ByteIO * m_byteio
Input/output stream of Dirac-format bytes.
Definition: arith_codec.h:180
void Decompress(T &out_data, const int num_bytes)
Decompresses the bitstream and writes into the output.
Definition: arith_codec.h:449
Class ByteIO - top-level class for reading/writing bytes to a stream.
Definition: byteio.h:72
ArithCodec(ByteIO *p_byteio, size_t number_of_contexts)
Constructor for encoding.
Definition: arith_codec.h:434
int m_input_bits_left
The index of the bit of the byte being read.
Definition: arith_codec.h:194
void InitEncoder()
Initialises the Encoder.
unsigned int DecodeUInt(const int bin1, const int max_bin)
Definition: arith_codec.h:257
Definition: arith_codec.h:65
void EncodeSymbol(const bool symbol, const int context_num)
encodes a symbol and writes to output
Definition: arith_codec.h:280
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
char * m_data_ptr
A point to the byte currently being read.
Definition: arith_codec.h:191
unsigned int m_code
The present input code.
Definition: arith_codec.h:197
void FlushEncoder()
flushes the output of the encoder.
bool InputBit()
Read in a bit of data.
Definition: arith_codec.h:455
Context()
Default Constructor.
Definition: arith_codec.h:93
char * m_decode_data_ptr
A pointer to the data for reading in.
Definition: arith_codec.h:188
void ReadAllData(int num_bytes)
Read all the data in.
unsigned int GetScaledProb0() const
Returns estimate of probability of 0 (false) scaled to 2**16.
Definition: arith_codec.h:79
unsigned int m_scount
Definition: arith_codec.h:171
unsigned int m_low_code
Start of the current code range.
Definition: arith_codec.h:174
Abstract binary arithmetic coding class.
Definition: arith_codec.h:374
virtual ~ArithCodec()
Destructor.
Definition: arith_codec.h:393
std::vector< Context > m_context_list
List of contexts.
Definition: arith_codec.h:148
Definition: arith_codec.h:95
© 2004 British Broadcasting Corporation.
Dirac code licensed under the Mozilla Public License (MPL) Version 1.1.
HTML documentation generated by Dimitri van Heesch's
excellent Doxygen tool.