The thread header CRC computation was broken for LZW/1.

This commit is contained in:
Andy McFadden 2003-02-23 01:23:02 +00:00
parent 104f34629c
commit 3c2721d6f8

View File

@ -648,10 +648,9 @@ Nu_CompressLZW(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
/* /*
* Compute the CRC. For LZW/1 this is on the entire 4K block, for * Compute the CRC. For LZW/1 this is on the entire 4K block, for
* the "version 3" thread CRC this is on just the "real" data. * the "version 3" thread header CRC this is on just the "real" data.
*/ */
*pThreadCrc = Nu_CalcCRC16(*pThreadCrc, *pThreadCrc = Nu_CalcCRC16(*pThreadCrc, lzwState->inputBuf, blockSize);
lzwState->inputBuf, blockSize);
if (!isType2) { if (!isType2) {
lzwState->chunkCrc = Nu_CalcCRC16(lzwState->chunkCrc, lzwState->chunkCrc = Nu_CalcCRC16(lzwState->chunkCrc,
lzwState->inputBuf, kNuLZWBlockSize); lzwState->inputBuf, kNuLZWBlockSize);
@ -1514,15 +1513,10 @@ Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord,
* See commentary in the compression code for why we have to * See commentary in the compression code for why we have to
* compute two CRCs for LZW/1. * compute two CRCs for LZW/1.
*/ */
if (isType2) { if (pThreadCrc != nil) {
if (pThreadCrc != nil) { *pThreadCrc = Nu_CalcCRC16(*pThreadCrc, writeBuf, writeLen);
*pThreadCrc = Nu_CalcCRC16(*pThreadCrc, writeBuf, writeLen); }
} if (!isType2) {
} else {
if (pThreadCrc != nil) {
*pThreadCrc = Nu_CalcCRC16(*pThreadCrc, writeBuf,
kNuLZWBlockSize);
}
lzwState->chunkCrc = Nu_CalcCRC16(lzwState->chunkCrc, lzwState->chunkCrc = Nu_CalcCRC16(lzwState->chunkCrc,
writeBuf, kNuLZWBlockSize); writeBuf, kNuLZWBlockSize);
} }