4.58 beta

This commit is contained in:
Igor Pavlov
2008-05-05 00:00:00 +00:00
committed by Kornel Lesiński
parent bd1fa36322
commit 3901bf0ab8
326 changed files with 10643 additions and 14913 deletions

View File

@@ -371,69 +371,26 @@ SOURCE=..\..\Common\StreamUtils.h
# Begin Group "C"
# PROP Default_Filter ""
# Begin Group "C-Lz"
# Begin Group "LzmaUtil"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.c
SOURCE=..\..\..\..\C\LzmaUtil\Lzma86Dec.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Compress\Lz\MatchFinder.h
SOURCE=..\..\..\..\C\LzmaUtil\Lzma86Dec.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Compress\Lz\MatchFinderMt.c
SOURCE=..\..\..\..\C\LzmaUtil\Lzma86Enc.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Compress\Lz\MatchFinderMt.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.h
# End Source File
# End Group
# Begin Group "LZMA_C"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\..\C\Compress\Lzma\LzmaDecode.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Compress\Lzma\LzmaDecode.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Compress\Lzma\LzmaTypes.h
# End Source File
# End Group
# Begin Group "Branch"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\..\C\Compress\Branch\BranchTypes.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Compress\Branch\BranchX86.h
SOURCE=..\..\..\..\C\LzmaUtil\Lzma86Enc.h
# End Source File
# End Group
# Begin Source File
@@ -456,6 +413,64 @@ SOURCE=..\..\..\..\C\Alloc.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Bra.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Bra86.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\LzFind.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\LzFind.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\LzFindMt.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\LzFindMt.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\LzHash.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\LzmaDec.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\LzmaDec.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\LzmaEnc.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\LzmaEnc.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Types.h
# End Source File
# End Group
@@ -483,22 +498,5 @@ SOURCE=.\LzmaBenchCon.cpp
SOURCE=.\LzmaBenchCon.h
# End Source File
# Begin Source File
SOURCE=.\LzmaRam.cpp
# End Source File
# Begin Source File
SOURCE=.\LzmaRam.h
# End Source File
# Begin Source File
SOURCE=.\LzmaRamDecode.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=.\LzmaRamDecode.h
# End Source File
# End Target
# End Project

View File

