text
stringlengths 0
99.6k
|
|---|
For text files, the delay is short because the table isn't
|
very long. For programs, however, the delay is quite
|
noticeable because all 256 possible byte values are usually
|
used.
|
Trees are an excellent tool to understanding the theory
|
behind Huffman squeezing. Oddly enough, ARC doesn't use this
|
concept to any advantage at all.
|
ARC VERSION 2.20 PAGE - 35
|
Lempel-Zev-Welch(3), or LZW compression is used to
|
'crunch' files. It is really quite amazing since it almost
|
always is chosen as the most efficient compressor and can be
|
performed 'on the fly' without first having to analyze a
|
files contents. It takes advantage of the fact that certain
|
sequences of bytes occur more often than others in typical
|
data files.
|
For example, in an ascii listing of a BASIC program,
|
the BASIC keywords, INPUT, GOTO, GOSUB and others occur with
|
abundance. In this document, words like "ARC", "compress",
|
"squeeze", or characters sequences like ". " or ", " occur
|
quite often. If we could replace these character sequences
|
with shorter codes, we would end up with a shorter output
|
file. When you enter a line of BASIC code, the BASIC
|
interpreter does just that by looking to see if any of
|
keywords in the line occur in its keyword table. ARC does
|
something similar, but prepares the keyword table from
|
scratch for each file it crunches.
|
The LZW algorithm reads the input file sequentially and
|
remembers sequences of characters that have occurred
|
previously in the file and replaces subsequent occurrences
|
with shorter codes. It prepares a 'string table' as it goes
|
through the file which is used to generate the codes. Again,
|
we could think of the string table as a tree, but this time
|
it is a much more complicated tree since each node can have
|
as many as 256 branches!
|
Lets take a simplified example.
|
Suppose that the alphabet consisted only of the letters
|
a,b, and c and our file is "abababacababaa".
|
We start by assigning a code to each letter in our
|
alphabet. Thus a=1 b=2 and c=3.
|
The first character we encounter is an "a". It is in
|
the string table, so we save the "a" as a prefix string and
|
get another character which we call the extension. The next
|
character is a "b", so we now have the sequence "ab", which
|
is not in the string table. Whenever the current
|
prefix+extension string we have in memory is not in the
|
string table, we do three things. We send the code for the
|
prefix to the output file, add the prefix+extension string
|
to our string table, and make the extension the new prefix.
|
Thus we code out a "1" and set the prefix equal to "2", the
|
code for "b" and add "ab" to the string table as code 4.
|
____________________
|
3. Welch, Terry A., "A TECHNIQUE FOR HIGH PERFORMANCE DATA
|
COMPRESSION", IEEE COMPUTER, June 1984.
|
ARC VERSION 2.20 PAGE - 36
|
We now have "b" as the prefix, and read in the next
|
character from the input file as our new extension. The next
|
character is an "a". "ba" is not in the string table, so we
|
code out the "b", add "ba"=5 to the string table, and make
|
"a" the new prefix.
|
Now is when it starts to get interesting. We now have
|
"a" as the prefix and read in "b" as the next extension.
|
This time "ab" is in the string table, so we make the code
|
for "ab" the new prefix and get another extension. The next
|
character is an "a", "aba" is not in the string table so we
|
send the prefix code "ab"=4 to the output file and add
|
"aba"=6 to our string table. Next time we encounter the
|
sequence "aba", we'll only have to send one code in the
|
place of three characters!
|
The prefix is now "a". We get the next character "b".
|
"ab" is in the string table, so we make "ab"=4 the prefix
|
and get another character. This time its an "a". "aba" is
|
also in the string table, so we we make "aba"=6 our prefix
|
and get another extension. This time its a "c", so we code
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.