home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 52
/
Amiga_Dream_52.iso
/
RiscOS
/
PRATIQUE
/
GZIPSA.ZIP
/
GZipSa
/
!gzip
/
LZW
/
Docs
/
Guide
/
Guide~
Wrap
Text File
|
1993-06-30
|
6KB
|
141 lines
_______________________________________________________________________________
LZW 1.02 (and LZWD 1.03) ---------------------------------
These modules are PUBLIC DOMAIN
Version date : 04 Oct 1990 ---------------------------------
----------------
- Introduction -
----------------
LZW and LZWD are utility modules, which will compress and decompress files.
As their names suggest, they use the LZW (Lempel-Zev-Welch) compression
algorithm, which (in one or more variations) is also used in many other file
compression utilities (like ARC/SPARK) and several graphics formats (like GIF
and TIFF).
LZW compression can easily achieve more than 50% compression on average
text or mildly to heavily redundant data files and the like.
In fact, the variation used in LZW and LZWD is identical to the one used in
GIF files (but without block counts). Compression is up to 12-bit codes,
there's no adaptive reset, and 2 special codes are used to reset the string
table and to signal the end of the data stream.
LZW and LZWD are written to be *FAST*. The algorithms are coded in heavily
optimized ARM code.
In situations where ARC is unusable, and only 1 file is involved, LZW and LZWD
can be very useful. The speed of (de)compression is many times that of
ARC/SPARK.
---------
- Usage -
---------
To use the modules, simply *RMLoad or *RMRun them. LZW will claim 69K for
(de)compression tables, in/output buffers and internal variables. LZWD claims
only 19K RMA space, so it will consume a minimum of precious memory in
'crunched' applications using LZW-compressed files.
LZW, the main utility, will compress from file/memory to file/memory (i.e.
file to file, file to memory, memory to file or memory to memory). When
compressing/decompressing from file to file, the file's load address,
execution address and attributes will be preserved/restored.
LZWD will only decompress from file to memory, but is optimized (i.e. it
does this faster than LZW, though only about 25%).
Access is via a set of SWI calls. The prefixes indicate in which module
(LZW or LZWD) the SWI is located.
LZW_Compress (&CD000)
---------------------
Compresses a block of data. The source and destination may both be either a
file, or a block of memory.
On entry : - r0 contains flags
bit 0 : 1 = source in memory (r1=address,r3=length)
0 = source in file (r1=pointer to filename)
bit 1 : 1 = destination in memory (r2=address,r4=length)
0 = destination in file (r2=pointer to filename)
- r1 contains source address or pointer to source filename
- r2 contains destination address or pointer to destination filename
- r3 (if source in memory) contains length of source in bytes
- r4 (if destination in memory) contains length of destination
buffer in bytes
On exit : - r0 is corrupted, or contains error pointer (V set)
- r5 (if destination is in memory) contains length of result data
in bytes, otherwise it is corrupted
- all other registers are preserved
If the destination is in memory, and the result data overflows the
destination buffer (i.e. >r3 bytes), a 'Memory overflow' error is generated.
This is probably better than not checking and risking 'Aborts'. Still, if you
need to 'skip' the check, set r3 to 'overkill' of 16Mbytes.
LZW_Decompress (&CD001)
-----------------------
Is identical to LZW_Compress, but decompresses a block of data.
LZW_CompressOn (&CD002)
-----------------------
As LZW_Compress, but appends the compressed data to an existing destination
file.
LZWD_Decompress (&CD100)
------------------------
Decompresses a block of data. The source is a file, and the destination is
a block of memory.
On entry : - r0 contains pointer to source filename
- r1 contains destination address
- r2 contains length of destination in bytes (*not* used currently,
there is no 'Memory overflow' error when exceeded, as when using
the LZW_ equivalent)
On exit : - r0 is corrupted, or contains error pointer (V set)
- r2 contains length of result data in bytes
- all other registers are preserved
LZWD_Decompress is about 25% faster than the equivalent LZW_Decompress. This
is because decompression to memory can be done faster. LZW uses a 'common
denominator' routine which can decompress to both file and memory.
-----------------
- Final remarks -
-----------------
If you have complaints, comments or bugs(!) to offer me, write to :
John Kortink
Middelhuisstr. 17
7482 EL Haaksbergen
The Netherlands
or send email to kortink@utrcu1.uucp
It is not very likely that new versions of these modules will appear. They
serve a (simple) purpose. If you can't use them in their present form (or if
you want a WIMP environment, or other fancy additions), you're probably on
your own, though you are free to contact me at the above address with your
suggestions. Maybe you can persuade me ...
_______________________________________________________________________________
!!! NOTE !!!
You may NOT change these modules or use ANY part of them in other products
without my approval. You may spread them freely (with *ALL* files included),
but not for any profit. This software is provided 'as is'. Using it is
entirely at your own risk.
_______________________________________________________________________________