4.45 beta

This commit is contained in:
Igor Pavlov
2007-04-17 00:00:00 +00:00
committed by Kornel Lesiński
parent d9666cf046
commit a145bfc7cf
458 changed files with 13144 additions and 18608 deletions

View File

@@ -1,109 +0,0 @@
// DLLExports.cpp
#include "StdAfx.h"
#include "../../../Common/MyInitGuid.h"
#include "../../../Common/ComTry.h"
#ifdef _WIN32
#include "../../../Common/Alloc.h"
#endif
#include "LZMAEncoder.h"
#include "LZMADecoder.h"
#ifdef CRC_GENERATE_TABLE
extern "C"
{
#include "../../../../C/7zCrc.h"
}
#endif
// {23170F69-40C1-278B-0301-010000000000}
DEFINE_GUID(CLSID_CLZMADecoder,
0x23170F69, 0x40C1, 0x278B, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00);
// {23170F69-40C1-278B-0301-010000000100}
DEFINE_GUID(CLSID_CLZMAEncoder,
0x23170F69, 0x40C1, 0x278B, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00);
extern "C"
BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
// NCompress::NRangeCoder::g_PriceTables.Init();
#ifdef CRC_GENERATE_TABLE
CrcGenerateTable();
#endif
#ifdef _WIN32
SetLargePageSize();
#endif
}
return TRUE;
}
STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
{
// NCompress::NRangeCoder::g_PriceTables.Init();
// CCRC::InitTable();
COM_TRY_BEGIN
*outObject = 0;
int correctInterface = (*iid == IID_ICompressCoder);
CMyComPtr<ICompressCoder> coder;
if (*clsid == CLSID_CLZMADecoder)
{
if (!correctInterface)
return E_NOINTERFACE;
coder = (ICompressCoder *)new NCompress::NLZMA::CDecoder();
}
else if (*clsid == CLSID_CLZMAEncoder)
{
if (!correctInterface)
return E_NOINTERFACE;
coder = (ICompressCoder *)new NCompress::NLZMA::CEncoder();
}
else
return CLASS_E_CLASSNOTAVAILABLE;
*outObject = coder.Detach();
COM_TRY_END
return S_OK;
}
STDAPI GetNumberOfMethods(UINT32 *numMethods)
{
*numMethods = 1;
return S_OK;
}
STDAPI GetMethodProperty(UINT32 index, PROPID propID, PROPVARIANT *value)
{
if (index != 0)
return E_INVALIDARG;
// ::VariantClear((tagVARIANT *)value);
switch(propID)
{
case NMethodPropID::kID:
{
const char id[] = { 0x03, 0x01, 0x01 };
if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
value->vt = VT_BSTR;
return S_OK;
}
case NMethodPropID::kName:
if ((value->bstrVal = ::SysAllocString(L"LZMA")) != 0)
value->vt = VT_BSTR;
return S_OK;
case NMethodPropID::kDecoder:
if ((value->bstrVal = ::SysAllocStringByteLen(
(const char *)&CLSID_CLZMADecoder, sizeof(GUID))) != 0)
value->vt = VT_BSTR;
return S_OK;
case NMethodPropID::kEncoder:
if ((value->bstrVal = ::SysAllocStringByteLen(
(const char *)&CLSID_CLZMAEncoder, sizeof(GUID))) != 0)
value->vt = VT_BSTR;
return S_OK;
}
return S_OK;
}

View File

