libpgf 7.26.45
PGF - Progressive Graphics File
Loading...
Searching...
No Matches
pgf::CSubband Class Reference

Wavelet channel class. More...

#include <Subband.h>

Public Member Functions

 CSubband ()
 Standard constructor.
 ~CSubband ()
 Destructor.
bool AllocMemory ()
void FreeMemory ()
 Delete the memory buffer of this subband.
void ExtractTile (CEncoder &encoder, bool tile=false, uint32_t tileX=0, uint32_t tileY=0)
void PlaceTile (CDecoder &decoder, int quantParam, bool tile=false, uint32_t tileX=0, uint32_t tileY=0)
void Quantize (int quantParam)
void Dequantize (int quantParam)
void SetData (uint32_t pos, DataT v)
DataT * GetBuffer ()
DataT GetData (uint32_t pos) const
int GetLevel () const
int GetHeight () const
int GetWidth () const
Orient::Orientation GetOrientation () const

Private Member Functions

void Initialize (uint32_t width, uint32_t height, int level, Orient::Orientation orient)
void WriteBuffer (DataT val)
void SetBuffer (DataT *b)
DataT ReadBuffer ()
uint32_t GetBuffPos () const
void InitBuffPos ()

Private Attributes

uint32_t m_width
 width in pixels
uint32_t m_height
 height in pixels
uint32_t m_size
 size of data buffer m_data
int m_level
 recursion level
Orient::Orientation m_orientation
 0=LL, 1=HL, 2=LH, 3=HH L=lowpass filtered, H=highpass filterd
uint32_t m_dataPos
 current position in m_data
DataT * m_data
 buffer

Friends

class CWaveletTransform
class CRoiIndices

Detailed Description

Wavelet channel class.

PGF wavelet channel subband class.

Author
C. Stamm, R. Spuler

Definition at line 42 of file Subband.h.

Constructor & Destructor Documentation

◆ CSubband()

pgf::CSubband::CSubband ( )

Standard constructor.

Definition at line 36 of file Subband.cpp.

37 : m_width(0)
38 , m_height(0)
39 , m_size(0)
40 , m_level(0)
42 , m_data(0)
43 , m_dataPos(0)
44#ifdef __PGFROISUPPORT__
45 , m_nTiles(0)
46#endif
47 {
48 }
int m_level
recursion level
Definition Subband.h:169
uint32_t m_height
height in pixels
Definition Subband.h:167
uint32_t m_dataPos
current position in m_data
Definition Subband.h:171
uint32_t m_size
size of data buffer m_data
Definition Subband.h:168
Orient::Orientation m_orientation
0=LL, 1=HL, 2=LH, 3=HH L=lowpass filtered, H=highpass filterd
Definition Subband.h:170
DataT * m_data
buffer
Definition Subband.h:172
uint32_t m_width
width in pixels
Definition Subband.h:166
constexpr Orientation LL
Definition PGFtypes.h:104

◆ ~CSubband()

pgf::CSubband::~CSubband ( )

Destructor.

Definition at line 52 of file Subband.cpp.

52 {
53 FreeMemory();
54 }
void FreeMemory()
Delete the memory buffer of this subband.
Definition Subband.cpp:102

Member Function Documentation

◆ AllocMemory()

bool pgf::CSubband::AllocMemory ( )

Allocate a memory buffer to store all wavelet coefficients of this subband.

Returns
True if the allocation did work without any problems

Definition at line 78 of file Subband.cpp.

78 {
79 uint32_t oldSize = m_size;
80
81#ifdef __PGFROISUPPORT__
82 m_size = BufferWidth()*m_ROI.Height();
83#endif
84 ASSERT(m_size > 0);
85
86 if (m_data) {
87 if (oldSize >= m_size) {
88 return true;
89 } else {
90 delete[] m_data;
91 m_data = new(std::nothrow) DataT[m_size];
92 return (m_data != 0);
93 }
94 } else {
95 m_data = new(std::nothrow) DataT[m_size];
96 return (m_data != 0);
97 }
98 }
int32_t DataT
Definition PGFtypes.h:367

◆ Dequantize()

void pgf::CSubband::Dequantize ( int quantParam)

Perform subband dequantization with given quantization parameter. A scalar quantization (with dead-zone) is used. A large quantization value results in strong quantization and therefore in big quality loss.

Parameters
quantParamA quantization parameter (larger or equal to 0)

Definition at line 155 of file Subband.cpp.

155 {
156 if (m_orientation == Orient::LL) {
157 quantParam -= m_level + 1;
158 } else if (m_orientation == Orient::HH) {
159 quantParam -= m_level - 1;
160 } else {
161 quantParam -= m_level;
162 }
163 if (quantParam > 0) {
164 for (uint32_t i = 0; i < m_size; i++) {
165 m_data[i] <<= quantParam;
166 }
167 }
168 }
constexpr Orientation HH
Definition PGFtypes.h:107

