next up previous
Next: About this document ... Up: A new compression and Previous: Compression example

Decompression example

Let's take the compressed output from the example in Appendix A, and decompress it. Remember, the compressed output from this example looked like:

A 00000000 00000101 00001000 01000010 00010000 10000100
00100001 l 00000000 00000100 00010001 00010001 00010001
00010001 a 00000000 00000011 00100100 10010010 01001001
n 00000000 00000010 01010101 01010101 ' ' 00000000 00000001
11111110

The non-encoded 'A' is read and placed in our decompressed output. Here's our decompressed output so far. Periods, '.', represent empty or unassigned spaces or characters. Note that we assume we know the size of the decompressed output before we decompress the input.

A...........................................

Next, the escape sequences follows, $00000000_{2}$, and then the length of the encoded sequence measured in bytes is given, $00000101_{2}$, or five (5). The five bytes that then follow specify additional occurrences of 'A' in our decompressed output. We decode these, giving:

A....A....A....A....A....A....A....A....A...

Next, an 'l' occurs, and this is immediately added to the decompressed output:

Al...A....A....A....A....A....A....A....A...

After the 'l', the escape sequence occurs, $00000000_{2}$, followed by the number of bytes in the encoded sequence, $00000100_{2}$, or four (4). The four bytes that then follow specify additional occurrences of 'l' in our decompressed output. We decode these, giving:

Al...Al...Al...Al...Al...Al...Al...Al...Al..

Next, an 'a' occurs, and this is immediately added to our decompressed output:

Ala..Al...Al...Al...Al...Al...Al...Al...Al..

The escape sequence, $00000000_{2}$, then follows the 'a', and after the escape sequence, the number of bytes in the encoding is given, $00000011_{2}$, or three (3). The three bytes that then follow specify additional occurrences of 'a' in the decompressed output. We decode these, giving:

Ala..Ala..Ala..Ala..Ala..Ala..Ala..Ala..Ala.

Next, an 'n' occurs, and this is immediately added to our decompressed output:

Alan.Ala..Ala..Ala..Ala..Ala..Ala..Ala..Ala.

The escape sequence, $00000000_{2}$, follows the 'n', and after the escape sequence, the number of bytes in the encoding is given, $00000010_{2}$, or two (2). The two bytes that then follow specify additional occurrences of 'n' in the decompressed output. We decode these, giving:

Alan.Alan.Alan.Alan.Alan.Alan.Alan.Alan.Alan

Next, a space, or ' ', occurs, and this is immediately added to our decompressed output:

Alan Alan.Alan.Alan.Alan.Alan.Alan.Alan.Alan

The escape sequence, $00000000_{2}$, follows the space, and after the escape sequence, the number of bytes in the encoding is given, $00000001_{2}$, or one (1). The one byte that then follows specifies additional occurrences of the space, or ' ', in the decompressed output. We decode these, giving:

Alan Alan Alan Alan Alan Alan Alan Alan Alan

We have decompressed the compressed output from Appendix A.


next up previous
Next: About this document ... Up: A new compression and Previous: Compression example
James Riechel 2007-12-12
Hosted by www.Geocities.ws

1