libpgf
6.12.24
PGF - Progressive Graphics 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 CRoiIndices; 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 00071 void ExtractTile(CEncoder& encoder, bool tile = false, UINT32 tileX = 0, UINT32 tileY = 0) THROW_; 00072 00081 void PlaceTile(CDecoder& decoder, int quantParam, bool tile = false, UINT32 tileX = 0, UINT32 tileY = 0) THROW_; 00082 00088 void Quantize(int quantParam); 00089 00095 void Dequantize(int quantParam); 00096 00101 void SetData(UINT32 pos, DataT v) { ASSERT(pos < m_size); m_data[pos] = v; } 00102 00106 DataT* GetBuffer() { return m_data; } 00107 00112 DataT GetData(UINT32 pos) const { ASSERT(pos < m_size); return m_data[pos]; } 00113 00117 int GetLevel() const { return m_level; } 00118 00122 int GetHeight() const { return m_height; } 00123 00127 int GetWidth() const { return m_width; } 00128 00134 Orientation GetOrientation() const { return m_orientation; } 00135 00136 #ifdef __PGFROISUPPORT__ 00137 00138 00139 00140 void IncBuffRow(UINT32 pos) { m_dataPos = pos + BufferWidth(); } 00141 00142 #endif 00143 00144 private: 00145 void Initialize(UINT32 width, UINT32 height, int level, Orientation orient); 00146 void WriteBuffer(DataT val) { ASSERT(m_dataPos < m_size); m_data[m_dataPos++] = val; } 00147 void SetBuffer(DataT* b) { ASSERT(b); m_data = b; } 00148 DataT ReadBuffer() { ASSERT(m_dataPos < m_size); return m_data[m_dataPos++]; } 00149 00150 UINT32 GetBuffPos() const { return m_dataPos; } 00151 00152 #ifdef __PGFROISUPPORT__ 00153 UINT32 BufferWidth() const { return m_ROI.Width(); } 00154 void TilePosition(UINT32 tileX, UINT32 tileY, UINT32& left, UINT32& top, UINT32& w, UINT32& h) const; 00155 const PGFRect& GetROI() const { return m_ROI; } 00156 void SetNTiles(UINT32 nTiles) { m_nTiles = nTiles; } 00157 void SetROI(const PGFRect& roi) { ASSERT(roi.right <= m_width); ASSERT(roi.bottom <= m_height); m_ROI = roi; } 00158 void InitBuffPos(UINT32 left = 0, UINT32 top = 0) { m_dataPos = top*BufferWidth() + left; ASSERT(m_dataPos < m_size); } 00159 #else 00160 void InitBuffPos() { m_dataPos = 0; } 00161 #endif 00162 00163 private: 00164 UINT32 m_width; 00165 UINT32 m_height; 00166 UINT32 m_size; 00167 int m_level; 00168 Orientation m_orientation; 00169 UINT32 m_dataPos; 00170 DataT* m_data; 00171 00172 #ifdef __PGFROISUPPORT__ 00173 PGFRect m_ROI; 00174 UINT32 m_nTiles; 00175 #endif 00176 }; 00177 00178 #endif //PGF_SUBBAND_H