libpgf  6.12.24
PGF - Progressive Graphics File
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CDecoder Class Reference

#include <Decoder.h>

Public Member Functions

and levelLength at current
stream position *It might
throw an IOException *param
stream A PGF stream *param
preHeader[out] A PGF pre
header *param header[out] A
PGF header *param postHeader[out]
A PGF post header *param
levelLength The location of
the levelLength array The
array is allocated in this
method The caller has to
delete this array *param
userDataPos The stream
position of the user 
data (metadata)*@param useOMP If true
 
and levelLength at current
stream position *It might
throw an IOException *param
stream A PGF stream *param
preHeader[out] A PGF pre
header *param header[out] A
PGF header *param postHeader[out]
A PGF post header *param
levelLength The location of
the levelLength array The
array is allocated in this
method The caller has to
delete this array *param
userDataPos The stream
position of the user then the
decoder will use multi
threading based on openMP
*param skipUserData If then
user data is not read In case
of available user the file
position is still returned in
userDataPos * 
CDecoder (CPGFStream *stream, PGFPreHeader &preHeader, PGFHeader &header, PGFPostHeader &postHeader, UINT32 *&levelLength, UINT64 &userDataPos, bool useOMP, bool skipUserData) THROW_
 
*Destructor * ~CDecoder ()
 
*Deccoding and dequantization
of HL and LH subband
*(interleaved) using
partitioning scheme.*Partitioning
scheme Return the length of
all encoded headers in bytes
*return The length of all
encoded headers in bytes
*UINT32 
GetEncodedHeaderLength () const
 
*Reset stream position to
beginning of PGF pre header
*void 
SetStreamPosToStart () THROW_
 
*Reset stream position to
beginning of data block *void 
SetStreamPosToData () THROW_
 
*Skip a given number of bytes
in the open stream *It might
throw an IOException *void 
Skip (UINT64 offset) THROW_
 
*Dequantization of a single
value at given position in
subband *It might throw an
IOException *param band A
subband *param bandPos A valid
position in subband band
*param quantParam The
quantization parameter *void 
DequantizeValue (CSubband *band, UINT32 bandPos, int quantParam) THROW_
 
*Copies data from the open
stream to a target buffer *It
might throw an IOException
*param target The target
buffer *param len The number
of bytes to read *return The
number of bytes copied to the
target buffer *UINT32 
ReadEncodedData (UINT8 *target, UINT32 len) const THROW_
 
*Reads stream and decodes tile
buffer *It might throw an
IOException *void 
DecodeBuffer () THROW_
 
*return Stream *CPGFStreamGetStream ()
 
*return True if decoded macro
blocks are available for
processing *bool 
MacroBlocksAvailable () const
 

Public Attributes

Constructor: Read pre-header
 
 header
 
and levelLength at current
stream position *It might
throw an IOException *param
stream A PGF stream *param
preHeader[out] A PGF pre
header *param header[out] A
PGF header *param postHeader[out]
A PGF post header *param
levelLength The location of
the levelLength array The
array is allocated in this
method The caller has to
delete this array *param
userDataPos The stream
position of the user then the
decoder will use multi
threading based on openMP
*param skipUserData If 
true
 
and levelLength at current
stream position *It might
throw an IOException *param
stream A PGF stream *param
preHeader[out] A PGF pre
header *param header[out] A
PGF header *param postHeader[out]
A PGF post header *param
levelLength The location of
the levelLength array The
array is allocated in this
method The caller has to
delete this array *param
userDataPos The stream
position of the user then the
decoder will use multi
threading based on openMP
*param skipUserData If then
user data is not read In case
of available user 
data
 
