PROGRAMMER'S GUIDECompression / decompression library
BackForward
Compression / decompression library / 2. reference

2.2 Function list

The following table lists the functions in the decompression library.

Table 2.3 List of data expansion library functions
 function
 Function name
 number
 Run-length stretch
 CMP_DecRunlen
 1
 Run-length extension / BYTE unit
 CMP_DecRunlenByte
 1.1
 Run-length extension / WORD unit
 CMP_DecRunlenWord
 1.2
 Run-length extension / DWORD unit
 CMP_DecRunlenDword
 1.3 1.3 

2.3 Function specifications


 List
 Title

Function specifications

 Function

Run-length stretch

 Function name

CMP_DecRunlen

 No

1

Form
Sint32 CMP_DecRunlen (void * in, void ** out, Sint32 size)
argument
 in (input)
 : Compressed data input buffer pointer.
 out (input)
 : Address of the decompressed data output buffer pointer.
  (output)
 : Extended data output end pointer.
 bufsize (input)
 : Output buffer size [BYTE].
Return value
Processing result
 CMP_DEC_OK (0)
 :normal termination. The input data has been stretched to the end.
 CMP_DEC_STOP (1)
 : Decompression processing interrupted. The output buffer size has been decompressed.
 CMP_DEC_ERR (-1)
 :abnormal termination. The input data is abnormal.
 CMP_DEC_ERR_H_ALGO (-2)
 :abnormal termination. It is an unsupported algorithm.
 CMP_DEC_ERR_H_UNIT (-3)
 :abnormal termination. It is an unsupported processing unit.
function
Decompress the compressed data.
Processes compressed data by the run-length compression tool CMPRUN.EXE of this system.
This function interprets the header of the input data and invokes the decompression function that matches the compression parameters.

Read compressed data from in.
Write the decompressed data to * out. * out post-increments each time a byte is written.
The user can know the size of the decompressed data from the difference between the * out value set before startup and the * out value after startup.
If the decompressed data exceeds bufsze [byte], processing is interrupted there. Even if it is interrupted, the output buffer is still filled with the correct decompression data for the buffer size.

caution
Both the input buffer and the output buffer are secured by the user. The start address of each buffer must match the start address of the 4-byte boundary. The output buffer should be large enough to get the decompressed data and be an integral multiple of the number of bytes processed.
remarks
Figure 2.1 Explanation of decompression function arguments
In (input) 
↓ 
─┬─┬─┬─┬─┬─────┬─┬─┬─┬── 
Input buffer │ ■ │ ■ │ ■ │ ■ │ ・ ・ ・ ・ ・ ・ │ ■ │ ■ │ ■ │ 
─┴─┴─┴─┴─┴─────┴─┴─┴─┴── 
 
│ ← ───────────── buffsize ─────────────── → │ 
─┬─┬─┬─┬─┬─────┬─┬─┬─┬─┬─┬─┬───┬─┬─┬─┬─ 
Output buffer │ □ │ □ │ □ │ □ │ ・ ・ ・ ・ ・ ・ ・ │ □ │ □ │ □ │ □ │ □ │ │ ・ ・ ・ │ │ │ │ │ 
─┴─┴─┴─┴─┴─────┴─┴─┴─┴─┴─┴─┴───┴─┴─┴─┴─ 
↑↑ 
* Out (input) out (output) 

 List
 Title

Function specifications

 Function

Run-length extension / BYTE unit

 Function name

CMP_DecRunlenByte

 No

1.1

Form
Sint32 CMP_DecRunlenByte (void * in, void ** out, Sint32 size)
argument
 in (input)
 : Compressed data input buffer pointer.
 out (input)
 : Address of the decompressed data output buffer pointer.
  (output)
 : Extended data output end pointer.
 bufsize (input)
 : Output buffer size [BYTE].
Return value
Processing result
 CMP_DEC_OK (0)
 :normal termination. The input data has been stretched to the end.
 CMP_DEC_STOP (1)
 : Decompression processing interrupted. The output buffer size has been decompressed.
 CMP_DEC_ERR (-1)
 :abnormal termination. The input data is abnormal.
 CMP_DEC_ERR_H_ALGO (-2)
 :abnormal termination. It is an unsupported algorithm.
 CMP_DEC_ERR_H_UNIT (-3)
 :abnormal termination. It is an unsupported processing unit.
