libpgf: CSubband Class Reference

| libpgf 7.21.2 PGF - Progressive Graphics File

Loading...
Searching...
No Matches
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 tileX=0, UINT32 tileY=0)
void | PlaceTile (CDecoder &decoder, int quantParam, bool tile=false, UINT32 tileX=0, UINT32 tileY=0)
void | Quantize (int quantParam)
void | Dequantize (int quantParam)
void | SetData (UINT32 pos, DataT v)
DataT * | GetBuffer ()
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
UINT32 | m_height
| height in pixels
UINT32 | m_size
| size of data buffer m_data
int | m_level
| recursion level
Orientation | m_orientation
| 0=LL, 1=HL, 2=LH, 3=HH L=lowpass filtered, H=highpass filterd
UINT32 | 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()

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)
40, m_orientation(LL)
41, m_data(0)
42, m_dataPos(0)
43#ifdef __PGFROISUPPORT__
44, m_nTiles(0)
45#endif
46{
47}
LL
@ LL
Definition PGFtypes.h:99
CSubband::m_size
UINT32 m_size
size of data buffer m_data
Definition Subband.h:168
CSubband::m_dataPos
UINT32 m_dataPos
current position in m_data
Definition Subband.h:171
CSubband::m_height
UINT32 m_height
height in pixels
Definition Subband.h:167
CSubband::m_orientation
Orientation m_orientation
0=LL, 1=HL, 2=LH, 3=HH L=lowpass filtered, H=highpass filterd
Definition Subband.h:170
CSubband::m_data
DataT * m_data
buffer
Definition Subband.h:172
CSubband::m_level
int m_level
recursion level
Definition Subband.h:169
CSubband::m_width
UINT32 m_width
width in pixels
Definition Subband.h:166

## ◆ ~CSubband()

CSubband::~CSubband | ( |  | ) |

Destructor.

Definition at line 51 of file Subband.cpp.

51 {
52 FreeMemory();
53}
CSubband::FreeMemory
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
INT32 DataT
Definition PGFtypes.h:269

## ◆ 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

  quantParam | A 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}
HH
@ HH
Definition PGFtypes.h:99

## ◆ 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

  encoder | An encoder instance
  tile | True if just a rectangular region is extracted, false if the entire subband is extracted.
  tileX | Tile index in x-direction
  tileY | Tile 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 tileX; tileY; tile; // prevents from unreferenced formal parameter warning
190 // write values into buffer using partitiong scheme
191 encoder.Partition(this, m_width, m_height, 0, m_width);
192 }
193}
CEncoder::Partition
void Partition(CSubband *band, int width, int height, int startPos, int pitch)
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}

## ◆ 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 107 of file Subband.h.

107{ return m_data; }

## ◆ GetBuffPos()

UINT32 CSubband::GetBuffPos | ( |  | ) | const
| inlineprivate

Definition at line 151 of file Subband.h.

151{ return m_dataPos; }

## ◆ GetData()

DataT CSubband::GetData | ( | UINT32 | pos | ) | const
| inline

Return wavelet coefficient at given position.

Parameters

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

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

135{ return m_orientation; }

## ◆ GetWidth()

int 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 CSubband::InitBuffPos | ( |  | ) |
| inlineprivate

Definition at line 162 of file Subband.h.

162{ m_dataPos = 0; }

## ◆ 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;
60 m_size = m_width*m_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}

## ◆ 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

  decoder | A decoder instance
  quantParam | Dequantization value
  tile | True if just a rectangular region is placed, false if the entire subband is placed.
  tileX | Tile index in x-direction
  tileY | Tile index in y-direction

Definition at line 203 of file Subband.cpp.

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

## ◆ 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

  quantParam | A 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}

## ◆ ReadBuffer()

DataT CSubband::ReadBuffer | ( |  | ) |
| inlineprivate

Definition at line 149 of file Subband.h.

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

## ◆ SetBuffer()

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

Definition at line 148 of file Subband.h.

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

## ◆ SetData()

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

Store wavelet coefficient in subband at given position.

Parameters

  pos | A subband position (>= 0)
  v | A wavelet coefficient

Definition at line 102 of file Subband.h.

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

## ◆ WriteBuffer()

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

Definition at line 147 of file Subband.h.

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

## Friends And Related Symbol Documentation

## ◆ 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* CSubband::m_data
| private

buffer

Definition at line 172 of file Subband.h.

## ◆ m_dataPos

UINT32 CSubband::m_dataPos
| private

current position in m_data

Definition at line 171 of file Subband.h.

## ◆ m_height

UINT32 CSubband::m_height
| private

height in pixels

Definition at line 167 of file Subband.h.

## ◆ m_level

int CSubband::m_level
| private

recursion level

Definition at line 169 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 170 of file Subband.h.

## ◆ m_size

UINT32 CSubband::m_size
| private

size of data buffer m_data

Definition at line 168 of file Subband.h.

## ◆ m_width

UINT32 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:

- Subband.h
- Subband.cpp