資源簡介
主要是實現了LZ77算法的代碼,并且將lz77算法相關的文檔和演示圖片一并上傳,供大家研究和學習。

代碼片段和文件信息
//////////////////////////////???
//?LZ77.CPP???
//////////////////////////////???
???
#include????
#include????
#include????
#include????
???
#include?“lz77.h“???
???
/////////////////////////////////////////////////////////???
//?取log2(n)的upper_bound???
int?CCompress::UpperLog2(int?n)???
{???
????int?i?=?0;???
????if?(n?>?0)???
????{???
????????int?m?=?1;???
????????while(1)???
????????{???
????????????if?(m?>=?n)???
????????????????return?i;???
????????????m?<<=?1;???
????????????i++;???
????????}???
????}???
????else????
????????return?-1;???
}???
//?UpperLog2???
/////////////////////////////////////////////////////////???
???
/////////////////////////////////////////////////////////???
//?取log2(n)的lower_bound???
int?CCompress::LowerLog2(int?n)???
{???
????int?i?=?0;???
????if?(n?>?0)???
????{???
????????int?m?=?1;???
????????while(1)???
????????{???
????????????if?(m?==?n)???
????????????????return?i;???
????????????if?(m?>?n)???
????????????????return?i?-?1;???
????????????m?<<=?1;???
????????????i++;???
????????}???
????}???
????else????
????????return?-1;???
}???
//?LowerLog2???
/////////////////////////////////////////////////////////???
???
////////////////////////////////////////////////////////////???
//?將位指針*piByte(字節偏移)?*piBit(字節內位偏移)后移num位???
void?CCompress::MovePos(int*?piByte?int*?piBit?int?num)???
{???
????num?+=?(*piBit);???
????(*piByte)?+=?num?/?8;???
????(*piBit)?=?num?%?8;???
}???
//?MovePos???
////////////////////////////////////////////////////////////???
???
////////////////////////////////////////////////////////////???
//?得到字節byte第pos位的值???
//??????pos順序為高位起從0記數(左起)???
BYTE?CCompress::GetBit(BYTE?byte?int?pos)???
{???
????int?j?=?1;???
????j?<<=?7?-?pos;???
????if?(byte?&?j)???
????????return?1;???
????else????
????????return?0;???
}???
//?GetBit???
/////////////////////////////////////////////////////////////???
???
/////////////////////////////////////////////////////////////???
//?設置byte的第iBit位為aBit???
//??????iBit順序為高位起從0記數(左起)???
void?CCompress::SetBit(BYTE*?byte?int?iBit?BYTE?aBit)???
{???
????if?(aBit)???
????????(*byte)?|=?(1?<(7?-?iBit));???
????else???
????????(*byte)?&=?~(1?<(7?-?iBit));???
}???
//?SetBit???
//////////////////////////////////////////////////////////////???
???
//////////////////////////////////////////////////////////////???
//?將DWORD值從高位字節到低位字節排列???
void?CCompress::InvertDWord(DWORD*?pDW)???
{???
????union?UDWORD{?DWORD?dw;?BYTE?b[4];?};???
????UDWORD*?pUDW?=?(UDWORD*)pDW;???
????BYTE?b;???
????b?=?pUDW->b[0];??pUDW->b[0]?=?pUDW->b[3];?pUDW->b[3]?=?b;???
????b?=?pUDW->b[1];??pUDW->b[1]?=?pUDW->b[2];?pUDW->b[2]?=?b;???
}???
//?InvertDWord???
//////////////////////////////////////////////////////////////???
???
////////////////////////////////////////////////////////???
//?CopyBits?:?復制內存中的位流???
//??????memDest?-?目標數據區???
//??????nDe
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????13??2012-08-16?18:44??lz77\compress.txt
?????文件??????33063??2009-04-23?17:05??lz77\Debug\Lz77.obj
?????文件?????204884??2009-04-23?17:54??lz77\Debug\lz77temp.exe
?????文件?????223756??2009-04-23?17:54??lz77\Debug\lz77temp.ilk
?????文件????3567212??2009-04-23?17:05??lz77\Debug\lz77temp.pch
?????文件?????525312??2009-04-23?17:54??lz77\Debug\lz77temp.pdb
?????文件??????17220??2009-04-23?17:54??lz77\Debug\main.obj
?????文件?????148480??2009-04-23?17:54??lz77\Debug\vc60.idb
?????文件??????77824??2009-04-23?17:54??lz77\Debug\vc60.pdb
?????文件?????????11??2012-08-16?18:44??lz77\decompress.txt
?????文件?????????11??2009-04-23?17:50??lz77\input.txt
?????文件??????15293??2009-04-23?16:59??lz77\Lz77.cpp
?????文件???????5070??2009-04-23?16:58??lz77\Lz77.h
?????文件???????4424??2009-04-23?17:56??lz77\lz77temp.dsp
?????文件????????524??2009-04-23?16:51??lz77\lz77temp.dsw
?????文件?????204884??2009-04-23?17:54??lz77\lz77temp.exe
?????文件??????41984??2009-04-23?17:56??lz77\lz77temp.ncb
?????文件??????49664??2009-04-23?17:56??lz77\lz77temp.opt
?????文件???????1317??2009-04-23?17:54??lz77\lz77temp.plg
?????文件?????161280??2012-08-16?18:44??lz77\LZ77壓縮算法詳解.doc
?????文件??????43101??2012-08-23?17:17??lz77\LZ77算法的基本原理.docx
????I.A....?????75779??2012-08-23?14:11??lz77\LZ77編碼算法圖解.pdf
?????文件???????4671??2009-04-23?17:56??lz77\main.cpp
?????文件?????????85??2009-04-23?17:55??lz77\說明.txt
?????目錄??????????0??2009-04-23?18:31??lz77\Debug
?????目錄??????????0??2012-11-06?09:18??lz77
-----------?---------??----------?-----??----
??????????????5405862????????????????????26
評論
共有 條評論