function
Decompress the compressed data.
Processes data compressed with run-length, processing unit BYTE.
Read compressed data from in.
Write the decompressed data to * out. * out post-increments each time one byte is written. The user can know the size of the decompressed data from the difference between the * out value set before startup and the * out value after startup.
If the decompressed data exceeds bufsze [byte], processing is interrupted there. Even if it is interrupted, the output buffer is still filled with the correct decompression data for the buffer size.
caution
Both the input buffer and the output buffer are secured by the user. The start address of each buffer must match the start address of the 4-byte boundary.
The output buffer should be large enough to get the decompressed data and be an integral multiple of the number of bytes processed.
remarks
The function interface is the same as CMP_DecRunlen (). See Figure 2.1.

 List
 Title

Function specifications

 Function

Run-length extension / WORD unit

 Function name

CMP_DecRunlenWord

 No

1.2

Form
Sint32 CMP_DecRunlenWord (void * in, void ** out, Sint32 size)
argument
 in (input)
 : Compressed data input buffer pointer.
 out (input)
 : Address of the decompressed data output buffer pointer.
 (output)
 : Extended data output end pointer.
 bufsize (input)
 : Output buffer size [BYTE].
Return value
Processing result
 CMP_DEC_OK (0)
 :normal termination. The input data has been stretched to the end.
 CMP_DEC_STOP (1)
 : Decompression processing interrupted. The output buffer size has been decompressed.
 CMP_DEC_ERR (-1)
 :abnormal termination. The input data is abnormal.
 CMP_DEC_ERR_H_ALGO (-2)
 :abnormal termination. It is an unsupported algorithm.
 CMP_DEC_ERR_H_UNIT (-3)
 :abnormal termination. It is an unsupported processing unit.
function
Decompress the compressed data.
Processes data compressed by run-length, processing unit WORD.
Read compressed data from in.
Write the decompressed data to * out. * out post-increments each time a byte is written.
The user can know the size of the decompressed data from the difference between the * out value set before startup and the * out value after startup.
If the decompressed data exceeds bufsze [byte], processing is interrupted there.
Even if it is interrupted, the output buffer is still filled with the correct decompression data for the buffer size.
caution
Both the input buffer and the output buffer are reserved by the user.
The start address of each buffer must match the start address of the 4-byte boundary.
The output buffer should be large enough to get the decompressed data and be an integral multiple of the number of bytes processed.
remarks
The function interface is the same as CMP_DecRunlen (). See Figure 2.1.

 List
 Title

Function specifications

 Function

Run-length extension / DWORD unit

 Function name

CMP_DecRunlenDword

 No

1.3 1.3

Form
Sint32 CMP_DecRunlenDword (void * in, void ** out, Sint32 size)
argument
in: Compressed data input buffer pointer.
out (input): Address of the decompressed data output buffer pointer.
       (Output): The last pointer for decompressed data output.
bufsize (input): Output buffer size [BYTE].
Return value (processing result)
CMP_DEC_OK (0): Normal termination. The input data has been stretched to the end.
CMP_DEC_STOP (1): Decompression processing is interrupted. The output buffer size has been decompressed.
CMP_DEC_ERR (-1): Abnormal termination. The input data is abnormal.
CMP_DEC_ERR_H_ALGO (-2): Abnormal termination. It is an unsupported algorithm.
CMP_DEC_ERR_H_UNIT (-3): Abnormal termination. It is an unsupported processing unit.
function
Decompress the compressed data.
Processes data compressed with run-length, processing unit DWORD.
Read compressed data from in.
Write the decompressed data to * out. * out post-increments each time a byte is written. The user can know the size of the decompressed data from the difference between the * out value set before startup and the * out value after startup.
If the decompressed data exceeds bufsze [byte], processing is interrupted there. Even if it is interrupted, the output buffer is still filled with the correct decompression data for the buffer size.
caution
Both the input buffer and the output buffer are reserved by the user. The start address of each buffer must match the start address of the 4-byte boundary.
The output buffer should be large enough to get the decompressed data and be an integral multiple of the number of bytes processed.
remarks
The function interface is the same as CMP_DecRunlen (). See Figure 2.1.

BackForward
PROGRAMMER'S GUIDECompression / decompression library
Copyright SEGA ENTERPRISES, LTD., 1997