Scribus
Open source desktop publishing at your fingertips
Subband.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 #ifndef PGF_SUBBAND_H
30 #define PGF_SUBBAND_H
31 
32 #include "PGFtypes.h"
33 
34 class CEncoder;
35 class CDecoder;
36 class CRoiIndices;
37 
42 class CSubband {
43  friend class CWaveletTransform;
44 
45 public:
48  CSubband();
49 
52  ~CSubband();
53 
57  bool AllocMemory();
58 
61  void FreeMemory();
62 
71  void ExtractTile(CEncoder& encoder, bool tile = false, UINT32 tileX = 0, UINT32 tileY = 0) THROW_;
72 
81  void PlaceTile(CDecoder& decoder, int quantParam, bool tile = false, UINT32 tileX = 0, UINT32 tileY = 0) THROW_;
82 
88  void Quantize(int quantParam);
89 
95  void Dequantize(int quantParam);
96 
101  void SetData(UINT32 pos, DataT v) { ASSERT(pos < m_size); m_data[pos] = v; }
102 
106  DataT* GetBuffer() { return m_data; }
107 
112  DataT GetData(UINT32 pos) const { ASSERT(pos < m_size); return m_data[pos]; }
113 
117  int GetLevel() const { return m_level; }
118 
122  int GetHeight() const { return m_height; }
123 
127  int GetWidth() const { return m_width; }
128 
134  Orientation GetOrientation() const { return m_orientation; }
135 
136 #ifdef __PGFROISUPPORT__
137  void IncBuffRow(UINT32 pos) { m_dataPos = pos + BufferWidth(); }
141 
142 #endif
143 
144 private:
145  void Initialize(UINT32 width, UINT32 height, int level, Orientation orient);
146  void WriteBuffer(DataT val) { ASSERT(m_dataPos < m_size); m_data[m_dataPos++] = val; }
147  void SetBuffer(DataT* b) { ASSERT(b); m_data = b; }
148  DataT ReadBuffer() { ASSERT(m_dataPos < m_size); return m_data[m_dataPos++]; }
149 
150  UINT32 GetBuffPos() const { return m_dataPos; }
151 
152 #ifdef __PGFROISUPPORT__
153  UINT32 BufferWidth() const { return m_ROI.Width(); }
154  void TilePosition(UINT32 tileX, UINT32 tileY, UINT32& left, UINT32& top, UINT32& w, UINT32& h) const;
155  const PGFRect& GetROI() const { return m_ROI; }
156  void SetNTiles(UINT32 nTiles) { m_nTiles = nTiles; }
157  void SetROI(const PGFRect& roi) { ASSERT(roi.right <= m_width); ASSERT(roi.bottom <= m_height); m_ROI = roi; }
158  void InitBuffPos(UINT32 left = 0, UINT32 top = 0) { m_dataPos = top*BufferWidth() + left; ASSERT(m_dataPos < m_size); }
159 #else
160  void InitBuffPos() { m_dataPos = 0; }
161 #endif
162 
163 private:
164  UINT32 m_width;
165  UINT32 m_height;
166  UINT32 m_size;
167  int m_level;
168  Orientation m_orientation;
169  UINT32 m_dataPos;
170  DataT* m_data;
171 
172 #ifdef __PGFROISUPPORT__
173  PGFRect m_ROI;
174  UINT32 m_nTiles;
175 #endif
176 };
177 
178 #endif //PGF_SUBBAND_H
~CSubband()
Destructor.
Definition: Subband.cpp:51
PGF decoder.
Definition: Decoder.h:46
void FreeMemory()
Delete the memory buffer of this subband.
Definition: Subband.cpp:101
PGF wavelet transform.
Definition: WaveletTransform.h:84
void Quantize(int quantParam)
Definition: Subband.cpp:112
PGF encoder.
Definition: Encoder.h:46
void Dequantize(int quantParam)
Definition: Subband.cpp:154
const PGFRect & GetROI(int level) const
Definition: WaveletTransform.h:146
void PlaceTile(CDecoder &decoder, int quantParam, bool tile=false, UINT32 tileX=0, UINT32 tileY=0) THROW_
Definition: Subband.cpp:202
Wavelet channel class.
Definition: Subband.h:42
void ExtractTile(CEncoder &encoder, bool tile=false, UINT32 tileX=0, UINT32 tileY=0) THROW_
Definition: Subband.cpp:177
void IncBuffRow(UINT32 pos)
Definition: Subband.h:140
Orientation GetOrientation() const
Definition: Subband.h:134
PGF definitions.
CSubband()
Standard constructor.
Definition: Subband.cpp:35
DataT * GetBuffer()
Definition: Subband.h:106
int GetLevel() const
Definition: Subband.h:117
DataT GetData(UINT32 pos) const
Definition: Subband.h:112
int GetHeight() const
Definition: Subband.h:122
int GetWidth() const
Definition: Subband.h:127
void SetROI(const PGFRect &rect)
Definition: WaveletTransform.cpp:517
bool AllocMemory()
Definition: Subband.cpp:77
ROI indices.
Definition: WaveletTransform.h:45
void SetData(UINT32 pos, DataT v)
Definition: Subband.h:101
UINT32 Width() const
Definition: PGFtypes.h:205
Rectangle.
Definition: PGFtypes.h:194