libpgf  6.11.42
PGF - Progressive Graphics File
Subband.h
Go to the documentation of this file.
00001 /*
00002  * The Progressive Graphics File; http://www.libpgf.org 
00003  * 
00004  * $Date: 2006-06-04 22:05:59 +0200 (So, 04 Jun 2006) $
00005  * $Revision: 229 $
00006  * 
00007  * This file Copyright (C) 2006 xeraina GmbH, Switzerland
00008  * 
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
00011  * as published by the Free Software Foundation; either version 2.1
00012  * of the License, or (at your option) any later version.
00013  * 
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  * 
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022  */
00023 
00028 
00029 #ifndef PGF_SUBBAND_H
00030 #define PGF_SUBBAND_H
00031 
00032 #include "PGFtypes.h"
00033 
00034 class CEncoder;
00035 class CDecoder;
00036 class CROIs;
00037 
00042 class CSubband {
00043         friend class CWaveletTransform;
00044 
00045 public:
00048         CSubband();
00049 
00052         ~CSubband();
00053 
00057         bool AllocMemory();
00058 
00061         void FreeMemory();
00062 
00072         void ExtractTile(CEncoder& encoder, bool tile = false, UINT32 tileX = 0, UINT32 tileY = 0) THROW_;
00073 
00082         void PlaceTile(CDecoder& decoder, int quantParam, bool tile = false, UINT32 tileX = 0, UINT32 tileY = 0) THROW_;
00083 
00089         void Quantize(int quantParam);
00090 
00096         void Dequantize(int quantParam);
00097 
00102         void SetData(UINT32 pos, DataT v)       { ASSERT(pos < m_size); m_data[pos] = v; }
00103 
00107         DataT* GetBuffer()                                      { return m_data; }
00108 
00113         DataT GetData(UINT32 pos) const         { ASSERT(pos < m_size); return m_data[pos]; }
00114 
00118         int GetLevel() const                            { return m_level; }
00119 
00123         int GetHeight() const                           { return m_height; }
00124 
00128         int GetWidth() const                            { return m_width; }
00129         
00135         Orientation GetOrientation() const      { return m_orientation; }
00136 
00137 #ifdef __PGFROISUPPORT__
00138 
00139 
00140         UINT32 BufferWidth() const      { return m_dataWidth; }
00141 
00145         void IncBuffRow(UINT32 pos)     { m_dataPos = pos + m_dataWidth; }
00146 
00147 #endif
00148 
00149 private:
00150         void Initialize(UINT32 width, UINT32 height, int level, Orientation orient);
00151         void WriteBuffer(DataT val)                     { ASSERT(m_dataPos < m_size); m_data[m_dataPos++] = val; }
00152         void SetBuffer(DataT* b)                        { ASSERT(b); m_data = b; }
00153         DataT ReadBuffer()                                      { ASSERT(m_dataPos < m_size); return m_data[m_dataPos++]; }
00154 
00155         UINT32 GetBuffPos() const                       { return m_dataPos; }
00156 
00157 #ifdef __PGFROISUPPORT__
00158 //      void IncBuffPos(UINT32 x, UINT32 y)     { ASSERT(x < m_width); ASSERT(y < m_height); m_dataPos += y*m_width + x; }
00159         void TilePosition(UINT32 tileX, UINT32 tileY, UINT32& left, UINT32& top, UINT32& w, UINT32& h) const;
00160         void SetROI(CROIs* roi)                         { ASSERT(roi); m_ROIs = roi; }
00161         void InitBuffPos(UINT32 left = 0, UINT32 top = 0)       { m_dataPos = top*m_dataWidth + left; ASSERT(m_dataPos < m_size); }
00162 #else
00163         void InitBuffPos()                                      { m_dataPos = 0; }
00164 #endif
00165 
00166 //      void PutData(INT16* buff, UINT32 width, bool low);
00167 //      void GetData(INT16* buff, UINT32 width, bool low);
00168 //      UINT32 GetSize() const                          { return m_size; }
00169 //      void SetWidth(UINT32 w)                         { m_width = w; }
00170 //      void SetHeight(UINT32 h)                        { m_height = h; }
00171 //      void SetSize(UINT32 s)                          { m_size = s; }
00172 //      void SetLevel(int l)                            { m_level = l; }
00173 //      void SetOrientation(Orientation o)      { m_orientation = o; }
00174 
00175 private:
00176         UINT32 m_width;                                 
00177         UINT32 m_height;                                
00178         UINT32 m_size;                                  
00179         int m_level;                                    
00180         Orientation m_orientation;              
00181         UINT32 m_dataPos;                               
00182         DataT* m_data;                                  
00183 
00184 #ifdef __PGFROISUPPORT__
00185         CROIs*   m_ROIs;                                
00186         UINT32   m_dataWidth;                   
00187 #endif
00188 };
00189 /*
00191 // store line of wavelet coefficients
00192 // because the wavelet coefficients in buff are interleaved
00193 // low determines whether the lowpass or highpass data is stored
00194 inline void CSubband::PutData(INT16* buff, int width, bool low) {
00195         ASSERT(m_dataPos + width/2 <= (UINT32)m_size);
00196         int start = (low) ? 0 : 1;
00197 
00198         for (int i=start; i < width; i += 2) {
00199                 m_data[m_dataPos] = buff[i];
00200                 m_dataPos++;
00201         }
00202 }
00203 
00205 // get line of wavelet coefficients
00206 // if low is true get the even coefficients in buff
00207 inline void CSubband::GetData(INT16* buff, int width, bool low) {
00208         ASSERT(m_dataPos + width/2 <= (UINT32)m_size);
00209         int start = (low) ? 0 : 1;
00210         //if (low) start = 0; else start = 1;
00211         for (int i=start; i < width; i += 2) {
00212                 buff[i] = m_data[m_dataPos];
00213                 m_dataPos++;
00214         }
00215 }
00216 */
00217 
00218 #endif //PGF_SUBBAND_H
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines