libpgf  6.14.12
PGF - Progressive Graphics File
CSubband Class Reference

Wavelet channel class. More...

#include <Subband.h>

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

Friends

class CWaveletTransform
 

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()

CSubband::CSubband ( )

Standard constructor.

Definition at line 35 of file Subband.cpp.

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

◆ ~CSubband()

CSubband::~CSubband ( )

Destructor.

Definition at line 51 of file Subband.cpp.

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

Member Function Documentation

◆ AllocMemory()

bool 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 77 of file Subband.cpp.

77  {
78  UINT32 oldSize = m_size;
79 
80 #ifdef __PGFROISUPPORT__
81  m_size = BufferWidth()*m_ROI.Height();
82 #endif
83  ASSERT(m_size > 0);
84 
85  if (m_data) {
86  if (oldSize >= m_size) {
87  return true;
88  } else {
89  delete[] m_data;
90  m_data = new(std::nothrow) DataT[m_size];
91  return (m_data != 0);
92  }
93  } else {
94  m_data = new(std::nothrow) DataT[m_size];
95  return (m_data != 0);
96  }
97 }
DataT * m_data
buffer
Definition: Subband.h:170
INT32 DataT
Definition: PGFtypes.h:219
UINT32 m_size
size of data buffer m_data
Definition: Subband.h:166

◆ Dequantize()

void 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 154 of file Subband.cpp.

154  {
155  if (m_orientation == LL) {
156  quantParam -= m_level + 1;
157  } else if (m_orientation == HH) {
158  quantParam -= m_level - 1;
159  } else {
160  quantParam -= m_level;
161  }
162  if (quantParam > 0) {
163  for (UINT32 i=0; i < m_size; i++) {
164  m_data[i] <<= quantParam;
165  }
166  }
167 }
Definition: PGFtypes.h:92
DataT * m_data
buffer
Definition: Subband.h:170
UINT32 m_size
size of data buffer m_data
Definition: Subband.h:166
Definition: PGFtypes.h:92
int m_level
recursion level
Definition: Subband.h:167
Orientation m_orientation
0=LL, 1=HL, 2=LH, 3=HH L=lowpass filtered, H=highpass filterd
Definition: Subband.h:168

◆ ExtractTile()

