PESCA lzh,

, zeer snel lzh compressor, Copywriter: Kurt haenen, {% R} {geen bereik te controleren.!} {, ---------------------------------------------------------------,         deze post met inbegrip van de bron van de turbo - Pascal, lzrw1 /KH - versie van ---------------------------------------------------------------, documenten,&#lzrw1kh eenheid 1, --------------------------,} {###################################################################} {#&## #} {#&##&###### #####&##&##&##&##&##&##&##&##&##} {#&##&##&##&##&##&##&##&##&##&##&##&##&##&##&##} {#&##&##&## ##### #######&##&##&##&## ######&##} {#&##&##&##&##&##&##&##&##&##&###&##&##&##&## #} {#&###### #####&##&##&##&##&##&##&##&##&##&##&##&##} {#&## #} {#&#zeer snel en gemakkelijk te begrijpen van de compressie algoritme&##} {#&## #} {###################################################################} {#&## #} {#&#deze eenheid tot vernieuwing lzrw1 /KH algoritme,&##} {#&#voert ook een aantal van rie dit nuttig zijn als&##} {#&#- bevat een groot aantal bytes&#continu #} {#&#op documenten,Dezelfde waarde.Het algoritme is niet goed&##} {#,&#lzh, maar kunnen worden gebruikt in het kader van de concurrentie, man.Dit' vasten&##} {#&#een ik' die tot nu toe.# #} {#&## #} {#&## #} {#&## #} {#&#Kurt haenen&##} {#&## #} {###################################################################}, eenheid lzrw1kh;, interfaces, het gebruik van de SysUtils;, ifdef} {%, - int16 = rij, {%; andere vormen van int16 = integer} {}; als de dollar, totaal,         buffermaxsize = 32768;,         buffermax = buffermaxsize-1;,         flag_copied = 80 dollar,         flag_compress = 40 dollar;,-  ,       bufferindex = 0. Buffermax + 15,      ;   cache = 0. Buffermaxsize;               {hier extra bytes - * * * * * * * * * * * * * *, als niet -  },       bufferarray = - [bufferindex bytes,        ; bufferptr = ^ bufferarray;,         elzrw1khcompressor = (uitzonderingen), - (functie; Bron: bufferptr DEST,                                                            ; sourcesize: caching: caching),, (Bron: bufferptr decompressie doelstelling;  ,                                                           sourcesize: geld): caching;, de aard, de   was   = - [0] projecten. Hoger.     hashtabptr = ^;哈希表;,VaR,  散列:hashtabptr;,                             {检查这个字符串已经                             },{在目前4 kb窗口},功能getmatch(来源:bufferptr;,                              X:bufferindex;,                              sourcesize:缓存;,                              散列:hashtabptr;,                          VAR尺寸:字;,                          VAR POS:bufferindex ) : BOOLEAN;, VAR,   HashValue : WORD;,   TmpHash : Int16;, BEGIN,   HashValue := (40543*((((Source^[X] SHL 4) XOR Source^[X+1]) SHL 4) XOR,                                      Source^[X+2]) SHR 4) AND $0FFF;,   Result := FALSE;,   TmpHash := Hash^[HashValue];,   IF (TmpHash <> -1) and (X - TmpHash < 4096) THEN BEGIN,     Pos := TmpHash;,     Size := 0;,     WHILE ((Size < 18) AND (Source^[X+Size] = Source^[Pos+Size]),                        AND (X+Size < SourceSize)) DO begin,       INC(Size);,     end;,     Result := (Size >= 3),   END;,   Hash^[HashValue] := X, END; ,,                                    {压缩缓冲最多32 KB },功能压缩(源目录:bufferptr;,                      sourcesize:缓存):缓存;,VaR,  点,命令,尺寸:字;,  关键词;,  X,Y,Z,POS,开始,bufferindex;  fillchar(哈希^,sizeof(哈希表),$法郎);,  DeST ^ [ 0 ]:= flag_compress;,  x:= 0;,  Y:= 3;,  Z = 1;,  点:= 0;,  命令:= 0;同时,  (X <;sourcesize)和(Y <;= sourcesize)开始,    如果(位>;15)然后开始,      DeST ^ [Z]:=嗨(命令);,      DeST ^ [ Z + 1 ]:=罗(命令),      Z;= Y,      点;:= 0;,       INC(Y,2),     END;,     Size := 1;,     WHILE ((Source^[X] = Source^[X+Size]) AND (Size < $FFF),                          AND (X+Size < SourceSize)) DO begin,               INC(Size);,     end;,     IF (Size >= 16) THEN BEGIN,       Dest^[Y] := 0;,       Dest^[Y+1] := HI(Size-16);,       Dest^[Y+2] := LO(Size-16);,       Dest^[Y+3] := Source^[X];,       INC(Y,4);,       INC(X,Size);,       Command := (Command SHL 1) + 1;,     END,     ELSE begin { not size >= 16 },       IF (GetMatch(Source,X,SourceSize,Hash,Size,Pos)) THEN BEGIN,         Key := ((X-Pos) SHL 4) + (Size-3);,         DeST ^ [Y]:=嗨(关键);,        DeST ^ [ y + 1 ]:=罗(重点);,        公司(Y,2);,        公司(X,大小);,        命令:=(命令:1)+ 1,      结束,      其他的开始,        DeST ^ [Y]:=源^ [x];,        公司(Y);,        公司(x);,        命令:=命令SHL 1,      结束;结束,    ;{大小<;= 16 },    公司(位),  ;{结束;而X <;sourcesize…},  命令:=命令SHL(16位);,  DeST ^ [Z]:=嗨(命令);,  DeST ^ [ Z + 1 ]:=罗(命令);如果,  (Y >;sourcesize)然后开始移动,    (来源^ [ 0 ],接待^ [ 1 ],sourcesize);,    DeST ^ [ 0 ]:= flag_copied;,    Y =成功(sourcesize),  端;,  结果:= Y,结束;,                                    {减压缓冲最大32 KB的},功能减压(源目录:bufferptr;,                        sourcesize:缓存):缓存;,VaR,  X,Y,POS:bufferindex;,  命令,尺寸,K字;,  位:字节;,  悟性:bufferindex;{ * DH *循环变量Y不安全}, BEGIN,   IF (Source^[0] = FLAG_Copied) THEN begin,     FOR Y := 1 TO PRED(SourceSize) DO begin,       Dest^[PRED(Y)] := Source^[Y];,       SaveY := Y;,     end;,     Y := SaveY;,   end,   ELSE BEGIN,     Y := 0;,     X := 3;,     Command := (Source^[1] SHL 8) + Source^[2];,     Bit := 16;,     WHILE (X < SourceSize) DO BEGIN,       IF (Bit = 0) THEN BEGIN,         Command := (Source^[X] SHL 8) + Source^[X+1];,         Bit := 16;,         INC(X,2),       END;,       IF ((Command AND $8000) = 0) THEN BEGIN,            Dest^[Y] := Source^[X];,            INC(X);,            INC(Y),       END,       ELSE BEGIN { command and $8000 },         Pos := ((Source^[X] SHL 4),                +(Source^[X+1] SHR 4));,         IF (Pos = 0) THEN BEGIN,           Size := (Source^[X+1] SHL 8) + Source^[X+2] + 15;,           FOR K := 0 TO Size DO begin,                Dest^[Y+K] := Source^[X+3];,           end;,           INC(X,4);,           INC(Y,Size+1),         END,         ELSE BEGIN { pos = 0 },           Size := (Source^[X+1] AND $0F)+2;,           FOR K := 0 TO Size DO,                Dest^[Y+K] := Dest^[Y-Pos+K];,           INC(X,2);,           INC(Y,Size+1),         END; { pos = 0 },       END; { command and $8000 },       Command := Command SHL 1;,       DEC(Bit),     END { while x < sourcesize },   END;,   Result := Y, END; { decompression }, {,   Unit "Finalization" as Delphi 2.0 would have it, }, var,   ExitSave : Pointer;, Procedure Cleanup; far;, begin,   ExitProc := ExitSave;,   if (Hash <> Nil) then,     Freemem(Hash, Sizeof(HashTable));, end;, Initialization,   Hash := Nil;,   try,     Getmem(Hash,Sizeof(Hashtable));,   except,     Raise ELzrw1KHCompressor.Create('LZRW1KH : no memory for HASH table');,   end;,   ExitSave := ExitProc;,   ExitProc := @Cleanup;, END.,



Previous:
Next Page: