Dirac - A Video Codec

Created by the British Broadcasting Corporation.


Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Friends | List of all members
dirac::ByteIO Class Reference

Class ByteIO - top-level class for reading/writing bytes to a stream.

#include <byteio.h>

Inheritance diagram for dirac::ByteIO:
Inheritance graph
[legend]

Public Member Functions

 ByteIO (bool new_stream=true)
 Default constructor. More...
 
 ByteIO (const ByteIO &stream_data)
 Constructor. More...
 
virtual ~ByteIO ()
 Destructor. More...
 
virtual void CollateByteStats (DiracByteStats &dirac_byte_stats)
 Gathers byte-stream statistics. More...
 
virtual const std::string GetBytes ()
 Get bytes in Dirac-bytestream format. More...
 
int GetReadBytePosition () const
 Get position of read stream pointer. More...
 
virtual int GetSize () const
 Gets size (in bytes) More...
 
void SetByteParams (const ByteIO &byte_io)
 Copies stream source/destination info. More...
 
void ByteAlignOutput ()
 Sync input for byte-alignment. More...
 
void WriteUint (unsigned int value)
 Ouputs an unsigned integer in interleaved exp Golomb format. More...
 
void SetBitsLeft (int left_bits)
 Sets input size in bits. More...
 
int BitsLeft (void)
 Sets input size in bits. More...
 

Protected Member Functions

bool CanRead () const
 
bool GetBit (unsigned char &c, int pos) const
 
void SetBit (unsigned char &c, int pos) const
 
void SetBits (unsigned char &c, unsigned char bits) const
 
void ByteAlignInput ()
 Sync input for byte-alignment. More...
 
bool ReadBool ()
 Reads boolean value. More...
 
bool ReadBoolB ()
 Reads boolean value - bounded i/o. More...
 
int ReadBit ()
 Reads next bit. More...
 
int ReadBitB ()
 Reads next bit - bounded i/o. More...
 
unsigned int ReadNBits (int count)
 Reads next 'count' bits. More...
 
void InputBytes (char *data, int count)
 Reads from stream. More...
 
void FlushInputB ()
 Flushes the bounde input. More...
 
int ReadSint ()
 Reads a signed integer in interleaved exp-Golomb format return Signed integer read. More...
 
int ReadSintB ()
 Reads a signed integer in interleaved exp-Golomb format from bounded input return Signed integer read. More...
 
unsigned int ReadUint ()
 Reads an unsigned integer in interleaved exp Golomb format. More...
 
unsigned int ReadUintB ()
 Reads an unsigned integer in interleaved exp Golomb format from bounded input. More...
 
unsigned int ReadUintLit (const int byte_size)
 Reads a fixed length unsigned integer from the stream in big endian. More...
 
unsigned char InputUnByte ()
 Reads a byte from the stream. More...
 
std::string InputUnString (const int count)
 Reads a series of bytes from a stream. More...
 
void WriteBit (const bool &bit)
 Outputs a bit. More...
 
int WriteNBits (unsigned int val)
 Outputs an unsigned integer. More...
 
void WriteNBits (unsigned int val, int count)
 Outputs an n bit integer. More...
 
void OutputBytes (const std::string &bytes)
 Outputs a series of bytes. More...
 
void OutputCurrentByte ()
 Outputs current byte contents. More...
 
void WriteSint (int val)
 Outputs an integer in Golomb signed integer format. More...
 
void WriteUintLit (const unsigned int &value, const int &length)
 Output unsigned int value in big endian format. More...
 
void RemoveRedundantBytes (const int count)
 Removes portion of byte-stream no longer required. More...
 
void SeekGet (const int offset, std::ios_base::seekdir dir)
 

Protected Attributes

std::stringstream * mp_stream
 Input/output steam. More...
 

Private Attributes

unsigned char m_current_byte
 Char used for temporary storage of op data bits. More...
 
int m_current_pos
 Used to set individual bit within the current header byte. More...
 
int m_num_bytes
 Number of bytes processed. More...
 
bool m_new_stream
 stream alloc flag More...
 
int m_bits_left
 num bits left to read More...
 

Friends

class ArithCodecBase
 ArithCodec can see internals for getting/setting bits. More...
 
class ArithCodecToVLCAdapter
 VLC entropy coder can see internals for getting/setting bits. More...
 

Constructor & Destructor Documentation

◆ ByteIO() [1/2]

dirac::ByteIO::ByteIO ( bool  new_stream = true)
Parameters
new_streamHas Creates & owns data buffer

◆ ByteIO() [2/2]

dirac::ByteIO::ByteIO ( const ByteIO stream_data)
Parameters
stream_dataCopies data buffer details

◆ ~ByteIO()

virtual dirac::ByteIO::~ByteIO ( )
virtual

Member Function Documentation

◆ BitsLeft()

int dirac::ByteIO::BitsLeft ( void  )
inline

Read is limited by this

References m_bits_left.

◆ ByteAlignInput()

void dirac::ByteIO::ByteAlignInput ( )
protected

◆ ByteAlignOutput()

void dirac::ByteIO::ByteAlignOutput ( )

◆ CanRead()

bool dirac::ByteIO::CanRead ( ) const
inlineprotected

References mp_stream.

◆ CollateByteStats()

virtual void dirac::ByteIO::CollateByteStats ( DiracByteStats dirac_byte_stats)
inlinevirtual

◆ FlushInputB()