@@ -26,15 +26,19 @@
#include "../LZMA/LZMAEncoder.h"
#include "LzmaBenchCon.h"
#include "LzmaRam.h"
#ifdef COMPRESS_MF_MT
#include "../../../Windows/System.h"
#endif
#include "../../MyVersion.h"
extern "C"
{
#include "LzmaRamDecode.h"
#include "../../../../C/Alloc.h"
#include "../../../../C/LzmaUtil/Lzma86Dec.h"
#include "../../../../C/LzmaUtil/Lzma86Enc.h"
}
using namespace NCommandLineParser;
@@ -105,7 +109,7 @@ static void PrintHelp()
" b: Benchmark\n"
"<Switches>\n"
" -a{N}: set compression mode - [0, 1], default: 1 (max)\n"
" -d{N}: set dictionary - [0,30], default: 23 (8MB)\n"
" -d{N}: set dictionary - [12, 30], default: 23 (8MB)\n"
" -fb{N}: set number of fast bytes - [5, 273], default: 128\n"
" -mc{N}: set number of cycles for match finder\n"
" -lc{N}: set number of literal context bits - [0, 8], default: 3\n"
@@ -159,7 +163,7 @@ int main2(int n, const char *args[])
g_IsNT = IsItWindowsNT();
#endif
fprintf(stderr, "\nLZMA 4.56 Copyright (c) 1999-2007 Igor Pavlov 2007-10-19\n");
fprintf(stderr, "\nLZMA " MY_VERSION_COPYRIGHT_DATE "\n");
if (n == 1)
{
@@ -306,7 +310,7 @@ int main2(int n, const char *args[])
inStreamSpec->File.GetLength(fileSize);
if (fileSize > 0xF0000000)
throw "File is too big";
UInt32 inSize = (UInt32)fileSize;
size_t inSize = (size_t)fileSize;
Byte *inBuffer = 0;
if (inSize != 0)
{
@@ -315,18 +319,15 @@ int main2(int n, const char *args[])
throw kCantAllocate;
}
UInt32 processedSize;
if (ReadStream(inStream, inBuffer, (UInt32)inSize, &processedSize) != S_OK)
if (ReadStream_FAIL(inStream, inBuffer, inSize) != S_OK)
throw "Can not read";
if ((UInt32)inSize != processedSize)
throw "Read size error";
Byte *outBuffer = 0;
size_t outSizeProcessed;
size_t outSize;
if (encodeMode)
{
// we allocate 105% of original size for output buffer
size_t outSize = (size_t)fileSize / 20 * 21 + (1 << 16);
outSize = (size_t)fileSize / 20 * 21 + (1 << 16);
if (outSize != 0)
{
outBuffer = (Byte *)MyAlloc((size_t)outSize);
@@ -335,8 +336,8 @@ int main2(int n, const char *args[])
}
if (!dictionaryIsDefined)
dictionary = 1 << 23;
int res = LzmaRamEncode(inBuffer, inSize, outBuffer, outSize, &outSizeProcessed,
dictionary, parser[NKey::kFilter86].PostCharIndex == 0 ? SZ_FILTER_YES : SZ_FILTER_AUTO);
int res = Lzma86_Encode(outBuffer, &outSize, inBuffer, inSize,
5, dictionary, parser[NKey::kFilter86].PostCharIndex == 0 ? SZ_FILTER_YES : SZ_FILTER_AUTO);
if (res != 0)
{
fprintf(stderr, "\nEncoder error = %d\n", (int)res);
@@ -345,20 +346,25 @@ int main2(int n, const char *args[])
}
else
{
size_t outSize;
if (LzmaRamGetUncompressedSize(inBuffer, inSize, &outSize) != 0)
UInt64 outSize64;
if (Lzma86_GetUnpackSize(inBuffer, inSize, &outSize64) != 0)
throw "data error";
outSize = (size_t)outSize64;
if (outSize != outSize64)
throw "too big";
if (outSize != 0)
{
outBuffer = (Byte *)MyAlloc(outSize);
if (outBuffer == 0)
throw kCantAllocate;
}
int res = LzmaRamDecompress(inBuffer, inSize, outBuffer, outSize, &outSizeProcessed, malloc, free);
int res = Lzma86_Decode(outBuffer, &outSize, inBuffer, &inSize);
if (inSize != (size_t)fileSize)
throw "incorrect processed size";
if (res != 0)
throw "LzmaDecoder error";
}
if (WriteStream(outStream, outBuffer, (UInt32)outSizeProcessed, &processedSize) != S_OK)
if (WriteStream(outStream, outBuffer, outSize) != S_OK)
throw kWriteError;
MyFree(outBuffer);
MyFree(inBuffer);
@@ -486,40 +492,22 @@ int main2(int n, const char *args[])
NCompress::NLZMA::CDecoder *decoderSpec = new NCompress::NLZMA::CDecoder;
CMyComPtr<ICompressCoder> decoder = decoderSpec;
const UInt32 kPropertiesSize = 5;
Byte properties[kPropertiesSize];
UInt32 processedSize;
if (ReadStream(inStream, properties, kPropertiesSize, &processedSize) != S_OK)
Byte header[kPropertiesSize + 8];
if (ReadStream_FALSE(inStream, header, kPropertiesSize + 8) != S_OK)
{
fprintf(stderr, kReadError);
return 1;
}
if (processedSize != kPropertiesSize)
{
fprintf(stderr, kReadError);
return 1;
}
if (decoderSpec->SetDecoderProperties2(properties, kPropertiesSize) != S_OK)
if (decoderSpec->SetDecoderProperties2(header, kPropertiesSize) != S_OK)
{
fprintf(stderr, "SetDecoderProperties error");
return 1;
}
fileSize = 0;
for (int i = 0; i < 8; i++)
{
Byte b;
if (inStream->Read(&b, 1, &processedSize) != S_OK)
{
fprintf(stderr, kReadError);
return 1;
}
if (processedSize != 1)
{
fprintf(stderr, kReadError);
return 1;
}
fileSize |= ((UInt64)b) << (8 * i);
}
if (decoder->Code(inStream, outStream, 0, &fileSize, 0) != S_OK)
fileSize |= ((UInt64)header[kPropertiesSize + i]) << (8 * i);
if (decoder->Code(inStream, outStream, 0, (fileSize == (UInt64)(Int64)-1) ? 0 : &fileSize, 0) != S_OK)
{
fprintf(stderr, "Decoder error");
return 1;
@@ -536,7 +524,7 @@ int main2(int n, const char *args[])
return 0;
}
int main(int n, const char *args[])
int MY_CDECL main(int n, const char *args[])
{
try { return main2(n, args); }
catch(const char *s)

View File

@@ -438,17 +438,14 @@ static UInt64 MyMultDiv64(UInt64 value, UInt64 elapsedTime, UInt64 freq)
UInt64 GetCompressRating(UInt32 dictionarySize, UInt64 elapsedTime, UInt64 freq, UInt64 size)
{
UInt64 t = GetLogSize(dictionarySize) - (kBenchMinDicLogSize << kSubBits);
// UInt64 numCommandsForOne = 1000 + ((t * t * 7) >> (2 * kSubBits)); // AMD K8
UInt64 numCommandsForOne = 870 + ((t * t * 5) >> (2 * kSubBits)); // Intel Core2
UInt64 numCommandsForOne = 870 + ((t * t * 5) >> (2 * kSubBits));
UInt64 numCommands = (UInt64)(size) * numCommandsForOne;
return MyMultDiv64(numCommands, elapsedTime, freq);
}
UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt32 numIterations)
{
// UInt64 numCommands = (inSize * 216 + outSize * 14) * numIterations; // AMD K8
UInt64 numCommands = (inSize * 220 + outSize * 8) * numIterations; // Intel Core2
UInt64 numCommands = (inSize * 200 + outSize * 4) * numIterations;
return MyMultDiv64(numCommands, elapsedTime, freq);
}
@@ -796,10 +793,9 @@ HRESULT LzmaBench(
{
for (UInt32 j = 0; j < numSubDecoderThreads; j++)
{
size_t allocaSize = ((i * numSubDecoderThreads + j) * 16 * 21) & 0x7FF;
HRESULT res = encoder.CreateDecoderThread(j, (i == 0 && j == 0)
#ifdef USE_ALLOCA
, allocaSize
, ((i * numSubDecoderThreads + j) * 16 * 21) & 0x7FF
#endif
);
RINOK(res);

View File

@@ -1,226 +0,0 @@
// LzmaRam.cpp
#include "StdAfx.h"
#include "../../../Common/Types.h"
#include "../LZMA/LZMADecoder.h"
#include "../LZMA/LZMAEncoder.h"
#include "LzmaRam.h"
extern "C"
{
#include "../../../../C/Compress/Branch/BranchX86.h"
}
class CInStreamRam:
public ISequentialInStream,
public CMyUnknownImp
{
const Byte *Data;
size_t Size;
size_t Pos;
public:
MY_UNKNOWN_IMP
void Init(const Byte *data, size_t size)
{
Data = data;
Size = size;
Pos = 0;
}
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
};
STDMETHODIMP CInStreamRam::Read(void *data, UInt32 size, UInt32 *processedSize)
{
if (size > (Size - Pos))
size = (UInt32)(Size - Pos);
for (UInt32 i = 0; i < size; i++)
((Byte *)data)[i] = Data[Pos + i];
Pos += size;
if(processedSize != NULL)
*processedSize = size;
return S_OK;
}
class COutStreamRam:
public ISequentialOutStream,
public CMyUnknownImp
{
size_t Size;
public:
Byte *Data;
size_t Pos;
bool Overflow;
void Init(Byte *data, size_t size)
{
Data = data;
Size = size;
Pos = 0;
Overflow = false;
}
void SetPos(size_t pos)
{
Overflow = false;
Pos = pos;
}
MY_UNKNOWN_IMP
HRESULT WriteByte(Byte b)
{
if (Pos >= Size)
{
Overflow = true;
return E_FAIL;
}
Data[Pos++] = b;
return S_OK;
}
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
};
STDMETHODIMP COutStreamRam::Write(const void *data, UInt32 size, UInt32 *processedSize)
{
UInt32 i;
for (i = 0; i < size && Pos < Size; i++)
Data[Pos++] = ((const Byte *)data)[i];
if(processedSize != NULL)
*processedSize = i;
if (i != size)
{
Overflow = true;
return E_FAIL;
}
return S_OK;
}
#define SZ_RAM_E_FAIL (1)
#define SZ_RAM_E_OUTOFMEMORY (2)
#define SZE_OUT_OVERFLOW (3)
int LzmaRamEncode(
const Byte *inBuffer, size_t inSize,
Byte *outBuffer, size_t outSize, size_t *outSizeProcessed,
UInt32 dictionarySize, ESzFilterMode filterMode)
{
#ifndef _NO_EXCEPTIONS
try {
#endif
*outSizeProcessed = 0;
const size_t kIdSize = 1;
const size_t kLzmaPropsSize = 5;
const size_t kMinDestSize = kIdSize + kLzmaPropsSize + 8;
if (outSize < kMinDestSize)
return SZE_OUT_OVERFLOW;
NCompress::NLZMA::CEncoder *encoderSpec = new NCompress::NLZMA::CEncoder;
CMyComPtr<ICompressCoder> encoder = encoderSpec;
PROPID propIDs[] =
{
NCoderPropID::kAlgorithm,
NCoderPropID::kDictionarySize,
NCoderPropID::kNumFastBytes,
};
const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
PROPVARIANT properties[kNumProps];
properties[0].vt = VT_UI4;
properties[1].vt = VT_UI4;
properties[2].vt = VT_UI4;
properties[0].ulVal = (UInt32)2;
properties[1].ulVal = (UInt32)dictionarySize;
properties[2].ulVal = (UInt32)64;
if (encoderSpec->SetCoderProperties(propIDs, properties, kNumProps) != S_OK)
return 1;
COutStreamRam *outStreamSpec = new COutStreamRam;
if (outStreamSpec == 0)
return SZ_RAM_E_OUTOFMEMORY;
CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
CInStreamRam *inStreamSpec = new CInStreamRam;
if (inStreamSpec == 0)
return SZ_RAM_E_OUTOFMEMORY;
CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
outStreamSpec->Init(outBuffer, outSize);
if (outStreamSpec->WriteByte(0) != S_OK)
return SZE_OUT_OVERFLOW;
if (encoderSpec->WriteCoderProperties(outStream) != S_OK)
return SZE_OUT_OVERFLOW;
if (outStreamSpec->Pos != kIdSize + kLzmaPropsSize)
return 1;
int i;
for (i = 0; i < 8; i++)
{
UInt64 t = (UInt64)(inSize);
if (outStreamSpec->WriteByte((Byte)((t) >> (8 * i))) != S_OK)
return SZE_OUT_OVERFLOW;
}
Byte *filteredStream = 0;
bool useFilter = (filterMode != SZ_FILTER_NO);
if (useFilter)
{
if (inSize != 0)
{
filteredStream = (Byte *)MyAlloc(inSize);
if (filteredStream == 0)
return SZ_RAM_E_OUTOFMEMORY;
memmove(filteredStream, inBuffer, inSize);
}
UInt32 x86State;
x86_Convert_Init(x86State);
x86_Convert(filteredStream, (SizeT)inSize, 0, &x86State, 1);
}
size_t minSize = 0;
int numPasses = (filterMode == SZ_FILTER_AUTO) ? 3 : 1;
bool bestIsFiltered = false;
int mainResult = 0;
size_t startPos = outStreamSpec->Pos;
for (i = 0; i < numPasses; i++)
{
if (numPasses > 1 && i == numPasses - 1 && !bestIsFiltered)
break;
outStreamSpec->SetPos(startPos);
bool curModeIsFiltered = false;
if (useFilter && i == 0)
curModeIsFiltered = true;
if (numPasses > 1 && i == numPasses - 1)
curModeIsFiltered = true;
inStreamSpec->Init(curModeIsFiltered ? filteredStream : inBuffer, inSize);
HRESULT lzmaResult = encoder->Code(inStream, outStream, 0, 0, 0);
mainResult = 0;
if (lzmaResult == E_OUTOFMEMORY)
{
mainResult = SZ_RAM_E_OUTOFMEMORY;
break;
}
if (i == 0 || outStreamSpec->Pos <= minSize)
{
minSize = outStreamSpec->Pos;
bestIsFiltered = curModeIsFiltered;
}
if (outStreamSpec->Overflow)
mainResult = SZE_OUT_OVERFLOW;
else if (lzmaResult != S_OK)
{
mainResult = SZ_RAM_E_FAIL;
break;
}
}
*outSizeProcessed = outStreamSpec->Pos;
if (bestIsFiltered)
outBuffer[0] = 1;
if (useFilter)
MyFree(filteredStream);
return mainResult;
#ifndef _NO_EXCEPTIONS
} catch(...) { return SZ_RAM_E_OUTOFMEMORY; }
#endif
}

View File

@@ -1,46 +0,0 @@
// LzmaRam.h
#ifndef __LzmaRam_h
#define __LzmaRam_h
#include <stdlib.h>
#include "../../../Common/Types.h"
/*
LzmaRamEncode: BCJ + LZMA RAM->RAM compressing.
It uses .lzma format, but it writes one additional byte to .lzma file:
0: - no filter
1: - x86(BCJ) filter.
To provide best compression ratio dictionarySize mustbe >= inSize
LzmaRamEncode allocates Data with MyAlloc/BigAlloc functions.
RAM Requirements:
RamSize = dictionarySize * 9.5 + 6MB + FilterBlockSize
FilterBlockSize = 0, if useFilter == false
FilterBlockSize = inSize, if useFilter == true
Return code:
0 - OK
1 - Unspecified Error
2 - Memory allocating error
3 - Output buffer OVERFLOW
If you use SZ_FILTER_AUTO mode, then encoder will use 2 or 3 passes:
2 passes when FILTER_NO provides better compression.
3 passes when FILTER_YES provides better compression.
*/
enum ESzFilterMode
{
SZ_FILTER_NO,
SZ_FILTER_YES,
SZ_FILTER_AUTO
};
int LzmaRamEncode(
const Byte *inBuffer, size_t inSize,
Byte *outBuffer, size_t outSize, size_t *outSizeProcessed,
UInt32 dictionarySize, ESzFilterMode filterMode);
#endif

View File

@@ -1,78 +0,0 @@
/* LzmaRamDecode.c */
#include "LzmaRamDecode.h"
#ifdef _SZ_ONE_DIRECTORY
#include "LzmaDecode.h"
#include "BranchX86.h"
#else
#include "../../../../C/Compress/Lzma/LzmaDecode.h"
#include "../../../../C/Compress/Branch/BranchX86.h"
#endif
#define LZMA_PROPS_SIZE 14
#define LZMA_SIZE_OFFSET 6
int LzmaRamGetUncompressedSize(
const unsigned char *inBuffer,
size_t inSize,
size_t *outSize)
{
unsigned int i;
if (inSize < LZMA_PROPS_SIZE)
return 1;
*outSize = 0;
for(i = 0; i < sizeof(size_t); i++)
*outSize += ((size_t)inBuffer[LZMA_SIZE_OFFSET + i]) << (8 * i);
for(; i < 8; i++)
if (inBuffer[LZMA_SIZE_OFFSET + i] != 0)
return 1;
return 0;
}
#define SZE_DATA_ERROR (1)
#define SZE_OUTOFMEMORY (2)
int LzmaRamDecompress(
const unsigned char *inBuffer,
size_t inSize,
unsigned char *outBuffer,
size_t outSize,
size_t *outSizeProcessed,
void * (*allocFunc)(size_t size),
void (*freeFunc)(void *))
{
CLzmaDecoderState state; /* it's about 24 bytes structure, if int is 32-bit */
int result;
SizeT outSizeProcessedLoc;
SizeT inProcessed;
int useFilter;
if (inSize < LZMA_PROPS_SIZE)
return 1;
useFilter = inBuffer[0];
*outSizeProcessed = 0;
if (useFilter > 1)
return 1;
if (LzmaDecodeProperties(&state.Properties, inBuffer + 1, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
return 1;
state.Probs = (CProb *)allocFunc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
if (state.Probs == 0)
return SZE_OUTOFMEMORY;
result = LzmaDecode(&state,
inBuffer + LZMA_PROPS_SIZE, (SizeT)inSize - LZMA_PROPS_SIZE, &inProcessed,
outBuffer, (SizeT)outSize, &outSizeProcessedLoc);
freeFunc(state.Probs);
if (result != LZMA_RESULT_OK)
return 1;
*outSizeProcessed = (size_t)outSizeProcessedLoc;
if (useFilter == 1)
{
UInt32 x86State;
x86_Convert_Init(x86State);
x86_Convert(outBuffer, (SizeT)outSizeProcessedLoc, 0, &x86State, 0);
}
return 0;
}

View File

@@ -1,55 +0,0 @@
/* LzmaRamDecode.h */
#ifndef __LzmaRamDecode_h
#define __LzmaRamDecode_h
#include <stdlib.h>
/*
LzmaRamGetUncompressedSize:
In:
inBuffer - input data
inSize - input data size
Out:
outSize - uncompressed size
Return code:
0 - OK
1 - Error in headers
*/
int LzmaRamGetUncompressedSize(
const unsigned char *inBuffer,
size_t inSize,
size_t *outSize);
/*
LzmaRamDecompress:
In:
inBuffer - input data
inSize - input data size
outBuffer - output data
outSize - output size
allocFunc - alloc function (can be malloc)
freeFunc - free function (can be free)
Out:
outSizeProcessed - processed size
Return code:
0 - OK
1 - Error in headers / data stream
2 - Memory allocating error
Memory requirements depend from properties of LZMA stream.
With default lzma settings it's about 16 KB.
*/
int LzmaRamDecompress(
const unsigned char *inBuffer,
size_t inSize,
unsigned char *outBuffer,
size_t outSize,
size_t *outSizeProcessed,
void * (*allocFunc)(size_t size),
void (*freeFunc)(void *));
#endif

View File

@@ -1,49 +1,13 @@
PROG = lzma.exe
LIBS = $(LIBS) user32.lib
CFLAGS = $(CFLAGS) \
-DCOMPRESS_MF_MT \
-DBENCH_MT \
LIBS = $(LIBS) oleaut32.lib user32.lib
!IFDEF CPU
LIBS = $(LIBS) bufferoverflowU.lib
CFLAGS = $(CFLAGS) -GS- -Zc:forScope -W4 -Wp64 -DUNICODE -D_UNICODE
!ENDIF
!IFNDEF O
!IFDEF CPU
O=$(CPU)
!ELSE
O=O
!ENDIF
!ENDIF
!IFDEF MY_STATIC_LINK
!IFNDEF MY_SINGLE_THREAD
CFLAGS = $(CFLAGS) -MT
!ENDIF
!ELSE
CFLAGS = $(CFLAGS) -MD
!ENDIF
CFLAGS = $(CFLAGS) -nologo -EHsc -c -Fo$O/
CFLAGS_O1 = $(CFLAGS) -O1
CFLAGS_O2 = $(CFLAGS) -O2
LFLAGS = $(LFLAGS) -nologo -OPT:NOWIN98
PROGPATH = $O\$(PROG)
COMPL_O1 = $(CPP) $(CFLAGS_O1) $**
COMPL_O2 = $(CPP) $(CFLAGS_O2) $**
COMPL = $(CPP) $(CFLAGS_O1) $**
LZMA_OBJS = \
$O\LzmaAlone.obj \
$O\LzmaBench.obj \
$O\LzmaBenchCon.obj \
$O\LzmaRam.obj \
LZMA_OPT_OBJS = \
$O\LZMADecoder.obj \
@@ -66,44 +30,33 @@ WIN_OBJS = \
$O\OutBuffer.obj \
$O\StreamUtils.obj \
LZ_OBJS = \
$O\LZOutWindow.obj \
C_OBJS = \
$O\Alloc.obj \
$O\7zCrc.obj \
$O\Alloc.obj \
$O\Bra86.obj \
$O\LzFind.obj \
$O\LzFindMt.obj \
$O\LzmaDec.obj \
$O\LzmaEnc.obj \
$O\Threads.obj \
C_LZ_OBJS = \
$O\MatchFinder.obj \
$O\MatchFinderMt.obj \
C_LZMAUTIL_OBJS = \
$O\Lzma86Dec.obj \
$O\Lzma86Enc.obj \
OBJS = \
$O\StdAfx.obj \
$(LZMA_OBJS) \
$(LZMA_OPT_OBJS) \
$(COMMON_OBJS) \
$(WIN_OBJS) \
$(7ZIP_COMMON_OBJS) \
$(LZ_OBJS) \
$(C_OBJS) \
$(C_LZ_OBJS) \
$O\LzmaRamDecode.obj \
$O\LzmaDecode.obj \
$(C_LZMAUTIL_OBJS) \
$O\FileStreams.obj \
$O\FileIO.obj \
$O\RangeCoderBit.obj \
$O\BranchX86.obj \
all: $(PROGPATH)
clean:
-del /Q $(PROGPATH) $O\*.exe $O\*.dll $O\*.obj $O\*.lib $O\*.exp $O\*.res $O\*.pch
$O:
if not exist "$O" mkdir "$O"
$(PROGPATH): $O $(OBJS)
link $(LFLAGS) -out:$(PROGPATH) $(OBJS) $(LIBS)
!include "../../../Build.mak"
$(LZMA_OBJS): $(*B).cpp
@@ -116,21 +69,11 @@ $(WIN_OBJS): ../../../Windows/$(*B).cpp
$(COMPL)
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
$(COMPL)
$(LZ_OBJS): ../LZ/$(*B).cpp
$(COMPL)
$O\RangeCoderBit.obj: ../RangeCoder/$(*B).cpp
$(COMPL)
$O\LzmaRamDecode.obj: LzmaRamDecode.c
$(COMPL_O1)
$O\LzmaDecode.obj: ../../../../C/Compress/Lzma/LzmaDecode.c
$(COMPL_O2)
$O\BranchX86.obj: ../../../../C/Compress/Branch/BranchX86.c
$(COMPL_O2)
$O\FileStreams.obj: ../../Common/FileStreams.cpp
$(COMPL)
$O\FileIO.obj: ../../../Windows/FileIO.cpp
$(COMPL)
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
$(C_LZ_OBJS): ../../../../C/Compress/Lz/$(*B).c
$(C_LZMAUTIL_OBJS): ../../../../C/LzmaUtil/$(*B).c
$(COMPL_O2)

View File

@@ -22,11 +22,8 @@ OBJS = \
LzmaAlone.o \
LzmaBench.o \
LzmaBenchCon.o \
LzmaRam.o \
LZMADecoder.o \
LZMAEncoder.o \
LZOutWindow.o \
RangeCoderBit.o \
InBuffer.o \
OutBuffer.o \
FileStreams.o \
@@ -41,10 +38,12 @@ OBJS = \
MyVector.o \
7zCrc.o \
Alloc.o \
BranchX86.o \
MatchFinder.o \
LzmaDecode.o \
LzmaRamDecode.o \
Bra86.o \
LzFind.o \
LzmaDec.o \
LzmaEnc.o \
Lzma86Dec.o \
Lzma86Enc.o \
all: $(PROG)
@@ -61,21 +60,12 @@ LzmaBench.o: LzmaBench.cpp
LzmaBenchCon.o: LzmaBenchCon.cpp
$(CXX) $(CFLAGS) LzmaBenchCon.cpp
LzmaRam.o: LzmaRam.cpp
$(CXX) $(CFLAGS) LzmaRam.cpp
LZMADecoder.o: ../LZMA/LZMADecoder.cpp
$(CXX) $(CFLAGS) ../LZMA/LZMADecoder.cpp
LZMAEncoder.o: ../LZMA/LZMAEncoder.cpp
$(CXX) $(CFLAGS) ../LZMA/LZMAEncoder.cpp
LZOutWindow.o: ../LZ/LZOutWindow.cpp
$(CXX) $(CFLAGS) ../LZ/LZOutWindow.cpp
RangeCoderBit.o: ../RangeCoder/RangeCoderBit.cpp
$(CXX) $(CFLAGS) ../RangeCoder/RangeCoderBit.cpp
InBuffer.o: ../../Common/InBuffer.cpp
$(CXX) $(CFLAGS) ../../Common/InBuffer.cpp
@@ -122,17 +112,23 @@ MyVector.o: ../../../Common/MyVector.cpp
Alloc.o: ../../../../C/Alloc.c
$(CXX_C) $(CFLAGS) ../../../../C/Alloc.c
BranchX86.o: ../../../../C/Compress/Branch/BranchX86.c
$(CXX_C) $(CFLAGS) ../../../../C/Compress/Branch/BranchX86.c
Bra86.o: ../../../../C/Bra86.c
$(CXX_C) $(CFLAGS) ../../../../C/Bra86.c
MatchFinder.o: ../../../../C/Compress/Lz/MatchFinder.c
$(CXX_C) $(CFLAGS) ../../../../C/Compress/Lz/MatchFinder.c
LzFind.o: ../../../../C/LzFind.c
$(CXX_C) $(CFLAGS) ../../../../C/LzFind.c
LzmaDecode.o: ../../../../C/Compress/Lzma/LzmaDecode.c
$(CXX_C) $(CFLAGS) ../../../../C/Compress/Lzma/LzmaDecode.c
LzmaDec.o: ../../../../C/LzmaDec.c
$(CXX_C) $(CFLAGS) ../../../../C/LzmaDec.c
LzmaRamDecode.o: LzmaRamDecode.c
$(CXX_C) $(CFLAGS) LzmaRamDecode.c
LzmaEnc.o: ../../../../C/LzmaEnc.c
$(CXX_C) $(CFLAGS) ../../../../C/LzmaEnc.c
Lzma86Dec.o: ../../../../C/LzmaUtil/Lzma86Dec.c
$(CXX_C) $(CFLAGS) ../../../../C/LzmaUtil/Lzma86Dec.c
Lzma86Enc.o: ../../../../C/LzmaUtil/Lzma86Enc.c
$(CXX_C) $(CFLAGS) ../../../../C/LzmaUtil/Lzma86Enc.c
clean:
-$(RM) $(PROG) $(OBJS)