*Unpartitions a rectangular
region of a given subband
*Partitioning 
scheme: The plane is partitioned in squares of side length LinBlockSize. * Read wavelet coefficients from the output buffer of a macro block. * It might throw an IOException. * @param band A subband * @param quantParam Dequantization value * @param width The width of the rectangle * @param height The height of the rectangle * @param startPos The relative subband position of the top left corner of the rectangular region * @param pitch The number of bytes in row of the subband */ void Partition(CSubband* band
 
*Unpartitions a rectangular
region of a given subband
*Partitioning int 
quantParam
 
*Unpartitions a rectangular
region of a given subband
*Partitioning int int 
width
 
*Unpartitions a rectangular
region of a given subband
*Partitioning int int int 
height
 
*Unpartitions a rectangular
region of a given subband
*Partitioning int int int int 
startPos
 
*Unpartitions a rectangular
region of a given subband
*Partitioning int int int int
int pitch 
THROW_
 

Private Member Functions

*PGF decoder macro block class
*author C I Bauersachs *brief
A macro block is a decoding
unit of fixed 
size (uncoded)*/class CMacroBlock
 
void ReadMacroBlock (CMacroBlock *block) THROW_
 throws IOException
 

Private Attributes

*PGF decoder macro block class
*author C 
Stamm
 
CPGFStreamm_stream
 input PGF stream
 
UINT64 m_startPos
 stream position at the beginning of the PGF pre-header
 
UINT64 m_streamSizeEstimation
 estimation of stream size
 
UINT32 m_encodedHeaderLength
 stream offset from startPos to the beginning of the data part (highest level)
 
CMacroBlock ** m_macroBlocks
 array of macroblocks
 
int m_currentBlockIndex
 index of current macro block
 
int m_macroBlockLen
 array length
 
int m_macroBlocksAvailable
 number of decoded macro blocks (including currently used macro block)
 
CMacroBlock * m_currentBlock
 current macro block (used by main thread)
 

Detailed Description

Definition at line 46 of file Decoder.h.

Constructor & Destructor Documentation

and levelLength at current stream position* It might throw an IOException* param stream A PGF stream* param preHeader [out] A PGF pre header* param header [out] A PGF header* param postHeader [out] A PGF post header* param levelLength The location of the levelLength array The array is allocated in this method The caller has to delete this array* param userDataPos The stream position of the user then the decoder will use multi threading based on openMP* param skipUserData If then user data is not read In case of available user the file position is still returned in userDataPos* CDecoder::CDecoder ( CPGFStream stream,
PGFPreHeader preHeader,
PGFHeader header,
PGFPostHeader postHeader,
UINT32 *&  levelLength,
UINT64 &  userDataPos,
bool  useOMP,
bool  skipUserData 
)
CDecoder::~CDecoder ( )

Definition at line 216 of file Decoder.cpp.

{
for (int i=0; i < m_macroBlockLen; i++) delete m_macroBlocks[i];
delete[] m_macroBlocks;
} else {
}
}

Member Function Documentation

and levelLength at current stream position* It might throw an IOException* param stream A PGF stream* param preHeader [out] A PGF pre header* param header [out] A PGF header* param postHeader [out] A PGF post header* param levelLength The location of the levelLength array The array is allocated in this method The caller has to delete this array* param userDataPos The stream position of the user CDecoder::data ( metadata  )
void CDecoder::DecodeBuffer ( )

Definition at line 479 of file Decoder.cpp.

{
// macro block management
if (m_macroBlockLen == 1) {
m_currentBlock->BitplaneDecode();
} else {
for (int i=0; i < m_macroBlockLen; i++) {
// read sequentially several blocks
try {
} catch(IOException& ex) {
if (ex.error == MissingData) {
break; // no further data available
} else {
throw ex;
}
}
}
// decode in parallel
#pragma omp parallel for default(shared) //no declared exceptions in next block
for (int i=0; i < m_macroBlocksAvailable; i++) {
m_macroBlocks[i]->BitplaneDecode();
}
// prepare current macro block
}
}
*Dequantization of a single value at given position in subband *If encoded data is then stores dequantized band value into *buffer m_value at position m_valuePos *Otherwise reads encoded data block and decodes it *It might throw an IOException *param band A subband *param bandPos A valid position in subband band *param quantParam The quantization parameter *void CDecoder::DequantizeValue ( CSubband band,
UINT32  bandPos,
int  quantParam 
)

Definition at line 447 of file Decoder.cpp.

