libpgf  6.11.42
PGF - Progressive Graphics File
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 CROIs;
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 
72  void ExtractTile(CEncoder& encoder, bool tile = false, UINT32 tileX = 0, UINT32 tileY = 0) THROW_;
73 
82  void PlaceTile(CDecoder& decoder, int quantParam, bool tile = false, UINT32 tileX = 0, UINT32 tileY = 0) THROW_;
83 
89  void Quantize(int quantParam);
90 
96  void Dequantize(int quantParam);
97 
102  void SetData(UINT32 pos, DataT v) { ASSERT(pos < m_size); m_data[pos] = v; }
103 
107  DataT* GetBuffer() { return m_data; }
108 
113  DataT GetData(UINT32 pos) const { ASSERT(pos < m_size); return m_data[pos]; }
114 
118  int GetLevel() const { return m_level; }
119 
123  int GetHeight() const { return m_height; }
124 
128  int GetWidth() const { return m_width; }
129 
136 
137 #ifdef __PGFROISUPPORT__
138 
139 
140  UINT32 BufferWidth() const { return m_dataWidth; }
141 
145  void IncBuffRow(UINT32 pos) { m_dataPos = pos + m_dataWidth; }
146 
147 #endif
148 
149 private:
150  void Initialize(UINT32 width, UINT32 height, int level, Orientation orient);
151  void WriteBuffer(DataT val) { ASSERT(m_dataPos < m_size); m_data[m_dataPos++] = val; }
152  void SetBuffer(DataT* b) { ASSERT(b); m_data = b; }
153  DataT ReadBuffer() { ASSERT(m_dataPos < m_size); return m_data[m_dataPos++]; }
154 
155  UINT32 GetBuffPos() const { return m_dataPos; }
156 
157 #ifdef __PGFROISUPPORT__
158 // void IncBuffPos(UINT32 x, UINT32 y) { ASSERT(x < m_width); ASSERT(y < m_height); m_dataPos += y*m_width + x; }
159  void TilePosition(UINT32 tileX, UINT32 tileY, UINT32& left, UINT32& top, UINT32& w, UINT32& h) const;
160  void SetROI(CROIs* roi) { ASSERT(roi); m_ROIs = roi; }
161  void InitBuffPos(UINT32 left = 0, UINT32 top = 0) { m_dataPos = top*m_dataWidth + left; ASSERT(m_dataPos < m_size); }
162 #else
163  void InitBuffPos() { m_dataPos = 0; }
164 #endif
165 
166 // void PutData(INT16* buff, UINT32 width, bool low);
167 // void GetData(INT16* buff, UINT32 width, bool low);
168 // UINT32 GetSize() const { return m_size; }
169 // void SetWidth(UINT32 w) { m_width = w; }
170 // void SetHeight(UINT32 h) { m_height = h; }
171 // void SetSize(UINT32 s) { m_size = s; }
172 // void SetLevel(int l) { m_level = l; }
173 // void SetOrientation(Orientation o) { m_orientation = o; }
174 
175 private:
176  UINT32 m_width;
177  UINT32 m_height;
178  UINT32 m_size;
179  int m_level;
181  UINT32 m_dataPos;
183 
184 #ifdef __PGFROISUPPORT__
185  CROIs* m_ROIs;
186  UINT32 m_dataWidth;
187 #endif
188 };
189 /*
191 // store line of wavelet coefficients
192 // because the wavelet coefficients in buff are interleaved
193 // low determines whether the lowpass or highpass data is stored
194 inline void CSubband::PutData(INT16* buff, int width, bool low) {
195  ASSERT(m_dataPos + width/2 <= (UINT32)m_size);
196  int start = (low) ? 0 : 1;
197 
198  for (int i=start; i < width; i += 2) {
199  m_data[m_dataPos] = buff[i];
200  m_dataPos++;
201  }
202 }
203 
205 // get line of wavelet coefficients
206 // if low is true get the even coefficients in buff
207 inline void CSubband::GetData(INT16* buff, int width, bool low) {
208  ASSERT(m_dataPos + width/2 <= (UINT32)m_size);
209  int start = (low) ? 0 : 1;
210  //if (low) start = 0; else start = 1;
211  for (int i=start; i < width; i += 2) {
212  buff[i] = m_data[m_dataPos];
213  m_dataPos++;
214  }
215 }
216 */
217 
218 #endif //PGF_SUBBAND_H