libpgf  6.11.42
PGF - Progressive Graphics File
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
WaveletTransform.h
Go to the documentation of this file.
1 /*
2  * The Progressive Graphics File; http://www.libpgf.org
3  *
4  * $Date: 2006-05-18 16:03:32 +0200 (Do, 18 Mai 2006) $
5  * $Revision: 194 $
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_WAVELETTRANSFORM_H
30 #define PGF_WAVELETTRANSFORM_H
31 
32 #include "PGFtypes.h"
33 #include "Subband.h"
34 
36 // Constants
37 #define FilterWidth 5
38 #define FilterHeight 3
39 
40 #ifdef __PGFROISUPPORT__
41 
42 
43 
44 
45 class CROIs {
46  friend class CWaveletTransform;
47 
51  CROIs(int levels) : m_nLevels(levels), m_ROIs(0), m_indices(0) { ASSERT(levels > 0); }
52 
55  ~CROIs() { Destroy(); }
56 
57  void Destroy() { delete[] m_ROIs; m_ROIs = 0; delete[] m_indices; m_indices = 0; }
58  void CreateROIs();
59  void CreateIndices();
60  void ComputeIndices(UINT32 width, UINT32 height, const PGFRect& rect);
61  void SetROI(int level, const PGFRect& rect) { ASSERT(m_ROIs); ASSERT(level >= 0 && level < m_nLevels); m_ROIs[level] = rect; }
62  const PGFRect& GetIndices(int level) const { ASSERT(m_indices); ASSERT(level >= 0 && level < m_nLevels); return m_indices[level]; }
63  UINT32 Left(int level) const { ASSERT(m_ROIs); ASSERT(level >= 0 && level < m_nLevels); return m_ROIs[level].left; }
64  UINT32 Top(int level) const { ASSERT(m_ROIs); ASSERT(level >= 0 && level < m_nLevels); return m_ROIs[level].top; }
65  bool ROIisSupported() const { return m_ROIs != 0; }
66  void ComputeTileIndex(UINT32 width, UINT32 height, UINT32 pos, bool horizontal, bool isMin);
67 
68 public:
72  UINT32 GetNofTiles(int level) const { ASSERT(level >= 0 && level < m_nLevels); return 1 << (m_nLevels - level - 1); }
73 
77  const PGFRect& GetROI(int level) const { ASSERT(m_ROIs); ASSERT(level >= 0 && level < m_nLevels); return m_ROIs[level]; }
78 
79 private:
80  int m_nLevels;
81  PGFRect *m_ROIs;
82  PGFRect *m_indices;
83 
84 };
85 #endif //__PGFROISUPPORT__
86 
87 
93  friend class CSubband;
94 
95 public:
102  CWaveletTransform(UINT32 width, UINT32 height, int levels, DataT* data = NULL);
103 
107 
114  OSError ForwardTransform(int level, int quant);
115 
124  OSError InverseTransform(int level, UINT32* width, UINT32* height, DataT** data);
125 
130  CSubband* GetSubband(int level, Orientation orientation) {
131  ASSERT(level >= 0 && level < m_nLevels);
132  return &m_subband[level][orientation];
133  }
134 
135 #ifdef __PGFROISUPPORT__
136 
137 
138 
139  void SetROI(const PGFRect& rect);
140 
143  void SetROI();
144 
148  const PGFRect& GetTileIndices(int level) const { return m_ROIs.GetIndices(level); }
149 
153  UINT32 GetNofTiles(int level) const { return m_ROIs.GetNofTiles(level); }
154 
158  const PGFRect& GetROI(int level) const { return m_ROIs.GetROI(level); }
159 
160 #endif // __PGFROISUPPORT__
161 
162 private:
163  void Destroy() { delete[] m_subband; m_subband = 0;
164  #ifdef __PGFROISUPPORT__
165  m_ROIs.Destroy();
166  #endif
167  }
168  void InitSubbands(UINT32 width, UINT32 height, DataT* data);
169  void ForwardRow(DataT* buff, UINT32 width);
170  void InverseRow(DataT* buff, UINT32 width);
171  void LinearToMallat(int destLevel,DataT* loRow, DataT* hiRow, UINT32 width);
172  void MallatToLinear(int srcLevel, DataT* loRow, DataT* hiRow, UINT32 width);
173 
174 #ifdef __PGFROISUPPORT__
175  CROIs m_ROIs;
176 #endif //__PGFROISUPPORT__
177 
178  int m_nLevels;
180 };
181 
182 #endif //PGF_WAVELETTRANSFORM_H