◆ ExtractTile()

void pgf::CSubband::ExtractTile ( CEncoder & encoder,
bool tile = false,
uint32_t tileX = 0,
uint32_t tileY = 0 )

Extracts a rectangular subregion of this subband. Write wavelet coefficients into buffer. It might throw an IOException.

Parameters
encoderAn encoder instance
tileTrue if just a rectangular region is extracted, false if the entire subband is extracted.
tileXTile index in x-direction
tileYTile index in y-direction

Definition at line 178 of file Subband.cpp.

178 {
179#ifdef __PGFROISUPPORT__
180 if (tile) {
181 // compute tile position and size
182 uint32_t xPos, yPos, w, h;
183 TilePosition(tileX, tileY, xPos, yPos, w, h);
184
185 // write values into buffer using partitiong scheme
186 encoder.Partition(this, w, h, xPos + yPos*m_width, m_width);
187 } else
188#endif
189 {
190 tileX; tileY; tile; // prevents from unreferenced formal parameter warning
191 // write values into buffer using partitiong scheme
192 encoder.Partition(this, m_width, m_height, 0, m_width);
193 }
194 }

◆ FreeMemory()

void pgf::CSubband::FreeMemory ( )

Delete the memory buffer of this subband.

Definition at line 102 of file Subband.cpp.

102 {
103 if (m_data) {
104 delete[] m_data; m_data = 0;
105 }
106 }

◆ GetBuffer()

DataT * pgf::CSubband::GetBuffer ( )
inline

Get a pointer to an array of all wavelet coefficients of this subband.

Returns
Pointer to array of wavelet coefficients

Definition at line 107 of file Subband.h.

107{ return m_data; }

◆ GetBuffPos()

uint32_t pgf::CSubband::GetBuffPos ( ) const
inlineprivate

Definition at line 151 of file Subband.h.

151{ return m_dataPos; }

◆ GetData()

DataT pgf::CSubband::GetData ( uint32_t pos) const
inline

Return wavelet coefficient at given position.

Parameters
posA subband position (>= 0)
Returns
Wavelet coefficient

Definition at line 113 of file Subband.h.

113{ ASSERT(pos < m_size); return m_data[pos]; }

◆ GetHeight()

int pgf::CSubband::GetHeight ( ) const
inline

Return height of this subband.

Returns
Height of this subband (in pixels)

Definition at line 123 of file Subband.h.

123{ return m_height; }

◆ GetLevel()

int pgf::CSubband::GetLevel ( ) const
inline

Return level of this subband.

Returns
Level of this subband

Definition at line 118 of file Subband.h.

118{ return m_level; }

◆ GetOrientation()

Orient::Orientation pgf::CSubband::GetOrientation ( ) const
inline

Return orientation of this subband. LL LH HL HH

Returns
Orientation of this subband (LL, HL, LH, HH)

Definition at line 135 of file Subband.h.

135{ return m_orientation; }

◆ GetWidth()

int pgf::CSubband::GetWidth ( ) const
inline

Return width of this subband.

Returns
Width of this subband (in pixels)

Definition at line 128 of file Subband.h.

128{ return m_width; }

◆ InitBuffPos()

void pgf::CSubband::InitBuffPos ( )
inlineprivate

Definition at line 162 of file Subband.h.

162{ m_dataPos = 0; }

◆ Initialize()

void pgf::CSubband::Initialize ( uint32_t width,
uint32_t height,
int level,
Orient::Orientation orient )
private

Definition at line 58 of file Subband.cpp.

58 {
59 m_width = width;
60 m_height = height;
62 m_level = level;
63 m_orientation = orient;
64 m_data = 0;
65 m_dataPos = 0;
66#ifdef __PGFROISUPPORT__
67 m_ROI.left = 0;
68 m_ROI.top = 0;
69 m_ROI.right = m_width;
70 m_ROI.bottom = m_height;
71 m_nTiles = 0;
72#endif
73 }

◆ PlaceTile()

void pgf::CSubband::PlaceTile ( CDecoder & decoder,
int quantParam,
bool tile = false,
uint32_t tileX = 0,
uint32_t tileY = 0 )

Decoding and dequantization of this subband. It might throw an IOException.

Parameters
decoderA decoder instance
quantParamDequantization value
tileTrue if just a rectangular region is placed, false if the entire subband is placed.
tileXTile index in x-direction
tileYTile index in y-direction

Definition at line 204 of file Subband.cpp.

