diff options
Diffstat (limited to 'src/filters/parser/DiracSplitter/libdirac/libdirac_byteio')
30 files changed, 2243 insertions, 2362 deletions
diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/accessunit_byteio.cpp b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/accessunit_byteio.cpp index 8248a0003..33bb8ff9f 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/accessunit_byteio.cpp +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/accessunit_byteio.cpp @@ -42,40 +42,40 @@ using namespace dirac; // Constructor for encoding -SequenceHeaderByteIO::SequenceHeaderByteIO(SourceParams& src_params, - EncoderParams& enc_params): - ParseUnitByteIO(), - m_parseparams_byteio(*this, m_parse_params, enc_params), +SequenceHeaderByteIO::SequenceHeaderByteIO( SourceParams& src_params, + EncoderParams& enc_params): +ParseUnitByteIO(), +m_parseparams_byteio(*this, m_parse_params, enc_params), // create default source parameters for comparisions - m_default_src_params(src_params.GetVideoFormat()), - m_src_params(src_params), - m_sourceparams_byteio(m_src_params, - m_default_src_params, - *this), - m_codec_params(enc_params), - m_codingparams_byteio(m_src_params, - m_codec_params, - m_default_src_params, - *this) +m_default_src_params(src_params.GetVideoFormat()), +m_src_params(src_params), +m_sourceparams_byteio( m_src_params, + m_default_src_params, + *this), +m_codec_params(enc_params), +m_codingparams_byteio(m_src_params, + m_codec_params, + m_default_src_params, + *this) { } // Constructor for decoding SequenceHeaderByteIO::SequenceHeaderByteIO(const ParseUnitByteIO& parseunit_byteio, - ParseParams& parse_params, - SourceParams& src_params, - CodecParams& codec_params) : - ParseUnitByteIO(parseunit_byteio), - m_parseparams_byteio(parseunit_byteio, parse_params), - m_src_params(src_params), - m_sourceparams_byteio(m_src_params, - m_default_src_params, - parseunit_byteio), - m_codec_params(codec_params), - m_codingparams_byteio(m_src_params, - m_codec_params, - m_default_src_params, - parseunit_byteio) + ParseParams& parse_params, + SourceParams& src_params, + CodecParams& codec_params) : +ParseUnitByteIO(parseunit_byteio), +m_parseparams_byteio( parseunit_byteio, parse_params), +m_src_params(src_params), +m_sourceparams_byteio( m_src_params, + m_default_src_params, + parseunit_byteio), +m_codec_params(codec_params), +m_codingparams_byteio( m_src_params, + m_codec_params, + m_default_src_params, + parseunit_byteio) { } @@ -84,7 +84,7 @@ SequenceHeaderByteIO::~SequenceHeaderByteIO() } //-----public------------------------------------------------------ -bool SequenceHeaderByteIO::Input() +bool SequenceHeaderByteIO::Input() { //int o=mp_stream->tellg(); InputParseParams(); @@ -92,22 +92,22 @@ bool SequenceHeaderByteIO::Input() // Inout Video format SetByteParams(m_parseparams_byteio); VideoFormat vf = IntToVideoFormat(ReadUint()); - if(vf == VIDEO_FORMAT_UNDEFINED) - DIRAC_THROW_EXCEPTION( - ERR_INVALID_VIDEO_FORMAT, - "Dirac does not recognise the specified video-format", - SEVERITY_ACCESSUNIT_ERROR); + if(vf==VIDEO_FORMAT_UNDEFINED) + DIRAC_THROW_EXCEPTION( + ERR_INVALID_VIDEO_FORMAT, + "Dirac does not recognise the specified video-format", + SEVERITY_ACCESSUNIT_ERROR); SourceParams src_params(vf, true); m_src_params = src_params; - + InputSourceParams(); - + CodecParams codec_params(vf); m_codec_params = codec_params; - + InputCodingParams(); - + return true; } @@ -122,15 +122,15 @@ void SequenceHeaderByteIO::Output() OutputSourceParams(); OutputCodingParams(); - + } int SequenceHeaderByteIO::GetSize() const { - return ParseUnitByteIO::GetSize() + - m_parseparams_byteio.GetSize() + - ByteIO::GetSize() + - m_sourceparams_byteio.GetSize() + + return ParseUnitByteIO::GetSize()+ + m_parseparams_byteio.GetSize()+ + ByteIO::GetSize() + + m_sourceparams_byteio.GetSize()+ m_codingparams_byteio.GetSize(); } @@ -150,7 +150,7 @@ unsigned char SequenceHeaderByteIO::CalcParseCode() const void SequenceHeaderByteIO::InputSourceParams() { - // copy current input params + // copy current input params m_sourceparams_byteio.SetByteParams(*this); m_sourceparams_byteio.Input(); diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/accessunit_byteio.h b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/accessunit_byteio.h index 346bd4110..2c2966ed8 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/accessunit_byteio.h +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/accessunit_byteio.h @@ -50,135 +50,132 @@ namespace dirac { -/** -* A random access point within a Dirac bytestream -*/ -class SequenceHeaderByteIO : public ParseUnitByteIO -{ -public: - /** - * Constructor (encoding) - *@param src_params Source parameters for current AccessUnit - *@param enc_params Encoder parameters for current AccessUnit + * A random access point within a Dirac bytestream */ - SequenceHeaderByteIO(SourceParams& src_params, - EncoderParams& enc_params); - - /** - * Constructor (decoding) - *@param parseunit_byteio Source of data - *@param parse_params Destination of parse paramters data - *@param src_params Destination of source paramters data - *@param codec_params Destination of coding paramters data - */ - SequenceHeaderByteIO(const ParseUnitByteIO& parseunit_byteio, + class SequenceHeaderByteIO : public ParseUnitByteIO + { + public: + + /** + * Constructor (encoding) + *@param src_params Source parameters for current AccessUnit + *@param enc_params Encoder parameters for current AccessUnit + */ + SequenceHeaderByteIO( SourceParams& src_params, + EncoderParams& enc_params); + + /** + * Constructor (decoding) + *@param parseunit_byteio Source of data + *@param parse_params Destination of parse paramters data + *@param src_params Destination of source paramters data + *@param codec_params Destination of coding paramters data + */ + SequenceHeaderByteIO(const ParseUnitByteIO& parseunit_byteio, ParseParams& parse_params, SourceParams& src_params, CodecParams& codec_params); - /** - * Destructor - */ - ~SequenceHeaderByteIO(); - - /** - * Parses data in Dirac-stream format (decoding) - */ - bool Input(); - - /** - * Writes access-unit info to Dirac stream-format (encoding) - */ - void Output(); - - /* - * Gets size of access-unit (in bytes) - */ - int GetSize() const; - - /** - * Gets parse-unit type - */ - ParseUnitType GetType() const - { - return PU_SEQ_HEADER; - } - -private: - - /** - * Calculates parse-code based on access-unit parameters (encoding) - *@return Char bit-set - */ - unsigned char CalcParseCode() const; - - /** - * Parse source attributes from bytestream-compatible input (decoding) - */ - void InputSourceParams(); - - /** - * Parse parse attributes from bytestream-compatible input (decoding) - */ - void InputParseParams(); - - /** - * Parse Coding attributes from bytestream-compatible input (decoding) - */ - void InputCodingParams(); - - /** - * Output source attributes for bytestream-compatible output (encoding) - */ - void OutputSourceParams(); - - /** - * Output parse attributes for bytestream-compatible output (encoding) - */ - void OutputParseParams(); - - /** - * Output coding attributes for bytestream-compatible output (encoding) - */ - void OutputCodingParams(); - - /** - * Current parse parameters - */ - ParseParams m_parse_params; - - - /** - * Parse-params byte input/output - */ - ParseParamsByteIO m_parseparams_byteio; - - /** - * Default source parameters - */ - SourceParams m_default_src_params; - - /** - * Current source parameters - */ - SourceParams& m_src_params; - - /** - * Source-params byte input/output - */ - SourceParamsByteIO m_sourceparams_byteio; - - /** - * Current codec parameters - */ - CodecParams& m_codec_params; - - /** - * Coding-params byte input/output - */ - CodingParamsByteIO m_codingparams_byteio; -}; + /** + * Destructor + */ + ~SequenceHeaderByteIO(); + + /** + * Parses data in Dirac-stream format (decoding) + */ + bool Input(); + + /** + * Writes access-unit info to Dirac stream-format (encoding) + */ + void Output(); + + /* + * Gets size of access-unit (in bytes) + */ + int GetSize() const; + + /** + * Gets parse-unit type + */ + ParseUnitType GetType() const { return PU_SEQ_HEADER;} + + private: + + /** + * Calculates parse-code based on access-unit parameters (encoding) + *@return Char bit-set + */ + unsigned char CalcParseCode() const; + + /** + * Parse source attributes from bytestream-compatible input (decoding) + */ + void InputSourceParams(); + + /** + * Parse parse attributes from bytestream-compatible input (decoding) + */ + void InputParseParams(); + + /** + * Parse Coding attributes from bytestream-compatible input (decoding) + */ + void InputCodingParams(); + + /** + * Output source attributes for bytestream-compatible output (encoding) + */ + void OutputSourceParams(); + + /** + * Output parse attributes for bytestream-compatible output (encoding) + */ + void OutputParseParams(); + + /** + * Output coding attributes for bytestream-compatible output (encoding) + */ + void OutputCodingParams(); + + /** + * Current parse parameters + */ + ParseParams m_parse_params; + + + /** + * Parse-params byte input/output + */ + ParseParamsByteIO m_parseparams_byteio; + + /** + * Default source parameters + */ + SourceParams m_default_src_params; + + /** + * Current source parameters + */ + SourceParams& m_src_params; + + /** + * Source-params byte input/output + */ + SourceParamsByteIO m_sourceparams_byteio; + + /** + * Current codec parameters + */ + CodecParams& m_codec_params; + + /** + * Coding-params byte input/output + */ + CodingParamsByteIO m_codingparams_byteio; + }; } // namespace dirac diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/byteio.cpp b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/byteio.cpp index 724239e54..12b129953 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/byteio.cpp +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/byteio.cpp @@ -42,37 +42,37 @@ using namespace dirac; using namespace std; ByteIO::ByteIO(bool new_stream): - m_current_byte(0), - m_current_pos(0), - m_num_bytes(0), - m_new_stream(true), - m_bits_left(0) +m_current_byte(0), +m_current_pos(0), +m_num_bytes(0), +m_new_stream(true), +m_bits_left(0) { if(new_stream) mp_stream = new stringstream(stringstream::in | stringstream::out | stringstream::binary); - + } ByteIO::ByteIO(const ByteIO& stream_data): - m_current_byte(0), - m_current_pos(0), - m_num_bytes(0), - m_new_stream(false), - m_bits_left(0) +m_current_byte(0), +m_current_pos(0), +m_num_bytes(0), +m_new_stream(false), +m_bits_left(0) { - mp_stream = stream_data.mp_stream; + mp_stream=stream_data.mp_stream; } ByteIO::~ByteIO() { - if(m_new_stream) + if (m_new_stream) delete mp_stream; } -const string ByteIO::GetBytes() +const string ByteIO::GetBytes() { return mp_stream->str(); } @@ -84,35 +84,35 @@ int ByteIO::GetSize() const void ByteIO::SetByteParams(const ByteIO& byte_io) { - mp_stream = byte_io.mp_stream; - m_current_byte = byte_io.m_current_byte; - m_current_pos = byte_io.m_current_pos; + mp_stream=byte_io.mp_stream; + m_current_byte=byte_io.m_current_byte; + m_current_pos=byte_io.m_current_pos; } //----------protected--------------------------------------------------------------- void ByteIO::ByteAlignInput() { - m_current_pos = 0; - m_current_byte = 0; + m_current_pos=0; + m_current_byte=0; } void ByteIO::ByteAlignOutput() { - if(m_current_pos != 0) + if(m_current_pos!=0) OutputCurrentByte(); } int ByteIO::ReadBit() { if(m_current_pos == CHAR_BIT) - m_current_pos = 0; + m_current_pos=0; - if(m_current_pos == 0) + if (m_current_pos == 0) m_current_byte = InputUnByte(); #if 1 // MSB to LSB - return GetBit(m_current_byte, (CHAR_BIT - 1 - m_current_pos++)); + return GetBit(m_current_byte, (CHAR_BIT-1-m_current_pos++)); #else // LSB to MSB return GetBit(m_current_byte, m_current_pos++); @@ -121,7 +121,7 @@ int ByteIO::ReadBit() int ByteIO::ReadBitB() { - if(m_bits_left) + if (m_bits_left) { --m_bits_left; return ReadBit(); @@ -143,7 +143,7 @@ bool ByteIO::ReadBoolB() unsigned int ByteIO::ReadNBits(int count) { unsigned int val = 0; - for(int i = 0; i < count; ++i) + for (int i = 0; i < count; ++i) { val <<= 1; val += ReadBit(); @@ -166,14 +166,14 @@ int ByteIO::ReadSint() int val = ReadUint(); bool bit; - //get the sign - if(val != 0) + //get the sign + if (val != 0) { bit = ReadBit(); - if(bit) + if (bit ) val = -val; } - return val; + return val; } int ByteIO::ReadSintB() @@ -182,24 +182,24 @@ int ByteIO::ReadSintB() int val = ReadUintB(); bool bit; - //get the sign - if(val != 0) + //get the sign + if (val != 0) { bit = ReadBitB(); - if(bit) + if (bit ) val = -val; } - return val; + return val; } unsigned int ByteIO::ReadUint() { unsigned int value = 1; - while(!ReadBit()) + while (!ReadBit()) { value <<= 1; - if(ReadBit()) - value += 1; + if (ReadBit()) + value +=1; } --value; return value; @@ -208,11 +208,11 @@ unsigned int ByteIO::ReadUint() unsigned int ByteIO::ReadUintB() { unsigned int value = 1; - while(!ReadBitB()) + while (!ReadBitB()) { value <<= 1; - if(ReadBitB()) - value += 1; + if (ReadBitB()) + value +=1; } --value; return value; @@ -223,21 +223,21 @@ void ByteIO::WriteBit(const bool& bit) if(bit) #if 1 // MSB to LSB - SetBit(m_current_byte, CHAR_BIT - 1 - m_current_pos); + SetBit(m_current_byte, CHAR_BIT-1-m_current_pos); #else // LSB to MSB SetBit(m_current_byte, m_current_pos); #endif - if(m_current_pos == CHAR_BIT - 1) - { + if ( m_current_pos == CHAR_BIT-1) + { // If a whole byte has been written, output to stream OutputCurrentByte(); m_current_byte = 0; m_current_pos = 0; - } + } else - // Shift mask to next bit in the output byte + // Shift mask to next bit in the output byte ++m_current_pos; } @@ -245,7 +245,7 @@ void ByteIO::WriteNBits(unsigned int val, int count) { do { - WriteBit(val & (1 << (count - 1))); + WriteBit(val & ( 1 << (count-1))); count--; } while(count > 0); @@ -253,7 +253,7 @@ void ByteIO::WriteNBits(unsigned int val, int count) int ByteIO::WriteNBits(unsigned int val) { - int nbits = static_cast<int>(log(static_cast<double>(val)) / log(2.0)) + 1; + int nbits = static_cast<int>(log(static_cast<double>(val))/log(2.0)) + 1; WriteNBits(val, nbits); return nbits; } @@ -265,24 +265,24 @@ void ByteIO::WriteSint(int val) WriteUint(value); //do sign - if(val < 0) WriteBit(1); - else if(val > 0) WriteBit(0); + if (val<0) WriteBit(1); + else if (val>0) WriteBit(0); } void ByteIO::WriteUint(unsigned int value) { - unsigned int val = value + 1; + unsigned int val = value+1; int num_follow_zeroes = 0; - while(val >= (1U << num_follow_zeroes)) + while (val >= (1U <<num_follow_zeroes)) ++num_follow_zeroes; --num_follow_zeroes; - for(int i = num_follow_zeroes - 1; i >= 0; --i) + for (int i=num_follow_zeroes-1; i>=0; --i) { WriteBit(BIT_ZERO); - WriteBit(val&(1 << i)); + WriteBit(val&(1<<i)); } WriteBit(BIT_ONE); } @@ -290,10 +290,10 @@ void ByteIO::WriteUint(unsigned int value) void ByteIO::RemoveRedundantBytes(const int size) { int prev_pos = mp_stream->tellg(); - string data = mp_stream->str(); + string data=mp_stream->str(); data.erase(0, size); mp_stream->str(data); - m_num_bytes = data.size(); + m_num_bytes=data.size(); if(data.size()) - SeekGet(max(prev_pos - size, 0), ios_base::beg); + SeekGet(max(prev_pos-size, 0), ios_base::beg); } diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/byteio.h b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/byteio.h index 806d98a55..db885d658 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/byteio.h +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/byteio.h @@ -53,371 +53,342 @@ namespace dirac { + + // BIT DEFS + #define BIT_ZERO 0 + #define BIT_ONE 1 + + // most significant bit in a character + #define MS_BIT (1 << (CHAR_BIT - 1)) + + /* array index for character containing bit */ + //#define BIT_IN_CHAR(bit) (1 << (CHAR_BIT-1-bit)) + #define BIT_IN_CHAR(bit) (1 << bit) + + + /** + * Class ByteIO - top-level class for reading/writing bytes to a stream + */ + class ByteIO + { + public: + + /** + * Default constructor + *@param new_stream <B>Has Creates & owns data buffer </B> + */ + ByteIO(bool new_stream=true); + + /** + * Constructor + *@param stream_data Copies data buffer details + */ + ByteIO(const ByteIO& stream_data); + + /** + * Destructor + */ + virtual ~ByteIO(); + + /** + * Gathers byte-stream statistics + *@param dirac_byte_stats Collates byte information + */ + virtual void CollateByteStats(DiracByteStats& dirac_byte_stats) + { dirac_byte_stats.Clear(); } + + /** + * Get bytes in Dirac-bytestream format + */ + virtual const std::string GetBytes(); + + /** + * Get position of read stream pointer + */ + int GetReadBytePosition() const { return mp_stream->tellg();}; + + + /** + *Gets size (in bytes) + */ + virtual int GetSize() const; + + /** + * Copies stream source/destination info + *@param byte_io Byte source/destination + */ + void SetByteParams(const ByteIO& byte_io); + + /** + * Sync input for byte-alignment + */ + void ByteAlignOutput(); + + /** + * Ouputs an unsigned integer in interleaved exp Golomb format + *@param value Integer to be output + */ + //void OutputVarLengthUint(const unsigned int& value); + void WriteUint(unsigned int value); + + /** + * Sets input size in bits. Read is limited by this + */ + void SetBitsLeft(int left_bits) { m_bits_left = left_bits; } + + /** + * Sets input size in bits. Read is limited by this + */ + int BitsLeft(void) { return m_bits_left; } + + protected: + + inline bool CanRead() const { return(!mp_stream->eof()); } + + inline bool GetBit(unsigned char& c, int pos) const { return (c & BIT_IN_CHAR(pos)); } + + inline void SetBit(unsigned char& c, int pos) const { c |= BIT_IN_CHAR(pos); } + + inline void SetBits(unsigned char& c, unsigned char bits) const { c |= bits; } + + /** + * Sync input for byte-alignment + */ + void ByteAlignInput(); + + + /** + * Reads boolean value + */ + bool ReadBool(); + + /** + * Reads boolean value - bounded i/o + */ + bool ReadBoolB(); + + /** + * Reads next bit + */ + int ReadBit(); + + /** + * Reads next bit - bounded i/o + */ + int ReadBitB(); + + /** + * Reads next 'count' bits + *@param count number of bits to be read + *@return unsigned interger read + */ + unsigned int ReadNBits(int count); + + /** + * Reads from stream + *@param data Start of char buffer + *@param count Number of bytes to read + */ + void InputBytes(char* data, int count) + { + //int j=mp_stream->tellg(); + mp_stream->read(data, count); -// BIT DEFS -#define BIT_ZERO 0 -#define BIT_ONE 1 - -// most significant bit in a character -#define MS_BIT (1 << (CHAR_BIT - 1)) - -/* array index for character containing bit */ -//#define BIT_IN_CHAR(bit) (1 << (CHAR_BIT-1-bit)) -#define BIT_IN_CHAR(bit) (1 << bit) - + //int h=mp_stream->tellg(); + } -/** -* Class ByteIO - top-level class for reading/writing bytes to a stream -*/ -class ByteIO -{ -public: - - /** - * Default constructor - *@param new_stream <B>Has Creates & owns data buffer </B> - */ - ByteIO(bool new_stream = true); - - /** - * Constructor - *@param stream_data Copies data buffer details - */ - ByteIO(const ByteIO& stream_data); - - /** - * Destructor - */ - virtual ~ByteIO(); - - /** - * Gathers byte-stream statistics - *@param dirac_byte_stats Collates byte information - */ - virtual void CollateByteStats(DiracByteStats& dirac_byte_stats) - { - dirac_byte_stats.Clear(); - } - - /** - * Get bytes in Dirac-bytestream format - */ - virtual const std::string GetBytes(); - - /** - * Get position of read stream pointer - */ - int GetReadBytePosition() const - { - return mp_stream->tellg(); - }; - - - /** - *Gets size (in bytes) - */ - virtual int GetSize() const; - - /** - * Copies stream source/destination info - *@param byte_io Byte source/destination - */ - void SetByteParams(const ByteIO& byte_io); - - /** - * Sync input for byte-alignment - */ - void ByteAlignOutput(); - - /** - * Ouputs an unsigned integer in interleaved exp Golomb format - *@param value Integer to be output - */ - //void OutputVarLengthUint(const unsigned int& value); - void WriteUint(unsigned int value); - - /** - * Sets input size in bits. Read is limited by this - */ - void SetBitsLeft(int left_bits) - { - m_bits_left = left_bits; - } - - /** - * Sets input size in bits. Read is limited by this - */ - int BitsLeft(void) - { - return m_bits_left; - } - -protected: - - inline bool CanRead() const - { - return(!mp_stream->eof()); - } - - inline bool GetBit(unsigned char& c, int pos) const - { - return (c & BIT_IN_CHAR(pos)); - } - - inline void SetBit(unsigned char& c, int pos) const - { - c |= BIT_IN_CHAR(pos); - } - - inline void SetBits(unsigned char& c, unsigned char bits) const - { - c |= bits; - } - - /** - * Sync input for byte-alignment - */ - void ByteAlignInput(); - - - /** - * Reads boolean value - */ - bool ReadBool(); - - /** - * Reads boolean value - bounded i/o - */ - bool ReadBoolB(); - - /** - * Reads next bit - */ - int ReadBit(); - - /** - * Reads next bit - bounded i/o - */ - int ReadBitB(); - - /** - * Reads next 'count' bits - *@param count number of bits to be read - *@return unsigned interger read - */ - unsigned int ReadNBits(int count); - - /** - * Reads from stream - *@param data Start of char buffer - *@param count Number of bytes to read - */ - void InputBytes(char* data, int count) - { - //int j=mp_stream->tellg(); - mp_stream->read(data, count); - - //int h=mp_stream->tellg(); - } - - /** - * Flushes the bounde input - */ - void FlushInputB(); - - /** - * Reads a signed integer in interleaved exp-Golomb format - *return Signed integer read - */ - //int InputVarLengthInt(); - int ReadSint(); - - /** - * Reads a signed integer in interleaved exp-Golomb format from bounded input - *return Signed integer read - */ - int ReadSintB(); - - /** - * Reads an unsigned integer in interleaved exp Golomb format - *@return Unsigned Integer read - */ - //unsigned int InputVarLengthUint(); - unsigned int ReadUint(); - - /** - * Reads an unsigned integer in interleaved exp Golomb format from bounded input - *@return Unsigned Integer read - */ - //unsigned int InputVarLengthUint(); - unsigned int ReadUintB(); - - /** - * Reads a fixed length unsigned integer from the stream in big endian - *@param byte_size Number of bytes in fixed length integer - *@return Unsigned Integer read - */ - //inline unsigned int InputFixedLengthUint(const int byte_size) { - inline unsigned int ReadUintLit(const int byte_size) - { - unsigned int val = 0; - for(int i = 0; i < byte_size; ++i) + /** + * Flushes the bounde input + */ + void FlushInputB(); + + /** + * Reads a signed integer in interleaved exp-Golomb format + *return Signed integer read + */ + //int InputVarLengthInt(); + int ReadSint(); + + /** + * Reads a signed integer in interleaved exp-Golomb format from bounded input + *return Signed integer read + */ + int ReadSintB(); + + /** + * Reads an unsigned integer in interleaved exp Golomb format + *@return Unsigned Integer read + */ + //unsigned int InputVarLengthUint(); + unsigned int ReadUint(); + + /** + * Reads an unsigned integer in interleaved exp Golomb format from bounded input + *@return Unsigned Integer read + */ + //unsigned int InputVarLengthUint(); + unsigned int ReadUintB(); + + /** + * Reads a fixed length unsigned integer from the stream in big endian + *@param byte_size Number of bytes in fixed length integer + *@return Unsigned Integer read + */ + //inline unsigned int InputFixedLengthUint(const int byte_size) { + inline unsigned int ReadUintLit(const int byte_size) { + unsigned int val=0; + for(int i=0; i < byte_size; ++i) + { + val <<= 8; + val += (unsigned char)mp_stream->get(); + } + m_num_bytes+=byte_size; + return val; + } + + /** + * Reads a byte from the stream + */ + inline unsigned char InputUnByte() {m_num_bytes++ ; return mp_stream->get(); } + + /** + * Reads a series of bytes from a stream + */ + inline std::string InputUnString(const int count) { - val <<= 8; - val += (unsigned char)mp_stream->get(); + std::string str; + for(int index=0; index < count; ++index) + str.push_back(InputUnByte()); + return str; } - m_num_bytes += byte_size; - return val; - } - - /** - * Reads a byte from the stream - */ - inline unsigned char InputUnByte() - { - m_num_bytes++ ; - return mp_stream->get(); - } - - /** - * Reads a series of bytes from a stream - */ - inline std::string InputUnString(const int count) - { - std::string str; - for(int index = 0; index < count; ++index) - str.push_back(InputUnByte()); - return str; - } - - /** - * Outputs a bit - *@param bit 1/0 Output - */ - void WriteBit(const bool& bit); - - /** - * Outputs an unsigned integer - *@param val Integer to be output - *@return number of bits written - */ - int WriteNBits(unsigned int val); - - /** - * Outputs an n bit integer - *@param val Unsigned Integer to be output - *@param count number of bits to be written - */ - void WriteNBits(unsigned int val, int count); - - - - /** - * Outputs a series of bytes - */ - void OutputBytes(const std::string& bytes) - { - int cur_pos = mp_stream->tellg(); - mp_stream->str(mp_stream->str() + bytes); - m_num_bytes += bytes.size(); + + /** + * Outputs a bit + *@param bit 1/0 Output + */ + void WriteBit(const bool& bit); + + /** + * Outputs an unsigned integer + *@param val Integer to be output + *@return number of bits written + */ + int WriteNBits(unsigned int val); + + /** + * Outputs an n bit integer + *@param val Unsigned Integer to be output + *@param count number of bits to be written + */ + void WriteNBits(unsigned int val, int count); + + + + /** + * Outputs a series of bytes + */ + void OutputBytes(const std::string& bytes) { + int cur_pos = mp_stream->tellg(); + mp_stream->str(mp_stream->str()+bytes); + m_num_bytes+=bytes.size(); // *mp_stream << bytes; - mp_stream->seekg(std::max(cur_pos, 0), std::ios_base::beg); - } - - /** - * Outputs current byte contents - */ - inline void OutputCurrentByte() - { - if(m_current_pos) - { - *mp_stream << (m_current_byte); - ++m_num_bytes; - m_current_pos = 0; - m_current_byte = 0; + mp_stream->seekg(std::max(cur_pos,0), std::ios_base::beg); } - }; - - /** - * Outputs an integer in Golomb signed integer format - *@param val Integer to be output - */ - //void OutputVarLengthInt(const int val); - void WriteSint(int val); - - /** - * Output unsigned int value in big endian format - * @param value Integer to be output - * @param length number of bytes in val to output - */ - //inline void OutputFixedLengthUint(const unsigned int& value, const int& length) - inline void WriteUintLit(const unsigned int& value, const int& length) - { - for(int i = length - 1; i >= 0 ; --i) + + /** + * Outputs current byte contents + */ + inline void OutputCurrentByte() { - unsigned char cp = (value >> (i * 8)) & 0xff; - *mp_stream << cp; - } - m_num_bytes += length; - } - - /** - * Removes portion of byte-stream no longer required - *@param count Number of bytes to be removed from beginning of stream - */ - void RemoveRedundantBytes(const int count); - - inline void SeekGet(const int offset, std::ios_base::seekdir dir) - { - mp_stream->seekg(offset, dir); - } - - /** - * Input/output steam - */ - std::stringstream* mp_stream; - - -private: - - /** - * ArithCodec can see internals for getting/setting bits - */ - friend class ArithCodecBase; - - /** - * VLC entropy coder can see internals for getting/setting bits - */ - friend class ArithCodecToVLCAdapter; - - /** - * Char used for temporary storage of op data bits - */ - unsigned char m_current_byte; - - /** - * Used to set individual bit within the current header byte - */ - int m_current_pos; - - /** - * Number of bytes processed - */ - int m_num_bytes; - - /** - * stream alloc flag - */ - bool m_new_stream; - - /** - * num bits left to read - */ - int m_bits_left; -protected: - - -}; + if (m_current_pos) + { + *mp_stream << (m_current_byte); + ++m_num_bytes; + m_current_pos = 0; + m_current_byte = 0; + } + }; + + /** + * Outputs an integer in Golomb signed integer format + *@param val Integer to be output + */ + //void OutputVarLengthInt(const int val); + void WriteSint(int val); + + /** + * Output unsigned int value in big endian format + * @param value Integer to be output + * @param length number of bytes in val to output + */ + //inline void OutputFixedLengthUint(const unsigned int& value, const int& length) + inline void WriteUintLit(const unsigned int& value, const int& length) + { + for(int i=length-1; i >=0 ; --i) + { + unsigned char cp = (value>>(i*8))&0xff; + *mp_stream << cp; + } + m_num_bytes+=length; + } + + /** + * Removes portion of byte-stream no longer required + *@param count Number of bytes to be removed from beginning of stream + */ + void RemoveRedundantBytes(const int count); + + inline void SeekGet(const int offset, std::ios_base::seekdir dir) + { + mp_stream->seekg(offset, dir); + } + + /** + * Input/output steam + */ + std::stringstream* mp_stream; + + + private: + + /** + * ArithCodec can see internals for getting/setting bits + */ + friend class ArithCodecBase; + + /** + * VLC entropy coder can see internals for getting/setting bits + */ + friend class ArithCodecToVLCAdapter; + + /** + * Char used for temporary storage of op data bits + */ + unsigned char m_current_byte; + + /** + * Used to set individual bit within the current header byte + */ + int m_current_pos; + + /** + * Number of bytes processed + */ + int m_num_bytes; + + /** + * stream alloc flag + */ + bool m_new_stream; + + /** + * num bits left to read + */ + int m_bits_left; + protected: + + + }; diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/codingparams_byteio.cpp b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/codingparams_byteio.cpp index 69875e31b..7326b4562 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/codingparams_byteio.cpp +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/codingparams_byteio.cpp @@ -42,13 +42,13 @@ using namespace dirac; CodingParamsByteIO::CodingParamsByteIO(const SourceParams& src_params, - CodecParams& codec_params, - const SourceParams& default_source_params, - const ByteIO& stream_data): - ByteIO(stream_data), - m_src_params(src_params), - m_codec_params(codec_params), - m_default_source_params(default_source_params) + CodecParams& codec_params, + const SourceParams& default_source_params, + const ByteIO& stream_data): +ByteIO(stream_data), +m_src_params(src_params), +m_codec_params(codec_params), +m_default_source_params(default_source_params) { } @@ -75,22 +75,22 @@ void CodingParamsByteIO::Input() // If source was coded as fields, halve the vertical dimensions // to set them to field dimensions - if(m_codec_params.FieldCoding()) + if (m_codec_params.FieldCoding()) { - m_codec_params.SetYl(m_codec_params.Yl() >> 1); - m_codec_params.SetChromaYl(m_codec_params.ChromaYl() >> 1); + m_codec_params.SetYl(m_codec_params.Yl()>>1); + m_codec_params.SetChromaYl(m_codec_params.ChromaYl()>>1); } unsigned int luma_depth = static_cast<unsigned int> - ( - std::log((double)m_src_params.LumaExcursion()) / std::log(2.0) + 1 - ); + ( + std::log((double)m_src_params.LumaExcursion())/std::log(2.0) + 1 + ); m_codec_params.SetLumaDepth(luma_depth); unsigned int chroma_depth = static_cast<unsigned int> - ( - std::log((double)m_src_params.ChromaExcursion()) / std::log(2.0) + 1 - ); + ( + std::log((double)m_src_params.ChromaExcursion())/std::log(2.0) + 1 + ); m_codec_params.SetChromaDepth(chroma_depth); // byte align @@ -112,7 +112,7 @@ void CodingParamsByteIO::Output() void CodingParamsByteIO::InputPictureCodingMode() { unsigned int coding_mode = ReadUint(); - if(coding_mode > 1) + if (coding_mode > 1) { std::ostringstream errstr; errstr << "Picture coding mode " << coding_mode diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/codingparams_byteio.h b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/codingparams_byteio.h index 05b512df8..b96b037a0 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/codingparams_byteio.h +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/codingparams_byteio.h @@ -51,83 +51,83 @@ namespace dirac { - -/** -* Represents compressed sequence-parameter data used in an AccessUnit -*/ -class CodingParamsByteIO : public ByteIO -{ -public: - - /** - * Constructor - *@param src_params Source parameters - *@param codec_params Coding parameters - *@param default_source_params Default source parameters - *@param stream_data Source/Destination of data - */ - CodingParamsByteIO(const SourceParams& src_params, - CodecParams& codec_params, - const SourceParams& default_source_params, - const ByteIO& stream_data); - - - /** - * Destructor - */ - ~CodingParamsByteIO(); - - /** - * Reads sequence information from Dirac byte-format - */ - void Input(); - - /** - * Outputs sequence information to Dirac byte-format - */ - void Output(); - -protected: - - -private: - - /** - * Reads number of bits used to compress input signal - */ - void InputVideoDepth(); - - /** - * Reads picture coding mode - 0 - frames, 1 - fields - */ - void InputPictureCodingMode(); - - /** - * Outputs number of bits used to compress input signal - */ - void OutputVideoDepth(); - + /** - * Outputs how input was coded - i.e. frames or fields + * Represents compressed sequence-parameter data used in an AccessUnit */ - void OutputPictureCodingMode(); - - /** - * Source paramters for intput/output - */ - const SourceParams& m_src_params; - - /** - * Coding paramters for intput/output - */ - CodecParams& m_codec_params; - - /** - * Default source parameters - */ - const SourceParams& m_default_source_params; - -}; + class CodingParamsByteIO : public ByteIO + { + public: + + /** + * Constructor + *@param src_params Source parameters + *@param codec_params Coding parameters + *@param default_source_params Default source parameters + *@param stream_data Source/Destination of data + */ + CodingParamsByteIO(const SourceParams& src_params, + CodecParams& codec_params, + const SourceParams& default_source_params, + const ByteIO& stream_data); + + + /** + * Destructor + */ + ~CodingParamsByteIO(); + + /** + * Reads sequence information from Dirac byte-format + */ + void Input(); + + /** + * Outputs sequence information to Dirac byte-format + */ + void Output(); + + protected: + + + private: + + /** + * Reads number of bits used to compress input signal + */ + void InputVideoDepth(); + + /** + * Reads picture coding mode - 0 - frames, 1 - fields + */ + void InputPictureCodingMode(); + + /** + * Outputs number of bits used to compress input signal + */ + void OutputVideoDepth(); + + /** + * Outputs how input was coded - i.e. frames or fields + */ + void OutputPictureCodingMode(); + + /** + * Source paramters for intput/output + */ + const SourceParams& m_src_params; + + /** + * Coding paramters for intput/output + */ + CodecParams& m_codec_params; + + /** + * Default source parameters + */ + const SourceParams& m_default_source_params; + + }; } // namespace dirac diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/component_byteio.cpp b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/component_byteio.cpp index 88a63811a..07f5433d1 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/component_byteio.cpp +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/component_byteio.cpp @@ -42,13 +42,13 @@ using namespace std; ComponentByteIO::ComponentByteIO(CompSort cs, const ByteIO& byteio): - ByteIO(byteio), - m_compsort(cs) +ByteIO(byteio), +m_compsort(cs) {} ComponentByteIO::ComponentByteIO(CompSort cs): - ByteIO(), - m_compsort(cs) +ByteIO(), +m_compsort(cs) {} ComponentByteIO::~ComponentByteIO() @@ -83,16 +83,16 @@ void ComponentByteIO::CollateByteStats(DiracByteStats& dirac_byte_stats) bool ComponentByteIO::Input() { - - return true; + + return true; } void ComponentByteIO::Output() { - + } //-------------private------------------------------------------------------- - + diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/component_byteio.h b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/component_byteio.h index 03ee2f1ea..e80b0877a 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/component_byteio.h +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/component_byteio.h @@ -52,73 +52,73 @@ namespace dirac { -/** -* Picture component in Dirac bytestream format -*/ -class ComponentByteIO : public ByteIO -{ -public: - - /** - * Constructor - *@param cs Picture-component type - *@param byteIO Input/output Byte stream - */ - ComponentByteIO(CompSort cs, - const ByteIO& byteIO); - - /** - * Constructor - *@param cs Picture-component type - */ - ComponentByteIO(CompSort cs); - /** - * Destructor + * Picture component in Dirac bytestream format */ - ~ComponentByteIO(); - - /** - * Gathers byte stats on the component data - *@param dirac_byte_stats Stat container - */ - void CollateByteStats(DiracByteStats& dirac_byte_stats); - - /** - * Add a subband byte-stream to this component - *@param p_subband_byteio Subband to be added - */ - void AddSubband(SubbandByteIO *p_subband_byteio); - - /** - * Inputs data from Dirac stream-format - */ - bool Input(); - - /** - * Outputs picture values to Dirac stream-format - */ - void Output(); - - - -protected: - - -private: - - /** - * Picture component type - */ - CompSort m_compsort; - - /** - * List of subbands in output/input order - */ - std::vector<ByteIO*> m_subband_list; - - -}; + class ComponentByteIO : public ByteIO + { + public: + + /** + * Constructor + *@param cs Picture-component type + *@param byteIO Input/output Byte stream + */ + ComponentByteIO(CompSort cs, + const ByteIO& byteIO); + + /** + * Constructor + *@param cs Picture-component type + */ + ComponentByteIO(CompSort cs); + + /** + * Destructor + */ + ~ComponentByteIO(); + + /** + * Gathers byte stats on the component data + *@param dirac_byte_stats Stat container + */ + void CollateByteStats(DiracByteStats& dirac_byte_stats); + + /** + * Add a subband byte-stream to this component + *@param p_subband_byteio Subband to be added + */ + void AddSubband(SubbandByteIO *p_subband_byteio); + + /** + * Inputs data from Dirac stream-format + */ + bool Input(); + + /** + * Outputs picture values to Dirac stream-format + */ + void Output(); + + + + protected: + + + private: + + /** + * Picture component type + */ + CompSort m_compsort; + + /** + * List of subbands in output/input order + */ + std::vector<ByteIO*> m_subband_list; + + + }; } // namespace dirac diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/dirac_byte_stats.cpp b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/dirac_byte_stats.cpp index 883badb14..9c697bc3d 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/dirac_byte_stats.cpp +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/dirac_byte_stats.cpp @@ -46,7 +46,7 @@ DiracByteStats::DiracByteStats() } DiracByteStats::DiracByteStats(const DiracByteStats& dirac_byte_stats): - m_byte_count(dirac_byte_stats.m_byte_count) +m_byte_count(dirac_byte_stats.m_byte_count) { } @@ -60,25 +60,25 @@ void DiracByteStats::Clear() m_byte_count.clear(); } -int64_t DiracByteStats::GetBitCount(const StatType& stat_type) const +int64_t DiracByteStats::GetBitCount(const StatType& stat_type) const { return GetByteCount(stat_type) * CHAR_BIT; } int64_t DiracByteStats::GetByteCount(const StatType& stat_type) const { - std::map<StatType, int64_t>::const_iterator it; - it = m_byte_count.find(stat_type); - if(it == m_byte_count.end()) - return 0; + std::map<StatType, int64_t>::const_iterator it; + it = m_byte_count.find(stat_type); + if(it==m_byte_count.end()) + return 0; - return it->second; + return it->second; } void DiracByteStats::SetByteCount(const StatType& stat_type, int64_t count) { - if(m_byte_count.find(stat_type) == m_byte_count.end()) - m_byte_count[stat_type] = 0; + if(m_byte_count.find(stat_type)==m_byte_count.end()) + m_byte_count[stat_type]=0; - m_byte_count[stat_type] += count; -} + m_byte_count[stat_type]+=count; + } diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/dirac_byte_stats.h b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/dirac_byte_stats.h index d32635a2a..0da273f0a 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/dirac_byte_stats.h +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/dirac_byte_stats.h @@ -50,71 +50,70 @@ namespace dirac { -#ifdef _MSC_VER -// char length -#define CHAR_BIT 8 + #ifdef _MSC_VER + // char length + #define CHAR_BIT 8 #endif -typedef enum -{ - STAT_TOTAL_BYTE_COUNT = 0, - STAT_MV_BYTE_COUNT, - STAT_YCOMP_BYTE_COUNT, - STAT_UCOMP_BYTE_COUNT, - STAT_VCOMP_BYTE_COUNT -} StatType; - - -/** -* Class DiracByteStats - for collecting statistics on aspects of the Dirac byte-stream -*/ -class DiracByteStats -{ -public: - /** - * Constructor - */ - DiracByteStats(); - - /** - * Copy constructor - */ - DiracByteStats(const DiracByteStats& dirac_byte_stats); - - /** - * Destructor - */ - ~DiracByteStats(); - - /** - * Clears data - */ - void Clear(); - - /** - * Gets number of bits for a particular stat-type - */ - int64_t GetBitCount(const StatType& stat_type) const; - - /** - * Gets number of bytes for a particular stat-type - */ - int64_t GetByteCount(const StatType& stat_type) const; - - /** - * Sets number of bytes for a particular stat-type - */ - void SetByteCount(const StatType& stat_type, int64_t count); - - -private: - - /** - * Map of byte-counts - */ - std::map<StatType, int64_t> m_byte_count; - -}; + typedef enum { + STAT_TOTAL_BYTE_COUNT=0, + STAT_MV_BYTE_COUNT, + STAT_YCOMP_BYTE_COUNT, + STAT_UCOMP_BYTE_COUNT, + STAT_VCOMP_BYTE_COUNT + } StatType; + + + /** + * Class DiracByteStats - for collecting statistics on aspects of the Dirac byte-stream + */ + class DiracByteStats + { + public: + /** + * Constructor + */ + DiracByteStats(); + + /** + * Copy constructor + */ + DiracByteStats(const DiracByteStats& dirac_byte_stats); + + /** + * Destructor + */ + ~DiracByteStats(); + + /** + * Clears data + */ + void Clear(); + + /** + * Gets number of bits for a particular stat-type + */ + int64_t GetBitCount(const StatType& stat_type) const; + + /** + * Gets number of bytes for a particular stat-type + */ + int64_t GetByteCount(const StatType& stat_type) const; + + /** + * Sets number of bytes for a particular stat-type + */ + void SetByteCount(const StatType& stat_type, int64_t count); + + + private: + + /** + * Map of byte-counts + */ + std::map<StatType, int64_t> m_byte_count; + + }; } // namespace dirac diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/dirac_byte_stream.cpp b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/dirac_byte_stream.cpp index b31e8de47..a45e54706 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/dirac_byte_stream.cpp +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/dirac_byte_stream.cpp @@ -44,8 +44,8 @@ using namespace dirac; using namespace std; DiracByteStream::DiracByteStream(): - ByteIO(), - mp_prev_parse_unit(NULL) +ByteIO(), +mp_prev_parse_unit(NULL) { } @@ -86,29 +86,29 @@ void DiracByteStream::Reset(ParseUnitByteIO* p_curr_unit, int pos) ParseUnitByteIO* DiracByteStream::GetNextParseUnit() { - if(GetSize() == 0) + if(GetSize()==0) return NULL; - int pos = 0; + int pos=0; if(mp_prev_parse_unit) { // remove the unwanted bytes associated with the previous parse-unit int prev_offset = mp_prev_parse_unit->GetNextParseOffset(); RemoveRedundantBytes(prev_offset ? prev_offset : mp_prev_parse_unit->GetSize()); delete mp_prev_parse_unit; - mp_prev_parse_unit = NULL; + mp_prev_parse_unit=NULL; if(!GetSize()) return NULL; } - ParseUnitByteIO* p_curr_unit = NULL; + ParseUnitByteIO* p_curr_unit=NULL; while(true) { pos = GetReadBytePosition(); p_curr_unit = new ParseUnitByteIO(*this); - if(!p_curr_unit->Input()) + if (!p_curr_unit->Input()) { Reset(p_curr_unit, pos); return NULL; @@ -121,7 +121,7 @@ ParseUnitByteIO* DiracByteStream::GetNextParseUnit() return NULL; } - if(p_curr_unit->IsEndOfSequence()) + if (p_curr_unit->IsEndOfSequence()) { break; } @@ -140,15 +140,15 @@ ParseUnitByteIO* DiracByteStream::GetNextParseUnit() } // while // Remove all redundant bytes that are not part of a parse unit - int remove_size = std::max(0, GetReadBytePosition() - p_curr_unit->GetSize()); - if(remove_size) + int remove_size = std::max (0, GetReadBytePosition()-p_curr_unit->GetSize()); + if (remove_size) { - //std::cerr << "Size="<<GetSize() << " Un-useful bytes=" << remove_size << std::endl; + //std::cerr << "Size="<<GetSize() << " Un-useful bytes=" << remove_size << std::endl; RemoveRedundantBytes(remove_size); } - mp_prev_parse_unit = p_curr_unit; - return p_curr_unit; + mp_prev_parse_unit=p_curr_unit; + return p_curr_unit; } DiracByteStats DiracByteStream::GetSequenceStats() const @@ -161,7 +161,7 @@ DiracByteStats DiracByteStream::GetSequenceStats() const void DiracByteStream::AddSequenceHeader(SequenceHeaderByteIO *p_seqheader_byteio) { // set previous parse-unit details - ParseUnitByteIO *mp_previous_parse_unit = mp_prev_parse_unit; + ParseUnitByteIO *mp_previous_parse_unit=mp_prev_parse_unit; if(!m_parse_unit_list.empty()) mp_previous_parse_unit = m_parse_unit_list.back().second; @@ -170,7 +170,7 @@ void DiracByteStream::AddSequenceHeader(SequenceHeaderByteIO *p_seqheader_byteio p_seqheader_byteio->SetAdjacentParseUnits(mp_previous_parse_unit); // push onto to pending list - m_parse_unit_list.push(std::make_pair(PU_SEQ_HEADER, p_seqheader_byteio)); + m_parse_unit_list.push(std::make_pair (PU_SEQ_HEADER, p_seqheader_byteio) ); // set previous parse-unit mp_previous_parse_unit = p_seqheader_byteio; @@ -182,7 +182,7 @@ void DiracByteStream::AddSequenceHeader(SequenceHeaderByteIO *p_seqheader_byteio void DiracByteStream::AddPicture(PictureByteIO *p_frame_byteio) { // set previous parse-unit details - ParseUnitByteIO *mp_previous_parse_unit = mp_prev_parse_unit; + ParseUnitByteIO *mp_previous_parse_unit=mp_prev_parse_unit; if(!m_parse_unit_list.empty()) mp_previous_parse_unit = m_parse_unit_list.back().second; @@ -190,26 +190,26 @@ void DiracByteStream::AddPicture(PictureByteIO *p_frame_byteio) // set adjacent parse-unit p_frame_byteio->SetAdjacentParseUnits(mp_previous_parse_unit); - // push onto to pending list - m_parse_unit_list.push(std::make_pair(PU_PICTURE, p_frame_byteio)); + // push onto to pending list + m_parse_unit_list.push(std::make_pair(PU_PICTURE, p_frame_byteio ) ); - // set previous parse-unit + // set previous parse-unit mp_previous_parse_unit = p_frame_byteio; - // save stats + // save stats p_frame_byteio->CollateByteStats(m_sequence_stats); } void DiracByteStream::Clear() { - while(!m_parse_unit_list.empty()) + while(!m_parse_unit_list.empty()) { - ParseUnitByteIO* p_parse_unit = m_parse_unit_list.front().second; + ParseUnitByteIO* p_parse_unit=m_parse_unit_list.front().second; m_parse_unit_list.pop(); if(m_parse_unit_list.empty()) { delete mp_prev_parse_unit; - mp_prev_parse_unit = p_parse_unit; + mp_prev_parse_unit=p_parse_unit; } else delete p_parse_unit; @@ -221,8 +221,8 @@ DiracByteStats DiracByteStream::EndSequence() // create EndOfSequenceByteIO *p_endofsequence_byteio = new EndOfSequenceByteIO(*this); - // set previous parse-unit details - ParseUnitByteIO *mp_previous_parse_unit = mp_prev_parse_unit; + // set previous parse-unit details + ParseUnitByteIO *mp_previous_parse_unit=mp_prev_parse_unit; if(!m_parse_unit_list.empty()) mp_previous_parse_unit = m_parse_unit_list.back().second; @@ -230,8 +230,8 @@ DiracByteStats DiracByteStream::EndSequence() // set adjacent parse-unit p_endofsequence_byteio->SetAdjacentParseUnits(mp_previous_parse_unit); - // push onto to pending list - m_parse_unit_list.push(std::make_pair(PU_END_OF_SEQUENCE, p_endofsequence_byteio)); + // push onto to pending list + m_parse_unit_list.push(std::make_pair(PU_END_OF_SEQUENCE, p_endofsequence_byteio) ); p_endofsequence_byteio->CollateByteStats(m_sequence_stats); diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/dirac_byte_stream.h b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/dirac_byte_stream.h index 6d2bf229d..d448b5fca 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/dirac_byte_stream.h +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/dirac_byte_stream.h @@ -53,105 +53,105 @@ namespace dirac { -/** -* Represents a series of bytes in the Dirac bytestream specfication format. -* These bytes are grouped into more managable parse units by this class. -*/ -class DiracByteStream : public ByteIO -{ -public: - - /** - * Constructor - */ - DiracByteStream(); - - /** - * Destructor - */ - ~DiracByteStream(); - - /** - * Adds Dirac-formatted bytes to internal-byte-stream for processing - *@param start Start of char list - *@param count Number of chars - */ - void AddBytes(char* start, int count); - - /** - * Gets the statistics of the most recent parse-unit to be processed - *@return Byte-statistics - */ - DiracByteStats GetLastUnitStats(); - - /** - * Gets the next parse-unit in the current byte-stream - */ - ParseUnitByteIO* GetNextParseUnit(); - - - /** - * Gets stats for current sequence - */ - DiracByteStats GetSequenceStats() const; - - /** - * Adds a random access point to the current Dirac byte stream - *@param p_seqheader_byteio Sequence header data. - */ - void AddSequenceHeader(SequenceHeaderByteIO *p_seqheader_byteio); - /** - * Adds a picture to the current Dirac byte stream - *@param p_frame_byteio Picture stream. This class is now responsible for deleting. + * Represents a series of bytes in the Dirac bytestream specfication format. + * These bytes are grouped into more managable parse units by this class. */ - void AddPicture(PictureByteIO *p_frame_byteio); - - /** - * Clear parse-units - */ - void Clear(); - - /** - * Insert end-of-sequence data - *@return Sequence stats - */ - DiracByteStats EndSequence(); - - /** - * Gets a pointer to all current output bytes - */ - const std::string GetBytes(); - - /** - * Any info pending? - */ - bool IsUnitAvailable() const; - -private: - - void Reset(ParseUnitByteIO* p_curr_unit, int pos); - -private: - - /** - * Parse-units in Dirac stream - */ - typedef std::queue< std::pair <ParseUnitType, ParseUnitByteIO*> > ParseUnitList; - ParseUnitList m_parse_unit_list; - - /** - * Last unit to be processed - * Required for specifying the previous parse-unit - */ - ParseUnitByteIO* mp_prev_parse_unit; - - /** - * Stats for current sequence - */ - DiracByteStats m_sequence_stats; - -}; + class DiracByteStream : public ByteIO + { + public: + + /** + * Constructor + */ + DiracByteStream(); + + /** + * Destructor + */ + ~DiracByteStream(); + + /** + * Adds Dirac-formatted bytes to internal-byte-stream for processing + *@param start Start of char list + *@param count Number of chars + */ + void AddBytes(char* start, int count); + + /** + * Gets the statistics of the most recent parse-unit to be processed + *@return Byte-statistics + */ + DiracByteStats GetLastUnitStats(); + + /** + * Gets the next parse-unit in the current byte-stream + */ + ParseUnitByteIO* GetNextParseUnit(); + + + /** + * Gets stats for current sequence + */ + DiracByteStats GetSequenceStats() const; + + /** + * Adds a random access point to the current Dirac byte stream + *@param p_seqheader_byteio Sequence header data. + */ + void AddSequenceHeader(SequenceHeaderByteIO *p_seqheader_byteio); + + /** + * Adds a picture to the current Dirac byte stream + *@param p_frame_byteio Picture stream. This class is now responsible for deleting. + */ + void AddPicture(PictureByteIO *p_frame_byteio); + + /** + * Clear parse-units + */ + void Clear(); + + /** + * Insert end-of-sequence data + *@return Sequence stats + */ + DiracByteStats EndSequence(); + + /** + * Gets a pointer to all current output bytes + */ + const std::string GetBytes(); + + /** + * Any info pending? + */ + bool IsUnitAvailable() const; + + private: + + void Reset(ParseUnitByteIO* p_curr_unit, int pos); + + private: + + /** + * Parse-units in Dirac stream + */ + typedef std::queue< std::pair <ParseUnitType, ParseUnitByteIO*> > ParseUnitList; + ParseUnitList m_parse_unit_list; + + /** + * Last unit to be processed + * Required for specifying the previous parse-unit + */ + ParseUnitByteIO* mp_prev_parse_unit; + + /** + * Stats for current sequence + */ + DiracByteStats m_sequence_stats; + + }; } // namespace dirac diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/displayparams_byteio.cpp b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/displayparams_byteio.cpp index f1faa202c..e74a4f278 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/displayparams_byteio.cpp +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/displayparams_byteio.cpp @@ -40,14 +40,14 @@ using namespace dirac; -SourceParamsByteIO::SourceParamsByteIO(SourceParams& src_params, - const SourceParams& default_src_params, - const ByteIO& stream_data): - ByteIO(stream_data), - m_src_params(src_params), - m_default_src_params(default_src_params) +SourceParamsByteIO::SourceParamsByteIO( SourceParams& src_params, + const SourceParams& default_src_params, + const ByteIO& stream_data): +ByteIO(stream_data), +m_src_params(src_params), +m_default_src_params(default_src_params) { - + } @@ -71,7 +71,7 @@ void SourceParamsByteIO::Input() // input frame rate InputFrameRate(); - // input pixel aspect ratio + // input pixel aspect ratio InputPixelAspectRatio(); // input clean area @@ -98,7 +98,7 @@ void SourceParamsByteIO::Output() // output frame rate OutputFrameRate(); - // output pixel aspect ratio + // output pixel aspect ratio OutputPixelAspectRatio(); // output clean area @@ -135,12 +135,12 @@ void SourceParamsByteIO::InputChromaSamplingFormat() // set chroma ChromaFormat chroma_format = IntToChromaFormat(ReadUint()); - if(chroma_format == formatNK) + if(chroma_format==formatNK) DIRAC_THROW_EXCEPTION( - ERR_INVALID_CHROMA_FORMAT, - "Dirac does not recognise the specified chroma-format", - SEVERITY_ACCESSUNIT_ERROR) - m_src_params.SetCFormat(chroma_format); + ERR_INVALID_CHROMA_FORMAT, + "Dirac does not recognise the specified chroma-format", + SEVERITY_ACCESSUNIT_ERROR) + m_src_params.SetCFormat(chroma_format); } void SourceParamsByteIO::InputPixelAspectRatio() @@ -151,24 +151,24 @@ void SourceParamsByteIO::InputPixelAspectRatio() // read index value int pixel_aspect_ratio_index = ReadUint(); - PixelAspectRatioType pixel_aspect_ratio = IntToPixelAspectRatioType(pixel_aspect_ratio_index); - if(pixel_aspect_ratio == PIXEL_ASPECT_RATIO_UNDEFINED) - DIRAC_THROW_EXCEPTION( - ERR_INVALID_PIXEL_ASPECT_RATIO, - "Dirac does not recognise the specified pixel_aspect_ratio", - SEVERITY_ACCESSUNIT_ERROR) - - if(pixel_aspect_ratio_index != PIXEL_ASPECT_RATIO_CUSTOM) - { - m_src_params.SetPixelAspectRatio(pixel_aspect_ratio); - } - else - { - // read num/denom - int numerator = ReadUint(); - int denominator = ReadUint(); - m_src_params.SetPixelAspectRatio(numerator, denominator); - } + PixelAspectRatioType pixel_aspect_ratio=IntToPixelAspectRatioType(pixel_aspect_ratio_index); + if(pixel_aspect_ratio==PIXEL_ASPECT_RATIO_UNDEFINED) + DIRAC_THROW_EXCEPTION( + ERR_INVALID_PIXEL_ASPECT_RATIO, + "Dirac does not recognise the specified pixel_aspect_ratio", + SEVERITY_ACCESSUNIT_ERROR) + + if(pixel_aspect_ratio_index!=PIXEL_ASPECT_RATIO_CUSTOM) + { + m_src_params.SetPixelAspectRatio(pixel_aspect_ratio); + } + else + { + // read num/denom + int numerator = ReadUint(); + int denominator = ReadUint(); + m_src_params.SetPixelAspectRatio(numerator, denominator); + } } @@ -178,10 +178,10 @@ void SourceParamsByteIO::InputCleanArea() if(!clean_area_flag) return; - m_src_params.SetCleanWidth(ReadUint()); - m_src_params.SetCleanHeight(ReadUint()); - m_src_params.SetLeftOffset(ReadUint()); - m_src_params.SetTopOffset(ReadUint()); + m_src_params.SetCleanWidth( ReadUint() ); + m_src_params.SetCleanHeight( ReadUint() ); + m_src_params.SetLeftOffset( ReadUint() ); + m_src_params.SetTopOffset( ReadUint() ); } void SourceParamsByteIO::InputColourMatrix() @@ -214,8 +214,8 @@ void SourceParamsByteIO::InputColourSpecification() // read index value int colour_spec_index = ReadUint(); - m_src_params.SetColourSpecification(colour_spec_index); - if(colour_spec_index == 0) + m_src_params.SetColourSpecification( colour_spec_index ); + if(colour_spec_index==0) { InputColourPrimaries(); InputColourMatrix(); @@ -230,24 +230,24 @@ void SourceParamsByteIO::InputFrameRate() return; int frame_rate_index = ReadUint(); - FrameRateType frame_rate = IntToFrameRateType(frame_rate_index); - if(frame_rate == FRAMERATE_UNDEFINED) + FrameRateType frame_rate=IntToFrameRateType(frame_rate_index); + if(frame_rate==FRAMERATE_UNDEFINED) DIRAC_THROW_EXCEPTION( - ERR_INVALID_PICTURE_RATE, - "Dirac does not recognise the specified frame-rate", - SEVERITY_ACCESSUNIT_ERROR) + ERR_INVALID_PICTURE_RATE, + "Dirac does not recognise the specified frame-rate", + SEVERITY_ACCESSUNIT_ERROR) - if(frame_rate_index != FRAMERATE_CUSTOM) - { - m_src_params.SetFrameRate(frame_rate); - } - else - { - // read num/denom - int numerator = ReadUint(); - int denominator = ReadUint(); - m_src_params.SetFrameRate(numerator, denominator); - } + if(frame_rate_index!=FRAMERATE_CUSTOM) + { + m_src_params.SetFrameRate(frame_rate); + } + else + { + // read num/denom + int numerator = ReadUint(); + int denominator = ReadUint(); + m_src_params.SetFrameRate(numerator, denominator); + } } void SourceParamsByteIO::InputScanFormat() @@ -257,7 +257,7 @@ void SourceParamsByteIO::InputScanFormat() return; unsigned int source_sampling = ReadUint(); - if(source_sampling > 1) + if (source_sampling > 1) { std::ostringstream errstr; errstr << "Source Sampling " << source_sampling @@ -279,25 +279,25 @@ void SourceParamsByteIO::InputSignalRange() // read index value int signal_range_index = ReadUint(); SignalRangeType signal_range = IntToSignalRangeType(signal_range_index); - if(signal_range == SIGNAL_RANGE_UNDEFINED) + if(signal_range==SIGNAL_RANGE_UNDEFINED) DIRAC_THROW_EXCEPTION( - ERR_INVALID_SIGNAL_RANGE, - "Dirac does not recognise the specified signal-range", - SEVERITY_ACCESSUNIT_ERROR) + ERR_INVALID_SIGNAL_RANGE, + "Dirac does not recognise the specified signal-range", + SEVERITY_ACCESSUNIT_ERROR) - if(signal_range_index != SIGNAL_RANGE_CUSTOM) - { - m_src_params.SetSignalRange(signal_range); - } - else - { - // read luma values - m_src_params.SetLumaOffset(ReadUint()); - m_src_params.SetLumaExcursion(ReadUint()); - // read chroma values - m_src_params.SetChromaOffset(ReadUint()); - m_src_params.SetChromaExcursion(ReadUint()); - } + if(signal_range_index!=SIGNAL_RANGE_CUSTOM) + { + m_src_params.SetSignalRange(signal_range); + } + else + { + // read luma values + m_src_params.SetLumaOffset( ReadUint() ); + m_src_params.SetLumaExcursion( ReadUint() ); + // read chroma values + m_src_params.SetChromaOffset( ReadUint() ); + m_src_params.SetChromaExcursion( ReadUint() ); + } } void SourceParamsByteIO::InputTransferFunction() @@ -315,8 +315,8 @@ void SourceParamsByteIO::OutputFrameSize() { // output 'is custom' dimensions flag - bool is_custom = (m_src_params.Xl() != m_default_src_params.Xl() || - m_src_params.Yl() != m_default_src_params.Yl()); + bool is_custom = (m_src_params.Xl()!=m_default_src_params.Xl() || + m_src_params.Yl()!=m_default_src_params.Yl()); WriteBit(is_custom); @@ -332,8 +332,8 @@ void SourceParamsByteIO::OutputFrameSize() void SourceParamsByteIO::OutputChromaSamplingFormat() { // output 'is default' flag - bool not_default = m_src_params.CFormat() != m_default_src_params.CFormat(); - + bool not_default = m_src_params.CFormat()!=m_default_src_params.CFormat(); + WriteBit(not_default); if(!not_default) @@ -346,20 +346,20 @@ void SourceParamsByteIO::OutputChromaSamplingFormat() void SourceParamsByteIO::OutputPixelAspectRatio() { - if(m_src_params.PixelAspectRatioIndex() != PIXEL_ASPECT_RATIO_CUSTOM - && m_src_params.PixelAspectRatioIndex() == m_default_src_params.PixelAspectRatioIndex()) + if (m_src_params.PixelAspectRatioIndex()!= PIXEL_ASPECT_RATIO_CUSTOM + && m_src_params.PixelAspectRatioIndex() == m_default_src_params.PixelAspectRatioIndex()) { // default frame rate index WriteBit(0); return; } // Non-defaults - WriteBit(1); + WriteBit(1); // Picture rate index WriteUint(m_src_params.PixelAspectRatioIndex()); - - if(!m_src_params.PixelAspectRatioIndex()) // i,e. custom value + + if (!m_src_params.PixelAspectRatioIndex()) // i,e. custom value { WriteUint(m_src_params.PixelAspectRatio().m_num); WriteUint(m_src_params.PixelAspectRatio().m_denom); @@ -369,10 +369,10 @@ void SourceParamsByteIO::OutputPixelAspectRatio() void SourceParamsByteIO::OutputCleanArea() { - if(m_src_params.CleanWidth() != m_default_src_params.CleanWidth() || - m_src_params.CleanHeight() != m_default_src_params.CleanHeight() || - m_src_params.LeftOffset() != m_default_src_params.LeftOffset() || - m_src_params.TopOffset() != m_default_src_params.TopOffset()) + if (m_src_params.CleanWidth() != m_default_src_params.CleanWidth() || + m_src_params.CleanHeight() != m_default_src_params.CleanHeight() || + m_src_params.LeftOffset() != m_default_src_params.LeftOffset() || + m_src_params.TopOffset() != m_default_src_params.TopOffset()) { WriteBit(1); // non-default value WriteUint(m_src_params.CleanWidth()); @@ -386,9 +386,9 @@ void SourceParamsByteIO::OutputCleanArea() void SourceParamsByteIO::OutputColourSpecification() { - if(m_src_params.ColourSpecificationIndex() && - m_src_params.ColourSpecificationIndex() == - m_default_src_params.ColourSpecificationIndex()) + if (m_src_params.ColourSpecificationIndex() && + m_src_params.ColourSpecificationIndex() == + m_default_src_params.ColourSpecificationIndex()) { // default colour specification WriteBit(0); @@ -396,14 +396,14 @@ void SourceParamsByteIO::OutputColourSpecification() } // Non-defaults - WriteBit(1); + WriteBit(1); // Output Colour specification index WriteUint(m_src_params.ColourSpecificationIndex()); - if(!m_src_params.ColourSpecificationIndex()) // i,e, custom values + if (!m_src_params.ColourSpecificationIndex()) // i,e, custom values { // Output Colour Primaries - if(m_src_params.ColourPrimariesIndex() == m_default_src_params.ColourPrimariesIndex()) + if (m_src_params.ColourPrimariesIndex() == m_default_src_params.ColourPrimariesIndex()) { // default value WriteBit(0); @@ -415,7 +415,7 @@ void SourceParamsByteIO::OutputColourSpecification() } // Output Colour Matrix - if(m_src_params.ColourMatrixIndex() == m_default_src_params.ColourMatrixIndex()) + if (m_src_params.ColourMatrixIndex() == m_default_src_params.ColourMatrixIndex()) { // default value WriteBit(0); @@ -427,7 +427,7 @@ void SourceParamsByteIO::OutputColourSpecification() } // Output TransferFunction - if(m_src_params.TransferFunctionIndex() == m_default_src_params.TransferFunctionIndex()) + if (m_src_params.TransferFunctionIndex() == m_default_src_params.TransferFunctionIndex()) { // default value WriteBit(0); @@ -442,20 +442,20 @@ void SourceParamsByteIO::OutputColourSpecification() void SourceParamsByteIO::OutputFrameRate() { - if(m_src_params.FrameRateIndex() != FRAMERATE_CUSTOM - && m_src_params.FrameRateIndex() == m_default_src_params.FrameRateIndex()) + if (m_src_params.FrameRateIndex()!=FRAMERATE_CUSTOM + && m_src_params.FrameRateIndex() == m_default_src_params.FrameRateIndex()) { // default frame rate index WriteBit(0); return; } // Non-defaults - WriteBit(1); + WriteBit(1); // Picture rate index WriteUint(m_src_params.FrameRateIndex()); - - if(!m_src_params.FrameRateIndex()) // i,e. custom value + + if (!m_src_params.FrameRateIndex()) // i,e. custom value { WriteUint(m_src_params.FrameRate().m_num); WriteUint(m_src_params.FrameRate().m_denom); @@ -465,8 +465,8 @@ void SourceParamsByteIO::OutputFrameRate() void SourceParamsByteIO::OutputScanFormat() { // output 'is default' flag - bool not_interlace_default = m_src_params.SourceSampling() != m_default_src_params.SourceSampling(); - + bool not_interlace_default = m_src_params.SourceSampling()!=m_default_src_params.SourceSampling(); + WriteBit(not_interlace_default); if(!not_interlace_default) @@ -479,20 +479,20 @@ void SourceParamsByteIO::OutputScanFormat() void SourceParamsByteIO::OutputSignalRange() { - if(m_src_params.SignalRangeIndex() != SIGNAL_RANGE_CUSTOM && - m_src_params.SignalRangeIndex() == m_default_src_params.SignalRangeIndex()) + if (m_src_params.SignalRangeIndex()!=SIGNAL_RANGE_CUSTOM && + m_src_params.SignalRangeIndex() == m_default_src_params.SignalRangeIndex()) { // defaults WriteBit(0); return; } - + // Non-defaults - WriteBit(1); + WriteBit(1); // Output Signal Range Index WriteUint(m_src_params.SignalRangeIndex()); - if(!m_src_params.SignalRangeIndex()) // i.e. custom values + if (!m_src_params.SignalRangeIndex()) // i.e. custom values { WriteUint(m_src_params.LumaOffset()); WriteUint(m_src_params.LumaExcursion()); diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/displayparams_byteio.h b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/displayparams_byteio.h index 12cf7cec6..bc5fe823d 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/displayparams_byteio.h +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/displayparams_byteio.h @@ -51,148 +51,148 @@ namespace dirac { - -/** -* Represents compressed source-parameter data contained in a sequence header -*/ -class SourceParamsByteIO : public ByteIO -{ -public: - - /** - * Constructor for Input/Output - *@param src_params Source parameters - *@param default_src_params Default Source parameters - *@param stream_data Source/Destination of data - */ - SourceParamsByteIO(SourceParams& src_params, - const SourceParams& default_src_params, - const ByteIO& stream_data); - /** - * Destructor - */ - ~SourceParamsByteIO(); - - /** - * Reads source params information from Dirac byte-format - */ - void Input(); - - /** - * Outputs source params information to Dirac byte-format - */ - void Output(); - -protected: - - -private: - - /** - * Reads frame dimensions - */ - void InputFrameSize(); - - /** - * Reads Chroma Sampling Format - */ - void InputChromaSamplingFormat(); - - /** - * Reads pixel aspect ratio info - */ - void InputPixelAspectRatio(); - - /** - * Reads clean-area info - */ - void InputCleanArea(); - - /** - * Reads colour-matrix info - */ - void InputColourMatrix(); - - /** - * Reads primary-colour info - */ - void InputColourPrimaries(); - - /** - * Reads colour spec info - */ - void InputColourSpecification(); - - /** - * Reads frame-rate info - */ - void InputFrameRate(); - - /** - * Reads Scan info - */ - void InputScanFormat(); - - /** - * Reads signal range info - */ - void InputSignalRange(); - - /** - * Reads transfer-function info - */ - void InputTransferFunction(); - - /** - * Outputs frame dimensions - */ - void OutputFrameSize(); - - /** - * Outputs Chroma Sampling Format - */ - void OutputChromaSamplingFormat(); - - /** - * Outputs pixel aspect ratio info - */ - void OutputPixelAspectRatio(); - - /** - * Outputs clean-area info - */ - void OutputCleanArea(); - - /** - * Outputs colour spec info - */ - void OutputColourSpecification(); - - /** - * Outputs frame-rate info - */ - void OutputFrameRate(); - - /** - * Outputs Scan info - */ - void OutputScanFormat(); - - /** - * Outputs signal range info - */ - void OutputSignalRange(); - - /** - * Source parameters for input/ouput - */ - SourceParams& m_src_params; - - /** - * Default source parameters - */ - const SourceParams& m_default_src_params; -}; + + /** + * Represents compressed source-parameter data contained in a sequence header + */ + class SourceParamsByteIO : public ByteIO + { + public: + + /** + * Constructor for Input/Output + *@param src_params Source parameters + *@param default_src_params Default Source parameters + *@param stream_data Source/Destination of data + */ + SourceParamsByteIO( SourceParams& src_params, + const SourceParams& default_src_params, + const ByteIO& stream_data); + /** + * Destructor + */ + ~SourceParamsByteIO(); + + /** + * Reads source params information from Dirac byte-format + */ + void Input(); + + /** + * Outputs source params information to Dirac byte-format + */ + void Output(); + + protected: + + + private: + + /** + * Reads frame dimensions + */ + void InputFrameSize(); + + /** + * Reads Chroma Sampling Format + */ + void InputChromaSamplingFormat(); + + /** + * Reads pixel aspect ratio info + */ + void InputPixelAspectRatio(); + + /** + * Reads clean-area info + */ + void InputCleanArea(); + + /** + * Reads colour-matrix info + */ + void InputColourMatrix(); + + /** + * Reads primary-colour info + */ + void InputColourPrimaries(); + + /** + * Reads colour spec info + */ + void InputColourSpecification(); + + /** + * Reads frame-rate info + */ + void InputFrameRate(); + + /** + * Reads Scan info + */ + void InputScanFormat(); + + /** + * Reads signal range info + */ + void InputSignalRange(); + + /** + * Reads transfer-function info + */ + void InputTransferFunction(); + + /** + * Outputs frame dimensions + */ + void OutputFrameSize(); + + /** + * Outputs Chroma Sampling Format + */ + void OutputChromaSamplingFormat(); + + /** + * Outputs pixel aspect ratio info + */ + void OutputPixelAspectRatio(); + + /** + * Outputs clean-area info + */ + void OutputCleanArea(); + + /** + * Outputs colour spec info + */ + void OutputColourSpecification(); + + /** + * Outputs frame-rate info + */ + void OutputFrameRate(); + + /** + * Outputs Scan info + */ + void OutputScanFormat(); + + /** + * Outputs signal range info + */ + void OutputSignalRange(); + + /** + * Source parameters for input/ouput + */ + SourceParams& m_src_params; + + /** + * Default source parameters + */ + const SourceParams& m_default_src_params; + }; } // namespace dirac diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/endofsequence_byteio.cpp b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/endofsequence_byteio.cpp index 58f74870a..ca0144e8e 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/endofsequence_byteio.cpp +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/endofsequence_byteio.cpp @@ -46,9 +46,9 @@ using namespace std; EndOfSequenceByteIO::EndOfSequenceByteIO(const ByteIO& byte_io): - ParseUnitByteIO(byte_io) +ParseUnitByteIO(byte_io) { - + } @@ -65,14 +65,14 @@ void EndOfSequenceByteIO::CollateByteStats(DiracByteStats& dirac_byte_stats) //-------------private------------------------------------------------------- - + unsigned char EndOfSequenceByteIO::CalcParseCode() const { unsigned char code = 0; - // set end-of-sequence parse-code - SetBits(code, PARSE_CODE_END_OF_SEQUENCE); + // set end-of-sequence parse-code + SetBits(code, PARSE_CODE_END_OF_SEQUENCE); - return code; + return code; } diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/endofsequence_byteio.h b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/endofsequence_byteio.h index f1b7bdb87..0bce3997f 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/endofsequence_byteio.h +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/endofsequence_byteio.h @@ -50,60 +50,54 @@ namespace dirac { -/** -* Signals the end of a sequence in a Dirac-formatted bitstream. Current Accessunit parameters -* are no longer valid for subsequent frames -*/ -class EndOfSequenceByteIO : public ParseUnitByteIO -{ -public: - - /** - * Constructor - *@param stream_data Stream parameters - */ - EndOfSequenceByteIO(const ByteIO& stream_data); - - /** - * Destructor - */ - ~EndOfSequenceByteIO(); - - - /** - * Gets parse-unit type - */ - ParseUnitType GetType() const - { - return PU_END_OF_SEQUENCE; - } - - /** - * Gathers byte stats on the end of sequence data - *@param dirac_byte_stats Stat container - */ - void CollateByteStats(DiracByteStats& dirac_byte_stats); -protected: - /** - * Calculates number of bytes to start of next unit - *@return Zero(0) End of sequence does not specify a 'next'unit + * Signals the end of a sequence in a Dirac-formatted bitstream. Current Accessunit parameters + * are no longer valid for subsequent frames */ - int CalcNextUnitOffset() + class EndOfSequenceByteIO : public ParseUnitByteIO { - return 0; - } - -private: - - /** - * Calculates parse-code based on picture parameters - *@return Char bit-set - */ - unsigned char CalcParseCode() const; - - -}; + public: + + /** + * Constructor + *@param stream_data Stream parameters + */ + EndOfSequenceByteIO(const ByteIO& stream_data); + + /** + * Destructor + */ + ~EndOfSequenceByteIO(); + + + /** + * Gets parse-unit type + */ + ParseUnitType GetType() const { return PU_END_OF_SEQUENCE;} + + /** + * Gathers byte stats on the end of sequence data + *@param dirac_byte_stats Stat container + */ + void CollateByteStats(DiracByteStats& dirac_byte_stats); + protected: + + /** + * Calculates number of bytes to start of next unit + *@return Zero(0) End of sequence does not specify a 'next'unit + */ + int CalcNextUnitOffset() { return 0;} + + private: + + /** + * Calculates parse-code based on picture parameters + *@return Char bit-set + */ + unsigned char CalcParseCode() const; + + + }; } // namespace dirac diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/mvdata_byteio.cpp b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/mvdata_byteio.cpp index 075fe0176..2ed0357aa 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/mvdata_byteio.cpp +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/mvdata_byteio.cpp @@ -42,35 +42,35 @@ using namespace dirac; MvDataByteIO::MvDataByteIO(PictureParams& pparams, - PicturePredParams& picpredparams): - ByteIO(), - m_pparams(pparams), - m_picpredparams(picpredparams), - m_splitmode_data(), - m_predmode_data(), - m_mv1hblock_data(), - m_mv1vblock_data(), - m_mv2hblock_data(), - m_mv2vblock_data(), - m_ydcblock_data(), - m_udcblock_data(), - m_vdcblock_data() + PicturePredParams& picpredparams): +ByteIO(), +m_pparams(pparams), +m_picpredparams(picpredparams), +m_splitmode_data(), +m_predmode_data(), +m_mv1hblock_data(), +m_mv1vblock_data(), +m_mv2hblock_data(), +m_mv2vblock_data(), +m_ydcblock_data(), +m_udcblock_data(), +m_vdcblock_data() {} MvDataByteIO::MvDataByteIO(ByteIO &byte_io, PictureParams& pparams, - PicturePredParams& picpredparams): - ByteIO(byte_io), - m_pparams(pparams), - m_picpredparams(picpredparams), - m_splitmode_data(byte_io), - m_predmode_data(byte_io), - m_mv1hblock_data(byte_io), - m_mv1vblock_data(byte_io), - m_mv2hblock_data(byte_io), - m_mv2vblock_data(byte_io), - m_ydcblock_data(byte_io), - m_udcblock_data(byte_io), - m_vdcblock_data(byte_io) + PicturePredParams& picpredparams): +ByteIO(byte_io), +m_pparams(pparams), +m_picpredparams(picpredparams), +m_splitmode_data(byte_io), +m_predmode_data(byte_io), +m_mv1hblock_data(byte_io), +m_mv1vblock_data(byte_io), +m_mv2hblock_data(byte_io), +m_mv2vblock_data(byte_io), +m_ydcblock_data(byte_io), +m_udcblock_data(byte_io), +m_vdcblock_data(byte_io) {} MvDataByteIO::~MvDataByteIO() @@ -85,50 +85,50 @@ void MvDataByteIO::CollateByteStats(DiracByteStats& dirac_byte_stats) int MvDataByteIO::GetSize() const { - if(m_pparams.NumRefs() == 2) + if (m_pparams.NumRefs()==2) return ByteIO::GetSize() + - m_splitmode_data.GetSize() + - m_predmode_data.GetSize() + - m_mv1hblock_data.GetSize() + - m_mv1vblock_data.GetSize() + - m_mv2hblock_data.GetSize() + - m_mv2vblock_data.GetSize() + - m_ydcblock_data.GetSize() + - m_udcblock_data.GetSize() + + m_splitmode_data.GetSize()+ + m_predmode_data.GetSize()+ + m_mv1hblock_data.GetSize()+ + m_mv1vblock_data.GetSize()+ + m_mv2hblock_data.GetSize()+ + m_mv2vblock_data.GetSize()+ + m_ydcblock_data.GetSize()+ + m_udcblock_data.GetSize()+ m_vdcblock_data.GetSize(); else return ByteIO::GetSize() + - m_splitmode_data.GetSize() + - m_predmode_data.GetSize() + - m_mv1hblock_data.GetSize() + - m_mv1vblock_data.GetSize() + - m_ydcblock_data.GetSize() + - m_udcblock_data.GetSize() + + m_splitmode_data.GetSize()+ + m_predmode_data.GetSize()+ + m_mv1hblock_data.GetSize()+ + m_mv1vblock_data.GetSize()+ + m_ydcblock_data.GetSize()+ + m_udcblock_data.GetSize()+ m_vdcblock_data.GetSize(); } const std::string MvDataByteIO::GetBytes() { //Output header and block data - if(m_pparams.NumRefs() == 2) + if (m_pparams.NumRefs()==2 ) return ByteIO::GetBytes() + - m_splitmode_data.GetBytes() + - m_predmode_data.GetBytes() + - m_mv1hblock_data.GetBytes() + - m_mv1vblock_data.GetBytes() + - m_mv2hblock_data.GetBytes() + - m_mv2vblock_data.GetBytes() + - m_ydcblock_data.GetBytes() + - m_udcblock_data.GetBytes() + + m_splitmode_data.GetBytes()+ + m_predmode_data.GetBytes()+ + m_mv1hblock_data.GetBytes()+ + m_mv1vblock_data.GetBytes()+ + m_mv2hblock_data.GetBytes()+ + m_mv2vblock_data.GetBytes()+ + m_ydcblock_data.GetBytes()+ + m_udcblock_data.GetBytes()+ m_vdcblock_data.GetBytes(); else return ByteIO::GetBytes() + - m_splitmode_data.GetBytes() + - m_predmode_data.GetBytes() + - m_mv1hblock_data.GetBytes() + - m_mv1vblock_data.GetBytes() + - m_ydcblock_data.GetBytes() + - m_udcblock_data.GetBytes() + + m_splitmode_data.GetBytes()+ + m_predmode_data.GetBytes()+ + m_mv1hblock_data.GetBytes()+ + m_mv1vblock_data.GetBytes()+ + m_ydcblock_data.GetBytes()+ + m_udcblock_data.GetBytes()+ m_vdcblock_data.GetBytes(); } @@ -186,7 +186,7 @@ void MvDataByteIO::OutputBlockParams() // output custom block params flag unsigned int pidx = BlockParametersIndex(olb_params); WriteUint(pidx); - if(pidx == 0) // custom block params + if (pidx == 0) // custom block params { // output Xblen WriteUint(olb_params.Xblen()); @@ -204,7 +204,7 @@ void MvDataByteIO::InputBlockParams() OLBParams olb_params; unsigned int p_idx = ReadUint(); - if(p_idx == 0) + if (p_idx == 0) { // Input Xblen olb_params.SetXblen(ReadUint()); @@ -216,7 +216,7 @@ void MvDataByteIO::InputBlockParams() olb_params.SetYbsep(ReadUint()); } else - SetDefaultBlockParameters(olb_params, p_idx); + SetDefaultBlockParameters (olb_params, p_idx); m_picpredparams.SetLumaBlockParams(olb_params); } @@ -231,13 +231,13 @@ void MvDataByteIO::InputMVPrecision() { // Input Motion vector precision MVPrecisionType mv_prec = IntToMVPrecisionType(ReadUint()); - if(mv_prec == MV_PRECISION_UNDEFINED) + if(mv_prec==MV_PRECISION_UNDEFINED) DIRAC_THROW_EXCEPTION( - ERR_INVALID_MOTION_VECTOR_PRECISION, - "Dirac does not recognise the specified MV precision", - SEVERITY_PICTURE_ERROR) + ERR_INVALID_MOTION_VECTOR_PRECISION, + "Dirac does not recognise the specified MV precision", + SEVERITY_PICTURE_ERROR) - m_picpredparams.SetMVPrecision(mv_prec); + m_picpredparams.SetMVPrecision(mv_prec); } void MvDataByteIO::OutputGlobalMotionParams() @@ -252,15 +252,15 @@ void MvDataByteIO::InputGlobalMotionParams() { // Always setting global motion to false // Using Global motion flag - if(ReadBool()) + if (ReadBool()) { m_picpredparams.SetUsingGlobalMotion(true); // NOTE: FIXME - input actual global motion params in future DIRAC_THROW_EXCEPTION( - ERR_UNSUPPORTED_STREAM_DATA, - "Cannot handle global motion parameters", - SEVERITY_PICTURE_ERROR) + ERR_UNSUPPORTED_STREAM_DATA, + "Cannot handle global motion parameters", + SEVERITY_PICTURE_ERROR) } else m_picpredparams.SetUsingGlobalMotion(false); @@ -278,7 +278,7 @@ void MvDataByteIO::InputFramePredictionMode() // TODO - need to process this field when alternative prediction modes // become available. unsigned int frame_pred_mode = ReadUint(); - if(frame_pred_mode != 0) + if (frame_pred_mode != 0) { DIRAC_THROW_EXCEPTION( ERR_UNSUPPORTED_STREAM_DATA, @@ -291,16 +291,16 @@ void MvDataByteIO::InputFramePredictionMode() void MvDataByteIO::OutputPictureWeights() { // Output default weights flags - if(m_picpredparams.PictureWeightsBits() != 1 || - m_picpredparams.Ref1Weight() != 1 || - (m_pparams.Refs().size() > 1 && m_picpredparams.Ref2Weight() != 1)) + if (m_picpredparams.PictureWeightsBits() != 1 || + m_picpredparams.Ref1Weight() != 1 || + (m_pparams.Refs().size() > 1 && m_picpredparams.Ref2Weight() != 1) ) { - WriteBit(true); + WriteBit(true); // Output weight precision bits WriteUint(m_picpredparams.PictureWeightsBits()); // Output Ref1 weight WriteSint(m_picpredparams.Ref1Weight()); - if(m_pparams.Refs().size() > 1) + if (m_pparams.Refs().size() > 1) { // Output Ref1 weight WriteSint(m_picpredparams.Ref2Weight()); @@ -308,17 +308,17 @@ void MvDataByteIO::OutputPictureWeights() } else { - WriteBit(false); + WriteBit(false); } } void MvDataByteIO::InputPictureWeights() { - if(ReadBool()) + if (ReadBool()) { m_picpredparams.SetPictureWeightsPrecision(ReadUint()); m_picpredparams.SetRef1Weight(ReadSint()); - if(m_pparams.Refs().size() > 1) + if (m_pparams.Refs().size() > 1) m_picpredparams.SetRef2Weight(ReadSint()); else m_picpredparams.SetRef2Weight(0); diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/mvdata_byteio.h b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/mvdata_byteio.h index ff809c3d5..578a3594e 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/mvdata_byteio.h +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/mvdata_byteio.h @@ -53,244 +53,217 @@ namespace dirac { -/** -* Represents compressed sequence-parameter data used in an AccessUnit -*/ -class MvDataByteIO : public ByteIO -{ -public: - - /** - * Constructor - *@param pparams Picture Params - *@param picpredparams Picture prediction parameters - */ - MvDataByteIO(PictureParams& pparams, - PicturePredParams& picpredparams); - - /** - * Constructor - *@param byte_io Input/Output Byte stream - *@param pparams Picture Params - *@param picpredparams Picture prediction parameters - */ - MvDataByteIO(ByteIO &byte_io, PictureParams& pparams, - PicturePredParams& picpredparams); - - /** - * Destructor - */ - virtual ~MvDataByteIO(); - - /** - * Gathers byte stats on the motion vector data - *@param dirac_byte_stats Stat container - */ - void CollateByteStats(DiracByteStats& dirac_byte_stats); - - /** - * Outputs motion vector data Dirac byte-format - */ - void Output(); - - /** - * Inputs motion vector information - */ - void Input(); - - - /** - * Get string containing coded bytes - */ - virtual const std::string GetBytes(); - /** - * Return pointer to the superblock splitting modes ByteIO stream + * Represents compressed sequence-parameter data used in an AccessUnit */ - MvDataElementByteIO* SplitModeData() + class MvDataByteIO : public ByteIO { - return &m_splitmode_data; + public: + + /** + * Constructor + *@param pparams Picture Params + *@param picpredparams Picture prediction parameters + */ + MvDataByteIO(PictureParams& pparams, + PicturePredParams& picpredparams); + + /** + * Constructor + *@param byte_io Input/Output Byte stream + *@param pparams Picture Params + *@param picpredparams Picture prediction parameters + */ + MvDataByteIO(ByteIO &byte_io, PictureParams& pparams, + PicturePredParams& picpredparams); + + /** + * Destructor + */ + virtual ~MvDataByteIO(); + + /** + * Gathers byte stats on the motion vector data + *@param dirac_byte_stats Stat container + */ + void CollateByteStats(DiracByteStats& dirac_byte_stats); + + /** + * Outputs motion vector data Dirac byte-format + */ + void Output(); + + /** + * Inputs motion vector information + */ + void Input(); + + + /** + * Get string containing coded bytes + */ + virtual const std::string GetBytes(); + + /** + * Return pointer to the superblock splitting modes ByteIO stream + */ + MvDataElementByteIO* SplitModeData() { return &m_splitmode_data; }; + + /** + * Return pointer to the superblock splitting modes ByteIO stream + */ + MvDataElementByteIO* PredModeData() { return &m_predmode_data; }; + + /** + * Return pointer to the block MVs reference 1 ByteIO stream + */ + MvDataElementByteIO* MV1HorizData() { return &m_mv1hblock_data; }; + + /** + * Return pointer to the block MVs reference 1 ByteIO stream + */ + MvDataElementByteIO* MV1VertData() { return &m_mv1vblock_data; }; + + /** + * Return pointer to the block MV reference 2 ByteIO stream + */ + MvDataElementByteIO* MV2HorizData() { return &m_mv2hblock_data; }; + + /** + * Return pointer to the block MV reference 2 ByteIO stream + */ + MvDataElementByteIO* MV2VertData() { return &m_mv2vblock_data; }; + + /** + * Return pointer to the block Y DC values ByteIO stream + */ + MvDataElementByteIO* YDCData() { return &m_ydcblock_data; }; + + /** + * Return pointer to the block U DC values ByteIO stream + */ + MvDataElementByteIO* UDCData() { return &m_udcblock_data; }; + + /** + * Return pointer to the block V DC values ByteIO stream + */ + MvDataElementByteIO* VDCData() { return &m_vdcblock_data; }; + + /** + * Return the size + */ + int GetSize() const; + + protected: + + + private: + /** + * Inputs block parameters + */ + void InputBlockParams(); + + /** + * Inputs Motion vector precision data + */ + void InputMVPrecision(); + + /** + * Inputs global motion parameters + */ + void InputGlobalMotionParams(); + + /** + * Inputs picture prediction mode + */ + void InputFramePredictionMode(); + + /** + * Inputs Picture Weights + */ + void InputPictureWeights(); + + /** + * Outputs block parameters + */ + void OutputBlockParams(); + + /** + * Outputs Motion vector precision data + */ + void OutputMVPrecision(); + + /** + * Outputs global motion parameters + */ + void OutputGlobalMotionParams(); + + /** + * Outputs picture prediction mode + */ + void OutputFramePredictionMode(); + + /** + * Outputs Picture Weights + */ + void OutputPictureWeights(); + + /** + * Sequence paramters for intput/output + */ + PictureParams& m_pparams; + + /** + * Codec params - EncParams for Output and DecParams for input + */ + PicturePredParams& m_picpredparams; + + /** + * block data containing split modes + */ + MvDataElementByteIO m_splitmode_data; + + /** + * block data containing prediction modes + */ + MvDataElementByteIO m_predmode_data; + + /** + * block data containing horizontal MV components for reference 1 + */ + MvDataElementByteIO m_mv1hblock_data; + + /** + * block data containing vertical MV components for reference 1 + */ + MvDataElementByteIO m_mv1vblock_data; + + /** + * block data containing horizontal MV components for reference 2 + */ + MvDataElementByteIO m_mv2hblock_data; + + /** + * block data containing vertical MV components for reference 2 + */ + MvDataElementByteIO m_mv2vblock_data; + + /** + * block data containing Y DC data + */ + MvDataElementByteIO m_ydcblock_data; + + /** + * block data containing U DC data + */ + MvDataElementByteIO m_udcblock_data; + + /** + * block data containing V DC data + */ + MvDataElementByteIO m_vdcblock_data; }; - /** - * Return pointer to the superblock splitting modes ByteIO stream - */ - MvDataElementByteIO* PredModeData() - { - return &m_predmode_data; - }; - - /** - * Return pointer to the block MVs reference 1 ByteIO stream - */ - MvDataElementByteIO* MV1HorizData() - { - return &m_mv1hblock_data; - }; - - /** - * Return pointer to the block MVs reference 1 ByteIO stream - */ - MvDataElementByteIO* MV1VertData() - { - return &m_mv1vblock_data; - }; - - /** - * Return pointer to the block MV reference 2 ByteIO stream - */ - MvDataElementByteIO* MV2HorizData() - { - return &m_mv2hblock_data; - }; - - /** - * Return pointer to the block MV reference 2 ByteIO stream - */ - MvDataElementByteIO* MV2VertData() - { - return &m_mv2vblock_data; - }; - - /** - * Return pointer to the block Y DC values ByteIO stream - */ - MvDataElementByteIO* YDCData() - { - return &m_ydcblock_data; - }; - - /** - * Return pointer to the block U DC values ByteIO stream - */ - MvDataElementByteIO* UDCData() - { - return &m_udcblock_data; - }; - - /** - * Return pointer to the block V DC values ByteIO stream - */ - MvDataElementByteIO* VDCData() - { - return &m_vdcblock_data; - }; - - /** - * Return the size - */ - int GetSize() const; - -protected: - - -private: - /** - * Inputs block parameters - */ - void InputBlockParams(); - - /** - * Inputs Motion vector precision data - */ - void InputMVPrecision(); - - /** - * Inputs global motion parameters - */ - void InputGlobalMotionParams(); - - /** - * Inputs picture prediction mode - */ - void InputFramePredictionMode(); - - /** - * Inputs Picture Weights - */ - void InputPictureWeights(); - - /** - * Outputs block parameters - */ - void OutputBlockParams(); - - /** - * Outputs Motion vector precision data - */ - void OutputMVPrecision(); - - /** - * Outputs global motion parameters - */ - void OutputGlobalMotionParams(); - - /** - * Outputs picture prediction mode - */ - void OutputFramePredictionMode(); - - /** - * Outputs Picture Weights - */ - void OutputPictureWeights(); - - /** - * Sequence paramters for intput/output - */ - PictureParams& m_pparams; - - /** - * Codec params - EncParams for Output and DecParams for input - */ - PicturePredParams& m_picpredparams; - - /** - * block data containing split modes - */ - MvDataElementByteIO m_splitmode_data; - - /** - * block data containing prediction modes - */ - MvDataElementByteIO m_predmode_data; - - /** - * block data containing horizontal MV components for reference 1 - */ - MvDataElementByteIO m_mv1hblock_data; - - /** - * block data containing vertical MV components for reference 1 - */ - MvDataElementByteIO m_mv1vblock_data; - - /** - * block data containing horizontal MV components for reference 2 - */ - MvDataElementByteIO m_mv2hblock_data; - - /** - * block data containing vertical MV components for reference 2 - */ - MvDataElementByteIO m_mv2vblock_data; - - /** - * block data containing Y DC data - */ - MvDataElementByteIO m_ydcblock_data; - - /** - * block data containing U DC data - */ - MvDataElementByteIO m_udcblock_data; - - /** - * block data containing V DC data - */ - MvDataElementByteIO m_vdcblock_data; -}; - } // namespace dirac #endif diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/mvdataelement_byteio.cpp b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/mvdataelement_byteio.cpp index 524845df4..f8785616d 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/mvdataelement_byteio.cpp +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/mvdataelement_byteio.cpp @@ -44,14 +44,14 @@ using namespace dirac; MvDataElementByteIO::MvDataElementByteIO(): - ByteIO(), - m_block_data() +ByteIO(), +m_block_data() { } MvDataElementByteIO::MvDataElementByteIO(ByteIO &byte_io): - ByteIO(byte_io), - m_block_data(byte_io) +ByteIO(byte_io), +m_block_data(byte_io) { } @@ -88,7 +88,7 @@ void MvDataElementByteIO::Input() } void MvDataElementByteIO::Output() -{ +{ //Output size of block data WriteUint(m_block_data.GetSize()); diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/mvdataelement_byteio.h b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/mvdataelement_byteio.h index 6896ac7ea..2e0aa4211 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/mvdataelement_byteio.h +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/mvdataelement_byteio.h @@ -53,80 +53,74 @@ namespace dirac { - -/** -* Represents compressed sequence-parameter data used in an AccessUnit -*/ -class MvDataElementByteIO : public ByteIO -{ -public: - - /** - * Constructor - */ - MvDataElementByteIO(); - - /** - * Constructor - *@param byte_io Input/Output Byte stream - */ - MvDataElementByteIO(ByteIO &byte_io); - - /** - * Destructor - */ - virtual ~MvDataElementByteIO(); - - /** - * Outputs motion vector data Dirac byte-format - */ - void Output(); - - /** - * Inputs motion vector information - */ - void Input(); - - - /** - * Get string containing coded bytes - */ - virtual const std::string GetBytes(); - + /** - * Return pointer to the block data ByteIO stream + * Represents compressed sequence-parameter data used in an AccessUnit */ - ByteIO* DataBlock() + class MvDataElementByteIO : public ByteIO { - return &m_block_data; + public: + + /** + * Constructor + */ + MvDataElementByteIO(); + + /** + * Constructor + *@param byte_io Input/Output Byte stream + */ + MvDataElementByteIO(ByteIO &byte_io); + + /** + * Destructor + */ + virtual ~MvDataElementByteIO(); + + /** + * Outputs motion vector data Dirac byte-format + */ + void Output(); + + /** + * Inputs motion vector information + */ + void Input(); + + + /** + * Get string containing coded bytes + */ + virtual const std::string GetBytes(); + + /** + * Return pointer to the block data ByteIO stream + */ + ByteIO* DataBlock() { return &m_block_data; }; + + /** + * Return the input block data size + */ + unsigned int DataBlockSize() { return m_block_size; } + + /** + * Return the size + */ + int GetSize() const; + + protected: + + /** + * block data + */ + ByteIO m_block_data; + + /** + * In block data size + */ + unsigned int m_block_size; }; - /** - * Return the input block data size - */ - unsigned int DataBlockSize() - { - return m_block_size; - } - - /** - * Return the size - */ - int GetSize() const; - -protected: - - /** - * block data - */ - ByteIO m_block_data; - - /** - * In block data size - */ - unsigned int m_block_size; -}; - } // namespace dirac #endif diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/parseparams_byteio.cpp b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/parseparams_byteio.cpp index cd3691ee0..5034933bc 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/parseparams_byteio.cpp +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/parseparams_byteio.cpp @@ -44,15 +44,15 @@ const unsigned int PP_AU_PICTURE_NUM_SIZE = 4; using namespace dirac; -ParseParamsByteIO::ParseParamsByteIO(const ByteIO& stream_data, - ParseParams &parse_params, - EncoderParams &enc_params): - ByteIO(stream_data), - m_parse_params(parse_params) +ParseParamsByteIO::ParseParamsByteIO( const ByteIO& stream_data, + ParseParams &parse_params, + EncoderParams &enc_params): +ByteIO(stream_data), +m_parse_params(parse_params) { - if(enc_params.NumL1() == 0) + if (enc_params.NumL1() == 0) { - if(!enc_params.UsingAC()) + if (!enc_params.UsingAC()) { // Simple Profile m_parse_params.SetProfile(1); @@ -66,15 +66,15 @@ ParseParamsByteIO::ParseParamsByteIO(const ByteIO& stream_data, else { // Main (Long GOP) profile - m_parse_params.SetProfile(8); + m_parse_params.SetProfile(8); } // FIXME - no support for Low Delay Profile } -ParseParamsByteIO::ParseParamsByteIO(const ByteIO& stream_data, +ParseParamsByteIO::ParseParamsByteIO( const ByteIO& stream_data, ParseParams &parse_params): - ByteIO(stream_data), - m_parse_params(parse_params) +ByteIO(stream_data), +m_parse_params(parse_params) { @@ -89,8 +89,8 @@ void ParseParamsByteIO::CheckVersion() std::ostringstream errstr; ParseParams def_parse_params; - if(m_parse_params.MajorVersion() > def_parse_params.MajorVersion() || - m_parse_params.MajorVersion() == 0 || + if (m_parse_params.MajorVersion() > def_parse_params.MajorVersion() || + m_parse_params.MajorVersion() == 0 || (m_parse_params.MajorVersion() == def_parse_params.MajorVersion() && m_parse_params.MinorVersion() > def_parse_params.MinorVersion())) { @@ -103,7 +103,7 @@ void ParseParamsByteIO::CheckVersion() errstr << ". May not be able to decode bitstream correctly" << std::endl; } - if(errstr.str().size()) + if (errstr.str().size()) { DiracException err( ERR_UNSUPPORTED_STREAM_DATA, @@ -120,21 +120,21 @@ void ParseParamsByteIO::CheckProfile() // No profiles were specified in versions 1.0, 1.1, and 2.0 and 2.1. // So for these versions profile should be 0 in the bitstream - if(m_parse_params.MajorVersion() <= 2 && - m_parse_params.MinorVersion() < 2 && - m_parse_params.Profile() != 0) + if (m_parse_params.MajorVersion() <= 2 && + m_parse_params.MinorVersion() < 2 && + m_parse_params.Profile() != 0) { errstr << "Cannot handle profile " << m_parse_params.Profile() << " for bitstream version " << m_parse_params.MajorVersion() << "." << m_parse_params.MinorVersion(); errstr << ". May not be able to decode bitstream correctly" << std::endl; } - else if(m_parse_params.MajorVersion() == def_parse_params.MajorVersion() && - m_parse_params.MinorVersion() == def_parse_params.MinorVersion() && - m_parse_params.Profile() != 1 /* Simple */ && - m_parse_params.Profile() != 2 /* Main (Intra) */ && - m_parse_params.Profile() != 8 /* Main (Long GOP) */ - ) + else if (m_parse_params.MajorVersion() == def_parse_params.MajorVersion() && + m_parse_params.MinorVersion() == def_parse_params.MinorVersion() && + m_parse_params.Profile() != 1 /* Simple */ && + m_parse_params.Profile() != 2 /* Main (Intra) */ && + m_parse_params.Profile() != 8 /* Main (Long GOP) */ + ) { errstr << "Cannot handle profile " << m_parse_params.Profile() << " for bitstream version " << m_parse_params.MajorVersion() @@ -144,7 +144,7 @@ void ParseParamsByteIO::CheckProfile() errstr << ". May not be able to decode bitstream correctly" << std::endl; } - if(errstr.str().size()) + if (errstr.str().size()) { DiracException err( ERR_UNSUPPORTED_STREAM_DATA, @@ -160,15 +160,15 @@ void ParseParamsByteIO::CheckLevel() ParseParams def_parse_params; // No resources constraints for decoder - if(def_parse_params.Level() == 0) + if (def_parse_params.Level() == 0) return; // Constraints on Decoder. Can Handles level 1 for Simple and Main (Intra) // profiles, and level 128 for Main (Long GOP) Profile. - if(def_parse_params.Level() != 0) + if (def_parse_params.Level() != 0) { - if((m_parse_params.Profile() <= 2 && m_parse_params.Level() != 1) || - (m_parse_params.Profile() == 8 && m_parse_params.Level() != 128)) + if ((m_parse_params.Profile() <= 2 && m_parse_params.Level() != 1) || + (m_parse_params.Profile() ==8 && m_parse_params.Level() != 128)) { errstr << "Cannot handle Level " << m_parse_params.Level() << " for bitstream version " << m_parse_params.MajorVersion() @@ -180,7 +180,7 @@ void ParseParamsByteIO::CheckLevel() } } - if(errstr.str().size()) + if (errstr.str().size()) { DiracException err( ERR_UNSUPPORTED_STREAM_DATA, diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/parseparams_byteio.h b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/parseparams_byteio.h index 04f040c2d..1e5423f31 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/parseparams_byteio.h +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/parseparams_byteio.h @@ -51,65 +51,65 @@ namespace dirac { - -/** -* Represents compressed parse-parameter data used in an AccessUnit -*/ -class ParseParamsByteIO : public ByteIO -{ -public: - - /** - * Constructor - *@param stream_data Destination of data - *@param parse_params Parse parameters - *@param enc_params Encoder parameters - */ - ParseParamsByteIO(const ByteIO& stream_data, - ParseParams &parse_params, - EncoderParams &enc_params); - - /** - * Constructor - *@param stream_data Source of data - *@param parse_params Destination of parse params - */ - ParseParamsByteIO(const ByteIO& stream_data, - ParseParams &parse_params); - - /** - * Destructor - */ - ~ParseParamsByteIO(); - - /** - * Reads parse information from Dirac byte-format - */ - void Input(); - - /** - * Outputs parse information to Dirac byte-format - */ - void Output(); - - /** - * Get access-unit number - */ - int GetIdNumber() const; - -protected: - -private: - void CheckVersion(); - void CheckProfile(); - void CheckLevel(); - -private: + /** - * Reference to parse parameters + * Represents compressed parse-parameter data used in an AccessUnit */ - ParseParams& m_parse_params; -}; + class ParseParamsByteIO : public ByteIO + { + public: + + /** + * Constructor + *@param stream_data Destination of data + *@param parse_params Parse parameters + *@param enc_params Encoder parameters + */ + ParseParamsByteIO(const ByteIO& stream_data, + ParseParams &parse_params, + EncoderParams &enc_params); + + /** + * Constructor + *@param stream_data Source of data + *@param parse_params Destination of parse params + */ + ParseParamsByteIO(const ByteIO& stream_data, + ParseParams &parse_params); + + /** + * Destructor + */ + ~ParseParamsByteIO(); + + /** + * Reads parse information from Dirac byte-format + */ + void Input(); + + /** + * Outputs parse information to Dirac byte-format + */ + void Output(); + + /** + * Get access-unit number + */ + int GetIdNumber() const; + + protected: + + private: + void CheckVersion(); + void CheckProfile(); + void CheckLevel(); + + private: + /** + * Reference to parse parameters + */ + ParseParams& m_parse_params; + }; } // namespace dirac diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/parseunit_byteio.cpp b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/parseunit_byteio.cpp index 9d4ac83de..56c0ebb8b 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/parseunit_byteio.cpp +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/parseunit_byteio.cpp @@ -52,30 +52,30 @@ const int PU_NEXT_PARSE_OFFSET_SIZE = 4; const int PU_PREVIOUS_PARSE_OFFSET_SIZE = 4; const int PU_PREFIX_SIZE = 4; const int PU_PARSE_CODE_SIZE = 1; -const int PU_PARSEUNIT_SIZE = PU_NEXT_PARSE_OFFSET_SIZE + PU_PREVIOUS_PARSE_OFFSET_SIZE + +const int PU_PARSEUNIT_SIZE = PU_NEXT_PARSE_OFFSET_SIZE + PU_PREVIOUS_PARSE_OFFSET_SIZE+ PU_PREFIX_SIZE + PU_PARSE_CODE_SIZE; ParseUnitByteIO::ParseUnitByteIO(): - ByteIO(), - m_previous_parse_offset(0), - m_next_parse_offset(0) +ByteIO(), +m_previous_parse_offset(0), +m_next_parse_offset(0) { } ParseUnitByteIO::ParseUnitByteIO(const ByteIO& byte_io): - ByteIO(byte_io), - m_previous_parse_offset(0), - m_next_parse_offset(0) +ByteIO(byte_io), +m_previous_parse_offset(0), +m_next_parse_offset(0) { } ParseUnitByteIO::ParseUnitByteIO(const ParseUnitByteIO& parseunit_byteio): - ByteIO(parseunit_byteio), - m_previous_parse_offset(parseunit_byteio.m_previous_parse_offset), - m_next_parse_offset(parseunit_byteio.m_next_parse_offset), - m_parse_code(parseunit_byteio.m_parse_code) +ByteIO(parseunit_byteio), +m_previous_parse_offset(parseunit_byteio.m_previous_parse_offset), +m_next_parse_offset(parseunit_byteio.m_next_parse_offset), +m_parse_code(parseunit_byteio.m_parse_code) { } @@ -113,16 +113,16 @@ bool ParseUnitByteIO::Input() bool ParseUnitByteIO::IsValid() { - if(IsEndOfSequence()) + if (IsEndOfSequence()) return true; // Skip past the end of current parse unit - SeekGet(m_next_parse_offset - GetSize(), ios_base::cur); + SeekGet(m_next_parse_offset-GetSize(), ios_base::cur); // check the next series of bytes are the parse-info prefix string prefix = InputUnString(PU_PREFIX_SIZE); - if(prefix == PU_PREFIX) + if(prefix==PU_PREFIX) { unsigned char next_parse_code; @@ -133,28 +133,28 @@ bool ParseUnitByteIO::IsValid() int next_unit_previous_parse_offset; next_unit_previous_parse_offset = ReadUintLit(PU_PREVIOUS_PARSE_OFFSET_SIZE); - if(next_unit_previous_parse_offset == m_next_parse_offset) + if (next_unit_previous_parse_offset == m_next_parse_offset) { - SeekGet(-(m_next_parse_offset - GetSize() + PU_PARSEUNIT_SIZE), ios_base::cur); + SeekGet(-(m_next_parse_offset-GetSize()+PU_PARSEUNIT_SIZE), ios_base::cur); return true; } } - SeekGet(-(m_next_parse_offset - GetSize()), ios_base::cur); + SeekGet(-(m_next_parse_offset-GetSize()), ios_base::cur); return false; } bool ParseUnitByteIO::CanSkip() { - if(m_next_parse_offset == 0 || m_next_parse_offset == GetSize()) + if(m_next_parse_offset==0 || m_next_parse_offset == GetSize()) return true; // Skip past the end of current parse unit and past the header of the // next unit - SeekGet(m_next_parse_offset - GetSize() + GetSize(), ios_base::cur); + SeekGet(m_next_parse_offset-GetSize() + GetSize(), ios_base::cur); if(GetReadBytePosition() >= 0) { - SeekGet(-(m_next_parse_offset - GetSize() + GetSize()), ios_base::cur); - return true; // success + SeekGet(-(m_next_parse_offset-GetSize() + GetSize()), ios_base::cur); + return true; // success } // end of stream reached @@ -171,15 +171,15 @@ const string ParseUnitByteIO::GetBytes() //FIXME : Need to do this properly. // Write the parse offsets in Big Endian format - for(int i = PU_NEXT_PARSE_OFFSET_SIZE - 1; i >= 0; --i) + for(int i=PU_NEXT_PARSE_OFFSET_SIZE-1; i >= 0; --i) { - unsigned char cp = (m_next_parse_offset >> (i * 8)) & 0xff; + unsigned char cp = (m_next_parse_offset>>(i*8)) & 0xff; parse_string << cp; } - for(int i = PU_PREVIOUS_PARSE_OFFSET_SIZE - 1; i >= 0; --i) + for(int i=PU_PREVIOUS_PARSE_OFFSET_SIZE-1; i >= 0; --i) { - unsigned char cp = (m_previous_parse_offset >> (i * 8)) & 0xff; + unsigned char cp = (m_previous_parse_offset>>(i*8)) & 0xff; parse_string << cp; } @@ -251,32 +251,32 @@ int ParseUnitByteIO::CalcNextUnitOffset() bool ParseUnitByteIO::SyncToUnitStart() { - // locate parse-unit prefix + // locate parse-unit prefix string byte_buffer; - while(CanRead() == true && mp_stream->tellg() >= 0) + while(CanRead()==true && mp_stream->tellg() >= 0) { // ensure current buffer length if((int)byte_buffer.size() == PU_PREFIX_SIZE) { - byte_buffer.assign(byte_buffer.substr(1, PU_PREFIX_SIZE - 1)); + byte_buffer.assign(byte_buffer.substr(1,PU_PREFIX_SIZE-1)); } // read next byte byte_buffer.push_back(InputUnByte()); //look to see if we have prefix - if(byte_buffer == PU_PREFIX) + if(byte_buffer==PU_PREFIX) { // check we can read a parse-unit //int prev_pos = mp_stream->tellg(); - mp_stream->seekg(PU_PARSEUNIT_SIZE - PU_PREFIX_SIZE, ios_base::cur); + mp_stream->seekg (PU_PARSEUNIT_SIZE-PU_PREFIX_SIZE, ios_base::cur); int cur_pos = mp_stream->tellg(); - if(cur_pos < 0) // past end of stream + if (cur_pos < 0) // past end of stream { mp_stream->clear(); return false; } - mp_stream->seekg(-(PU_PARSEUNIT_SIZE - PU_PREFIX_SIZE), ios_base::cur); + mp_stream->seekg(-(PU_PARSEUNIT_SIZE-PU_PREFIX_SIZE), ios_base::cur); return true; } diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/parseunit_byteio.h b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/parseunit_byteio.h index ab015d1fe..8d7742afa 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/parseunit_byteio.h +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/parseunit_byteio.h @@ -53,216 +53,193 @@ namespace dirac { -/* Types of parse-unit */ -typedef enum -{ - PU_SEQ_HEADER = 0, - PU_PICTURE, - PU_END_OF_SEQUENCE, - PU_AUXILIARY_DATA, - PU_PADDING_DATA, - PU_CORE_PICTURE, - PU_LOW_DELAY_PICTURE, - PU_UNDEFINED -} ParseUnitType; - -/** -* Represents a collection of data in a Dirac bytestream that can be parsed as a -* self-contained unit -*/ -class ParseUnitByteIO : public ByteIO -{ -public: - - /** - * Constructor - */ - ParseUnitByteIO(); - - /** - * Constructor - *@param byte_io Stream parameters - */ - ParseUnitByteIO(const ByteIO& byte_io); - - /** - * Constructor - *@param parseunit_byteio Parse-unit parameters - */ - ParseUnitByteIO(const ParseUnitByteIO& parseunit_byteio); - - /** - * Destructor - */ - ~ParseUnitByteIO(); - - /** - * Gathers byte stats on the parse-unit data - *@param dirac_byte_stats Stat container - */ - virtual void CollateByteStats(DiracByteStats& dirac_byte_stats); - - /** - * Reads from byte-stream to find parse data - *@return <B>false</B> if not enough data in stream - */ - bool Input(); // decoding - - /** - * Accesses validity of a unit by comparing it with an adjacent unit - */ - bool IsValid(); - - /** - * Can Skip past the entire parse-unit - *@return <B>false</B> Nothing to skip to - */ - bool CanSkip(); - - /** - * Gets string containing coded bytes - */ - virtual const std::string GetBytes(); // encoding - - /** - * Set next/previous parse-unit values - *@param p_prev_parseunit Previous parse-unit - */ - void SetAdjacentParseUnits(ParseUnitByteIO *p_prev_parseunit); // encoding - - /* - * Gets number of bytes input/output within unit - */ - virtual int GetSize() const; - - /** - * Gets expected number of bytes to start of next parse-unit - */ - int GetNextParseOffset() const; - - /** - * Gets number of bytes to start of previous parse-unit - */ - int GetPreviousParseOffset() const; - - /** - * Gets parse-unit type - */ - virtual ParseUnitType GetType() const; - - /** - * Returns true is parse unit is a Sequence Header - */ - bool IsSeqHeader() const - { - return m_parse_code == 0x00; - } - - /** - * Returns true is parse unit is an End of Sequence unit - */ - bool IsEndOfSequence() const - { - return m_parse_code == 0x10; - } - - /** - * Returns true is parse unit is Auxiliary Data - */ - bool IsAuxiliaryData() const - { - return (m_parse_code & 0xF8) == 0x20; - } - - /** - * Returns true is parse unit is Padding data - */ - bool IsPaddingData() const - { - return m_parse_code == 0x30; - } - - /** - * Returns true is parse unit is Picture data - */ - bool IsPicture() const - { - return ((m_parse_code & 0x08) == 0x08); - } - - /** - * Returns true is parse unit is Low Delay Sybtax unit - */ - bool IsLowDelay() const - { - return ((m_parse_code & 0x88) == 0x88); - } - - /** - * Returns true is parse unit is Core syntax unit - */ - bool IsCoreSyntax() const - { - return ((m_parse_code & 0x88) == 0x08); - } - - /** - * Returns true is parse unit uses Arithmetic coding - */ - bool IsUsingAC() const + /* Types of parse-unit */ + typedef enum { + PU_SEQ_HEADER=0, + PU_PICTURE, + PU_END_OF_SEQUENCE, + PU_AUXILIARY_DATA, + PU_PADDING_DATA, + PU_CORE_PICTURE, + PU_LOW_DELAY_PICTURE, + PU_UNDEFINED + } ParseUnitType; + + /** + * Represents a collection of data in a Dirac bytestream that can be parsed as a + * self-contained unit + */ + class ParseUnitByteIO : public ByteIO { - return ((m_parse_code & 0x48) == 0x08); - } - -protected: - - /** - * Calculates number of bytes to start of next unit - *@return Number of bytes to next unit - */ - virtual int CalcNextUnitOffset(); - - /** - * Pure virtual method for calculating parse-code - *@return Char containing bit-set for parse-unit parameters - */ - virtual unsigned char CalcParseCode() const - { - return 0; // encoding - } - - /** - * Locates start of parse-unit - *@return <B>false</B> if not enough data - */ - bool SyncToUnitStart(); // decoding - - /** - * Get parse code - */ - unsigned char GetParseCode() const - { - return m_parse_code; - } - -private: - - /** - * Number of bytes to next parse-unit - */ - int m_previous_parse_offset; - - /** - * Number of bytes to previous parse-unit - */ - int m_next_parse_offset; - - /** - * Parse-type-identifier - */ - unsigned char m_parse_code; - -}; + public: + + /** + * Constructor + */ + ParseUnitByteIO(); + + /** + * Constructor + *@param byte_io Stream parameters + */ + ParseUnitByteIO(const ByteIO& byte_io); + + /** + * Constructor + *@param parseunit_byteio Parse-unit parameters + */ + ParseUnitByteIO(const ParseUnitByteIO& parseunit_byteio); + + /** + * Destructor + */ + ~ParseUnitByteIO(); + + /** + * Gathers byte stats on the parse-unit data + *@param dirac_byte_stats Stat container + */ + virtual void CollateByteStats(DiracByteStats& dirac_byte_stats); + + /** + * Reads from byte-stream to find parse data + *@return <B>false</B> if not enough data in stream + */ + bool Input(); // decoding + + /** + * Accesses validity of a unit by comparing it with an adjacent unit + */ + bool IsValid(); + + /** + * Can Skip past the entire parse-unit + *@return <B>false</B> Nothing to skip to + */ + bool CanSkip(); + + /** + * Gets string containing coded bytes + */ + virtual const std::string GetBytes(); // encoding + + /** + * Set next/previous parse-unit values + *@param p_prev_parseunit Previous parse-unit + */ + void SetAdjacentParseUnits(ParseUnitByteIO *p_prev_parseunit); // encoding + + /* + * Gets number of bytes input/output within unit + */ + virtual int GetSize() const; + + /** + * Gets expected number of bytes to start of next parse-unit + */ + int GetNextParseOffset() const; + + /** + * Gets number of bytes to start of previous parse-unit + */ + int GetPreviousParseOffset() const; + + /** + * Gets parse-unit type + */ + virtual ParseUnitType GetType() const; + + /** + * Returns true is parse unit is a Sequence Header + */ + bool IsSeqHeader() const + { return m_parse_code==0x00; } + + /** + * Returns true is parse unit is an End of Sequence unit + */ + bool IsEndOfSequence() const + { return m_parse_code==0x10; } + + /** + * Returns true is parse unit is Auxiliary Data + */ + bool IsAuxiliaryData() const + { return (m_parse_code&0xF8)==0x20; } + + /** + * Returns true is parse unit is Padding data + */ + bool IsPaddingData() const + { return m_parse_code==0x30; } + + /** + * Returns true is parse unit is Picture data + */ + bool IsPicture() const + { return ((m_parse_code&0x08)==0x08); } + + /** + * Returns true is parse unit is Low Delay Sybtax unit + */ + bool IsLowDelay() const + { return ((m_parse_code&0x88)==0x88); } + + /** + * Returns true is parse unit is Core syntax unit + */ + bool IsCoreSyntax() const + { return ((m_parse_code&0x88)==0x08); } + + /** + * Returns true is parse unit uses Arithmetic coding + */ + bool IsUsingAC() const + { return ((m_parse_code&0x48)==0x08); } + + protected: + + /** + * Calculates number of bytes to start of next unit + *@return Number of bytes to next unit + */ + virtual int CalcNextUnitOffset(); + + /** + * Pure virtual method for calculating parse-code + *@return Char containing bit-set for parse-unit parameters + */ + virtual unsigned char CalcParseCode() const { return 0;} // encoding + + /** + * Locates start of parse-unit + *@return <B>false</B> if not enough data + */ + bool SyncToUnitStart(); // decoding + + /** + * Get parse code + */ + unsigned char GetParseCode() const { return m_parse_code;} + + private: + + /** + * Number of bytes to next parse-unit + */ + int m_previous_parse_offset; + + /** + * Number of bytes to previous parse-unit + */ + int m_next_parse_offset; + + /** + * Parse-type-identifier + */ + unsigned char m_parse_code; + + }; } // namespace dirac diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/picture_byteio.cpp b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/picture_byteio.cpp index 06b52aa62..23231bea7 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/picture_byteio.cpp +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/picture_byteio.cpp @@ -54,37 +54,37 @@ const int CODE_VLC_ENTROPY_CODING_BIT = 6; const unsigned int MAX_NUM_REFS = 2;
PictureByteIO::PictureByteIO(PictureParams& frame_params,
- int frame_num) :
- ParseUnitByteIO(),
- m_frame_params(frame_params),
- m_frame_num(frame_num),
- m_mv_data(0),
- m_transform_data(0)
+ int frame_num) :
+ParseUnitByteIO(),
+m_frame_params(frame_params),
+m_frame_num(frame_num),
+m_mv_data(0),
+m_transform_data(0)
{
-
+
}
PictureByteIO::PictureByteIO(PictureParams& frame_params,
- const ParseUnitByteIO& parseunit_byteio):
- ParseUnitByteIO(parseunit_byteio),
- m_frame_params(frame_params),
- m_frame_num(0),
- m_mv_data(0),
- m_transform_data(0)
+ const ParseUnitByteIO& parseunit_byteio ):
+ParseUnitByteIO(parseunit_byteio),
+m_frame_params(frame_params),
+m_frame_num(0),
+m_mv_data(0),
+m_transform_data(0)
{
-
+
}
PictureByteIO::~PictureByteIO()
{
//delete block data
- if(m_mv_data)
+ if (m_mv_data)
{
delete m_mv_data;
m_mv_data = 0;
}
- if(m_transform_data)
+ if (m_transform_data)
{
delete m_transform_data;
m_transform_data = 0;
@@ -110,13 +110,13 @@ bool PictureByteIO::Input() // Use of VLC for entropy coding is supported for
// intra frames only
- if(m_frame_params.GetPictureType() == INTER_PICTURE &&
- m_frame_params.UsingAC() == false)
+ if (m_frame_params.GetPictureType() == INTER_PICTURE &&
+ m_frame_params.UsingAC() == false)
{
DIRAC_THROW_EXCEPTION(
- ERR_UNSUPPORTED_STREAM_DATA,
- "VLC codes for entropy coding of coefficient data supported for Intra frames only",
- SEVERITY_PICTURE_ERROR);
+ ERR_UNSUPPORTED_STREAM_DATA,
+ "VLC codes for entropy coding of coefficient data supported for Intra frames only",
+ SEVERITY_PICTURE_ERROR);
}
// input picture number
@@ -125,10 +125,10 @@ bool PictureByteIO::Input() // input reference Picture numbers
InputReferencePictures();
-
+
// input retired Picture numbers list
m_frame_params.SetRetiredPictureNum(-1);
- if(IsRef())
+ if (IsRef())
InputRetiredPicture();
// byte align
@@ -137,7 +137,7 @@ bool PictureByteIO::Input() return true;
}
-const string PictureByteIO::GetBytes()
+const string PictureByteIO::GetBytes()
{
// Write mv data
if(m_frame_params.PicSort().IsInter() && m_mv_data)
@@ -146,7 +146,7 @@ const string PictureByteIO::GetBytes() }
// Write transform header
- if(m_transform_data)
+ if (m_transform_data)
{
OutputBytes(m_transform_data->GetBytes());
}
@@ -156,15 +156,15 @@ const string PictureByteIO::GetBytes() int PictureByteIO::GetSize() const
{
int size = 0;
- if(m_mv_data)
+ if (m_mv_data)
size += m_mv_data->GetSize();
- if(m_transform_data)
+ if (m_transform_data)
size += m_transform_data->GetSize();
//std::cerr << "Picture Header Size=" << ByteIO::GetSize();
//std::cerr << "Data Size=" << size << std::endl;
- return size + ParseUnitByteIO::GetSize() + ByteIO::GetSize();
+ return size+ParseUnitByteIO::GetSize()+ByteIO::GetSize();
}
void PictureByteIO::Output()
@@ -172,23 +172,23 @@ void PictureByteIO::Output() // output picture number
WriteUintLit(m_frame_num, PP_PICTURE_NUM_SIZE);
- if(m_frame_params.GetPictureType() == INTER_PICTURE)
+ if(m_frame_params.GetPictureType()==INTER_PICTURE)
{
// output reference picture numbers
const std::vector<int>& refs = m_frame_params.Refs();
- for(size_t i = 0; i < refs.size() && i < MAX_NUM_REFS; ++i)
+ for(size_t i=0; i < refs.size() && i < MAX_NUM_REFS; ++i)
WriteSint(refs[i] - m_frame_num);
}
// output retired picture
- ASSERTM(m_frame_params.GetReferenceType() == REFERENCE_PICTURE || m_frame_params.RetiredPictureNum() == -1, "Only Reference frames can retire frames");
+ ASSERTM (m_frame_params.GetReferenceType() == REFERENCE_PICTURE || m_frame_params.RetiredPictureNum() == -1, "Only Reference frames can retire frames");
if(m_frame_params.GetReferenceType() == REFERENCE_PICTURE)
{
- if(m_frame_params.RetiredPictureNum() == -1)
+ if (m_frame_params.RetiredPictureNum() == -1)
WriteSint(0);
else
{
- WriteSint(m_frame_params.RetiredPictureNum() - m_frame_num);
+ WriteSint (m_frame_params.RetiredPictureNum() - m_frame_num);
}
}
// byte align output
@@ -198,14 +198,14 @@ void PictureByteIO::Output() //-------------private-------------------------------------------------------
-
+
unsigned char PictureByteIO::CalcParseCode() const
{
unsigned char code = 0;
int num_refs = m_frame_params.Refs().size();
- if(m_frame_params.GetPictureType() == INTER_PICTURE)
+ if(m_frame_params.GetPictureType()==INTER_PICTURE)
{
// set number of refs
if(num_refs == 1)
@@ -214,42 +214,42 @@ unsigned char PictureByteIO::CalcParseCode() const SetBit(code, CODE_TWO_REF_BIT);
}
// set ref type
- if(m_frame_params.GetReferenceType() == REFERENCE_PICTURE)
+ if(m_frame_params.GetReferenceType()==REFERENCE_PICTURE)
SetBit(code, CODE_REF_PICTURE_BIT);
// Set parse unit type
SetBit(code, CODE_PUTYPE_1_BIT);
// Set Entropy Coding type
- if(!m_frame_params.UsingAC())
+ if (!m_frame_params.UsingAC())
{
SetBit(code, CODE_VLC_ENTROPY_CODING_BIT);
}
return code;
-
+
}
-void PictureByteIO::InputReferencePictures()
+void PictureByteIO::InputReferencePictures()
{
// get number of frames referred to
- int ref_count = NumRefs();
+ int ref_count = NumRefs();
- // get the number of these frames
+ // get the number of these frames
vector<int>& refs = m_frame_params.Refs();
refs.resize(ref_count);
- for(int i = 0; i < ref_count; ++i)
- refs[i] = m_frame_num + ReadSint();
+ for(int i=0; i < ref_count; ++i)
+ refs[i]=m_frame_num+ReadSint();
}
-
-void PictureByteIO::InputRetiredPicture()
+
+void PictureByteIO::InputRetiredPicture()
{
TESTM(IsRef(), "Retired Picture offset only set for Reference Frames");
// input retired picture offset
int offset = ReadSint();
// input retired frames
- if(offset)
+ if (offset)
{
m_frame_params.SetRetiredPictureNum(m_frame_num + offset);
}
diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/picture_byteio.h b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/picture_byteio.h index 1fcd0cb9c..bdca76f40 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/picture_byteio.h +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/picture_byteio.h @@ -54,178 +54,154 @@ namespace dirac
{
-/**
-* A compressed picture in Dirac bytestream format
-*/
-class PictureByteIO : public ParseUnitByteIO
-{
-public:
-
- /**
- * Constructor
- *@param frame_params Picture parameters
- *@param frame_num Picture number
- */
- PictureByteIO(PictureParams& frame_params,
- int frame_num);
-
-
- /**
- * Constructor
- *@param frame_params Destination of data
- *@param parseunit_byteio Source of data
- */
- PictureByteIO(PictureParams& frame_params,
- const ParseUnitByteIO& parseunit_byteio);
-
- /**
- * Destructor
- */
- virtual ~PictureByteIO();
-
- /**
- * Gathers byte stats on the picture data
- *@param dirac_byte_stats Stat container
- */
- void CollateByteStats(DiracByteStats& dirac_byte_stats);
-
- /**
- * Inputs data from Dirac stream-format
- */
- bool Input();
-
- /**
- * Outputs picture values to Dirac stream-format
- */
- void Output();
-
-
-
- const std::string GetBytes();
-
- int GetSize() const;
-
- /**
- * Gets parse-unit type
- */
- ParseUnitType GetType() const
- {
- return PU_PICTURE;
- }
-
- /**
- * Returns true is picture in Reference picture
- */
- int IsRef() const
- {
- return (GetParseCode() & 0x0C) == 0x0C;
- }
-
- /**
- * Returns true is picture in Non-Reference picture
- */
- int IsNonRef() const
- {
- return (GetParseCode() & 0x0C) == 0x08;
- }
-
- /**
- * Gets parse-unit type
- */
- int NumRefs() const
- {
- return (GetParseCode() & 0x03);
- }
-
- /**
- * Returns true is picture is Intra picture
- */
- bool IsIntra() const
- {
- return IsPicture() && (NumRefs() == 0) ;
- }
-
/**
- * Returns true is picture is Inter picture
- */
- bool IsInter() const
- {
- return IsPicture() && (NumRefs() > 0) ;
- }
-
- /***
- * Sets the MVDataIO
+ * A compressed picture in Dirac bytestream format
*/
- void SetMvData(MvDataByteIO *mv_data)
+ class PictureByteIO : public ParseUnitByteIO
{
- m_mv_data = mv_data;
- }
-
- /***
- * Sets the TransformByteIo
- */
- void SetTransformData(TransformByteIO *transform_data)
- {
- m_transform_data = transform_data;
- }
-
-protected:
-
-
-private:
-
- /**
- * Calculates parse-code based on picture parameters
- *@return Char bit-set
- */
- unsigned char CalcParseCode() const;
-
- /**
- * Reads reference-picture data
- */
- void InputReferencePictures();
-
- /**
- * Reads retired picture number
- */
- void InputRetiredPicture();
-
- /**
- * Calculates picture-type (eg INTRA/INTER) of picture
- */
- void SetPictureType();
-
- /**
- * Calculates reference-type of picture
- */
- void SetReferenceType();
-
- /**
- * Sets the entropy coding flag in the picture parameters
- */
- void SetEntropyCodingFlag();
-
- /**
- * Picture parameters
- */
- PictureParams& m_frame_params;
-
- /**
- * Picture number
- */
- int m_frame_num;
-
- /**
- * MV data
- */
- MvDataByteIO * m_mv_data;
-
- /**
- * Transform data
- */
- TransformByteIO * m_transform_data;
-
-};
+ public:
+
+ /**
+ * Constructor
+ *@param frame_params Picture parameters
+ *@param frame_num Picture number
+ */
+ PictureByteIO(PictureParams& frame_params,
+ int frame_num);
+
+
+ /**
+ * Constructor
+ *@param frame_params Destination of data
+ *@param parseunit_byteio Source of data
+ */
+ PictureByteIO(PictureParams& frame_params,
+ const ParseUnitByteIO& parseunit_byteio);
+
+ /**
+ * Destructor
+ */
+ virtual ~PictureByteIO();
+
+ /**
+ * Gathers byte stats on the picture data
+ *@param dirac_byte_stats Stat container
+ */
+ void CollateByteStats(DiracByteStats& dirac_byte_stats);
+
+ /**
+ * Inputs data from Dirac stream-format
+ */
+ bool Input();
+
+ /**
+ * Outputs picture values to Dirac stream-format
+ */
+ void Output();
+
+
+
+ const std::string GetBytes();
+
+ int GetSize() const;
+
+ /**
+ * Gets parse-unit type
+ */
+ ParseUnitType GetType() const { return PU_PICTURE;}
+
+ /**
+ * Returns true is picture in Reference picture
+ */
+ int IsRef() const { return (GetParseCode()&0x0C)==0x0C;}
+
+ /**
+ * Returns true is picture in Non-Reference picture
+ */
+ int IsNonRef() const { return (GetParseCode()&0x0C)==0x08;}
+
+ /**
+ * Gets parse-unit type
+ */
+ int NumRefs() const { return (GetParseCode()&0x03);}
+
+ /**
+ * Returns true is picture is Intra picture
+ */
+ bool IsIntra() const { return IsPicture() && (NumRefs()==0) ; }
+
+ /**
+ * Returns true is picture is Inter picture
+ */
+ bool IsInter() const { return IsPicture() && (NumRefs()>0) ; }
+
+ /***
+ * Sets the MVDataIO
+ */
+ void SetMvData(MvDataByteIO *mv_data) {m_mv_data = mv_data; }
+
+ /***
+ * Sets the TransformByteIo
+ */
+ void SetTransformData(TransformByteIO *transform_data) {m_transform_data = transform_data; }
+
+ protected:
+
+
+ private:
+
+ /**
+ * Calculates parse-code based on picture parameters
+ *@return Char bit-set
+ */
+ unsigned char CalcParseCode() const;
+
+ /**
+ * Reads reference-picture data
+ */
+ void InputReferencePictures();
+
+ /**
+ * Reads retired picture number
+ */
+ void InputRetiredPicture();
+
+ /**
+ * Calculates picture-type (eg INTRA/INTER) of picture
+ */
+ void SetPictureType();
+
+ /**
+ * Calculates reference-type of picture
+ */
+ void SetReferenceType();
+
+ /**
+ * Sets the entropy coding flag in the picture parameters
+ */
+ void SetEntropyCodingFlag();
+
+ /**
+ * Picture parameters
+ */
+ PictureParams& m_frame_params;
+
+ /**
+ * Picture number
+ */
+ int m_frame_num;
+
+ /**
+ * MV data
+ */
+ MvDataByteIO * m_mv_data;
+
+ /**
+ * Transform data
+ */
+ TransformByteIO * m_transform_data;
+
+ };
} // namespace dirac
diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/subband_byteio.cpp b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/subband_byteio.cpp index 41b6fcb66..63d0607b9 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/subband_byteio.cpp +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/subband_byteio.cpp @@ -42,19 +42,19 @@ using namespace std; SubbandByteIO::SubbandByteIO(Subband& sub_band, const ByteIO& byteio): - ByteIO(byteio), - m_subband(sub_band), - m_band_data_length(0) +ByteIO(byteio), +m_subband(sub_band), +m_band_data_length(0) { - + } SubbandByteIO::SubbandByteIO(Subband& sub_band): - ByteIO(), - m_subband(sub_band), - m_band_data_length(0) +ByteIO(), +m_subband(sub_band), +m_band_data_length(0) { - + } SubbandByteIO::~SubbandByteIO() @@ -70,7 +70,7 @@ bool SubbandByteIO::Input() m_band_data_length = ReadUint(); // set skip flag if no data - m_subband.SetSkip(m_band_data_length == 0 ? true : false); + m_subband.SetSkip(m_band_data_length==0 ? true : false); // check for zero-length sub-band if(m_subband.Skipped()) @@ -79,16 +79,16 @@ bool SubbandByteIO::Input() return true; } - // If we're not skipped, we need a quantisation index for the subband - m_subband.SetQuantIndex(ReadUint()); + // If we're not skipped, we need a quantisation index for the subband + m_subband.SetQuantIndex(ReadUint() ); - if(!m_subband.UsingMultiQuants()) + if ( !m_subband.UsingMultiQuants() ) { - // Propogate the quantiser index to all the code blocks if we + // Propogate the quantiser index to all the code blocks if we // don't have multiquants - for(int j = 0 ; j < m_subband.GetCodeBlocks().LengthY() ; ++j) - for(int i = 0 ; i < m_subband.GetCodeBlocks().LengthX() ; ++i) - m_subband.GetCodeBlocks()[j][i].SetQuantIndex(m_subband.QuantIndex()); + for ( int j=0 ; j<m_subband.GetCodeBlocks().LengthY() ; ++j ) + for ( int i=0 ; i<m_subband.GetCodeBlocks().LengthX() ; ++i ) + m_subband.GetCodeBlocks()[j][i].SetQuantIndex( m_subband.QuantIndex() ); } // byte align @@ -98,12 +98,12 @@ bool SubbandByteIO::Input() return true; } -int SubbandByteIO::GetBandDataLength() const +int SubbandByteIO::GetBandDataLength() const { return m_band_data_length; } -const string SubbandByteIO::GetBytes() +const string SubbandByteIO::GetBytes() { ByteIO byte_io; @@ -113,7 +113,7 @@ const string SubbandByteIO::GetBytes() byte_io.WriteUint(GetSize()); // check for zero-length sub-band - if(GetSize() == 0) + if(GetSize()==0) { byte_io.ByteAlignOutput(); return byte_io.GetBytes(); @@ -128,10 +128,10 @@ const string SubbandByteIO::GetBytes() //std::cerr << "Subband hdr size=" << byte_io.GetSize(); //std::cerr << " Arithdata size=" << this->GetSize()<< std::endl; - return byte_io.GetBytes() + ByteIO::GetBytes(); + return byte_io.GetBytes()+ByteIO::GetBytes(); } //-------------private------------------------------------------------------- - + diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/subband_byteio.h b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/subband_byteio.h index ad8460c6b..88d03cf87 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/subband_byteio.h +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/subband_byteio.h @@ -50,65 +50,65 @@ namespace dirac { -/** -* Subband Dirac-bytestream input/output -*/ -class SubbandByteIO : public ByteIO -{ -public: - - /** - * Constructor - *@param sub_band Corresponding Subband - *@param byteio Source/Destination of data - */ - SubbandByteIO(Subband& sub_band, - const ByteIO& byteio); - - - /* Constructor - *@param sub_band Corresponding Subband - *@param byteio Source/Destination of data - */ - SubbandByteIO(Subband& sub_band); - - /** - * Destructor - */ - ~SubbandByteIO(); - - /** - * Inputs data from Dirac stream-format - */ - bool Input(); - - - /** - * Gets number of bytes in Arith-coded data block - */ - int GetBandDataLength() const; - - /** - * Gets subband bytes in Dirac-bytestream format - */ - const std::string GetBytes(); - - -protected: - - -private: - - /** - * Sub-band that is inputed/outputed - */ - Subband& m_subband; - /** - * Number of bytes in arith-coded data block + * Subband Dirac-bytestream input/output */ - int m_band_data_length; -}; + class SubbandByteIO : public ByteIO + { + public: + + /** + * Constructor + *@param sub_band Corresponding Subband + *@param byteio Source/Destination of data + */ + SubbandByteIO(Subband& sub_band, + const ByteIO& byteio); + + + /* Constructor + *@param sub_band Corresponding Subband + *@param byteio Source/Destination of data + */ + SubbandByteIO(Subband& sub_band); + + /** + * Destructor + */ + ~SubbandByteIO(); + + /** + * Inputs data from Dirac stream-format + */ + bool Input(); + + + /** + * Gets number of bytes in Arith-coded data block + */ + int GetBandDataLength() const; + + /** + * Gets subband bytes in Dirac-bytestream format + */ + const std::string GetBytes(); + + + protected: + + + private: + + /** + * Sub-band that is inputed/outputed + */ + Subband& m_subband; + + /** + * Number of bytes in arith-coded data block + */ + int m_band_data_length; + }; } // namespace dirac diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/transform_byteio.cpp b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/transform_byteio.cpp index 918b781fe..6eba5a31d 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/transform_byteio.cpp +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/transform_byteio.cpp @@ -43,57 +43,57 @@ using namespace dirac; TransformByteIO::TransformByteIO(PictureParams& fparams, CodecParams& cparams): - ByteIO(), - m_fparams(fparams), - m_cparams(cparams), - m_default_cparams(cparams.GetVideoFormat(), fparams.GetPictureType(), fparams.Refs().size(), true) +ByteIO(), +m_fparams(fparams), +m_cparams(cparams), +m_default_cparams(cparams.GetVideoFormat(), fparams.GetPictureType(), fparams.Refs().size(), true) { } TransformByteIO::TransformByteIO(ByteIO &byte_io, PictureParams& fparams, CodecParams& cparams): - ByteIO(byte_io), - m_fparams(fparams), - m_cparams(cparams), - m_default_cparams(cparams.GetVideoFormat(), fparams.GetPictureType(), fparams.Refs().size(), true) +ByteIO(byte_io), +m_fparams(fparams), +m_cparams(cparams), +m_default_cparams(cparams.GetVideoFormat(), fparams.GetPictureType(), fparams.Refs().size(), true) { } TransformByteIO::~TransformByteIO() { - for(size_t index = 0; index < m_component_list.size(); ++index) - delete m_component_list[index]; + for(size_t index=0; index < m_component_list.size(); ++index) + delete m_component_list[index]; } void TransformByteIO::CollateByteStats(DiracByteStats& dirac_byte_stats) { // set number of component bytes - for(size_t index = 0; index < m_component_list.size(); ++index) + for(size_t index=0; index < m_component_list.size(); ++index) m_component_list[index]->CollateByteStats(dirac_byte_stats); } int TransformByteIO::GetSize() const { //std::cerr << "Transform Size=" << ByteIO::GetSize() << std::endl; - int size = 0; - for(size_t index = 0; index < m_component_list.size(); ++index) + int size=0; + for(size_t index=0; index < m_component_list.size(); ++index) size += m_component_list[index]->GetSize(); - return ByteIO::GetSize() + size; + return ByteIO::GetSize()+size; } const std::string TransformByteIO::GetBytes() { std::string bytes; - for(size_t index = 0; index < m_component_list.size(); ++index) + for(size_t index=0; index < m_component_list.size(); ++index) bytes += m_component_list[index]->GetBytes(); - return ByteIO::GetBytes() + bytes; + return ByteIO::GetBytes()+bytes; } void TransformByteIO::Output() { // Zero Transform flag - applies only to inter frames - if(m_fparams.PicSort().IsInter()) + if (m_fparams.PicSort().IsInter()) WriteBit(false); // Wavelet index WriteUint(m_cparams.TransformFilter()); @@ -103,9 +103,9 @@ void TransformByteIO::Output() // Spatial Partition flag WriteBit(m_cparams.SpatialPartition()); - if(m_cparams.SpatialPartition()) + if (m_cparams.SpatialPartition()) { - for(unsigned int i = 0; i <= m_cparams.TransformDepth(); ++i) + for (unsigned int i = 0; i <= m_cparams.TransformDepth(); ++i) { const CodeBlocks &cb = m_cparams.GetCodeBlocks(i); // Number of Horizontal code blocks for level i @@ -127,25 +127,25 @@ void TransformByteIO::Input() m_cparams.SetZeroTransform(false); // Zero transform flag - applies only for inter frames - if(m_fparams.PicSort().IsInter()) + if (m_fparams.PicSort().IsInter()) m_cparams.SetZeroTransform(ReadBool()); - if(m_cparams.ZeroTransform()) + if (m_cparams.ZeroTransform()) return; // Transform filter m_cparams.SetTransformFilter(ReadUint()); // transform depth - m_cparams.SetTransformDepth(ReadUint()); + m_cparams.SetTransformDepth(ReadUint()); // Spatial partition flag m_cparams.SetSpatialPartition(ReadBool()); - if(m_cparams.SpatialPartition()) + if (m_cparams.SpatialPartition()) { // Input number of code blocks for each level - for(unsigned int i = 0; i <= m_cparams.TransformDepth(); ++i) + for (unsigned int i = 0; i <= m_cparams.TransformDepth(); ++i) { // number of horizontal code blocks for level i unsigned int hblocks = ReadUint(); @@ -162,7 +162,7 @@ void TransformByteIO::Input() void TransformByteIO::AddComponent(ComponentByteIO* component_byteio) { - m_component_list.push_back(component_byteio); + m_component_list.push_back(component_byteio); } diff --git a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/transform_byteio.h b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/transform_byteio.h index 0153c8302..6fa1c0c5f 100644 --- a/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/transform_byteio.h +++ b/src/filters/parser/DiracSplitter/libdirac/libdirac_byteio/transform_byteio.h @@ -52,94 +52,94 @@ namespace dirac { - -/** -* Represents compressed sequence-parameter data used in an AccessUnit -*/ -class TransformByteIO : public ByteIO -{ -public: - - /** - * Output Constructor - *@param fparams Picture parameters - *@param c_params Codec params - */ - TransformByteIO(PictureParams& fparams, - CodecParams& c_params); - - /** - * Input Constructor - *@param byte_io ByteIO object for copy constructor - *@param fparams Picture parameters - *@param c_params Codec params - */ - TransformByteIO(ByteIO &byte_io, PictureParams& fparams, - CodecParams& c_params); - - /** - * Destructor - */ - virtual ~TransformByteIO(); - - /** - * Gathers byte stats on the transform data - *@param dirac_byte_stats Stats container - */ - void CollateByteStats(DiracByteStats& dirac_byte_stats); - - /** - * Outputs sequence information to Dirac byte-format - */ - void Output(); - - /** - * Outputs sequence information to Dirac byte-format - */ - void Input(); - - - /** - * Get string containing coded bytes - */ - virtual const std::string GetBytes(); - - /** - * Return the size - */ - int GetSize() const; - - /** - * Adds a Picture-component in Dirac-bytestream format - *@param component_byteio Picture-component bytestream - */ - void AddComponent(ComponentByteIO *component_byteio); - -protected: - - -private: - - /** - * Sequence paramters for intput/output - */ - PictureParams& m_fparams; - + /** - * Codec params - EncParams for Output and DecParams for input - */ - CodecParams& m_cparams; - - /** - * Default Codec params - EncParams for Output and DecParams for input - */ - CodecParams m_default_cparams; - - /*** - * Transform Component data + * Represents compressed sequence-parameter data used in an AccessUnit */ - std::vector<ComponentByteIO *> m_component_list; -}; + class TransformByteIO : public ByteIO + { + public: + + /** + * Output Constructor + *@param fparams Picture parameters + *@param c_params Codec params + */ + TransformByteIO(PictureParams& fparams, + CodecParams& c_params); + + /** + * Input Constructor + *@param byte_io ByteIO object for copy constructor + *@param fparams Picture parameters + *@param c_params Codec params + */ + TransformByteIO(ByteIO &byte_io, PictureParams& fparams, + CodecParams& c_params); + + /** + * Destructor + */ + virtual ~TransformByteIO(); + + /** + * Gathers byte stats on the transform data + *@param dirac_byte_stats Stats container + */ + void CollateByteStats(DiracByteStats& dirac_byte_stats); + + /** + * Outputs sequence information to Dirac byte-format + */ + void Output(); + + /** + * Outputs sequence information to Dirac byte-format + */ + void Input(); + + + /** + * Get string containing coded bytes + */ + virtual const std::string GetBytes(); + + /** + * Return the size + */ + int GetSize() const; + + /** + * Adds a Picture-component in Dirac-bytestream format + *@param component_byteio Picture-component bytestream + */ + void AddComponent(ComponentByteIO *component_byteio); + + protected: + + + private: + + /** + * Sequence paramters for intput/output + */ + PictureParams& m_fparams; + + /** + * Codec params - EncParams for Output and DecParams for input + */ + CodecParams& m_cparams; + + /** + * Default Codec params - EncParams for Output and DecParams for input + */ + CodecParams m_default_cparams; + + /*** + * Transform Component data + */ + std::vector<ComponentByteIO *> m_component_list; + }; } // namespace dirac |