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 <peterh@wetafx.co.nz>
  • Loading branch information
peterhillman authored and cary-ilm committed Aug 17, 2020
1 parent 5ba38f1 commit c3ed4a1
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 c3ed4a1

Please sign in to comment.