 |
libpgf
7.15.32
PGF - Progressive Graphics File
|
PGF encoder.
More...
#include <Encoder.h>
|
| CEncoder (CPGFStream *stream, PGFPreHeader preHeader, PGFHeader header, const PGFPostHeader &postHeader, UINT64 &userDataPos, bool useOMP) |
|
| ~CEncoder () |
| Destructor. More...
|
|
void | FavorSpeedOverSize () |
| Encoder favors speed over compression size. More...
|
|
void | Flush () |
|
void | UpdatePostHeaderSize (PGFPreHeader preHeader) |
|
UINT32 | WriteLevelLength (UINT32 *&levelLength) |
|
UINT32 | UpdateLevelLength () |
|
void | Partition (CSubband *band, int width, int height, int startPos, int pitch) |
|
void | SetEncodedLevel (int currentLevel) |
|
void | WriteValue (CSubband *band, int bandPos) |
|
INT64 | ComputeHeaderLength () const |
|
INT64 | ComputeBufferLength () const |
|
INT64 | ComputeOffset () const |
|
void | SetStreamPosToStart () |
| Resets stream position to beginning of PGF pre-header. More...
|
|
void | SetBufferStartPos () |
| Save current stream position as beginning of current level. More...
|
|
PGF encoder.
PGF encoder class.
- Author
- C. Stamm
Definition at line 46 of file Encoder.h.
◆ CEncoder()
Write pre-header, header, post-Header, and levelLength. It might throw an IOException.
- Parameters
-
stream | A PGF stream |
preHeader | A already filled in PGF pre-header |
header | An already filled in PGF header |
postHeader | [in] An already filled in PGF post-header (containing color table, user data, ...) |
userDataPos | [out] File position of user data |
useOMP | If true, then the encoder will use multi-threading based on openMP |
Write pre-header, header, postHeader, and levelLength. It might throw an IOException.
- Parameters
-
stream | A PGF stream |
preHeader | A already filled in PGF pre-header |
header | An already filled in PGF header |
postHeader | [in] An already filled in PGF post-header (containing color table, user data, ...) |
userDataPos | [out] File position of user data |
useOMP | If true, then the encoder will use multi-threading based on openMP |
Definition at line 70 of file Encoder.cpp.
77 #ifdef __PGFROISUPPORT__
88 #ifdef LIBPGF_USE_OPENMP
95 #ifdef LIBPGF_USE_OPENMP
◆ ~CEncoder()
◆ ComputeBufferLength()
INT64 CEncoder::ComputeBufferLength |
( |
| ) |
const |
|
inline |
Compute stream length of encoded buffer.
- Returns
- encoded buffer length
Definition at line 179 of file Encoder.h.
◆ ComputeHeaderLength()
INT64 CEncoder::ComputeHeaderLength |
( |
| ) |
const |
|
inline |
Compute stream length of header.
- Returns
- header length
Definition at line 174 of file Encoder.h.
◆ ComputeOffset()
INT64 CEncoder::ComputeOffset |
( |
| ) |
const |
|
inline |
Compute file offset between real and expected levelLength position.
- Returns
- file offset
Definition at line 184 of file Encoder.h.
◆ EncodeBuffer()
Definition at line 341 of file Encoder.cpp.
343 #ifdef __PGFROISUPPORT__
383 #ifdef LIBPGF_USE_OPENMP
384 #pragma omp parallel for default(shared) //no declared exceptions in next block
◆ FavorSpeedOverSize()
void CEncoder::FavorSpeedOverSize |
( |
| ) |
|
|
inline |
Encoder favors speed over compression size.
Definition at line 121 of file Encoder.h.
◆ Flush()
◆ Partition()
void CEncoder::Partition |
( |
CSubband * |
band, |
|
|
int |
width, |
|
|
int |
height, |
|
|
int |
startPos, |
|
|
int |
pitch |
|
) |
| |
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.
- Parameters
-
band | A subband |
width | The width of the rectangle |
height | The height of the rectangle |
startPos | The absolute subband position of the top left corner of the rectangular region |
pitch | The number of bytes in row of the subband |
Definition at line 246 of file Encoder.cpp.
252 const int wr = pitch - ww.rem;
253 int pos, base = startPos, base2;
256 for (
int i=0; i < hh.quot; i++) {
259 for (
int j=0; j < ww.quot; j++) {
273 for (
int x=0; x < ww.rem; x++) {
283 for (
int j=0; j < ww.quot; j++) {
286 for (
int y=0; y < hh.rem; y++) {
297 for (
int y=0; y < hh.rem; y++) {
299 for (
int x=0; x < ww.rem; x++) {
◆ SetBufferStartPos()
void CEncoder::SetBufferStartPos |
( |
| ) |
|
|
inline |
Save current stream position as beginning of current level.
Definition at line 192 of file Encoder.h.
◆ SetEncodedLevel()
void CEncoder::SetEncodedLevel |
( |
int |
currentLevel | ) |
|
|
inline |
Informs the encoder about the encoded level.
- Parameters
-
currentLevel | encoded level [0, nLevels) |
Definition at line 162 of file Encoder.h.
◆ SetStreamPosToStart()
void CEncoder::SetStreamPosToStart |
( |
| ) |
|
|
inline |
Resets stream position to beginning of PGF pre-header.
Definition at line 188 of file Encoder.h.
◆ UpdateLevelLength()
UINT32 CEncoder::UpdateLevelLength |
( |
| ) |
|
Write new levelLength into stream. It might throw an IOException.
- Returns
- Written image bytes.
Definition at line 202 of file Encoder.cpp.
209 #ifdef PGF_USE_BIG_ENDIAN
221 #endif //PGF_USE_BIG_ENDIAN
◆ UpdatePostHeaderSize()
void CEncoder::UpdatePostHeaderSize |
( |
PGFPreHeader |
preHeader | ) |
|
Increase post-header size and write new size into stream.
- Parameters
-
preHeader | An already filled in PGF pre-header It might throw an IOException. |
Definition at line 160 of file Encoder.cpp.
◆ WriteLevelLength()
UINT32 CEncoder::WriteLevelLength |
( |
UINT32 *& |
levelLength | ) |
|
Create level length data structure and write a place holder into stream. It might throw an IOException.
- Parameters
-
levelLength | A reference to an integer array, large enough to save the relative file positions of all PGF levels |
- Returns
- number of bytes written into stream
Definition at line 177 of file Encoder.cpp.
179 delete[] levelLength;
180 levelLength =
new(std::nothrow) UINT32[
m_nLevels];
181 if (!levelLength) ReturnWithError(InsufficientMemory);
182 for (UINT8 l = 0; l <
m_nLevels; l++) levelLength[l] = 0;
◆ WriteMacroBlock()
Definition at line 406 of file Encoder.cpp.
408 #ifdef __PGFROISUPPORT__
412 int count =
sizeof(UINT16);
419 #ifdef PGF_USE_BIG_ENDIAN
421 UINT16 wl =
__VAL(wordLen);
422 m_stream->
Write(&count, &wl); ASSERT(count ==
sizeof(UINT16));
424 #ifdef __PGFROISUPPORT__
431 #endif // __PGFROISUPPORT__
434 for (
int i=0; i < wordLen; i++) {
435 block->m_codeBuffer[i] =
__VAL(block->m_codeBuffer[i]);
439 m_stream->
Write(&count, &wordLen); ASSERT(count ==
sizeof(UINT16));
441 #ifdef __PGFROISUPPORT__
447 #endif // __PGFROISUPPORT__
448 #endif // PGF_USE_BIG_ENDIAN
468 block->m_valuePos = 0;
469 block->m_maxAbsValue = 0;
◆ WriteValue()
void CEncoder::WriteValue |
( |
CSubband * |
band, |
|
|
int |
bandPos |
|
) |
| |
Write a single value into subband at given position. It might throw an IOException.
- Parameters
-
band | A subband |
bandPos | A valid position in subband band |
Definition at line 326 of file Encoder.cpp.
◆ m_bufferStartPos
UINT64 CEncoder::m_bufferStartPos |
|
private |
stream position of encoded buffer
Definition at line 216 of file Encoder.h.
◆ m_currentBlock
current macro block (used by main thread)
Definition at line 221 of file Encoder.h.
◆ m_currLevelIndex
int CEncoder::m_currLevelIndex |
|
private |
counts where (=index) to save next value
Definition at line 224 of file Encoder.h.
◆ m_favorSpeed
bool CEncoder::m_favorSpeed |
|
private |
favor speed over size
Definition at line 226 of file Encoder.h.
◆ m_forceWriting
bool CEncoder::m_forceWriting |
|
private |
all macro blocks have to be written into the stream
Definition at line 227 of file Encoder.h.
◆ m_lastMacroBlock
int CEncoder::m_lastMacroBlock |
|
private |
array index of the last created macro block
Definition at line 220 of file Encoder.h.
◆ m_levelLength
UINT32* CEncoder::m_levelLength |
|
private |
temporary saves the level index
Definition at line 223 of file Encoder.h.
◆ m_levelLengthPos
UINT64 CEncoder::m_levelLengthPos |
|
private |
stream position of Metadata
Definition at line 215 of file Encoder.h.
◆ m_macroBlockLen
int CEncoder::m_macroBlockLen |
|
private |
◆ m_macroBlocks
array of macroblocks
Definition at line 218 of file Encoder.h.
◆ m_nLevels
UINT8 CEncoder::m_nLevels |
|
private |
◆ m_startPosition
UINT64 CEncoder::m_startPosition |
|
private |
stream position of PGF start (PreHeader)
Definition at line 214 of file Encoder.h.
◆ m_stream
The documentation for this class was generated from the following files:
int m_macroBlockLen
array length
#define LinBlockSize
side length of a coefficient block in a HH or LL subband
virtual UINT64 GetPos() const =0
#define BufferSize
must be a multiple of WordWidth, BufferSize <= UINT16_MAX
void SetBufferStartPos()
Save current stream position as beginning of current level.
UINT32 m_maxAbsValue
maximum absolute coefficient in each buffer
DataT GetData(UINT32 pos) const
UINT32 * m_levelLength
temporary saves the level index
bool m_forceWriting
all macro blocks have to be written into the stream
UINT32 m_valuePos
current buffer position
int m_lastLevelIndex
index of last encoded level: [0, nLevels); used because a level-end can occur before a buffer is full
CMacroBlock * m_currentBlock
current macro block (used by main thread)
UINT64 m_startPosition
stream position of PGF start (PreHeader)
INT64 ComputeBufferLength() const
void EncodeBuffer(ROIBlockHeader h)
CPGFStream * m_stream
output PMF stream
CMacroBlock ** m_macroBlocks
array of macroblocks
virtual void Write(int *count, void *buffer)=0
UINT64 m_levelLengthPos
stream position of Metadata
virtual void SetPos(short posMode, INT64 posOff)=0
void WriteValue(CSubband *band, int bandPos)
UINT32 NumberOfWords(UINT32 pos)
int m_currLevelIndex
counts where (=index) to save next value
void SetStreamPosToStart()
Resets stream position to beginning of PGF pre-header.
UINT8 m_nLevels
number of levels
DataT m_value[BufferSize]
input buffer of values with index m_valuePos
UINT64 m_bufferStartPos
stream position of encoded buffer
#define CodeBufferLen
number of words in code buffer (CodeBufferLen > BufferLen)
void Init(int lastLevelIndex)
int m_lastMacroBlock
array index of the last created macro block
bool m_favorSpeed
favor speed over size
void WriteMacroBlock(CMacroBlock *block)
ROIBlockHeader m_header
block header