This commit is contained in:
Igor Pavlov
2008-12-31 00:00:00 +00:00
committed by Kornel Lesiński
parent c1f1243a70
commit 3a524e5ba2
259 changed files with 2792 additions and 4855 deletions

View File

@@ -1,64 +0,0 @@
// Arj/Decoder2.h
#ifndef __COMPRESS_ARJ_DECODER2_H
#define __COMPRESS_ARJ_DECODER2_H
#include "../../../Common/MyCom.h"
#include "../../ICoder.h"
#include "../../Common/MSBFDecoder.h"
#include "../../Common/InBuffer.h"
#include "../LZ/LZOutWindow.h"
/*
// {23170F69-40C1-278B-0404-020000000000}
DEFINE_GUID(CLSID_CCompressArj2Decoder,
0x23170F69, 0x40C1, 0x278B, 0x04, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00);
*/
namespace NCompress {
namespace NArj {
namespace NDecoder2 {
class CCoder :
public ICompressCoder,
public CMyUnknownImp
{
CLZOutWindow m_OutWindowStream;
NStream::NMSBF::CDecoder<CInBuffer> m_InBitStream;
void ReleaseStreams()
{
m_OutWindowStream.ReleaseStream();
m_InBitStream.ReleaseStream();
}
class CCoderReleaser
{
CCoder *m_Coder;
public:
bool NeedFlush;
CCoderReleaser(CCoder *coder): m_Coder(coder), NeedFlush(true) {}
~CCoderReleaser()
{
if (NeedFlush)
m_Coder->m_OutWindowStream.Flush();
m_Coder->ReleaseStreams();
}
};
friend class CCoderReleaser;
HRESULT CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
public:
MY_UNKNOWN_IMP
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
};
}}}
#endif

View File

@@ -1,8 +0,0 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/MyWindows.h"
#endif

View File

