This is LWZDecoder.h in view mode; [Download] [Up]
/*
** Copyright (c) 1995 Netsurfer Inc. All Rights Reserved.
**
** Author: <bbum@friday.com>
*/
/*
** Copyright 1990, 1991, 1993, David Koblas. (koblas@netcom.com)
**
** Permission to use, copy, modify, and distribute this software and its
** documentation for any purpose and without fee is hereby granted,
** provided that the above copyright notice appear in all copies and that
** both that copyright notice and this permission notice appear in
** supporting documentation. This software is provided "as is" without
** express or implied warranty.
*/
/*"
* Maximum number of bits present in any single LWZ code.
"*/
#define MAX_LWZ_BITS 12
#ifndef FALSE
#define FALSE NO
#endif
#ifndef TRUE
#define TRUE YES
#endif
/// RETURN CODES
#define LWZ_NO_ERROR 0 // nothing amiss
#define LWZ_DONE -1 // missing EOD-- common, usually ignored.
#define LWZ_NO_EOD -2 // missing EOD-- common, usually ignored.
#define LWZ_CIRCULAR_ERR -3 // circular code-- fatal
#define LWZ_BIT_OVERRUN -4 // ran off end of bits
#define LWZ_DATA_BLOCK_ERR -5 // error reading data block
/*"
* Lempel-Welch-Ziv decompression state (rather large).
"*/
typedef struct __LWZState {
/*" state used by LWZReadByte
"*/
int code_size;
int set_code_size;
int max_code;
int max_code_size;
int firstcode;
int oldcode;
int clear_code;
int end_code;
int table[2][ (1 << MAX_LWZ_BITS) ];
int stack[ (1 << MAX_LWZ_BITS) * 2];
int *stackPtr;
BOOL fresh;
BOOL zeroDataBlock;
/*" state used by GetCode, GetDataBlock
"*/
unsigned char buf[280];
int curbit;
int lastbit;
BOOL done;
int last_byte;
} LWZState;
/*"
* Initialize decompressor.
"*/
extern void LWZInitState(id decoder, LWZState *state, unsigned char codeSize);
/*"
* Decompress a single byte.
"*/
extern int LWZReadByte(id decoder, LWZState *state, NXStream *stream);
/*"
* Read a block of compressed image data
"*/
extern int GetDataBlock(id decoder, LWZState *state,
NXStream *stream, unsigned char *buf);
/*"
* Retrieve a single compression code.
"*/
extern int GetCode(id decoder, LWZState *state, NXStream *stream);
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.