lzma_c: no need to rebuild for using in kpack/kerpack, cleanup
Removed samples, converted indentation to spaces, translated to english, added header for exporting functions. Added is_kerpack argument to lzma_compress() to make it usable either for kpack and kerpack without rebuild
This commit is contained in:
1770
lzma_c/LZMAEncoder.c
1770
lzma_c/LZMAEncoder.c
File diff suppressed because it is too large
Load Diff
@@ -6,15 +6,15 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CState State;
|
||||
bool Prev1IsChar;
|
||||
bool Prev2;
|
||||
unsigned PosPrev2;
|
||||
unsigned BackPrev2;
|
||||
unsigned Price;
|
||||
unsigned PosPrev;
|
||||
unsigned BackPrev;
|
||||
unsigned Backs[kNumRepDistances];
|
||||
CState State;
|
||||
bool Prev1IsChar;
|
||||
bool Prev2;
|
||||
unsigned PosPrev2;
|
||||
unsigned BackPrev2;
|
||||
unsigned Price;
|
||||
unsigned PosPrev;
|
||||
unsigned BackPrev;
|
||||
unsigned Backs[kNumRepDistances];
|
||||
} COptimal;
|
||||
#define COptimal_MakeAsChar(a) (a)->BackPrev=(unsigned)-1,(a)->Prev1IsChar=false
|
||||
#define COptimal_MakeAsShortRep(a) (a)->BackPrev=0,(a)->Prev1IsChar=false
|
||||
@@ -26,27 +26,27 @@ typedef struct
|
||||
typedef CMyBitEncoder CLiteralEncoder2[0x300];
|
||||
typedef struct
|
||||
{
|
||||
CLiteralEncoder2* _coders;
|
||||
int _numPrevBits;
|
||||
int _numPosBits;
|
||||
unsigned _posMask;
|
||||
CLiteralEncoder2* _coders;
|
||||
int _numPrevBits;
|
||||
int _numPosBits;
|
||||
unsigned _posMask;
|
||||
} CLiteralEncoder;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CMyBitEncoder _choice;
|
||||
CMyBitEncoder _choice2;
|
||||
NRangeCoder_CBitTreeEncoder _lowCoder[kNumPosStatesEncodingMax];
|
||||
NRangeCoder_CBitTreeEncoder _midCoder[kNumPosStatesEncodingMax];
|
||||
NRangeCoder_CBitTreeEncoder _highCoder;
|
||||
CMyBitEncoder _choice;
|
||||
CMyBitEncoder _choice2;
|
||||
NRangeCoder_CBitTreeEncoder _lowCoder[kNumPosStatesEncodingMax];
|
||||
NRangeCoder_CBitTreeEncoder _midCoder[kNumPosStatesEncodingMax];
|
||||
NRangeCoder_CBitTreeEncoder _highCoder;
|
||||
} NLength_CEncoder;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
NLength_CEncoder base;
|
||||
unsigned _prices[kNumSymbolsTotal][kNumPosStatesEncodingMax];
|
||||
unsigned _tableSize;
|
||||
unsigned _counters[kNumPosStatesEncodingMax];
|
||||
NLength_CEncoder base;
|
||||
unsigned _prices[kNumSymbolsTotal][kNumPosStatesEncodingMax];
|
||||
unsigned _tableSize;
|
||||
unsigned _counters[kNumPosStatesEncodingMax];
|
||||
} NLength_CPriceTableEncoder;
|
||||
#define CPriceTableEncoder_Init(a,b) NLength_CEncoder_Init(&a.base,b)
|
||||
|
||||
|
@@ -1,21 +1,11 @@
|
||||
#include "MatchFinder.h"
|
||||
/* memcpy must be inlined - we do not want to use RTL */
|
||||
#include <memory.h>
|
||||
/*#pragma function(memcpy)
|
||||
void* __cdecl memcpy(void* _Dst, const void* _Src, size_t _Size)
|
||||
{
|
||||
unsigned long i;
|
||||
for (i = 0; i < _Size; i++)
|
||||
((char*)_Dst)[i] = ((char*)_Src)[i];
|
||||
return _Dst;
|
||||
}*/
|
||||
//#pragma intrinsic(memcpy)
|
||||
|
||||
#define kMaxValForNormalize (((unsigned)1<<31)-1)
|
||||
|
||||
/* settings for bt4:
|
||||
defined HASH_ARRAY_2
|
||||
defined HASH_ARRAY_3
|
||||
defined HASH_ARRAY_2
|
||||
defined HASH_ARRAY_3
|
||||
*/
|
||||
|
||||
//#define kHash2Size 0x400
|
||||
@@ -57,56 +47,56 @@ static unsigned _streamPos;
|
||||
|
||||
static void LZInWindow_Create(unsigned keepSizeBefore,unsigned keepSizeAfter,unsigned keepSizeReserv,byte**mem)
|
||||
{
|
||||
_keepSizeBefore = keepSizeBefore;
|
||||
_keepSizeAfter = keepSizeAfter;
|
||||
_keepSizeReserv = keepSizeReserv;
|
||||
_blockSize = keepSizeBefore + keepSizeAfter + keepSizeReserv;
|
||||
_bufferBase = *mem;
|
||||
_blockSize = (_blockSize + 3) & ~3;
|
||||
*mem += _blockSize;
|
||||
_pointerToLastSafePosition = _bufferBase + _blockSize - keepSizeAfter;
|
||||
_keepSizeBefore = keepSizeBefore;
|
||||
_keepSizeAfter = keepSizeAfter;
|
||||
_keepSizeReserv = keepSizeReserv;
|
||||
_blockSize = keepSizeBefore + keepSizeAfter + keepSizeReserv;
|
||||
_bufferBase = *mem;
|
||||
_blockSize = (_blockSize + 3) & ~3;
|
||||
*mem += _blockSize;
|
||||
_pointerToLastSafePosition = _bufferBase + _blockSize - keepSizeAfter;
|
||||
}
|
||||
|
||||
static void ReadBlock(void)
|
||||
{
|
||||
if (_streamEndWasReached)
|
||||
return;
|
||||
for (;;)
|
||||
{
|
||||
unsigned size;
|
||||
size = (unsigned)(_bufferBase-_buffer) + _blockSize - _streamPos;
|
||||
if (!size) return;
|
||||
if (size > pack_length - pack_pos)
|
||||
size = pack_length - pack_pos;
|
||||
memcpy(_buffer+_streamPos,curin,size);
|
||||
curin += size;
|
||||
pack_pos += size;
|
||||
if (size == 0)
|
||||
{
|
||||
byte* pointerToPosition;
|
||||
_posLimit = _streamPos;
|
||||
pointerToPosition = _buffer + _posLimit;
|
||||
if (pointerToPosition > _pointerToLastSafePosition)
|
||||
_posLimit = _pointerToLastSafePosition - _buffer;
|
||||
_streamEndWasReached = true;
|
||||
return;
|
||||
}
|
||||
_streamPos += size;
|
||||
if (_streamPos >= _pos + _keepSizeAfter)
|
||||
{
|
||||
_posLimit = _streamPos - _keepSizeAfter;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (_streamEndWasReached)
|
||||
return;
|
||||
for (;;)
|
||||
{
|
||||
unsigned size;
|
||||
size = (unsigned)(_bufferBase-_buffer) + _blockSize - _streamPos;
|
||||
if (!size) return;
|
||||
if (size > pack_length - pack_pos)
|
||||
size = pack_length - pack_pos;
|
||||
memcpy(_buffer+_streamPos,curin,size);
|
||||
curin += size;
|
||||
pack_pos += size;
|
||||
if (size == 0)
|
||||
{
|
||||
byte* pointerToPosition;
|
||||
_posLimit = _streamPos;
|
||||
pointerToPosition = _buffer + _posLimit;
|
||||
if (pointerToPosition > _pointerToLastSafePosition)
|
||||
_posLimit = _pointerToLastSafePosition - _buffer;
|
||||
_streamEndWasReached = true;
|
||||
return;
|
||||
}
|
||||
_streamPos += size;
|
||||
if (_streamPos >= _pos + _keepSizeAfter)
|
||||
{
|
||||
_posLimit = _streamPos - _keepSizeAfter;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void LZInWindow_Init(void)
|
||||
{
|
||||
_buffer = _bufferBase;
|
||||
_pos = 0;
|
||||
_streamPos = 0;
|
||||
_streamEndWasReached = false;
|
||||
ReadBlock();
|
||||
_buffer = _bufferBase;
|
||||
_pos = 0;
|
||||
_streamPos = 0;
|
||||
_streamEndWasReached = false;
|
||||
ReadBlock();
|
||||
}
|
||||
#else
|
||||
#define LZInWindow_Create(a,b,c,d) /* nothing */
|
||||
@@ -118,24 +108,24 @@ const byte* GetPointerToCurrentPos(void) {return _buffer+_pos;}
|
||||
#ifdef GENERIC_INPUT
|
||||
static void MoveBlock(void)
|
||||
{
|
||||
unsigned offset,numBytes;
|
||||
offset = _buffer-_bufferBase+_pos-_keepSizeBefore;
|
||||
numBytes = _buffer-_bufferBase+_streamPos-offset;
|
||||
// copying backwards: safe to use memcpy instead of memmove
|
||||
memcpy(_bufferBase,_bufferBase+offset,numBytes);
|
||||
_buffer -= offset;
|
||||
unsigned offset,numBytes;
|
||||
offset = _buffer-_bufferBase+_pos-_keepSizeBefore;
|
||||
numBytes = _buffer-_bufferBase+_streamPos-offset;
|
||||
// copying backwards: safe to use memcpy instead of memmove
|
||||
memcpy(_bufferBase,_bufferBase+offset,numBytes);
|
||||
_buffer -= offset;
|
||||
}
|
||||
|
||||
static void LZInWindow_MovePos(void)
|
||||
{
|
||||
_pos++;
|
||||
if (_pos > _posLimit)
|
||||
{
|
||||
const byte* pointerToPosition = _buffer+_pos;
|
||||
if (pointerToPosition > _pointerToLastSafePosition)
|
||||
MoveBlock();
|
||||
ReadBlock();
|
||||
}
|
||||
_pos++;
|
||||
if (_pos > _posLimit)
|
||||
{
|
||||
const byte* pointerToPosition = _buffer+_pos;
|
||||
if (pointerToPosition > _pointerToLastSafePosition)
|
||||
MoveBlock();
|
||||
ReadBlock();
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define LZInWindow_MovePos() _pos++
|
||||
@@ -145,21 +135,21 @@ byte GetIndexByte(int index) {return _buffer[_pos+index];}
|
||||
|
||||
unsigned GetMatchLen(int index,unsigned distance,unsigned limit)
|
||||
{
|
||||
const byte* pby;
|
||||
unsigned i;
|
||||
const byte* pby;
|
||||
unsigned i;
|
||||
#ifdef GENERIC_INPUT
|
||||
if (_streamEndWasReached)
|
||||
if ((_pos+index)+limit > _streamPos)
|
||||
limit = _streamPos - (_pos+index);
|
||||
if (_streamEndWasReached)
|
||||
if ((_pos+index)+limit > _streamPos)
|
||||
limit = _streamPos - (_pos+index);
|
||||
#else
|
||||
unsigned limit2 = pack_length - (pack_pos + index);
|
||||
if (limit > limit2)
|
||||
limit = limit2;
|
||||
unsigned limit2 = pack_length - (pack_pos + index);
|
||||
if (limit > limit2)
|
||||
limit = limit2;
|
||||
#endif
|
||||
distance++;
|
||||
pby = _buffer + _pos + index;
|
||||
for (i=0;i<limit && pby[i]==pby[(int)(i-distance)];i++) ;
|
||||
return i;
|
||||
distance++;
|
||||
pby = _buffer + _pos + index;
|
||||
for (i=0;i<limit && pby[i]==pby[(int)(i-distance)];i++) ;
|
||||
return i;
|
||||
}
|
||||
|
||||
unsigned GetNumAvailableBytes(void) {return _streamPos-_pos;}
|
||||
@@ -167,10 +157,10 @@ unsigned GetNumAvailableBytes(void) {return _streamPos-_pos;}
|
||||
#ifdef GENERIC_INPUT
|
||||
void ReduceOffsets(int subValue)
|
||||
{
|
||||
_buffer += subValue;
|
||||
_posLimit -= subValue;
|
||||
_pos -= subValue;
|
||||
_streamPos -= subValue;
|
||||
_buffer += subValue;
|
||||
_posLimit -= subValue;
|
||||
_pos -= subValue;
|
||||
_streamPos -= subValue;
|
||||
}
|
||||
#else
|
||||
#define ReduceOffsets(a) /* nothing */
|
||||
@@ -182,241 +172,241 @@ static unsigned crc_table[256];
|
||||
|
||||
void MatchFinder_Create(unsigned historySize,unsigned keepAddBufferBefore,unsigned matchMaxLen,unsigned keepAddBufferAfter,byte**mem)
|
||||
{
|
||||
unsigned sizeReserv;
|
||||
sizeReserv = (historySize + keepAddBufferBefore + matchMaxLen + keepAddBufferAfter)/2+256;
|
||||
LZInWindow_Create(historySize+keepAddBufferBefore,matchMaxLen+keepAddBufferAfter,sizeReserv,mem);
|
||||
_matchMaxLen = matchMaxLen;
|
||||
_cyclicBufferSize = historySize+1;
|
||||
_hash = (unsigned*)*mem;
|
||||
*mem += (kHashSizeSum + _cyclicBufferSize*2) * sizeof(unsigned);
|
||||
_cutValue = 0xFF;
|
||||
unsigned sizeReserv;
|
||||
sizeReserv = (historySize + keepAddBufferBefore + matchMaxLen + keepAddBufferAfter)/2+256;
|
||||
LZInWindow_Create(historySize+keepAddBufferBefore,matchMaxLen+keepAddBufferAfter,sizeReserv,mem);
|
||||
_matchMaxLen = matchMaxLen;
|
||||
_cyclicBufferSize = historySize+1;
|
||||
_hash = (unsigned*)*mem;
|
||||
*mem += (kHashSizeSum + _cyclicBufferSize*2) * sizeof(unsigned);
|
||||
_cutValue = 0xFF;
|
||||
}
|
||||
|
||||
void MatchFinder_Init(void)
|
||||
{
|
||||
unsigned i,j,r;
|
||||
LZInWindow_Init();
|
||||
for (i=0;i<kHashSizeSum;i++)
|
||||
_hash[i] = 0;
|
||||
_cyclicBufferPos = 0;
|
||||
ReduceOffsets(-1);
|
||||
for (i=0;i<256;i++)
|
||||
{
|
||||
r = i;
|
||||
for (j=0;j<8;j++)
|
||||
{
|
||||
if (r & 1)
|
||||
r = (r>>1) ^ 0xEDB88320;
|
||||
else
|
||||
r >>= 1;
|
||||
}
|
||||
crc_table[i] = r;
|
||||
}
|
||||
unsigned i,j,r;
|
||||
LZInWindow_Init();
|
||||
for (i=0;i<kHashSizeSum;i++)
|
||||
_hash[i] = 0;
|
||||
_cyclicBufferPos = 0;
|
||||
ReduceOffsets(-1);
|
||||
for (i=0;i<256;i++)
|
||||
{
|
||||
r = i;
|
||||
for (j=0;j<8;j++)
|
||||
{
|
||||
if (r & 1)
|
||||
r = (r>>1) ^ 0xEDB88320;
|
||||
else
|
||||
r >>= 1;
|
||||
}
|
||||
crc_table[i] = r;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned Hash(const byte* ptr, unsigned* hash2Value)
|
||||
{
|
||||
unsigned temp;
|
||||
temp = crc_table[ptr[0]] ^ ptr[1];
|
||||
*hash2Value = *(word*)ptr; //ptr[0] + ((unsigned)ptr[1] << 8);
|
||||
return (temp ^ ((unsigned)ptr[2]<<8)) & (kHashSize - 1);
|
||||
unsigned temp;
|
||||
temp = crc_table[ptr[0]] ^ ptr[1];
|
||||
*hash2Value = *(word*)ptr; //ptr[0] + ((unsigned)ptr[1] << 8);
|
||||
return (temp ^ ((unsigned)ptr[2]<<8)) & (kHashSize - 1);
|
||||
}
|
||||
|
||||
unsigned GetLongestMatch(unsigned* distances)
|
||||
{
|
||||
unsigned lenLimit,maxLen=0;
|
||||
unsigned matchMinPos;
|
||||
const byte* cur;
|
||||
unsigned hash2Value,hashValue;
|
||||
unsigned curMatch,curMatch2;
|
||||
unsigned *son,*ptr0,*ptr1;
|
||||
unsigned len0,len1,count;
|
||||
if (_pos + _matchMaxLen <= _streamPos)
|
||||
lenLimit = _matchMaxLen;
|
||||
else
|
||||
{
|
||||
lenLimit = _streamPos - _pos;
|
||||
if (lenLimit < kNumHashBytes)
|
||||
return 0;
|
||||
}
|
||||
matchMinPos = (_pos>_cyclicBufferSize) ? (_pos-_cyclicBufferSize) : 0;
|
||||
cur = _buffer+_pos;
|
||||
hashValue = Hash(cur,&hash2Value);
|
||||
curMatch = _hash[hashValue];
|
||||
curMatch2 = _hash[kHash2Offset + hash2Value];
|
||||
_hash[kHash2Offset + hash2Value] = _pos;
|
||||
distances[2] = 0xFFFFFFFF;
|
||||
if (curMatch2 > matchMinPos)
|
||||
//if (_buffer[curMatch2] == cur[0])
|
||||
{
|
||||
distances[2] = _pos - curMatch2 - 1;
|
||||
maxLen = 2;
|
||||
}
|
||||
_hash[hashValue] = _pos;
|
||||
son = _hash + kHashSizeSum;
|
||||
ptr0 = son + (_cyclicBufferPos << 1) + 1;
|
||||
ptr1 = son + (_cyclicBufferPos << 1);
|
||||
distances[kNumHashBytes] = 0xFFFFFFFF;
|
||||
len0 = len1 = kNumHashDirectBytes;
|
||||
count = _cutValue;
|
||||
for (;;)
|
||||
{
|
||||
const byte* pb;
|
||||
unsigned len,delta;
|
||||
unsigned cyclicPos;
|
||||
unsigned* pair;
|
||||
if (curMatch <= matchMinPos || count--==0)
|
||||
{
|
||||
*ptr0 = *ptr1 = 0;
|
||||
break;
|
||||
}
|
||||
pb = _buffer+curMatch;
|
||||
len = (len0<len1) ? len0 : len1;
|
||||
do
|
||||
if (pb[len] != cur[len]) break;
|
||||
while (++len != lenLimit);
|
||||
delta = _pos - curMatch;
|
||||
while (maxLen < len)
|
||||
distances[++maxLen] = delta-1;
|
||||
cyclicPos = (delta <= _cyclicBufferPos) ?
|
||||
(_cyclicBufferPos - delta) :
|
||||
(_cyclicBufferPos - delta + _cyclicBufferSize);
|
||||
pair = son + (cyclicPos<<1);
|
||||
if (len != lenLimit)
|
||||
{
|
||||
if (pb[len] < cur[len])
|
||||
{
|
||||
*ptr1 = curMatch;
|
||||
ptr1 = pair+1;
|
||||
curMatch = *ptr1;
|
||||
len1 = len;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptr0 = curMatch;
|
||||
ptr0 = pair;
|
||||
curMatch = *ptr0;
|
||||
len0 = len;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptr1 = pair[0];
|
||||
*ptr0 = pair[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*if (distances[4] < distances[3])
|
||||
distances[3] = distances[4];
|
||||
if (distances[3] < distances[2])
|
||||
distances[2] = distances[3];*/
|
||||
return maxLen;
|
||||
unsigned lenLimit,maxLen=0;
|
||||
unsigned matchMinPos;
|
||||
const byte* cur;
|
||||
unsigned hash2Value,hashValue;
|
||||
unsigned curMatch,curMatch2;
|
||||
unsigned *son,*ptr0,*ptr1;
|
||||
unsigned len0,len1,count;
|
||||
if (_pos + _matchMaxLen <= _streamPos)
|
||||
lenLimit = _matchMaxLen;
|
||||
else
|
||||
{
|
||||
lenLimit = _streamPos - _pos;
|
||||
if (lenLimit < kNumHashBytes)
|
||||
return 0;
|
||||
}
|
||||
matchMinPos = (_pos>_cyclicBufferSize) ? (_pos-_cyclicBufferSize) : 0;
|
||||
cur = _buffer+_pos;
|
||||
hashValue = Hash(cur,&hash2Value);
|
||||
curMatch = _hash[hashValue];
|
||||
curMatch2 = _hash[kHash2Offset + hash2Value];
|
||||
_hash[kHash2Offset + hash2Value] = _pos;
|
||||
distances[2] = 0xFFFFFFFF;
|
||||
if (curMatch2 > matchMinPos)
|
||||
//if (_buffer[curMatch2] == cur[0])
|
||||
{
|
||||
distances[2] = _pos - curMatch2 - 1;
|
||||
maxLen = 2;
|
||||
}
|
||||
_hash[hashValue] = _pos;
|
||||
son = _hash + kHashSizeSum;
|
||||
ptr0 = son + (_cyclicBufferPos << 1) + 1;
|
||||
ptr1 = son + (_cyclicBufferPos << 1);
|
||||
distances[kNumHashBytes] = 0xFFFFFFFF;
|
||||
len0 = len1 = kNumHashDirectBytes;
|
||||
count = _cutValue;
|
||||
for (;;)
|
||||
{
|
||||
const byte* pb;
|
||||
unsigned len,delta;
|
||||
unsigned cyclicPos;
|
||||
unsigned* pair;
|
||||
if (curMatch <= matchMinPos || count--==0)
|
||||
{
|
||||
*ptr0 = *ptr1 = 0;
|
||||
break;
|
||||
}
|
||||
pb = _buffer+curMatch;
|
||||
len = (len0<len1) ? len0 : len1;
|
||||
do
|
||||
if (pb[len] != cur[len]) break;
|
||||
while (++len != lenLimit);
|
||||
delta = _pos - curMatch;
|
||||
while (maxLen < len)
|
||||
distances[++maxLen] = delta-1;
|
||||
cyclicPos = (delta <= _cyclicBufferPos) ?
|
||||
(_cyclicBufferPos - delta) :
|
||||
(_cyclicBufferPos - delta + _cyclicBufferSize);
|
||||
pair = son + (cyclicPos<<1);
|
||||
if (len != lenLimit)
|
||||
{
|
||||
if (pb[len] < cur[len])
|
||||
{
|
||||
*ptr1 = curMatch;
|
||||
ptr1 = pair+1;
|
||||
curMatch = *ptr1;
|
||||
len1 = len;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptr0 = curMatch;
|
||||
ptr0 = pair;
|
||||
curMatch = *ptr0;
|
||||
len0 = len;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptr1 = pair[0];
|
||||
*ptr0 = pair[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*if (distances[4] < distances[3])
|
||||
distances[3] = distances[4];
|
||||
if (distances[3] < distances[2])
|
||||
distances[2] = distances[3];*/
|
||||
return maxLen;
|
||||
}
|
||||
|
||||
void DummyLongestMatch(void)
|
||||
{
|
||||
unsigned lenLimit;
|
||||
unsigned matchMinPos;
|
||||
const byte* cur;
|
||||
unsigned hash2Value,hashValue;
|
||||
unsigned curMatch;
|
||||
unsigned* son,*ptr0,*ptr1;
|
||||
unsigned len0,len1,count;
|
||||
if (_pos + _matchMaxLen <= _streamPos)
|
||||
lenLimit = _matchMaxLen;
|
||||
else
|
||||
{
|
||||
lenLimit = _streamPos - _pos;
|
||||
if (lenLimit < kNumHashBytes)
|
||||
return;
|
||||
}
|
||||
matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0;
|
||||
cur = _buffer+_pos;
|
||||
hashValue = Hash(cur,&hash2Value);
|
||||
_hash[kHash2Offset + hash2Value] = _pos;
|
||||
curMatch = _hash[hashValue];
|
||||
_hash[hashValue] = _pos;
|
||||
son = _hash+kHashSizeSum;
|
||||
ptr0 = son + (_cyclicBufferPos << 1) + 1;
|
||||
ptr1 = son + (_cyclicBufferPos << 1);
|
||||
len0 = len1 = kNumHashDirectBytes;
|
||||
count = _cutValue;
|
||||
for (;;)
|
||||
{
|
||||
const byte* pb;
|
||||
unsigned len;
|
||||
unsigned delta,cyclicPos;
|
||||
unsigned* pair;
|
||||
if (curMatch <= matchMinPos || count--==0)
|
||||
break;
|
||||
pb = _buffer+curMatch;
|
||||
len = (len0<len1) ? len0 : len1;
|
||||
do
|
||||
if (pb[len] != cur[len]) break;
|
||||
while (++len != lenLimit);
|
||||
delta = _pos - curMatch;
|
||||
cyclicPos = (delta <= _cyclicBufferPos) ?
|
||||
(_cyclicBufferPos - delta) :
|
||||
(_cyclicBufferPos - delta + _cyclicBufferSize);
|
||||
pair = son + (cyclicPos << 1);
|
||||
if (len != lenLimit)
|
||||
{
|
||||
if (pb[len] < cur[len])
|
||||
{
|
||||
*ptr1 = curMatch;
|
||||
ptr1 = pair+1;
|
||||
curMatch = *ptr1;
|
||||
len1 = len;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptr0 = curMatch;
|
||||
ptr0 = pair;
|
||||
curMatch = *ptr0;
|
||||
len0 = len;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptr1 = pair[0];
|
||||
*ptr0 = pair[1];
|
||||
return;
|
||||
}
|
||||
}
|
||||
*ptr0 = *ptr1 = 0;
|
||||
unsigned lenLimit;
|
||||
unsigned matchMinPos;
|
||||
const byte* cur;
|
||||
unsigned hash2Value,hashValue;
|
||||
unsigned curMatch;
|
||||
unsigned* son,*ptr0,*ptr1;
|
||||
unsigned len0,len1,count;
|
||||
if (_pos + _matchMaxLen <= _streamPos)
|
||||
lenLimit = _matchMaxLen;
|
||||
else
|
||||
{
|
||||
lenLimit = _streamPos - _pos;
|
||||
if (lenLimit < kNumHashBytes)
|
||||
return;
|
||||
}
|
||||
matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0;
|
||||
cur = _buffer+_pos;
|
||||
hashValue = Hash(cur,&hash2Value);
|
||||
_hash[kHash2Offset + hash2Value] = _pos;
|
||||
curMatch = _hash[hashValue];
|
||||
_hash[hashValue] = _pos;
|
||||
son = _hash+kHashSizeSum;
|
||||
ptr0 = son + (_cyclicBufferPos << 1) + 1;
|
||||
ptr1 = son + (_cyclicBufferPos << 1);
|
||||
len0 = len1 = kNumHashDirectBytes;
|
||||
count = _cutValue;
|
||||
for (;;)
|
||||
{
|
||||
const byte* pb;
|
||||
unsigned len;
|
||||
unsigned delta,cyclicPos;
|
||||
unsigned* pair;
|
||||
if (curMatch <= matchMinPos || count--==0)
|
||||
break;
|
||||
pb = _buffer+curMatch;
|
||||
len = (len0<len1) ? len0 : len1;
|
||||
do
|
||||
if (pb[len] != cur[len]) break;
|
||||
while (++len != lenLimit);
|
||||
delta = _pos - curMatch;
|
||||
cyclicPos = (delta <= _cyclicBufferPos) ?
|
||||
(_cyclicBufferPos - delta) :
|
||||
(_cyclicBufferPos - delta + _cyclicBufferSize);
|
||||
pair = son + (cyclicPos << 1);
|
||||
if (len != lenLimit)
|
||||
{
|
||||
if (pb[len] < cur[len])
|
||||
{
|
||||
*ptr1 = curMatch;
|
||||
ptr1 = pair+1;
|
||||
curMatch = *ptr1;
|
||||
len1 = len;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptr0 = curMatch;
|
||||
ptr0 = pair;
|
||||
curMatch = *ptr0;
|
||||
len0 = len;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptr1 = pair[0];
|
||||
*ptr0 = pair[1];
|
||||
return;
|
||||
}
|
||||
}
|
||||
*ptr0 = *ptr1 = 0;
|
||||
}
|
||||
|
||||
#ifdef GENERIC_INPUT
|
||||
// for memory input size is always less than kMaxValForNormalize
|
||||
static void Normalize(void)
|
||||
{
|
||||
unsigned subValue;
|
||||
unsigned* items;
|
||||
unsigned i,numItems;
|
||||
subValue = _pos - _cyclicBufferSize;
|
||||
items = _hash;
|
||||
numItems = (kHashSizeSum + _cyclicBufferSize*2);
|
||||
for (i=0;i<numItems;i++)
|
||||
{
|
||||
unsigned value;
|
||||
value = items[i];
|
||||
if (value <= subValue)
|
||||
value = 0;
|
||||
else
|
||||
value -= subValue;
|
||||
items[i] = value;
|
||||
}
|
||||
ReduceOffsets(subValue);
|
||||
unsigned subValue;
|
||||
unsigned* items;
|
||||
unsigned i,numItems;
|
||||
subValue = _pos - _cyclicBufferSize;
|
||||
items = _hash;
|
||||
numItems = (kHashSizeSum + _cyclicBufferSize*2);
|
||||
for (i=0;i<numItems;i++)
|
||||
{
|
||||
unsigned value;
|
||||
value = items[i];
|
||||
if (value <= subValue)
|
||||
value = 0;
|
||||
else
|
||||
value -= subValue;
|
||||
items[i] = value;
|
||||
}
|
||||
ReduceOffsets(subValue);
|
||||
}
|
||||
#endif
|
||||
|
||||
void MatchFinder_MovePos(void)
|
||||
{
|
||||
if (++_cyclicBufferPos == _cyclicBufferSize)
|
||||
_cyclicBufferPos = 0;
|
||||
LZInWindow_MovePos();
|
||||
if (++_cyclicBufferPos == _cyclicBufferSize)
|
||||
_cyclicBufferPos = 0;
|
||||
LZInWindow_MovePos();
|
||||
#ifdef GENERIC_INPUT
|
||||
if (_pos == kMaxValForNormalize)
|
||||
Normalize();
|
||||
if (_pos == kMaxValForNormalize)
|
||||
Normalize();
|
||||
#endif
|
||||
}
|
||||
|
@@ -10,182 +10,182 @@ static unsigned PriceTable[kBitModelTotal >> kNumMoveReducingBits];
|
||||
|
||||
void RangeEncoder_Init(void)
|
||||
{
|
||||
int i;
|
||||
unsigned start,end,j;
|
||||
low = 0;
|
||||
range = 0xFFFFFFFF;
|
||||
_cacheSize = 1;
|
||||
_cache = 0;
|
||||
/* init price table */
|
||||
int i;
|
||||
unsigned start,end,j;
|
||||
low = 0;
|
||||
range = 0xFFFFFFFF;
|
||||
_cacheSize = 1;
|
||||
_cache = 0;
|
||||
/* init price table */
|
||||
#define kNumBits (kNumBitModelTotalBits - kNumMoveReducingBits)
|
||||
for (i=kNumBits;i--;)
|
||||
{
|
||||
start = 1 << (kNumBits - i - 1);
|
||||
end = 1 << (kNumBits - i);
|
||||
for (j=start;j<end;j++)
|
||||
PriceTable[j] = (i<<kNumBitPriceShiftBits) +
|
||||
(((end-j)<<kNumBitPriceShiftBits) >> (kNumBits - i - 1));
|
||||
}
|
||||
for (i=kNumBits;i--;)
|
||||
{
|
||||
start = 1 << (kNumBits - i - 1);
|
||||
end = 1 << (kNumBits - i);
|
||||
for (j=start;j<end;j++)
|
||||
PriceTable[j] = (i<<kNumBitPriceShiftBits) +
|
||||
(((end-j)<<kNumBitPriceShiftBits) >> (kNumBits - i - 1));
|
||||
}
|
||||
#undef kNumBits
|
||||
}
|
||||
|
||||
void RangeEncoder_ShiftLow(void)
|
||||
{
|
||||
if ((unsigned)low < 0xFF000000U || (int)(low>>32))
|
||||
{
|
||||
byte temp = _cache;
|
||||
do
|
||||
{
|
||||
*curout++ = (byte)(temp + (byte)(low>>32));
|
||||
temp = 0xFF;
|
||||
} while (--_cacheSize);
|
||||
_cache = (byte)((unsigned)low>>24);
|
||||
}
|
||||
_cacheSize++;
|
||||
low = (unsigned)low << 8;
|
||||
if ((unsigned)low < 0xFF000000U || (int)(low>>32))
|
||||
{
|
||||
byte temp = _cache;
|
||||
do
|
||||
{
|
||||
*curout++ = (byte)(temp + (byte)(low>>32));
|
||||
temp = 0xFF;
|
||||
} while (--_cacheSize);
|
||||
_cache = (byte)((unsigned)low>>24);
|
||||
}
|
||||
_cacheSize++;
|
||||
low = (unsigned)low << 8;
|
||||
}
|
||||
|
||||
void RangeEncoder_FlushData(void)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<5;i++)
|
||||
RangeEncoder_ShiftLow();
|
||||
int i;
|
||||
for (i=0;i<5;i++)
|
||||
RangeEncoder_ShiftLow();
|
||||
}
|
||||
|
||||
void RangeEncoder_EncodeDirectBits(unsigned value,int numTotalBits)
|
||||
{
|
||||
int i;
|
||||
for (i=numTotalBits;i--;)
|
||||
{
|
||||
range >>= 1;
|
||||
if (((value >> i) & 1) == 1)
|
||||
low += range;
|
||||
if (range < kTopValue)
|
||||
{
|
||||
range <<= 8;
|
||||
RangeEncoder_ShiftLow();
|
||||
}
|
||||
}
|
||||
int i;
|
||||
for (i=numTotalBits;i--;)
|
||||
{
|
||||
range >>= 1;
|
||||
if (((value >> i) & 1) == 1)
|
||||
low += range;
|
||||
if (range < kTopValue)
|
||||
{
|
||||
range <<= 8;
|
||||
RangeEncoder_ShiftLow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CMyBitEncoder_Encode(CMyBitEncoder* e,unsigned symbol)
|
||||
{
|
||||
unsigned newBound;
|
||||
newBound = (range >> kNumBitModelTotalBits) * *e;
|
||||
if (symbol == 0)
|
||||
{
|
||||
range = newBound;
|
||||
*e += (kBitModelTotal - *e) >> kNumMoveBits;
|
||||
}
|
||||
else
|
||||
{
|
||||
low += newBound;
|
||||
range -= newBound;
|
||||
*e -= *e >> kNumMoveBits;
|
||||
}
|
||||
if (range < kTopValue)
|
||||
{
|
||||
range <<= 8;
|
||||
RangeEncoder_ShiftLow();
|
||||
}
|
||||
unsigned newBound;
|
||||
newBound = (range >> kNumBitModelTotalBits) * *e;
|
||||
if (symbol == 0)
|
||||
{
|
||||
range = newBound;
|
||||
*e += (kBitModelTotal - *e) >> kNumMoveBits;
|
||||
}
|
||||
else
|
||||
{
|
||||
low += newBound;
|
||||
range -= newBound;
|
||||
*e -= *e >> kNumMoveBits;
|
||||
}
|
||||
if (range < kTopValue)
|
||||
{
|
||||
range <<= 8;
|
||||
RangeEncoder_ShiftLow();
|
||||
}
|
||||
}
|
||||
|
||||
unsigned CMyBitEncoder_GetPrice(CMyBitEncoder* e, unsigned symbol)
|
||||
{
|
||||
return PriceTable[(((*e-symbol)^((-(int)symbol))) & (kBitModelTotal-1)) >> kNumMoveReducingBits];
|
||||
return PriceTable[(((*e-symbol)^((-(int)symbol))) & (kBitModelTotal-1)) >> kNumMoveReducingBits];
|
||||
}
|
||||
unsigned CMyBitEncoder_GetPrice0(CMyBitEncoder* e)
|
||||
{
|
||||
return PriceTable[*e >> kNumMoveReducingBits];
|
||||
return PriceTable[*e >> kNumMoveReducingBits];
|
||||
}
|
||||
unsigned CMyBitEncoder_GetPrice1(CMyBitEncoder* e)
|
||||
{
|
||||
return PriceTable[(kBitModelTotal - *e) >> kNumMoveReducingBits];
|
||||
return PriceTable[(kBitModelTotal - *e) >> kNumMoveReducingBits];
|
||||
}
|
||||
|
||||
void CBitTreeEncoder_Init(NRangeCoder_CBitTreeEncoder*e,int numBitLevels)
|
||||
{
|
||||
unsigned i;
|
||||
e->numBitLevels = numBitLevels;
|
||||
for (i=1;i<((unsigned)1<<numBitLevels);i++)
|
||||
CMyBitEncoder_Init(e->Models[i]);
|
||||
unsigned i;
|
||||
e->numBitLevels = numBitLevels;
|
||||
for (i=1;i<((unsigned)1<<numBitLevels);i++)
|
||||
CMyBitEncoder_Init(e->Models[i]);
|
||||
}
|
||||
void CBitTreeEncoder_Encode(NRangeCoder_CBitTreeEncoder*e,unsigned symbol)
|
||||
{
|
||||
unsigned modelIndex = 1;
|
||||
int bitIndex;
|
||||
unsigned bit;
|
||||
for (bitIndex = e->numBitLevels; bitIndex--;)
|
||||
{
|
||||
bit = (symbol >> bitIndex) & 1;
|
||||
CMyBitEncoder_Encode(&e->Models[modelIndex],bit);
|
||||
modelIndex = (modelIndex << 1) | bit;
|
||||
}
|
||||
unsigned modelIndex = 1;
|
||||
int bitIndex;
|
||||
unsigned bit;
|
||||
for (bitIndex = e->numBitLevels; bitIndex--;)
|
||||
{
|
||||
bit = (symbol >> bitIndex) & 1;
|
||||
CMyBitEncoder_Encode(&e->Models[modelIndex],bit);
|
||||
modelIndex = (modelIndex << 1) | bit;
|
||||
}
|
||||
}
|
||||
void CBitTreeEncoder_ReverseEncode(NRangeCoder_CBitTreeEncoder*e,unsigned symbol)
|
||||
{
|
||||
unsigned modelIndex = 1;
|
||||
int i;
|
||||
unsigned bit;
|
||||
for (i=0;i<e->numBitLevels;i++)
|
||||
{
|
||||
bit = symbol & 1;
|
||||
CMyBitEncoder_Encode(&e->Models[modelIndex],bit);
|
||||
modelIndex = (modelIndex << 1) | bit;
|
||||
symbol >>= 1;
|
||||
}
|
||||
unsigned modelIndex = 1;
|
||||
int i;
|
||||
unsigned bit;
|
||||
for (i=0;i<e->numBitLevels;i++)
|
||||
{
|
||||
bit = symbol & 1;
|
||||
CMyBitEncoder_Encode(&e->Models[modelIndex],bit);
|
||||
modelIndex = (modelIndex << 1) | bit;
|
||||
symbol >>= 1;
|
||||
}
|
||||
}
|
||||
unsigned CBitTreeEncoder_GetPrice(NRangeCoder_CBitTreeEncoder*e,unsigned symbol)
|
||||
{
|
||||
unsigned price = 0;
|
||||
symbol |= (1 << e->numBitLevels);
|
||||
while (symbol != 1)
|
||||
{
|
||||
price += CMyBitEncoder_GetPrice(&e->Models[symbol>>1],symbol&1);
|
||||
symbol >>= 1;
|
||||
}
|
||||
return price;
|
||||
unsigned price = 0;
|
||||
symbol |= (1 << e->numBitLevels);
|
||||
while (symbol != 1)
|
||||
{
|
||||
price += CMyBitEncoder_GetPrice(&e->Models[symbol>>1],symbol&1);
|
||||
symbol >>= 1;
|
||||
}
|
||||
return price;
|
||||
}
|
||||
unsigned CBitTreeEncoder_ReverseGetPrice(NRangeCoder_CBitTreeEncoder*e,unsigned symbol)
|
||||
{
|
||||
unsigned price=0;
|
||||
unsigned modelIndex=1;
|
||||
int i;
|
||||
unsigned bit;
|
||||
for (i=e->numBitLevels;i;i--)
|
||||
{
|
||||
bit = symbol&1;
|
||||
symbol >>= 1;
|
||||
price += CMyBitEncoder_GetPrice(&e->Models[modelIndex],bit);
|
||||
modelIndex = (modelIndex<<1)|bit;
|
||||
}
|
||||
return price;
|
||||
unsigned price=0;
|
||||
unsigned modelIndex=1;
|
||||
int i;
|
||||
unsigned bit;
|
||||
for (i=e->numBitLevels;i;i--)
|
||||
{
|
||||
bit = symbol&1;
|
||||
symbol >>= 1;
|
||||
price += CMyBitEncoder_GetPrice(&e->Models[modelIndex],bit);
|
||||
modelIndex = (modelIndex<<1)|bit;
|
||||
}
|
||||
return price;
|
||||
}
|
||||
unsigned ReverseBitTreeGetPrice(CMyBitEncoder*Models,unsigned NumBitLevels,unsigned symbol)
|
||||
{
|
||||
unsigned price=0;
|
||||
unsigned modelIndex=1;
|
||||
unsigned bit;
|
||||
int i;
|
||||
for (i=NumBitLevels;i;i--)
|
||||
{
|
||||
bit = symbol & 1;
|
||||
symbol >>= 1;
|
||||
price += CMyBitEncoder_GetPrice(Models+modelIndex,bit);
|
||||
modelIndex = (modelIndex<<1)|bit;
|
||||
}
|
||||
return price;
|
||||
unsigned price=0;
|
||||
unsigned modelIndex=1;
|
||||
unsigned bit;
|
||||
int i;
|
||||
for (i=NumBitLevels;i;i--)
|
||||
{
|
||||
bit = symbol & 1;
|
||||
symbol >>= 1;
|
||||
price += CMyBitEncoder_GetPrice(Models+modelIndex,bit);
|
||||
modelIndex = (modelIndex<<1)|bit;
|
||||
}
|
||||
return price;
|
||||
}
|
||||
void ReverseBitTreeEncode(CMyBitEncoder*Models,int NumBitLevels,unsigned symbol)
|
||||
{
|
||||
unsigned modelIndex = 1;
|
||||
int i;
|
||||
unsigned bit;
|
||||
for (i=0;i<NumBitLevels;i++)
|
||||
{
|
||||
bit = symbol & 1;
|
||||
CMyBitEncoder_Encode(Models+modelIndex,bit);
|
||||
modelIndex = (modelIndex<<1)|bit;
|
||||
symbol >>= 1;
|
||||
}
|
||||
unsigned modelIndex = 1;
|
||||
int i;
|
||||
unsigned bit;
|
||||
for (i=0;i<NumBitLevels;i++)
|
||||
{
|
||||
bit = symbol & 1;
|
||||
CMyBitEncoder_Encode(Models+modelIndex,bit);
|
||||
modelIndex = (modelIndex<<1)|bit;
|
||||
symbol >>= 1;
|
||||
}
|
||||
}
|
||||
|
@@ -2,8 +2,8 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CMyBitEncoder Models[1<<8];
|
||||
int numBitLevels;
|
||||
CMyBitEncoder Models[1<<8];
|
||||
int numBitLevels;
|
||||
} NRangeCoder_CBitTreeEncoder;
|
||||
|
||||
extern void CBitTreeEncoder_Init(NRangeCoder_CBitTreeEncoder*e,int numBitLevels);
|
||||
|
@@ -1,132 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="lzmapack" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=lzmapack - 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 "lzmapack.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 "lzmapack.mak" CFG="lzmapack - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "lzmapack - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "lzmapack - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "lzmapack - 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 ""
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O1 /Ob1 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /Zl /FD /c
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "lzmapack - 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 ""
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "lzmapack - Win32 Release"
|
||||
# Name "lzmapack - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LZMAEncoder.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MatchFinder.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\RangeCoder.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\lzma.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LZMAEncoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MatchFinder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\RangeCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\RangeCoderBit.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\RangeCoderBitTree.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
@@ -1,44 +0,0 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "lzmapack"=.\lzmapack.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "lzmatest"=.\lzmatest\lzmatest.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name lzmapack
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
@@ -1,102 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="lzmatest" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=lzmatest - 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 "lzmatest.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 "lzmatest.mak" CFG="lzmatest - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "lzmatest - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "lzmatest - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "lzmatest - 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 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# 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 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 /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib ..\lzmapack.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "lzmatest - 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 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# 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 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 /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib ..\lzmapack.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "lzmatest - Win32 Release"
|
||||
# Name "lzmatest - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\main.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
@@ -1,31 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
extern "C" __stdcall lzma_set_dict_size(unsigned logdictsize);
|
||||
extern "C" __stdcall lzma_compress(
|
||||
const void* source,
|
||||
void* destination,
|
||||
unsigned length,
|
||||
void* workmem);
|
||||
|
||||
int main()
|
||||
{
|
||||
FILE* f;
|
||||
f = fopen("test.in","rb");
|
||||
fseek(f,0,SEEK_END);
|
||||
unsigned inlen = ftell(f);
|
||||
fseek(f,0,SEEK_SET);
|
||||
void* in = VirtualAlloc(NULL,inlen,MEM_COMMIT,PAGE_READWRITE);
|
||||
void* out = VirtualAlloc(NULL,inlen,MEM_COMMIT,PAGE_READWRITE);
|
||||
fread(in,1,inlen,f);
|
||||
fclose(f);
|
||||
unsigned logdictsize,dictsize;
|
||||
for (logdictsize=0,dictsize=1;dictsize<inlen && logdictsize<=28;logdictsize++,dictsize<<=1) ;
|
||||
lzma_set_dict_size(logdictsize);
|
||||
void* work = VirtualAlloc(NULL,dictsize*19/2+0x509000,MEM_COMMIT,PAGE_READWRITE);
|
||||
unsigned outlen = lzma_compress(in,out,inlen,work);
|
||||
printf("%d -> %d\n",inlen,outlen);
|
||||
f = fopen("test.out","wb");
|
||||
fwrite(out,1,outlen,f);
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
@@ -1,44 +1,33 @@
|
||||
<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> C <20><><EFBFBD><EFBFBD>, diamond'<27><>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
LZMA-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LZMA SDK 4.32 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> copyright (c) 1999-2005
|
||||
Igor Pavlov, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> http://www.7-zip.org/sdk.html,
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> C++,C# <EFBFBD> Java <EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> LZMA-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> ANSI-C, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 7z.
|
||||
This directory contains a simplified version of the LZMA packer rewritten in C by me, diamond.
|
||||
The original LZMA SDK 4.32 is copyright (c) 1999-2005
|
||||
Igor Pavlov, can be obtained from the page http://www.7-zip.org/sdk.html,
|
||||
in particular, it contains versions of the source code in C++, C# and Java for packing and
|
||||
unpacking, the LZMA unpacking code in ANSI-C, a description of the 7z format.
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
bt4 match-finder, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>), <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. (<28><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LZMA
|
||||
SDK.) <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> VC++, <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> ANSI C <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> VC-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #pragma intrinsic(memcpy), <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> memcpy <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD> - <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> C run-time library. (<28><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> MtApPack, <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
RTL <20> <20> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD> Windows, <20> <20><><EFBFBD> Kolibri.)
|
||||
This version is not thread-safe (!), supports only bt4 match-finder,
|
||||
some packing parameters are fixed (however, this can be easily modified if necessary),
|
||||
only data compression in RAM is supported. (These restrictions are not in the original LZMA SDK.)
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LZMA SDK, <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>) GNU LGPL <EFBFBD><EFBFBD><EFBFBD>
|
||||
GNU CPL. (<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> SDK <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.)
|
||||
This library, like the original LZMA SDK, can be used in other
|
||||
programs under one of the licenses (your choice) GNU LGPL or
|
||||
GNU CPL. (The original SDK also allows the original library to be used without restrictions,
|
||||
provided that the object files are used without modifying the code; this version does not.)
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20> C++-<2D><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>:
|
||||
extern "C" __stdcall void lzma_set_dict_size(unsigned logdictsize);
|
||||
extern "C" __stdcall unsigned lzma_compress(
|
||||
const void* source,
|
||||
void* destination,
|
||||
unsigned length,
|
||||
void* workmem);
|
||||
Two functions are exported: in C++ the declaration looks like this:
|
||||
extern "C" __stdcall void lzma_set_dict_size(unsigned logdictsize);
|
||||
extern "C" __stdcall unsigned lzma_compress(
|
||||
const void* source,
|
||||
void* destination,
|
||||
unsigned length,
|
||||
void* workmem, int is_kerpack)
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
(<28>.<2E>. dictsize == (1<<logdictsize)). <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> 256Mb,
|
||||
<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> logdictsize <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 28. <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
||||
<EFBFBD>.<2E>. <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 12345 <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 16384 <20><><EFBFBD><EFBFBD> <20>
|
||||
<EFBFBD><EFBFBD> 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. source - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, destination - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
||||
length - <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, workmem - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> 0x509000+dictsize*19/2
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0x10 + length*9/8 <20><><EFBFBD><EFBFBD>.
|
||||
Before packing, the dictionary size of the first of these functions, taking the base 2 logarithm of this value,
|
||||
(i.e. dictsize == (1<<logdictsize)). The maximum buffer size is 256Mb,
|
||||
so the logdictsize parameter should not exceed 28. If the buffer size is larger than the input data size,
|
||||
the result does not depend on the buffer size, i.e. for data of 12345 bytes,
|
||||
the results of compression with a 16384-byte buffer and with a 1 megabyte buffer are the same.
|
||||
Packing is performed by calling the second of these functions;
|
||||
source is a pointer to the input data, destination is a pointer to the buffer for packed data,
|
||||
length is the length of the input data, workmem is a pointer to temporary memory
|
||||
used by the packer; at least 0x509000+dictsize*19/2 bytes must be allocated.
|
||||
For packed data, 0x10 + length*9/8 bytes is enough in the worst case.
|
||||
|
Reference in New Issue
Block a user