Skip to content

Commit

Permalink
version as inline function
Browse files Browse the repository at this point in the history
  • Loading branch information
tmaurer3 committed Sep 6, 2018
1 parent 1cbc38f commit 1af3a47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
8 changes: 3 additions & 5 deletions src/LercLib/Lerc2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ Contributors: Thomas Maurer
USING_NAMESPACE_LERC
using namespace std;

const int Lerc2::kCurrVersion; // clang linker complains if this static member is not declared in the .cpp

// -------------------------------------------------------------------------- ;

Lerc2::Lerc2()
Expand All @@ -49,7 +47,7 @@ Lerc2::Lerc2(int nDim, int nCols, int nRows, const Byte* pMaskBits)

bool Lerc2::SetEncoderToOldVersion(int version)
{
if (version < 2 || version > kCurrVersion)
if (version < 2 || version > CurrentVersion())
return false;

if (version < 4 && m_headerInfo.nDim > 1)
Expand All @@ -71,7 +69,7 @@ void Lerc2::Init()
m_imageEncodeMode = IEM_Tiling;

m_headerInfo.RawInit();
m_headerInfo.version = kCurrVersion;
m_headerInfo.version = CurrentVersion();
m_headerInfo.microBlockSize = m_microBlockSize;
}

Expand Down Expand Up @@ -220,7 +218,7 @@ bool Lerc2::ReadHeader(const Byte** ppByte, size_t& nBytesRemainingInOut, struct
ptr += sizeof(int);
nBytesRemaining -= sizeof(int);

if (hd.version > kCurrVersion) // this reader is outdated
if (hd.version > CurrentVersion()) // this reader is outdated
return false;

if (hd.version >= 3)
Expand Down
9 changes: 5 additions & 4 deletions src/LercLib/Lerc2.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ class Lerc2
bool Decode(const Byte** ppByte, size_t& nBytesRemaining, T* arr, Byte* pMaskBits = nullptr); // if mask ptr is not 0, mask bits are returned (even if all valid or same as previous)

private:
static const int kCurrVersion = 4; // 2: added Huffman coding to 8 bit types DT_Char, DT_Byte;
// 3: changed the bit stuffing to using a uint aligned buffer,
// added Fletcher32 checksum
// 4: allow nDim values per pixel
// 2: added Huffman coding to 8 bit types DT_Char, DT_Byte;
// 3: changed the bit stuffing to using a uint aligned buffer,
// added Fletcher32 checksum
// 4: allow nDim values per pixel
static int CurrentVersion() { return 4; }

enum ImageEncodeMode { IEM_Tiling = 0, IEM_DeltaHuffman, IEM_Huffman };
enum BlockEncodeMode { BEM_RawBinary = 0, BEM_BitStuffSimple, BEM_BitStuffLUT };
Expand Down

0 comments on commit 1af3a47

Please sign in to comment.