1 / 11
文档名称:

LZSS压缩算法实验报告.doc

格式:doc   大小:240KB   页数:11页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

LZSS压缩算法实验报告.doc

上传人:mh900965 2016/8/26 文件大小:240 KB

下载得到文件列表

LZSS压缩算法实验报告.doc

文档介绍

文档介绍:实验名称: LZSS 压缩算法实验报告一、实验内容使用 Visual 6..0 C++ 编程实现 LZ77 压缩算法。二、实验目的用 LZSS 实现文件的压缩。三、实验原理 LZSS 压缩算法是词典编码无损压缩技术的一种。 LZSS 压缩算法的字典模型使用了自适应的方式,也就是说,将已经编码过的信息作为字典, 四、实验环境 1 、软件环境: Visual C++ 2 、编程语言: C++ 五、实验代码#include <> #include <> #include <> #include <> /* size of ring buffer */ #define N 4096 /* index for root of binary search trees */ #define NIL N /* upper limit for g_match_len. Changed from 18 to 16 for patability with and #define F 18 */ #define F 16 /* encode string into position and length if match_length is greater than this: */ #define THRESHOLD 2 /* these assume little-endian CPU like Intel x86 -- need byte-swap function for big endian CPU */ #define READ_LE32(X) *(uint32_t *)(X) #define WRITE_LE32(X,Y) *(uint32_t *)(X) = (Y) /* this assumes sizeof(long)==4 */ typedef unsigned long uint32_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 parison */ static unsigned char g_ring_buffer[N +F- 1]; /* position and length of longest match; set by insert_node() */ static unsigned g_match_pos, g_match_len; /* left & right children & parent -- these constitute binary search tree */ static unsigned g_left_child[N + 1], g_right_child[N + 257], g_parent[N + 1]; /* input & output files */ static FILE *g_infile, *g_outfile; /***************************************************************************** initialize trees *****************************************************************************/ static void init_tree(void) { unsigned i; /* For i=0 toN- 1, g_right_child[i] and g_left_child[i] will be the right and left children of node i. These nodes need not be initialized. Also, g_parent[i] is the parent of node i. These are initialized to NIL (= N), which stands for 'not used.' For i=0 to 255, g_right_child[N +i+ 1] is the root of the