@@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /YX /FD /c
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /D "COMPRESS_MF_MT" /D "_ST_MODE" /Yu"StdAfx.h" /FD /c
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /D "COMPRESS_MF_MT" /D "_7ZIP_LARGE_PAGES" /Yu"StdAfx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -70,7 +70,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /D "COMPRESS_MF_MT" /D "_ST_MODE" /Yu"StdAfx.h" /FD /GZ /c
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /D "COMPRESS_MF_MT" /D "_7ZIP_LARGE_PAGES" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -97,7 +97,11 @@ SOURCE=..\Codec.def
# End Source File
# Begin Source File
SOURCE=.\DllExports.cpp
SOURCE=..\CodecExports.cpp
# End Source File
# Begin Source File
SOURCE=..\DllExports.cpp
# End Source File
# Begin Source File
@@ -174,88 +178,12 @@ SOURCE=..\..\ICoder.h
# End Source File
# Begin Source File
SOURCE=..\MatchFinders\IMatchFinder.h
# End Source File
# Begin Source File
SOURCE=..\..\IStream.h
# End Source File
# End Group
# Begin Group "LZ"
# PROP Default_Filter ""
# Begin Group "BT"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\LZ\BinTree\BinTree.h
# End Source File
# Begin Source File
SOURCE=..\LZ\BinTree\BinTree2.h
# End Source File
# Begin Source File
SOURCE=..\LZ\BinTree\BinTree3.h
# End Source File
# Begin Source File
SOURCE=..\LZ\BinTree\BinTree4.h
# End Source File
# Begin Source File
SOURCE=..\LZ\BinTree\BinTreeBase.h
# End Source File
# Begin Source File
SOURCE=..\LZ\BinTree\BinTreeD.h
# End Source File
# Begin Source File
SOURCE=..\LZ\BinTree\BinTreeD4.h
# End Source File
# Begin Source File
SOURCE=..\LZ\BinTree\BinTreeDMain.h
# End Source File
# Begin Source File
SOURCE=..\LZ\BinTree\BinTreeMain.h
# End Source File
# Begin Source File
SOURCE=..\LZ\BinTree\BinTreeR.h
# End Source File
# Begin Source File
SOURCE=..\LZ\BinTree\BinTreeR4.h
# End Source File
# Begin Source File
SOURCE=..\LZ\BinTree\BinTreeRMain.h
# End Source File
# End Group
# Begin Group "HC"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\LZ\HashChain\HC4.h
# End Source File
# Begin Source File
SOURCE=..\LZ\HashChain\HCMain.h
# End Source File
# End Group
# Begin Source File
SOURCE=..\LZ\IMatchFinder.h
# End Source File
# Begin Source File
SOURCE=..\LZ\LZInWindow.h
# End Source File
# Begin Source File
SOURCE=..\LZ\LZOutWindow.cpp
@@ -270,34 +198,10 @@ SOURCE=..\LZ\LZOutWindow.h
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\Common\AlignedBuffer.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\AlignedBuffer.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\Alloc.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\Alloc.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\ComTry.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\CRC.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\CRC.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\Defs.h
# End Source File
# Begin Source File
@@ -316,34 +220,6 @@ SOURCE=..\..\..\Common\MyUnknown.h
SOURCE=..\..\..\Common\MyWindows.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\NewHandler.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\NewHandler.h
# End Source File
# End Group
# Begin Group "Windows"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\Windows\Handle.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\Synchronization.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\Synchronization.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\Thread.h
# End Source File
# End Group
# Begin Group "C"
@@ -418,6 +294,15 @@ SOURCE=..\..\..\..\C\7zCrc.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Alloc.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Alloc.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\IStream.h
# End Source File
# Begin Source File
@@ -474,5 +359,9 @@ SOURCE=.\LZMAEncoder.cpp
SOURCE=.\LZMAEncoder.h
# End Source File
# Begin Source File
SOURCE=.\LZMARegister.cpp
# End Source File
# End Target
# End Project

View File

