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

#include <Encoder.h>

Public Member Functions

*Write pre post and
levelLength *It might throw an
IOException *param stream A
PGF stream *param preHeader A
already filled in PGF pre
header *param header An
already filled in PGF header
*param postHeader[in] An
already filled in PGF post 
header (containing color table, user data,...)*@param userDataPos[out] File position of user data *@param useOMP If true
 
*Write pre post and
levelLength *It might throw an
IOException *param stream A
PGF stream *param preHeader A
already filled in PGF pre
header *param header An
already filled in PGF header
*param postHeader[in] An
already filled in PGF post
then the encoder will use
multi threading based on
openMP * 
CEncoder (CPGFStream *stream, PGFPreHeader preHeader, PGFHeader header, const PGFPostHeader &postHeader, UINT64 &userDataPos, bool useOMP) THROW_
 
*Destructor * ~CEncoder ()
 
*Encoder favors speed over
compression size *void 
FavorSpeedOverSize ()
 
*Pad buffer with zeros and
encode buffer *It might throw
an IOException *void 
Flush () THROW_
 
*Increase post header size and
write new size into stream
*param preHeader An already
filled in PGF pre header *It
might throw an IOException
*void 
UpdatePostHeaderSize (PGFPreHeader preHeader) THROW_
 
*Create level length data
structure and write a place
holder into stream *It might
throw an IOException *param
levelLength A reference to an
integer large enough to save
the relative file positions of
all PGF levels *return number
of bytes written into stream
*UINT32 
WriteLevelLength (UINT32 *&levelLength) THROW_
 
*Write new levelLength into
stream *It might throw an
IOException *return Written
image bytes *UINT32 
UpdateLevelLength () THROW_
 

Public Attributes

*Write pre header
 
*Write pre post Header
 
*Create level length data
structure and write a place
holder into stream *It might
throw an IOException *param
levelLength A reference to an
integer 
array
 
*Partitions a rectangular
region of a given subband
*Partitioning 
scheme: The plane is partitioned in squares of side length LinBlockSize. * Write wavelet coefficients from subband into the input buffer of a macro block. * It might throw an IOException. * @param band A subband * @param width The width of the rectangle * @param height The height of the rectangle * @param startPos The absolute 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
 
*Partitions a rectangular
region of a given subband
*Partitioning int 
width
 
*Partitions a rectangular
region of a given subband
*Partitioning int int 
height
 
*Partitions a rectangular
region of a given subband
*Partitioning int int int 
startPos
 
*Partitions a rectangular
region of a given subband
*Partitioning int int int int
pitch 
THROW_
 

Private Member Functions

*PGF encoder macro block class
*author C I Bauersachs *brief
A macro block is an encoding
unit of fixed 
size (uncoded)*/class CMacroBlock
 

Private Attributes

*PGF encoder macro block class
*author C 
Stamm
 

Detailed Description

Definition at line 46 of file Encoder.h.

Constructor & Destructor Documentation

* Write pre post and levelLength* It might throw an IOException* param stream A PGF stream* param preHeader A already filled in PGF pre header* param header An already filled in PGF header* param postHeader [in] An already filled in PGF post then the encoder will use multi threading based on openMP* CEncoder::CEncoder ( CPGFStream stream,
PGFPreHeader  preHeader,
PGFHeader  header,
const PGFPostHeader postHeader,
UINT64 &  userDataPos,
bool  useOMP 
)
CEncoder::~CEncoder ( )

Definition at line 146 of file Encoder.cpp.

{
delete m_currentBlock;
delete[] m_macroBlocks;
}

Member Function Documentation

* Encoder favors speed over compression size* void CEncoder::FavorSpeedOverSize ( )
inline

Definition at line 117 of file Encoder.h.

{ m_favorSpeed = true; }
*Pad buffer with zeros and encode buffer *It might throw an IOException *void CEncoder::Flush ( )

Definition at line 305 of file Encoder.cpp.

{
if (m_currentBlock->m_valuePos > 0) {
// pad buffer with zeros
memset(&(m_currentBlock->m_value[m_currentBlock->m_valuePos]), 0, (BufferSize - m_currentBlock->m_valuePos)*DataTSize);
m_currentBlock->m_valuePos = BufferSize;
// encode buffer
m_forceWriting = true; // makes sure that the following EncodeBuffer is really written into the stream
EncodeBuffer(ROIBlockHeader(m_currentBlock->m_valuePos, true));
}
}
* Write pre post and levelLength* It might throw an IOException* param stream A PGF stream* param preHeader A already filled in PGF pre header* param header An already filled in PGF header* param postHeader [in] An already filled in PGF post CEncoder::header ( containing color  table,
user  data,
  ... 
)
* PGF encoder macro block class* author C I Bauersachs* brief A macro block is an encoding unit of fixed CEncoder::size ( uncoded  )
inlineprivate

< input buffer of values with index m_valuePos

< output buffer for encoded bitstream

< block header

< current buffer position

< maximum absolute coefficient in each buffer

< current position in encoded bitstream