{
if (m_currentBlock->IsCompletelyRead()) {
// all data of current macro block has been read --> prepare next macro block
DecodeTileBuffer();
}
band->SetData(bandPos, m_currentBlock->m_value[m_currentBlock->m_valuePos] << quantParam);
m_currentBlock->m_valuePos++;
}
* Deccoding and dequantization of HL and LH subband* (interleaved) using partitioning scheme. * Partitioning scheme Return the length of all encoded headers in bytes* return The length of all encoded headers in bytes* UINT32 CDecoder::GetEncodedHeaderLength ( ) const
inline

Definition at line 136 of file Decoder.h.

* return Stream* CPGFStream* CDecoder::GetStream ( )
inline

Definition at line 174 of file Decoder.h.

{ return m_stream; }
* return True if decoded macro blocks are available for processing* bool CDecoder::MacroBlocksAvailable ( ) const
inline

Definition at line 178 of file Decoder.h.

{ return m_macroBlocksAvailable > 1; }
*Copies data from the open stream to a target buffer *It might throw an IOException *param target The target buffer *param len The number of bytes to read *return The number of bytes copied to the target buffer *UINT32 CDecoder::ReadEncodedData ( UINT8 *  target,
UINT32  len 
) const

Definition at line 231 of file Decoder.cpp.

{
int count = len;
m_stream->Read(&count, target);
return count;
}
void CDecoder::ReadMacroBlock ( CMacroBlock *  block)
private

throws IOException

Definition at line 519 of file Decoder.cpp.

{
ASSERT(block);
UINT16 wordLen;
int count, expected;
#ifdef TRACE
//UINT32 filePos = (UINT32)m_stream->GetPos();
//printf("DecodeBuffer: %d\n", filePos);
#endif
// read wordLen
count = expected = sizeof(UINT16);
m_stream->Read(&count, &wordLen);
if (count != expected) ReturnWithError(MissingData);
wordLen = __VAL(wordLen);
if (wordLen > BufferSize)
ReturnWithError(FormatCannotRead);
#ifdef __PGFROISUPPORT__
// read ROIBlockHeader
if (m_roi) {
m_stream->Read(&count, &h.val);
if (count != expected) ReturnWithError(MissingData);
// convert ROIBlockHeader
h.val = __VAL(h.val);
}
#endif
// save header
block->m_header = h;
// read data
count = expected = wordLen*WordBytes;
m_stream->Read(&count, block->m_codeBuffer);
if (count != expected) ReturnWithError(MissingData);
#ifdef PGF_USE_BIG_ENDIAN
// convert data
count /= WordBytes;
for (int i=0; i < count; i++) {
block->m_codeBuffer[i] = __VAL(block->m_codeBuffer[i]);
}
#endif
#ifdef __PGFROISUPPORT__
ASSERT(m_roi && h.rbh.bufferSize <= BufferSize || h.rbh.bufferSize == BufferSize);
#else
ASSERT(h.rbh.bufferSize == BufferSize);
#endif
}
* Reset stream position to beginning of data block* void CDecoder::SetStreamPosToData ( )
inline

Definition at line 144 of file Decoder.h.

* Reset stream position to beginning of PGF pre header* void CDecoder::SetStreamPosToStart ( )
inline

Definition at line 140 of file Decoder.h.

{ ASSERT(m_stream); m_stream->SetPos(FSFromStart, m_startPos); }
* PGF decoder macro block class* author C I Bauersachs* brief A macro block is a decoding unit of fixed CDecoder::size ( uncoded  )
inlineprivate

< block header

< output buffer of values with index m_valuePos

< input buffer for encoded bitstream

< current position in m_value

Definition at line 50 of file Decoder.h.

