aboutsummaryrefslogtreecommitdiff
path: root/common/huffman.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2011-07-18 10:27:26 -0400
committerMatthew Hoops2011-07-18 10:28:10 -0400
commit87b4ef5547c23db116466bedaf8b67dd57c19f75 (patch)
tree1c4338bf4f303f1dc5d35eb12647fb27b3e6ebf9 /common/huffman.cpp
parente6171fbb7415076926aa8d9123b39ab530508a8f (diff)
downloadscummvm-rg350-87b4ef5547c23db116466bedaf8b67dd57c19f75.tar.gz
scummvm-rg350-87b4ef5547c23db116466bedaf8b67dd57c19f75.tar.bz2
scummvm-rg350-87b4ef5547c23db116466bedaf8b67dd57c19f75.zip
COMMON: Update code from eos
Diffstat (limited to 'common/huffman.cpp')
-rw-r--r--common/huffman.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/common/huffman.cpp b/common/huffman.cpp
index 668e2216c9..a8ebe4142a 100644
--- a/common/huffman.cpp
+++ b/common/huffman.cpp
@@ -34,12 +34,17 @@ Huffman::Symbol::Symbol(uint32 c, uint32 s) : code(c), symbol(s) {
Huffman::Huffman(uint8 maxLength, uint32 codeCount, const uint32 *codes, const uint8 *lengths, const uint32 *symbols) {
- assert(maxLength > 0);
assert(codeCount > 0);
assert(codes);
assert(lengths);
+ if (maxLength == 0)
+ for (uint32 i = 0; i < codeCount; i++)
+ maxLength = MAX(maxLength, lengths[i]);
+
+ assert(maxLength <= 32);
+
_codes.resize(maxLength);
_symbols.resize(codeCount);
@@ -63,7 +68,7 @@ void Huffman::setSymbols(const uint32 *symbols) {
_symbols[i]->symbol = symbols ? *symbols++ : i;
}
-uint32 Huffman::getSymbol(BitStream &bits) {
+uint32 Huffman::getSymbol(BitStream &bits) const {
uint32 code = 0;
for (uint32 i = 0; i < _codes.size(); i++) {