Japanese
PROGRAMMER'S GUIDECompression/decompression library
■ | Go forward
compression/decompression library

1. guide


1.1 Application

This compression/decompression library is for decompressing data compressed using a separately provided run-length compression tool.

Run length compression tool CMPRUN.EXE

1.2 Compression method

A unique mismatch sequence processing has been added. In simple run-length algorithms, mismatched sequences degrade the compression ratio, so they are processed together. Match series are expressed by run length and value. The mismatched series is expressed by the mismatched sequence length and mismatched series value (uncompressed data).
In order to distinguish between the code representing a matching sequence and the code representing an unmatched sequence, the unmatched sequence length is written as a negative value (two's complement).
Inputting a short run length will split the mismatched series and worsen the compression ratio, so we devised the termination conditions for the mismatched series.

[Definition of mismatched series]
The mismatched series is defined by the following start and end conditions.

< Starting conditions for mismatched series>

Input the symbol (character) of run length 1.

[Example of mismatched series]
The following image is an example of a mismatched series.

< Termination conditions for unmatched series>

Input a matching sequence with a run length of 3 or more.
or
When the unmatched sequence length reaches the limit that can be expressed by the number of bytes per processing unit.

Figure 1.1 Example of mismatched series
Start...A A A B C C C C D D D ・・・・・・
End Start...A A A B C D E F G G G...
End Start...A A A B C C C D D E E E ......
End Start...A A A B C C D D D E F F...
                     end

[Processing unit]
Select the processing unit from the three types shown in the table below. Starting from the beginning, input one character (symbol) separated by each processing unit boundary.

Table 1.1 Processing unit
processing unit Image of compression processing unit for input data
BYTE
(1 byte)
WORD
(2 bytes)
DWORD
(4 bytes)

* Numbers are in hexadecimal. is equivalent to 1 byte.

[Expression of the leader]
The normal run length (matching sequence length) is expressed as a positive number, and the mismatching sequence length is expressed as a negative number. The run length (matching sequence length) is always greater than or equal to 2, so write it as a value subtracted by 2.
The number of bytes used to represent the run length is the same as the processing unit byte number.
The actual amount of data for run length is interpreted in units of processing. In other words, if the processing unit is WORD and the run length is 5, it means encoding processing for 10 bytes of data.
The following table shows the range of run length values that can be expressed.

Table 1.2 Run length width and run length expression


processing unit
 Run length (matching series length)
 mismatched sequence length
 expression (description)
 expression (description)
 BYTE1 byte
 WORD2 bytes
 DWORD4 bytes 

[Processing image diagram]

The following figure is an image of the compression algorithm using run length/mismatch sequence processing.

Figure 1.2 Run length/mismatch sequence processing

 ... Matching series value or mismatching series value (uncompressed data)
・ ...Processing unit. Either BYTE, WORD, or DWORD.
...Run length or unmatched sequence length.
・ ...Run length width. Equals processing unit.


■ | Go forward
PROGRAMMER'S GUIDECompression/decompression library
Copyright SEGA ENTERPRISES, LTD., 1997