StormLib API Reference

SCompCompress

Description

int WINAPI SCompCompress(
  void * pvOutBuffer,               // Pointer to buffer where imploded data will be stored
  int * pcbOutBuffer,               // Pointer to size of output buffer
  void * pvInBuffer,                // Pointer to buffer with data to be imploded
  int cbInBuffer,                   // Size of the input data
  unsigned uCompressionMask,        // Compression methods to use
  int nCmpType,                     // First parameter specific to compression method
  int nCmpLevel                     // Second parameter specific to compression method
);

SCompCompress compresses a data buffer, using various compression methods.

Parameters

pbOutBuffer
[out] Pointer to buffer where the compressed data will be stored.
pcbOutBuffer
[in, out] On call, pointer to the length of the buffer in pbOutBuffer. When finished, this variable receives length of the compressed data.
pbInBuffer
[in] Pointer to data that are to be imploded.
cbInBuffer
[in] Length of the data pointed by pbInBuffer.
uCompressionMask
[in] Bit mask that specifies compression methods to use. For possible values of this parameter, see SFileAddFileEx.
nCmpType
[in] An extra parameter, specific to compression type. This parameter is only used internally by Huffmann compression when applied after an ADPCM compression.
nCmpLevel
[in] An extra parameter, specific to compression type. This parameter is used by ADPCM compression and is related to WAVE quality. See Remarks section for additional information.

Return Value

When the function succeeds, it returns nonzero. On an error, the function returns FALSE and GetLastError gives the error code.

Remarks

When the compression library was unable to compress the data, it will copy the input data to the output buffer. The caller can determine this by checking size of the output data against size of the input data. If cbOutData == cbInData, it means that the data haven't been compressed.

When compressing WAVE files using ADPCM compression, the first MPQ block of the WAVE file must be compressed by a data compression (e.g. MPQ_COMPRESSION_PKWARE). The nCmpLevel can be used to control quality of the WAVE files. The following table shows parameters for different WAVE qualities:

WAVE Quality uCompressionMask nCmpLevel
High quality, the worst compression 0x08 (stereo)
0x08 (mono)
(ignored)
Medium quality, medium compression 0x81 (stereo)
0x41 (mono)
4
Low quality, the best compression 0x81 (stereo)
0x41 (mono)
2

Availability in Storm.dll

Available in Storm.dll Yes
Ordinal number in Storm.dll 1.00 N/A
Ordinal number in Storm.dll 1.09 551 (0x227)