void dirac::ByteIO::FlushInputB ( )
protected

◆ GetBit()

bool dirac::ByteIO::GetBit ( unsigned char &  c,
int  pos 
) const
inlineprotected

References BIT_IN_CHAR.

◆ GetBytes()

virtual const std::string dirac::ByteIO::GetBytes ( )
virtual

◆ GetReadBytePosition()

int dirac::ByteIO::GetReadBytePosition ( ) const
inline

References mp_stream.

◆ GetSize()

virtual int dirac::ByteIO::GetSize ( ) const
virtual

◆ InputBytes()

void dirac::ByteIO::InputBytes ( char *  data,
int  count 
)
inlineprotected
Parameters
dataStart of char buffer
countNumber of bytes to read

References mp_stream.

◆ InputUnByte()

unsigned char dirac::ByteIO::InputUnByte ( )
inlineprotected

References m_num_bytes, and mp_stream.

Referenced by InputUnString().

◆ InputUnString()

std::string dirac::ByteIO::InputUnString ( const int  count)
inlineprotected

References InputUnByte().

◆ OutputBytes()

void dirac::ByteIO::OutputBytes ( const std::string &  bytes)
inlineprotected

References m_num_bytes, and mp_stream.

◆ OutputCurrentByte()

void dirac::ByteIO::OutputCurrentByte ( )
inlineprotected

◆ ReadBit()

int dirac::ByteIO::ReadBit ( )
protected

◆ ReadBitB()

int dirac::ByteIO::ReadBitB ( )
protected

◆ ReadBool()

bool dirac::ByteIO::ReadBool ( )
protected

◆ ReadBoolB()

bool dirac::ByteIO::ReadBoolB ( )
protected

◆ ReadNBits()

unsigned int dirac::ByteIO::ReadNBits ( int  count)
protected
Parameters
countnumber of bits to be read
Returns
unsigned interger read

◆ ReadSint()

int dirac::ByteIO::ReadSint ( )
protected

◆ ReadSintB()

int dirac::ByteIO::ReadSintB ( )
protected

◆ ReadUint()

unsigned int dirac::ByteIO::ReadUint ( )
protected
Returns
Unsigned Integer read

◆ ReadUintB()

unsigned int dirac::ByteIO::ReadUintB ( )
protected
Returns
Unsigned Integer read

◆ ReadUintLit()

unsigned int dirac::ByteIO::ReadUintLit ( const int  byte_size)
inlineprotected
Parameters
byte_sizeNumber of bytes in fixed length integer
Returns
Unsigned Integer read

References m_num_bytes, and mp_stream.

◆ RemoveRedundantBytes()

void dirac::ByteIO::RemoveRedundantBytes ( const int  count)
protected
Parameters
countNumber of bytes to be removed from beginning of stream

◆ SeekGet()

void dirac::ByteIO::SeekGet ( const int  offset,
std::ios_base::seekdir  dir 
)
inlineprotected

References mp_stream.

◆ SetBit()

void dirac::ByteIO::SetBit ( unsigned char &  c,
int  pos 
) const
inlineprotected

References BIT_IN_CHAR.

◆ SetBits()

void dirac::ByteIO::SetBits ( unsigned char &  c,
unsigned char  bits 
) const
inlineprotected

◆ SetBitsLeft()

void dirac::ByteIO::SetBitsLeft ( int  left_bits)
inline

Read is limited by this

References m_bits_left.

◆ SetByteParams()

void dirac::ByteIO::SetByteParams ( const ByteIO byte_io)
Parameters
byte_ioByte source/destination

◆ WriteBit()

void dirac::ByteIO::WriteBit ( const bool &  bit)
protected

◆ WriteNBits() [1/2]

int dirac::ByteIO::WriteNBits ( unsigned int  val)
protected
Parameters
valInteger to be output
Returns
number of bits written

◆ WriteNBits() [2/2]

void dirac::ByteIO::WriteNBits ( unsigned int  val,
int  count 
)
protected
Parameters
valUnsigned Integer to be output
countnumber of bits to be written

◆ WriteSint()

void dirac::ByteIO::WriteSint ( int  val)
protected
Parameters
valInteger to be output

◆ WriteUint()

void dirac::ByteIO::WriteUint ( unsigned int  value)
Parameters
valueInteger to be output

◆ WriteUintLit()

void dirac::ByteIO::WriteUintLit ( const unsigned int &  value,
const int &  length 
)
inlineprotected
Parameters
valueInteger to be output
lengthnumber of bytes in val to output

References m_num_bytes, and mp_stream.

Friends And Related Function Documentation

◆ ArithCodecBase

friend class ArithCodecBase
friend

◆ ArithCodecToVLCAdapter

friend class ArithCodecToVLCAdapter
friend

Member Data Documentation

◆ m_bits_left

int dirac::ByteIO::m_bits_left
private

Referenced by BitsLeft(), and SetBitsLeft().

◆ m_current_byte

unsigned char dirac::ByteIO::m_current_byte
private

Referenced by OutputCurrentByte().

◆ m_current_pos

int dirac::ByteIO::m_current_pos
private

Referenced by OutputCurrentByte().

◆ m_new_stream

bool dirac::ByteIO::m_new_stream
private

◆ m_num_bytes

int dirac::ByteIO::m_num_bytes
private

◆ mp_stream

std::stringstream* dirac::ByteIO::mp_stream
protected

The documentation for this class was generated from the following file:

© 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.