34 lines
1.2 KiB
Diff
34 lines
1.2 KiB
Diff
From c3ed4a1db1f39bf4524a644cb2af81dc8cfab33f Mon Sep 17 00:00:00 2001
|
|
From: Peter Hillman <peterh@wetafx.co.nz>
|
|
Date: Mon, 17 Aug 2020 12:29:03 +1200
|
|
Subject: [PATCH] compute Huf codelengths using 64 bit to prevent shift
|
|
overflow
|
|
|
|
Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
|
|
---
|
|
OpenEXR/IlmImf/ImfFastHuf.cpp | 4 ++--
|
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/IlmImf/ImfFastHuf.cpp b/IlmImf/ImfFastHuf.cpp
|
|
index 9ccf2e15d..c04b56e75 100644
|
|
--- a/IlmImf/ImfFastHuf.cpp
|
|
+++ b/IlmImf/ImfFastHuf.cpp
|
|
@@ -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)
|
|
@@ -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);
|
|
}
|