void CSubband::ExtractTile ( CEncoder encoder,
bool  tile = false,
UINT32  tileX = 0,
UINT32  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 177 of file Subband.cpp.

177  {
178 #ifdef __PGFROISUPPORT__
179  if (tile) {
180  // compute tile position and size
181  UINT32 xPos, yPos, w, h;
182  TilePosition(tileX, tileY, xPos, yPos, w, h);
183 
184  // write values into buffer using partitiong scheme
185  encoder.Partition(this, w, h, xPos + yPos*m_width, m_width);
186  } else
187 #endif
188  {
189  // write values into buffer using partitiong scheme
190  encoder.Partition(this, m_width, m_height, 0, m_width);
191  }
192 }
UINT32 m_width
width in pixels
Definition: Subband.h:164
UINT32 m_height
height in pixels
Definition: Subband.h:165
void Partition(CSubband *band, int width, int height, int startPos, int pitch) THROW_
Definition: Encoder.cpp:246

◆ FreeMemory()

void CSubband::FreeMemory ( )

Delete the memory buffer of this subband.

Definition at line 101 of file Subband.cpp.

101  {
102  if (m_data) {
103  delete[] m_data; m_data = 0;
104  }
105 }
DataT * m_data
buffer
Definition: Subband.h:170

◆ GetBuffer()

DataT* 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 106 of file Subband.h.

106 { return m_data; }
DataT * m_data
buffer
Definition: Subband.h:170

◆ GetBuffPos()

UINT32 CSubband::GetBuffPos ( ) const
inlineprivate

Definition at line 150 of file Subband.h.

150 { return m_dataPos; }
UINT32 m_dataPos
current position in m_data
Definition: Subband.h:169

◆ GetData()

DataT CSubband::GetData ( UINT32  pos) const
inline

Return wavelet coefficient at given position.

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

Definition at line 112 of file Subband.h.

112 { ASSERT(pos < m_size); return m_data[pos]; }
DataT * m_data
buffer
Definition: Subband.h:170
UINT32 m_size
size of data buffer m_data
Definition: Subband.h:166

◆ GetHeight()

int CSubband::GetHeight ( ) const
inline

Return height of this subband.

Returns
Height of this subband (in pixels)

Definition at line 122 of file Subband.h.

122 { return m_height; }
UINT32 m_height
height in pixels
Definition: Subband.h:165

◆ GetLevel()

int CSubband::GetLevel ( ) const
inline

Return level of this subband.

Returns
Level of this subband

Definition at line 117 of file Subband.h.

117 { return m_level; }
int m_level
recursion level
Definition: Subband.h:167

◆ GetOrientation()

Orientation 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 134 of file Subband.h.

134 { return m_orientation; }
Orientation m_orientation
0=LL, 1=HL, 2=LH, 3=HH L=lowpass filtered, H=highpass filterd
Definition: Subband.h:168

◆ GetWidth()

int CSubband::GetWidth ( ) const
inline

Return width of this subband.

Returns
Width of this subband (in pixels)

Definition at line 127 of file Subband.h.

127 { return m_width; }
UINT32 m_width
width in pixels
Definition: Subband.h:164

◆ InitBuffPos()

void CSubband::InitBuffPos ( )
inlineprivate

Definition at line 160 of file Subband.h.

160 { m_dataPos = 0; }
UINT32 m_dataPos
current position in m_data
Definition: Subband.h:169

◆ Initialize()

void CSubband::Initialize ( UINT32  width,
UINT32  height,
int  level,
Orientation  orient 
)
private

Definition at line 57 of file Subband.cpp.

57  {
58  m_width = width;
59  m_height = height;
61  m_level = level;
62  m_orientation = orient;
63  m_data = 0;
64  m_dataPos = 0;
65 #ifdef __PGFROISUPPORT__
66  m_ROI.left = 0;
67  m_ROI.top = 0;
68  m_ROI.right = m_width;
69  m_ROI.bottom = m_height;
70  m_nTiles = 0;
71 #endif
72 }
DataT * m_data
buffer
Definition: Subband.h:170
UINT32 m_width
width in pixels
Definition: Subband.h:164
UINT32 m_height
height in pixels
Definition: Subband.h:165
UINT32 m_size
size of data buffer m_data
Definition: Subband.h:166
int m_level
recursion level
Definition: Subband.h:167
UINT32 m_dataPos
current position in m_data
Definition: Subband.h:169
Orientation m_orientation
0=LL, 1=HL, 2=LH, 3=HH L=lowpass filtered, H=highpass filterd
Definition: Subband.h:168

◆ PlaceTile()

void CSubband::PlaceTile ( CDecoder decoder,
int  quantParam,
bool  tile = false,
UINT32  tileX = 0,
UINT32  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 202 of file Subband.cpp.

202  {
203  // allocate memory
204  if (!AllocMemory()) ReturnWithError(InsufficientMemory);
205 
206  // correct quantParam with normalization factor
207  if (m_orientation == LL) {
208  quantParam -= m_level + 1;
209  } else if (m_orientation == HH) {
210  quantParam -= m_level - 1;
211  } else {
212  quantParam -= m_level;
213  }
214  if (quantParam < 0) quantParam = 0;
215 
216 #ifdef __PGFROISUPPORT__
217  if (tile) {
218  UINT32 xPos, yPos, w, h;
219 
220  // compute tile position and size
221  TilePosition(tileX, tileY, xPos, yPos, w, h);
222 
223  ASSERT(xPos >= m_ROI.left && yPos >= m_ROI.top);
224  decoder.Partition(this, quantParam, w, h, (xPos - m_ROI.left) + (yPos - m_ROI.top)*BufferWidth(), BufferWidth());
225  } else
226 #endif
227  {
228  // read values into buffer using partitiong scheme
229  decoder.Partition(this, quantParam, m_width, m_height, 0, m_width);
230  }
231 }
Definition: PGFtypes.h:92
UINT32 m_width
width in pixels
Definition: Subband.h:164
UINT32 m_height
height in pixels
Definition: Subband.h:165
bool AllocMemory()
Definition: Subband.cpp:77
void Partition(CSubband *band, int quantParam, int width, int height, int startPos, int pitch) THROW_
Definition: Decoder.cpp:252
Definition: PGFtypes.h:92
int m_level
recursion level
Definition: Subband.h:167
Orientation m_orientation
0=LL, 1=HL, 2=LH, 3=HH L=lowpass filtered, H=highpass filterd
Definition: Subband.h:168

◆ Quantize()

void 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 112 of file Subband.cpp.

112  {
113  if (m_orientation == LL) {
114  quantParam -= (m_level + 1);
115  // uniform rounding quantization
116  if (quantParam > 0) {
117  quantParam--;
118  for (UINT32 i=0; i < m_size; i++) {
119  if (m_data[i] < 0) {
120  m_data[i] = -(((-m_data[i] >> quantParam) + 1) >> 1);
121  } else {
122  m_data[i] = ((m_data[i] >> quantParam) + 1) >> 1;
123  }
124  }
125  }
126  } else {
127  if (m_orientation == HH) {
128  quantParam -= (m_level - 1);
129  } else {
130  quantParam -= m_level;
131  }
132  // uniform deadzone quantization
133  if (quantParam > 0) {
134  int threshold = ((1 << quantParam) * 7)/5; // good value
135  quantParam--;
136  for (UINT32 i=0; i < m_size; i++) {
137  if (m_data[i] < -threshold) {
138  m_data[i] = -(((-m_data[i] >> quantParam) + 1) >> 1);
139  } else if (m_data[i] > threshold) {
140  m_data[i] = ((m_data[i] >> quantParam) + 1) >> 1;
141  } else {
142  m_data[i] = 0;
143  }
144  }
145  }
146  }
147 }
Definition: PGFtypes.h:92
DataT * m_data
buffer
Definition: Subband.h:170
UINT32 m_size
size of data buffer m_data
Definition: Subband.h:166
Definition: PGFtypes.h:92
int m_level
recursion level
Definition: Subband.h:167
Orientation m_orientation
0=LL, 1=HL, 2=LH, 3=HH L=lowpass filtered, H=highpass filterd
Definition: Subband.h:168

◆ ReadBuffer()

DataT CSubband::ReadBuffer ( )
inlineprivate

Definition at line 148 of file Subband.h.

148 { ASSERT(m_dataPos < m_size); return m_data[m_dataPos++]; }
DataT * m_data
buffer
Definition: Subband.h:170
UINT32 m_size
size of data buffer m_data
Definition: Subband.h:166
UINT32 m_dataPos
current position in m_data
Definition: Subband.h:169

◆ SetBuffer()

void CSubband::SetBuffer ( DataT b)
inlineprivate

Definition at line 147 of file Subband.h.

147 { ASSERT(b); m_data = b; }
DataT * m_data
buffer
Definition: Subband.h:170

◆ SetData()

void CSubband::SetData ( UINT32  pos,
DataT  v 
)
inline

Store wavelet coefficient in subband at given position.

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

Definition at line 101 of file Subband.h.

101 { ASSERT(pos < m_size); m_data[pos] = v; }
DataT * m_data
buffer
Definition: Subband.h:170
UINT32 m_size
size of data buffer m_data
Definition: Subband.h:166

◆ WriteBuffer()

void CSubband::WriteBuffer ( DataT  val)
inlineprivate

Definition at line 146 of file Subband.h.

146 { ASSERT(m_dataPos < m_size); m_data[m_dataPos++] = val; }
DataT * m_data
buffer
Definition: Subband.h:170
UINT32 m_size
size of data buffer m_data
Definition: Subband.h:166
UINT32 m_dataPos
current position in m_data
Definition: Subband.h:169

Friends And Related Function Documentation

◆ CWaveletTransform

friend class CWaveletTransform
friend

Definition at line 43 of file Subband.h.

Member Data Documentation

◆ m_data

DataT* CSubband::m_data
private

buffer

Definition at line 170 of file Subband.h.

◆ m_dataPos

UINT32 CSubband::m_dataPos
private

current position in m_data

Definition at line 169 of file Subband.h.

◆ m_height

UINT32 CSubband::m_height
private

height in pixels

Definition at line 165 of file Subband.h.

◆ m_level

int CSubband::m_level
private

recursion level

Definition at line 167 of file Subband.h.

◆ m_orientation

Orientation CSubband::m_orientation
private

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

Definition at line 168 of file Subband.h.

◆ m_size

UINT32 CSubband::m_size
private

size of data buffer m_data

Definition at line 166 of file Subband.h.

◆ m_width

UINT32 CSubband::m_width
private

width in pixels

Definition at line 164 of file Subband.h.


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