用C语言编写程序实现Zip或者Rar无损压缩算法
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
*HUFF.C Huffman encode for multimedia application 8*8 pixel Ver 3 *
* *
*Ver 1: Complied in Borland Turbo C++ 3.0 *
*Ver 2: Complied in Microsoft Visual C++ 6.0 *
*Ver 3: Complied in Microsoft Visual C++ 6.0 *
* add code to print code table of the compression *
* print output message in Chinese *
* *
*by Lee Meitz, Solid Mechanics, Huazhong Univ of Sci and Tech *
*2001.11.15 - 2001.12.27 *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define DNUM 64 //define data number 8*8
#define LOOP 10000 //times of compression
typedef struct
{
unsigned short weight, data;
unsigned short parent, lchild, rchild;
} HuffNode;
typedef struct
{
unsigned char code;
unsigned short codelength;
} HuffCode;
unsigned int fCount[256] = {0};
unsigned int data_num;
unsigned int code_size;
unsigned int last_bit;
void FrequencyCount(unsigned char*); //频率统计
void HuffSelect(HuffNode*, int, int*, int*); //从结点中选出权最小的两个

这是一个用C语言编写的程序,用于实现Zip或Rar无损压缩算法。程序包括频率统计、Huffman编码表构建、数据压缩等功能,并提供了不同版本的编译信息。代码中包含对8x8像素数据的处理,以及随机数据的压缩示例。
5663

被折叠的 条评论
为什么被折叠?



