lzss的c语言程序免费下载,LZSS压缩算法C语言实现.doc

本文档提供了一段C语言实现的LZSS(Lempel-Ziv-Storer-Szymanski)数据压缩算法的源代码。代码经过了修改以适应Microsoft的COMPRESS/EXPAND工具,并优化了部分细节,如将F值从16改为18,调整了编码字符串的阈值等。代码中包含了关键的数据结构如缓冲区和匹配长度的定义,以及压缩和解压缩过程中的关键函数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/*----------------------------------------------------------------------------

LZSS.C -- A Data Compression Program

4/6/1989 Haruhiko Okumura

Use, distribute, and modify this program freely.

Please send me your improved versions.

PC-VANSCIENCE

NIFTY-ServePAF01022

CompuServe74050,1022

Some changes made June, 2003 by Chris Giese

, /~geezer

- Changed F from 16 to 18, for compatability with Microsoft COMPRESS/EXPAND

EXPAND.EXE is on the install disks for MS-DOS version 6 and Windows 3.1

COMPRESS.EXE is in the Win 3.1 SDK, and comes with Borland C++ 3.1

- Changed compress/expand chars on command line from e/d to c/u

- Where possible and correct, changed ints to unsigned

- Made all functions static

- Changed formatting, indenting, global variable names, and function names

- Tried to simplify/clarify code in some areas

----------------------------------------------------------------------------*/

#include

#include

#include

#include

/* size of ring buffer */

#defineN4096

/* index for root of binary search trees */

#define NILN

/* upper limit for g_match_len. Changed from 18 to 16 for binary

compatability with Microsoft COMPRESS.EXE and EXPAND.EXE

#defineF18 */

#defineF16

/* encode string into position and length

if match_length is greater than this: */

#defineTHRESHOLD2

/* these assume little-endian CPU like Intel x86

-- need byte-swap function for big endian CPU */

#defineREAD_LE32(X)*(uint32_t *)(X)

#defineWRITE_LE32(X,Y)*(uint32_t *)(X) = (Y)

/* this assumes sizeof(long)==4 */

typedef unsigned longuint32_t;

/* text (input) size counter, code (output) size counter,

and counter for reporting progress every 1K bytes */

static unsigned long g_text_size, g_code_size, g_print_count;

/* ring buffer of size N, with extra F-1 bytes

to facilitate string comparison */

static unsigned char g_ring_buffer[N + F - 1];

/* position and length of longest match; set by insert_node() */

static unsigned g_match_

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值