Microsoft Tape Format Specification

附录 C 数据压缩算法

MTF 当前定义了一种基于 Stac Technologies LZS221 compression libraries 数据压缩算法。 LZS221压缩算法的定义是为了提供支持生产环境的磁带切换的软件压缩 流。 它假设了你已经知道如何使用 LZS221 compression libraries 进行工作。

Table 31. Data Compression Algorithm Table
名称说明
MTF_LZS221Stac Technologies LZS2210x0ABE

Common Block Header

数据集中的 Common Block Headers 需要设置来表明会出现压缩流。 需要设置 Block Attributes 字段的 MTF_COMPRESSION 比特以及 Software Compression Algorithm 需要设为 0x0ABE。

注意:压缩不能用于 End of Set(MTF_ESET)的数据流。

Stream Header

在 Stream Header 的 Stream Tape Format Attributes 字段设置 STREAM_COMPRESSED 比特以及设置 Data Compression Algorith 字段为 0x0ABE 来表示这个流是压缩的。 如果压缩流是变长的(STREAM_VARIABLE)所有组成变长流的 Stream Headers 都需要指定使用压缩。 当启用压缩,所有的流数据都必须被 Compression Frame Headers 封装。

LZS221 Buffer Sizes

The size of the buffers used by the Compress and Decompress routines are provided in the table below.

名称说明大小
srcSource buffer62 1024
dstDestination buffer(62 1024) + 32
scratchRAMScratch buffer used by LZS221. This is defined in the LZS221 header file.LZS_HISTORY_SIZE

压缩

LZS221 compression library 定义了压缩 API。 未压缩的数据通过 src buffer 传进,而压缩后数据通过 dst buffer 返回。 以下的原型来自于 LZS221-86 compression library。

extern void OS2_API Compress(char **src,
                             char **dst,
                             unsigned long *srcCnt,
                             unsigned long *dstCnt,
                             char *scratchRAM);

解压

LZS221 compression library 定义了解压 API。 压缩后的数据通过 src buffer 传进,而解缩后数据通过 dst buffer 返回。 以下的原型来自于 LZS221-86 compression library。

extern int OS2_API Decompress(char **src,
                              char **dst,
                              unsigned long *srcCnt,
                              unsigned long *dstCnt,
                              char *scratchRAM);

压缩和解压伪代码

The following compress and decompress pseudo code integrates into the LZS221-86 compression library and is provided to assist in development.

代码略