{
public:
CMacroBlock(CDecoder *decoder)
: m_header(0) // makes sure that IsCompletelyRead() returns true for an empty macro block
, m_valuePos(0)
, m_decoder(decoder)
{
ASSERT(m_decoder);
}
bool IsCompletelyRead() const { return m_valuePos >= m_header.rbh.bufferSize; }
void BitplaneDecode();
DataT m_value[BufferSize];
UINT32 m_codeBuffer[CodeBufferLen];
UINT32 m_valuePos;
private:
UINT32 ComposeBitplane(UINT32 bufferSize, DataT planeMask, UINT32* sigBits, UINT32* refBits, UINT32* signBits);
UINT32 ComposeBitplaneRLD(UINT32 bufferSize, DataT planeMask, UINT32 sigPos, UINT32* refBits);
UINT32 ComposeBitplaneRLD(UINT32 bufferSize, DataT planeMask, UINT32* sigBits, UINT32* refBits, UINT32 signPos);
void SetBitAtPos(UINT32 pos, DataT planeMask) { (m_value[pos] >= 0) ? m_value[pos] |= planeMask : m_value[pos] -= planeMask; }
void SetSign(UINT32 pos, bool sign) { m_value[pos] = -m_value[pos]*sign + m_value[pos]*(!sign); }
CDecoder *m_decoder; // outer class
bool m_sigFlagVector[BufferSize+1]; // see paper from Malvar, Fast Progressive Wavelet Coder
};
*Skip a given number of bytes in the open stream *It might throw an IOException *void CDecoder::Skip ( UINT64  offset)

Definition at line 434 of file Decoder.cpp.

{
m_stream->SetPos(FSFromCurrent, offset);
}

Member Data Documentation

* CDecoder::Constructor

Definition at line 89 of file Decoder.h.

and levelLength at current stream position* It might throw an IOException* param stream A PGF stream* param preHeader [out] A PGF pre header* param header [out] A PGF header* param postHeader [out] A PGF post header* param levelLength The location of the levelLength array The array is allocated in this method The caller has to delete this array* param userDataPos The stream position of the user then the decoder will use multi threading based on openMP* param skipUserData If then user data is not read In case of available user CDecoder::data

Definition at line 102 of file Decoder.h.

CDecoder::header

Definition at line 89 of file Decoder.h.

* Unpartitions a rectangular region of a given subband* Partitioning int int int CDecoder::height

Definition at line 122 of file Decoder.h.

CMacroBlock* CDecoder::m_currentBlock
private

current macro block (used by main thread)

Definition at line 212 of file Decoder.h.

int CDecoder::m_currentBlockIndex
private

index of current macro block

Definition at line 209 of file Decoder.h.

UINT32 CDecoder::m_encodedHeaderLength
private

stream offset from startPos to the beginning of the data part (highest level)

Definition at line 206 of file Decoder.h.

int CDecoder::m_macroBlockLen
private

array length

Definition at line 210 of file Decoder.h.

CMacroBlock** CDecoder::m_macroBlocks
private

array of macroblocks

Definition at line 208 of file Decoder.h.

int CDecoder::m_macroBlocksAvailable
private

number of decoded macro blocks (including currently used macro block)

Definition at line 211 of file Decoder.h.

UINT64 CDecoder::m_startPos
private

stream position at the beginning of the PGF pre-header

Definition at line 204 of file Decoder.h.

CPGFStream* CDecoder::m_stream
private

input PGF stream

Definition at line 203 of file Decoder.h.

UINT64 CDecoder::m_streamSizeEstimation
private

estimation of stream size

Definition at line 205 of file Decoder.h.

* Unpartitions a rectangular region of a given subband* Partitioning int CDecoder::quantParam

Definition at line 122 of file Decoder.h.

* Unpartitions a rectangular region of a given subband* Partitioning CDecoder::scheme

Definition at line 122 of file Decoder.h.

* PGF decoder macro block class* author C CDecoder::Stamm
private

Definition at line 49 of file Decoder.h.

* Unpartitions a rectangular region of a given subband* Partitioning int int int int CDecoder::startPos

Definition at line 122 of file Decoder.h.

* Unpartitions a rectangular region of a given subband* Partitioning int int int int int pitch CDecoder::THROW_

Definition at line 122 of file Decoder.h.

and levelLength at current stream position* It might throw an IOException* param stream A PGF stream* param preHeader [out] A PGF pre header* param header [out] A PGF header* param postHeader [out] A PGF post header* param levelLength The location of the levelLength array The array is allocated in this method The caller has to delete this array* param userDataPos The stream position of the user then the decoder will use multi threading based on openMP* param skipUserData If CDecoder::true

Definition at line 102 of file Decoder.h.

* Unpartitions a rectangular region of a given subband* Partitioning int int CDecoder::width

Definition at line 122 of file Decoder.h.


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