@@ -317,7 +317,7 @@ STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
return S_OK;
}
#ifdef _ST_MODE
#ifndef NO_READ_FROM_CODER
STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
{

View File

@@ -4,11 +4,15 @@
#define __LZMA_DECODER_H
#include "../../../Common/MyCom.h"
#include "../../../Common/Alloc.h"
#include "../../ICoder.h"
#include "../LZ/LZOutWindow.h"
#include "../RangeCoder/RangeCoderBitTree.h"
extern "C"
{
#include "../../../../C/Alloc.h"
}
#include "LZMA.h"
namespace NCompress {
@@ -146,7 +150,7 @@ class CDecoder:
public ICompressCoder,
public ICompressSetDecoderProperties2,
public ICompressGetInStreamProcessedSize,
#ifdef _ST_MODE
#ifndef NO_READ_FROM_CODER
public ICompressSetInStream,
public ICompressSetOutStreamSize,
public ISequentialInStream,
@@ -187,7 +191,7 @@ class CDecoder:
HRESULT CodeSpec(UInt32 size);
public:
#ifdef _ST_MODE
#ifndef NO_READ_FROM_CODER
MY_UNKNOWN_IMP5(
ICompressSetDecoderProperties2,
ICompressGetInStreamProcessedSize,
@@ -238,7 +242,7 @@ public:
STDMETHOD(ReleaseInStream)();
STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
#ifdef _ST_MODE
#ifndef NO_READ_FROM_CODER
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
#endif

View File

@@ -3,6 +3,7 @@
#include "StdAfx.h"
#include <stdio.h>
#include <malloc.h>
#include "../../../Common/Defs.h"
#include "../../Common/StreamUtils.h"
@@ -22,7 +23,8 @@ namespace NLZMA {
const int kDefaultDictionaryLogSize = 22;
const UInt32 kNumFastBytesDefault = 0x20;
Byte g_FastPos[1 << 11];
#ifndef LZMA_LOG_BSR
Byte g_FastPos[1 << kNumLogBits];
class CFastPosInit
{
@@ -30,7 +32,7 @@ public:
CFastPosInit() { Init(); }
void Init()
{
const Byte kFastSlots = 22;
const Byte kFastSlots = kNumLogBits * 2;
int c = 2;
g_FastPos[0] = 0;
g_FastPos[1] = 1;
@@ -43,6 +45,7 @@ public:
}
}
} g_FastPosInit;
#endif
void CLiteralEncoder2::Encode(NRangeCoder::CEncoder *rangeEncoder, Byte symbol)
{
@@ -343,35 +346,37 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
return E_INVALIDARG;
break;
}
#ifdef COMPRESS_MF_MT
case NCoderPropID::kMultiThread:
{
if (prop.vt != VT_BOOL)
return E_INVALIDARG;
#ifdef COMPRESS_MF_MT
Bool newMultiThread = (prop.boolVal == VARIANT_TRUE);
if (newMultiThread != _multiThread)
{
ReleaseMatchFinder();
_multiThread = newMultiThread;
}
#endif
break;
}
case NCoderPropID::kNumThreads:
{
if (prop.vt != VT_UI4)
return E_INVALIDARG;
#ifdef COMPRESS_MF_MT
Bool newMultiThread = (prop.ulVal > 1) ? True : False;
if (newMultiThread != _multiThread)
{
ReleaseMatchFinder();
_multiThread = newMultiThread;
}
#endif
break;
}
#endif
case NCoderPropID::kDictionarySize:
{
const int kDicLogSizeMaxCompress = 30;
const int kDicLogSizeMaxCompress = 30; // must be <= ((kNumLogBits - 1) * 2) + 7 = 31;
if (prop.vt != VT_UI4)
return E_INVALIDARG;
UInt32 dictionarySize = prop.ulVal;
@@ -1260,6 +1265,9 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
ICompressProgressInfo *progress)
{
// _needReleaseMFStream = false;
#ifdef COMPRESS_MF_MT
alloca(0x300);
#endif
CCoderReleaser coderReleaser(this);
RINOK(SetStreams(inStream, outStream, inSize, outSize));
for (;;)

View File

@@ -4,11 +4,11 @@
#define __LZMA_ENCODER_H
#include "../../../Common/MyCom.h"
#include "../../../Common/Alloc.h"
#include "../../ICoder.h"
extern "C"
{
#include "../../../../C/Alloc.h"
#include "../../../../C/Compress/Lz/MatchFinder.h"
#ifdef COMPRESS_MF_MT
#include "../../../../C/Compress/Lz/MatchFinderMt.h"
@@ -59,23 +59,53 @@ struct COptimal
};
extern Byte g_FastPos[1 << 11];
// #define LZMA_LOG_BRANCH
#if _MSC_VER >= 1400
// Must give gain in core 2. but slower ~2% on k8.
// #define LZMA_LOG_BSR
#endif
#ifndef LZMA_LOG_BSR
static const int kNumLogBits = 13; // don't change it !
extern Byte g_FastPos[];
#endif
inline UInt32 GetPosSlot(UInt32 pos)
{
if (pos < (1 << 11))
#ifdef LZMA_LOG_BSR
if (pos < 2)
return pos;
unsigned long index;
_BitScanReverse(&index, pos);
return (index + index) + ((pos >> (index - 1)) & 1);
#else
if (pos < (1 << kNumLogBits))
return g_FastPos[pos];
if (pos < (1 << 21))
return g_FastPos[pos >> 10] + 20;
return g_FastPos[pos >> 20] + 40;
if (pos < (1 << (kNumLogBits * 2 - 1)))
return g_FastPos[pos >> (kNumLogBits - 1)] + (kNumLogBits - 1) * 2;
return g_FastPos[pos >> (kNumLogBits - 1) * 2] + (kNumLogBits - 1) * 4;
#endif
}
inline UInt32 GetPosSlot2(UInt32 pos)
{
if (pos < (1 << 17))
#ifdef LZMA_LOG_BSR
unsigned long index;
_BitScanReverse(&index, pos);
return (index + index) + ((pos >> (index - 1)) & 1);
#else
#ifdef LZMA_LOG_BRANCH
if (pos < (1 << (kNumLogBits + 6)))
return g_FastPos[pos >> 6] + 12;
if (pos < (1 << 27))
return g_FastPos[pos >> 16] + 32;
return g_FastPos[pos >> 26] + 52;
if (pos < (1 << (kNumLogBits * 2 + 5)))
return g_FastPos[pos >> (kNumLogBits + 5)] + (kNumLogBits + 5) * 2;
return g_FastPos[pos >> (kNumLogBits * 2 + 4)] + (kNumLogBits * 2 + 4) * 2;
#else
// it's faster with VC6-32bit.
UInt32 s = 6 + ((kNumLogBits - 1) & (UInt32)((Int32)(((1 << (kNumLogBits + 6)) - 1) - pos) >> 31));
return g_FastPos[pos >> s] + (s * 2);
#endif
#endif
}
const UInt32 kIfinityPrice = 0xFFFFFFF;

View File

@@ -0,0 +1,19 @@
// LZMARegister.cpp
#include "StdAfx.h"
#include "../../Common/RegisterCodec.h"
#include "LZMADecoder.h"
static void *CreateCodec() { return (void *)(ICompressCoder *)(new NCompress::NLZMA::CDecoder); }
#ifndef EXTRACT_ONLY
#include "LZMAEncoder.h"
static void *CreateCodecOut() { return (void *)(ICompressCoder *)(new NCompress::NLZMA::CEncoder); }
#else
#define CreateCodecOut 0
#endif
static CCodecInfo g_CodecInfo =
{ CreateCodec, CreateCodecOut, 0x030101, L"LZMA", 1, false };
REGISTER_CODEC(LZMA)

View File

@@ -1,21 +1,22 @@
PROG = LZMA.dll
DEF_FILE = ../Codec.def
CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MF_MT -D_ST_MODE
CFLAGS = $(CFLAGS) -I ../../../ \
-DCOMPRESS_MF_MT \
-D_7ZIP_LARGE_PAGES \
LIBS = $(LIBS) oleaut32.lib
LZMA_OBJS = \
COMPRESS_OBJS = \
$O\CodecExports.obj \
$O\DllExports.obj \
COMMON_OBJS = \
$O\CRC.obj \
LZMA_OPT_OBJS = \
$O\LZMADecoder.obj \
$O\LZMAEncoder.obj \
COMMON_OBJS = \
$O\Alloc.obj \
$O\CRC.obj \
WIN_OBJS = \
$O\Synchronization.obj
$O\LZMARegister.obj \
7ZIP_COMMON_OBJS = \
$O\InBuffer.obj \
@@ -26,37 +27,36 @@ LZ_OBJS = \
$O\LZOutWindow.obj \
C_OBJS = \
$O\7zCrc.obj \
$O\Sort.obj \
$O\Threads.obj \
$O\Alloc.obj \
C_LZ_OBJS = \
$O\MatchFinder.obj \
$O\MatchFinderMt.obj \
!include "../../Crc2.mak"
OBJS = \
$O\StdAfx.obj \
$(LZMA_OBJS) \
$(LZMA_OPT_OBJS) \
$(COMPRESS_OBJS) \
$(COMMON_OBJS) \
$(WIN_OBJS) \
$(LZMA_OPT_OBJS) \
$(7ZIP_COMMON_OBJS) \
$(LZ_OBJS) \
$(C_OBJS) \
$(C_LZ_OBJS) \
$(CRC_OBJS) \
$O\RangeCoderBit.obj \
$O\resource.res
!include "../../../Build.mak"
$(LZMA_OBJS): $(*B).cpp
$(COMPRESS_OBJS): ../$(*B).cpp
$(COMPL)
$(COMMON_OBJS): ../../../Common/$(*B).cpp
$(COMPL)
$(LZMA_OPT_OBJS): $(*B).cpp
$(COMPL_O2)
$(COMMON_OBJS): ../../../Common/$(*B).cpp
$(COMPL)
$(WIN_OBJS): ../../../Windows/$(*B).cpp
$(COMPL)
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
$(COMPL)
$(LZ_OBJS): ../LZ/$(*B).cpp
@@ -67,3 +67,4 @@ $(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
$(C_LZ_OBJS): ../../../../C/Compress/Lz/$(*B).c
$(COMPL_O2)
!include "../../Crc.mak"