Added support for 12-bit and 16-bit LZC (UNIX "compress") compression format.

This commit is contained in:
Andy McFadden 2002-09-28 00:56:08 +00:00
parent 105c85fcd6
commit 18a61d2d31
6 changed files with 32 additions and 14 deletions

View File

@ -1,3 +1,6 @@
2002/09/27 fadden
- added support for 12-bit and 16-bit LZC (UNIX compress)
2002/09/26 fadden 2002/09/26 fadden
- added support for SQueezed files (both compress and expand) - added support for SQueezed files (both compress and expand)

View File

@ -195,7 +195,16 @@ Nu_CompressToArchive(NuArchive* pArchive, NuDataSource* pDataSource,
err = Nu_CompressLZW2(pArchive, pStraw, dstFp, srcLen, &dstLen, err = Nu_CompressLZW2(pArchive, pStraw, dstFp, srcLen, &dstLen,
&threadCrc); &threadCrc);
break; break;
case kNuThreadFormatLZC12:
err = Nu_CompressLZC12(pArchive, pStraw, dstFp, srcLen, &dstLen,
&threadCrc);
break;
case kNuThreadFormatLZC16:
err = Nu_CompressLZC16(pArchive, pStraw, dstFp, srcLen, &dstLen,
&threadCrc);
break;
default: default:
/* should've been blocked in Value.c */
Assert(0); Assert(0);
err = kNuErrInternal; err = kNuErrInternal;
goto bail; goto bail;

View File

@ -171,9 +171,7 @@ Nu_ExpandStream(NuArchive* pArchive, const NuRecord* pRecord,
break; break;
case kNuThreadFormatLZC12: case kNuThreadFormatLZC12:
case kNuThreadFormatLZC16: case kNuThreadFormatLZC16:
err = kNuErrBadFormat; err = Nu_ExpandLZC(pArchive, pRecord, pThread, infp, pFunnel, pCalcCrc);
Nu_ReportError(NU_BLOB, kNuErrNone,
"LZC-compressed threads not supported");
break; break;
default: default:
err = kNuErrBadFormat; err = kNuErrBadFormat;
@ -190,7 +188,7 @@ Nu_ExpandStream(NuArchive* pArchive, const NuRecord* pRecord,
if (pCalcCrc != nil) { if (pCalcCrc != nil) {
if (calcCrc != pThread->thThreadCRC) { if (calcCrc != pThread->thThreadCRC) {
if (!Nu_ShouldIgnoreBadCRC(pArchive, pRecord, kNuErrBadThreadCRC)) { if (!Nu_ShouldIgnoreBadCRC(pArchive, pRecord, kNuErrBadThreadCRC)) {
err = kNuErrBadThreadCRC; err = kNuErrBadDataCRC;
Nu_ReportError(NU_BLOB, err, "expected 0x%04x, got 0x%04x", Nu_ReportError(NU_BLOB, err, "expected 0x%04x, got 0x%04x",
pThread->thThreadCRC, calcCrc); pThread->thThreadCRC, calcCrc);
goto bail; goto bail;

View File

@ -27,11 +27,13 @@ GCC_FLAGS = -Wall -Wwrite-strings -Wstrict-prototypes -Wpointer-arith -Wshadow
CFLAGS = @BUILD_FLAGS@ -I. @DEFS@ CFLAGS = @BUILD_FLAGS@ -I. @DEFS@
SRCS = Archive.c ArchiveIO.c Compress.c Crc16.c Debug.c Deferred.c \ SRCS = Archive.c ArchiveIO.c Compress.c Crc16.c Debug.c Deferred.c \
Entry.c Expand.c FileIO.c Funnel.c Lzw.c MiscStuff.c MiscUtils.c \ Entry.c Expand.c FileIO.c Funnel.c Lzc.c Lzw.c MiscStuff.c \
Record.c SourceSink.c Squeeze.c Thread.c Value.c Version.c MiscUtils.c Record.c SourceSink.c Squeeze.c Thread.c Value.c \
Version.c
OBJS = Archive.o ArchiveIO.o Compress.o Crc16.o Debug.o Deferred.o \ OBJS = Archive.o ArchiveIO.o Compress.o Crc16.o Debug.o Deferred.o \
Entry.o Expand.o FileIO.o Funnel.o Lzw.o MiscStuff.o MiscUtils.o \ Entry.o Expand.o FileIO.o Funnel.o Lzc.o Lzw.o MiscStuff.o \
Record.o SourceSink.o Squeeze.o Thread.o Value.o Version.o MiscUtils.o Record.o SourceSink.o Squeeze.o Thread.o Value.o \
Version.o
STATIC_PRODUCT = libnufx.a STATIC_PRODUCT = libnufx.a
SHARED_PRODUCT = libnufx.so SHARED_PRODUCT = libnufx.so

View File

@ -631,13 +631,21 @@ NuError Nu_StrawRead(NuArchive* pArchive, NuStraw* pStraw, uchar* buffer,
long len); long len);
NuError Nu_StrawRewind(NuArchive* pArchive, NuStraw* pStraw); NuError Nu_StrawRewind(NuArchive* pArchive, NuStraw* pStraw);
/* Lzc.c */
NuError Nu_CompressLZC12(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
ulong srcLen, ulong* pDstLen, ushort* pCrc);
NuError Nu_CompressLZC16(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
ulong srcLen, ulong* pDstLen, ushort* pCrc);
NuError Nu_ExpandLZC(NuArchive* pArchive, const NuRecord* pRecord,
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pThreadCrc);
/* Lzw.c */ /* Lzw.c */
NuError Nu_CompressLZW1(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, NuError Nu_CompressLZW1(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
ulong srcLen, ulong* pDstLen, ushort* pCrc); ulong srcLen, ulong* pDstLen, ushort* pCrc);
NuError Nu_CompressLZW2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, NuError Nu_CompressLZW2(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
ulong srcLen, ulong* pDstLen, ushort* pCrc); ulong srcLen, ulong* pDstLen, ushort* pCrc);
NuError Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord, NuError Nu_ExpandLZW(NuArchive* pArchive, const NuRecord* pRecord,
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pCrc); const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, ushort* pThreadCrc);
/* MiscUtils.c */ /* MiscUtils.c */
extern const char* kNufxLibName; extern const char* kNufxLibName;

View File

@ -208,10 +208,8 @@ Nu_ConvertCompressValToFormat(NuArchive* pArchive, NuValue compValue)
case kNuCompressLZW1: threadFormat = kNuThreadFormatLZW1; break; case kNuCompressLZW1: threadFormat = kNuThreadFormatLZW1; break;
case kNuCompressLZW2: threadFormat = kNuThreadFormatLZW2; break; case kNuCompressLZW2: threadFormat = kNuThreadFormatLZW2; break;
case kNuCompressSQ: threadFormat = kNuThreadFormatHuffmanSQ; break; case kNuCompressSQ: threadFormat = kNuThreadFormatHuffmanSQ; break;
case kNuCompressLZC12: threadFormat = kNuThreadFormatLZC12; case kNuCompressLZC12: threadFormat = kNuThreadFormatLZC12; break;
unsup = true; break; case kNuCompressLZC16: threadFormat = kNuThreadFormatLZC16; break;
case kNuCompressLZC16: threadFormat = kNuThreadFormatLZC16;
unsup = true; break;
default: default:
Assert(false); Assert(false);
Nu_ReportError(NU_BLOB, kNuErrInvalidArg, Nu_ReportError(NU_BLOB, kNuErrInvalidArg,
@ -221,7 +219,7 @@ Nu_ConvertCompressValToFormat(NuArchive* pArchive, NuValue compValue)
if (unsup) { if (unsup) {
Nu_ReportError(NU_BLOB, kNuErrNone, Nu_ReportError(NU_BLOB, kNuErrNone,
"Unsupported compression type 0x%04x requested (%ld)", "Unsupported compression type 0x%04x requested (%ld), using none",
threadFormat, compValue); threadFormat, compValue);
return kNuThreadFormatUncompressed; return kNuThreadFormatUncompressed;
} }