update to 0.7.0
This commit is contained in:
@@ -122,7 +122,7 @@ begin
|
||||
end;
|
||||
|
||||
function ExecStdioProcess(Ctx: PExecCtx; InBuff: Pointer;
|
||||
var InSize, OutSize: Integer; Output: _ExecOutput): Boolean;
|
||||
InSize, OutSize: Integer; Output: _ExecOutput): Boolean;
|
||||
|
||||
function ProcessLib(Instance: Integer; Stdin, Stdout: THandle): Boolean;
|
||||
const
|
||||
@@ -131,18 +131,20 @@ function ExecStdioProcess(Ctx: PExecCtx; InBuff: Pointer;
|
||||
Buffer: array [0 .. BufferSize - 1] of Byte;
|
||||
BytesRead: DWORD;
|
||||
X: Integer;
|
||||
LOutSize: Integer;
|
||||
begin
|
||||
Result := False;
|
||||
LOutSize := OutSize;
|
||||
try
|
||||
FileWriteBuffer(Stdin, InSize, InSize.Size);
|
||||
FileWriteBuffer(Stdin, OutSize, OutSize.Size);
|
||||
FileWriteBuffer(Stdin, LOutSize, LOutSize.Size);
|
||||
FileWriteBuffer(Stdin, InBuff^, InSize);
|
||||
FileReadBuffer(Stdout, OutSize, OutSize.Size);
|
||||
if OutSize <= 0 then
|
||||
FileReadBuffer(Stdout, LOutSize, LOutSize.Size);
|
||||
if LOutSize <= 0 then
|
||||
exit
|
||||
else
|
||||
begin
|
||||
X := OutSize;
|
||||
X := LOutSize;
|
||||
while X > 0 do
|
||||
begin
|
||||
BytesRead := Min(X, Length(Buffer));
|
||||
@@ -636,16 +638,16 @@ begin
|
||||
SI.Option := StreamInfo.Option;
|
||||
if ExeDecode(X, Instance, Input, @SI, Funcs) then
|
||||
begin
|
||||
Funcs^.LogRestore(PChar(Codec.Names[X]), nil, StreamInfo.OldSize,
|
||||
StreamInfo.NewSize, Res1, True);
|
||||
Buffer := Funcs^.Allocator(Instance, CodecSize[Instance]);
|
||||
Res1 := CodecSize[Instance];
|
||||
Funcs^.LogPatch2(StreamInfo.OldSize, Res1, StreamInfo.ExtSize, Res2 > 0);
|
||||
Funcs^.LogRestore(PChar(Codec.Names[X]), nil, StreamInfo.OldSize,
|
||||
StreamInfo.NewSize, Res1, True);
|
||||
if GetBits(StreamInfo.Option, 31, 1) = 1 then
|
||||
begin
|
||||
Buffer := Funcs^.Allocator(Instance, Res1 + StreamInfo.OldSize);
|
||||
Res2 := PrecompDecodePatch(InputExt, StreamInfo.ExtSize, Buffer, Res1,
|
||||
Buffer + Res1, StreamInfo.OldSize);
|
||||
Funcs^.LogPatch2(StreamInfo.OldSize, Res1, StreamInfo.ExtSize, Res2 > 0);
|
||||
if Res2 > 0 then
|
||||
begin
|
||||
Output(Instance, Buffer + Res1, StreamInfo.OldSize);
|
||||
|
@@ -47,7 +47,7 @@ type
|
||||
StreamPosition, StreamOffset, OldSize, NewSize, DepthSize: String;
|
||||
Names, Exprs: TArray<String>;
|
||||
Values: TArray<Double>;
|
||||
Conditions: TArray<String>;
|
||||
Conditions: array [0 .. 2] of TArray<String>;
|
||||
end;
|
||||
|
||||
PCfgRecDynArray = ^TCfgRecDynArray;
|
||||
@@ -149,9 +149,12 @@ begin
|
||||
Exprs[Y] := CodecCfg[0, J, X].Exprs[Y];
|
||||
Values[Y] := CodecCfg[0, J, X].Values[Y];
|
||||
end;
|
||||
SetLength(Conditions, Length(CodecCfg[0, J, X].Conditions));
|
||||
for Y := Low(Conditions) to High(Conditions) do
|
||||
Conditions[Y] := CodecCfg[0, J, X].Conditions[Y];
|
||||
for Z := Low(Conditions) to High(Conditions) do
|
||||
begin
|
||||
SetLength(Conditions[Z], Length(CodecCfg[0, J, X].Conditions[Z]));
|
||||
for Y := Low(Conditions[Z]) to High(Conditions[Z]) do
|
||||
Conditions[Z, Y] := CodecCfg[0, J, X].Conditions[Z, Y];
|
||||
end;
|
||||
for Z := Low(Structure) to High(Structure) do
|
||||
for Y := Low(Structure[Z]) to High(Structure[Z]) do
|
||||
Parser.DefineVariable(Structure[Z, Y].Name,
|
||||
@@ -331,6 +334,12 @@ begin
|
||||
if Status = TScanStatus.Fail then
|
||||
break;
|
||||
end;
|
||||
for Y := Low(Conditions[0]) to High(Conditions[0]) do
|
||||
if Round(Parser.Evaluate(Conditions[0, Y])) = 0 then
|
||||
begin
|
||||
Status := TScanStatus.Fail;
|
||||
break;
|
||||
end;
|
||||
if Status = TScanStatus.Fail then
|
||||
begin
|
||||
Inc(Pos);
|
||||
@@ -369,68 +378,75 @@ begin
|
||||
end;
|
||||
if Status = TScanStatus.Fail then
|
||||
break;
|
||||
StreamPosInt1 := Pos + Round(Parser.Evaluate(StreamPosition));
|
||||
StreamPosInt2 := StreamPosInt1;
|
||||
for Y := Low(Structure[2]) to High(Structure[2]) do
|
||||
begin
|
||||
if (Structure[2, Y].BeforeStream = True) then
|
||||
for Y := Low(Conditions[1]) to High(Conditions[1]) do
|
||||
if Round(Parser.Evaluate(Conditions[1, Y])) = 0 then
|
||||
begin
|
||||
if Structure[2, Y].Name = 'Stream' then
|
||||
begin
|
||||
StreamPosInt1 := StreamPosInt2;
|
||||
continue;
|
||||
end;
|
||||
Funcs^.ReadFuture(Instance, StreamPosInt2,
|
||||
Structure[2, Y].Data, Structure[2, Y].Size);
|
||||
I64 := 0;
|
||||
EndianMove(Structure[2, Y].Data, @I64,
|
||||
Min(Structure[2, Y].Size, I64.Size), BigEndian);
|
||||
Structure[2, Y].Value := I64.ToDouble;
|
||||
Inc(StreamPosInt2, Structure[2, Y].Size);
|
||||
Status := TScanStatus.Fail;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
for A := Low(Exprs) to High(Exprs) do
|
||||
if Status = TScanStatus.None then
|
||||
begin
|
||||
for B := Low(Exprs) to High(Exprs) do
|
||||
try
|
||||
if A = B then
|
||||
StreamPosInt1 := Pos +
|
||||
Round(Parser.Evaluate(StreamPosition));
|
||||
StreamPosInt2 := StreamPosInt1;
|
||||
for Y := Low(Structure[2]) to High(Structure[2]) do
|
||||
begin
|
||||
if (Structure[2, Y].BeforeStream = True) then
|
||||
begin
|
||||
if Structure[2, Y].Name = 'Stream' then
|
||||
begin
|
||||
StreamPosInt1 := StreamPosInt2;
|
||||
continue;
|
||||
Values[B] := Parser.Evaluate(Exprs[B]);
|
||||
end;
|
||||
Funcs^.ReadFuture(Instance, StreamPosInt2,
|
||||
Structure[2, Y].Data, Structure[2, Y].Size);
|
||||
I64 := 0;
|
||||
EndianMove(Structure[2, Y].Data, @I64,
|
||||
Min(Structure[2, Y].Size, I64.Size), BigEndian);
|
||||
Structure[2, Y].Value := I64.ToDouble;
|
||||
Inc(StreamPosInt2, Structure[2, Y].Size);
|
||||
end;
|
||||
end;
|
||||
for A := Low(Exprs) to High(Exprs) do
|
||||
begin
|
||||
for B := Low(Exprs) to High(Exprs) do
|
||||
try
|
||||
if A = B then
|
||||
continue;
|
||||
Values[B] := Parser.Evaluate(Exprs[B]);
|
||||
except
|
||||
end;
|
||||
try
|
||||
Values[A] := Parser.Evaluate(Exprs[A]);
|
||||
except
|
||||
end;
|
||||
try
|
||||
Values[A] := Parser.Evaluate(Exprs[A]);
|
||||
except
|
||||
end;
|
||||
end;
|
||||
StreamOffsetInt := Round(Parser.Evaluate(StreamOffset));
|
||||
OldSizeInt := Round(Parser.Evaluate(OldSize));
|
||||
NewSizeInt := Round(Parser.Evaluate(NewSize));
|
||||
DepthSizeInt := Round(Parser.Evaluate(DepthSize));
|
||||
for Y := Low(Structure[2]) to High(Structure[2]) do
|
||||
begin
|
||||
if (Structure[2, Y].BeforeStream = False) then
|
||||
StreamOffsetInt := Round(Parser.Evaluate(StreamOffset));
|
||||
OldSizeInt := Round(Parser.Evaluate(OldSize));
|
||||
NewSizeInt := Round(Parser.Evaluate(NewSize));
|
||||
DepthSizeInt := Round(Parser.Evaluate(DepthSize));
|
||||
for Y := Low(Structure[2]) to High(Structure[2]) do
|
||||
begin
|
||||
Funcs^.ReadFuture(Instance, StreamPosInt2 + OldSizeInt,
|
||||
Structure[2, Y].Data, Structure[2, Y].Size);
|
||||
I64 := 0;
|
||||
EndianMove(Structure[2, Y].Data, @I64,
|
||||
Min(Structure[2, Y].Size, I64.Size), BigEndian);
|
||||
Structure[2, Y].Value := I64.ToDouble;
|
||||
Inc(StreamPosInt2, Structure[2, Y].Size);
|
||||
if (Structure[2, Y].BeforeStream = False) then
|
||||
begin
|
||||
Funcs^.ReadFuture(Instance, StreamPosInt2 + OldSizeInt,
|
||||
Structure[2, Y].Data, Structure[2, Y].Size);
|
||||
I64 := 0;
|
||||
EndianMove(Structure[2, Y].Data, @I64,
|
||||
Min(Structure[2, Y].Size, I64.Size), BigEndian);
|
||||
Structure[2, Y].Value := I64.ToDouble;
|
||||
Inc(StreamPosInt2, Structure[2, Y].Size);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if Length(Conditions) = 0 then
|
||||
DoAddStream(CodecCfg[Instance, I, J])
|
||||
else
|
||||
for Y := Low(Conditions) to High(Conditions) do
|
||||
begin
|
||||
if (Round(Parser.Evaluate(Conditions[Y])) <> 0) and
|
||||
(Y = High(Conditions)) then
|
||||
DoAddStream(CodecCfg[Instance, I, J])
|
||||
else
|
||||
for Y := Low(Conditions[2]) to High(Conditions[2]) do
|
||||
if Round(Parser.Evaluate(Conditions[2, Y])) = 0 then
|
||||
begin
|
||||
Status := TScanStatus.Fail;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if Status = TScanStatus.None then
|
||||
DoAddStream(CodecCfg[Instance, I, J]);
|
||||
UpdateCounters(CodecCfg[Instance, I, J]);
|
||||
for Y := Low(Counter) to High(Counter) do
|
||||
begin
|
||||
@@ -628,15 +644,25 @@ begin
|
||||
CfgRec^.DepthSize := ReadString('StreamList' + X.ToString,
|
||||
'DepthSize', '0');
|
||||
ConvertHexChr(CfgRec^.DepthSize);
|
||||
Y := 1;
|
||||
while ReadString('StreamList' + X.ToString, 'Condition' + Y.ToString,
|
||||
'') <> '' do
|
||||
for Z := Low(CfgRec^.Conditions) to High(CfgRec^.Conditions) do
|
||||
begin
|
||||
S2 := ReadString('StreamList' + X.ToString,
|
||||
'Condition' + Y.ToString, '');
|
||||
ConvertHexChr(S2);
|
||||
Insert(S2, CfgRec^.Conditions, Length(CfgRec^.Conditions));
|
||||
Inc(Y);
|
||||
case Z of
|
||||
0:
|
||||
S3 := 'Condition1_';
|
||||
1:
|
||||
S3 := 'ConditionN_';
|
||||
2:
|
||||
S3 := 'ConditionS_';
|
||||
end;
|
||||
Y := 1;
|
||||
while ReadString('StreamList' + X.ToString, S3 + Y.ToString,
|
||||
'') <> '' do
|
||||
begin
|
||||
S2 := ReadString('StreamList' + X.ToString, S3 + Y.ToString, '');
|
||||
ConvertHexChr(S2);
|
||||
Insert(S2, CfgRec^.Conditions[Z], Length(CfgRec^.Conditions[Z]));
|
||||
Inc(Y);
|
||||
end;
|
||||
end;
|
||||
ReadSectionValues('StreamList' + X.ToString, SL);
|
||||
for J := SL.Count - 1 downto 0 do
|
||||
|
@@ -62,8 +62,8 @@ begin
|
||||
if (CompareText(S, LZ4Codecs[LZ4_CODEC]) = 0) and LZ4DLL.DLLLoaded then
|
||||
begin
|
||||
CodecEnabled[LZ4_CODEC] := True;
|
||||
if Funcs^.GetParam(Command, X, 'm') <> '' then
|
||||
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 'm'));
|
||||
if Funcs^.GetParam(Command, X, 's') <> '' then
|
||||
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 's'));
|
||||
if Funcs^.GetParam(Command, X, 'a') <> '' then
|
||||
LAcceleration := StrToInt(Funcs^.GetParam(Command, X, 'a'));
|
||||
end
|
||||
@@ -75,8 +75,8 @@ begin
|
||||
for I := Low(SOList) to High(SOList) do
|
||||
SOList[I][LZ4HC_CODEC].Update
|
||||
([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True);
|
||||
if Funcs^.GetParam(Command, X, 'm') <> '' then
|
||||
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 'm'));
|
||||
if Funcs^.GetParam(Command, X, 's') <> '' then
|
||||
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 's'));
|
||||
end
|
||||
else if (CompareText(S, LZ4Codecs[LZ4F_CODEC]) = 0) and LZ4DLL.DLLLoaded
|
||||
then
|
||||
@@ -86,8 +86,8 @@ begin
|
||||
for I := Low(SOList) to High(SOList) do
|
||||
SOList[I][LZ4F_CODEC].Update
|
||||
([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True);
|
||||
if Funcs^.GetParam(Command, X, 'm') <> '' then
|
||||
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 'm'));
|
||||
if Funcs^.GetParam(Command, X, 's') <> '' then
|
||||
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 's'));
|
||||
if Funcs^.GetParam(Command, X, 'b') <> '' then
|
||||
LBlockSize := StrToInt(Funcs^.GetParam(Command, X, 'b')) - 4;
|
||||
if Funcs^.GetParam(Command, X, 'd') <> '' then
|
||||
@@ -232,34 +232,34 @@ begin
|
||||
(CodecEnabled[LZ4HC_CODEC] and (SOList[Instance][LZ4HC_CODEC].Count = 1))
|
||||
then
|
||||
begin
|
||||
Y := LZ4_decompress_safe(Input + Pos, Buffer, SizeEx - Pos, LMaxSize);
|
||||
if Abs(Y) > 256 then
|
||||
if (Input + Pos)^ in [$F0 .. $F3] then
|
||||
begin
|
||||
try
|
||||
X := LZ4_decompress_generic(Input + Pos, Buffer, SizeEx - Pos, Abs(Y),
|
||||
Integer(endOnOutputSize));
|
||||
except
|
||||
X := 0;
|
||||
end;
|
||||
// X := Abs(X);
|
||||
Y := Abs(Y);
|
||||
if (Round(X * 1.4) < Y) and (X < Y) and (X > 256) then
|
||||
X := LZ4_decompress_generic(Input + Pos, Buffer, SizeEx - Pos, LMaxSize,
|
||||
Integer(endOnOutputSize));
|
||||
if X > 256 then
|
||||
Y := LZ4_decompress_safe(Input + Pos, Buffer, X, LMaxSize)
|
||||
else
|
||||
Y := 0;
|
||||
if Y > 256 then
|
||||
begin
|
||||
Output(Instance, Buffer, Y);
|
||||
SI.Position := Pos;
|
||||
SI.OldSize := X;
|
||||
SI.NewSize := Y;
|
||||
SI.Option := 0;
|
||||
if CodecEnabled[LZ4_CODEC] then
|
||||
SetBits(SI.Option, LZ4_CODEC, 0, 5)
|
||||
else
|
||||
SetBits(SI.Option, LZ4HC_CODEC, 0, 5);
|
||||
SI.Status := TStreamStatus.None;
|
||||
Funcs^.LogScan1(LZ4Codecs[GetBits(SI.Option, 0, 5)], SI.Position,
|
||||
SI.OldSize, SI.NewSize);
|
||||
Add(Instance, @SI, nil, nil);
|
||||
Inc(Pos, 256);
|
||||
continue;
|
||||
if (X < Y) and (X > 256) then
|
||||
begin
|
||||
Output(Instance, Buffer, Y);
|
||||
SI.Position := Pos;
|
||||
SI.OldSize := X;
|
||||
SI.NewSize := Y;
|
||||
SI.Option := 0;
|
||||
if CodecEnabled[LZ4_CODEC] then
|
||||
SetBits(SI.Option, LZ4_CODEC, 0, 5)
|
||||
else
|
||||
SetBits(SI.Option, LZ4HC_CODEC, 0, 5);
|
||||
SI.Status := TStreamStatus.None;
|
||||
Funcs^.LogScan1(LZ4Codecs[GetBits(SI.Option, 0, 5)], SI.Position,
|
||||
SI.OldSize, SI.NewSize);
|
||||
Add(Instance, @SI, nil, nil);
|
||||
Inc(Pos, 256);
|
||||
continue;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
@@ -135,8 +135,8 @@ begin
|
||||
for I := Low(SOList) to High(SOList) do
|
||||
SOList[I][LZO1X_CODEC].Update
|
||||
([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True);
|
||||
if Funcs^.GetParam(Command, X, 'm') <> '' then
|
||||
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 'm'));
|
||||
if Funcs^.GetParam(Command, X, 's') <> '' then
|
||||
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 's'));
|
||||
end
|
||||
else if (CompareText(S, LZOCodecs[LZO2A_CODEC]) = 0) and LZODLL.DLLLoaded
|
||||
then
|
||||
@@ -144,8 +144,8 @@ begin
|
||||
CodecEnabled[LZO2A_CODEC] := True;
|
||||
if Funcs^.GetParam(Command, X, 'v') = '999' then
|
||||
LZO2AVariant := 999;
|
||||
if Funcs^.GetParam(Command, X, 'm') <> '' then
|
||||
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 'm'));
|
||||
if Funcs^.GetParam(Command, X, 's') <> '' then
|
||||
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 's'));
|
||||
end
|
||||
else if (CompareText(S, LZOCodecs[LZO1C_CODEC]) = 0) and LZODLL.DLLLoaded
|
||||
then
|
||||
@@ -153,8 +153,8 @@ begin
|
||||
CodecEnabled[LZO1C_CODEC] := True;
|
||||
if Funcs^.GetParam(Command, X, 'v') = '999' then
|
||||
LZO1CVariant := 999;
|
||||
if Funcs^.GetParam(Command, X, 'm') <> '' then
|
||||
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 'm'));
|
||||
if Funcs^.GetParam(Command, X, 's') <> '' then
|
||||
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 's'));
|
||||
end;
|
||||
Inc(X);
|
||||
end;
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -25,7 +25,7 @@ const
|
||||
|
||||
const
|
||||
FLAC_LEVEL = 5;
|
||||
J_WORKMEM = 262144;
|
||||
J_WORKMEM = 65536;
|
||||
|
||||
type
|
||||
PFlacEncCD = ^TFlacEncCD;
|
||||
@@ -776,6 +776,7 @@ begin
|
||||
JOJPEG_CODEC:
|
||||
begin
|
||||
ctx := JJInst[Instance];
|
||||
FillChar(ctx^, jojpeg_Size, 0);
|
||||
Buffer := Funcs^.Allocator(Instance, J_WORKMEM * 2);
|
||||
I := 0;
|
||||
J := 0;
|
||||
@@ -789,14 +790,14 @@ begin
|
||||
while True do
|
||||
begin
|
||||
Res1 := jojpeg_Loop(ctx, jojpeg_Compress);
|
||||
if (Res1 = jojpeg_enc_Input) then
|
||||
if (Res1 = 1) then
|
||||
begin
|
||||
Res2 := Min(StreamInfo^.OldSize - I, J_WORKMEM);
|
||||
jojpeg_Addbuf(ctx, jojpeg_Compress, PByte(OldInput) + I, Res2,
|
||||
jojpeg_enc_Input);
|
||||
Inc(I, Res2);
|
||||
end;
|
||||
if (Res1 in [0, jojpeg_enc_Output1]) then
|
||||
if (Res1 in [0, 2]) then
|
||||
begin
|
||||
Res2 := jojpeg_Getvalue(ctx, jojpeg_Compress, jojpeg_enc_Output1);
|
||||
Move(Buffer^, (PByte(NewInput) + J)^, Res2);
|
||||
@@ -804,7 +805,7 @@ begin
|
||||
jojpeg_Addbuf(ctx, jojpeg_Compress, Buffer, J_WORKMEM,
|
||||
jojpeg_enc_Output1);
|
||||
end;
|
||||
if (Res1 = jojpeg_enc_Output2) or (Res1 = 0) then
|
||||
if (Res1 = 3) or (Res1 = 0) then
|
||||
begin
|
||||
Res2 := jojpeg_Getvalue(ctx, jojpeg_Compress, jojpeg_enc_Output2);
|
||||
Output(Instance, Buffer + J_WORKMEM, Res2);
|
||||
@@ -898,6 +899,7 @@ begin
|
||||
JOJPEG_CODEC:
|
||||
begin
|
||||
ctx := JJInst[Instance];
|
||||
FillChar(ctx^, jojpeg_Size, 0);
|
||||
Buffer := Funcs^.Allocator(Instance, J_WORKMEM);
|
||||
I := 0;
|
||||
J := 0;
|
||||
|
@@ -26,6 +26,7 @@ const
|
||||
|
||||
const
|
||||
O_MAXSIZE = 16 * 1024 * 1024;
|
||||
O_WORKMEM = 64 * 1024 * 1024;
|
||||
O_LENGTH = 32;
|
||||
O_TRADEOFF = 256;
|
||||
O_DICTIONARY = 0;
|
||||
@@ -382,8 +383,8 @@ begin
|
||||
for I := Low(SOList) to High(SOList) do
|
||||
SOList[I][Y].Update
|
||||
([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True);
|
||||
if Funcs^.GetParam(Command, X, 'm') <> '' then
|
||||
OMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 'm'));
|
||||
if Funcs^.GetParam(Command, X, 's') <> '' then
|
||||
OMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 's'));
|
||||
if Funcs^.GetParam(Command, X, 'n') <> '' then
|
||||
OLength := StrToInt(Funcs^.GetParam(Command, X, 'n'));
|
||||
if Funcs^.GetParam(Command, X, 't') <> '' then
|
||||
@@ -595,9 +596,11 @@ end;
|
||||
function OodleProcess(Instance, Depth: Integer; OldInput, NewInput: Pointer;
|
||||
StreamInfo: PStrInfo2; Output: _PrecompOutput; Funcs: PPrecompFuncs): Boolean;
|
||||
var
|
||||
Buffer: PByte;
|
||||
Buffer, Work: PByte;
|
||||
Params: String;
|
||||
A, B: Integer;
|
||||
I: Integer;
|
||||
W: Integer;
|
||||
X, Y: Integer;
|
||||
Res1: Integer;
|
||||
Res2: NativeUInt;
|
||||
@@ -609,7 +612,18 @@ begin
|
||||
exit;
|
||||
Y := GetOodleCodec(X);
|
||||
Buffer := Funcs^.Allocator(Instance, OodleLZ_GetCompressedBufferSizeNeeded(Y,
|
||||
StreamInfo^.NewSize));
|
||||
StreamInfo^.NewSize) + IfThen(OldCompress, 0, O_WORKMEM));
|
||||
if OldCompress then
|
||||
begin
|
||||
Work := nil;
|
||||
W := 0
|
||||
end
|
||||
else
|
||||
begin
|
||||
Work := Buffer + OodleLZ_GetCompressedBufferSizeNeeded(Y,
|
||||
StreamInfo^.NewSize);
|
||||
W := O_WORKMEM;
|
||||
end;
|
||||
SOList[Instance][X].Index := 0;
|
||||
while SOList[Instance][X].Get(I) >= 0 do
|
||||
begin
|
||||
@@ -635,7 +649,7 @@ begin
|
||||
+ 'd' + GetBits(StreamInfo^.Option, 24, 5).ToString;
|
||||
if not Result then
|
||||
Res1 := OodleLZ_Compress(Y, NewInput, StreamInfo^.NewSize, Buffer, I,
|
||||
@COptions);
|
||||
@COptions, nil, nil, Work, W);
|
||||
if not Result then
|
||||
Result := (Res1 = StreamInfo^.OldSize) and CompareMem(OldInput, Buffer,
|
||||
StreamInfo^.OldSize);
|
||||
@@ -644,6 +658,27 @@ begin
|
||||
if Result or (StreamInfo^.Status = TStreamStatus.Predicted) then
|
||||
break;
|
||||
end;
|
||||
if Result and OPTIMISE_DEC and (StreamInfo^.Status <> TStreamStatus.Database)
|
||||
then
|
||||
begin
|
||||
A := Pred(I);
|
||||
for B := A downto 1 do
|
||||
begin
|
||||
Move(OodleLZ_CompressOptions_GetDefault(Y, B)^, COptions,
|
||||
SizeOf(TOodleLZ_CompressOptions));
|
||||
COptions.sendQuantumCRCs := GetBits(StreamInfo^.Option, 12, 1) = 1;
|
||||
COptions.spaceSpeedTradeoffBytes := GetBits(StreamInfo^.Option, 13, 11);
|
||||
COptions.dictionarySize := IfThen(GetBits(StreamInfo^.Option, 24, 5) = 0,
|
||||
0, Round(Power(2, GetBits(StreamInfo^.Option, 24, 5))));
|
||||
Res1 := OodleLZ_Compress(Y, NewInput, StreamInfo^.NewSize, Buffer, B,
|
||||
@COptions, nil, nil, Work, W);
|
||||
if (Res1 = StreamInfo^.OldSize) and CompareMem(OldInput, Buffer,
|
||||
StreamInfo^.OldSize) then
|
||||
I := B
|
||||
else
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
{ if (Result = False) and ((StreamInfo^.Status >= TStreamStatus.Predicted) or
|
||||
(SOList[Instance][X].Count = 1)) and (DIFF_TOLERANCE > 0) then
|
||||
begin
|
||||
@@ -670,8 +705,9 @@ end;
|
||||
function OodleRestore(Instance, Depth: Integer; Input, InputExt: Pointer;
|
||||
StreamInfo: _StrInfo3; Output: _PrecompOutput; Funcs: PPrecompFuncs): Boolean;
|
||||
var
|
||||
Buffer: PByte;
|
||||
Buffer, Work: PByte;
|
||||
Params: String;
|
||||
W: Integer;
|
||||
X, Y: Integer;
|
||||
Res1: Integer;
|
||||
Res2: NativeUInt;
|
||||
@@ -683,7 +719,18 @@ begin
|
||||
exit;
|
||||
Y := GetOodleCodec(X);
|
||||
Buffer := Funcs^.Allocator(Instance, OodleLZ_GetCompressedBufferSizeNeeded(Y,
|
||||
StreamInfo.NewSize));
|
||||
StreamInfo.NewSize) + IfThen(OldCompress, 0, O_WORKMEM));
|
||||
if OldCompress then
|
||||
begin
|
||||
Work := nil;
|
||||
W := 0
|
||||
end
|
||||
else
|
||||
begin
|
||||
Work := Buffer + OodleLZ_GetCompressedBufferSizeNeeded(Y,
|
||||
StreamInfo.NewSize);
|
||||
W := O_WORKMEM;
|
||||
end;
|
||||
Move(OodleLZ_CompressOptions_GetDefault(Y, GetBits(StreamInfo.Option, 5, 7))^,
|
||||
COptions, SizeOf(TOodleLZ_CompressOptions));
|
||||
COptions.sendQuantumCRCs := GetBits(StreamInfo.Option, 12, 1) = 1;
|
||||
@@ -695,7 +742,7 @@ begin
|
||||
GetBits(StreamInfo.Option, 13, 11).ToString + ':' + 'd' +
|
||||
GetBits(StreamInfo.Option, 24, 5).ToString;
|
||||
Res1 := OodleLZ_Compress(Y, Input, StreamInfo.NewSize, Buffer,
|
||||
GetBits(StreamInfo.Option, 5, 7), @COptions);
|
||||
GetBits(StreamInfo.Option, 5, 7), @COptions, nil, nil, Work, W);
|
||||
Funcs^.LogRestore(OodleCodecs[GetBits(StreamInfo.Option, 0, 5)],
|
||||
PChar(Params), StreamInfo.OldSize, StreamInfo.NewSize, Res1, True);
|
||||
if GetBits(StreamInfo.Option, 31, 1) = 1 then
|
||||
|
@@ -77,7 +77,7 @@ begin
|
||||
while Y > 0 do
|
||||
begin
|
||||
Inc(LPos, Y);
|
||||
CRC := Utils.Hash32(CRC, @Buffer[0], Y);
|
||||
CRC := Utils.CRC32(CRC, @Buffer[0], Y);
|
||||
Dec(X, Y);
|
||||
Y := Funcs^.ReadFuture(Instance, LPos, @Buffer[0], Min(X, BufferSize));
|
||||
end;
|
||||
@@ -201,7 +201,7 @@ begin
|
||||
begin
|
||||
if not Checked then
|
||||
begin
|
||||
CRC := Utils.Hash32(0, Input + Pos, MinSize);
|
||||
CRC := Utils.CRC32(0, Input + Pos, MinSize);
|
||||
Checked := True;
|
||||
end;
|
||||
if (CodecSearch[I, SearchInfo[I, J, X]].Hash = CRC) and
|
||||
|
@@ -3,7 +3,8 @@ unit PrecompUtils;
|
||||
interface
|
||||
|
||||
uses
|
||||
Utils, Threading,
|
||||
InitCode,
|
||||
Utils, Threading, XXHASHLIB,
|
||||
WinAPI.Windows,
|
||||
System.SysUtils, System.Classes, System.StrUtils, System.Types, System.Math,
|
||||
System.Generics.Defaults, System.Generics.Collections;
|
||||
@@ -55,7 +56,7 @@ type
|
||||
Codec: Byte;
|
||||
Scan2: Boolean;
|
||||
Option: Integer;
|
||||
Checksum: Cardinal;
|
||||
Checksum: XXH128_hash_t;
|
||||
Status: TStreamStatus;
|
||||
DepthInfo: TDepthInfo;
|
||||
end;
|
||||
@@ -194,7 +195,9 @@ type
|
||||
AcceptPatch: function(OldSize, NewSize, PatchSize: Integer): Boolean cdecl;
|
||||
// 40
|
||||
Transfer: procedure(Instance: Integer; Codec: PChar)cdecl;
|
||||
Reserved: array [0 .. (PRECOMP_FCOUNT - 1) - 41] of Pointer;
|
||||
Storage: function(Instance: Integer; Size: PInteger): Pointer cdecl;
|
||||
AddResourceEx: function(Data: Pointer; Size: Integer): Integer cdecl;
|
||||
Reserved: array [0 .. (PRECOMP_FCOUNT - 1) - 43] of Pointer;
|
||||
end;
|
||||
|
||||
_PrecompOutput = procedure(Instance: Integer; const Buffer: Pointer;
|
||||
@@ -248,7 +251,7 @@ type
|
||||
Size: Integer;
|
||||
Codec: Byte;
|
||||
Option: Integer;
|
||||
Checksum: Cardinal;
|
||||
Checksum: XXH128_hash_t;
|
||||
Status: TStreamStatus;
|
||||
end;
|
||||
|
||||
@@ -256,7 +259,7 @@ type
|
||||
|
||||
TDuplicate1 = packed record
|
||||
Size: Integer;
|
||||
Checksum: Cardinal;
|
||||
Checksum: XXH128_hash_t;
|
||||
Index: Integer;
|
||||
Count: Integer;
|
||||
end;
|
||||
@@ -366,6 +369,7 @@ function PrecompAcceptPatch(OldSize, NewSize, PatchSize: Integer)
|
||||
var
|
||||
PrecompFunctions: _PrecompFuncs;
|
||||
DIFF_TOLERANCE: Single = 0.05;
|
||||
OPTIMISE_DEC: Boolean = False;
|
||||
EncodeSICmp: TEncodeSIComparer;
|
||||
FutureSICmp: TFutureSIComparer;
|
||||
StockMethods, ExternalMethods: TStringList;
|
||||
@@ -427,10 +431,9 @@ begin
|
||||
List2 := DecodeStr(List1[I], SPrecompSep2);
|
||||
for J := Succ(Low(List2)) to High(List2) do
|
||||
begin
|
||||
if FileExists(ExtractFilePath(Utils.GetModuleName) + List2[J]) then
|
||||
if FileExists(PluginsPath + List2[J]) then
|
||||
begin
|
||||
Result := PrecompAddResource
|
||||
(PChar(ExtractFilePath(Utils.GetModuleName) + List2[J]));
|
||||
Result := PrecompAddResource(PChar(List2[J]));
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
@@ -591,7 +594,7 @@ begin
|
||||
else
|
||||
begin
|
||||
for I := Succ(Low(List2)) to High(List2) do
|
||||
if List2[I].StartsWith(Param, True) and
|
||||
if List2[I].StartsWith(Param, False) and
|
||||
(ResourceExists(List2[I]) = False) then
|
||||
begin
|
||||
S := List2[I].Substring(Length(Param));
|
||||
@@ -649,14 +652,14 @@ begin
|
||||
if S = '' then
|
||||
S := '15';
|
||||
FillChar(ZStream, SizeOf(z_stream), 0);
|
||||
ZStream.next_in := InBuff;
|
||||
ZStream.avail_in := InSize;
|
||||
ZStream.next_out := OutBuff;
|
||||
ZStream.avail_out := OutSize;
|
||||
deflateInit2(ZStream, I div 10, Z_DEFLATED, -StrToInt(S), I mod 10,
|
||||
Z_DEFAULT_STRATEGY);
|
||||
try
|
||||
ZStream.next_in := InBuff;
|
||||
ZStream.avail_in := InSize;
|
||||
ZStream.next_out := OutBuff;
|
||||
ZStream.avail_out := OutSize;
|
||||
if deflate(ZStream, Z_FULL_FLUSH) = Z_STREAM_END then
|
||||
if deflate(ZStream, Z_FINISH) = Z_STREAM_END then
|
||||
Result := ZStream.total_out;
|
||||
finally
|
||||
deflateEnd(ZStream);
|
||||
@@ -733,7 +736,7 @@ begin
|
||||
ZStream.avail_in := InSize;
|
||||
ZStream.next_out := OutBuff;
|
||||
ZStream.avail_out := OutSize;
|
||||
if inflate(ZStream, Z_FULL_FLUSH) = Z_STREAM_END then
|
||||
if inflate(ZStream, Z_FINISH) = Z_STREAM_END then
|
||||
Result := ZStream.total_out;
|
||||
finally
|
||||
inflateEnd(ZStream);
|
||||
@@ -825,9 +828,12 @@ var
|
||||
LMD5Digest: TMD5Digest;
|
||||
LSHA1: TSHA1;
|
||||
LSHA1Digest: TSHA1Digest;
|
||||
xxSeed32: XXH32_hash_t;
|
||||
xxSeed64: XXH32_hash_t;
|
||||
begin
|
||||
Result := False;
|
||||
case IndexText(Codec, ['crc32', 'adler32', 'crc64', 'md5', 'sha1']) of
|
||||
case IndexText(Codec, ['crc32', 'adler32', 'crc64', 'md5', 'sha1', 'xxh32',
|
||||
'xxh64', 'xxh128', 'xxh3', 'xxh3_128']) of
|
||||
0:
|
||||
if HashSize = SizeOf(Cardinal) then
|
||||
begin
|
||||
@@ -861,6 +867,39 @@ begin
|
||||
Move(LSHA1Digest, HashBuff^, HashSize);
|
||||
Result := True;
|
||||
end;
|
||||
5:
|
||||
if HashSize = SizeOf(XXH32_hash_t) then
|
||||
begin
|
||||
xxSeed32 := 0;
|
||||
PXXH32_hash_t(HashBuff)^ := XXH32(InBuff, InSize, xxSeed32);
|
||||
Result := True;
|
||||
end;
|
||||
6:
|
||||
if HashSize = SizeOf(XXH64_hash_t) then
|
||||
begin
|
||||
xxSeed64 := 0;
|
||||
PXXH64_hash_t(HashBuff)^ := XXH64(InBuff, InSize, xxSeed64);
|
||||
Result := True;
|
||||
end;
|
||||
7:
|
||||
if HashSize = SizeOf(XXH128_hash_t) then
|
||||
begin
|
||||
xxSeed64 := 0;
|
||||
PXXH128_hash_t(HashBuff)^ := XXH128(InBuff, InSize, xxSeed64);
|
||||
Result := True;
|
||||
end;
|
||||
8:
|
||||
if HashSize = SizeOf(XXH64_hash_t) then
|
||||
begin
|
||||
PXXH64_hash_t(HashBuff)^ := XXH3_64bits(InBuff, InSize);
|
||||
Result := True;
|
||||
end;
|
||||
9:
|
||||
if HashSize = SizeOf(XXH128_hash_t) then
|
||||
begin
|
||||
PXXH128_hash_t(HashBuff)^ := XXH3_128bits(InBuff, InSize);
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -898,7 +937,6 @@ function PrecompAddResource(FileName: PChar): Integer;
|
||||
var
|
||||
I: Integer;
|
||||
Exists: Boolean;
|
||||
LResData: PResData;
|
||||
begin
|
||||
Result := -1;
|
||||
Exists := False;
|
||||
@@ -913,18 +951,19 @@ begin
|
||||
end;
|
||||
if not Exists then
|
||||
begin
|
||||
New(LResData);
|
||||
LResData^.Name := ExtractFileName(FileName);
|
||||
with TFileStream.Create(FileName, fmOpenRead or fmShareDenyNone) do
|
||||
with TFileStream.Create(PluginsPath + FileName, fmOpenRead or
|
||||
fmShareDenyNone) do
|
||||
try
|
||||
LResData^.Size := Size;
|
||||
GetMem(LResData^.Data, LResData^.Size);
|
||||
ReadBuffer(LResData^.Data^, LResData^.Size);
|
||||
I := Length(Resources);
|
||||
SetLength(Resources, Succ(I));
|
||||
Resources[I].Name := ExtractFileName(FileName);
|
||||
Resources[I].Size := Size;
|
||||
GetMem(Resources[I].Data, Resources[I].Size);
|
||||
ReadBuffer(Resources[I].Data^, Resources[I].Size);
|
||||
Result := I;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
Insert(LResData^, Resources, Length(Resources));
|
||||
Result := Pred(Length(Resources));
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@@ -483,9 +483,10 @@ begin
|
||||
Inc(Pos);
|
||||
continue;
|
||||
end;
|
||||
if (Pos >= 2) and ((Input + Pos - 2)^ and $F = 8) and
|
||||
if (Pos >= 3) and ((Input + Pos - 2)^ and $F = 8) and
|
||||
((Input + Pos - 1)^ and $20 = 0) and
|
||||
(EndianSwap(PWord(Input + Pos - 2)^) mod $1F = 0) then
|
||||
(EndianSwap(PWord(Input + Pos - 2)^) mod $1F = 0) and
|
||||
((Input + Pos)^ and 7 <> $7) then
|
||||
begin
|
||||
WinBits := (Input + Pos - 2)^ shr 4;
|
||||
if WinBits = ZWinBits then
|
||||
@@ -565,6 +566,8 @@ begin
|
||||
else
|
||||
SI.Status := TStreamStatus.None;
|
||||
SetBits(SI.Option, WinBits, 12, 3);
|
||||
if not((Input + Pos)^ and 7 in [$4, $5]) then
|
||||
SetBits(SI.Option, 1, 15, 1);
|
||||
for I := Low(CodecEnabled) to High(CodecEnabled) do
|
||||
begin
|
||||
if (I = ZLIB_CODEC) and (WinBits = 0) then
|
||||
@@ -761,6 +764,7 @@ begin
|
||||
if (Res1 in [0, 2]) or (Res1 > 3) then
|
||||
begin
|
||||
Res2 := raw2hif_getoutlen(HR);
|
||||
// ShowMessage('enc: ' + Res2.ToString);
|
||||
Output(Instance, Buffer, Res2);
|
||||
Inc(J, Res2);
|
||||
raw2hif_addbuf(HR, Buffer, R_WORKMEM);
|
||||
@@ -785,8 +789,49 @@ begin
|
||||
StreamInfo^.OldSize, M = StreamInfo^.NewSize);
|
||||
if M = StreamInfo^.NewSize then
|
||||
begin
|
||||
SetBits(StreamInfo^.Option, L, 5, 7);
|
||||
Result := True;
|
||||
if GetBits(StreamInfo^.Option, 15, 1) = 1 then
|
||||
begin
|
||||
HR := RefInst2[Instance];
|
||||
I := 0;
|
||||
J := 0;
|
||||
M := 0;
|
||||
CRC := 0;
|
||||
Ptr := Funcs^.Storage(Instance, @M);
|
||||
// ShowMessage('dec: ' + M.ToString);
|
||||
hif2raw_Init(HR, L);
|
||||
while True do
|
||||
begin
|
||||
Res1 := hif2raw_Loop(HR);
|
||||
if (Res1 in [0, 2]) or (Res1 > 3) then
|
||||
begin
|
||||
Res2 := hif2raw_getoutlen(HR);
|
||||
if Res2 > 0 then
|
||||
CRC := Hash32(CRC, Buffer, Res2);
|
||||
hif2raw_addbuf(HR, Buffer, R_WORKMEM);
|
||||
if Res1 = 0 then
|
||||
break;
|
||||
end;
|
||||
if Res1 = 1 then
|
||||
begin
|
||||
Res2 := Min(M - J, R_WORKMEM);
|
||||
hif2raw_addbuf(HR, Ptr + J, Res2);
|
||||
Inc(J, Res2);
|
||||
end;
|
||||
if Res1 = 3 then
|
||||
begin
|
||||
Res2 := Min(StreamInfo^.NewSize - I, R_WORKMEM);
|
||||
hif2raw_addbuf(HR, PByte(NewInput) + I, Res2);
|
||||
Inc(I, Res2);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if (GetBits(StreamInfo^.Option, 15, 1) = 0) or
|
||||
(CRC = Hash32(0, OldInput, StreamInfo^.OldSize)) then
|
||||
begin
|
||||
// ShowMessage('Verified!');
|
||||
SetBits(StreamInfo^.Option, L, 5, 7);
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
PREFLATE_CODEC:
|
||||
|
@@ -60,8 +60,8 @@ begin
|
||||
for I := Low(SOList) to High(SOList) do
|
||||
SOList[I][ZSTD_CODEC].Update
|
||||
([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True);
|
||||
if Funcs^.GetParam(Command, X, 'm') <> '' then
|
||||
ZMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 'm'));
|
||||
if Funcs^.GetParam(Command, X, 's') <> '' then
|
||||
ZMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 's'));
|
||||
end;
|
||||
Inc(X);
|
||||
end;
|
||||
@@ -249,6 +249,7 @@ function ZSTDProcess(Instance, Depth: Integer; OldInput, NewInput: Pointer;
|
||||
var
|
||||
Buffer: PByte;
|
||||
Params: String;
|
||||
A, B: Integer;
|
||||
I: Integer;
|
||||
X: Integer;
|
||||
Res1: Integer;
|
||||
@@ -323,8 +324,23 @@ begin
|
||||
if Result or (StreamInfo^.Status >= TStreamStatus.Predicted) then
|
||||
break;
|
||||
end;
|
||||
if (Result = False) and ((StreamInfo^.Status >= TStreamStatus.Predicted) or
|
||||
(SOList[Instance][X].Count = 1)) and (DIFF_TOLERANCE > 0) then
|
||||
if Result and OPTIMISE_DEC and (StreamInfo^.Status <> TStreamStatus.Database)
|
||||
then
|
||||
begin
|
||||
A := Pred(I);
|
||||
for B := A downto 1 do
|
||||
begin
|
||||
Res1 := ZSTD_compressCCtx(cctx[Instance], Buffer, StreamInfo^.NewSize,
|
||||
NewInput, StreamInfo^.NewSize, B);
|
||||
if (Res1 = StreamInfo^.OldSize) and CompareMem(OldInput, Buffer,
|
||||
StreamInfo^.OldSize) then
|
||||
I := B
|
||||
else
|
||||
break;
|
||||
end;
|
||||
end
|
||||
else if (Result = False) and ((StreamInfo^.Status >= TStreamStatus.Predicted)
|
||||
or (SOList[Instance][X].Count = 1)) and (DIFF_TOLERANCE > 0) then
|
||||
begin
|
||||
Buffer := Funcs^.Allocator(Instance, Res1 + Max(StreamInfo^.OldSize, Res1));
|
||||
Res2 := PrecompEncodePatch(OldInput, StreamInfo^.OldSize, Buffer, Res1,
|
||||
|
Reference in New Issue
Block a user