update to 0.6.6
This commit is contained in:
@@ -3,6 +3,7 @@ unit BrunsliDLL;
|
||||
interface
|
||||
|
||||
uses
|
||||
LibImport,
|
||||
WinAPI.Windows,
|
||||
System.SysUtils, System.Classes;
|
||||
|
||||
@@ -39,41 +40,31 @@ var
|
||||
implementation
|
||||
|
||||
var
|
||||
DLLHandle: THandle;
|
||||
S: String;
|
||||
Lib: TLibImport;
|
||||
|
||||
procedure Init;
|
||||
begin
|
||||
S := 'brunsli.dll';
|
||||
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) + S));
|
||||
if DLLHandle >= 32 then
|
||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'brunsli.dll');
|
||||
if Lib.Loaded then
|
||||
begin
|
||||
@brunsli_alloc_JPEGData := GetProcAddress(DLLHandle,
|
||||
'brunsli_alloc_JPEGData');
|
||||
@brunsli_free_JPEGData := GetProcAddress(DLLHandle,
|
||||
'brunsli_free_JPEGData');
|
||||
@brunsli_GetMaximumEncodedSize := GetProcAddress(DLLHandle,
|
||||
'brunsli_GetMaximumEncodedSize');
|
||||
@brunsli_ReadJpeg := GetProcAddress(DLLHandle, 'brunsli_ReadJpeg');
|
||||
@brunsli_EncodeJpeg := GetProcAddress(DLLHandle, 'brunsli_EncodeJpeg');
|
||||
@brunsli_DecodeJpeg := GetProcAddress(DLLHandle, 'brunsli_DecodeJpeg');
|
||||
@brunsli_alloc_JPEGOutput := GetProcAddress(DLLHandle,
|
||||
'brunsli_alloc_JPEGOutput');
|
||||
@brunsli_free_JPEGOutput := GetProcAddress(DLLHandle,
|
||||
'brunsli_free_JPEGOutput');
|
||||
@brunsli_WriteJpeg := GetProcAddress(DLLHandle, 'brunsli_WriteJpeg');
|
||||
@brunsli_alloc_JPEGData := Lib.GetProcAddr('brunsli_alloc_JPEGData');
|
||||
@brunsli_free_JPEGData := Lib.GetProcAddr('brunsli_free_JPEGData');
|
||||
@brunsli_GetMaximumEncodedSize :=
|
||||
Lib.GetProcAddr('brunsli_GetMaximumEncodedSize');
|
||||
@brunsli_ReadJpeg := Lib.GetProcAddr('brunsli_ReadJpeg');
|
||||
@brunsli_EncodeJpeg := Lib.GetProcAddr('brunsli_EncodeJpeg');
|
||||
@brunsli_DecodeJpeg := Lib.GetProcAddr('brunsli_DecodeJpeg');
|
||||
@brunsli_alloc_JPEGOutput := Lib.GetProcAddr('brunsli_alloc_JPEGOutput');
|
||||
@brunsli_free_JPEGOutput := Lib.GetProcAddr('brunsli_free_JPEGOutput');
|
||||
@brunsli_WriteJpeg := Lib.GetProcAddr('brunsli_WriteJpeg');
|
||||
DLLLoaded := Assigned(brunsli_alloc_JPEGData) and
|
||||
Assigned(brunsli_alloc_JPEGOutput);
|
||||
end
|
||||
else
|
||||
DLLLoaded := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Deinit;
|
||||
begin
|
||||
if not DLLLoaded then
|
||||
exit;
|
||||
FreeLibrary(DLLHandle);
|
||||
Lib.Free;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
@@ -3,6 +3,7 @@ unit FLACDLL;
|
||||
interface
|
||||
|
||||
uses
|
||||
LibImport,
|
||||
WinAPI.Windows,
|
||||
System.SysUtils, System.Classes;
|
||||
|
||||
@@ -121,68 +122,60 @@ var
|
||||
implementation
|
||||
|
||||
var
|
||||
DLLHandle: THandle;
|
||||
Lib: TLibImport;
|
||||
|
||||
procedure Init;
|
||||
begin
|
||||
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) +
|
||||
'libFLAC_dynamic.dll'));
|
||||
if DLLHandle >= 32 then
|
||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) +
|
||||
'libFLAC_dynamic.dll');
|
||||
if Lib.Loaded then
|
||||
begin
|
||||
@FLAC__stream_encoder_new := GetProcAddress(DLLHandle,
|
||||
'FLAC__stream_encoder_new');
|
||||
@FLAC__stream_encoder_set_verify := GetProcAddress(DLLHandle,
|
||||
'FLAC__stream_encoder_set_verify');
|
||||
@FLAC__stream_encoder_set_channels := GetProcAddress(DLLHandle,
|
||||
'FLAC__stream_encoder_set_channels');
|
||||
@FLAC__stream_encoder_new := Lib.GetProcAddr('FLAC__stream_encoder_new');
|
||||
@FLAC__stream_encoder_set_verify :=
|
||||
Lib.GetProcAddr('FLAC__stream_encoder_set_verify');
|
||||
@FLAC__stream_encoder_set_channels :=
|
||||
Lib.GetProcAddr('FLAC__stream_encoder_set_channels');
|
||||
@FLAC__stream_encoder_set_compression_level :=
|
||||
GetProcAddress(DLLHandle, 'FLAC__stream_encoder_set_compression_level');
|
||||
Lib.GetProcAddr('FLAC__stream_encoder_set_compression_level');
|
||||
@FLAC__stream_encoder_set_bits_per_sample :=
|
||||
GetProcAddress(DLLHandle, 'FLAC__stream_encoder_set_bits_per_sample');
|
||||
Lib.GetProcAddr('FLAC__stream_encoder_set_bits_per_sample');
|
||||
@FLAC__stream_encoder_set_sample_rate :=
|
||||
GetProcAddress(DLLHandle, 'FLAC__stream_encoder_set_sample_rate');
|
||||
Lib.GetProcAddr('FLAC__stream_encoder_set_sample_rate');
|
||||
@FLAC__stream_encoder_set_total_samples_estimate :=
|
||||
GetProcAddress(DLLHandle,
|
||||
'FLAC__stream_encoder_set_total_samples_estimate');
|
||||
@FLAC__stream_encoder_init_stream := GetProcAddress(DLLHandle,
|
||||
'FLAC__stream_encoder_init_stream');
|
||||
@FLAC__stream_encoder_init_file := GetProcAddress(DLLHandle,
|
||||
'FLAC__stream_encoder_init_file');
|
||||
Lib.GetProcAddr('FLAC__stream_encoder_set_total_samples_estimate');
|
||||
@FLAC__stream_encoder_init_stream :=
|
||||
Lib.GetProcAddr('FLAC__stream_encoder_init_stream');
|
||||
@FLAC__stream_encoder_init_file :=
|
||||
Lib.GetProcAddr('FLAC__stream_encoder_init_file');
|
||||
@FLAC__stream_encoder_process_interleaved :=
|
||||
GetProcAddress(DLLHandle, 'FLAC__stream_encoder_process_interleaved');
|
||||
@FLAC__stream_encoder_finish := GetProcAddress(DLLHandle,
|
||||
'FLAC__stream_encoder_finish');
|
||||
@FLAC__stream_encoder_delete := GetProcAddress(DLLHandle,
|
||||
'FLAC__stream_encoder_delete');
|
||||
@FLAC__stream_decoder_new := GetProcAddress(DLLHandle,
|
||||
'FLAC__stream_decoder_new');
|
||||
@FLAC__stream_decoder_init_stream := GetProcAddress(DLLHandle,
|
||||
'FLAC__stream_decoder_init_stream');
|
||||
@FLAC__stream_decoder_init_file := GetProcAddress(DLLHandle,
|
||||
'FLAC__stream_decoder_init_file');
|
||||
@FLAC__stream_decoder_get_channels := GetProcAddress(DLLHandle,
|
||||
'FLAC__stream_decoder_get_channels');
|
||||
Lib.GetProcAddr('FLAC__stream_encoder_process_interleaved');
|
||||
@FLAC__stream_encoder_finish :=
|
||||
Lib.GetProcAddr('FLAC__stream_encoder_finish');
|
||||
@FLAC__stream_encoder_delete :=
|
||||
Lib.GetProcAddr('FLAC__stream_encoder_delete');
|
||||
@FLAC__stream_decoder_new := Lib.GetProcAddr('FLAC__stream_decoder_new');
|
||||
@FLAC__stream_decoder_init_stream :=
|
||||
Lib.GetProcAddr('FLAC__stream_decoder_init_stream');
|
||||
@FLAC__stream_decoder_init_file :=
|
||||
Lib.GetProcAddr('FLAC__stream_decoder_init_file');
|
||||
@FLAC__stream_decoder_get_channels :=
|
||||
Lib.GetProcAddr('FLAC__stream_decoder_get_channels');
|
||||
@FLAC__stream_decoder_get_bits_per_sample :=
|
||||
GetProcAddress(DLLHandle, 'FLAC__stream_decoder_get_bits_per_sample');
|
||||
Lib.GetProcAddr('FLAC__stream_decoder_get_bits_per_sample');
|
||||
@FLAC__stream_decoder_process_until_end_of_stream :=
|
||||
GetProcAddress(DLLHandle,
|
||||
'FLAC__stream_decoder_process_until_end_of_stream');
|
||||
@FLAC__stream_decoder_finish := GetProcAddress(DLLHandle,
|
||||
'FLAC__stream_decoder_finish');
|
||||
@FLAC__stream_decoder_delete := GetProcAddress(DLLHandle,
|
||||
'FLAC__stream_decoder_delete');
|
||||
Lib.GetProcAddr('FLAC__stream_decoder_process_until_end_of_stream');
|
||||
@FLAC__stream_decoder_finish :=
|
||||
Lib.GetProcAddr('FLAC__stream_decoder_finish');
|
||||
@FLAC__stream_decoder_delete :=
|
||||
Lib.GetProcAddr('FLAC__stream_decoder_delete');
|
||||
DLLLoaded := Assigned(FLAC__stream_encoder_new) and
|
||||
Assigned(FLAC__stream_decoder_new);
|
||||
end
|
||||
else
|
||||
DLLLoaded := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Deinit;
|
||||
begin
|
||||
if not DLLLoaded then
|
||||
exit;
|
||||
FreeLibrary(DLLHandle);
|
||||
Lib.Free;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
@@ -3,7 +3,7 @@ unit FLZMA2DLL;
|
||||
interface
|
||||
|
||||
uses
|
||||
MemoryModule,
|
||||
LibImport,
|
||||
WinAPI.Windows,
|
||||
System.SysUtils, System.Classes, System.Types;
|
||||
|
||||
@@ -24,6 +24,82 @@ type
|
||||
pos: size_t;
|
||||
end;
|
||||
|
||||
type
|
||||
FL2_cParameter = (
|
||||
(* compression parameters *)
|
||||
FL2_p_compressionLevel,
|
||||
(* Update all compression parameters according to pre-defined cLevel table
|
||||
* Default level is FL2_CLEVEL_DEFAULT==6.
|
||||
* Setting FL2_p_highCompression to 1 switches to an alternate cLevel table. *)
|
||||
FL2_p_highCompression,
|
||||
(* Maximize compression ratio for a given dictionary size.
|
||||
* Levels 1..10 = dictionaryLog 20..29 (1 Mb..512 Mb).
|
||||
* Typically provides a poor speed/ratio tradeoff. *)
|
||||
FL2_p_dictionaryLog,
|
||||
(* Maximum allowed back-reference distance, expressed as power of 2.
|
||||
* Must be clamped between FL2_DICTLOG_MIN and FL2_DICTLOG_MAX.
|
||||
* Default = 24 *)
|
||||
FL2_p_dictionarySize, (* Same as above but expressed as an absolute value.
|
||||
* Must be clamped between FL2_DICTSIZE_MIN and FL2_DICTSIZE_MAX.
|
||||
* Default = 16 Mb *)
|
||||
FL2_p_overlapFraction,
|
||||
(* The radix match finder is block-based, so some overlap is retained from
|
||||
* each block to improve compression of the next. This value is expressed
|
||||
* as n / 16 of the block size (dictionary size). Larger values are slower.
|
||||
* Values above 2 mostly yield only a small improvement in compression.
|
||||
* A large value for a small dictionary may worsen multithreaded compression.
|
||||
* Default = 2 *)
|
||||
FL2_p_resetInterval,
|
||||
(* For multithreaded decompression. A dictionary reset will occur
|
||||
* after each dictionarySize * resetInterval bytes of input.
|
||||
* Default = 4 *)
|
||||
FL2_p_bufferResize,
|
||||
(* Buffering speeds up the matchfinder. Buffer resize determines the percentage of
|
||||
* the normal buffer size used, which depends on dictionary size.
|
||||
* 0=50, 1=75, 2=100, 3=150, 4=200. Higher number = slower, better
|
||||
* compression, higher memory usage. A CPU with a large memory cache
|
||||
* may make effective use of a larger buffer.
|
||||
* Default = 2 *)
|
||||
FL2_p_hybridChainLog,
|
||||
(* Size of the hybrid mode HC3 hash chain, as a power of 2.
|
||||
* Resulting table size is (1 << (chainLog+2)) bytes.
|
||||
* Larger tables result in better and slower compression.
|
||||
* This parameter is only used by the hybrid "ultra" strategy.
|
||||
* Default = 9 *)
|
||||
FL2_p_hybridCycles,
|
||||
(* Number of search attempts made by the HC3 match finder.
|
||||
* Used only by the hybrid "ultra" strategy.
|
||||
* More attempts result in slightly better and slower compression.
|
||||
* Default = 1 *)
|
||||
FL2_p_searchDepth,
|
||||
(* Match finder will resolve string matches up to this length. If a longer
|
||||
* match exists further back in the input, it will not be found.
|
||||
* Default = 42 *)
|
||||
FL2_p_fastLength, (* Only useful for strategies >= opt.
|
||||
* Length of match considered "good enough" to stop search.
|
||||
* Larger values make compression stronger and slower.
|
||||
* Default = 48 *)
|
||||
FL2_p_divideAndConquer,
|
||||
(* Split long chains of 2-byte matches into shorter chains with a small overlap
|
||||
* for further processing. Allows buffering of all chains at length 2.
|
||||
* Faster, less compression. Generally a good tradeoff.
|
||||
* Default = enabled *)
|
||||
FL2_p_strategy, (* 1 = fast; 2 = optimized, 3 = ultra (hybrid mode).
|
||||
* The higher the value of the selected strategy, the more complex it is,
|
||||
* resulting in stronger and slower compression.
|
||||
* Default = ultra *)
|
||||
FL2_p_literalCtxBits, (* lc value for LZMA2 encoder
|
||||
* Default = 3 *)
|
||||
FL2_p_literalPosBits, (* lp value for LZMA2 encoder
|
||||
* Default = 0 *)
|
||||
FL2_p_posBits, (* pb value for LZMA2 encoder
|
||||
* Default = 2 *)
|
||||
FL2_p_omitProperties,
|
||||
(* Omit the property byte at the start of the stream. For use within 7-zip *)
|
||||
(* or other containers which store the property byte elsewhere. *)
|
||||
(* A stream compressed under this setting cannot be decoded by this library. *)
|
||||
FL2_cParameter_Force32 = $40000000);
|
||||
|
||||
var
|
||||
FL2_compress: function(dst: Pointer; dstCapacity: size_t; const src: Pointer;
|
||||
srcSize: size_t; compressionLevel: Integer): size_t cdecl;
|
||||
@@ -63,13 +139,20 @@ var
|
||||
input: PFL2_inBuffer): size_t cdecl;
|
||||
|
||||
FL2_endStream: function(fcs: Pointer; output: PFL2_outBuffer): size_t cdecl;
|
||||
|
||||
FL2_isError: function(code: size_t): Cardinal cdecl;
|
||||
FL2_CStream_setParameter: function(fcs: Pointer; param: FL2_cParameter;
|
||||
value: size_t): size_t cdecl;
|
||||
FL2_CStream_getParameter: function(fcs: Pointer; param: FL2_cParameter)
|
||||
: size_t cdecl;
|
||||
FL2_setDStreamMemoryLimitMt: procedure(fds: Pointer; limit: size_t)cdecl;
|
||||
DLLLoaded: boolean = False;
|
||||
|
||||
type
|
||||
TLZMACRec = record
|
||||
Threads: Integer;
|
||||
Level: Integer;
|
||||
HighCompress: boolean;
|
||||
procedure Parse(S: String);
|
||||
end;
|
||||
|
||||
@@ -86,8 +169,9 @@ type
|
||||
FProp: TLZMACRec;
|
||||
FOutput: TStream;
|
||||
FBuffer: array [0 .. FBufferSize - 1] of Byte;
|
||||
FInitialized: boolean;
|
||||
public
|
||||
constructor Create(AOutput: TStream; AConfig: String = 't50p');
|
||||
constructor Create(AOutput: TStream; AConfig: String);
|
||||
destructor Destroy; override;
|
||||
function Write(const Buffer; Count: LongInt): LongInt; override;
|
||||
end;
|
||||
@@ -113,8 +197,7 @@ uses
|
||||
Utils;
|
||||
|
||||
var
|
||||
DLLStream: TResourceStream;
|
||||
DLLHandle: TMemoryModule;
|
||||
Lib: TLibImport;
|
||||
|
||||
procedure TLZMACRec.Parse(S: string);
|
||||
var
|
||||
@@ -122,7 +205,8 @@ var
|
||||
I, J: Integer;
|
||||
begin
|
||||
Threads := 1;
|
||||
Level := 5;
|
||||
Level := 6;
|
||||
HighCompress := False;
|
||||
List := DecodeStr(S, ':');
|
||||
for I := Low(List) to High(List) do
|
||||
begin
|
||||
@@ -130,6 +214,8 @@ begin
|
||||
Threads := ConvertToThreads(List[I].Substring(1));
|
||||
if List[I].StartsWith('l', True) then
|
||||
Level := List[I].Substring(1).ToInteger;
|
||||
if List[I].StartsWith('hi', True) then
|
||||
HighCompress := List[I].Substring(2).ToBoolean;
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -148,15 +234,22 @@ begin
|
||||
end;
|
||||
|
||||
constructor TLZMACompressStream.Create(AOutput: TStream; AConfig: String);
|
||||
var
|
||||
LConfig: String;
|
||||
begin
|
||||
inherited Create;
|
||||
FProp.Parse(AConfig);
|
||||
LConfig := AConfig;
|
||||
if LConfig = '' then
|
||||
LConfig := 't50p';
|
||||
FProp.Parse(LConfig);
|
||||
FOutput := AOutput;
|
||||
if FProp.Threads > 1 then
|
||||
FCtx := FL2_createCStreamMt(FProp.Threads, 0)
|
||||
else
|
||||
FCtx := FL2_createCStream;
|
||||
FL2_initCStream(FCtx, FProp.Level);
|
||||
FL2_CStream_setParameter(FCtx, FL2_cParameter.FL2_p_highCompression,
|
||||
Integer(FProp.HighCompress));
|
||||
FInitialized := False;
|
||||
end;
|
||||
|
||||
destructor TLZMACompressStream.Destroy;
|
||||
@@ -164,14 +257,17 @@ var
|
||||
Oup: FL2_outBuffer;
|
||||
Res: size_t;
|
||||
begin
|
||||
Oup.dst := @FBuffer[0];
|
||||
Oup.size := FBufferSize;
|
||||
Oup.pos := 0;
|
||||
repeat
|
||||
Res := FL2_endStream(FCtx, @Oup);
|
||||
FOutput.WriteBuffer(FBuffer[0], Oup.pos);
|
||||
if FInitialized then
|
||||
begin
|
||||
Oup.dst := @FBuffer[0];
|
||||
Oup.size := FBufferSize;
|
||||
Oup.pos := 0;
|
||||
until Res = 0;
|
||||
repeat
|
||||
Res := FL2_endStream(FCtx, @Oup);
|
||||
FOutput.WriteBuffer(FBuffer[0], Oup.pos);
|
||||
Oup.pos := 0;
|
||||
until Res = 0;
|
||||
end;
|
||||
FL2_freeCCtx(FCtx);
|
||||
inherited Destroy;
|
||||
end;
|
||||
@@ -182,6 +278,11 @@ var
|
||||
Oup: FL2_outBuffer;
|
||||
begin
|
||||
Result := 0;
|
||||
if not FInitialized then
|
||||
begin
|
||||
FL2_initCStream(FCtx, FProp.Level);
|
||||
FInitialized := True;
|
||||
end;
|
||||
Inp.src := PByte(@Buffer);
|
||||
Inp.size := Count;
|
||||
Inp.pos := 0;
|
||||
@@ -200,12 +301,23 @@ begin
|
||||
end;
|
||||
|
||||
constructor TLZMADecompressStream.Create(AInput: TStream; AConfig: String);
|
||||
var
|
||||
LConfig: String;
|
||||
LSize: Int64;
|
||||
begin
|
||||
inherited Create;
|
||||
FProp.Parse(AConfig);
|
||||
LConfig := AConfig;
|
||||
if LConfig = '' then
|
||||
LConfig := 't50p';
|
||||
FProp.Parse(LConfig);
|
||||
FInput := AInput;
|
||||
LSize := 0;
|
||||
LSize := LSize.MaxValue;
|
||||
if FProp.Threads > 1 then
|
||||
FCtx := FL2_createDStreamMt(FProp.Threads)
|
||||
begin
|
||||
FCtx := FL2_createDStreamMt(FProp.Threads);
|
||||
FL2_setDStreamMemoryLimitMt(FCtx, LSize);
|
||||
end
|
||||
else
|
||||
FCtx := FL2_createDStream;
|
||||
FL2_initDStream(FCtx);
|
||||
@@ -255,50 +367,44 @@ end;
|
||||
|
||||
procedure Init;
|
||||
begin
|
||||
DLLStream := TResourceStream.Create(HInstance, 'fast_lzma2', RT_RCDATA);
|
||||
DLLHandle := MemoryLoadLibary(DLLStream.Memory);
|
||||
if Assigned(DLLHandle) then
|
||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'fast-lzma2.dll');
|
||||
if Lib.Loaded then
|
||||
begin
|
||||
@FL2_compress := MemoryGetProcAddress(DLLHandle, 'FL2_compress');
|
||||
@FL2_compressMt := MemoryGetProcAddress(DLLHandle, 'FL2_compressMt');
|
||||
@FL2_decompress := MemoryGetProcAddress(DLLHandle, 'FL2_decompress');
|
||||
@FL2_decompressMt := MemoryGetProcAddress(DLLHandle, 'FL2_decompressMt');
|
||||
@FL2_createCCtx := MemoryGetProcAddress(DLLHandle, 'FL2_createCCtx');
|
||||
@FL2_createCCtxMt := MemoryGetProcAddress(DLLHandle, 'FL2_createCCtxMt');
|
||||
@FL2_freeCCtx := MemoryGetProcAddress(DLLHandle, 'FL2_freeCCtx');
|
||||
@FL2_compressCCtx := MemoryGetProcAddress(DLLHandle, 'FL2_compressCCtx');
|
||||
@FL2_createDCtx := MemoryGetProcAddress(DLLHandle, 'FL2_createDCtx');
|
||||
@FL2_createDCtxMt := MemoryGetProcAddress(DLLHandle, 'FL2_createDCtxMt');
|
||||
@FL2_freeDCtx := MemoryGetProcAddress(DLLHandle, 'FL2_freeDCtx');
|
||||
@FL2_decompressDCtx := MemoryGetProcAddress(DLLHandle,
|
||||
'FL2_decompressDCtx');
|
||||
@FL2_createCStream := MemoryGetProcAddress(DLLHandle, 'FL2_createCStream');
|
||||
@FL2_createCStreamMt := MemoryGetProcAddress(DLLHandle,
|
||||
'FL2_createCStreamMt');
|
||||
@FL2_freeCStream := MemoryGetProcAddress(DLLHandle, 'FL2_freeCStream');
|
||||
@FL2_initCStream := MemoryGetProcAddress(DLLHandle, 'FL2_initCStream');
|
||||
@FL2_compressStream := MemoryGetProcAddress(DLLHandle,
|
||||
'FL2_compressStream');
|
||||
@FL2_createDStream := MemoryGetProcAddress(DLLHandle, 'FL2_createDStream');
|
||||
@FL2_createDStreamMt := MemoryGetProcAddress(DLLHandle,
|
||||
'FL2_createDStreamMt');
|
||||
@FL2_freeDStream := MemoryGetProcAddress(DLLHandle, 'FL2_freeDStream');
|
||||
@FL2_initDStream := MemoryGetProcAddress(DLLHandle, 'FL2_initDStream');
|
||||
@FL2_decompressStream := MemoryGetProcAddress(DLLHandle,
|
||||
'FL2_decompressStream');
|
||||
@FL2_endStream := MemoryGetProcAddress(DLLHandle, 'FL2_endStream');
|
||||
@FL2_isError := MemoryGetProcAddress(DLLHandle, 'FL2_isError');
|
||||
@FL2_compress := Lib.GetProcAddr('FL2_compress');
|
||||
@FL2_compressMt := Lib.GetProcAddr('FL2_compressMt');
|
||||
@FL2_decompress := Lib.GetProcAddr('FL2_decompress');
|
||||
@FL2_decompressMt := Lib.GetProcAddr('FL2_decompressMt');
|
||||
@FL2_createCCtx := Lib.GetProcAddr('FL2_createCCtx');
|
||||
@FL2_createCCtxMt := Lib.GetProcAddr('FL2_createCCtxMt');
|
||||
@FL2_freeCCtx := Lib.GetProcAddr('FL2_freeCCtx');
|
||||
@FL2_compressCCtx := Lib.GetProcAddr('FL2_compressCCtx');
|
||||
@FL2_createDCtx := Lib.GetProcAddr('FL2_createDCtx');
|
||||
@FL2_createDCtxMt := Lib.GetProcAddr('FL2_createDCtxMt');
|
||||
@FL2_freeDCtx := Lib.GetProcAddr('FL2_freeDCtx');
|
||||
@FL2_decompressDCtx := Lib.GetProcAddr('FL2_decompressDCtx');
|
||||
@FL2_createCStream := Lib.GetProcAddr('FL2_createCStream');
|
||||
@FL2_createCStreamMt := Lib.GetProcAddr('FL2_createCStreamMt');
|
||||
@FL2_freeCStream := Lib.GetProcAddr('FL2_freeCStream');
|
||||
@FL2_initCStream := Lib.GetProcAddr('FL2_initCStream');
|
||||
@FL2_compressStream := Lib.GetProcAddr('FL2_compressStream');
|
||||
@FL2_createDStream := Lib.GetProcAddr('FL2_createDStream');
|
||||
@FL2_createDStreamMt := Lib.GetProcAddr('FL2_createDStreamMt');
|
||||
@FL2_freeDStream := Lib.GetProcAddr('FL2_freeDStream');
|
||||
@FL2_initDStream := Lib.GetProcAddr('FL2_initDStream');
|
||||
@FL2_decompressStream := Lib.GetProcAddr('FL2_decompressStream');
|
||||
@FL2_endStream := Lib.GetProcAddr('FL2_endStream');
|
||||
@FL2_isError := Lib.GetProcAddr('FL2_isError');
|
||||
@FL2_CStream_setParameter := Lib.GetProcAddr('FL2_CStream_setParameter');
|
||||
@FL2_CStream_getParameter := Lib.GetProcAddr('FL2_CStream_getParameter');
|
||||
@FL2_setDStreamMemoryLimitMt :=
|
||||
Lib.GetProcAddr('FL2_setDStreamMemoryLimitMt');
|
||||
DLLLoaded := Assigned(FL2_compress) and Assigned(FL2_decompress);
|
||||
end
|
||||
else
|
||||
DLLLoaded := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Deinit;
|
||||
begin
|
||||
if not DLLLoaded then
|
||||
exit;
|
||||
MemoryFreeLibrary(DLLHandle);
|
||||
Lib.Free;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
52
imports/GrittibanzliDLL.pas
Normal file
52
imports/GrittibanzliDLL.pas
Normal file
@@ -0,0 +1,52 @@
|
||||
unit GrittibanzliDLL;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
WinAPI.Windows,
|
||||
System.SysUtils, System.Classes;
|
||||
|
||||
var
|
||||
Grittibanzli: function(const src: Pointer; srcSize: Cardinal; dst1: Pointer;
|
||||
dst1Capacity: PCardinal; dst2: Pointer; dst2Capacity: PCardinal)
|
||||
: boolean cdecl;
|
||||
Ungrittibanzli: function(const src1: Pointer; src1Size: Cardinal;
|
||||
const src2: Pointer; src2Size: Cardinal; dst: Pointer;
|
||||
dstCapacity: PCardinal): boolean cdecl;
|
||||
DLLLoaded: boolean = False;
|
||||
|
||||
implementation
|
||||
|
||||
var
|
||||
DLLHandle: THandle;
|
||||
|
||||
procedure Init;
|
||||
begin
|
||||
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) +
|
||||
'grittibanzli_dll.dll'));
|
||||
if DLLHandle >= 32 then
|
||||
begin
|
||||
@Grittibanzli := GetProcAddress(DLLHandle, '__Grittibanzli');
|
||||
@Ungrittibanzli := GetProcAddress(DLLHandle, '__Ungrittibanzli');
|
||||
DLLLoaded := Assigned(Grittibanzli) and Assigned(Ungrittibanzli);
|
||||
end
|
||||
else
|
||||
DLLLoaded := False;
|
||||
end;
|
||||
|
||||
procedure Deinit;
|
||||
begin
|
||||
if not DLLLoaded then
|
||||
exit;
|
||||
FreeLibrary(DLLHandle);
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
Init;
|
||||
|
||||
finalization
|
||||
|
||||
Deinit;
|
||||
|
||||
end.
|
@@ -3,6 +3,7 @@ unit JoJpegDLL;
|
||||
interface
|
||||
|
||||
uses
|
||||
LibImport,
|
||||
WinAPI.Windows,
|
||||
System.SysUtils, System.Classes;
|
||||
|
||||
@@ -32,30 +33,25 @@ var
|
||||
implementation
|
||||
|
||||
var
|
||||
DLLHandle: THandle;
|
||||
Lib: TLibImport;
|
||||
|
||||
procedure Init;
|
||||
begin
|
||||
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) +
|
||||
'jojpeg_dll.dll'));
|
||||
if DLLHandle >= 32 then
|
||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'jojpeg_dll.dll');
|
||||
if Lib.Loaded then
|
||||
begin
|
||||
@jojpeg_Init := GetProcAddress(DLLHandle, 'jojpeg_Init');
|
||||
@jojpeg_Quit := GetProcAddress(DLLHandle, 'jojpeg_Quit');
|
||||
@jojpeg_Loop := GetProcAddress(DLLHandle, 'jojpeg_Loop');
|
||||
@jojpeg_Getvalue := GetProcAddress(DLLHandle, 'jojpeg_Getvalue');
|
||||
@jojpeg_Addbuf := GetProcAddress(DLLHandle, 'jojpeg_Addbuf');
|
||||
@jojpeg_Init := Lib.GetProcAddr('jojpeg_Init');
|
||||
@jojpeg_Quit := Lib.GetProcAddr('jojpeg_Quit');
|
||||
@jojpeg_Loop := Lib.GetProcAddr('jojpeg_Loop');
|
||||
@jojpeg_Getvalue := Lib.GetProcAddr('jojpeg_Getvalue');
|
||||
@jojpeg_Addbuf := Lib.GetProcAddr('jojpeg_Addbuf');
|
||||
DLLLoaded := Assigned(jojpeg_Init);
|
||||
end
|
||||
else
|
||||
DLLLoaded := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Deinit;
|
||||
begin
|
||||
if not DLLLoaded then
|
||||
exit;
|
||||
FreeLibrary(DLLHandle);
|
||||
Lib.Free;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
@@ -3,13 +3,23 @@ unit LZ4DLL;
|
||||
interface
|
||||
|
||||
uses
|
||||
LibImport,
|
||||
WinAPI.Windows,
|
||||
System.SysUtils;
|
||||
System.SysUtils, System.Math;
|
||||
|
||||
const
|
||||
LZ4F_VERSION = 100;
|
||||
|
||||
type
|
||||
PLZ4_streamDecode_t = ^LZ4_streamDecode_t;
|
||||
LZ4_streamDecode_t = array [0 .. 1 shl 9 - 1] of byte;
|
||||
|
||||
PLZ4_stream_t = ^LZ4_stream_t;
|
||||
LZ4_stream_t = array [0 .. 1 shl 9 - 1] of byte;
|
||||
|
||||
PLZ4_streamHC_t = ^LZ4_streamHC_t;
|
||||
LZ4_streamHC_t = array [0 .. 1 shl 9 - 1] of byte;
|
||||
|
||||
LZ4F_errorCode_t = type size_t;
|
||||
|
||||
LZ4F_blockSizeID_t = (LZ4F_default = 0, LZ4F_max64KB = 4, LZ4F_max256KB = 5,
|
||||
@@ -83,67 +93,65 @@ var
|
||||
LZ4F_getFrameInfo: function(dctx: LZ4F_dctx;
|
||||
out frameInfoPtr: LZ4F_frameInfo_t; srcBuffer: Pointer;
|
||||
out srcSizePtr: size_t): size_t cdecl;
|
||||
LZ4_createStreamDecode: function: PLZ4_streamDecode_t cdecl;
|
||||
LZ4_freeStreamDecode: function(LZ4_stream: PLZ4_streamDecode_t)
|
||||
: Integer cdecl;
|
||||
LZ4_decompress_safe_continue: function(LZ4_stream: PLZ4_streamDecode_t;
|
||||
const src: Pointer; dst: Pointer; srcSize: Integer; dstCapacity: Integer)
|
||||
: Integer cdecl;
|
||||
LZ4_createStream: function: PLZ4_stream_t cdecl;
|
||||
LZ4_freeStream: function(streamPtr: PLZ4_stream_t): Integer cdecl;
|
||||
LZ4_resetStream: procedure(streamHCPtr: PLZ4_stream_t)cdecl;
|
||||
LZ4_compress_fast_continue: function(streamPtr: PLZ4_stream_t;
|
||||
const src: Pointer; dst: Pointer; srcSize: Integer; maxDstSize: Integer;
|
||||
acceleration: Integer): Integer cdecl;
|
||||
LZ4_createStreamHC: function: PLZ4_streamHC_t cdecl;
|
||||
LZ4_freeStreamHC: function(streamHCPtr: PLZ4_streamHC_t): Integer cdecl;
|
||||
LZ4_resetStreamHC: procedure(streamHCPtr: PLZ4_streamHC_t;
|
||||
compressionLevel: Integer)cdecl;
|
||||
LZ4_compress_HC_continue: function(streamHCPtr: PLZ4_streamHC_t;
|
||||
const src: Pointer; dst: Pointer; srcSize: Integer; maxDstSize: Integer)
|
||||
: Integer cdecl;
|
||||
DLLLoaded: Boolean = False;
|
||||
|
||||
function LZ4F_decompress_safe(source: Pointer; dest: Pointer;
|
||||
compressedSize: Integer; maxDecompressedSize: Integer): Integer;
|
||||
sourceSize: Integer; destSize: Integer; compressedSize: PInteger = nil;
|
||||
blockSize: PInteger = nil): Integer;
|
||||
function LZ4_compress_block(src, dst: Pointer;
|
||||
srcSize, dstCapacity: Integer): Integer;
|
||||
|
||||
implementation
|
||||
|
||||
var
|
||||
DLLHandle: THandle;
|
||||
|
||||
procedure Init(Filename: String);
|
||||
begin
|
||||
if DLLLoaded then
|
||||
Exit;
|
||||
DLLHandle := 0;
|
||||
DLLHandle := LoadLibrary(PWideChar(ExtractFilePath(ParamStr(0)) + Filename));
|
||||
if DLLHandle >= 32 then
|
||||
begin
|
||||
@LZ4_decompress_safe := GetProcAddress(DLLHandle, 'LZ4_decompress_safe');
|
||||
@LZ4_decompress_fast := GetProcAddress(DLLHandle, 'LZ4_decompress_fast');
|
||||
@LZ4_compress_default := GetProcAddress(DLLHandle, 'LZ4_compress_default');
|
||||
@LZ4_compress_fast := GetProcAddress(DLLHandle, 'LZ4_compress_fast');
|
||||
@LZ4_compress_HC := GetProcAddress(DLLHandle, 'LZ4_compress_HC');
|
||||
@LZ4_compressHC2 := GetProcAddress(DLLHandle, 'LZ4_compressHC2');
|
||||
@LZ4F_compressFrame := GetProcAddress(DLLHandle, 'LZ4F_compressFrame');
|
||||
@LZ4F_compressFrameBound := GetProcAddress(DLLHandle,
|
||||
'LZ4F_compressFrameBound');
|
||||
@LZ4F_createDecompressionContext := GetProcAddress(DLLHandle,
|
||||
'LZ4F_createDecompressionContext');
|
||||
@LZ4F_freeDecompressionContext := GetProcAddress(DLLHandle,
|
||||
'LZ4F_freeDecompressionContext');
|
||||
@LZ4F_decompress := GetProcAddress(DLLHandle, 'LZ4F_decompress');
|
||||
@LZ4F_getFrameInfo := GetProcAddress(DLLHandle, 'LZ4F_getFrameInfo');
|
||||
DLLLoaded := Assigned(LZ4_decompress_safe);
|
||||
end
|
||||
else
|
||||
DLLLoaded := False;
|
||||
end;
|
||||
|
||||
procedure Deinit;
|
||||
begin
|
||||
if not DLLLoaded then
|
||||
Exit;
|
||||
FreeLibrary(DLLHandle);
|
||||
end;
|
||||
|
||||
function LZ4F_decompress_safe(source: Pointer; dest: Pointer;
|
||||
compressedSize: Integer; maxDecompressedSize: Integer): Integer;
|
||||
sourceSize: Integer; destSize: Integer; compressedSize: PInteger;
|
||||
blockSize: PInteger): Integer;
|
||||
var
|
||||
ctx: LZ4F_dctx;
|
||||
srcSizePtr, dstSizePtr: size_t;
|
||||
fi: LZ4F_frameInfo_t;
|
||||
srcSizePtr, dstSizePtr, srcSizePtr2: size_t;
|
||||
begin
|
||||
Result := 0;
|
||||
if Assigned(compressedSize) then
|
||||
compressedSize^ := 0;
|
||||
if Assigned(blockSize) then
|
||||
blockSize^ := 4;
|
||||
if NativeUInt(LZ4F_createDecompressionContext(ctx)) = 0 then
|
||||
try
|
||||
srcSizePtr := compressedSize;
|
||||
dstSizePtr := maxDecompressedSize;
|
||||
srcSizePtr := sourceSize;
|
||||
dstSizePtr := destSize;
|
||||
try
|
||||
FillChar(fi, SizeOf(LZ4F_frameInfo_t), 0);
|
||||
srcSizePtr2 := sourceSize;
|
||||
if LZ4F_decompress(ctx, dest, dstSizePtr, source, srcSizePtr, nil) = 0
|
||||
then
|
||||
begin
|
||||
LZ4F_getFrameInfo(ctx, fi, source, srcSizePtr2);
|
||||
if Assigned(compressedSize) then
|
||||
compressedSize^ := srcSizePtr;
|
||||
if Assigned(blockSize) then
|
||||
blockSize^ := Max(4, Integer(fi.blockSizeID));
|
||||
Result := dstSizePtr;
|
||||
end;
|
||||
finally
|
||||
LZ4F_freeDecompressionContext(ctx);
|
||||
end;
|
||||
@@ -151,6 +159,157 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function LZ4_compress_block(src, dst: Pointer;
|
||||
srcSize, dstCapacity: Integer): Integer;
|
||||
const
|
||||
blockSize = 64 * 1024;
|
||||
const
|
||||
BuffSize = 256 * 1024;
|
||||
var
|
||||
Buff: array [0 .. BuffSize - 1] of byte;
|
||||
ctx: PLZ4_stream_t;
|
||||
Pos1, Pos2, Res: Integer;
|
||||
X, Y: Integer;
|
||||
begin
|
||||
Result := 0;
|
||||
ctx := LZ4_createStream;
|
||||
LZ4_resetStream(ctx);
|
||||
Pos1 := 0;
|
||||
Pos2 := 0;
|
||||
try
|
||||
while (Pos1 < srcSize) and (Pos2 < dstCapacity) do
|
||||
begin
|
||||
X := Min(srcSize - Pos1, blockSize);
|
||||
Y := dstCapacity - Pos2;
|
||||
Res := LZ4_compress_fast_continue(ctx, PByte(src) + Pos1, @Buff[0], X,
|
||||
BuffSize, 1);
|
||||
if Res <= 0 then
|
||||
begin
|
||||
LZ4_freeStream(ctx);
|
||||
exit(-Pos2);
|
||||
end;
|
||||
Move(Buff[0], (PByte(dst) + Pos2)^, Res);
|
||||
Inc(Pos1, X);
|
||||
Inc(Pos2, Res);
|
||||
end;
|
||||
finally
|
||||
LZ4_freeStream(ctx);
|
||||
end;
|
||||
Result := Pos2;
|
||||
end;
|
||||
|
||||
function UnravelEncode(InBuff: Pointer; InSize: Integer; OutBuff: Pointer;
|
||||
OutSize: Integer): Integer;
|
||||
const
|
||||
blockSize = 65536;
|
||||
var
|
||||
ctx: PLZ4_streamHC_t;
|
||||
Pos1, Pos2, Res: Integer;
|
||||
X, Y: Integer;
|
||||
begin
|
||||
Result := 0;
|
||||
ctx := LZ4_createStreamHC;
|
||||
LZ4_resetStreamHC(ctx, 9);
|
||||
Pos1 := 0;
|
||||
Pos2 := 0;
|
||||
try
|
||||
while (Pos1 < InSize) do
|
||||
begin
|
||||
X := Min(InSize - Pos1, blockSize);
|
||||
Y := OutSize - (Pos2 + Integer.Size);
|
||||
Res := LZ4_compress_HC_continue(ctx, PByte(InBuff) + Pos1,
|
||||
PByte(OutBuff) + Pos2 + Integer.Size, X, Y);
|
||||
if Res <= 0 then
|
||||
begin
|
||||
LZ4_freeStreamHC(ctx);
|
||||
exit(-Pos2);
|
||||
end;
|
||||
PInteger(PByte(OutBuff) + Pos2)^ := Res;
|
||||
Inc(Pos1, X);
|
||||
Inc(Pos2, Res + Integer.Size);
|
||||
end;
|
||||
finally
|
||||
LZ4_freeStreamHC(ctx);
|
||||
end;
|
||||
Result := Pos2;
|
||||
end;
|
||||
|
||||
function UnravelDecode(InBuff: Pointer; InSize: Integer; OutBuff: Pointer;
|
||||
OutSize: Integer): Integer;
|
||||
const
|
||||
blockSize = 65536;
|
||||
var
|
||||
ctx: PLZ4_streamDecode_t;
|
||||
Pos1, Pos2, Res: Integer;
|
||||
begin
|
||||
Result := 0;
|
||||
ctx := LZ4_createStreamDecode;
|
||||
Pos1 := 0;
|
||||
Pos2 := 0;
|
||||
try
|
||||
while (Pos1 < InSize) and (Pos2 < OutSize) do
|
||||
begin
|
||||
Res := LZ4_decompress_safe_continue(ctx, PByte(InBuff) + Pos1 +
|
||||
Integer.Size, PByte(OutBuff) + Pos2, PInteger(PByte(InBuff) + Pos1)^,
|
||||
Min(OutSize - Pos2, blockSize));
|
||||
if Res <= 0 then
|
||||
begin
|
||||
LZ4_freeStreamDecode(ctx);
|
||||
exit(-Pos2);
|
||||
end;
|
||||
Inc(Pos1, PInteger(PByte(InBuff) + Pos1)^ + Integer.Size);
|
||||
Inc(Pos2, Res);
|
||||
end;
|
||||
finally
|
||||
LZ4_freeStreamDecode(ctx);
|
||||
end;
|
||||
Result := Pos2;
|
||||
end;
|
||||
|
||||
var
|
||||
Lib: TLibImport;
|
||||
|
||||
procedure Init(Filename: String);
|
||||
begin
|
||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Filename);
|
||||
if Lib.Loaded then
|
||||
begin
|
||||
@LZ4_decompress_safe := Lib.GetProcAddr('LZ4_decompress_safe');
|
||||
@LZ4_decompress_fast := Lib.GetProcAddr('LZ4_decompress_fast');
|
||||
@LZ4_compress_default := Lib.GetProcAddr('LZ4_compress_default');
|
||||
@LZ4_compress_fast := Lib.GetProcAddr('LZ4_compress_fast');
|
||||
@LZ4_compress_HC := Lib.GetProcAddr('LZ4_compress_HC');
|
||||
@LZ4_compressHC2 := Lib.GetProcAddr('LZ4_compressHC2');
|
||||
@LZ4F_compressFrame := Lib.GetProcAddr('LZ4F_compressFrame');
|
||||
@LZ4F_compressFrameBound := Lib.GetProcAddr('LZ4F_compressFrameBound');
|
||||
@LZ4F_createDecompressionContext :=
|
||||
Lib.GetProcAddr('LZ4F_createDecompressionContext');
|
||||
@LZ4F_freeDecompressionContext :=
|
||||
Lib.GetProcAddr('LZ4F_freeDecompressionContext');
|
||||
@LZ4F_decompress := Lib.GetProcAddr('LZ4F_decompress');
|
||||
@LZ4F_getFrameInfo := Lib.GetProcAddr('LZ4F_getFrameInfo');
|
||||
@LZ4_createStreamDecode := Lib.GetProcAddr('LZ4_createStreamDecode');
|
||||
@LZ4_freeStreamDecode := Lib.GetProcAddr('LZ4_freeStreamDecode');
|
||||
@LZ4_decompress_safe_continue :=
|
||||
Lib.GetProcAddr('LZ4_decompress_safe_continue');
|
||||
@LZ4_createStream := Lib.GetProcAddr('LZ4_createStream');
|
||||
@LZ4_freeStream := Lib.GetProcAddr('LZ4_freeStream');
|
||||
@LZ4_resetStream := Lib.GetProcAddr('LZ4_resetStream');
|
||||
@LZ4_compress_fast_continue :=
|
||||
Lib.GetProcAddr('LZ4_compress_fast_continue');
|
||||
@LZ4_createStreamHC := Lib.GetProcAddr('LZ4_createStreamHC');
|
||||
@LZ4_freeStreamHC := Lib.GetProcAddr('LZ4_freeStreamHC');
|
||||
@LZ4_resetStreamHC := Lib.GetProcAddr('LZ4_resetStreamHC');
|
||||
@LZ4_compress_HC_continue := Lib.GetProcAddr('LZ4_compress_HC_continue');
|
||||
DLLLoaded := Assigned(LZ4_decompress_safe);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Deinit;
|
||||
begin
|
||||
Lib.Free;
|
||||
end;
|
||||
|
||||
const
|
||||
DLLParam = '--lz4=';
|
||||
|
||||
|
@@ -3,6 +3,7 @@ unit LZODLL;
|
||||
interface
|
||||
|
||||
uses
|
||||
LibImport,
|
||||
WinAPI.Windows,
|
||||
System.SysUtils;
|
||||
|
||||
@@ -60,83 +61,36 @@ var
|
||||
dst: Pointer; dst_len: PNativeUInt; wrkmem: Pointer): integer; cdecl;
|
||||
lzo2a_decompress_safe: function(const src: Pointer; src_len: NativeUInt;
|
||||
dst: Pointer; dst_len: PNativeUInt): integer cdecl;
|
||||
lzopro_lzo1x_w03_15_compress: function(const src: Pointer;
|
||||
src_len: NativeUInt; dst: Pointer; dst_len: PNativeUInt; wrkmem: Pointer)
|
||||
: integer; cdecl;
|
||||
lzopro_lzo1x_99_compress: function(const src; src_len: integer; var dst;
|
||||
var dst_len; var cb; compression_level: integer): integer; cdecl;
|
||||
DLLLoaded: Boolean = False;
|
||||
|
||||
function lzo1x_99_compress(const src: Pointer; src_len: NativeUInt;
|
||||
dst: Pointer; dst_len: PNativeUInt; compression_level: integer): integer;
|
||||
|
||||
implementation
|
||||
|
||||
var
|
||||
DLLHandle: THandle;
|
||||
|
||||
procedure nfree(self: Pointer; ptr: Pointer); cdecl;
|
||||
begin
|
||||
FreeMem(ptr);
|
||||
end;
|
||||
|
||||
function nalloc(self: Pointer; items, size: LongWord): Pointer; cdecl;
|
||||
var
|
||||
p: Pointer;
|
||||
begin
|
||||
GetMem(p, size * items);
|
||||
Result := p;
|
||||
end;
|
||||
|
||||
procedure nprogress(self: Pointer; a, b: LongWord; c: integer); cdecl;
|
||||
begin
|
||||
end;
|
||||
|
||||
function lzo1x_99_compress(const src: Pointer; src_len: NativeUInt;
|
||||
dst: Pointer; dst_len: PNativeUInt; compression_level: integer): integer;
|
||||
var
|
||||
mycb: lzo_callback_t;
|
||||
begin
|
||||
mycb.nalloc := nalloc;
|
||||
mycb.nfree := nfree;
|
||||
mycb.nprogress := nprogress;
|
||||
Result := lzopro_lzo1x_99_compress(src^, src_len, dst^, dst_len^, mycb,
|
||||
compression_level);
|
||||
end;
|
||||
Lib: TLibImport;
|
||||
|
||||
procedure Init(Filename: String);
|
||||
begin
|
||||
if DLLLoaded then
|
||||
Exit;
|
||||
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) + Filename));
|
||||
if DLLHandle >= 32 then
|
||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Filename);
|
||||
if Lib.Loaded then
|
||||
begin
|
||||
@lzo1x_1_compress := GetProcAddress(DLLHandle, 'lzo1x_1_compress');
|
||||
@lzo1x_1_11_compress := GetProcAddress(DLLHandle, 'lzo1x_1_11_compress');
|
||||
@lzo1x_1_12_compress := GetProcAddress(DLLHandle, 'lzo1x_1_12_compress');
|
||||
@lzo1x_1_15_compress := GetProcAddress(DLLHandle, 'lzo1x_1_15_compress');
|
||||
@lzo1x_999_compress := GetProcAddress(DLLHandle, 'lzo1x_999_compress');
|
||||
@lzo1x_999_compress_level := GetProcAddress(DLLHandle,
|
||||
'lzo1x_999_compress_level');
|
||||
@lzo1x_decompress_safe := GetProcAddress(DLLHandle,
|
||||
'lzo1x_decompress_safe');
|
||||
@lzo1c_999_compress := GetProcAddress(DLLHandle, 'lzo1c_999_compress');
|
||||
@lzo1c_decompress_safe := GetProcAddress(DLLHandle,
|
||||
'lzo1c_decompress_safe');
|
||||
@lzo2a_999_compress := GetProcAddress(DLLHandle, 'lzo2a_999_compress');
|
||||
@lzo2a_decompress_safe := GetProcAddress(DLLHandle,
|
||||
'lzo2a_decompress_safe');
|
||||
@lzo1x_1_compress := Lib.GetProcAddr('lzo1x_1_compress');
|
||||
@lzo1x_1_11_compress := Lib.GetProcAddr('lzo1x_1_11_compress');
|
||||
@lzo1x_1_12_compress := Lib.GetProcAddr('lzo1x_1_12_compress');
|
||||
@lzo1x_1_15_compress := Lib.GetProcAddr('lzo1x_1_15_compress');
|
||||
@lzo1x_999_compress := Lib.GetProcAddr('lzo1x_999_compress');
|
||||
@lzo1x_999_compress_level := Lib.GetProcAddr('lzo1x_999_compress_level');
|
||||
@lzo1x_decompress_safe := Lib.GetProcAddr('lzo1x_decompress_safe');
|
||||
@lzo1c_999_compress := Lib.GetProcAddr('lzo1c_999_compress');
|
||||
@lzo1c_decompress_safe := Lib.GetProcAddr('lzo1c_decompress_safe');
|
||||
@lzo2a_999_compress := Lib.GetProcAddr('lzo2a_999_compress');
|
||||
@lzo2a_decompress_safe := Lib.GetProcAddr('lzo2a_decompress_safe');
|
||||
DLLLoaded := Assigned(lzo1x_decompress_safe);
|
||||
end
|
||||
else
|
||||
DLLLoaded := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Deinit;
|
||||
begin
|
||||
if not DLLLoaded then
|
||||
Exit;
|
||||
FreeLibrary(DLLHandle);
|
||||
Lib.Free;
|
||||
end;
|
||||
|
||||
const
|
||||
|
@@ -3,6 +3,7 @@ unit OodleDLL;
|
||||
interface
|
||||
|
||||
uses
|
||||
LibImport,
|
||||
WinAPI.Windows,
|
||||
System.SysUtils, System.Types, System.IOUtils;
|
||||
|
||||
@@ -72,57 +73,42 @@ function OodleLZ_GetCompressedBufferSizeNeeded(compressor: Byte;
|
||||
implementation
|
||||
|
||||
var
|
||||
DLLHandle: THandle;
|
||||
Lib: TLibImport;
|
||||
OldCompress, OldCompressOptions_GetDefault,
|
||||
OldGetCompressedBufferSizeNeeded: Boolean;
|
||||
DLLs: TStringDynArray;
|
||||
|
||||
procedure Init(Filename: String);
|
||||
var
|
||||
I: Integer;
|
||||
C: Cardinal;
|
||||
begin
|
||||
if DLLLoaded then
|
||||
Exit;
|
||||
DLLs := TDirectory.GetFiles(ExtractFilePath(ParamStr(0)), 'oo2core*.dll',
|
||||
TSearchOption.soTopDirectoryOnly);
|
||||
Insert(ExtractFilePath(ParamStr(0)) + Filename, DLLs, 0);
|
||||
for I := Low(DLLs) to High(DLLs) do
|
||||
begin
|
||||
DLLHandle := LoadLibrary(PChar(DLLs[I]));
|
||||
if DLLHandle >= 32 then
|
||||
break;
|
||||
end;
|
||||
if DLLHandle < 32 then
|
||||
begin
|
||||
DLLs := TDirectory.GetFiles(ExtractFilePath(ParamStr(0)), 'oo2ext*.dll',
|
||||
TSearchOption.soTopDirectoryOnly);
|
||||
for I := Low(DLLs) to High(DLLs) do
|
||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Filename);
|
||||
if not Lib.Loaded then
|
||||
for I := 3 to 9 do
|
||||
begin
|
||||
DLLHandle := LoadLibrary(PChar(DLLs[I]));
|
||||
if DLLHandle >= 32 then
|
||||
Lib.Free;
|
||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'oo2core_' +
|
||||
I.ToString + '_win64.dll');
|
||||
if Lib.Loaded then
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
if DLLHandle < 32 then
|
||||
begin
|
||||
DLLs := TDirectory.GetFiles(ExtractFilePath(ParamStr(0)), 'oodle2*.dll',
|
||||
TSearchOption.soTopDirectoryOnly);
|
||||
for I := Low(DLLs) to High(DLLs) do
|
||||
if not Lib.Loaded then
|
||||
for I := 3 to 9 do
|
||||
begin
|
||||
DLLHandle := LoadLibrary(PChar(DLLs[I]));
|
||||
if DLLHandle >= 32 then
|
||||
Lib.Free;
|
||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'oo2ext_' +
|
||||
I.ToString + '_win64.dll');
|
||||
if Lib.Loaded then
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
if DLLHandle >= 32 then
|
||||
if Lib.Loaded then
|
||||
begin
|
||||
Oodle_CheckVersion := GetProcAddress(DLLHandle, 'Oodle_CheckVersion');
|
||||
Oodle_CheckVersion := Lib.GetProcAddr('Oodle_CheckVersion');
|
||||
if not Assigned(Oodle_CheckVersion) then
|
||||
for I := 0 to 32 do
|
||||
begin
|
||||
@Oodle_CheckVersion := GetProcAddress(DLLHandle,
|
||||
PChar('_Oodle_CheckVersion@' + (I * 2).ToString));
|
||||
@Oodle_CheckVersion :=
|
||||
Lib.GetProcAddr(PAnsiChar('_Oodle_CheckVersion@' + (I * 2).ToString));
|
||||
if Assigned(Oodle_CheckVersion) then
|
||||
break;
|
||||
end;
|
||||
@@ -131,61 +117,57 @@ begin
|
||||
OldCompress := LongRec(C).Hi < $2E06;
|
||||
OldGetCompressedBufferSizeNeeded := LongRec(C).Hi < $2E08;
|
||||
OldCompressOptions_GetDefault := LongRec(C).Hi < $2E08;
|
||||
@OodleLZ_Compress_1 := GetProcAddress(DLLHandle, 'OodleLZ_Compress');
|
||||
@OodleLZ_Compress_1 := Lib.GetProcAddr('OodleLZ_Compress');
|
||||
if not Assigned(OodleLZ_Compress_1) then
|
||||
for I := 0 to 32 do
|
||||
begin
|
||||
@OodleLZ_Compress_1 := GetProcAddress(DLLHandle,
|
||||
PChar('_OodleLZ_Compress@' + (I * 2).ToString));
|
||||
@OodleLZ_Compress_1 :=
|
||||
Lib.GetProcAddr(PAnsiChar('_OodleLZ_Compress@' + (I * 2).ToString));
|
||||
if Assigned(OodleLZ_Compress_1) then
|
||||
break;
|
||||
end;
|
||||
@OodleLZ_Compress_2 := @OodleLZ_Compress_1;
|
||||
OodleLZ_Decompress := GetProcAddress(DLLHandle, 'OodleLZ_Decompress');
|
||||
OodleLZ_Decompress := Lib.GetProcAddr('OodleLZ_Decompress');
|
||||
if not Assigned(OodleLZ_Decompress) then
|
||||
for I := 0 to 32 do
|
||||
begin
|
||||
@OodleLZ_Decompress := GetProcAddress(DLLHandle,
|
||||
PChar('_OodleLZ_Decompress@' + (I * 2).ToString));
|
||||
@OodleLZ_Decompress :=
|
||||
Lib.GetProcAddr(PAnsiChar('_OodleLZ_Decompress@' + (I * 2).ToString));
|
||||
if Assigned(OodleLZ_Decompress) then
|
||||
break;
|
||||
end;
|
||||
OodleLZ_CompressOptions_GetDefault_1 := GetProcAddress(DLLHandle,
|
||||
'OodleLZ_CompressOptions_GetDefault');
|
||||
OodleLZ_CompressOptions_GetDefault_1 :=
|
||||
Lib.GetProcAddr('OodleLZ_CompressOptions_GetDefault');
|
||||
if not Assigned(OodleLZ_CompressOptions_GetDefault_1) then
|
||||
for I := 0 to 32 do
|
||||
begin
|
||||
@OodleLZ_CompressOptions_GetDefault_1 :=
|
||||
GetProcAddress(DLLHandle, PChar('_OodleLZ_CompressOptions_GetDefault@'
|
||||
+ (I * 2).ToString));
|
||||
Lib.GetProcAddr(PAnsiChar('_OodleLZ_CompressOptions_GetDefault@' +
|
||||
(I * 2).ToString));
|
||||
if Assigned(OodleLZ_CompressOptions_GetDefault_1) then
|
||||
break;
|
||||
end;
|
||||
@OodleLZ_CompressOptions_GetDefault_2 :=
|
||||
@OodleLZ_CompressOptions_GetDefault_1;
|
||||
OodleLZ_GetCompressedBufferSizeNeeded_1 :=
|
||||
GetProcAddress(DLLHandle, 'OodleLZ_GetCompressedBufferSizeNeeded');
|
||||
Lib.GetProcAddr('OodleLZ_GetCompressedBufferSizeNeeded');
|
||||
if not Assigned(OodleLZ_GetCompressedBufferSizeNeeded_1) then
|
||||
for I := 0 to 32 do
|
||||
begin
|
||||
@OodleLZ_GetCompressedBufferSizeNeeded_1 :=
|
||||
GetProcAddress(DLLHandle,
|
||||
PChar('_OodleLZ_GetCompressedBufferSizeNeeded@' + (I * 2).ToString));
|
||||
Lib.GetProcAddr(PAnsiChar('_OodleLZ_GetCompressedBufferSizeNeeded@' +
|
||||
(I * 2).ToString));
|
||||
if Assigned(OodleLZ_GetCompressedBufferSizeNeeded_1) then
|
||||
break;
|
||||
end;
|
||||
@OodleLZ_GetCompressedBufferSizeNeeded_2 :=
|
||||
@OodleLZ_GetCompressedBufferSizeNeeded_1;
|
||||
end
|
||||
else
|
||||
DLLLoaded := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Deinit;
|
||||
begin
|
||||
if not DLLLoaded then
|
||||
Exit;
|
||||
FreeLibrary(DLLHandle);
|
||||
Lib.Free;
|
||||
end;
|
||||
|
||||
function OodleLZ_Compress(compressor: Integer; rawBuf: Pointer;
|
||||
@@ -228,7 +210,7 @@ var
|
||||
|
||||
initialization
|
||||
|
||||
DLLFile := 'oodle.dll';
|
||||
DLLFile := 'oo2core_9_win64.dll';
|
||||
for I := 1 to ParamCount do
|
||||
if ParamStr(I).StartsWith(DLLParam) then
|
||||
begin
|
||||
|
@@ -3,6 +3,7 @@ unit PackJPGDLL;
|
||||
interface
|
||||
|
||||
uses
|
||||
LibImport,
|
||||
WinAPI.Windows,
|
||||
System.SysUtils, System.Classes;
|
||||
|
||||
@@ -25,35 +26,28 @@ var
|
||||
implementation
|
||||
|
||||
var
|
||||
DLLHandle: THandle;
|
||||
Lib: TLibImport;
|
||||
|
||||
procedure Init;
|
||||
begin
|
||||
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) +
|
||||
'packjpg_dll.dll'));
|
||||
if DLLHandle >= 32 then
|
||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'packjpg_dll.dll');
|
||||
if Lib.Loaded then
|
||||
begin
|
||||
@pjglib_convert_stream2stream := GetProcAddress(DLLHandle,
|
||||
'pjglib_convert_stream2stream');
|
||||
@pjglib_convert_file2file := GetProcAddress(DLLHandle,
|
||||
'pjglib_convert_file2file');
|
||||
@pjglib_convert_stream2mem := GetProcAddress(DLLHandle,
|
||||
'pjglib_convert_stream2mem');
|
||||
@pjglib_init_streams := GetProcAddress(DLLHandle, 'pjglib_init_streams');
|
||||
@pjglib_version_info := GetProcAddress(DLLHandle, 'pjglib_version_info');
|
||||
@pjglib_short_name := GetProcAddress(DLLHandle, 'pjglib_short_name');
|
||||
@pjglib_convert_stream2stream :=
|
||||
Lib.GetProcAddr('pjglib_convert_stream2stream');
|
||||
@pjglib_convert_file2file := Lib.GetProcAddr('pjglib_convert_file2file');
|
||||
@pjglib_convert_stream2mem := Lib.GetProcAddr('pjglib_convert_stream2mem');
|
||||
@pjglib_init_streams := Lib.GetProcAddr('pjglib_init_streams');
|
||||
@pjglib_version_info := Lib.GetProcAddr('pjglib_version_info');
|
||||
@pjglib_short_name := Lib.GetProcAddr('pjglib_short_name');
|
||||
DLLLoaded := Assigned(pjglib_init_streams) and
|
||||
Assigned(pjglib_convert_stream2stream);
|
||||
end
|
||||
else
|
||||
DLLLoaded := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Deinit;
|
||||
begin
|
||||
if not DLLLoaded then
|
||||
exit;
|
||||
FreeLibrary(DLLHandle);
|
||||
Lib.Free;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
@@ -3,6 +3,7 @@ unit PreflateDLL;
|
||||
interface
|
||||
|
||||
uses
|
||||
LibImport,
|
||||
WinAPI.Windows,
|
||||
System.SysUtils, System.Classes;
|
||||
|
||||
@@ -18,27 +19,22 @@ var
|
||||
implementation
|
||||
|
||||
var
|
||||
DLLHandle: THandle;
|
||||
Lib: TLibImport;
|
||||
|
||||
procedure Init;
|
||||
begin
|
||||
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) +
|
||||
'preflate_dll.dll'));
|
||||
if DLLHandle >= 32 then
|
||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'preflate_dll.dll');
|
||||
if Lib.Loaded then
|
||||
begin
|
||||
@preflate_decode := GetProcAddress(DLLHandle, 'decode');
|
||||
@preflate_reencode := GetProcAddress(DLLHandle, 'reencode');
|
||||
@preflate_decode := Lib.GetProcAddr('decode');
|
||||
@preflate_reencode := Lib.GetProcAddr('reencode');
|
||||
DLLLoaded := Assigned(preflate_decode) and Assigned(preflate_reencode);
|
||||
end
|
||||
else
|
||||
DLLLoaded := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Deinit;
|
||||
begin
|
||||
if not DLLLoaded then
|
||||
exit;
|
||||
FreeLibrary(DLLHandle);
|
||||
Lib.Free;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
@@ -3,6 +3,7 @@ unit ReflateDLL;
|
||||
interface
|
||||
|
||||
uses
|
||||
LibImport,
|
||||
WinAPI.Windows,
|
||||
System.SysUtils, System.Classes;
|
||||
|
||||
@@ -25,41 +26,35 @@ var
|
||||
implementation
|
||||
|
||||
var
|
||||
DLLHandle1, DLLHandle2: THandle;
|
||||
Lib1, Lib2: TLibImport;
|
||||
|
||||
procedure Init;
|
||||
begin
|
||||
DLLHandle1 := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) +
|
||||
'RAW2HIF_DLL.DLL'));
|
||||
DLLHandle2 := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) +
|
||||
'HIF2RAW_DLL.DLL'));
|
||||
if (DLLHandle1 >= 32) and (DLLHandle2 >= 32) then
|
||||
Lib1 := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'RAW2HIF_DLL.DLL');
|
||||
Lib2 := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'HIF2RAW_DLL.DLL');
|
||||
if Lib1.Loaded and Lib2.Loaded then
|
||||
begin
|
||||
@raw2hif_Alloc := GetProcAddress(DLLHandle1, 'raw2hif_Alloc');
|
||||
@raw2hif_Free := GetProcAddress(DLLHandle1, 'raw2hif_Free');
|
||||
@raw2hif_Init := GetProcAddress(DLLHandle1, 'raw2hif_Init');
|
||||
@raw2hif_Loop := GetProcAddress(DLLHandle1, 'raw2hif_Loop');
|
||||
@raw2hif_getoutlen := GetProcAddress(DLLHandle1, 'raw2hif_getoutlen');
|
||||
@raw2hif_getou2len := GetProcAddress(DLLHandle1, 'raw2hif_getou2len');
|
||||
@raw2hif_addbuf := GetProcAddress(DLLHandle1, 'raw2hif_addbuf');
|
||||
@hif2raw_Alloc := GetProcAddress(DLLHandle2, 'hif2raw_Alloc');
|
||||
@hif2raw_Free := GetProcAddress(DLLHandle2, 'hif2raw_Free');
|
||||
@hif2raw_Init := GetProcAddress(DLLHandle2, 'hif2raw_Init');
|
||||
@hif2raw_Loop := GetProcAddress(DLLHandle2, 'hif2raw_Loop');
|
||||
@hif2raw_getoutlen := GetProcAddress(DLLHandle2, 'hif2raw_getoutlen');
|
||||
@hif2raw_addbuf := GetProcAddress(DLLHandle2, 'hif2raw_addbuf');
|
||||
@raw2hif_Alloc := Lib1.GetProcAddr('raw2hif_Alloc');
|
||||
@raw2hif_Free := Lib1.GetProcAddr('raw2hif_Free');
|
||||
@raw2hif_Init := Lib1.GetProcAddr('raw2hif_Init');
|
||||
@raw2hif_Loop := Lib1.GetProcAddr('raw2hif_Loop');
|
||||
@raw2hif_getoutlen := Lib1.GetProcAddr('raw2hif_getoutlen');
|
||||
@raw2hif_getou2len := Lib1.GetProcAddr('raw2hif_getou2len');
|
||||
@raw2hif_addbuf := Lib1.GetProcAddr('raw2hif_addbuf');
|
||||
@hif2raw_Alloc := Lib2.GetProcAddr('hif2raw_Alloc');
|
||||
@hif2raw_Free := Lib2.GetProcAddr('hif2raw_Free');
|
||||
@hif2raw_Init := Lib2.GetProcAddr('hif2raw_Init');
|
||||
@hif2raw_Loop := Lib2.GetProcAddr('hif2raw_Loop');
|
||||
@hif2raw_getoutlen := Lib2.GetProcAddr('hif2raw_getoutlen');
|
||||
@hif2raw_addbuf := Lib2.GetProcAddr('hif2raw_addbuf');
|
||||
DLLLoaded := Assigned(raw2hif_Alloc) and Assigned(hif2raw_Alloc);
|
||||
end
|
||||
else
|
||||
DLLLoaded := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Deinit;
|
||||
begin
|
||||
if not DLLLoaded then
|
||||
exit;
|
||||
FreeLibrary(DLLHandle1);
|
||||
FreeLibrary(DLLHandle2);
|
||||
Lib1.Free;
|
||||
Lib2.Free;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
@@ -3,7 +3,7 @@ unit XDeltaDLL;
|
||||
interface
|
||||
|
||||
uses
|
||||
MemoryModule,
|
||||
LibImport,
|
||||
WinAPI.Windows,
|
||||
System.SysUtils, System.Classes;
|
||||
|
||||
@@ -37,34 +37,25 @@ var
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
Utils;
|
||||
|
||||
var
|
||||
DLLStream: TResourceStream;
|
||||
DLLHandle: TMemoryModule;
|
||||
Lib: TLibImport;
|
||||
|
||||
procedure Init;
|
||||
begin
|
||||
DLLStream := TResourceStream.Create(HInstance, 'xdelta3_dll', RT_RCDATA);
|
||||
DLLHandle := MemoryLoadLibary(DLLStream.Memory);
|
||||
if Assigned(DLLHandle) then
|
||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'xdelta3_dll.dll');
|
||||
if Lib.Loaded then
|
||||
begin
|
||||
DLLLoaded := True;
|
||||
@xd3_encode := MemoryGetProcAddress(DLLHandle, 'xd3_encode');
|
||||
@xd3_encode := Lib.GetProcAddr('xd3_encode');
|
||||
Assert(@xd3_encode <> nil);
|
||||
@xd3_decode := MemoryGetProcAddress(DLLHandle, 'xd3_decode');
|
||||
@xd3_decode := Lib.GetProcAddr('xd3_decode');
|
||||
Assert(@xd3_decode <> nil);
|
||||
end
|
||||
else
|
||||
DLLLoaded := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Deinit;
|
||||
begin
|
||||
if not DLLLoaded then
|
||||
exit;
|
||||
MemoryFreeLibrary(DLLHandle);
|
||||
Lib.Free;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
@@ -3,6 +3,7 @@ unit ZLibDLL;
|
||||
interface
|
||||
|
||||
uses
|
||||
LibImport,
|
||||
WinAPI.Windows,
|
||||
System.SysUtils, System.Types, System.IOUtils, System.ZLib;
|
||||
|
||||
@@ -86,55 +87,8 @@ function inflateReset(var strm: z_stream): integer;
|
||||
implementation
|
||||
|
||||
var
|
||||
DLLHandle: THandle;
|
||||
Lib: TLibImport;
|
||||
WinAPIDLL: boolean;
|
||||
DLLs: TStringDynArray;
|
||||
|
||||
procedure Init(Filename: String);
|
||||
var
|
||||
I: integer;
|
||||
begin
|
||||
if DLLLoaded then
|
||||
Exit;
|
||||
DLLs := TDirectory.GetFiles(ExtractFilePath(ParamStr(0)), 'zlib*.dll',
|
||||
TSearchOption.soTopDirectoryOnly);
|
||||
Insert(ExtractFilePath(ParamStr(0)) + 'zlib.dll', DLLs, Length(DLLs));
|
||||
Insert(ExtractFilePath(ParamStr(0)) + Filename, DLLs, 0);
|
||||
for I := Low(DLLs) to High(DLLs) do
|
||||
begin
|
||||
DLLHandle := LoadLibrary(PChar(DLLs[I]));
|
||||
if (DLLHandle >= 32) and Assigned(GetProcAddress(DLLHandle, 'zlibVersion'))
|
||||
then
|
||||
break;
|
||||
end;
|
||||
if DLLHandle >= 32 then
|
||||
begin
|
||||
DLLLoaded := True;
|
||||
@_zlibVersion := GetProcAddress(DLLHandle, 'zlibVersion');
|
||||
@_zlibCompileFlags := GetProcAddress(DLLHandle, 'zlibCompileFlags');
|
||||
DLLLoaded := Assigned(_zlibVersion) and Assigned(_zlibCompileFlags);
|
||||
if DLLLoaded then
|
||||
begin
|
||||
WinAPIDLL := _zlibCompileFlags and $400 = $400;
|
||||
if WinAPIDLL then
|
||||
begin
|
||||
@s_deflateInit2_ := GetProcAddress(DLLHandle, 'deflateInit2_');
|
||||
@s_deflate := GetProcAddress(DLLHandle, 'deflate');
|
||||
@s_deflateEnd := GetProcAddress(DLLHandle, 'deflateEnd');
|
||||
@s_deflateReset := GetProcAddress(DLLHandle, 'deflateReset');
|
||||
end
|
||||
else
|
||||
begin
|
||||
@c_deflateInit2_ := GetProcAddress(DLLHandle, 'deflateInit2_');
|
||||
@c_deflate := GetProcAddress(DLLHandle, 'deflate');
|
||||
@c_deflateEnd := GetProcAddress(DLLHandle, 'deflateEnd');
|
||||
@c_deflateReset := GetProcAddress(DLLHandle, 'deflateReset');
|
||||
end;
|
||||
end;
|
||||
end
|
||||
else
|
||||
DLLLoaded := False;
|
||||
end;
|
||||
|
||||
function deflateInit2(var strm: z_stream; level, method, windowBits, memLevel,
|
||||
strategy: integer): integer;
|
||||
@@ -192,11 +146,49 @@ begin
|
||||
Result := System.ZLib.inflateReset(strm);
|
||||
end;
|
||||
|
||||
procedure Init(Filename: String);
|
||||
begin
|
||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Filename);
|
||||
if not(Lib.Loaded and Assigned(Lib.GetProcAddr('zlibVersion'))) then
|
||||
begin
|
||||
Lib.Free;
|
||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'zlibwapi.dll');
|
||||
end;
|
||||
if not(Lib.Loaded and Assigned(Lib.GetProcAddr('zlibVersion'))) then
|
||||
begin
|
||||
Lib.Free;
|
||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'zlib1.dll');
|
||||
end;
|
||||
if Lib.Loaded and Assigned(Lib.GetProcAddr('zlibVersion')) then
|
||||
begin
|
||||
DLLLoaded := True;
|
||||
@_zlibVersion := Lib.GetProcAddr('zlibVersion');
|
||||
@_zlibCompileFlags := Lib.GetProcAddr('zlibCompileFlags');
|
||||
DLLLoaded := Assigned(_zlibVersion) and Assigned(_zlibCompileFlags);
|
||||
if DLLLoaded then
|
||||
begin
|
||||
WinAPIDLL := _zlibCompileFlags and $400 = $400;
|
||||
if WinAPIDLL then
|
||||
begin
|
||||
@s_deflateInit2_ := Lib.GetProcAddr('deflateInit2_');
|
||||
@s_deflate := Lib.GetProcAddr('deflate');
|
||||
@s_deflateEnd := Lib.GetProcAddr('deflateEnd');
|
||||
@s_deflateReset := Lib.GetProcAddr('deflateReset');
|
||||
end
|
||||
else
|
||||
begin
|
||||
@c_deflateInit2_ := Lib.GetProcAddr('deflateInit2_');
|
||||
@c_deflate := Lib.GetProcAddr('deflate');
|
||||
@c_deflateEnd := Lib.GetProcAddr('deflateEnd');
|
||||
@c_deflateReset := Lib.GetProcAddr('deflateReset');
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Deinit;
|
||||
begin
|
||||
if not DLLLoaded then
|
||||
Exit;
|
||||
FreeLibrary(DLLHandle);
|
||||
Lib.Free;
|
||||
end;
|
||||
|
||||
const
|
||||
|
@@ -3,6 +3,7 @@ unit ZSTDDLL;
|
||||
interface
|
||||
|
||||
uses
|
||||
LibImport,
|
||||
WinAPI.Windows,
|
||||
System.SysUtils;
|
||||
|
||||
@@ -142,54 +143,45 @@ begin
|
||||
end;
|
||||
|
||||
var
|
||||
DLLHandle: THandle;
|
||||
Lib: TLibImport;
|
||||
|
||||
procedure Init(Filename: String);
|
||||
begin
|
||||
if DLLLoaded then
|
||||
Exit;
|
||||
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) + Filename));
|
||||
if DLLHandle >= 32 then
|
||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Filename);
|
||||
if Lib.Loaded then
|
||||
begin
|
||||
@ZSTD_compress := GetProcAddress(DLLHandle, 'ZSTD_compress');
|
||||
@ZSTD_compress2 := GetProcAddress(DLLHandle, 'ZSTD_compress2');
|
||||
@ZSTD_decompress := GetProcAddress(DLLHandle, 'ZSTD_decompress');
|
||||
@ZSTD_findFrameCompressedSize := GetProcAddress(DLLHandle,
|
||||
'ZSTD_findFrameCompressedSize');
|
||||
@ZSTD_findDecompressedSize := GetProcAddress(DLLHandle,
|
||||
'ZSTD_findDecompressedSize');
|
||||
@ZSTD_createCCtx := GetProcAddress(DLLHandle, 'ZSTD_createCCtx');
|
||||
@ZSTD_freeCCtx := GetProcAddress(DLLHandle, 'ZSTD_freeCCtx');
|
||||
@ZSTD_CCtx_reset := GetProcAddress(DLLHandle, 'ZSTD_CCtx_reset');
|
||||
@ZSTD_CCtx_setParameter := GetProcAddress(DLLHandle,
|
||||
'ZSTD_CCtx_setParameter');
|
||||
@ZSTD_createDCtx := GetProcAddress(DLLHandle, 'ZSTD_createDCtx');
|
||||
@ZSTD_freeDCtx := GetProcAddress(DLLHandle, 'ZSTD_freeDCtx');
|
||||
@ZSTD_createCDict := GetProcAddress(DLLHandle, 'ZSTD_createCDict');
|
||||
@ZSTD_freeCDict := GetProcAddress(DLLHandle, 'ZSTD_freeCDict');
|
||||
@ZSTD_compressCCtx := GetProcAddress(DLLHandle, 'ZSTD_compressCCtx');
|
||||
@ZSTD_createDDict := GetProcAddress(DLLHandle, 'ZSTD_createDDict');
|
||||
@ZSTD_freeDDict := GetProcAddress(DLLHandle, 'ZSTD_freeDDict');
|
||||
@ZSTD_decompressDCtx := GetProcAddress(DLLHandle, 'ZSTD_decompressDCtx');
|
||||
@ZSTD_compress_usingCDict := GetProcAddress(DLLHandle,
|
||||
'ZSTD_compress_usingCDict');
|
||||
@ZSTD_decompress_usingDDict := GetProcAddress(DLLHandle,
|
||||
'ZSTD_decompress_usingDDict');
|
||||
@ZSTD_initCStream := GetProcAddress(DLLHandle, 'ZSTD_initCStream');
|
||||
@ZSTD_compressStream := GetProcAddress(DLLHandle, 'ZSTD_compressStream');
|
||||
@ZSTD_flushStream := GetProcAddress(DLLHandle, 'ZSTD_flushStream');
|
||||
@ZSTD_endStream := GetProcAddress(DLLHandle, 'ZSTD_endStream');
|
||||
@ZSTD_compress := Lib.GetProcAddr('ZSTD_compress');
|
||||
@ZSTD_compress2 := Lib.GetProcAddr('ZSTD_compress2');
|
||||
@ZSTD_decompress := Lib.GetProcAddr('ZSTD_decompress');
|
||||
@ZSTD_findFrameCompressedSize :=
|
||||
Lib.GetProcAddr('ZSTD_findFrameCompressedSize');
|
||||
@ZSTD_findDecompressedSize := Lib.GetProcAddr('ZSTD_findDecompressedSize');
|
||||
@ZSTD_createCCtx := Lib.GetProcAddr('ZSTD_createCCtx');
|
||||
@ZSTD_freeCCtx := Lib.GetProcAddr('ZSTD_freeCCtx');
|
||||
@ZSTD_CCtx_reset := Lib.GetProcAddr('ZSTD_CCtx_reset');
|
||||
@ZSTD_CCtx_setParameter := Lib.GetProcAddr('ZSTD_CCtx_setParameter');
|
||||
@ZSTD_createDCtx := Lib.GetProcAddr('ZSTD_createDCtx');
|
||||
@ZSTD_freeDCtx := Lib.GetProcAddr('ZSTD_freeDCtx');
|
||||
@ZSTD_createCDict := Lib.GetProcAddr('ZSTD_createCDict');
|
||||
@ZSTD_freeCDict := Lib.GetProcAddr('ZSTD_freeCDict');
|
||||
@ZSTD_compressCCtx := Lib.GetProcAddr('ZSTD_compressCCtx');
|
||||
@ZSTD_createDDict := Lib.GetProcAddr('ZSTD_createDDict');
|
||||
@ZSTD_freeDDict := Lib.GetProcAddr('ZSTD_freeDDict');
|
||||
@ZSTD_decompressDCtx := Lib.GetProcAddr('ZSTD_decompressDCtx');
|
||||
@ZSTD_compress_usingCDict := Lib.GetProcAddr('ZSTD_compress_usingCDict');
|
||||
@ZSTD_decompress_usingDDict :=
|
||||
Lib.GetProcAddr('ZSTD_decompress_usingDDict');
|
||||
@ZSTD_initCStream := Lib.GetProcAddr('ZSTD_initCStream');
|
||||
@ZSTD_compressStream := Lib.GetProcAddr('ZSTD_compressStream');
|
||||
@ZSTD_flushStream := Lib.GetProcAddr('ZSTD_flushStream');
|
||||
@ZSTD_endStream := Lib.GetProcAddr('ZSTD_endStream');
|
||||
DLLLoaded := Assigned(ZSTD_compress) and Assigned(ZSTD_decompress);
|
||||
end
|
||||
else
|
||||
DLLLoaded := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Deinit;
|
||||
begin
|
||||
if not DLLLoaded then
|
||||
Exit;
|
||||
FreeLibrary(DLLHandle);
|
||||
Lib.Free;
|
||||
end;
|
||||
|
||||
const
|
||||
|
Reference in New Issue
Block a user