libpgf 7.26.45
PGF - Progressive Graphics File
Loading...
Searching...
No Matches
Decoder.h
Go to the documentation of this file.
1/*
2 * The Progressive Graphics File; http://www.libpgf.org
3 *
4 * $Date: 2006-06-04 22:05:59 +0200 (So, 04 Jun 2006) $
5 * $Revision: 229 $
6 *
7 * This file Copyright (C) 2006 xeraina GmbH, Switzerland
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23
28
29#pragma once
30
31#include "PGFstream.h"
32#include "BitStream.h"
33#include "Subband.h"
34#include "WaveletTransform.h"
35
36namespace pgf {
41 class CDecoder {
47 public:
51 : m_header(0) // makes sure that IsCompletelyRead() returns true for an empty macro block
52#pragma warning( suppress : 4351 )
53 , m_value()
54 , m_codeBuffer()
55 , m_valuePos(0)
57 {
58 }
59
64
69 void BitplaneDecode();
70
74 uint32_t m_valuePos;
75
76 private:
77 uint32_t ComposeBitplane(uint32_t bufferSize, DataT planeMask, uint32_t* sigBits, uint32_t* refBits, uint32_t* signBits);
78 uint32_t ComposeBitplaneRLD(uint32_t bufferSize, DataT planeMask, uint32_t sigPos, uint32_t* refBits);
79 uint32_t ComposeBitplaneRLD(uint32_t bufferSize, DataT planeMask, uint32_t* sigBits, uint32_t* refBits, uint32_t signPos);
80 void SetBitAtPos(uint32_t pos, DataT planeMask) { (m_value[pos] >= 0) ? m_value[pos] |= planeMask : m_value[pos] -= planeMask; }
81 void SetSign(uint32_t pos, bool sign) { m_value[pos] = -m_value[pos]*sign + m_value[pos]*(!sign); }
82
83 bool m_sigFlagVector[BufferSize+1]; // see paper from Malvar, Fast Progressive Wavelet Coder
84 };
85
86 public:
98 CDecoder(CPGFStream* stream, PGFPreHeader& preHeader, PGFHeader& header,
99 PGFPostHeader& postHeader, uint32_t*& levelLength, uint64_t& userDataPos,
100 bool useOMP, uint32_t userDataPolicy); // throws IOException
101
104 ~CDecoder();
105
117 void Partition(CSubband* band, int quantParam, int width, int height, int startPos, int pitch);
118
126 void DecodeInterleaved(CWaveletTransform* wtChannel, int level, int quantParam);
127
132
135 void SetStreamPosToStart() { ASSERT(m_stream); m_stream->SetPos(FSFromStart, m_startPos); }
136
140
144 void Skip(uint64_t offset);
145
152 void DequantizeValue(CSubband* band, uint32_t bandPos, int quantParam);
153
160 uint32_t ReadEncodedData(uint8_t* target, uint32_t len) const;
161
165 void DecodeBuffer();
166
170
174 void GetNextMacroBlock();
175
176#ifdef __PGFROISUPPORT__
181 void SkipTileBuffer();
182
185 void SetROI() { m_roi = true; }
186#endif
187
188#ifdef TRACE
189 void DumpBuffer();
190#endif
191
192 private:
193 void ReadMacroBlock(CMacroBlock* block);
194
196 uint64_t m_startPos;
199
205
206#ifdef __PGFROISUPPORT__
207 bool m_roi;
208#endif
209 };
210}
PGF stream class.
PGF wavelet subband class.
PGF wavelet transform class.
A macro block is a decoding unit of fixed size (uncoded).
Definition Decoder.h:46
DataT m_value[BufferSize]
output buffer of values with index m_valuePos
Definition Decoder.h:72
uint32_t ComposeBitplane(uint32_t bufferSize, DataT planeMask, uint32_t *sigBits, uint32_t *refBits, uint32_t *signBits)
Definition Decoder.cpp:764
bool m_sigFlagVector[BufferSize+1]
Definition Decoder.h:83
uint32_t m_valuePos
current position in m_value
Definition Decoder.h:74
ROIBlockHeader m_header
block header
Definition Decoder.h:71
void SetBitAtPos(uint32_t pos, DataT planeMask)
Definition Decoder.h:80
CMacroBlock()
Constructor: Initializes new macro block.
Definition Decoder.h:50
void SetSign(uint32_t pos, bool sign)
Definition Decoder.h:81
uint32_t m_codeBuffer[CodeBufferLen]
input buffer for encoded bitstream
Definition Decoder.h:73
uint32_t ComposeBitplaneRLD(uint32_t bufferSize, DataT planeMask, uint32_t sigPos, uint32_t *refBits)
Definition Decoder.cpp:825
bool IsCompletelyRead() const
Definition Decoder.h:63
int m_macroBlocksAvailable
number of decoded macro blocks (including currently used macro block)
Definition Decoder.h:203
CMacroBlock ** m_macroBlocks
array of macroblocks
Definition Decoder.h:200
void Skip(uint64_t offset)
Definition Decoder.cpp:450
void Partition(CSubband *band, int quantParam, int width, int height, int startPos, int pitch)
Definition Decoder.cpp:267
void DecodeBuffer()
Definition Decoder.cpp:495
int m_currentBlockIndex
index of current macro block
Definition Decoder.h:201
int m_macroBlockLen
array length
Definition Decoder.h:202
uint32_t ReadEncodedData(uint8_t *target, uint32_t len) const
Definition Decoder.cpp:247
CPGFStream * m_stream
input PGF stream
Definition Decoder.h:195
void SetStreamPosToData()
Resets stream position to beginning of data block.
Definition Decoder.h:139
void ReadMacroBlock(CMacroBlock *block)
throws IOException
Definition Decoder.cpp:536
void DequantizeValue(CSubband *band, uint32_t bandPos, int quantParam)
Definition Decoder.cpp:463
uint64_t m_streamSizeEstimation
estimation of stream size
Definition Decoder.h:197
CPGFStream * GetStream()
Definition Decoder.h:169
void DecodeInterleaved(CWaveletTransform *wtChannel, int level, int quantParam)
Definition Decoder.cpp:334
uint32_t m_encodedHeaderLength
stream offset from startPos to the beginning of the data part (highest level)
Definition Decoder.h:198
uint64_t m_startPos
stream position at the beginning of the PGF pre-header
Definition Decoder.h:196
void GetNextMacroBlock()
Definition Decoder.cpp:478
CMacroBlock * m_currentBlock
current macro block (used by main thread)
Definition Decoder.h:204
CDecoder(CPGFStream *stream, PGFPreHeader &preHeader, PGFHeader &header, PGFPostHeader &postHeader, uint32_t *&levelLength, uint64_t &userDataPos, bool useOMP, uint32_t userDataPolicy)
Definition Decoder.cpp:74
uint32_t GetEncodedHeaderLength() const
Definition Decoder.h:131
void SetStreamPosToStart()
Resets stream position to beginning of PGF pre-header.
Definition Decoder.h:135
Abstract stream base class.
Definition PGFstream.h:39
virtual void SetPos(short posMode, int64_t posOff)=0
Wavelet channel class.
Definition Subband.h:42
PGF wavelet transform.
Definition PGFimage.h:33
int32_t DataT
Definition PGFtypes.h:367
constexpr uint32_t CodeBufferLen
number of words in code buffer (CodeBufferLen > BufferLen)
Definition PGFtypes.h:86
constexpr uint32_t BufferSize
must be a multiple of WordWidth, BufferSize <= UINT16_MAX
Definition PGFtypes.h:84
PGF header.
Definition PGFtypes.h:169
Optional PGF post-header.
Definition PGFtypes.h:199
PGF pre-header.
Definition PGFtypes.h:136
uint16_t bufferSize
number of uncoded uint32_t values in a block
Definition PGFtypes.h:219
Block header used with ROI coding scheme.
Definition PGFtypes.h:211
struct pgf::ROIBlockHeader::RBH rbh
ROI block header.