Skip to content

Commit

Permalink
Merge pull request #248 from Esri/tmaurer3/limit_diff_enc_to_int_loss…
Browse files Browse the repository at this point in the history
…less

limit diff encode to int lossless
  • Loading branch information
tmaurer3 committed Oct 25, 2023
2 parents 8ab281e + 6530e5f commit 1906bfb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/LercLib/Huffman.h
Expand Up @@ -176,7 +176,6 @@ inline bool Huffman::DecodeOneValue(const Byte** ppSrc, size_t& nBytesRemaining,
}

// if not there, go through the tree (slower)

if (!m_root)
return false;

Expand Down
2 changes: 1 addition & 1 deletion src/LercLib/Lerc2.cpp
Expand Up @@ -1422,7 +1422,7 @@ bool Lerc2::WriteTiles(const T* data, Byte** ppByte, int& numBytes) const

const bool bDtInt = (hd.dt < DT_Float);
const bool bIntLossless = bDtInt && (hd.maxZError == 0.5);
const bool bTryDiffEnc = (hd.version >= 5) && (nDepth > 1) && (hd.maxZError > 0); // turn off for flt lossless
const bool bTryDiffEnc = (hd.version >= 5) && (nDepth > 1) && bIntLossless; // only for int lossless to avoid error propagation

const bool bCheckForIntOverflow = NeedToCheckForIntOverflow(hd);
const bool bCheckForFltRndErr = NeedToCheckForFltRndErr(hd);
Expand Down
6 changes: 3 additions & 3 deletions src/LercLib/Lerc2.h
Expand Up @@ -106,7 +106,7 @@ class Lerc2
numValidPixel,
microBlockSize,
blobSize,
nBlobsMore; // for multi-band Lerc blob, how many more blobs or bands appended to this one
nBlobsMore; // for multi-band Lerc blob, how many more blobs or bands appended to this one

Byte bPassNoDataValues, // 1 - pass noData values to decoder, 0 - don't pass, ignore
bIsInt, // 1 - float or double data is all integer numbers, 0 - not
Expand Down Expand Up @@ -435,8 +435,8 @@ inline int Lerc2::NumBytesTile(int numValidPixel, T zMin, T zMax, DataType dtZ,
unsigned int maxElem = (unsigned int)(maxVal + 0.5);
if (maxElem > 0)
{
nBytes += (!tryLut) ? m_bitStuffer2.ComputeNumBytesNeededSimple(numValidPixel, maxElem)
: m_bitStuffer2.ComputeNumBytesNeededLut(sortedQuantVec, tryLut);
nBytes += (!tryLut) ? BitStuffer2::ComputeNumBytesNeededSimple(numValidPixel, maxElem)
: BitStuffer2::ComputeNumBytesNeededLut(sortedQuantVec, tryLut);
}

if (nBytes < nBytesRaw)
Expand Down

0 comments on commit 1906bfb

Please sign in to comment.