[Scummvm-cvs-logs] scummvm master -> 614162e5fc8489324e586b57db46558b4d6c26ef
m-kiewitz
m_kiewitz at users.sourceforge.net
Sat Jul 4 03:10:26 CEST 2015
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
614162e5fc COMMON: PKWARE data comp. lib. mask dictionary xs
Commit: 614162e5fc8489324e586b57db46558b4d6c26ef
https://github.com/scummvm/scummvm/commit/614162e5fc8489324e586b57db46558b4d6c26ef
Author: Martin Kiewitz (m_kiewitz at users.sourceforge.net)
Date: 2015-07-04T03:10:26+02:00
Commit Message:
COMMON: PKWARE data comp. lib. mask dictionary xs
added masking of dictionary offsets when copying from dictionary
issues should now all be fixed
Changed paths:
common/dcl.cpp
diff --git a/common/dcl.cpp b/common/dcl.cpp
index 703544b..2588fc5 100644
--- a/common/dcl.cpp
+++ b/common/dcl.cpp
@@ -338,6 +338,7 @@ bool DecompressorDCL::unpack(SeekableReadStream *sourceStream, WriteStream *targ
byte dictionary[MIDI_SETUP_BUNDLE_FILE_MAXIMUM_DICTIONARY_SIZE];
uint16 dictionaryPos = 0;
uint16 dictionarySize = 0;
+ uint16 dictionaryMask = 0;
int value;
uint16 tokenOffset = 0;
uint16 tokenLength = 0;
@@ -369,6 +370,7 @@ bool DecompressorDCL::unpack(SeekableReadStream *sourceStream, WriteStream *targ
warning("DCL-INFLATE: Error: unsupported dictionary type %02x", dictionaryType);
return false;
}
+ dictionaryMask = dictionarySize - 1;
while ((!targetFixedSize) || (_bytesWritten < _targetSize)) {
if (getBitsLSB(1)) { // (length,distance) pair
@@ -408,47 +410,29 @@ bool DecompressorDCL::unpack(SeekableReadStream *sourceStream, WriteStream *targ
return false;
}
- if (!targetPtr) {
- // FIXME: there is some issue in this code that causes some graphics glitches in SCI
- // will figure this out tomorrow. For now the old code is called for those cases and
- // that makes it work.
- uint16 dictionaryBaseIndex = (dictionaryPos - tokenOffset) & (dictionarySize - 1);
- uint16 dictionaryIndex = dictionaryBaseIndex;
- uint16 dictionaryNextIndex = dictionaryPos;
+ uint16 dictionaryBaseIndex = (dictionaryPos - tokenOffset) & dictionaryMask;
+ uint16 dictionaryIndex = dictionaryBaseIndex;
+ uint16 dictionaryNextIndex = dictionaryPos;
- while (tokenLength) {
- // Write byte from dictionary
- putByte(dictionary[dictionaryIndex]);
- debug(9, "\33[32;31m%02x\33[37;37m ", dictionary[dictionaryIndex]);
+ while (tokenLength) {
+ // Write byte from dictionary
+ putByte(dictionary[dictionaryIndex]);
+ debug(9, "\33[32;31m%02x\33[37;37m ", dictionary[dictionaryIndex]);
- dictionary[dictionaryNextIndex] = dictionary[dictionaryIndex];
- dictionaryNextIndex++; dictionaryIndex++;
+ dictionary[dictionaryNextIndex] = dictionary[dictionaryIndex];
- if (dictionaryIndex == dictionaryPos)
- dictionaryIndex = dictionaryBaseIndex;
- if (dictionaryNextIndex == dictionarySize)
- dictionaryNextIndex = 0;
+ dictionaryNextIndex = (dictionaryNextIndex + 1) & dictionaryMask;
+ dictionaryIndex = (dictionaryIndex + 1) & dictionaryMask;
- tokenLength--;
- }
- dictionaryPos = dictionaryNextIndex;
- debug(9, "\n");
- } else {
- while (tokenLength) {
- uint32 copy_length = (tokenLength > tokenOffset) ? tokenOffset : tokenLength;
- assert(tokenLength >= copy_length);
- uint32 pos = _bytesWritten - tokenOffset;
- for (uint32 i = 0; i < copy_length; i++)
- putByte(targetPtr[pos + i]);
-
- for (uint32 i = 0; i < copy_length; i++)
- debug(9, "\33[32;31m%02x\33[37;37m ", targetPtr[pos + i]);
- debug(9, "\n");
-
- tokenLength -= copy_length;
- tokenOffset += copy_length;
- }
+ if (dictionaryIndex == dictionaryPos)
+ dictionaryIndex = dictionaryBaseIndex;
+ if (dictionaryNextIndex == dictionarySize)
+ dictionaryNextIndex = 0;
+
+ tokenLength--;
}
+ dictionaryPos = dictionaryNextIndex;
+ debug(9, "\n");
} else { // Copy byte verbatim
value = (mode == DCL_ASCII_MODE) ? huffman_lookup(ascii_tree) : getByteLSB();
More information about the Scummvm-git-logs
mailing list