< index of last encoded level: [0, nLevels); used because a level-end can occur before a buffer is full

Definition at line 50 of file Encoder.h.

{
public:
CMacroBlock(CEncoder *encoder)
: m_header(0)
, m_encoder(encoder)
{
ASSERT(m_encoder);
Init(-1);
}
void Init(int lastLevelIndex) { // initialize for reusage
m_valuePos = 0;
m_maxAbsValue = 0;
m_codePos = 0;
m_lastLevelIndex = lastLevelIndex;
}
void BitplaneEncode();
DataT m_value[BufferSize];
UINT32 m_codeBuffer[CodeBufferLen];
UINT32 m_valuePos;
UINT32 m_maxAbsValue;
UINT32 m_codePos;
int m_lastLevelIndex;
private:
UINT32 RLESigns(UINT32 codePos, UINT32* signBits, UINT32 signLen);
UINT32 DecomposeBitplane(UINT32 bufferSize, UINT32 planeMask, UINT32 codePos, UINT32* sigBits, UINT32* refBits, UINT32* signBits, UINT32& signLen, UINT32& codeLen);
UINT8 NumberOfBitplanes();
bool GetBitAtPos(UINT32 pos, UINT32 planeMask) const { return (abs(m_value[pos]) & planeMask) > 0; }
CEncoder *m_encoder; // encoder instance
bool m_sigFlagVector[BufferSize+1]; // see paper from Malvar, Fast Progressive Wavelet Coder
};
*Write new levelLength into stream *It might throw an IOException *return Written image bytes *UINT32 CEncoder::UpdateLevelLength ( )

Definition at line 197 of file Encoder.cpp.

{
UINT64 curPos = m_stream->GetPos(); // end of image
// set file pos to levelLength
m_stream->SetPos(FSFromStart, m_levelLengthPos);
if (m_levelLength) {
#ifdef PGF_USE_BIG_ENDIAN
UINT32 levelLength;
for (int i=0; i < m_currLevelIndex; i++) {
levelLength = __VAL(UINT32(m_levelLength[i]));
m_stream->Write(&count, &levelLength);
}
#else
int count = m_currLevelIndex*WordBytes;
m_stream->Write(&count, m_levelLength);
#endif //PGF_USE_BIG_ENDIAN
} else {
int count = m_currLevelIndex*WordBytes;
m_stream->SetPos(FSFromCurrent, count);
}
// begin of image
UINT32 retValue = UINT32(curPos - m_stream->GetPos());
// restore file position
m_stream->SetPos(FSFromStart, curPos);
return retValue;
}
*Increase post header size and write new size into stream *param preHeader An already filled in PGF pre header *It might throw an IOException *void CEncoder::UpdatePostHeaderSize ( PGFPreHeader  preHeader)

Definition at line 155 of file Encoder.cpp.

{
UINT64 curPos = m_stream->GetPos(); // end of user data
// write preHeader
m_stream->SetPos(FSFromStart, m_startPosition);
preHeader.hSize = __VAL(preHeader.hSize);
m_stream->Write(&count, &preHeader);
m_stream->SetPos(FSFromStart, curPos);
}
*Create level length data structure and write a place holder into stream *It might throw an IOException *param levelLength A reference to an integer large enough to save the relative file positions of all PGF levels *return number of bytes written into stream *UINT32 CEncoder::WriteLevelLength ( UINT32 *&  levelLength)

Definition at line 172 of file Encoder.cpp.

{
// renew levelLength
delete[] levelLength;
levelLength = new(std::nothrow) UINT32[m_nLevels];
if (!levelLength) ReturnWithError(InsufficientMemory);
for (UINT8 l = 0; l < m_nLevels; l++) levelLength[l] = 0;
m_levelLength = levelLength;
// save level length file position
m_levelLengthPos = m_stream->GetPos();
// write dummy levelLength
int count = m_nLevels*WordBytes;
m_stream->Write(&count, m_levelLength);
// save current file position
SetBufferStartPos();
return count;
}

Member Data Documentation

* Create level length data structure and write a place holder into stream* It might throw an IOException* param levelLength A reference to an integer CEncoder::array

Definition at line 133 of file Encoder.h.

*Write pre CEncoder::header

Definition at line 96 of file Encoder.h.

* Write pre post CEncoder::Header

Definition at line 96 of file Encoder.h.

* Partitions a rectangular region of a given subband* Partitioning int int CEncoder::height

Definition at line 153 of file Encoder.h.

* Partitions a rectangular region of a given subband* Partitioning CEncoder::scheme

Definition at line 153 of file Encoder.h.

* PGF encoder macro block class* author C CEncoder::Stamm
private

Definition at line 49 of file Encoder.h.

* Partitions a rectangular region of a given subband* Partitioning int int int CEncoder::startPos

Definition at line 153 of file Encoder.h.

* Partitions a rectangular region of a given subband* Partitioning int int int int pitch CEncoder::THROW_

Definition at line 153 of file Encoder.h.

* Partitions a rectangular region of a given subband* Partitioning int CEncoder::width

Definition at line 153 of file Encoder.h.


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