204 {
205 // allocate memory
206 if (!AllocMemory()) ReturnWithError(InsufficientMemory);
207
208 // correct quantParam with normalization factor
209 if (m_orientation == Orient::LL) {
210 quantParam -= m_level + 1;
211 } else if (m_orientation == Orient::HH) {
212 quantParam -= m_level - 1;
213 } else {
214 quantParam -= m_level;
215 }
216 if (quantParam < 0) quantParam = 0;
217
218#ifdef __PGFROISUPPORT__
219 if (tile) {
220 uint32_t xPos, yPos, w, h;
221
222 // compute tile position and size
223 TilePosition(tileX, tileY, xPos, yPos, w, h);
224
225 ASSERT(xPos >= m_ROI.left && yPos >= m_ROI.top);
226 decoder.Partition(this, quantParam, w, h, (xPos - m_ROI.left) + (yPos - m_ROI.top)*BufferWidth(), BufferWidth());
227 } else
228#endif
229 {
230 tileX; tileY; tile; // prevents from unreferenced formal parameter warning
231 // read values into buffer using partitiong scheme
232 decoder.Partition(this, quantParam, m_width, m_height, 0, m_width);
233 }
234 }
bool AllocMemory()
Definition Subband.cpp:78

◆ Quantize()

void pgf::CSubband::Quantize ( int quantParam)

Perform subband quantization with given quantization parameter. A scalar quantization (with dead-zone) is used. A large quantization value results in strong quantization and therefore in big quality loss.

Parameters
quantParamA quantization parameter (larger or equal to 0)

Definition at line 113 of file Subband.cpp.

113 {
114 if (m_orientation == Orient::LL) {
115 quantParam -= (m_level + 1);
116 // uniform rounding quantization
117 if (quantParam > 0) {
118 quantParam--;
119 for (uint32_t i = 0; i < m_size; i++) {
120 if (m_data[i] < 0) {
121 m_data[i] = -(((-m_data[i] >> quantParam) + 1) >> 1);
122 } else {
123 m_data[i] = ((m_data[i] >> quantParam) + 1) >> 1;
124 }
125 }
126 }
127 } else {
128 if (m_orientation == Orient::HH) {
129 quantParam -= (m_level - 1);
130 } else {
131 quantParam -= m_level;
132 }
133 // uniform deadzone quantization
134 if (quantParam > 0) {
135 int threshold = ((1 << quantParam) * 7)/5; // good value
136 quantParam--;
137 for (uint32_t i = 0; i < m_size; i++) {
138 if (m_data[i] < -threshold) {
139 m_data[i] = -(((-m_data[i] >> quantParam) + 1) >> 1);
140 } else if (m_data[i] > threshold) {
141 m_data[i] = ((m_data[i] >> quantParam) + 1) >> 1;
142 } else {
143 m_data[i] = 0;
144 }
145 }
146 }
147 }
148 }

◆ ReadBuffer()

DataT pgf::CSubband::ReadBuffer ( )
inlineprivate

Definition at line 149 of file Subband.h.

149{ ASSERT(m_dataPos < m_size); return m_data[m_dataPos++]; }

◆ SetBuffer()

void pgf::CSubband::SetBuffer ( DataT * b)
inlineprivate

Definition at line 148 of file Subband.h.

148{ ASSERT(b); m_data = b; }

◆ SetData()

void pgf::CSubband::SetData ( uint32_t pos,
DataT v )
inline

Store wavelet coefficient in subband at given position.

Parameters
posA subband position (>= 0)
vA wavelet coefficient

Definition at line 102 of file Subband.h.

102{ ASSERT(pos < m_size); m_data[pos] = v; }

◆ WriteBuffer()

void pgf::CSubband::WriteBuffer ( DataT val)
inlineprivate

Definition at line 147 of file Subband.h.

147{ ASSERT(m_dataPos < m_size); m_data[m_dataPos++] = val; }

◆ CRoiIndices

friend class CRoiIndices
friend

Definition at line 44 of file Subband.h.

◆ CWaveletTransform

friend class CWaveletTransform
friend

Definition at line 43 of file Subband.h.

Member Data Documentation

◆ m_data

DataT* pgf::CSubband::m_data
private

buffer

Definition at line 172 of file Subband.h.

◆ m_dataPos

uint32_t pgf::CSubband::m_dataPos
private

current position in m_data

Definition at line 171 of file Subband.h.

◆ m_height

uint32_t pgf::CSubband::m_height
private

height in pixels

Definition at line 167 of file Subband.h.

◆ m_level

int pgf::CSubband::m_level
private

recursion level

Definition at line 169 of file Subband.h.

◆ m_orientation

Orient::Orientation pgf::CSubband::m_orientation
private

0=LL, 1=HL, 2=LH, 3=HH L=lowpass filtered, H=highpass filterd

Definition at line 170 of file Subband.h.

◆ m_size

uint32_t pgf::CSubband::m_size
private

size of data buffer m_data

Definition at line 168 of file Subband.h.

◆ m_width

uint32_t pgf::CSubband::m_width
private

width in pixels

Definition at line 166 of file Subband.h.


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