@@ -1,18 +1,16 @@
// Arj/Decoder.cpp
// ArjDecoder1.cpp
#include "StdAfx.h"
#include "ArjDecoder1.h"
#include "Windows/Defs.h"
namespace NCompress{
namespace NArj {
namespace NDecoder1 {
static const UInt32 kHistorySize = 26624;
static const UInt32 kMatchMaxLen = 256;
static const UInt32 kMatchMinLen = 3;
static const UInt32 kMatchMaxLen = 256;
// static const UInt32 kNC = 255 + kMatchMaxLen + 2 - kMatchMinLen;
@@ -237,9 +235,8 @@ UInt32 CCoder::decode_p()
}
HRESULT CCoder::CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 *outSize,
ICompressProgressInfo *progress)
HRESULT CCoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
{
if (outSize == NULL)
return E_INVALIDARG;
@@ -306,13 +303,12 @@ HRESULT CCoder::CodeReal(ISequentialInStream *inStream,
return m_OutWindowStream.Flush();
}
STDMETHODIMP CCoder::Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress)
STDMETHODIMP CCoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{
try { return CodeReal(inStream, outStream, inSize, outSize, progress);}
catch(const CInBufferException &e) { return e.ErrorCode; }
catch(const CLZOutWindowException &e) { return e.ErrorCode; }
catch(const CLzOutWindowException &e) { return e.ErrorCode; }
catch(...) { return S_FALSE; }
}

View File

@@ -1,19 +1,16 @@
// Arj/Decoder1.h
// ArjDecoder1.h
#ifndef __COMPRESS_ARJ_DECODER1_H
#define __COMPRESS_ARJ_DECODER1_H
#include "../../../Common/MyCom.h"
#include "../../ICoder.h"
#include "../../Common/MSBFDecoder.h"
#include "../../Common/InBuffer.h"
#include "../LZ/LZOutWindow.h"
#include "../../Common/MyCom.h"
/*
// {23170F69-40C1-278B-0404-010000000000}
DEFINE_GUID(CLSID_CCompressArjDecoder,
0x23170F69, 0x40C1, 0x278B, 0x04, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00);
*/
#include "../ICoder.h"
#include "../Common/InBuffer.h"
#include "BitmDecoder.h"
#include "LzOutWindow.h"
namespace NCompress {
namespace NArj {
@@ -47,8 +44,8 @@ class CCoder :
public ICompressCoder,
public CMyUnknownImp
{
CLZOutWindow m_OutWindowStream;
NStream::NMSBF::CDecoder<CInBuffer> m_InBitStream;
CLzOutWindow m_OutWindowStream;
NBitm::CDecoder<CInBuffer> m_InBitStream;
UInt32 left[2 * NC - 1];
UInt32 right[2 * NC - 1];
@@ -86,15 +83,13 @@ class CCoder :
UInt32 decode_c();
UInt32 decode_p();
HRESULT CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
public:
MY_UNKNOWN_IMP
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
};

View File

@@ -1,4 +1,4 @@
// Arj/Decoder2.cpp
// ArjDecoder2.cpp
#include "StdAfx.h"
@@ -9,12 +9,10 @@ namespace NArj {
namespace NDecoder2 {
static const UInt32 kHistorySize = 26624;
// static const UInt32 kMatchMaxLen = 256;
static const UInt32 kMatchMinLen = 3;
HRESULT CCoder::CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 *outSize,
ICompressProgressInfo * /* progress */)
HRESULT CCoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo * /* progress */)
{
if (outSize == NULL)
return E_INVALIDARG;
@@ -80,13 +78,12 @@ HRESULT CCoder::CodeReal(ISequentialInStream *inStream,
return m_OutWindowStream.Flush();
}
STDMETHODIMP CCoder::Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress)
STDMETHODIMP CCoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{
try { return CodeReal(inStream, outStream, inSize, outSize, progress);}
catch(const CInBufferException &e) { return e.ErrorCode; }
catch(const CLZOutWindowException &e) { return e.ErrorCode; }
catch(const CLzOutWindowException &e) { return e.ErrorCode; }
catch(...) { return S_FALSE; }
}

59
CPP/7zip/Compress/ArjDecoder2.h Executable file
View File

@@ -0,0 +1,59 @@
// ArjDecoder2.h
#ifndef __COMPRESS_ARJ_DECODER2_H
#define __COMPRESS_ARJ_DECODER2_H
#include "../../Common/MyCom.h"
#include "../ICoder.h"
#include "../Common/InBuffer.h"
#include "BitmDecoder.h"
#include "LzOutWindow.h"
namespace NCompress {
namespace NArj {
namespace NDecoder2 {
class CCoder :
public ICompressCoder,
public CMyUnknownImp
{
CLzOutWindow m_OutWindowStream;
NBitm::CDecoder<CInBuffer> m_InBitStream;
void ReleaseStreams()
{
m_OutWindowStream.ReleaseStream();
m_InBitStream.ReleaseStream();
}
class CCoderReleaser
{
CCoder *m_Coder;
public:
bool NeedFlush;
CCoderReleaser(CCoder *coder): m_Coder(coder), NeedFlush(true) {}
~CCoderReleaser()
{
if (NeedFlush)
m_Coder->m_OutWindowStream.Flush();
m_Coder->ReleaseStreams();
}
};
friend class CCoderReleaser;
HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
public:
MY_UNKNOWN_IMP
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
};
}}}
#endif

View File

@@ -1,26 +0,0 @@
// BZip2CRC.cpp
#include "StdAfx.h"
#include "BZip2CRC.h"
UInt32 CBZip2CRC::Table[256];
static const UInt32 kBZip2CRCPoly = 0x04c11db7; /* AUTODIN II, Ethernet, & FDDI */
void CBZip2CRC::InitTable()
{
for (UInt32 i = 0; i < 256; i++)
{
UInt32 r = (i << 24);
for (int j = 8; j > 0; j--)
r = (r & 0x80000000) ? ((r << 1) ^ kBZip2CRCPoly) : (r << 1);
Table[i] = r;
}
}
class CBZip2CRCTableInit
{
public:
CBZip2CRCTableInit() { CBZip2CRC::InitTable(); }
} g_BZip2CRCTableInit;

View File

@@ -1,8 +0,0 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/MyWindows.h"
#endif

26
CPP/7zip/Compress/BZip2Crc.cpp Executable file
View File

@@ -0,0 +1,26 @@
// BZip2Crc.cpp
#include "StdAfx.h"
#include "BZip2Crc.h"
UInt32 CBZip2Crc::Table[256];
static const UInt32 kBZip2CrcPoly = 0x04c11db7; /* AUTODIN II, Ethernet, & FDDI */
void CBZip2Crc::InitTable()
{
for (UInt32 i = 0; i < 256; i++)
{
UInt32 r = (i << 24);
for (int j = 8; j > 0; j--)
r = (r & 0x80000000) ? ((r << 1) ^ kBZip2CrcPoly) : (r << 1);
Table[i] = r;
}
}
class CBZip2CrcTableInit
{
public:
CBZip2CrcTableInit() { CBZip2Crc::InitTable(); }
} g_BZip2CrcTableInit;

View File

@@ -1,28 +1,28 @@
// BZip2CRC.h
// BZip2Crc.h
#ifndef __BZIP2_CRC_H
#define __BZIP2_CRC_H
#include "Common/Types.h"
class CBZip2CRC
class CBZip2Crc
{
UInt32 _value;
static UInt32 Table[256];
public:
static void InitTable();
CBZip2CRC(): _value(0xFFFFFFFF) {};
CBZip2Crc(): _value(0xFFFFFFFF) {};
void Init() { _value = 0xFFFFFFFF; }
void UpdateByte(Byte b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); }
void UpdateByte(unsigned int b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); }
UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; }
};
class CBZip2CombinedCRC
class CBZip2CombinedCrc
{
UInt32 _value;
public:
CBZip2CombinedCRC(): _value(0){};
CBZip2CombinedCrc(): _value(0){};
void Init() { _value = 0; }
void Update(UInt32 v) { _value = ((_value << 1) | (_value >> 31)) ^ v; }
UInt32 GetDigest() const { return _value ; }

View File

@@ -2,20 +2,22 @@
#include "StdAfx.h"
#include "BZip2Decoder.h"
extern "C"
{
#include "../../../../C/Alloc.h"
#include "../../../C/Alloc.h"
}
#include "../../../Common/Defs.h"
#include "../BWT/Mtf8.h"
#include "BZip2CRC.h"
#include "../../Common/Defs.h"
#include "BZip2Crc.h"
#include "BZip2Decoder.h"
#include "Mtf8.h"
namespace NCompress {
namespace NBZip2 {
#define NO_INLINE MY_FAST_CALL
const UInt32 kNumThreadsMax = 4;
static const UInt32 kBufferSize = (1 << 17);
@@ -92,7 +94,7 @@ UInt32 CDecoder::ReadBits(int numBits) { return m_InStream.ReadBits(numBits); }
Byte CDecoder::ReadByte() {return (Byte)ReadBits(8); }
bool CDecoder::ReadBit() { return ReadBits(1) != 0; }
UInt32 CDecoder::ReadCRC()
UInt32 CDecoder::ReadCrc()
{
UInt32 crc = 0;
for (int i = 0; i < 4; i++)
@@ -103,17 +105,17 @@ UInt32 CDecoder::ReadCRC()
return crc;
}
UInt32 NO_INLINE ReadBits(NStream::NMSBF::CDecoder<CInBuffer> *m_InStream, int num)
UInt32 NO_INLINE ReadBits(NBitm::CDecoder<CInBuffer> *m_InStream, int num)
{
return m_InStream->ReadBits(num);
}
UInt32 NO_INLINE ReadBit(NStream::NMSBF::CDecoder<CInBuffer> *m_InStream)
UInt32 NO_INLINE ReadBit(NBitm::CDecoder<CInBuffer> *m_InStream)
{
return m_InStream->ReadBits(1);
}
static HRESULT NO_INLINE ReadBlock(NStream::NMSBF::CDecoder<CInBuffer> *m_InStream,
static HRESULT NO_INLINE ReadBlock(NBitm::CDecoder<CInBuffer> *m_InStream,
UInt32 *CharCounters, UInt32 blockSizeMax, Byte *m_Selectors, CHuffmanDecoder *m_HuffmanDecoders,
UInt32 *blockSizeRes, UInt32 *origPtrRes, bool *randRes)
{
@@ -280,7 +282,7 @@ void NO_INLINE DecodeBlock1(UInt32 *charCounters, UInt32 blockSize)
static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32 OrigPtr, COutBuffer &m_OutStream)
{
CBZip2CRC crc;
CBZip2Crc crc;
// it's for speed optimization: prefetch & prevByte_init;
UInt32 tPos = tt[tt[OrigPtr] >> 8];
@@ -371,7 +373,7 @@ static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32
static UInt32 NO_INLINE DecodeBlock2Rand(const UInt32 *tt, UInt32 blockSize, UInt32 OrigPtr, COutBuffer &m_OutStream)
{
CBZip2CRC crc;
CBZip2Crc crc;
UInt32 randIndex = 1;
UInt32 randToGo = kRandNums[0] - 2;
@@ -492,7 +494,7 @@ HRESULT CDecoder::ReadSignatures(bool &wasFinished, UInt32 &crc)
Byte s[6];
for (int i = 0; i < 6; i++)
s[i] = ReadByte();
crc = ReadCRC();
crc = ReadCrc();
if (s[0] == kFinSig0)
{
if (s[1] != kFinSig1 ||
@@ -503,7 +505,7 @@ HRESULT CDecoder::ReadSignatures(bool &wasFinished, UInt32 &crc)
return S_FALSE;
wasFinished = true;
return (crc == CombinedCRC.GetDigest()) ? S_OK : S_FALSE;
return (crc == CombinedCrc.GetDigest()) ? S_OK : S_FALSE;
}
if (s[0] != kBlockSig0 ||
s[1] != kBlockSig1 ||
@@ -512,7 +514,7 @@ HRESULT CDecoder::ReadSignatures(bool &wasFinished, UInt32 &crc)
s[4] != kBlockSig4 ||
s[5] != kBlockSig5)
return S_FALSE;
CombinedCRC.Update(crc);
CombinedCrc.Update(crc);
return S_OK;
}
@@ -552,7 +554,7 @@ HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress)
isBZ = true;
UInt32 dicSize = (UInt32)(s[3] - kArSig3) * kBlockSizeStep;
CombinedCRC.Init();
CombinedCrc.Init();
#ifdef COMPRESS_BZIP2_MT
if (MtMode)
{
@@ -608,9 +610,8 @@ HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress)
return S_OK;
}
HRESULT CDecoder::CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 * /* outSize */,
ICompressProgressInfo *progress)
HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
{
if (!m_InStream.Create(kBufferSize))
return E_OUTOFMEMORY;
@@ -630,9 +631,8 @@ HRESULT CDecoder::CodeReal(ISequentialInStream *inStream,
return isBZ ? S_OK: S_FALSE;
}
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress)
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{
try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
catch(const CInBufferException &e) { return e.ErrorCode; }

View File

@@ -1,23 +1,24 @@
// Compress/BZip2/Decoder.h
// Compress/BZip2Decoder.h
#ifndef __COMPRESS_BZIP2_DECODER_H
#define __COMPRESS_BZIP2_DECODER_H
#include "../../ICoder.h"
#include "../../../Common/MyCom.h"
#include "../../Common/MSBFDecoder.h"
#include "../../Common/InBuffer.h"
#include "../../Common/OutBuffer.h"
#include "../Huffman/HuffmanDecoder.h"
#include "BZip2Const.h"
#include "BZip2CRC.h"
#include "../../Common/MyCom.h"
#ifdef COMPRESS_BZIP2_MT
#include "../../../Windows/Thread.h"
#include "../../../Windows/Synchronization.h"
#include "../../Windows/Synchronization.h"
#include "../../Windows/Thread.h"
#endif
#define NO_INLINE MY_FAST_CALL
#include "../ICoder.h"
#include "../Common/InBuffer.h"
#include "../Common/OutBuffer.h"
#include "BitmDecoder.h"
#include "BZip2Const.h"
#include "BZip2Crc.h"
#include "HuffmanDecoder.h"
namespace NCompress {
namespace NBZip2 {
@@ -67,7 +68,7 @@ class CDecoder :
public:
COutBuffer m_OutStream;
Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
NStream::NMSBF::CDecoder<CInBuffer> m_InStream;
NBitm::CDecoder<CInBuffer> m_InStream;
Byte m_Selectors[kNumSelectorsMax];
CHuffmanDecoder m_HuffmanDecoders[kNumTablesMax];
private:
@@ -77,12 +78,11 @@ private:
UInt32 ReadBits(int numBits);
Byte ReadByte();
bool ReadBit();
UInt32 ReadCRC();
UInt32 ReadCrc();
HRESULT PrepareBlock(CState &state);
HRESULT DecodeFile(bool &isBZ, ICompressProgressInfo *progress);
HRESULT CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
class CDecoderFlusher
{
CDecoder *_decoder;
@@ -98,7 +98,7 @@ private:
};
public:
CBZip2CombinedCRC CombinedCRC;
CBZip2CombinedCrc CombinedCrc;
#ifdef COMPRESS_BZIP2_MT
ICompressProgressInfo *Progress;
@@ -144,9 +144,8 @@ public:
#endif
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);

View File

@@ -4,15 +4,14 @@
extern "C"
{
#include "../../../../C/Alloc.h"
#include "../../../../C/BwtSort.h"
#include "../../../../C/HuffEnc.h"
#include "../../../C/Alloc.h"
#include "../../../C/BwtSort.h"
#include "../../../C/HuffEnc.h"
}
#include "BZip2Crc.h"
#include "BZip2Encoder.h"
#include "../BWT/Mtf8.h"
#include "BZip2CRC.h"
#include "Mtf8.h"
namespace NCompress {
namespace NBZip2 {
@@ -239,7 +238,7 @@ void CThreadInfo::WriteBits2(UInt32 value, UInt32 numBits)
{ m_OutStreamCurrent->WriteBits(value, numBits); }
void CThreadInfo::WriteByte2(Byte b) { WriteBits2(b , 8); }
void CThreadInfo::WriteBit2(bool v) { WriteBits2((v ? 1 : 0), 1); }
void CThreadInfo::WriteCRC2(UInt32 v)
void CThreadInfo::WriteCrc2(UInt32 v)
{
for (int i = 0; i < 4; i++)
WriteByte2(((Byte)(v >> (24 - i * 8))));
@@ -249,7 +248,7 @@ void CEncoder::WriteBits(UInt32 value, UInt32 numBits)
{ m_OutStream.WriteBits(value, numBits); }
void CEncoder::WriteByte(Byte b) { WriteBits(b , 8); }
void CEncoder::WriteBit(bool v) { WriteBits((v ? 1 : 0), 1); }
void CEncoder::WriteCRC(UInt32 v)
void CEncoder::WriteCrc(UInt32 v)
{
for (int i = 0; i < 4; i++)
WriteByte(((Byte)(v >> (24 - i * 8))));
@@ -284,7 +283,7 @@ void CThreadInfo::EncodeBlock(const Byte *block, UInt32 blockSize)
if (inUse[i])
{
inUse16[i >> 4] = true;
mtf.Buffer[numInUse++] = (Byte)i;
mtf.Buf[numInUse++] = (Byte)i;
}
for (i = 0; i < 16; i++)
WriteBit2(inUse16[i]);
@@ -583,7 +582,7 @@ UInt32 CThreadInfo::EncodeBlockWithHeaders(const Byte *block, UInt32 blockSize)
WriteByte2(kBlockSig4);
WriteByte2(kBlockSig5);
CBZip2CRC crc;
CBZip2Crc crc;
int numReps = 0;
Byte prevByte = block[0];
UInt32 i = 0;
@@ -608,7 +607,7 @@ UInt32 CThreadInfo::EncodeBlockWithHeaders(const Byte *block, UInt32 blockSize)
}
while (++i < blockSize);
UInt32 crcRes = crc.GetDigest();
WriteCRC2(crcRes);
WriteCrc2(crcRes);
EncodeBlock(block, blockSize);
return crcRes;
}
@@ -689,7 +688,7 @@ HRESULT CThreadInfo::EncodeBlock3(UInt32 blockSize)
Encoder->ThreadsInfo[m_BlockIndex].CanWriteEvent.Lock();
#endif
for (UInt32 i = 0; i < m_NumCrcs; i++)
Encoder->CombinedCRC.Update(m_CRCs[i]);
Encoder->CombinedCrc.Update(m_CRCs[i]);
Encoder->WriteBytes(m_TempArray, outStreamTemp.GetPos(), outStreamTemp.GetCurByte());
HRESULT res = S_OK;
#ifdef COMPRESS_BZIP2_MT
@@ -720,9 +719,8 @@ void CEncoder::WriteBytes(const Byte *data, UInt32 sizeInBits, Byte lastByte)
}
HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 * /* outSize */,
ICompressProgressInfo *progress)
HRESULT CEncoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
{
#ifdef COMPRESS_BZIP2_MT
Progress = progress;
@@ -764,7 +762,7 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
CFlusher flusher(this);
CombinedCRC.Init();
CombinedCrc.Init();
#ifdef COMPRESS_BZIP2_MT
NextBlockIndex = 0;
StreamWasFinished = false;
@@ -824,13 +822,12 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
WriteByte(kFinSig4);
WriteByte(kFinSig5);
WriteCRC(CombinedCRC.GetDigest());
WriteCrc(CombinedCrc.GetDigest());
return S_OK;
}
STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress)
STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{
try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
catch(const CInBufferException &e) { return e.ErrorCode; }
@@ -838,19 +835,18 @@ STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
catch(...) { return S_FALSE; }
}
HRESULT CEncoder::SetCoderProperties(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties)
HRESULT CEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps)
{
for(UInt32 i = 0; i < numProperties; i++)
for(UInt32 i = 0; i < numProps; i++)
{
const PROPVARIANT &property = properties[i];
const PROPVARIANT &prop = props[i];
switch(propIDs[i])
{
case NCoderPropID::kNumPasses:
{
if (property.vt != VT_UI4)
if (prop.vt != VT_UI4)
return E_INVALIDARG;
UInt32 numPasses = property.ulVal;
UInt32 numPasses = prop.ulVal;
if (numPasses == 0)
numPasses = 1;
if (numPasses > kNumPassesMax)
@@ -861,9 +857,9 @@ HRESULT CEncoder::SetCoderProperties(const PROPID *propIDs,
}
case NCoderPropID::kDictionarySize:
{
if (property.vt != VT_UI4)
if (prop.vt != VT_UI4)
return E_INVALIDARG;
UInt32 dictionary = property.ulVal / kBlockSizeStep;
UInt32 dictionary = prop.ulVal / kBlockSizeStep;
if (dictionary < kBlockSizeMultMin)
dictionary = kBlockSizeMultMin;
else if (dictionary > kBlockSizeMultMax)
@@ -874,9 +870,9 @@ HRESULT CEncoder::SetCoderProperties(const PROPID *propIDs,
case NCoderPropID::kNumThreads:
{
#ifdef COMPRESS_BZIP2_MT
if (property.vt != VT_UI4)
if (prop.vt != VT_UI4)
return E_INVALIDARG;
NumThreads = property.ulVal;
NumThreads = prop.ulVal;
if (NumThreads < 1)
NumThreads = 1;
#endif

View File

@@ -1,21 +1,25 @@
// Compress/BZip2/Encoder.h
// Compress/BZip2Encoder.h
#ifndef __COMPRESS_BZIP2_ENCODER_H
#define __COMPRESS_BZIP2_ENCODER_H
#include "../../ICoder.h"
#include "../../../Common/MyCom.h"
#include "../../Common/MSBFEncoder.h"
#include "../../Common/InBuffer.h"
#include "../../Common/OutBuffer.h"
#include "BZip2Const.h"
#include "BZip2CRC.h"
#include "../../Common/Defs.h"
#include "../../Common/MyCom.h"
#ifdef COMPRESS_BZIP2_MT
#include "../../../Windows/Thread.h"
#include "../../../Windows/Synchronization.h"
#include "../../Windows/Synchronization.h"
#include "../../Windows/Thread.h"
#endif
#include "../ICoder.h"
#include "../Common/InBuffer.h"
#include "../Common/OutBuffer.h"
#include "BitmEncoder.h"
#include "BZip2Const.h"
#include "BZip2Crc.h"
namespace NCompress {
namespace NBZip2 {
@@ -38,13 +42,13 @@ public:
void Flush()
{
if(m_BitPos < 8)
if (m_BitPos < 8)
WriteBits(0, m_BitPos);
}
void WriteBits(UInt32 value, int numBits)
{
while(numBits > 0)
while (numBits > 0)
{
int numNewBits = MyMin(numBits, m_BitPos);
numBits -= numNewBits;
@@ -108,7 +112,7 @@ private:
void WriteBits2(UInt32 value, UInt32 numBits);
void WriteByte2(Byte b);
void WriteBit2(bool v);
void WriteCRC2(UInt32 v);
void WriteCrc2(UInt32 v);
void EncodeBlock(const Byte *block, UInt32 blockSize);
UInt32 EncodeBlockWithHeaders(const Byte *block, UInt32 blockSize);
@@ -158,9 +162,9 @@ class CEncoder :
public:
CInBuffer m_InStream;
Byte MtPad[1 << 8]; // It's pad for Multi-Threading. Must be >= Cache_Line_Size.
NStream::NMSBF::CEncoder<COutBuffer> m_OutStream;
CBitmEncoder<COutBuffer> m_OutStream;
UInt32 NumPasses;
CBZip2CombinedCRC CombinedCRC;
CBZip2CombinedCrc CombinedCrc;
#ifdef COMPRESS_BZIP2_MT
CThreadInfo *ThreadsInfo;
@@ -186,7 +190,7 @@ public:
void WriteBits(UInt32 value, UInt32 numBits);
void WriteByte(Byte b);
void WriteBit(bool v);
void WriteCRC(UInt32 v);
void WriteCrc(UInt32 v);
#ifdef COMPRESS_BZIP2_MT
HRESULT Create();
@@ -227,15 +231,12 @@ public:
MY_UNKNOWN_IMP1(ICompressSetCoderProperties)
#endif
HRESULT CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties);
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
#ifdef COMPRESS_BZIP2_MT
STDMETHOD(SetNumberOfThreads)(UInt32 numThreads);

View File

@@ -1,10 +1,11 @@
// Bzip2Register.cpp
// BZip2Register.cpp
#include "StdAfx.h"
#include "../../Common/RegisterCodec.h"
#include "../Common/RegisterCodec.h"
#include "BZip2Decoder.h"
static void *CreateCodec() { return (void *)(ICompressCoder *)(new NCompress::NBZip2::CDecoder); }
#if !defined(EXTRACT_ONLY) && !defined(BZIP2_EXTRACT_ONLY)
#include "BZip2Encoder.h"

View File

@@ -1,13 +1,14 @@
// x86_2.cpp
// Bcj2Coder.cpp
#include "StdAfx.h"
#include "x86_2.h"
extern "C"
{
#include "../../../../C/Alloc.h"
#include "../../../C/Alloc.h"
}
#include "Bcj2Coder.h"
namespace NCompress {
namespace NBcj2 {

View File

@@ -1,11 +1,13 @@
// x86_2.h
// Bcj2Coder.h
#ifndef __BRANCH_X86_2_H
#define __BRANCH_X86_2_H
#ifndef __COMPRESS_BCJ2_CODER_H
#define __COMPRESS_BCJ2_CODER_H
#include "../../../Common/MyCom.h"
#include "../RangeCoder/RangeCoderBit.h"
#include "../../ICoder.h"
#include "../../Common/MyCom.h"
#include "../ICoder.h"
#include "RangeCoderBit.h"
namespace NCompress {
namespace NBcj2 {

View File

@@ -1,10 +1,11 @@
// BranchRegister.cpp
// Bcj2Register.cpp
#include "StdAfx.h"
#include "../../Common/RegisterCodec.h"
#include "../Common/RegisterCodec.h"
#include "Bcj2Coder.h"
#include "x86_2.h"
static void *CreateCodec() { return (void *)(ICompressCoder2 *)(new NCompress::NBcj2::CDecoder()); }
#ifndef EXTRACT_ONLY
static void *CreateCodecOut() { return (void *)(ICompressCoder2 *)(new NCompress::NBcj2::CEncoder()); }

View File

@@ -1,7 +1,8 @@
// x86.cpp
// BcjCoder.cpp
#include "StdAfx.h"
#include "x86.h"
#include "BcjCoder.h"
UInt32 CBCJ_x86_Encoder::SubFilter(Byte *data, UInt32 size)
{

View File

@@ -1,14 +1,15 @@
// x86.h
// BcjCoder.h
#ifndef __X86_H
#define __X86_H
#ifndef __COMPRESS_BCJ_CODER_H
#define __COMPRESS_BCJ_CODER_H
#include "BranchCoder.h"
extern "C"
{
#include "../../../../C/Bra.h"
#include "../../../C/Bra.h"
}
#include "BranchCoder.h"
struct CBranch86
{
UInt32 _prevMask;

View File

@@ -1,10 +1,11 @@
// BranchRegister.cpp
// BcjRegister.cpp
#include "StdAfx.h"
#include "../../Common/RegisterCodec.h"
#include "../Common/RegisterCodec.h"
#include "BcjCoder.h"
#include "x86.h"
static void *CreateCodec() { return (void *)(ICompressFilter *)(new CBCJ_x86_Decoder()); }
#ifndef EXTRACT_ONLY
static void *CreateCodecOut() { return (void *)(ICompressFilter *)(new CBCJ_x86_Encoder()); }

View File

@@ -0,0 +1,24 @@
// BitlDecoder.cpp
#include "StdAfx.h"
#include "BitlDecoder.h"
namespace NBitl {
Byte kInvertTable[256];
struct CInverterTableInitializer
{
CInverterTableInitializer()
{
for (int i = 0; i < 256; i++)
{
int x = ((i & 0x55) << 1) | ((i & 0xAA) >> 1);
x = ((x & 0x33) << 2) | ((x & 0xCC) >> 2);
kInvertTable[i] = (Byte)(((x & 0x0F) << 4) | ((x & 0xF0) >> 4));
}
}
} g_InverterTableInitializer;
}

125
CPP/7zip/Compress/BitlDecoder.h Executable file
View File

@@ -0,0 +1,125 @@
// BitlDecoder.h -- the Least Significant Bit of byte is First
#ifndef __BITL_DECODER_H
#define __BITL_DECODER_H
#include "../IStream.h"
namespace NBitl {
const int kNumBigValueBits = 8 * 4;
const int kNumValueBytes = 3;
const int kNumValueBits = 8 * kNumValueBytes;
const UInt32 kMask = (1 << kNumValueBits) - 1;
extern Byte kInvertTable[256];
template<class TInByte>
class CBaseDecoder
{
protected:
int m_BitPos;
UInt32 m_Value;
TInByte m_Stream;
public:
UInt32 NumExtraBytes;
bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
void SetStream(ISequentialInStream *inStream) { m_Stream.SetStream(inStream); }
void ReleaseStream() { m_Stream.ReleaseStream(); }
void Init()
{
m_Stream.Init();
m_BitPos = kNumBigValueBits;
m_Value = 0;
NumExtraBytes = 0;
}
UInt64 GetProcessedSize() const
{ return m_Stream.GetProcessedSize() - (kNumBigValueBits - m_BitPos) / 8; }
UInt64 GetProcessedBitsSize() const
{ return (m_Stream.GetProcessedSize() << 3) - (kNumBigValueBits - m_BitPos); }
int GetBitPosition() const { return (m_BitPos & 7); }
void Normalize()
{
for (;m_BitPos >= 8; m_BitPos -= 8)
{
Byte b = 0;
if (!m_Stream.ReadByte(b))
{
b = 0xFF; // check it
NumExtraBytes++;
}
m_Value = (b << (kNumBigValueBits - m_BitPos)) | m_Value;
}
}
UInt32 ReadBits(int numBits)
{
Normalize();
UInt32 res = m_Value & ((1 << numBits) - 1);
m_BitPos += numBits;
m_Value >>= numBits;
return res;
}
bool ExtraBitsWereRead() const
{
if (NumExtraBytes == 0)
return false;
return ((UInt32)(kNumBigValueBits - m_BitPos) < (NumExtraBytes << 3));
}
};
template<class TInByte>
class CDecoder: public CBaseDecoder<TInByte>
{
UInt32 m_NormalValue;
public:
void Init()
{
CBaseDecoder<TInByte>::Init();
m_NormalValue = 0;
}
void Normalize()
{
for (; this->m_BitPos >= 8; this->m_BitPos -= 8)
{
Byte b = 0;
if (!this->m_Stream.ReadByte(b))
{
b = 0xFF; // check it
this->NumExtraBytes++;
}
m_NormalValue = (b << (kNumBigValueBits - this->m_BitPos)) | m_NormalValue;
this->m_Value = (this->m_Value << 8) | kInvertTable[b];
}
}
UInt32 GetValue(int numBits)
{
Normalize();
return ((this->m_Value >> (8 - this->m_BitPos)) & kMask) >> (kNumValueBits - numBits);
}
void MovePos(int numBits)
{
this->m_BitPos += numBits;
m_NormalValue >>= numBits;
}
UInt32 ReadBits(int numBits)
{
Normalize();
UInt32 res = m_NormalValue & ( (1 << numBits) - 1);
MovePos(numBits);
return res;
}
};
}
#endif

60
CPP/7zip/Compress/BitlEncoder.h Executable file
View File

@@ -0,0 +1,60 @@
// BitlEncoder.h -- the Least Significant Bit of byte is First
#ifndef __BITL_ENCODER_H
#define __BITL_ENCODER_H
#include "../Common/OutBuffer.h"
class CBitlEncoder
{
COutBuffer m_Stream;
int m_BitPos;
Byte m_CurByte;
public:
bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
void SetStream(ISequentialOutStream *outStream) { m_Stream.SetStream(outStream); }
void ReleaseStream() { m_Stream.ReleaseStream(); }
void Init()
{
m_Stream.Init();
m_BitPos = 8;
m_CurByte = 0;
}
HRESULT Flush()
{
FlushByte();
return m_Stream.Flush();
}
void FlushByte()
{
if(m_BitPos < 8)
m_Stream.WriteByte(m_CurByte);
m_BitPos = 8;
m_CurByte = 0;
}
void WriteBits(UInt32 value, int numBits)
{
while(numBits > 0)
{
if (numBits < m_BitPos)
{
m_CurByte |= (value & ((1 << numBits) - 1)) << (8 - m_BitPos);
m_BitPos -= numBits;
return;
}
numBits -= m_BitPos;
m_Stream.WriteByte((Byte)(m_CurByte | (value << (8 - m_BitPos))));
value >>= m_BitPos;
m_BitPos = 8;
m_CurByte = 0;
}
}
UInt32 GetBitPosition() const { return (8 - m_BitPos); }
UInt64 GetProcessedSize() const {
return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) /8; }
void WriteByte(Byte b) { m_Stream.WriteByte(b);}
};
#endif

66
CPP/7zip/Compress/BitmDecoder.h Executable file
View File

@@ -0,0 +1,66 @@
// BitmDecoder.h -- the Most Significant Bit of byte is First
#ifndef __BITM_DECODER_H
#define __BITM_DECODER_H
#include "../IStream.h"
namespace NBitm {
const int kNumBigValueBits = 8 * 4;
const int kNumValueBytes = 3;
const int kNumValueBits = 8 * kNumValueBytes;
const UInt32 kMask = (1 << kNumValueBits) - 1;
template<class TInByte>
class CDecoder
{
UInt32 m_BitPos;
UInt32 m_Value;
public:
TInByte m_Stream;
bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
void SetStream(ISequentialInStream *inStream) { m_Stream.SetStream(inStream);}
void ReleaseStream() { m_Stream.ReleaseStream();}
void Init()
{
m_Stream.Init();
m_BitPos = kNumBigValueBits;
Normalize();
}
UInt64 GetProcessedSize() const
{ return m_Stream.GetProcessedSize() - (kNumBigValueBits - m_BitPos) / 8; }
UInt32 GetBitPosition() const { return (m_BitPos & 7); }
void Normalize()
{
for (;m_BitPos >= 8; m_BitPos -= 8)
m_Value = (m_Value << 8) | m_Stream.ReadByte();
}
UInt32 GetValue(UInt32 numBits) const
{
// return (m_Value << m_BitPos) >> (kNumBigValueBits - numBits);
return ((m_Value >> (8 - m_BitPos)) & kMask) >> (kNumValueBits - numBits);
}
void MovePos(UInt32 numBits)
{
m_BitPos += numBits;
Normalize();
}
UInt32 ReadBits(UInt32 numBits)
{
UInt32 res = GetValue(numBits);
MovePos(numBits);
return res;
}
};
}
#endif

52
CPP/7zip/Compress/BitmEncoder.h Executable file
View File

@@ -0,0 +1,52 @@
// BitmEncoder.h -- the Most Significant Bit of byte is First
#ifndef __BITM_ENCODER_H
#define __BITM_ENCODER_H
#include "../IStream.h"
template<class TOutByte>
class CBitmEncoder
{
TOutByte m_Stream;
int m_BitPos;
Byte m_CurByte;
public:
bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
void SetStream(ISequentialOutStream *outStream) { m_Stream.SetStream(outStream);}
void ReleaseStream() { m_Stream.ReleaseStream(); }
void Init()
{
m_Stream.Init();
m_BitPos = 8;
m_CurByte = 0;
}
HRESULT Flush()
{
if(m_BitPos < 8)
WriteBits(0, m_BitPos);
return m_Stream.Flush();
}
void WriteBits(UInt32 value, int numBits)
{
while(numBits > 0)
{
if (numBits < m_BitPos)
{
m_CurByte |= ((Byte)value << (m_BitPos -= numBits));
return;
}
numBits -= m_BitPos;
UInt32 newBits = (value >> numBits);
value -= (newBits << numBits);
m_Stream.WriteByte((Byte)(m_CurByte | newBits));
m_BitPos = 8;
m_CurByte = 0;
}
}
UInt64 GetProcessedSize() const {
return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) / 8; }
};
#endif

View File

@@ -1,8 +0,0 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/MyWindows.h"
#endif

View File

@@ -1,6 +1,7 @@
// BranchCoder.cpp
#include "StdAfx.h"
#include "BranchCoder.h"
STDMETHODIMP CBranchConverter::Init()

View File

@@ -1,12 +1,11 @@
// BranchCoder.h
#ifndef __BRANCH_CODER_H
#define __BRANCH_CODER_H
#ifndef __COMPRESS_BRANCH_CODER_H
#define __COMPRESS_BRANCH_CODER_H
#include "Common/MyCom.h"
#include "Common/Types.h"
#include "../../Common/MyCom.h"
#include "../../ICoder.h"
#include "../ICoder.h"
class CBranchConverter:
public ICompressFilter,

View File

@@ -1,13 +1,14 @@
// BranchMisc.cpp
#include "StdAfx.h"
#include "BranchMisc.h"
extern "C"
{
#include "../../../../C/Bra.h"
#include "../../../C/Bra.h"
}
#include "BranchMisc.h"
UInt32 CBC_ARM_Encoder::SubFilter(Byte *data, UInt32 size)
{ return (UInt32)::ARM_Convert(data, size, _bufferPos, 1); }

View File

@@ -1,7 +1,7 @@
// BranchMisc.h
#ifndef __BRANCHMISC_H
#define __BRANCHMISC_H
#ifndef __COMPRESS_BRANCH_MISC_H
#define __COMPRESS_BRANCH_MISC_H
#include "BranchCoder.h"

View File

@@ -2,7 +2,7 @@
#include "StdAfx.h"
#include "../../Common/RegisterCodec.h"
#include "../Common/RegisterCodec.h"
#include "BranchMisc.h"

30
CPP/7zip/Compress/ByteSwap.h Executable file
View File

@@ -0,0 +1,30 @@
// ByteSwap.h
#ifndef __COMPRESS_BYTE_SWAP_H
#define __COMPRESS_BYTE_SWAP_H
#include "../../Common/MyCom.h"
#include "../ICoder.h"
class CByteSwap2:
public ICompressFilter,
public CMyUnknownImp
{
public:
MY_UNKNOWN_IMP
STDMETHOD(Init)();
STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
};
class CByteSwap4:
public ICompressFilter,
public CMyUnknownImp
{
public:
MY_UNKNOWN_IMP
STDMETHOD(Init)();
STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
};
#endif

View File

@@ -1,37 +0,0 @@
// ByteSwap.h
#ifndef __BYTESWAP_H
#define __BYTESWAP_H
#include "../../ICoder.h"
#include "Common/MyCom.h"
// {23170F69-40C1-278B-0203-020000000000}
DEFINE_GUID(CLSID_CCompressConvertByteSwap2,
0x23170F69, 0x40C1, 0x278B, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00);
// {23170F69-40C1-278B-0203-040000000000}
DEFINE_GUID(CLSID_CCompressConvertByteSwap4,
0x23170F69, 0x40C1, 0x278B, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00);
class CByteSwap2:
public ICompressFilter,
public CMyUnknownImp
{
public:
MY_UNKNOWN_IMP
STDMETHOD(Init)();
STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
};
class CByteSwap4:
public ICompressFilter,
public CMyUnknownImp
{
public:
MY_UNKNOWN_IMP
STDMETHOD(Init)();
STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
};
#endif

View File

@@ -1,8 +0,0 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/MyWindows.h"
#endif

View File

@@ -2,9 +2,10 @@
#include "StdAfx.h"
#include "../../Common/RegisterCodec.h"
#include "../Common/RegisterCodec.h"
#include "ByteSwap.h"
static void *CreateCodec2() { return (void *)(ICompressFilter *)(new CByteSwap2); }
static void *CreateCodec4() { return (void *)(ICompressFilter *)(new CByteSwap4); }

View File

@@ -1,8 +0,0 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/MyWindows.h"
#endif

View File

@@ -4,11 +4,12 @@
extern "C"
{
#include "../../../../C/Alloc.h"
#include "../../../C/Alloc.h"
}
#include "../Common/StreamUtils.h"
#include "CopyCoder.h"
#include "../../Common/StreamUtils.h"
namespace NCompress {
@@ -59,4 +60,3 @@ STDMETHODIMP CCopyCoder::GetInStreamProcessedSize(UInt64 *value)
}
}

View File

@@ -1,10 +1,11 @@
// Compress/CopyCoder.h
#ifndef __COMPRESS_COPYCODER_H
#define __COMPRESS_COPYCODER_H
#ifndef __COMPRESS_COPY_CODER_H
#define __COMPRESS_COPY_CODER_H
#include "../../ICoder.h"
#include "../../../Common/MyCom.h"
#include "../../Common/MyCom.h"
#include "../ICoder.h"
namespace NCompress {
@@ -21,10 +22,8 @@ public:
MY_UNKNOWN_IMP1(ICompressGetInStreamProcessedSize)
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
};

View File

@@ -1,10 +1,11 @@
// LZMARegister.cpp
// CopyRegister.cpp
#include "StdAfx.h"
#include "../../Common/RegisterCodec.h"
#include "../Common/RegisterCodec.h"
#include "CopyCoder.h"
static void *CreateCodec() { return (void *)(ICompressCoder *)(new NCompress::CCopyCoder); }
static CCodecInfo g_CodecInfo =

View File

@@ -1,8 +0,0 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/MyWindows.h"
#endif

View File

@@ -2,9 +2,10 @@
#include "StdAfx.h"
#include "../../Common/RegisterCodec.h"
#include "../Common/RegisterCodec.h"
#include "DeflateDecoder.h"
static void *CreateCodecDeflate64() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NDecoder::CCOMCoder64); }
#if !defined(EXTRACT_ONLY) && !defined(DEFLATE_EXTRACT_ONLY)
#include "DeflateEncoder.h"

View File

@@ -231,10 +231,8 @@ HRESULT CCoder::CodeSpec(UInt32 curSize)
return S_OK;
}
HRESULT CCoder::CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream,
const UInt64 *, const UInt64 *outSize,
ICompressProgressInfo *progress)
HRESULT CCoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *, const UInt64 *outSize, ICompressProgressInfo *progress)
{
SetInStream(inStream);
m_OutWindowStream.SetStream(outStream);
@@ -286,14 +284,13 @@ HRESULT CCoder::CodeReal(ISequentialInStream *inStream,
#define DEFLATE_TRY_BEGIN try {
#define DEFLATE_TRY_END } \
catch(const CInBufferException &e) { return e.ErrorCode; } \
catch(const CLZOutWindowException &e) { return e.ErrorCode; } \
catch(const CLzOutWindowException &e) { return e.ErrorCode; } \
catch(...) { return S_FALSE; }
#endif
HRESULT CCoder::Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress)
HRESULT CCoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{
DEFLATE_TRY_BEGIN
return CodeReal(inStream, outStream, inSize, outSize, progress);

View File

@@ -3,15 +3,16 @@
#ifndef __DEFLATE_DECODER_H
#define __DEFLATE_DECODER_H
#include "../../../Common/MyCom.h"
#include "../../Common/MyCom.h"
#include "../../ICoder.h"
#include "../../Common/LSBFDecoder.h"
#include "../../Common/InBuffer.h"
#include "../LZ/LZOutWindow.h"
#include "../Huffman/HuffmanDecoder.h"
#include "../ICoder.h"
#include "../Common/InBuffer.h"
#include "BitlDecoder.h"
#include "DeflateConst.h"
#include "HuffmanDecoder.h"
#include "LzOutWindow.h"
namespace NCompress {
namespace NDeflate {
@@ -27,8 +28,8 @@ class CCoder:
#endif
public CMyUnknownImp
{
CLZOutWindow m_OutWindowStream;
NStream::NLSBF::CDecoder<CInBuffer> m_InBitStream;
CLzOutWindow m_OutWindowStream;
NBitl::CDecoder<CInBuffer> m_InBitStream;
NCompress::NHuffman::CDecoder<kNumHuffmanBits, kFixedMainTableSize> m_MainDecoder;
NCompress::NHuffman::CDecoder<kNumHuffmanBits, kFixedDistTableSize> m_DistDecoder;
NCompress::NHuffman::CDecoder<kNumHuffmanBits, kLevelTableSize> m_LevelDecoder;
@@ -82,9 +83,8 @@ public:
CCoder(bool deflate64Mode, bool deflateNSIS = false);
void SetKeepHistory(bool keepHistory) { _keepHistory = keepHistory; }
HRESULT CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
#ifndef NO_READ_FROM_CODER
MY_UNKNOWN_IMP4(
@@ -98,9 +98,8 @@ public:
ICompressGetInStreamProcessedSize)
#endif
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(SetInStream)(ISequentialInStream *inStream);
STDMETHOD(ReleaseInStream)();

View File

@@ -2,18 +2,16 @@
#include "StdAfx.h"
#include <stdio.h>
#include "DeflateEncoder.h"
#include "Windows/Defs.h"
#include "Common/ComTry.h"
extern "C"
{
#include "../../../../C/Alloc.h"
#include "../../../../C/HuffEnc.h"
#include "../../../C/Alloc.h"
#include "../../../C/HuffEnc.h"
}
#include "Common/ComTry.h"
#include "DeflateEncoder.h"
#if _MSC_VER >= 1300
#define NO_INLINE __declspec(noinline)
#else
@@ -163,13 +161,11 @@ HRESULT CCoder::Create()
COM_TRY_END
}
// ICompressSetEncoderProperties2
HRESULT CCoder::BaseSetEncoderProperties2(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties)
HRESULT CCoder::BaseSetEncoderProperties2(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps)
{
for(UInt32 i = 0; i < numProperties; i++)
for (UInt32 i = 0; i < numProps; i++)
{
const PROPVARIANT &prop = properties[i];
const PROPVARIANT &prop = props[i];
switch(propIDs[i])
{
case NCoderPropID::kNumPasses:
@@ -220,14 +216,10 @@ HRESULT CCoder::BaseSetEncoderProperties2(const PROPID *propIDs,
void CCoder::Free()
{
::MidFree(m_OnePosMatchesMemory);
m_OnePosMatchesMemory = 0;
::MyFree(m_DistanceMemory);
m_DistanceMemory = 0;
::MyFree(m_Values);
m_Values = 0;
::MyFree(m_Tables);
m_Tables = 0;
::MidFree(m_OnePosMatchesMemory); m_OnePosMatchesMemory = 0;
::MyFree(m_DistanceMemory); m_DistanceMemory = 0;
::MyFree(m_Values); m_Values = 0;
::MyFree(m_Tables); m_Tables = 0;
}
CCoder::~CCoder()
@@ -922,9 +914,8 @@ SRes Read(void *object, void *data, size_t *size)
return (SRes)res;
}
HRESULT CCoder::CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 * /* inSize */ , const UInt64 * /* outSize */ ,
ICompressProgressInfo *progress)
HRESULT CCoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 * /* inSize */ , const UInt64 * /* outSize */ , ICompressProgressInfo *progress)
{
m_CheckStatic = (m_NumPasses != 1 || m_NumDivPasses != 1);
m_IsMultiPass = (m_CheckStatic || (m_NumPasses != 1 || m_NumDivPasses != 1));
@@ -971,32 +962,26 @@ HRESULT CCoder::CodeReal(ISequentialInStream *inStream,
return m_OutStream.Flush();
}
HRESULT CCoder::BaseCode(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress)
HRESULT CCoder::BaseCode(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{
try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
catch(const COutBufferException &e) { return e.ErrorCode; }
catch(...) { return E_FAIL; }
}
STDMETHODIMP CCOMCoder::Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress)
STDMETHODIMP CCOMCoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{ return BaseCode(inStream, outStream, inSize, outSize, progress); }
STDMETHODIMP CCOMCoder::SetCoderProperties(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties)
{ return BaseSetEncoderProperties2(propIDs, properties, numProperties); }
STDMETHODIMP CCOMCoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps)
{ return BaseSetEncoderProperties2(propIDs, props, numProps); }
STDMETHODIMP CCOMCoder64::Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress)
STDMETHODIMP CCOMCoder64::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{ return BaseCode(inStream, outStream, inSize, outSize, progress); }
STDMETHODIMP CCOMCoder64::SetCoderProperties(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties)
{ return BaseSetEncoderProperties2(propIDs, properties, numProperties); }
STDMETHODIMP CCOMCoder64::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps)
{ return BaseSetEncoderProperties2(propIDs, props, numProps); }
}}}

View File

@@ -3,18 +3,18 @@
#ifndef __DEFLATE_ENCODER_H
#define __DEFLATE_ENCODER_H
#include "Common/MyCom.h"
#include "../../ICoder.h"
#include "../../Common/LSBFEncoder.h"
#include "DeflateConst.h"
extern "C"
{
#include "../../../../C/LzFind.h"
#include "../../../C/LzFind.h"
}
#include "Common/MyCom.h"
#include "../ICoder.h"
#include "BitlEncoder.h"
#include "DeflateConst.h"
namespace NCompress {
namespace NDeflate {
namespace NEncoder {
@@ -58,7 +58,7 @@ typedef struct _CSeqInStream
class CCoder
{
CMatchFinder _lzInWindow;
NStream::NLSBF::CEncoder m_OutStream;
CBitlEncoder m_OutStream;
CSeqInStream _seqInStream;
@@ -171,20 +171,15 @@ public:
CCoder(bool deflate64Mode = false);
~CCoder();
HRESULT CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
HRESULT BaseCode(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
HRESULT BaseCode(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
// ICompressSetCoderProperties
HRESULT BaseSetEncoderProperties2(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties);
HRESULT BaseSetEncoderProperties2(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
};
///////////////////////////////////////////////////////////////
class CCOMCoder :
public ICompressCoder,
@@ -195,12 +190,9 @@ class CCOMCoder :
public:
MY_UNKNOWN_IMP1(ICompressSetCoderProperties)
CCOMCoder(): CCoder(false) {};
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
// ICompressSetCoderProperties
STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties);
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
};
class CCOMCoder64 :
@@ -212,15 +204,11 @@ class CCOMCoder64 :
public:
MY_UNKNOWN_IMP1(ICompressSetCoderProperties)
CCOMCoder64(): CCoder(true) {};
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
// ICompressSetCoderProperties
STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties);
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
};
}}}
#endif

View File

@@ -2,9 +2,10 @@
#include "StdAfx.h"
#include "../../Common/RegisterCodec.h"
#include "../Common/RegisterCodec.h"
#include "DeflateDecoder.h"
static void *CreateCodecDeflateNsis() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NDecoder::CNsisCOMCoder); }
static CCodecInfo g_CodecInfo =

View File

@@ -2,10 +2,12 @@
#include "StdAfx.h"
#include "../../Common/RegisterCodec.h"
#include "../Common/RegisterCodec.h"
#include "DeflateDecoder.h"
static void *CreateCodecDeflate() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NDecoder::CCOMCoder); }
#if !defined(EXTRACT_ONLY) && !defined(DEFLATE_EXTRACT_ONLY)
#include "DeflateEncoder.h"
static void *CreateCodecOutDeflate() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NEncoder::CCOMCoder); }

View File

@@ -1,9 +1,9 @@
// Compress/HuffmanDecoder.h
#ifndef __COMPRESS_HUFFMANDECODER_H
#define __COMPRESS_HUFFMANDECODER_H
#ifndef __COMPRESS_HUFFMAN_DECODER_H
#define __COMPRESS_HUFFMAN_DECODER_H
#include "../../../Common/Types.h"
#include "../../Common/Types.h"
namespace NCompress {
namespace NHuffman {

View File

@@ -1,8 +0,0 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/MyWindows.h"
#endif

View File

@@ -121,9 +121,8 @@ public:
~CCoderReleaser() { m_Coder->ReleaseStreams(); }
};
STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 *outSize,
ICompressProgressInfo *progress)
HRESULT CCoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
{
if (!m_InBitStream.Create(1 << 20))
return E_OUTOFMEMORY;
@@ -193,12 +192,11 @@ STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream,
return m_OutWindowStream.Flush();
}
STDMETHODIMP CCoder::Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress)
STDMETHODIMP CCoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{
try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
catch(const CLZOutWindowException &e) { return e.ErrorCode; }
catch(const CLzOutWindowException &e) { return e.ErrorCode; }
catch(...) { return S_FALSE; }
}

View File

@@ -1,26 +1,26 @@
// ImplodeDecoder.h
#ifndef __IMPLODE_DECODER_H
#define __IMPLODE_DECODER_H
#ifndef __COMPRESS_IMPLODE_DECODER_H
#define __COMPRESS_IMPLODE_DECODER_H
#include "../../../Common/MyCom.h"
#include "../../Common/MyCom.h"
#include "../../ICoder.h"
#include "../LZ/LZOutWindow.h"
#include "../ICoder.h"
#include "ImplodeHuffmanDecoder.h"
#include "LzOutWindow.h"
namespace NCompress {
namespace NImplode {
namespace NDecoder {
class CCoder :
class CCoder:
public ICompressCoder,
public ICompressSetDecoderProperties2,
public CMyUnknownImp
{
CLZOutWindow m_OutWindowStream;
NStream::NLSBF::CDecoder<CInBuffer> m_InBitStream;
CLzOutWindow m_OutWindowStream;
NBitl::CDecoder<CInBuffer> m_InBitStream;
NImplode::NHuffman::CDecoder m_LiteralDecoder;
NImplode::NHuffman::CDecoder m_LengthDecoder;
@@ -41,17 +41,14 @@ public:
MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
void ReleaseStreams();
HRESULT (Flush)() { return m_OutWindowStream.Flush(); }
HRESULT Flush() { return m_OutWindowStream.Flush(); }
STDMETHOD(CodeReal)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
// ICompressSetDecoderProperties
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
};

View File

@@ -3,8 +3,9 @@
#ifndef __IMPLODE_HUFFMAN_DECODER_H
#define __IMPLODE_HUFFMAN_DECODER_H
#include "../../Common/LSBFDecoder.h"
#include "../../Common/InBuffer.h"
#include "../Common/InBuffer.h"
#include "BitlDecoder.h"
namespace NCompress {
namespace NImplode {
@@ -12,7 +13,7 @@ namespace NHuffman {
const int kNumBitsInLongestCode = 16;
typedef NStream::NLSBF::CDecoder<CInBuffer> CInBit;
typedef NBitl::CDecoder<CInBuffer> CInBit;
class CDecoder
{

View File

@@ -1,8 +0,0 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/MyWindows.h"
#endif

View File

@@ -1,403 +0,0 @@
# Microsoft Developer Studio Project File - Name="LZMA" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=LZMA - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "LZMA.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "LZMA.mak" CFG="LZMA - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "LZMA - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "LZMA - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "LZMA - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# 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 "_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"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-zip\Codecs\LZMA.dll" /opt:NOWIN98
# SUBTRACT LINK32 /pdb:none /debug
!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# 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 "_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"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-zip\Codecs\LZMA.dll" /pdbtype:sept
!ENDIF
# Begin Target
# Name "LZMA - Win32 Release"
# Name "LZMA - Win32 Debug"
# Begin Group "Spec"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\Codec.def
# End Source File
# Begin Source File
SOURCE=..\CodecExports.cpp
# End Source File
# Begin Source File
SOURCE=..\DllExports.cpp
# End Source File
# Begin Source File
SOURCE=.\resource.rc
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"StdAfx.h"
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# End Group
# Begin Group "7-zip Common"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\Common\InBuffer.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Common\InBuffer.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\OutBuffer.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Common\OutBuffer.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\StreamUtils.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Common\StreamUtils.h
# End Source File
# End Group
# Begin Group "RangeCoder"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\RangeCoder\RangeCoder.h
# End Source File
# Begin Source File
SOURCE=..\RangeCoder\RangeCoderBit.cpp
# End Source File
# Begin Source File
SOURCE=..\RangeCoder\RangeCoderBit.h
# End Source File
# Begin Source File
SOURCE=..\RangeCoder\RangeCoderBitTree.h
# End Source File
# Begin Source File
SOURCE=..\RangeCoder\RangeCoderOpt.h
# End Source File
# End Group
# Begin Group "Interface"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\ICoder.h
# End Source File
# Begin Source File
SOURCE=..\..\IStream.h
# End Source File
# End Group
# Begin Group "LZ"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\LZ\LZOutWindow.cpp
# End Source File
# Begin Source File
SOURCE=..\LZ\LZOutWindow.h
# End Source File
# End Group
# Begin Group "Common"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\Common\ComTry.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\Defs.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\Exception.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\MyCom.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\MyUnknown.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\MyWindows.h
# End Source File
# End Group
# Begin Group "C"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\..\C\7zCrc.c
!IF "$(CFG)" == "LZMA - Win32 Release"
# ADD CPP /O2
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
# SUBTRACT CPP /YX /Yc /Yu
!ENDIF
# End Source File
# Begin Source File
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
SOURCE=..\..\..\..\C\LzFind.c
!IF "$(CFG)" == "LZMA - Win32 Release"
# ADD CPP /O2
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
# SUBTRACT CPP /YX /Yc /Yu
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\LzFind.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\LzFindMt.c
!IF "$(CFG)" == "LZMA - Win32 Release"
# ADD CPP /O2
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
# SUBTRACT CPP /YX /Yc /Yu
!ENDIF
# 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
!IF "$(CFG)" == "LZMA - Win32 Release"
# ADD CPP /O2
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
# SUBTRACT CPP /YX /Yc /Yu
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\LzmaDec.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\LzmaEnc.c
!IF "$(CFG)" == "LZMA - Win32 Release"
# ADD CPP /O2
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
# SUBTRACT CPP /YX /Yc /Yu
!ENDIF
# 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
# Begin Source File
SOURCE=.\LZMA.h
# End Source File
# Begin Source File
SOURCE=.\LZMADecoder.cpp
!IF "$(CFG)" == "LZMA - Win32 Release"
# ADD CPP /O2
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\LZMADecoder.h
# End Source File
# Begin Source File
SOURCE=.\LZMAEncoder.cpp
!IF "$(CFG)" == "LZMA - Win32 Release"
# ADD CPP /O2 /FAs
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\LZMAEncoder.h
# End Source File
# Begin Source File
SOURCE=.\LZMARegister.cpp
# End Source File
# End Target
# End Project

View File

@@ -1,29 +0,0 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "LZMA"=".\LZMA.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -1,3 +0,0 @@
// StdAfx.cpp
#include "StdAfx.h"

View File

@@ -1,8 +0,0 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/MyWindows.h"
#endif

View File

@@ -1,61 +0,0 @@
PROG = LZMA.dll
DEF_FILE = ../Codec.def
CFLAGS = $(CFLAGS) -I ../../../ \
-DCOMPRESS_MF_MT \
-D_7ZIP_LARGE_PAGES \
LIBS = $(LIBS) oleaut32.lib
COMPRESS_OBJS = \
$O\CodecExports.obj \
$O\DllExports.obj \
COMMON_OBJS = \
$O\CRC.obj \
LZMA_OPT_OBJS = \
$O\LZMADecoder.obj \
$O\LZMAEncoder.obj \
$O\LZMARegister.obj \
7ZIP_COMMON_OBJS = \
$O\InBuffer.obj \
$O\OutBuffer.obj \
$O\StreamUtils.obj \
C_OBJS = \
$O\Alloc.obj \
$O\LzFind.obj \
$O\LzFindMt.obj \
$O\LzmaDec.obj \
$O\LzmaEnc.obj \
$O\Threads.obj \
!include "../../Crc2.mak"
OBJS = \
$O\StdAfx.obj \
$(COMPRESS_OBJS) \
$(COMMON_OBJS) \
$(LZMA_OPT_OBJS) \
$(7ZIP_COMMON_OBJS) \
$(C_OBJS) \
$(CRC_OBJS) \
$O\RangeCoderBit.obj \
$O\resource.res
!include "../../../Build.mak"
$(COMPRESS_OBJS): ../$(*B).cpp
$(COMPL)
$(COMMON_OBJS): ../../../Common/$(*B).cpp
$(COMPL)
$(LZMA_OPT_OBJS): $(*B).cpp
$(COMPL_O2)
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
$(COMPL)
$O\RangeCoderBit.obj: ../RangeCoder/$(*B).cpp
$(COMPL)
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
!include "../../Crc.mak"

View File

@@ -1,3 +0,0 @@
#include "../../MyVersionInfo.rc"
MY_VERSION_INFO_DLL("LZMA Codec", "LZMA")

View File

@@ -160,23 +160,19 @@ SOURCE=.\StdAfx.h
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\LZMA\LZMA.h
SOURCE=..\LzmaDecoder.cpp
# End Source File
# Begin Source File
SOURCE=..\LZMA\LZMADecoder.cpp
SOURCE=..\LzmaDecoder.h
# End Source File
# Begin Source File
SOURCE=..\LZMA\LZMADecoder.h
SOURCE=..\LzmaEncoder.cpp
# End Source File
# Begin Source File
SOURCE=..\LZMA\LZMAEncoder.cpp
# End Source File
# Begin Source File
SOURCE=..\LZMA\LZMAEncoder.h
SOURCE=..\LzmaEncoder.h
# End Source File
# End Group
# End Group

View File

@@ -22,8 +22,8 @@
#include "../../Common/FileStreams.h"
#include "../../Common/StreamUtils.h"
#include "../LZMA/LZMADecoder.h"
#include "../LZMA/LZMAEncoder.h"
#include "../LzmaDecoder.h"
#include "../LzmaEncoder.h"
#include "LzmaBenchCon.h"
@@ -380,7 +380,7 @@ int main2(int n, const char *args[])
UInt64 fileSize;
if (encodeMode)
{
NCompress::NLZMA::CEncoder *encoderSpec = new NCompress::NLZMA::CEncoder;
NCompress::NLzma::CEncoder *encoderSpec = new NCompress::NLzma::CEncoder;
CMyComPtr<ICompressCoder> encoder = encoderSpec;
if (!dictDefined)
@@ -482,7 +482,7 @@ int main2(int n, const char *args[])
}
else
{
NCompress::NLZMA::CDecoder *decoderSpec = new NCompress::NLZMA::CDecoder;
NCompress::NLzma::CDecoder *decoderSpec = new NCompress::NLzma::CDecoder;
CMyComPtr<ICompressCoder> decoder = decoderSpec;
decoderSpec->FinishStream = true;
const UInt32 kPropertiesSize = 5;

View File

@@ -30,22 +30,23 @@
extern "C"
{
#include "../../../../C/Alloc.h"
#include "../../../../C/7zCrc.h"
#include "../../../../C/Alloc.h"
}
#include "../../../Common/MyCom.h"
#include "../../ICoder.h"
#ifdef BENCH_MT
#include "../../../Windows/Thread.h"
#include "../../../Windows/Synchronization.h"
#include "../../../Windows/Thread.h"
#endif
#ifdef EXTERNAL_LZMA
#include "../../../Windows/PropVariant.h"
#include "../../ICoder.h"
#else
#include "../LZMA/LZMADecoder.h"
#include "../LZMA/LZMAEncoder.h"
#include "../LzmaDecoder.h"
#include "../LzmaEncoder.h"
#endif
static const UInt32 kUncompressMinBlockSize = 1 << 26;
@@ -697,14 +698,14 @@ HRESULT LzmaBench(
#ifdef EXTERNAL_LZMA
RINOK(codecs->CreateCoder(name, true, encoder.encoder));
#else
encoder.encoder = new NCompress::NLZMA::CEncoder;
encoder.encoder = new NCompress::NLzma::CEncoder;
#endif
for (UInt32 j = 0; j < numSubDecoderThreads; j++)
{
#ifdef EXTERNAL_LZMA
RINOK(codecs->CreateCoder(name, false, encoder.decoders[j]));
#else
encoder.decoders[j] = new NCompress::NLZMA::CDecoder;
encoder.decoders[j] = new NCompress::NLzma::CDecoder;
#endif
}
}

View File

@@ -10,8 +10,8 @@ LZMA_OBJS = \
$O\LzmaBenchCon.obj \
LZMA_OPT_OBJS = \
$O\LZMADecoder.obj \
$O\LZMAEncoder.obj \
$O\LzmaDecoder.obj \
$O\LzmaEncoder.obj \
COMMON_OBJS = \
$O\CommandLineParser.obj \
@@ -61,7 +61,7 @@ OBJS = \
$(LZMA_OBJS): $(*B).cpp
$(COMPL)
$(LZMA_OPT_OBJS): ../LZMA/$(*B).cpp
$(LZMA_OPT_OBJS): ../$(*B).cpp
$(COMPL_O2)
$(COMMON_OBJS): ../../../Common/$(*B).cpp
$(COMPL)

View File

@@ -22,8 +22,8 @@ OBJS = \
LzmaAlone.o \
LzmaBench.o \
LzmaBenchCon.o \
LZMADecoder.o \
LZMAEncoder.o \
LzmaDecoder.o \
LzmaEncoder.o \
InBuffer.o \
OutBuffer.o \
FileStreams.o \
@@ -60,11 +60,11 @@ LzmaBench.o: LzmaBench.cpp
LzmaBenchCon.o: LzmaBenchCon.cpp
$(CXX) $(CFLAGS) LzmaBenchCon.cpp
LZMADecoder.o: ../LZMA/LZMADecoder.cpp
$(CXX) $(CFLAGS) ../LZMA/LZMADecoder.cpp
LzmaDecoder.o: ../LzmaDecoder.cpp
$(CXX) $(CFLAGS) ../LzmaDecoder.cpp
LZMAEncoder.o: ../LZMA/LZMAEncoder.cpp
$(CXX) $(CFLAGS) ../LZMA/LZMAEncoder.cpp
LzmaEncoder.o: ../LzmaEncoder.cpp
$(CXX) $(CFLAGS) ../LzmaEncoder.cpp
InBuffer.o: ../../Common/InBuffer.cpp
$(CXX) $(CFLAGS) ../../Common/InBuffer.cpp

View File

@@ -1,16 +1,14 @@
// LZOutWindow.cpp
// LzOutWindow.cpp
#include "StdAfx.h"
#include "LZOutWindow.h"
#include "LzOutWindow.h"
void CLZOutWindow::Init(bool solid)
void CLzOutWindow::Init(bool solid)
{
if(!solid)
if (!solid)
COutBuffer::Init();
#ifdef _NO_EXCEPTIONS
ErrorCode = S_OK;
#endif
}

View File

@@ -1,16 +1,17 @@
// LZOutWindow.h
// LzOutWindow.h
#ifndef __LZ_OUT_WINDOW_H
#define __LZ_OUT_WINDOW_H
#include "../../IStream.h"
#include "../../Common/OutBuffer.h"
#include "../IStream.h"
#include "../Common/OutBuffer.h"
#ifndef _NO_EXCEPTIONS
typedef COutBufferException CLZOutWindowException;
typedef COutBufferException CLzOutWindowException;
#endif
class CLZOutWindow: public COutBuffer
class CLzOutWindow: public COutBuffer
{
public:
void Init(bool solid = false);

View File

@@ -213,7 +213,7 @@ STDMETHODIMP CCoder::Code(ISequentialInStream *inStream,
{
try { return CodeReal(inStream, outStream, inSize, outSize, progress);}
catch(const CInBufferException &e) { return e.ErrorCode; }
catch(const CLZOutWindowException &e) { return e.ErrorCode; }
catch(const CLzOutWindowException &e) { return e.ErrorCode; }
catch(...) { return S_FALSE; }
}

View File

@@ -3,12 +3,15 @@
#ifndef __COMPRESS_LZH_DECODER_H
#define __COMPRESS_LZH_DECODER_H
#include "../../../Common/MyCom.h"
#include "../../ICoder.h"
#include "../../Common/MSBFDecoder.h"
#include "../../Common/InBuffer.h"
#include "../Huffman/HuffmanDecoder.h"
#include "../LZ/LZOutWindow.h"
#include "../../Common/MyCom.h"
#include "../ICoder.h"
#include "../Common/InBuffer.h"
#include "BitmDecoder.h"
#include "HuffmanDecoder.h"
#include "LzOutWindow.h"
namespace NCompress {
namespace NLzh {
@@ -44,8 +47,8 @@ class CCoder :
public ICompressCoder,
public CMyUnknownImp
{
CLZOutWindow m_OutWindowStream;
NStream::NMSBF::CDecoder<CInBuffer> m_InBitStream;
CLzOutWindow m_OutWindowStream;
NBitm::CDecoder<CInBuffer> m_InBitStream;
int m_NumDictBits;

View File

@@ -1,16 +1,16 @@
// LZMADecoder.cpp
// LzmaDecoder.cpp
#include "StdAfx.h"
#include "LZMADecoder.h"
#include "../../../Common/Defs.h"
#include "../../Common/StreamUtils.h"
extern "C"
{
#include "../../../../C/Alloc.h"
#include "../../../C/Alloc.h"
}
#include "../Common/StreamUtils.h"
#include "LzmaDecoder.h"
static HRESULT SResToHRESULT(SRes res)
{
switch(res)
@@ -26,7 +26,7 @@ static HRESULT SResToHRESULT(SRes res)
}
namespace NCompress {
namespace NLZMA {
namespace NLzma {
static const UInt32 kInBufSize = 1 << 20;
@@ -76,9 +76,8 @@ STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
return S_OK;
}
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 * /* inSize */,
const UInt64 *outSize, ICompressProgressInfo *progress)
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
{
if (_inBuf == 0)
return S_FALSE;

View File

@@ -1,18 +1,18 @@
// LZMADecoder.h
// LzmaDecoder.h
#ifndef __LZMA_DECODER_H
#define __LZMA_DECODER_H
#include "../../../Common/MyCom.h"
#include "../../ICoder.h"
extern "C"
{
#include "../../../../C/LzmaDec.h"
#include "../../../C/LzmaDec.h"
}
#include "../../Common/MyCom.h"
#include "../ICoder.h"
namespace NCompress {
namespace NLZMA {
namespace NLzma {
class CDecoder:
public ICompressCoder,
@@ -49,14 +49,10 @@ public:
ICompressGetInStreamProcessedSize)
#endif
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *_inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
STDMETHOD(SetInStream)(ISequentialInStream *inStream);
STDMETHOD(ReleaseInStream)();
STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);

View File

@@ -1,30 +1,16 @@
// LZMA/Encoder.cpp
// LzmaEncoder.cpp
#include "StdAfx.h"
#include <stdio.h>
#ifdef _WIN32
#define USE_ALLOCA
#endif
#ifdef USE_ALLOCA
#ifdef _WIN32
#include <malloc.h>
#else
#include <stdlib.h>
#endif
#endif
#include "LZMAEncoder.h"
#include "../../Common/StreamUtils.h"
extern "C"
{
#include "../../../../C/Alloc.h"
#include "../../../C/Alloc.h"
}
#include "../Common/StreamUtils.h"
#include "LzmaEncoder.h"
static HRESULT SResToHRESULT(SRes res)
{
switch(res)
@@ -38,7 +24,7 @@ static HRESULT SResToHRESULT(SRes res)
}
namespace NCompress {
namespace NLZMA {
namespace NLzma {
static const UInt32 kStreamStepSize = (UInt32)1 << 31;
@@ -123,14 +109,14 @@ static int ParseMatchFinder(const wchar_t *s, int *btMode, int *numHashBytes)
}
STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties)
const PROPVARIANT *coderProps, UInt32 numProps)
{
CLzmaEncProps props;
LzmaEncProps_Init(&props);
for (UInt32 i = 0; i < numProperties; i++)
for (UInt32 i = 0; i < numProps; i++)
{
const PROPVARIANT &prop = properties[i];
const PROPVARIANT &prop = coderProps[i];
switch (propIDs[i])
{
case NCoderPropID::kNumFastBytes:
@@ -203,10 +189,8 @@ SRes CompressProgress(void *pp, UInt64 inSize, UInt64 outSize)
return (SRes)p->Res;
}
STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 * /* inSize */,
const UInt64 * /* outSize */,
ICompressProgressInfo *progress)
STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
{
CCompressProgressImp progressImp;
progressImp.p.Progress = CompressProgress;

View File

@@ -1,18 +1,19 @@
// LZMA/Encoder.h
// LzmaEncoder.h
#ifndef __LZMA_ENCODER_H
#define __LZMA_ENCODER_H
#include "../../../Common/MyCom.h"
#include "../../ICoder.h"
extern "C"
{
#include "../../../../C/LzmaEnc.h"
#include "../../../C/LzmaEnc.h"
}
#include "../../Common/MyCom.h"
#include "../ICoder.h"
namespace NCompress {
namespace NLZMA {
namespace NLzma {
struct CSeqInStream
{
@@ -35,7 +36,7 @@ class CEncoder :
public CMyUnknownImp
{
CLzmaEncHandle _encoder;
CSeqInStream _seqInStream;
CSeqOutStream _seqOutStream;
@@ -48,19 +49,10 @@ public:
ICompressWriteCoderProperties
)
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
// ICompressSetCoderProperties2
STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties);
// ICompressWriteCoderProperties
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
STDMETHOD(SetOutStream)(ISequentialOutStream *outStream);
STDMETHOD(ReleaseOutStream)();

View File

@@ -1,14 +1,15 @@
// LZMARegister.cpp
// LzmaRegister.cpp
#include "StdAfx.h"
#include "../../Common/RegisterCodec.h"
#include "../Common/RegisterCodec.h"
#include "LZMADecoder.h"
static void *CreateCodec() { return (void *)(ICompressCoder *)(new NCompress::NLZMA::CDecoder); }
#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); }
#include "LzmaEncoder.h"
static void *CreateCodecOut() { return (void *)(ICompressCoder *)(new NCompress::NLzma::CEncoder); }
#else
#define CreateCodecOut 0
#endif

View File

@@ -1,8 +0,0 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/MyWindows.h"
#endif

View File

@@ -2,7 +2,7 @@
#include "StdAfx.h"
#include "Common/Defs.h"
#include "../../Common/Defs.h"
#include "Lzx86Converter.h"

View File

@@ -1,10 +1,11 @@
// Lzx/x86Converter.h
// Lzx86Converter.h
#ifndef __LZX_X86CONVERTER_H
#define __LZX_X86CONVERTER_H
#ifndef __LZX_86_CONVERTER_H
#define __LZX_86_CONVERTER_H
#include "Common/MyCom.h"
#include "../../IStream.h"
#include "../../Common/MyCom.h"
#include "../IStream.h"
namespace NCompress {
namespace NLzx {

View File

@@ -2,14 +2,9 @@
#include "StdAfx.h"
#include "LzxDecoder.h"
#include "../../Common/Defs.h"
#include "Common/Defs.h"
extern "C"
{
#include "../../../../C/Alloc.h"
}
#include "Windows/Defs.h"
#include "LzxDecoder.h"
namespace NCompress {
namespace NLzx {
@@ -306,10 +301,8 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
return S_OK;
}
HRESULT CDecoder::CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream,
const UInt64 *, const UInt64 *outSize,
ICompressProgressInfo *progress)
HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *, const UInt64 *outSize, ICompressProgressInfo *progress)
{
if (outSize == NULL)
return E_INVALIDARG;
@@ -343,12 +336,11 @@ HRESULT CDecoder::CodeReal(ISequentialInStream *inStream,
return Flush();
}
HRESULT CDecoder::Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress)
HRESULT CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{
try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
catch(const CLZOutWindowException &e) { return e.ErrorCode; }
catch(const CLzOutWindowException &e) { return e.ErrorCode; }
catch(...) { return S_FALSE; }
}

View File

@@ -1,14 +1,14 @@
// LzxDecoder.h
#ifndef __LZXDECODER_H
#define __LZXDECODER_H
#ifndef __LZX_DECODER_H
#define __LZX_DECODER_H
#include "../../ICoder.h"
#include "../ICoder.h"
#include "../../Compress/Huffman/HuffmanDecoder.h"
#include "../../Compress/LZ/LZOutWindow.h"
#include "../../Common/InBuffer.h"
#include "../Common/InBuffer.h"
#include "HuffmanDecoder.h"
#include "LzOutWindow.h"
#include "Lzx.h"
#include "Lzx86Converter.h"
@@ -101,7 +101,7 @@ class CDecoder :
public CMyUnknownImp
{
NBitStream::CDecoder m_InBitStream;
CLZOutWindow m_OutWindowStream;
CLzOutWindow m_OutWindowStream;
UInt32 m_RepDistances[kNumRepDistances];
UInt32 m_NumPosLenSlots;
@@ -135,10 +135,8 @@ class CDecoder :
HRESULT CodeSpec(UInt32 size);
HRESULT CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
public:
CDecoder(bool wimMode = false);
@@ -147,11 +145,8 @@ public:
void ReleaseStreams();
STDMETHOD(Flush)();
// ICompressCoder interface
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(SetInStream)(ISequentialInStream *inStream);
STDMETHOD(ReleaseInStream)();

View File

@@ -1,63 +1,63 @@
// Mtf8.h
#ifndef __MTF8_H
#define __MTF8_H
#ifndef __COMPRESS_MTF8_H
#define __COMPRESS_MTF8_H
#include "Common/Types.h"
#include "../../Common/Types.h"
namespace NCompress {
class CMtf8Encoder
struct CMtf8Encoder
{
public:
Byte Buffer[256];
Byte Buf[256];
int FindAndMove(Byte v)
{
int pos;
for (pos = 0; Buffer[pos] != v; pos++);
for (pos = 0; Buf[pos] != v; pos++);
int resPos = pos;
for (; pos >= 8; pos -= 8)
{
Buffer[pos] = Buffer[pos - 1];
Buffer[pos - 1] = Buffer[pos - 2];
Buffer[pos - 2] = Buffer[pos - 3];
Buffer[pos - 3] = Buffer[pos - 4];
Buffer[pos - 4] = Buffer[pos - 5];
Buffer[pos - 5] = Buffer[pos - 6];
Buffer[pos - 6] = Buffer[pos - 7];
Buffer[pos - 7] = Buffer[pos - 8];
Buf[pos] = Buf[pos - 1];
Buf[pos - 1] = Buf[pos - 2];
Buf[pos - 2] = Buf[pos - 3];
Buf[pos - 3] = Buf[pos - 4];
Buf[pos - 4] = Buf[pos - 5];
Buf[pos - 5] = Buf[pos - 6];
Buf[pos - 6] = Buf[pos - 7];
Buf[pos - 7] = Buf[pos - 8];
}
for (; pos > 0; pos--)
Buffer[pos] = Buffer[pos - 1];
Buffer[0] = v;
Buf[pos] = Buf[pos - 1];
Buf[0] = v;
return resPos;
}
};
/*
class CMtf8Decoder
struct CMtf8Decoder
{
public:
Byte Buffer[256];
Byte Buf[256];
void Init(int) {};
Byte GetHead() const { return Buffer[0]; }
Byte GetHead() const { return Buf[0]; }
Byte GetAndMove(int pos)
{
Byte res = Buffer[pos];
Byte res = Buf[pos];
for (; pos >= 8; pos -= 8)
{
Buffer[pos] = Buffer[pos - 1];
Buffer[pos - 1] = Buffer[pos - 2];
Buffer[pos - 2] = Buffer[pos - 3];
Buffer[pos - 3] = Buffer[pos - 4];
Buffer[pos - 4] = Buffer[pos - 5];
Buffer[pos - 5] = Buffer[pos - 6];
Buffer[pos - 6] = Buffer[pos - 7];
Buffer[pos - 7] = Buffer[pos - 8];
Buf[pos] = Buf[pos - 1];
Buf[pos - 1] = Buf[pos - 2];
Buf[pos - 2] = Buf[pos - 3];
Buf[pos - 3] = Buf[pos - 4];
Buf[pos - 4] = Buf[pos - 5];
Buf[pos - 5] = Buf[pos - 6];
Buf[pos - 6] = Buf[pos - 7];
Buf[pos - 7] = Buf[pos - 8];
}
for (; pos > 0; pos--)
Buffer[pos] = Buffer[pos - 1];
Buffer[0] = res;
Buf[pos] = Buf[pos - 1];
Buf[0] = res;
return res;
}
};
@@ -78,41 +78,41 @@ typedef UInt32 CMtfVar;
#define MTF_MASK ((1 << MTF_MOVS) - 1)
class CMtf8Decoder
struct CMtf8Decoder
{
public:
CMtfVar Buffer[256 >> MTF_MOVS];
void StartInit() { memset(Buffer, 0, sizeof(Buffer)); }
void Add(unsigned int pos, Byte val) { Buffer[pos >> MTF_MOVS] |= ((CMtfVar)val << ((pos & MTF_MASK) << 3)); }
Byte GetHead() const { return (Byte)Buffer[0]; }
CMtfVar Buf[256 >> MTF_MOVS];
void StartInit() { memset(Buf, 0, sizeof(Buf)); }
void Add(unsigned int pos, Byte val) { Buf[pos >> MTF_MOVS] |= ((CMtfVar)val << ((pos & MTF_MASK) << 3)); }
Byte GetHead() const { return (Byte)Buf[0]; }
Byte GetAndMove(unsigned int pos)
{
UInt32 lim = ((UInt32)pos >> MTF_MOVS);
pos = (pos & MTF_MASK) << 3;
CMtfVar prev = (Buffer[lim] >> pos) & 0xFF;
CMtfVar prev = (Buf[lim] >> pos) & 0xFF;
UInt32 i = 0;
if ((lim & 1) != 0)
{
CMtfVar next = Buffer[0];
Buffer[0] = (next << 8) | prev;
CMtfVar next = Buf[0];
Buf[0] = (next << 8) | prev;
prev = (next >> (MTF_MASK << 3));
i = 1;
lim -= 1;
}
for (; i < lim; i += 2)
{
CMtfVar next = Buffer[i];
Buffer[i] = (next << 8) | prev;
CMtfVar next = Buf[i];
Buf[i] = (next << 8) | prev;
prev = (next >> (MTF_MASK << 3));
next = Buffer[i + 1];
Buffer[i + 1] = (next << 8) | prev;
next = Buf[i + 1];
Buf[i + 1] = (next << 8) | prev;
prev = (next >> (MTF_MASK << 3));
}
CMtfVar next = Buffer[i];
CMtfVar next = Buf[i];
CMtfVar mask = (((CMtfVar)0x100 << pos) - 1);
Buffer[i] = (next & ~mask) | (((next << 8) | prev) & mask);
return (Byte)Buffer[0];
Buf[i] = (next & ~mask) | (((next << 8) | prev) & mask);
return (Byte)Buf[0];
}
};
@@ -125,13 +125,13 @@ class CMtf8Decoder
Byte Counts[16];
int Size;
public:
Byte Buffer[256];
Byte Buf[256];
Byte GetHead() const
{
if (SmallSize > 0)
return SmallBuffer[kSmallSize - SmallSize];
return Buffer[0];
return Buf[0];
}
void Init(int size)
@@ -165,12 +165,12 @@ public:
g--;
int offset = (g << 4);
for (int t = Counts[g] - 1; t >= 0; t--, i--)
Buffer[i] = Buffer[offset + t];
Buf[i] = Buf[offset + t];
}
while(g != 0);
for (i = kSmallSize - 1; i >= 0; i--)
Buffer[i] = SmallBuffer[i];
Buf[i] = SmallBuffer[i];
Init(Size);
}
pos -= SmallSize;
@@ -178,9 +178,9 @@ public:
for (g = 0; pos >= Counts[g]; g++)
pos -= Counts[g];
int offset = (g << 4);
Byte res = Buffer[offset + pos];
Byte res = Buf[offset + pos];
for (pos; pos < 16 - 1; pos++)
Buffer[offset + pos] = Buffer[offset + pos + 1];
Buf[offset + pos] = Buf[offset + pos + 1];
SmallSize++;
SmallBuffer[kSmallSize - SmallSize] = res;
@@ -192,4 +192,5 @@ public:
*/
}
#endif

View File

@@ -1,8 +0,0 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/MyWindows.h"
#endif

View File

@@ -1,16 +1,16 @@
// Compress/PPMD/Context.h
// PpmdContext.h
// This code is based on Dmitry Shkarin's PPMdH code
#ifndef __COMPRESS_PPMD_CONTEXT_H
#define __COMPRESS_PPMD_CONTEXT_H
#include "../../../Common/Types.h"
#include "../../Common/Types.h"
#include "../RangeCoder/RangeCoder.h"
#include "PPMDSubAlloc.h"
#include "PpmdSubAlloc.h"
#include "RangeCoder.h"
namespace NCompress {
namespace NPPMD {
namespace NPpmd {
const int INT_BITS=7, PERIOD_BITS=7, TOT_BITS=INT_BITS+PERIOD_BITS,
INTERVAL=1 << INT_BITS, BIN_SCALE=1 << TOT_BITS, MAX_FREQ=124;

View File

@@ -1,13 +1,13 @@
// PPMDDecode.h
// PpmdDecode.h
// This code is based on Dmitry Shkarin's PPMdH code
#ifndef __COMPRESS_PPMD_DECODE_H
#define __COMPRESS_PPMD_DECODE_H
#include "PPMDContext.h"
#include "PpmdContext.h"
namespace NCompress {
namespace NPPMD {
namespace NPpmd {
class CRangeDecoderVirt
{

View File

@@ -1,14 +1,14 @@
// PPMDDecoder.cpp
// PpmdDecoder.cpp
#include "StdAfx.h"
#include "Common/Defs.h"
#include "Windows/Defs.h"
#include "PPMDDecoder.h"
#include "PpmdDecoder.h"
namespace NCompress {
namespace NPPMD {
namespace NPpmd {
const int kLenIdFinished = -1;
const int kLenIdNeedInit = -2;
@@ -84,9 +84,8 @@ HRESULT CDecoder::CodeSpec(UInt32 size, Byte *memStream)
return S_OK;
}
STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 *outSize,
ICompressProgressInfo *progress)
STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress)
{
if (!_outStream.Create(1 << 20))
return E_OUTOFMEMORY;
@@ -132,9 +131,8 @@ STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
#endif
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress)
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{
PPMD_TRY_BEGIN
return CodeReal(inStream, outStream, inSize, outSize, progress);

View File

@@ -1,18 +1,19 @@
// Compress/PPM/PPMDDecoder.h
// PpmdDecoder.h
#ifndef __COMPRESS_PPMD_DECODER_H
#define __COMPRESS_PPMD_DECODER_H
#include "../../../Common/MyCom.h"
#include "../../Common/MyCom.h"
#include "../../ICoder.h"
#include "../../Common/OutBuffer.h"
#include "../RangeCoder/RangeCoder.h"
#include "../ICoder.h"
#include "PPMDDecode.h"
#include "../Common/OutBuffer.h"
#include "PpmdDecode.h"
#include "RangeCoder.h"
namespace NCompress {
namespace NPPMD {
namespace NPpmd {
class CDecoder :
public ICompressCoder,
@@ -39,6 +40,7 @@ class CDecoder :
UInt64 _processedSize;
HRESULT CodeSpec(UInt32 num, Byte *memStream);
public:
#ifndef NO_READ_FROM_CODER
@@ -60,15 +62,11 @@ public:
HRESULT Flush() { return _outStream.Flush(); }
STDMETHOD(CodeReal)(ISequentialInStream *inStream,
ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
STDMETHOD(CodeReal)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
@@ -81,7 +79,6 @@ public:
#endif
CDecoder(): _outSizeDefined(false) {}
};
}}

View File

@@ -1,17 +1,16 @@
// PPMDEncode.h
// PpmdEncode.h
// This code is based on Dmitry Shkarin's PPMdH code
#ifndef __COMPRESS_PPMD_ENCODE_H
#define __COMPRESS_PPMD_ENCODE_H
#include "PPMDContext.h"
#include "PpmdContext.h"
namespace NCompress {
namespace NPPMD {
namespace NPpmd {
struct CEncodeInfo: public CInfo
{
void EncodeBinSymbol(int symbol, NRangeCoder::CEncoder *rangeEncoder)
{
PPM_CONTEXT::STATE& rs = MinContext->oneState();
@@ -135,8 +134,8 @@ SYMBOL_FOUND:
}
NextContext();
}
};
}}
#endif

View File

@@ -1,20 +1,16 @@
// Compress/Associative/Encoder.h
// PpmdEncoder.cpp
#include "StdAfx.h"
#include "Windows/Defs.h"
// #include <fstream.h>
// #include <iomanip.h>
#include "Common/Defs.h"
#include "../Common/StreamUtils.h"
#include "../../Common/StreamUtils.h"
#include "PPMDEncoder.h"
#include "PpmdEncoder.h"
namespace NCompress {
namespace NPPMD {
namespace NPpmd {
const UInt32 kMinMemSize = (1 << 11);
const UInt32 kMinOrder = 2;
@@ -45,12 +41,11 @@ public:
CCounter g_Counter;
*/
STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties)
STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps)
{
for (UInt32 i = 0; i < numProperties; i++)
for (UInt32 i = 0; i < numProps; i++)
{
const PROPVARIANT &prop = properties[i];
const PROPVARIANT &prop = props[i];
switch(propIDs[i])
{
case NCoderPropID::kUsedMemorySize:
@@ -77,11 +72,11 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
{
const UInt32 kPropSize = 5;
Byte properties[kPropSize];
properties[0] = _order;
Byte props[kPropSize];
props[0] = _order;
for (int i = 0; i < 4; i++)
properties[1 + i] = Byte(_usedMemorySize >> (8 * i));
return WriteStream(outStream, properties, kPropSize);
props[1 + i] = Byte(_usedMemorySize >> (8 * i));
return WriteStream(outStream, props, kPropSize);
}
const UInt32 kUsedMemorySizeDefault = (1 << 24);
@@ -94,10 +89,8 @@ CEncoder::CEncoder():
}
HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 * /* outSize */,
ICompressProgressInfo *progress)
HRESULT CEncoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
{
if (!_inStream.Create(1 << 20))
return E_OUTOFMEMORY;
@@ -142,9 +135,8 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
}
}
STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress)
STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{
try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
catch(const COutBufferException &e) { return e.ErrorCode; }

View File

@@ -1,18 +1,19 @@
// Compress/PPMD/Encoder.h
// PpmdEncoder.h
#ifndef __COMPRESS_PPMD_ENCODER_H
#define __COMPRESS_PPMD_ENCODER_H
#include "../../../Common/MyCom.h"
#include "../../Common/MyCom.h"
#include "../../ICoder.h"
#include "../../Common/InBuffer.h"
#include "../RangeCoder/RangeCoder.h"
#include "../ICoder.h"
#include "PPMDEncode.h"
#include "../Common/InBuffer.h"
#include "PpmdEncode.h"
#include "RangeCoder.h"
namespace NCompress {
namespace NPPMD {
namespace NPpmd {
class CEncoder :
public ICompressCoder,
@@ -41,9 +42,8 @@ public:
_rangeEncoder.ReleaseStream();
}
HRESULT CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
class CEncoderFlusher
{
@@ -63,17 +63,14 @@ public:
ICompressSetCoderProperties,
ICompressWriteCoderProperties)
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties);
STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
CEncoder();
};
}}

View File

@@ -1,14 +1,15 @@
// PPMDRegister.cpp
// PpmdRegister.cpp
#include "StdAfx.h"
#include "../../Common/RegisterCodec.h"
#include "../Common/RegisterCodec.h"
#include "PPMDDecoder.h"
static void *CreateCodec() { return (void *)(ICompressCoder *)(new NCompress::NPPMD::CDecoder); }
#include "PpmdDecoder.h"
static void *CreateCodec() { return (void *)(ICompressCoder *)(new NCompress::NPpmd::CDecoder); }
#ifndef EXTRACT_ONLY
#include "PPMDEncoder.h"
static void *CreateCodecOut() { return (void *)(ICompressCoder *)(new NCompress::NPPMD::CEncoder); }
#include "PpmdEncoder.h"
static void *CreateCodecOut() { return (void *)(ICompressCoder *)(new NCompress::NPpmd::CEncoder); }
#else
#define CreateCodecOut 0
#endif

View File

@@ -1,16 +1,16 @@
// PPMDSubAlloc.h
// PpmdSubAlloc.h
// This code is based on Dmitry Shkarin's PPMdH code
#ifndef __PPMD_SUBALLOC_H
#define __PPMD_SUBALLOC_H
#include "PPMDType.h"
#ifndef __COMPRESS_PPMD_SUB_ALLOC_H
#define __COMPRESS_PPMD_SUB_ALLOC_H
extern "C"
{
#include "../../../../C/Alloc.h"
#include "../../../C/Alloc.h"
}
#include "PpmdType.h"
const UINT N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4;
const UINT UNIT_SIZE=12, N_INDEXES=N1+N2+N3+N4;

View File

@@ -7,8 +7,9 @@
* modified by Igor Pavlov (2004-08-29).
****************************************************************************/
#ifndef __PPMD_TYPE_H
#define __PPMD_TYPE_H
#ifndef __COMPRESS_PPMD_TYPE_H
#define __COMPRESS_PPMD_TYPE_H
const int kMaxOrderCompress = 32;
const int MAX_O = 255; /* maximum allowed model order */

View File

@@ -1,8 +0,0 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/MyWindows.h"
#endif

View File

@@ -2,8 +2,9 @@
#include "StdAfx.h"
#include "../../Common/Defs.h"
#include "QuantumDecoder.h"
#include "../../../Common/Defs.h"
namespace NCompress {
namespace NQuantum {
@@ -104,10 +105,8 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
return _rangeDecoder.Stream.WasFinished() ? S_FALSE : S_OK;
}
HRESULT CDecoder::CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream,
const UInt64 *, const UInt64 *outSize,
ICompressProgressInfo *progress)
HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *, const UInt64 *outSize, ICompressProgressInfo *progress)
{
if (outSize == NULL)
return E_INVALIDARG;
@@ -139,13 +138,12 @@ HRESULT CDecoder::CodeReal(ISequentialInStream *inStream,
return Flush();
}
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress)
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
{
try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
catch(const CInBufferException &e) { return e.ErrorCode; }
catch(const CLZOutWindowException &e) { return e.ErrorCode; }
catch(const CLzOutWindowException &e) { return e.ErrorCode; }
catch(...) { return S_FALSE; }
}

View File

@@ -1,13 +1,15 @@
// QuantumDecoder.h
#ifndef __QUANTUM_DECODER_H
#define __QUANTUM_DECODER_H
#ifndef __COMPRESS_QUANTUM_DECODER_H
#define __COMPRESS_QUANTUM_DECODER_H
#include "../../../Common/MyCom.h"
#include "../../Common/MyCom.h"
#include "../../Common/InBuffer.h"
#include "../../ICoder.h"
#include "../LZ/LZOutWindow.h"
#include "../ICoder.h"
#include "../Common/InBuffer.h"
#include "LzOutWindow.h"
namespace NCompress {
namespace NQuantum {
@@ -207,7 +209,7 @@ class CDecoder:
public ICompressSetOutStreamSize,
public CMyUnknownImp
{
CLZOutWindow _outWindowStream;
CLzOutWindow _outWindowStream;
NRangeCoder::CDecoder _rangeDecoder;
///////////////////
@@ -256,13 +258,11 @@ public:
HRESULT Flush() { return _outWindowStream.Flush(); }
HRESULT CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress);
STDMETHOD(SetInStream)(ISequentialInStream *inStream);
STDMETHOD(ReleaseInStream)();

View File

@@ -1,10 +1,10 @@
// Compress/RangeCoder/RangeCoder.h
// Compress/RangeCoder.h
#ifndef __COMPRESS_RANGECODER_H
#define __COMPRESS_RANGECODER_H
#ifndef __COMPRESS_RANGE_CODER_H
#define __COMPRESS_RANGE_CODER_H
#include "../../Common/InBuffer.h"
#include "../../Common/OutBuffer.h"
#include "../Common/InBuffer.h"
#include "../Common/OutBuffer.h"
namespace NCompress {
namespace NRangeCoder {

Some files were not shown because too many files have changed in this diff Show More