~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to frmts/hfa/hfacompress.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: hfacompress.cpp 17547 2009-08-21 10:02:01Z rouault $
 
2
 * $Id: hfacompress.cpp 23624 2011-12-21 19:31:43Z rouault $
3
3
 *
4
4
 * Name:     hfadataset.cpp
5
5
 * Project:  Erdas Imagine Driver
30
30
 
31
31
#include "hfa_p.h"
32
32
 
33
 
CPL_CVSID("$Id: hfacompress.cpp 17547 2009-08-21 10:02:01Z rouault $");
 
33
CPL_CVSID("$Id: hfacompress.cpp 23624 2011-12-21 19:31:43Z rouault $");
34
34
 
35
35
HFACompress::HFACompress( void *pData, GUInt32 nBlockSize, int nDataType )
36
36
{
42
42
 
43
43
  /* Allocate some memory for the count and values - probably too big */
44
44
  /* About right for worst case scenario tho */
45
 
  m_pCounts     = (GByte*)CPLMalloc( m_nBlockCount * sizeof(GUInt32) + sizeof(GUInt32) );
 
45
  m_pCounts     = (GByte*)VSIMalloc( m_nBlockCount * sizeof(GUInt32) + sizeof(GUInt32) );
46
46
  m_nSizeCounts = 0;
47
47
  
48
 
  m_pValues     = (GByte*)CPLMalloc( m_nBlockCount * sizeof(GUInt32) + sizeof(GUInt32) );
 
48
  m_pValues     = (GByte*)VSIMalloc( m_nBlockCount * sizeof(GUInt32) + sizeof(GUInt32) );
49
49
  m_nSizeValues = 0;
50
50
  
51
51
  m_nMin        = 0;
168
168
      lower 2 bits of the data it restricts what we can use */
169
169
  if( count < 0x40 )
170
170
  {
171
 
    pCounter[0] = count;
 
171
    pCounter[0] = (GByte) count;
172
172
    *pnSizeCount = 1;
173
173
  }
174
174
  else if( count < 0x8000 )
175
175
  {
176
176
    pCounter[1] = count & 0xff;
177
177
    count /= 256;
178
 
    pCounter[0] = count | 0x40;
 
178
    pCounter[0] = (GByte) (count | 0x40);
179
179
    *pnSizeCount = 2;
180
180
  }
181
181
  else if( count < 0x800000 )
184
184
    count /= 256;
185
185
    pCounter[1] = count & 0xff;
186
186
    count /= 256;
187
 
    pCounter[0] = count | 0x80;
 
187
    pCounter[0] = (GByte) (count | 0x80);
188
188
    *pnSizeCount = 3;
189
189
  }
190
190
  else
195
195
    count /= 256;
196
196
    pCounter[1] = count & 0xff;
197
197
    count /= 256;
198
 
    pCounter[0] = count | 0xc0;
 
198
    pCounter[0] = (GByte) (count | 0xc0);
199
199
    *pnSizeCount = 4;
200
200
  }
201
201
}