資源簡介
LZ77數據無損壓縮算法,可以說實現數據的壓縮和解壓

代碼片段和文件信息
/*******************************************
?*?????????????????????????????????????????*
?*??????Lempel-Ziv?77?Data?Compressor??????*
?*??????Demo?Program?by?Rachad?ALAO????????*
?*??????ENST?/?Telecom?Copyright?1997??????*
?*?????????????????????????????????????????*
?*******************************************/
#include?
#include?
#include?
#include?
struct?Match?{
????????int?Length;
????????int?Pointer;
????????};
/*?look?ahead?buffer?size?*/
int?N?=?512;
/*?look?ahead?buffer?size?in?bits?*/
int?NB?=?9;
/*?input?words?buffer?size?*/
int?M?=?32;
/*?Words?Buffer?size?in?bits?*/
int?MB?=?5;
/*?The?Words?Buffer?and?base?of?the?Allocated?memory?*/
unsigned?char?*Buffer?*base;
/*?Number?of?words?in?the?Word?Buffer?used?to?handle?the?eof?*/
int???????????NW?=?0;
/*?The?ascii?Probabilities?Board?*/
unsigned?long?Proba[256];
/***********************************************************************
?????????????????????????My?Bit?File?library
?***********************************************************************/
#define?Cache_Size?20000
#define?Error?-1
#define?Ok?1
struct?BFILE?{
????????FILE?*f;??????????????????????????/*?The?physical?file???????????????????*/
????????unsigned?char?Cache[Cache_Size];??/*?The?Cache?used?to?acces?the?File????*/
????????unsigned?char?CByte;??????????????/*?The?Current?Word?being?written??????*/
????????int??CBPos;???????????????????????/*?Current?Pos.?in?the?Current?Word????*/
????????unsigned?int?CPos;????????????????/*?Current?Pos.?in?the?Cache???????????*/
????????unsigned?int?CEnd;????????????????/*?Cache?End?if?not?full???????????????*/
????????char?Mode;????????????????????????/*?R?=?Read?W?=?Write?????????????????*/
????????char?eof;?????????????????????????/*?!=0?if?end?of?file??????????????????*/
????????};
/****?Opens?a?Bit?File?****/
struct?BFILE?*BF_Open?(?const?char?*Name?const?char?Mode)
{?struct?BFILE?*Tmp;
??char?FMode[3];
Tmp?=?(struct?BFILE?*?)malloc(sizeof(struct?BFILE));
if?(!Tmp)
???return?NULL;
FMode[0]?=?Mode;
FMode[1]?=?‘b‘;
FMode[2]?=?‘\0‘;
Tmp->f?=?fopen(Name?FMode);
if?(Tmp->f)?{
???Tmp->Mode?=?Mode;
???if?(Mode?==?‘r‘?)?{
??????/*?Fills?the?bit?file?cache?if?in?R?mode*/
??????Tmp->CEnd??=?fread?(Tmp->Cache?sizeof(unsigned?char)?Cache_Size?Tmp->f);
??????Tmp->CByte?=?Tmp->Cache[0];
??????Tmp->CBPos?=?7;
??????Tmp->CPos??=?1;
??????Tmp->eof???=?0;
??????}
???else?{
??????Tmp->CEnd??=?0;
??????Tmp->CPos??=?0;
??????Tmp->CBPos?=?0;
??????Tmp->CByte?=?0;
??????Tmp->eof???=?1;
??????}
???}
else?{
?????free?(Tmp);
?????return?NULL;
?????}
return?Tmp;
}
/****?Writes?nbits?bits?in?the?BFILE?*f?****/
int?BF_Write?(?unsigned?long?bits?int?nbits?struct?BFILE?*f)
{?int?i?=?0;
if?(!f?||?f->Mode?!=?‘w‘)
???return?Error;
if?(nbits?>?8?*?sizeof(unsigned?long))
???nbits?=?8?*?sizeof?(unsigned?long);
for?(i?=
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????18377??2011-11-21?20:46??LZ773\code\lz77.c
?????文件??????59904??2011-11-01?17:15??LZ773\pro\Debug\d.doc
?????文件??????59904??2011-11-21?20:50??LZ773\pro\Debug\dewq.doc
?????文件?????208983??2011-11-21?20:47??LZ773\pro\Debug\lz77.exe
?????文件?????231328??2011-11-21?20:47??LZ773\pro\Debug\lz77.ilk
?????文件??????36322??2011-11-21?20:46??LZ773\pro\Debug\lz77.obj
?????文件?????201608??2011-11-21?20:46??LZ773\pro\Debug\lz77.pch
?????文件?????492544??2011-11-21?20:53??LZ773\pro\Debug\lz77.pdb
?????文件??????14542??2011-11-21?20:49??LZ773\pro\Debug\qq
?????文件??????33792??2011-11-21?21:38??LZ773\pro\Debug\vc60.idb
?????文件??????53248??2011-11-21?20:46??LZ773\pro\Debug\vc60.pdb
?????文件???????3433??2011-11-21?20:55??LZ773\pro\lz77.dsp
?????文件????????533??2011-11-21?20:35??LZ773\pro\lz77.dsw
?????文件??????50176??2011-11-21?21:51??LZ773\pro\lz77.ncb
?????文件??????48640??2011-11-21?21:51??LZ773\pro\lz77.opt
?????文件????????242??2011-11-21?21:38??LZ773\pro\lz77.plg
?????文件????????713??2011-11-21?20:55??LZ773\readme.txt
?????文件??????59904??2011-11-01?17:15??LZ773\test\d.doc
?????文件??????59904??2011-11-21?20:50??LZ773\test\dewq.doc
?????文件?????208987??2011-11-21?20:53??LZ773\test\lz77.exe
?????文件?????224608??2011-11-21?20:53??LZ773\test\lz77.ilk
?????文件??????14542??2011-11-21?20:49??LZ773\test\qq
?????目錄??????????0??2011-11-21?20:53??LZ773\code\Debug
?????目錄??????????0??2011-11-21?20:50??LZ773\pro\Debug
?????目錄??????????0??2011-11-21?20:53??LZ773\code
?????目錄??????????0??2011-11-21?21:51??LZ773\pro
?????目錄??????????0??2011-11-21?20:53??LZ773\test
?????目錄??????????0??2011-11-21?20:55??LZ773
-----------?---------??----------?-----??----
??????????????2082234????????????????????28
............此處省略1個文件信息
評論
共有 條評論