Skip to content

Commit

Permalink
compute Huf codelengths using 64 bit to prevent shift overflow
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Hillman <[email protected]>
  • Loading branch information
peterhillman authored and cary-ilm committed May 12, 2021
1 parent 2e17ee6 commit ff65d03
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions OpenEXR/IlmImf/ImfFastHuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ FastHufDecoder::FastHufDecoder
for (int l = _minCodeLength; l <= _maxCodeLength; ++l)
{
countTmp[l] = (double)codeCount[l] *
(double)(2 << (_maxCodeLength-l));
(double)(2ll << (_maxCodeLength-l));
}

for (int l = _minCodeLength; l <= _maxCodeLength; ++l)
Expand All @@ -215,7 +215,7 @@ FastHufDecoder::FastHufDecoder
for (int k =l + 1; k <= _maxCodeLength; ++k)
tmp += countTmp[k];

tmp /= (double)(2 << (_maxCodeLength - l));
tmp /= (double)(2ll << (_maxCodeLength - l));

base[l] = (Int64)ceil (tmp);
}
Expand Down

0 comments on commit ff65d03

Please sign in to comment.