libpgf
6.11.42
PGF - Progressive Graphics File
|
Wavelet channel class. More...
#include <Subband.h>
Public Member Functions | |
CSubband () | |
~CSubband () | |
bool | AllocMemory () |
void | FreeMemory () |
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) |
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 |
Standard constructor.
Definition at line 35 of file Subband.cpp.
bool CSubband::AllocMemory | ( | ) |
Allocate a memory buffer to store all wavelet coefficients of this subband.
Definition at line 68 of file Subband.cpp.
{ UINT32 oldSize = m_size; #ifdef __PGFROISUPPORT__ if (m_ROIs) { // reset dataWidth and size const PGFRect& roi = m_ROIs->GetROI(m_level); m_dataWidth = __min(m_width, roi.right) - roi.left; ASSERT(m_dataWidth > 0); m_size = m_dataWidth*(__min(m_height, roi.bottom) - roi.top); } #endif ASSERT(m_size > 0); if (m_data) { if (oldSize >= m_size) { return true; } else { delete[] m_data; m_data = new(std::nothrow) DataT[m_size]; return (m_data != 0); } } else { m_data = new(std::nothrow) DataT[m_size]; return (m_data != 0); } }
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.
quantParam | A quantization parameter (larger or equal to 0) |
Definition at line 151 of file Subband.cpp.
{ if (m_orientation == LL) { quantParam -= m_level + 1; } else if (m_orientation == HH) { quantParam -= m_level - 1; } else { quantParam -= m_level; } if (quantParam > 0) { for (UINT32 i=0; i < m_size; i++) { m_data[i] <<= quantParam; } } }
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.
encoder | An encoder instance |
quant | A quantization value (linear scalar quantization) |
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 |
Extracts a rectangular subregion of this subband. Write wavelet coefficients into buffer. It might throw an IOException.
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 174 of file Subband.cpp.
{ #ifdef __PGFROISUPPORT__ if (tile) { // compute tile position and size UINT32 xPos, yPos, w, h; TilePosition(tileX, tileY, xPos, yPos, w, h); // write values into buffer using partitiong scheme encoder.Partition(this, w, h, xPos + yPos*m_width, m_width); } else #endif { // write values into buffer using partitiong scheme encoder.Partition(this, m_width, m_height, 0, m_width); } }
void CSubband::FreeMemory | ( | ) |
Delete the memory buffer of this subband.
Definition at line 98 of file Subband.cpp.
DataT* CSubband::GetBuffer | ( | ) | [inline] |
UINT32 CSubband::GetBuffPos | ( | ) | const [inline, private] |
DataT CSubband::GetData | ( | UINT32 | pos | ) | const [inline] |
int CSubband::GetHeight | ( | ) | const [inline] |
int CSubband::GetLevel | ( | ) | const [inline] |
Orientation CSubband::GetOrientation | ( | ) | const [inline] |
Return orientation of this subband. LL LH HL HH
Definition at line 135 of file Subband.h.
{ return m_orientation; }
int CSubband::GetWidth | ( | ) | const [inline] |
void CSubband::InitBuffPos | ( | ) | [inline, private] |
void CSubband::Initialize | ( | UINT32 | width, |
UINT32 | height, | ||
int | level, | ||
Orientation | orient | ||
) | [private] |
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.
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 199 of file Subband.cpp.
{ // allocate memory if (!AllocMemory()) ReturnWithError(InsufficientMemory); // correct quantParam with normalization factor if (m_orientation == LL) { quantParam -= m_level + 1; } else if (m_orientation == HH) { quantParam -= m_level - 1; } else { quantParam -= m_level; } if (quantParam < 0) quantParam = 0; #ifdef __PGFROISUPPORT__ if (tile) { // compute tile position and size const PGFRect& roi = m_ROIs->GetROI(m_level); UINT32 xPos, yPos, w, h; TilePosition(tileX, tileY, xPos, yPos, w, h); // read values into buffer using partitiong scheme decoder.Partition(this, quantParam, w, h, (xPos - roi.left) + (yPos - roi.top)*m_dataWidth, m_dataWidth); } else #endif { // read values into buffer using partitiong scheme decoder.Partition(this, quantParam, m_width, m_height, 0, m_width); } }
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.
quantParam | A quantization parameter (larger or equal to 0) |
Definition at line 109 of file Subband.cpp.
{ if (m_orientation == LL) { quantParam -= (m_level + 1); // uniform rounding quantization if (quantParam > 0) { quantParam--; for (UINT32 i=0; i < m_size; i++) { if (m_data[i] < 0) { m_data[i] = -(((-m_data[i] >> quantParam) + 1) >> 1); } else { m_data[i] = ((m_data[i] >> quantParam) + 1) >> 1; } } } } else { if (m_orientation == HH) { quantParam -= (m_level - 1); } else { quantParam -= m_level; } // uniform deadzone quantization if (quantParam > 0) { int threshold = ((1 << quantParam) * 7)/5; // good value quantParam--; for (UINT32 i=0; i < m_size; i++) { if (m_data[i] < -threshold) { m_data[i] = -(((-m_data[i] >> quantParam) + 1) >> 1); } else if (m_data[i] > threshold) { m_data[i] = ((m_data[i] >> quantParam) + 1) >> 1; } else { m_data[i] = 0; } } } } }
DataT CSubband::ReadBuffer | ( | ) | [inline, private] |
void CSubband::SetBuffer | ( | DataT * | b | ) | [inline, private] |
void CSubband::SetData | ( | UINT32 | pos, |
DataT | v | ||
) | [inline] |
void CSubband::WriteBuffer | ( | DataT | val | ) | [inline, private] |
friend class CWaveletTransform [friend] |
DataT* CSubband::m_data [private] |
UINT32 CSubband::m_dataPos [private] |
UINT32 CSubband::m_height [private] |
int CSubband::m_level [private] |
Orientation CSubband::m_orientation [private] |
UINT32 CSubband::m_size [private] |
UINT32 CSubband::m_width [private] |