/* LzFind.c -- Match finder for LZ algorithms\r
-2017-06-10 : Igor Pavlov : Public domain */\r
+2018-07-08 : Igor Pavlov : Public domain */\r
\r
#include "Precomp.h"\r
\r
p->streamEndWasReached = 1;\r
return;\r
}\r
- \r
+\r
for (;;)\r
{\r
Byte *dest = p->buffer + (p->streamPos - p->pos);\r
\r
void MatchFinder_Construct(CMatchFinder *p)\r
{\r
- UInt32 i;\r
+ unsigned i;\r
p->bufferBase = NULL;\r
p->directInput = 0;\r
p->hash = NULL;\r
\r
for (i = 0; i < 256; i++)\r
{\r
- UInt32 r = i;\r
+ UInt32 r = (UInt32)i;\r
unsigned j;\r
for (j = 0; j < 8; j++)\r
r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1)));\r
ISzAllocPtr alloc)\r
{\r
UInt32 sizeReserv;\r
- \r
+\r
if (historySize > kMaxHistorySize)\r
{\r
MatchFinder_Free(p, alloc);\r
return 0;\r
}\r
- \r
+\r
sizeReserv = historySize >> 1;\r
if (historySize >= ((UInt32)3 << 30)) sizeReserv = historySize >> 3;\r
else if (historySize >= ((UInt32)2 << 30)) sizeReserv = historySize >> 2;\r
- \r
+\r
sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19);\r
\r
p->keepSizeBefore = historySize + keepAddBufferBefore + 1;\r
p->keepSizeAfter = matchMaxLen + keepAddBufferAfter;\r
- \r
+\r
/* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */\r
- \r
+\r
if (LzInWindow_Create(p, sizeReserv, alloc))\r
{\r
UInt32 newCyclicBufferSize = historySize + 1;\r
p->historySize = historySize;\r
p->hashSizeSum = hs;\r
p->cyclicBufferSize = newCyclicBufferSize;\r
- \r
+\r
numSons = newCyclicBufferSize;\r
if (p->btMode)\r
numSons <<= 1;\r
\r
if (p->hash && p->numRefs == newSize)\r
return 1;\r
- \r
+\r
MatchFinder_FreeThisClassMemory(p, alloc);\r
p->numRefs = newSize;\r
p->hash = AllocRefs(newSize, alloc);\r
- \r
+\r
if (p->hash)\r
{\r
p->son = p->hash + p->hashSizeSum;\r
{\r
UInt32 limit = kMaxValForNormalize - p->pos;\r
UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos;\r
- \r
+\r
if (limit2 < limit)\r
limit = limit2;\r
limit2 = p->streamPos - p->pos;\r
- \r
+\r
if (limit2 <= p->keepSizeAfter)\r
{\r
if (limit2 > 0)\r
}\r
else\r
limit2 -= p->keepSizeAfter;\r
- \r
+\r
if (limit2 < limit)\r
limit = limit2;\r
- \r
+\r
{\r
UInt32 lenLimit = p->streamPos - p->pos;\r
if (lenLimit > p->matchMaxLen)\r
p->streamPos = p->cyclicBufferSize;\r
p->result = SZ_OK;\r
p->streamEndWasReached = 0;\r
- \r
+\r
if (readData)\r
MatchFinder_ReadBlock(p);\r
- \r
+\r
MatchFinder_SetLimits(p);\r
}\r
\r
MatchFinder_Init_3(p, True);\r
}\r
\r
- \r
+\r
static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)\r
{\r
return (p->pos - p->historySize - 1) & kNormalizeMask;\r
MatchFinder_ReduceOffsets(p, subValue);\r
}\r
\r
+\r
+MY_NO_INLINE\r
static void MatchFinder_CheckLimits(CMatchFinder *p)\r
{\r
if (p->pos == kMaxValForNormalize)\r
MatchFinder_SetLimits(p);\r
}\r
\r
-static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,\r
+\r
+/*\r
+ (lenLimit > maxLen)\r
+*/\r
+MY_FORCE_INLINE\r
+static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,\r
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,\r
- UInt32 *distances, UInt32 maxLen)\r
+ UInt32 *distances, unsigned maxLen)\r
{\r
+ /*\r
son[_cyclicBufferPos] = curMatch;\r
for (;;)\r
{\r
break;\r
if (maxLen < len)\r
{\r
- *distances++ = maxLen = len;\r
+ maxLen = len;\r
+ *distances++ = len;\r
*distances++ = delta - 1;\r
if (len == lenLimit)\r
return distances;\r
}\r
}\r
}\r
+ */\r
+\r
+ const Byte *lim = cur + lenLimit;\r
+ son[_cyclicBufferPos] = curMatch;\r
+ do\r
+ {\r
+ UInt32 delta = pos - curMatch;\r
+ if (delta >= _cyclicBufferSize)\r
+ break;\r
+ {\r
+ ptrdiff_t diff;\r
+ curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];\r
+ diff = (ptrdiff_t)0 - delta;\r
+ if (cur[maxLen] == cur[maxLen + diff])\r
+ {\r
+ const Byte *c = cur;\r
+ while (*c == c[diff])\r
+ {\r
+ if (++c == lim)\r
+ {\r
+ distances[0] = (UInt32)(lim - cur);\r
+ distances[1] = delta - 1;\r
+ return distances + 2;\r
+ }\r
+ }\r
+ {\r
+ unsigned len = (unsigned)(c - cur);\r
+ if (maxLen < len)\r
+ {\r
+ maxLen = len;\r
+ distances[0] = (UInt32)len;\r
+ distances[1] = delta - 1;\r
+ distances += 2;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ while (--cutValue);\r
+\r
+ return distances;\r
}\r
\r
+\r
+MY_FORCE_INLINE\r
UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,\r
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,\r
UInt32 *distances, UInt32 maxLen)\r
{\r
- CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;\r
- CLzRef *ptr1 = son + (_cyclicBufferPos << 1);\r
- UInt32 len0 = 0, len1 = 0;\r
+ CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1;\r
+ CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1);\r
+ unsigned len0 = 0, len1 = 0;\r
for (;;)\r
{\r
UInt32 delta = pos - curMatch;\r
return distances;\r
}\r
{\r
- CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);\r
+ CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);\r
const Byte *pb = cur - delta;\r
- UInt32 len = (len0 < len1 ? len0 : len1);\r
+ unsigned len = (len0 < len1 ? len0 : len1);\r
+ UInt32 pair0 = pair[0];\r
if (pb[len] == cur[len])\r
{\r
if (++len != lenLimit && pb[len] == cur[len])\r
break;\r
if (maxLen < len)\r
{\r
- *distances++ = maxLen = len;\r
+ maxLen = (UInt32)len;\r
+ *distances++ = (UInt32)len;\r
*distances++ = delta - 1;\r
if (len == lenLimit)\r
{\r
- *ptr1 = pair[0];\r
+ *ptr1 = pair0;\r
*ptr0 = pair[1];\r
return distances;\r
}\r
static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,\r
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)\r
{\r
- CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;\r
- CLzRef *ptr1 = son + (_cyclicBufferPos << 1);\r
- UInt32 len0 = 0, len1 = 0;\r
+ CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1;\r
+ CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1);\r
+ unsigned len0 = 0, len1 = 0;\r
for (;;)\r
{\r
UInt32 delta = pos - curMatch;\r
return;\r
}\r
{\r
- CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);\r
+ CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);\r
const Byte *pb = cur - delta;\r
- UInt32 len = (len0 < len1 ? len0 : len1);\r
+ unsigned len = (len0 < len1 ? len0 : len1);\r
if (pb[len] == cur[len])\r
{\r
while (++len != lenLimit)\r
p->buffer++; \\r
if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);\r
\r
-#define MOVE_POS_RET MOVE_POS return offset;\r
+#define MOVE_POS_RET MOVE_POS return (UInt32)offset;\r
\r
static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }\r
\r
#define GET_MATCHES_HEADER2(minLen, ret_op) \\r
- UInt32 lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \\r
- lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \\r
+ unsigned lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \\r
+ lenLimit = (unsigned)p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \\r
cur = p->buffer;\r
\r
#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0)\r
#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue\r
\r
#define GET_MATCHES_FOOTER(offset, maxLen) \\r
- offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \\r
- distances + offset, maxLen) - distances); MOVE_POS_RET;\r
+ offset = (unsigned)(GetMatchesSpec1((UInt32)lenLimit, curMatch, MF_PARAMS(p), \\r
+ distances + offset, (UInt32)maxLen) - distances); MOVE_POS_RET;\r
\r
#define SKIP_FOOTER \\r
- SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;\r
+ SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;\r
\r
#define UPDATE_maxLen { \\r
ptrdiff_t diff = (ptrdiff_t)0 - d2; \\r
const Byte *c = cur + maxLen; \\r
const Byte *lim = cur + lenLimit; \\r
for (; c != lim; c++) if (*(c + diff) != *c) break; \\r
- maxLen = (UInt32)(c - cur); }\r
+ maxLen = (unsigned)(c - cur); }\r
\r
static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
{\r
- UInt32 offset;\r
+ unsigned offset;\r
GET_MATCHES_HEADER(2)\r
HASH2_CALC;\r
curMatch = p->hash[hv];\r
\r
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
{\r
- UInt32 offset;\r
+ unsigned offset;\r
GET_MATCHES_HEADER(3)\r
HASH_ZIP_CALC;\r
curMatch = p->hash[hv];\r
\r
static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
{\r
- UInt32 h2, d2, maxLen, offset, pos;\r
+ UInt32 h2, d2, pos;\r
+ unsigned maxLen, offset;\r
UInt32 *hash;\r
GET_MATCHES_HEADER(3)\r
\r
d2 = pos - hash[h2];\r
\r
curMatch = (hash + kFix3HashSize)[hv];\r
- \r
+\r
hash[h2] = pos;\r
(hash + kFix3HashSize)[hv] = pos;\r
\r
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)\r
{\r
UPDATE_maxLen\r
- distances[0] = maxLen;\r
+ distances[0] = (UInt32)maxLen;\r
distances[1] = d2 - 1;\r
offset = 2;\r
if (maxLen == lenLimit)\r
{\r
- SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));\r
+ SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p));\r
MOVE_POS_RET;\r
}\r
}\r
- \r
+\r
GET_MATCHES_FOOTER(offset, maxLen)\r
}\r
\r
static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
{\r
- UInt32 h2, h3, d2, d3, maxLen, offset, pos;\r
+ UInt32 h2, h3, d2, d3, pos;\r
+ unsigned maxLen, offset;\r
UInt32 *hash;\r
GET_MATCHES_HEADER(4)\r
\r
hash = p->hash;\r
pos = p->pos;\r
\r
- d2 = pos - hash[ h2];\r
+ d2 = pos - hash [h2];\r
d3 = pos - (hash + kFix3HashSize)[h3];\r
\r
curMatch = (hash + kFix4HashSize)[hv];\r
\r
- hash[ h2] = pos;\r
+ hash [h2] = pos;\r
(hash + kFix3HashSize)[h3] = pos;\r
(hash + kFix4HashSize)[hv] = pos;\r
\r
maxLen = 0;\r
offset = 0;\r
- \r
+\r
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)\r
{\r
- distances[0] = maxLen = 2;\r
+ maxLen = 2;\r
+ distances[0] = 2;\r
distances[1] = d2 - 1;\r
offset = 2;\r
}\r
- \r
+\r
if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur)\r
{\r
maxLen = 3;\r
offset += 2;\r
d2 = d3;\r
}\r
- \r
+\r
if (offset != 0)\r
{\r
UPDATE_maxLen\r
- distances[(size_t)offset - 2] = maxLen;\r
+ distances[(size_t)offset - 2] = (UInt32)maxLen;\r
if (maxLen == lenLimit)\r
{\r
- SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));\r
+ SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p));\r
MOVE_POS_RET;\r
}\r
}\r
- \r
+\r
if (maxLen < 3)\r
maxLen = 3;\r
- \r
+\r
GET_MATCHES_FOOTER(offset, maxLen)\r
}\r
\r
hash = p->hash;\r
pos = p->pos;\r
\r
- d2 = pos - hash[ h2];\r
+ d2 = pos - hash [h2];\r
d3 = pos - (hash + kFix3HashSize)[h3];\r
d4 = pos - (hash + kFix4HashSize)[h4];\r
\r
curMatch = (hash + kFix5HashSize)[hv];\r
\r
- hash[ h2] = pos;\r
+ hash [h2] = pos;\r
(hash + kFix3HashSize)[h3] = pos;\r
(hash + kFix4HashSize)[h4] = pos;\r
(hash + kFix5HashSize)[hv] = pos;\r
offset = 2;\r
d2 = d3;\r
}\r
- \r
+\r
if (d2 != d4 && d4 < p->cyclicBufferSize\r
&& *(cur - d4) == *cur\r
&& *(cur - d4 + 3) == *(cur + 3))\r
offset += 2;\r
d2 = d4;\r
}\r
- \r
+\r
if (offset != 0)\r
{\r
UPDATE_maxLen\r
\r
if (maxLen < 4)\r
maxLen = 4;\r
- \r
+\r
GET_MATCHES_FOOTER(offset, maxLen)\r
}\r
*/\r
\r
static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
{\r
- UInt32 h2, h3, d2, d3, maxLen, offset, pos;\r
+ UInt32 h2, h3, d2, d3, pos;\r
+ unsigned maxLen, offset;\r
UInt32 *hash;\r
GET_MATCHES_HEADER(4)\r
\r
\r
hash = p->hash;\r
pos = p->pos;\r
- \r
- d2 = pos - hash[ h2];\r
+\r
+ d2 = pos - hash [h2];\r
d3 = pos - (hash + kFix3HashSize)[h3];\r
- \r
curMatch = (hash + kFix4HashSize)[hv];\r
\r
- hash[ h2] = pos;\r
+ hash [h2] = pos;\r
(hash + kFix3HashSize)[h3] = pos;\r
(hash + kFix4HashSize)[hv] = pos;\r
\r
\r
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)\r
{\r
- distances[0] = maxLen = 2;\r
+ maxLen = 2;\r
+ distances[0] = 2;\r
distances[1] = d2 - 1;\r
offset = 2;\r
}\r
- \r
+\r
if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur)\r
{\r
maxLen = 3;\r
offset += 2;\r
d2 = d3;\r
}\r
- \r
+\r
if (offset != 0)\r
{\r
UPDATE_maxLen\r
- distances[(size_t)offset - 2] = maxLen;\r
+ distances[(size_t)offset - 2] = (UInt32)maxLen;\r
if (maxLen == lenLimit)\r
{\r
p->son[p->cyclicBufferPos] = curMatch;\r
MOVE_POS_RET;\r
}\r
}\r
- \r
+\r
if (maxLen < 3)\r
maxLen = 3;\r
\r
- offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),\r
+ offset = (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),\r
distances + offset, maxLen) - (distances));\r
MOVE_POS_RET\r
}\r
\r
hash = p->hash;\r
pos = p->pos;\r
- \r
- d2 = pos - hash[ h2];\r
+\r
+ d2 = pos - hash [h2];\r
d3 = pos - (hash + kFix3HashSize)[h3];\r
d4 = pos - (hash + kFix4HashSize)[h4];\r
\r
curMatch = (hash + kFix5HashSize)[hv];\r
\r
- hash[ h2] = pos;\r
+ hash [h2] = pos;\r
(hash + kFix3HashSize)[h3] = pos;\r
(hash + kFix4HashSize)[h4] = pos;\r
(hash + kFix5HashSize)[hv] = pos;\r
offset = 2;\r
d2 = d3;\r
}\r
- \r
+\r
if (d2 != d4 && d4 < p->cyclicBufferSize\r
&& *(cur - d4) == *cur\r
&& *(cur - d4 + 3) == *(cur + 3))\r
offset += 2;\r
d2 = d4;\r
}\r
- \r
+\r
if (offset != 0)\r
{\r
UPDATE_maxLen\r
MOVE_POS_RET;\r
}\r
}\r
- \r
+\r
if (maxLen < 4)\r
maxLen = 4;\r
\r
\r
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
{\r
- UInt32 offset;\r
+ unsigned offset;\r
GET_MATCHES_HEADER(3)\r
HASH_ZIP_CALC;\r
curMatch = p->hash[hv];\r
p->hash[hv] = p->pos;\r
- offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),\r
+ offset = (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),\r
distances, 2) - (distances));\r
MOVE_POS_RET\r
}\r
HASH4_CALC;\r
hash = p->hash;\r
curMatch = (hash + kFix4HashSize)[hv];\r
- hash[ h2] =\r
+ hash [h2] =\r
(hash + kFix3HashSize)[h3] =\r
(hash + kFix4HashSize)[hv] = p->pos;\r
SKIP_FOOTER\r
HASH5_CALC;\r
hash = p->hash;\r
curMatch = (hash + kFix5HashSize)[hv];\r
- hash[ h2] =\r
+ hash [h2] =\r
(hash + kFix3HashSize)[h3] =\r
(hash + kFix4HashSize)[h4] =\r
(hash + kFix5HashSize)[hv] = p->pos;\r
HASH4_CALC;\r
hash = p->hash;\r
curMatch = (hash + kFix4HashSize)[hv];\r
- hash[ h2] =\r
+ hash [h2] =\r
(hash + kFix3HashSize)[h3] =\r
(hash + kFix4HashSize)[hv] = p->pos;\r
p->son[p->cyclicBufferPos] = curMatch;\r
HASH5_CALC;\r
hash = p->hash;\r
curMatch = hash + kFix5HashSize)[hv];\r
- hash[ h2] =\r
+ hash [h2] =\r
(hash + kFix3HashSize)[h3] =\r
(hash + kFix4HashSize)[h4] =\r
(hash + kFix5HashSize)[hv] = p->pos;\r
/* LzmaEnc.c -- LZMA Encoder\r
-2018-04-29 : Igor Pavlov : Public domain */\r
+2019-01-10: Igor Pavlov : Public domain */\r
\r
#include "Precomp.h"\r
\r
#define kNumBitPriceShiftBits 4\r
#define kBitPrice (1 << kNumBitPriceShiftBits)\r
\r
+#define REP_LEN_COUNT 64\r
+\r
void LzmaEncProps_Init(CLzmaEncProps *p)\r
{\r
p->level = 5;\r
int level = p->level;\r
if (level < 0) level = 5;\r
p->level = level;\r
- \r
+\r
if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level <= 7 ? (1 << 25) : (1 << 26)));\r
if (p->dictSize > p->reduceSize)\r
{\r
if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1);\r
if (p->numHashBytes < 0) p->numHashBytes = 4;\r
if (p->mc == 0) p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1);\r
- \r
+\r
if (p->numThreads < 0)\r
p->numThreads =\r
#ifndef _7ZIP_ST\r
g_FastPos[0] = 0;\r
g_FastPos[1] = 1;\r
g_FastPos += 2;\r
- \r
+\r
for (slot = 2; slot < kNumLogBits * 2; slot++)\r
{\r
size_t k = ((size_t)1 << ((slot >> 1) - 1));\r
} COptimal;\r
\r
\r
-#define kNumOpts (1 << 12)\r
-#define kPackReserve (1 + kNumOpts * 2)\r
+// 18.06\r
+#define kNumOpts (1 << 11)\r
+#define kPackReserve (kNumOpts * 8)\r
+// #define kNumOpts (1 << 12)\r
+// #define kPackReserve (1 + kNumOpts * 2)\r
\r
#define kNumLenToPosStates 4\r
#define kNumPosSlotBits 6\r
typedef struct\r
{\r
unsigned tableSize;\r
- unsigned counters[LZMA_NUM_PB_STATES_MAX];\r
UInt32 prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal];\r
+ // UInt32 prices1[LZMA_NUM_PB_STATES_MAX][kLenNumLowSymbols * 2];\r
+ // UInt32 prices2[kLenNumSymbolsTotal];\r
} CLenPriceEnc;\r
\r
+#define GET_PRICE_LEN(p, posState, len) \\r
+ ((p)->prices[posState][(size_t)(len) - LZMA_MATCH_LEN_MIN])\r
+\r
+/*\r
+#define GET_PRICE_LEN(p, posState, len) \\r
+ ((p)->prices2[(size_t)(len) - 2] + ((p)->prices1[posState][((len) - 2) & (kLenNumLowSymbols * 2 - 1)] & (((len) - 2 - kLenNumLowSymbols * 2) >> 9)))\r
+*/\r
\r
typedef struct\r
{\r
\r
CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];\r
CLzmaProb posEncoders[kNumFullDistances];\r
- \r
+\r
CLenEnc lenProbs;\r
CLenEnc repLenProbs;\r
\r
unsigned lc, lp, pb;\r
unsigned lclp;\r
\r
- Bool fastMode;\r
- Bool writeEndMark;\r
- Bool finished;\r
- Bool multiThread;\r
- Bool needInit;\r
+ BoolInt fastMode;\r
+ BoolInt writeEndMark;\r
+ BoolInt finished;\r
+ BoolInt multiThread;\r
+ BoolInt needInit;\r
+ // BoolInt _maxMode;\r
\r
UInt64 nowPos64;\r
- \r
+\r
unsigned matchPriceCount;\r
- unsigned alignPriceCount;\r
+ // unsigned alignPriceCount;\r
+ int repLenEncCounter;\r
\r
unsigned distTableSize;\r
\r
SRes result;\r
\r
#ifndef _7ZIP_ST\r
- Bool mtMode;\r
+ BoolInt mtMode;\r
// begin of CMatchFinderMt is used in LZ thread\r
CMatchFinderMt matchFinderMt;\r
// end of CMatchFinderMt is used in BT and HASH threads\r
#ifndef _7ZIP_ST\r
Byte pad[128];\r
#endif\r
- \r
+\r
// LZ thread\r
CProbPrice ProbPrices[kBitModelTotal >> kNumMoveReducingBits];\r
\r
CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX];\r
CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];\r
CLzmaProb posEncoders[kNumFullDistances];\r
- \r
+\r
CLenEnc lenProbs;\r
CLenEnc repLenProbs;\r
\r
{\r
CLzmaEnc *p = (CLzmaEnc *)pp;\r
CSaveState *dest = &p->saveState;\r
- \r
+\r
dest->state = p->state;\r
- \r
+\r
dest->lenProbs = p->lenProbs;\r
dest->repLenProbs = p->repLenProbs;\r
\r
\r
dest->lenProbs = p->lenProbs;\r
dest->repLenProbs = p->repLenProbs;\r
- \r
+\r
COPY_ARR(dest, p, reps);\r
- \r
+\r
COPY_ARR(dest, p, posAlignEncoder);\r
COPY_ARR(dest, p, isRep);\r
COPY_ARR(dest, p, isRepG0);\r
p->lp = props.lp;\r
p->pb = props.pb;\r
p->fastMode = (props.algo == 0);\r
+ // p->_maxMode = True;\r
p->matchFinderBase.btMode = (Byte)(props.btMode ? 1 : 0);\r
{\r
unsigned numHashBytes = 4;\r
\r
#ifdef _LZMA_ENC_USE_BRANCH\r
\r
-#define RC_BIT(p, prob, symbol) { \\r
+#define RC_BIT(p, prob, bit) { \\r
RC_BIT_PRE(p, prob) \\r
- if (symbol == 0) { range = newBound; ttt += (kBitModelTotal - ttt) >> kNumMoveBits; } \\r
+ if (bit == 0) { range = newBound; ttt += (kBitModelTotal - ttt) >> kNumMoveBits; } \\r
else { (p)->low += newBound; range -= newBound; ttt -= ttt >> kNumMoveBits; } \\r
*(prob) = (CLzmaProb)ttt; \\r
RC_NORM(p) \\r
\r
#else\r
\r
-#define RC_BIT(p, prob, symbol) { \\r
+#define RC_BIT(p, prob, bit) { \\r
UInt32 mask; \\r
RC_BIT_PRE(p, prob) \\r
- mask = 0 - (UInt32)symbol; \\r
+ mask = 0 - (UInt32)bit; \\r
range &= mask; \\r
mask &= newBound; \\r
range -= mask; \\r
(p)->low += mask; \\r
- mask = (UInt32)symbol - 1; \\r
+ mask = (UInt32)bit - 1; \\r
range += newBound & mask; \\r
mask &= (kBitModelTotal - ((1 << kNumMoveBits) - 1)); \\r
mask += ((1 << kNumMoveBits) - 1); \\r
p->range = range;\r
}\r
\r
-static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol)\r
+static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 sym)\r
{\r
UInt32 range = p->range;\r
- symbol |= 0x100;\r
+ sym |= 0x100;\r
do\r
{\r
UInt32 ttt, newBound;\r
- // RangeEnc_EncodeBit(p, probs + (symbol >> 8), (symbol >> 7) & 1);\r
- CLzmaProb *prob = probs + (symbol >> 8);\r
- UInt32 bit = (symbol >> 7) & 1;\r
- symbol <<= 1;\r
+ // RangeEnc_EncodeBit(p, probs + (sym >> 8), (sym >> 7) & 1);\r
+ CLzmaProb *prob = probs + (sym >> 8);\r
+ UInt32 bit = (sym >> 7) & 1;\r
+ sym <<= 1;\r
RC_BIT(p, prob, bit);\r
}\r
- while (symbol < 0x10000);\r
+ while (sym < 0x10000);\r
p->range = range;\r
}\r
\r
-static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol, UInt32 matchByte)\r
+static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 sym, UInt32 matchByte)\r
{\r
UInt32 range = p->range;\r
UInt32 offs = 0x100;\r
- symbol |= 0x100;\r
+ sym |= 0x100;\r
do\r
{\r
UInt32 ttt, newBound;\r
CLzmaProb *prob;\r
UInt32 bit;\r
matchByte <<= 1;\r
- // RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (symbol >> 8)), (symbol >> 7) & 1);\r
- prob = probs + (offs + (matchByte & offs) + (symbol >> 8));\r
- bit = (symbol >> 7) & 1;\r
- symbol <<= 1;\r
- offs &= ~(matchByte ^ symbol);\r
+ // RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (sym >> 8)), (sym >> 7) & 1);\r
+ prob = probs + (offs + (matchByte & offs) + (sym >> 8));\r
+ bit = (sym >> 7) & 1;\r
+ sym <<= 1;\r
+ offs &= ~(matchByte ^ sym);\r
RC_BIT(p, prob, bit);\r
}\r
- while (symbol < 0x10000);\r
+ while (sym < 0x10000);\r
p->range = range;\r
}\r
\r
}\r
\r
\r
-#define GET_PRICE(prob, symbol) \\r
- p->ProbPrices[((prob) ^ (unsigned)(((-(int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits];\r
+#define GET_PRICE(prob, bit) \\r
+ p->ProbPrices[((prob) ^ (unsigned)(((-(int)(bit))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits];\r
\r
-#define GET_PRICEa(prob, symbol) \\r
- ProbPrices[((prob) ^ (unsigned)((-((int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits];\r
+#define GET_PRICEa(prob, bit) \\r
+ ProbPrices[((prob) ^ (unsigned)((-((int)(bit))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits];\r
\r
#define GET_PRICE_0(prob) p->ProbPrices[(prob) >> kNumMoveReducingBits]\r
#define GET_PRICE_1(prob) p->ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]\r
#define GET_PRICEa_1(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]\r
\r
\r
-static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 symbol, const CProbPrice *ProbPrices)\r
+static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 sym, const CProbPrice *ProbPrices)\r
{\r
UInt32 price = 0;\r
- symbol |= 0x100;\r
+ sym |= 0x100;\r
do\r
{\r
- unsigned bit = symbol & 1;\r
- symbol >>= 1;\r
- price += GET_PRICEa(probs[symbol], bit);\r
+ unsigned bit = sym & 1;\r
+ sym >>= 1;\r
+ price += GET_PRICEa(probs[sym], bit);\r
}\r
- while (symbol >= 2);\r
+ while (sym >= 2);\r
return price;\r
}\r
\r
\r
-static UInt32 LitEnc_Matched_GetPrice(const CLzmaProb *probs, UInt32 symbol, UInt32 matchByte, const CProbPrice *ProbPrices)\r
+static UInt32 LitEnc_Matched_GetPrice(const CLzmaProb *probs, UInt32 sym, UInt32 matchByte, const CProbPrice *ProbPrices)\r
{\r
UInt32 price = 0;\r
UInt32 offs = 0x100;\r
- symbol |= 0x100;\r
+ sym |= 0x100;\r
do\r
{\r
matchByte <<= 1;\r
- price += GET_PRICEa(probs[offs + (matchByte & offs) + (symbol >> 8)], (symbol >> 7) & 1);\r
- symbol <<= 1;\r
- offs &= ~(matchByte ^ symbol);\r
+ price += GET_PRICEa(probs[offs + (matchByte & offs) + (sym >> 8)], (sym >> 7) & 1);\r
+ sym <<= 1;\r
+ offs &= ~(matchByte ^ sym);\r
}\r
- while (symbol < 0x10000);\r
+ while (sym < 0x10000);\r
return price;\r
}\r
\r
\r
-static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, unsigned numBits, UInt32 symbol)\r
+static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, unsigned numBits, unsigned sym)\r
{\r
UInt32 range = rc->range;\r
unsigned m = 1;\r
do\r
{\r
UInt32 ttt, newBound;\r
- unsigned bit = symbol & 1;\r
+ unsigned bit = sym & 1;\r
// RangeEnc_EncodeBit(rc, probs + m, bit);\r
- symbol >>= 1;\r
+ sym >>= 1;\r
RC_BIT(rc, probs + m, bit);\r
m = (m << 1) | bit;\r
}\r
p->high[i] = kProbInitValue;\r
}\r
\r
-static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, unsigned symbol, unsigned posState)\r
+static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, unsigned sym, unsigned posState)\r
{\r
UInt32 range, ttt, newBound;\r
CLzmaProb *probs = p->low;\r
range = rc->range;\r
RC_BIT_PRE(rc, probs);\r
- if (symbol >= kLenNumLowSymbols)\r
+ if (sym >= kLenNumLowSymbols)\r
{\r
RC_BIT_1(rc, probs);\r
probs += kLenNumLowSymbols;\r
RC_BIT_PRE(rc, probs);\r
- if (symbol >= kLenNumLowSymbols * 2)\r
+ if (sym >= kLenNumLowSymbols * 2)\r
{\r
RC_BIT_1(rc, probs);\r
rc->range = range;\r
- // RcTree_Encode(rc, p->high, kLenNumHighBits, symbol - kLenNumLowSymbols * 2);\r
- LitEnc_Encode(rc, p->high, symbol - kLenNumLowSymbols * 2);\r
+ // RcTree_Encode(rc, p->high, kLenNumHighBits, sym - kLenNumLowSymbols * 2);\r
+ LitEnc_Encode(rc, p->high, sym - kLenNumLowSymbols * 2);\r
return;\r
}\r
- symbol -= kLenNumLowSymbols;\r
+ sym -= kLenNumLowSymbols;\r
}\r
\r
- // RcTree_Encode(rc, probs + (posState << kLenNumLowBits), kLenNumLowBits, symbol);\r
+ // RcTree_Encode(rc, probs + (posState << kLenNumLowBits), kLenNumLowBits, sym);\r
{\r
unsigned m;\r
unsigned bit;\r
RC_BIT_0(rc, probs);\r
probs += (posState << (1 + kLenNumLowBits));\r
- bit = (symbol >> 2) ; RC_BIT(rc, probs + 1, bit); m = (1 << 1) + bit;\r
- bit = (symbol >> 1) & 1; RC_BIT(rc, probs + m, bit); m = (m << 1) + bit;\r
- bit = symbol & 1; RC_BIT(rc, probs + m, bit);\r
+ bit = (sym >> 2) ; RC_BIT(rc, probs + 1, bit); m = (1 << 1) + bit;\r
+ bit = (sym >> 1) & 1; RC_BIT(rc, probs + m, bit); m = (m << 1) + bit;\r
+ bit = sym & 1; RC_BIT(rc, probs + m, bit);\r
rc->range = range;\r
}\r
}\r
}\r
\r
\r
-MY_NO_INLINE static void MY_FAST_CALL LenPriceEnc_UpdateTable(\r
- CLenPriceEnc *p, unsigned posState,\r
+MY_NO_INLINE static void MY_FAST_CALL LenPriceEnc_UpdateTables(\r
+ CLenPriceEnc *p,\r
+ unsigned numPosStates,\r
const CLenEnc *enc,\r
const CProbPrice *ProbPrices)\r
{\r
- // int y; for (y = 0; y < 100; y++) {\r
- UInt32 a;\r
- unsigned i, numSymbols;\r
+ UInt32 b;\r
+\r
+ {\r
+ unsigned prob = enc->low[0];\r
+ UInt32 a, c;\r
+ unsigned posState;\r
+ b = GET_PRICEa_1(prob);\r
+ a = GET_PRICEa_0(prob);\r
+ c = b + GET_PRICEa_0(enc->low[kLenNumLowSymbols]);\r
+ for (posState = 0; posState < numPosStates; posState++)\r
+ {\r
+ UInt32 *prices = p->prices[posState];\r
+ const CLzmaProb *probs = enc->low + (posState << (1 + kLenNumLowBits));\r
+ SetPrices_3(probs, a, prices, ProbPrices);\r
+ SetPrices_3(probs + kLenNumLowSymbols, c, prices + kLenNumLowSymbols, ProbPrices);\r
+ }\r
+ }\r
\r
- UInt32 *prices = p->prices[posState];\r
+ /*\r
{\r
- const CLzmaProb *probs = enc->low + (posState << (1 + kLenNumLowBits));\r
- SetPrices_3(probs, GET_PRICEa_0(enc->low[0]), prices, ProbPrices);\r
+ unsigned i;\r
+ UInt32 b;\r
+ a = GET_PRICEa_0(enc->low[0]);\r
+ for (i = 0; i < kLenNumLowSymbols; i++)\r
+ p->prices2[i] = a;\r
a = GET_PRICEa_1(enc->low[0]);\r
- SetPrices_3(probs + kLenNumLowSymbols, a + GET_PRICEa_0(enc->low[kLenNumLowSymbols]), prices + kLenNumLowSymbols, ProbPrices);\r
+ b = a + GET_PRICEa_0(enc->low[kLenNumLowSymbols]);\r
+ for (i = kLenNumLowSymbols; i < kLenNumLowSymbols * 2; i++)\r
+ p->prices2[i] = b;\r
a += GET_PRICEa_1(enc->low[kLenNumLowSymbols]);\r
}\r
- numSymbols = p->tableSize;\r
- p->counters[posState] = numSymbols;\r
- for (i = kLenNumLowSymbols * 2; i < numSymbols; i += 1)\r
+ */\r
+\r
+ // p->counter = numSymbols;\r
+ // p->counter = 64;\r
+\r
{\r
- prices[i] = a +\r
- // RcTree_GetPrice(enc->high, kLenNumHighBits, i - kLenNumLowSymbols * 2, ProbPrices);\r
- LitEnc_GetPrice(enc->high, i - kLenNumLowSymbols * 2, ProbPrices);\r
- /*\r
- unsigned sym = (i - kLenNumLowSymbols * 2) >> 1;\r
- UInt32 price = a + RcTree_GetPrice(enc->high, kLenNumHighBits - 1, sym, ProbPrices);\r
- UInt32 prob = enc->high[(1 << 7) + sym];\r
- prices[i ] = price + GET_PRICEa_0(prob);\r
- prices[i + 1] = price + GET_PRICEa_1(prob);\r
- */\r
- }\r
- // }\r
-}\r
+ unsigned i = p->tableSize;\r
\r
-static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, unsigned numPosStates,\r
- const CLenEnc *enc,\r
- const CProbPrice *ProbPrices)\r
-{\r
- unsigned posState;\r
- for (posState = 0; posState < numPosStates; posState++)\r
- LenPriceEnc_UpdateTable(p, posState, enc, ProbPrices);\r
-}\r
+ if (i > kLenNumLowSymbols * 2)\r
+ {\r
+ const CLzmaProb *probs = enc->high;\r
+ UInt32 *prices = p->prices[0] + kLenNumLowSymbols * 2;\r
+ i -= kLenNumLowSymbols * 2 - 1;\r
+ i >>= 1;\r
+ b += GET_PRICEa_1(enc->low[kLenNumLowSymbols]);\r
+ do\r
+ {\r
+ /*\r
+ p->prices2[i] = a +\r
+ // RcTree_GetPrice(enc->high, kLenNumHighBits, i - kLenNumLowSymbols * 2, ProbPrices);\r
+ LitEnc_GetPrice(probs, i - kLenNumLowSymbols * 2, ProbPrices);\r
+ */\r
+ // UInt32 price = a + RcTree_GetPrice(probs, kLenNumHighBits - 1, sym, ProbPrices);\r
+ unsigned sym = --i + (1 << (kLenNumHighBits - 1));\r
+ UInt32 price = b;\r
+ do\r
+ {\r
+ unsigned bit = sym & 1;\r
+ sym >>= 1;\r
+ price += GET_PRICEa(probs[sym], bit);\r
+ }\r
+ while (sym >= 2);\r
+\r
+ {\r
+ unsigned prob = probs[(size_t)i + (1 << (kLenNumHighBits - 1))];\r
+ prices[(size_t)i * 2 ] = price + GET_PRICEa_0(prob);\r
+ prices[(size_t)i * 2 + 1] = price + GET_PRICEa_1(prob);\r
+ }\r
+ }\r
+ while (i);\r
\r
+ {\r
+ unsigned posState;\r
+ size_t num = (p->tableSize - kLenNumLowSymbols * 2) * sizeof(p->prices[0][0]);\r
+ for (posState = 1; posState < numPosStates; posState++)\r
+ memcpy(p->prices[posState] + kLenNumLowSymbols * 2, p->prices[0] + kLenNumLowSymbols * 2, num);\r
+ }\r
+ }\r
+ }\r
+}\r
\r
/*\r
#ifdef SHOW_STAT\r
printf("\n MovePos %u", num);\r
#endif\r
*/\r
- \r
+\r
#define MOVE_POS(p, num) { \\r
p->additionalOffset += (num); \\r
- p->matchFinder.Skip(p->matchFinderObj, (num)); }\r
+ p->matchFinder.Skip(p->matchFinderObj, (UInt32)(num)); }\r
\r
\r
static unsigned ReadMatchDistances(CLzmaEnc *p, unsigned *numPairsRes)\r
{\r
unsigned numPairs;\r
- \r
+\r
p->additionalOffset++;\r
p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);\r
numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches);\r
*numPairsRes = numPairs;\r
- \r
+\r
#ifdef SHOW_STAT\r
printf("\n i = %u numPairs = %u ", g_STAT_OFFSET, numPairs / 2);\r
g_STAT_OFFSET++;\r
printf("%2u %6u | ", p->matches[i], p->matches[i + 1]);\r
}\r
#endif\r
- \r
+\r
if (numPairs == 0)\r
return 0;\r
{\r
const Byte *p2 = p1 + len;\r
ptrdiff_t dif = (ptrdiff_t)-1 - p->matches[(size_t)numPairs - 1];\r
const Byte *lim = p1 + numAvail;\r
- for (; p2 != lim && *p2 == p2[dif]; p2++);\r
+ for (; p2 != lim && *p2 == p2[dif]; p2++)\r
+ {}\r
return (unsigned)(p2 - p1);\r
}\r
}\r
+ GET_PRICE_1(p->isRep0Long[state][posState])) \\r
+ GET_PRICE_1(p->isRep[state]) \\r
+ GET_PRICE_0(p->isRepG0[state])\r
- \r
\r
+MY_FORCE_INLINE\r
static UInt32 GetPrice_PureRep(const CLzmaEnc *p, unsigned repIndex, size_t state, size_t posState)\r
{\r
UInt32 price;\r
for (;;)\r
{\r
UInt32 dist = p->opt[cur].dist;\r
- UInt32 len = p->opt[cur].len;\r
- UInt32 extra = p->opt[cur].extra;\r
+ unsigned len = (unsigned)p->opt[cur].len;\r
+ unsigned extra = (unsigned)p->opt[cur].extra;\r
cur -= len;\r
\r
if (extra)\r
{\r
wr--;\r
- p->opt[wr].len = len;\r
+ p->opt[wr].len = (UInt32)len;\r
cur -= extra;\r
len = extra;\r
if (extra == 1)\r
p->optCur = wr;\r
return len;\r
}\r
- \r
+\r
wr--;\r
p->opt[wr].dist = dist;\r
- p->opt[wr].len = len;\r
+ p->opt[wr].len = (UInt32)len;\r
}\r
}\r
\r
UInt32 matchPrice, repMatchPrice;\r
const Byte *data;\r
Byte curByte, matchByte;\r
- \r
+\r
p->optCur = p->optEnd = 0;\r
- \r
+\r
if (p->additionalOffset == 0)\r
mainLen = ReadMatchDistances(p, &numPairs);\r
else\r
mainLen = p->longestMatchLen;\r
numPairs = p->numPairs;\r
}\r
- \r
+\r
numAvail = p->numAvail;\r
if (numAvail < 2)\r
{\r
}\r
if (numAvail > LZMA_MATCH_LEN_MAX)\r
numAvail = LZMA_MATCH_LEN_MAX;\r
- \r
+\r
data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;\r
repMaxIndex = 0;\r
- \r
+\r
for (i = 0; i < LZMA_NUM_REPS; i++)\r
{\r
unsigned len;\r
repLens[i] = 0;\r
continue;\r
}\r
- for (len = 2; len < numAvail && data[len] == data2[len]; len++);\r
+ for (len = 2; len < numAvail && data[len] == data2[len]; len++)\r
+ {}\r
repLens[i] = len;\r
if (len > repLens[repMaxIndex])\r
repMaxIndex = i;\r
}\r
- \r
+\r
if (repLens[repMaxIndex] >= p->numFastBytes)\r
{\r
unsigned len;\r
- p->backRes = repMaxIndex;\r
+ p->backRes = (UInt32)repMaxIndex;\r
len = repLens[repMaxIndex];\r
MOVE_POS(p, len - 1)\r
return len;\r
}\r
- \r
+\r
matches = p->matches;\r
- \r
+\r
if (mainLen >= p->numFastBytes)\r
{\r
p->backRes = matches[(size_t)numPairs - 1] + LZMA_NUM_REPS;\r
MOVE_POS(p, mainLen - 1)\r
return mainLen;\r
}\r
- \r
+\r
curByte = *data;\r
matchByte = *(data - reps[0]);\r
- \r
- if (mainLen < 2 && curByte != matchByte && repLens[repMaxIndex] < 2)\r
+\r
+ last = repLens[repMaxIndex];\r
+ if (last <= mainLen)\r
+ last = mainLen;\r
+\r
+ if (last < 2 && curByte != matchByte)\r
{\r
p->backRes = MARK_LIT;\r
return 1;\r
}\r
- \r
+\r
p->opt[0].state = (CState)p->state;\r
- \r
+\r
posState = (position & p->pbMask);\r
- \r
+\r
{\r
const CLzmaProb *probs = LIT_PROBS(position, *(data - 1));\r
p->opt[1].price = GET_PRICE_0(p->isMatch[p->state][posState]) +\r
LitEnc_Matched_GetPrice(probs, curByte, matchByte, p->ProbPrices) :\r
LitEnc_GetPrice(probs, curByte, p->ProbPrices));\r
}\r
- \r
+\r
MakeAs_Lit(&p->opt[1]);\r
- \r
+\r
matchPrice = GET_PRICE_1(p->isMatch[p->state][posState]);\r
repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[p->state]);\r
- \r
- if (matchByte == curByte)\r
+\r
+ // 18.06\r
+ if (matchByte == curByte && repLens[0] == 0)\r
{\r
UInt32 shortRepPrice = repMatchPrice + GetPrice_ShortRep(p, p->state, posState);\r
if (shortRepPrice < p->opt[1].price)\r
p->opt[1].price = shortRepPrice;\r
MakeAs_ShortRep(&p->opt[1]);\r
}\r
+ if (last < 2)\r
+ {\r
+ p->backRes = p->opt[1].dist;\r
+ return 1;\r
+ }\r
}\r
- \r
- last = (mainLen >= repLens[repMaxIndex] ? mainLen : repLens[repMaxIndex]);\r
- \r
- if (last < 2)\r
- {\r
- p->backRes = p->opt[1].dist;\r
- return 1;\r
- }\r
- \r
+\r
p->opt[1].len = 1;\r
- \r
+\r
p->opt[0].reps[0] = reps[0];\r
p->opt[0].reps[1] = reps[1];\r
p->opt[0].reps[2] = reps[2];\r
p->opt[0].reps[3] = reps[3];\r
- \r
- {\r
- unsigned len = last;\r
- do\r
- p->opt[len--].price = kInfinityPrice;\r
- while (len >= 2);\r
- }\r
\r
// ---------- REP ----------\r
- \r
+\r
for (i = 0; i < LZMA_NUM_REPS; i++)\r
{\r
unsigned repLen = repLens[i];\r
price = repMatchPrice + GetPrice_PureRep(p, i, p->state, posState);\r
do\r
{\r
- UInt32 price2 = price + p->repLenEnc.prices[posState][(size_t)repLen - 2];\r
+ UInt32 price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState, repLen);\r
COptimal *opt = &p->opt[repLen];\r
if (price2 < opt->price)\r
{\r
opt->price = price2;\r
- opt->len = repLen;\r
- opt->dist = i;\r
+ opt->len = (UInt32)repLen;\r
+ opt->dist = (UInt32)i;\r
opt->extra = 0;\r
}\r
}\r
while (--repLen >= 2);\r
}\r
- \r
- \r
+\r
+\r
// ---------- MATCH ----------\r
{\r
- unsigned len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2);\r
+ unsigned len = repLens[0] + 1;\r
if (len <= mainLen)\r
{\r
unsigned offs = 0;\r
UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]);\r
\r
- while (len > matches[offs])\r
- offs += 2;\r
- \r
+ if (len < 2)\r
+ len = 2;\r
+ else\r
+ while (len > matches[offs])\r
+ offs += 2;\r
+\r
for (; ; len++)\r
{\r
COptimal *opt;\r
UInt32 dist = matches[(size_t)offs + 1];\r
- UInt32 price2 = normalMatchPrice + p->lenEnc.prices[posState][(size_t)len - LZMA_MATCH_LEN_MIN];\r
+ UInt32 price = normalMatchPrice + GET_PRICE_LEN(&p->lenEnc, posState, len);\r
unsigned lenToPosState = GetLenToPosState(len);\r
- \r
+\r
if (dist < kNumFullDistances)\r
- price2 += p->distancesPrices[lenToPosState][dist & (kNumFullDistances - 1)];\r
+ price += p->distancesPrices[lenToPosState][dist & (kNumFullDistances - 1)];\r
else\r
{\r
unsigned slot;\r
GetPosSlot2(dist, slot);\r
- price2 += p->alignPrices[dist & kAlignMask];\r
- price2 += p->posSlotPrices[lenToPosState][slot];\r
+ price += p->alignPrices[dist & kAlignMask];\r
+ price += p->posSlotPrices[lenToPosState][slot];\r
}\r
- \r
+\r
opt = &p->opt[len];\r
- \r
- if (price2 < opt->price)\r
+\r
+ if (price < opt->price)\r
{\r
- opt->price = price2;\r
- opt->len = len;\r
+ opt->price = price;\r
+ opt->len = (UInt32)len;\r
opt->dist = dist + LZMA_NUM_REPS;\r
opt->extra = 0;\r
}\r
- \r
+\r
if (len == matches[offs])\r
{\r
offs += 2;\r
}\r
}\r
}\r
- \r
+\r
\r
cur = 0;\r
\r
}\r
\r
\r
- \r
+\r
// ---------- Optimal Parsing ----------\r
\r
for (;;)\r
{\r
- UInt32 numAvail, numAvailFull;\r
+ unsigned numAvail;\r
+ UInt32 numAvailFull;\r
unsigned newLen, numPairs, prev, state, posState, startLen;\r
- UInt32 curPrice, litPrice, matchPrice, repMatchPrice;\r
- Bool nextIsLit;\r
+ UInt32 litPrice, matchPrice, repMatchPrice;\r
+ BoolInt nextIsLit;\r
Byte curByte, matchByte;\r
const Byte *data;\r
COptimal *curOpt, *nextOpt;\r
\r
if (++cur == last)\r
- return Backward(p, cur);\r
+ break;\r
+\r
+ // 18.06\r
+ if (cur >= kNumOpts - 64)\r
+ {\r
+ unsigned j, best;\r
+ UInt32 price = p->opt[cur].price;\r
+ best = cur;\r
+ for (j = cur + 1; j <= last; j++)\r
+ {\r
+ UInt32 price2 = p->opt[j].price;\r
+ if (price >= price2)\r
+ {\r
+ price = price2;\r
+ best = j;\r
+ }\r
+ }\r
+ {\r
+ unsigned delta = best - cur;\r
+ if (delta != 0)\r
+ {\r
+ MOVE_POS(p, delta);\r
+ }\r
+ }\r
+ cur = best;\r
+ break;\r
+ }\r
\r
newLen = ReadMatchDistances(p, &numPairs);\r
- \r
+\r
if (newLen >= p->numFastBytes)\r
{\r
p->numPairs = numPairs;\r
p->longestMatchLen = newLen;\r
- return Backward(p, cur);\r
+ break;\r
}\r
- \r
+\r
curOpt = &p->opt[cur];\r
+\r
+ position++;\r
+\r
+ // we need that check here, if skip_items in p->opt are possible\r
+ /*\r
+ if (curOpt->price >= kInfinityPrice)\r
+ continue;\r
+ */\r
+\r
prev = cur - curOpt->len;\r
- \r
+\r
if (curOpt->len == 1)\r
{\r
- state = p->opt[prev].state;\r
+ state = (unsigned)p->opt[prev].state;\r
if (IsShortRep(curOpt))\r
state = kShortRepNextStates[state];\r
else\r
\r
if (curOpt->extra)\r
{\r
- prev -= curOpt->extra;\r
+ prev -= (unsigned)curOpt->extra;\r
state = kState_RepAfterLit;\r
if (curOpt->extra == 1)\r
- state = (dist < LZMA_NUM_REPS) ? kState_RepAfterLit : kState_MatchAfterLit;\r
+ state = (dist < LZMA_NUM_REPS ? kState_RepAfterLit : kState_MatchAfterLit);\r
}\r
else\r
{\r
- state = p->opt[prev].state;\r
+ state = (unsigned)p->opt[prev].state;\r
if (dist < LZMA_NUM_REPS)\r
state = kRepNextStates[state];\r
else\r
reps[3] = prevOpt->reps[2];\r
}\r
}\r
- \r
+\r
curOpt->state = (CState)state;\r
curOpt->reps[0] = reps[0];\r
curOpt->reps[1] = reps[1];\r
curByte = *data;\r
matchByte = *(data - reps[0]);\r
\r
- position++;\r
posState = (position & p->pbMask);\r
\r
/*\r
< MATCH [ : LIT : REP_0 ]\r
*/\r
\r
- curPrice = curOpt->price;\r
- litPrice = curPrice + GET_PRICE_0(p->isMatch[state][posState]);\r
+ {\r
+ UInt32 curPrice = curOpt->price;\r
+ unsigned prob = p->isMatch[state][posState];\r
+ matchPrice = curPrice + GET_PRICE_1(prob);\r
+ litPrice = curPrice + GET_PRICE_0(prob);\r
+ }\r
\r
nextOpt = &p->opt[(size_t)cur + 1];\r
nextIsLit = False;\r
\r
- // if (litPrice >= nextOpt->price) litPrice = 0; else // 18.new\r
+ // here we can allow skip_items in p->opt, if we don't check (nextOpt->price < kInfinityPrice)\r
+ // 18.new.06\r
+ if ((nextOpt->price < kInfinityPrice\r
+ // && !IsLitState(state)\r
+ && matchByte == curByte)\r
+ || litPrice > nextOpt->price\r
+ )\r
+ litPrice = 0;\r
+ else\r
{\r
const CLzmaProb *probs = LIT_PROBS(position, *(data - 1));\r
litPrice += (!IsLitState(state) ?\r
LitEnc_Matched_GetPrice(probs, curByte, matchByte, p->ProbPrices) :\r
LitEnc_GetPrice(probs, curByte, p->ProbPrices));\r
- \r
+\r
if (litPrice < nextOpt->price)\r
{\r
nextOpt->price = litPrice;\r
}\r
}\r
\r
- matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]);\r
repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]);\r
- \r
+\r
+ numAvailFull = p->numAvail;\r
+ {\r
+ unsigned temp = kNumOpts - 1 - cur;\r
+ if (numAvailFull > temp)\r
+ numAvailFull = (UInt32)temp;\r
+ }\r
+\r
+ // 18.06\r
// ---------- SHORT_REP ----------\r
- // if (IsLitState(state)) // 18.new\r
+ if (IsLitState(state)) // 18.new\r
if (matchByte == curByte)\r
- // if (repMatchPrice < nextOpt->price) // 18.new\r
- if (nextOpt->len < 2\r
+ if (repMatchPrice < nextOpt->price) // 18.new\r
+ // if (numAvailFull < 2 || data[1] != *(data - reps[0] + 1))\r
+ if (\r
+ // nextOpt->price >= kInfinityPrice ||\r
+ nextOpt->len < 2 // we can check nextOpt->len, if skip items are not allowed in p->opt\r
|| (nextOpt->dist != 0\r
- && nextOpt->extra <= 1 // 17.old\r
- ))\r
+ // && nextOpt->extra <= 1 // 17.old\r
+ )\r
+ )\r
{\r
UInt32 shortRepPrice = repMatchPrice + GetPrice_ShortRep(p, state, posState);\r
- if (shortRepPrice <= nextOpt->price) // 17.old\r
- // if (shortRepPrice < nextOpt->price) // 18.new\r
+ // if (shortRepPrice <= nextOpt->price) // 17.old\r
+ if (shortRepPrice < nextOpt->price) // 18.new\r
{\r
nextOpt->price = shortRepPrice;\r
nextOpt->len = 1;\r
nextIsLit = False;\r
}\r
}\r
- \r
- numAvailFull = p->numAvail;\r
- {\r
- UInt32 temp = kNumOpts - 1 - cur;\r
- if (numAvailFull > temp)\r
- numAvailFull = temp;\r
- }\r
\r
if (numAvailFull < 2)\r
continue;\r
\r
// ---------- LIT : REP_0 ----------\r
\r
- if (\r
- // litPrice != 0 && // 18.new\r
- !nextIsLit\r
+ if (!nextIsLit\r
+ && litPrice != 0 // 18.new\r
&& matchByte != curByte\r
&& numAvailFull > 2)\r
{\r
if (limit > numAvailFull)\r
limit = numAvailFull;\r
for (len = 3; len < limit && data[len] == data2[len]; len++)\r
- {\r
- }\r
- \r
+ {}\r
+\r
{\r
unsigned state2 = kLiteralNextStates[state];\r
unsigned posState2 = (position + 1) & p->pbMask;\r
UInt32 price = litPrice + GetPrice_Rep_0(p, state2, posState2);\r
{\r
unsigned offset = cur + len;\r
- while (last < offset)\r
- p->opt[++last].price = kInfinityPrice;\r
- \r
+\r
+ if (last < offset)\r
+ last = offset;\r
+\r
// do\r
{\r
UInt32 price2;\r
COptimal *opt;\r
len--;\r
// price2 = price + GetPrice_Len_Rep_0(p, len, state2, posState2);\r
- price2 = price + p->repLenEnc.prices[posState2][len - LZMA_MATCH_LEN_MIN];\r
+ price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState2, len);\r
\r
opt = &p->opt[offset];\r
// offset--;\r
if (price2 < opt->price)\r
{\r
opt->price = price2;\r
- opt->len = len;\r
+ opt->len = (UInt32)len;\r
opt->dist = 0;\r
opt->extra = 1;\r
}\r
}\r
}\r
}\r
- \r
+\r
startLen = 2; /* speed optimization */\r
+\r
{\r
// ---------- REP ----------\r
unsigned repIndex = 0; // 17.old\r
const Byte *data2 = data - reps[repIndex];\r
if (data[0] != data2[0] || data[1] != data2[1])\r
continue;\r
- \r
- for (len = 2; len < numAvail && data[len] == data2[len]; len++);\r
- \r
+\r
+ for (len = 2; len < numAvail && data[len] == data2[len]; len++)\r
+ {}\r
+\r
// if (len < startLen) continue; // 18.new: speed optimization\r
\r
- while (last < cur + len)\r
- p->opt[++last].price = kInfinityPrice;\r
+ {\r
+ unsigned offset = cur + len;\r
+ if (last < offset)\r
+ last = offset;\r
+ }\r
{\r
unsigned len2 = len;\r
price = repMatchPrice + GetPrice_PureRep(p, repIndex, state, posState);\r
do\r
{\r
- UInt32 price2 = price + p->repLenEnc.prices[posState][(size_t)len2 - 2];\r
+ UInt32 price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState, len2);\r
COptimal *opt = &p->opt[cur + len2];\r
if (price2 < opt->price)\r
{\r
opt->price = price2;\r
- opt->len = len2;\r
- opt->dist = repIndex;\r
+ opt->len = (UInt32)len2;\r
+ opt->dist = (UInt32)repIndex;\r
opt->extra = 0;\r
}\r
}\r
while (--len2 >= 2);\r
}\r
- \r
+\r
if (repIndex == 0) startLen = len + 1; // 17.old\r
// startLen = len + 1; // 18.new\r
\r
unsigned limit = len2 + p->numFastBytes;\r
if (limit > numAvailFull)\r
limit = numAvailFull;\r
- \r
- for (; len2 < limit && data[len2] == data2[len2]; len2++);\r
- \r
- len2 -= len;\r
- if (len2 >= 3)\r
+\r
+ len2 += 2;\r
+ if (len2 <= limit)\r
+ if (data[len2 - 2] == data2[len2 - 2])\r
+ if (data[len2 - 1] == data2[len2 - 1])\r
{\r
unsigned state2 = kRepNextStates[state];\r
unsigned posState2 = (position + len) & p->pbMask;\r
- price +=\r
- p->repLenEnc.prices[posState][(size_t)len - 2]\r
+ price += GET_PRICE_LEN(&p->repLenEnc, posState, len)\r
+ GET_PRICE_0(p->isMatch[state2][posState2])\r
+ LitEnc_Matched_GetPrice(LIT_PROBS(position + len, data[(size_t)len - 1]),\r
data[len], data2[len], p->ProbPrices);\r
- \r
+\r
// state2 = kLiteralNextStates[state2];\r
state2 = kState_LitAfterRep;\r
posState2 = (posState2 + 1) & p->pbMask;\r
\r
\r
price += GetPrice_Rep_0(p, state2, posState2);\r
+\r
+ for (; len2 < limit && data[len2] == data2[len2]; len2++)\r
+ {}\r
+\r
+ len2 -= len;\r
+ // if (len2 >= 3)\r
+ {\r
{\r
unsigned offset = cur + len + len2;\r
- while (last < offset)\r
- p->opt[++last].price = kInfinityPrice;\r
+\r
+ if (last < offset)\r
+ last = offset;\r
// do\r
{\r
- unsigned price2;\r
+ UInt32 price2;\r
COptimal *opt;\r
len2--;\r
// price2 = price + GetPrice_Len_Rep_0(p, len2, state2, posState2);\r
- price2 = price + p->repLenEnc.prices[posState2][len2 - LZMA_MATCH_LEN_MIN];\r
+ price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState2, len2);\r
\r
opt = &p->opt[offset];\r
// offset--;\r
if (price2 < opt->price)\r
{\r
opt->price = price2;\r
- opt->len = len2;\r
+ opt->len = (UInt32)len2;\r
opt->extra = (CExtra)(len + 1);\r
- opt->dist = repIndex;\r
+ opt->dist = (UInt32)repIndex;\r
}\r
}\r
// while (len2 >= 3);\r
}\r
}\r
+ }\r
}\r
}\r
}\r
{\r
newLen = numAvail;\r
for (numPairs = 0; newLen > matches[numPairs]; numPairs += 2);\r
- matches[numPairs] = newLen;\r
+ matches[numPairs] = (UInt32)newLen;\r
numPairs += 2;\r
}\r
- \r
+\r
+ // startLen = 2; /* speed optimization */\r
+\r
if (newLen >= startLen)\r
{\r
UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[state]);\r
UInt32 dist;\r
unsigned offs, posSlot, len;\r
- while (last < cur + newLen)\r
- p->opt[++last].price = kInfinityPrice;\r
+\r
+ {\r
+ unsigned offset = cur + newLen;\r
+ if (last < offset)\r
+ last = offset;\r
+ }\r
\r
offs = 0;\r
while (startLen > matches[offs])\r
offs += 2;\r
dist = matches[(size_t)offs + 1];\r
- \r
+\r
// if (dist >= kNumFullDistances)\r
GetPosSlot2(dist, posSlot);\r
- \r
+\r
for (len = /*2*/ startLen; ; len++)\r
{\r
- UInt32 price = normalMatchPrice + p->lenEnc.prices[posState][(size_t)len - LZMA_MATCH_LEN_MIN];\r
+ UInt32 price = normalMatchPrice + GET_PRICE_LEN(&p->lenEnc, posState, len);\r
{\r
COptimal *opt;\r
- unsigned lenToPosState = len - 2; lenToPosState = GetLenToPosState2(lenToPosState);\r
+ unsigned lenNorm = len - 2;\r
+ lenNorm = GetLenToPosState2(lenNorm);\r
if (dist < kNumFullDistances)\r
- price += p->distancesPrices[lenToPosState][dist & (kNumFullDistances - 1)];\r
+ price += p->distancesPrices[lenNorm][dist & (kNumFullDistances - 1)];\r
else\r
- price += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[dist & kAlignMask];\r
- \r
+ price += p->posSlotPrices[lenNorm][posSlot] + p->alignPrices[dist & kAlignMask];\r
+\r
opt = &p->opt[cur + len];\r
if (price < opt->price)\r
{\r
opt->price = price;\r
- opt->len = len;\r
+ opt->len = (UInt32)len;\r
opt->dist = dist + LZMA_NUM_REPS;\r
opt->extra = 0;\r
}\r
}\r
\r
- if (/*_maxMode && */ len == matches[offs])\r
+ if (len == matches[offs])\r
{\r
+ // if (p->_maxMode) {\r
// MATCH : LIT : REP_0\r
\r
const Byte *data2 = data - dist - 1;\r
unsigned limit = len2 + p->numFastBytes;\r
if (limit > numAvailFull)\r
limit = numAvailFull;\r
- \r
- for (; len2 < limit && data[len2] == data2[len2]; len2++);\r
- \r
+\r
+ len2 += 2;\r
+ if (len2 <= limit)\r
+ if (data[len2 - 2] == data2[len2 - 2])\r
+ if (data[len2 - 1] == data2[len2 - 1])\r
+ {\r
+ for (; len2 < limit && data[len2] == data2[len2]; len2++)\r
+ {}\r
+\r
len2 -= len;\r
- \r
- if (len2 >= 3)\r
+\r
+ // if (len2 >= 3)\r
{\r
unsigned state2 = kMatchNextStates[state];\r
unsigned posState2 = (position + len) & p->pbMask;\r
price += GetPrice_Rep_0(p, state2, posState2);\r
\r
offset = cur + len + len2;\r
- while (last < offset)\r
- p->opt[++last].price = kInfinityPrice;\r
+\r
+ if (last < offset)\r
+ last = offset;\r
// do\r
{\r
UInt32 price2;\r
COptimal *opt;\r
len2--;\r
// price2 = price + GetPrice_Len_Rep_0(p, len2, state2, posState2);\r
- price2 = price + p->repLenEnc.prices[posState2][len2 - LZMA_MATCH_LEN_MIN];\r
+ price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState2, len2);\r
opt = &p->opt[offset];\r
// offset--;\r
if (price2 < opt->price)\r
{\r
opt->price = price2;\r
- opt->len = len2;\r
+ opt->len = (UInt32)len2;\r
opt->extra = (CExtra)(len + 1);\r
opt->dist = dist + LZMA_NUM_REPS;\r
}\r
}\r
// while (len2 >= 3);\r
}\r
- \r
+\r
+ }\r
+\r
offs += 2;\r
if (offs == numPairs)\r
break;\r
}\r
}\r
}\r
+\r
+ do\r
+ p->opt[last].price = kInfinityPrice;\r
+ while (--last);\r
+\r
+ return Backward(p, cur);\r
}\r
\r
\r
p->backRes = MARK_LIT;\r
if (numAvail < 2)\r
return 1;\r
+ // if (mainLen < 2 && p->state == 0) return 1; // 18.06.notused\r
if (numAvail > LZMA_MATCH_LEN_MAX)\r
numAvail = LZMA_MATCH_LEN_MAX;\r
data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;\r
repLen = repIndex = 0;\r
- \r
+\r
for (i = 0; i < LZMA_NUM_REPS; i++)\r
{\r
unsigned len;\r
const Byte *data2 = data - p->reps[i];\r
if (data[0] != data2[0] || data[1] != data2[1])\r
continue;\r
- for (len = 2; len < numAvail && data[len] == data2[len]; len++);\r
+ for (len = 2; len < numAvail && data[len] == data2[len]; len++)\r
+ {}\r
if (len >= p->numFastBytes)\r
{\r
- p->backRes = i;\r
+ p->backRes = (UInt32)i;\r
MOVE_POS(p, len - 1)\r
return len;\r
}\r
}\r
\r
mainDist = 0; /* for GCC */\r
- \r
+\r
if (mainLen >= 2)\r
{\r
mainDist = p->matches[(size_t)numPairs - 1];\r
|| (repLen + 2 >= mainLen && mainDist >= (1 << 9))\r
|| (repLen + 3 >= mainLen && mainDist >= (1 << 15)))\r
{\r
- p->backRes = repIndex;\r
+ p->backRes = (UInt32)repIndex;\r
MOVE_POS(p, repLen - 1)\r
return repLen;\r
}\r
- \r
+\r
if (mainLen < 2 || numAvail <= 2)\r
return 1;\r
\r
{\r
unsigned len1 = ReadMatchDistances(p, &p->numPairs);\r
p->longestMatchLen = len1;\r
- \r
+\r
if (len1 >= 2)\r
{\r
UInt32 newDist = p->matches[(size_t)p->numPairs - 1];\r
return 1;\r
}\r
}\r
- \r
+\r
data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;\r
- \r
+\r
for (i = 0; i < LZMA_NUM_REPS; i++)\r
{\r
unsigned len, limit;\r
break;\r
}\r
}\r
- \r
+\r
p->backRes = mainDist + LZMA_NUM_REPS;\r
if (mainLen != 2)\r
{\r
RC_BIT_0(&p->rc, prob)\r
}\r
p->state = kMatchNextStates[p->state];\r
- \r
+\r
p->rc.range = range;\r
LenEnc_Encode(&p->lenProbs, &p->rc, 0, posState);\r
range = p->rc.range;\r
}\r
while (--numBits);\r
}\r
- \r
+\r
{\r
// RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask);\r
CLzmaProb *probs = p->posAlignEncoder;\r
}\r
\r
\r
-\r
-static void FillAlignPrices(CLzmaEnc *p)\r
+MY_NO_INLINE static void FillAlignPrices(CLzmaEnc *p)\r
{\r
unsigned i;\r
const CProbPrice *ProbPrices = p->ProbPrices;\r
const CLzmaProb *probs = p->posAlignEncoder;\r
- p->alignPriceCount = 0;\r
+ // p->alignPriceCount = 0;\r
for (i = 0; i < kAlignTableSize / 2; i++)\r
{\r
UInt32 price = 0;\r
- unsigned symbol = i;\r
+ unsigned sym = i;\r
unsigned m = 1;\r
unsigned bit;\r
UInt32 prob;\r
- bit = symbol & 1; symbol >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit;\r
- bit = symbol & 1; symbol >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit;\r
- bit = symbol & 1; symbol >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit;\r
+ bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit;\r
+ bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit;\r
+ bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit;\r
prob = probs[m];\r
p->alignPrices[i ] = price + GET_PRICEa_0(prob);\r
p->alignPrices[i + 8] = price + GET_PRICEa_1(prob);\r
}\r
\r
\r
-static void FillDistancesPrices(CLzmaEnc *p)\r
+MY_NO_INLINE static void FillDistancesPrices(CLzmaEnc *p)\r
{\r
+ // int y; for (y = 0; y < 100; y++) {\r
+\r
UInt32 tempPrices[kNumFullDistances];\r
- unsigned i, lenToPosState;\r
+ unsigned i, lps;\r
\r
const CProbPrice *ProbPrices = p->ProbPrices;\r
p->matchPriceCount = 0;\r
\r
- for (i = kStartPosModelIndex; i < kNumFullDistances; i++)\r
+ for (i = kStartPosModelIndex / 2; i < kNumFullDistances / 2; i++)\r
{\r
unsigned posSlot = GetPosSlot1(i);\r
- unsigned footerBits = ((posSlot >> 1) - 1);\r
+ unsigned footerBits = (posSlot >> 1) - 1;\r
unsigned base = ((2 | (posSlot & 1)) << footerBits);\r
+ const CLzmaProb *probs = p->posEncoders + (size_t)base * 2;\r
// tempPrices[i] = RcTree_ReverseGetPrice(p->posEncoders + base, footerBits, i - base, p->ProbPrices);\r
-\r
- const CLzmaProb *probs = p->posEncoders + base;\r
UInt32 price = 0;\r
unsigned m = 1;\r
- unsigned symbol = i - base;\r
+ unsigned sym = i;\r
+ unsigned offset = (unsigned)1 << footerBits;\r
+ base += i;\r
+\r
+ if (footerBits)\r
do\r
{\r
- unsigned bit = symbol & 1;\r
- symbol >>= 1;\r
+ unsigned bit = sym & 1;\r
+ sym >>= 1;\r
price += GET_PRICEa(probs[m], bit);\r
m = (m << 1) + bit;\r
}\r
while (--footerBits);\r
- tempPrices[i] = price;\r
+\r
+ {\r
+ unsigned prob = probs[m];\r
+ tempPrices[base ] = price + GET_PRICEa_0(prob);\r
+ tempPrices[base + offset] = price + GET_PRICEa_1(prob);\r
+ }\r
}\r
\r
- for (lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++)\r
+ for (lps = 0; lps < kNumLenToPosStates; lps++)\r
{\r
- unsigned posSlot;\r
- const CLzmaProb *encoder = p->posSlotEncoder[lenToPosState];\r
- UInt32 *posSlotPrices = p->posSlotPrices[lenToPosState];\r
- unsigned distTableSize = p->distTableSize;\r
- const CLzmaProb *probs = encoder;\r
- for (posSlot = 0; posSlot < distTableSize; posSlot += 2)\r
+ unsigned slot;\r
+ unsigned distTableSize2 = (p->distTableSize + 1) >> 1;\r
+ UInt32 *posSlotPrices = p->posSlotPrices[lps];\r
+ const CLzmaProb *probs = p->posSlotEncoder[lps];\r
+\r
+ for (slot = 0; slot < distTableSize2; slot++)\r
{\r
- // posSlotPrices[posSlot] = RcTree_GetPrice(encoder, kNumPosSlotBits, posSlot, p->ProbPrices);\r
- UInt32 price = 0;\r
+ // posSlotPrices[slot] = RcTree_GetPrice(encoder, kNumPosSlotBits, slot, p->ProbPrices);\r
+ UInt32 price;\r
unsigned bit;\r
- unsigned symbol = (posSlot >> 1) + (1 << (kNumPosSlotBits - 1));\r
- UInt32 prob;\r
- bit = symbol & 1; symbol >>= 1; price += GET_PRICEa(probs[symbol], bit);\r
- bit = symbol & 1; symbol >>= 1; price += GET_PRICEa(probs[symbol], bit);\r
- bit = symbol & 1; symbol >>= 1; price += GET_PRICEa(probs[symbol], bit);\r
- bit = symbol & 1; symbol >>= 1; price += GET_PRICEa(probs[symbol], bit);\r
- bit = symbol & 1; symbol >>= 1; price += GET_PRICEa(probs[symbol], bit);\r
- prob = probs[(posSlot >> 1) + (1 << (kNumPosSlotBits - 1))];\r
- posSlotPrices[posSlot ] = price + GET_PRICEa_0(prob);\r
- posSlotPrices[posSlot + 1] = price + GET_PRICEa_1(prob);\r
+ unsigned sym = slot + (1 << (kNumPosSlotBits - 1));\r
+ unsigned prob;\r
+ bit = sym & 1; sym >>= 1; price = GET_PRICEa(probs[sym], bit);\r
+ bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[sym], bit);\r
+ bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[sym], bit);\r
+ bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[sym], bit);\r
+ bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[sym], bit);\r
+ prob = probs[(size_t)slot + (1 << (kNumPosSlotBits - 1))];\r
+ posSlotPrices[(size_t)slot * 2 ] = price + GET_PRICEa_0(prob);\r
+ posSlotPrices[(size_t)slot * 2 + 1] = price + GET_PRICEa_1(prob);\r
}\r
- for (posSlot = kEndPosModelIndex; posSlot < distTableSize; posSlot++)\r
- posSlotPrices[posSlot] += ((UInt32)(((posSlot >> 1) - 1) - kNumAlignBits) << kNumBitPriceShiftBits);\r
\r
{\r
- UInt32 *distancesPrices = p->distancesPrices[lenToPosState];\r
+ UInt32 delta = ((UInt32)((kEndPosModelIndex / 2 - 1) - kNumAlignBits) << kNumBitPriceShiftBits);\r
+ for (slot = kEndPosModelIndex / 2; slot < distTableSize2; slot++)\r
{\r
- distancesPrices[0] = posSlotPrices[0];\r
- distancesPrices[1] = posSlotPrices[1];\r
- distancesPrices[2] = posSlotPrices[2];\r
- distancesPrices[3] = posSlotPrices[3];\r
+ posSlotPrices[(size_t)slot * 2 ] += delta;\r
+ posSlotPrices[(size_t)slot * 2 + 1] += delta;\r
+ delta += ((UInt32)1 << kNumBitPriceShiftBits);\r
}\r
+ }\r
+\r
+ {\r
+ UInt32 *dp = p->distancesPrices[lps];\r
+\r
+ dp[0] = posSlotPrices[0];\r
+ dp[1] = posSlotPrices[1];\r
+ dp[2] = posSlotPrices[2];\r
+ dp[3] = posSlotPrices[3];\r
+\r
for (i = 4; i < kNumFullDistances; i += 2)\r
{\r
UInt32 slotPrice = posSlotPrices[GetPosSlot1(i)];\r
- distancesPrices[i ] = slotPrice + tempPrices[i];\r
- distancesPrices[i + 1] = slotPrice + tempPrices[i + 1];\r
+ dp[i ] = slotPrice + tempPrices[i];\r
+ dp[i + 1] = slotPrice + tempPrices[i + 1];\r
}\r
}\r
}\r
+ // }\r
}\r
\r
\r
{\r
RangeEnc_Construct(&p->rc);\r
MatchFinder_Construct(&p->matchFinderBase);\r
- \r
+\r
#ifndef _7ZIP_ST\r
MatchFinderMt_Construct(&p->matchFinderMt);\r
p->matchFinderMt.MatchFinder = &p->matchFinderBase;\r
#ifndef _7ZIP_ST\r
MatchFinderMt_Destruct(&p->matchFinderMt, allocBig);\r
#endif\r
- \r
+\r
MatchFinder_Free(&p->matchFinderBase, allocBig);\r
LzmaEnc_FreeLits(p, alloc);\r
RangeEnc_Free(&p->rc, alloc);\r
}\r
\r
if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) != 0)\r
- \r
+\r
for (;;)\r
{\r
UInt32 dist;\r
unsigned len, posState;\r
UInt32 range, ttt, newBound;\r
CLzmaProb *probs;\r
- \r
+\r
if (p->fastMode)\r
len = GetOptimumFast(p);\r
else\r
posState = (unsigned)nowPos32 & p->pbMask;\r
range = p->rc.range;\r
probs = &p->isMatch[p->state][posState];\r
- \r
+\r
RC_BIT_PRE(&p->rc, probs)\r
- \r
+\r
dist = p->backRes;\r
\r
#ifdef SHOW_STAT2\r
RC_BIT_1(&p->rc, probs);\r
probs = &p->isRep[p->state];\r
RC_BIT_PRE(&p->rc, probs)\r
- \r
+\r
if (dist < LZMA_NUM_REPS)\r
{\r
RC_BIT_1(&p->rc, probs);\r
if (len != 1)\r
{\r
LenEnc_Encode(&p->repLenProbs, &p->rc, len - LZMA_MATCH_LEN_MIN, posState);\r
- if (!p->fastMode)\r
- if (--p->repLenEnc.counters[posState] == 0)\r
- LenPriceEnc_UpdateTable(&p->repLenEnc, posState, &p->repLenProbs, p->ProbPrices);\r
-\r
+ --p->repLenEncCounter;\r
p->state = kRepNextStates[p->state];\r
}\r
}\r
p->state = kMatchNextStates[p->state];\r
\r
LenEnc_Encode(&p->lenProbs, &p->rc, len - LZMA_MATCH_LEN_MIN, posState);\r
- if (!p->fastMode)\r
- if (--p->lenEnc.counters[posState] == 0)\r
- LenPriceEnc_UpdateTable(&p->lenEnc, posState, &p->lenProbs, p->ProbPrices);\r
+ // --p->lenEnc.counter;\r
\r
dist -= LZMA_NUM_REPS;\r
p->reps[3] = p->reps[2];\r
p->reps[2] = p->reps[1];\r
p->reps[1] = p->reps[0];\r
p->reps[0] = dist + 1;\r
- \r
+\r
p->matchPriceCount++;\r
GetPosSlot(dist, posSlot);\r
// RcTree_Encode_PosSlot(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], posSlot);\r
{\r
- UInt32 symbol = posSlot + (1 << kNumPosSlotBits);\r
+ UInt32 sym = (UInt32)posSlot + (1 << kNumPosSlotBits);\r
range = p->rc.range;\r
probs = p->posSlotEncoder[GetLenToPosState(len)];\r
do\r
{\r
- CLzmaProb *prob = probs + (symbol >> kNumPosSlotBits);\r
- UInt32 bit = (symbol >> (kNumPosSlotBits - 1)) & 1;\r
- symbol <<= 1;\r
+ CLzmaProb *prob = probs + (sym >> kNumPosSlotBits);\r
+ UInt32 bit = (sym >> (kNumPosSlotBits - 1)) & 1;\r
+ sym <<= 1;\r
RC_BIT(&p->rc, prob, bit);\r
}\r
- while (symbol < (1 << kNumPosSlotBits * 2));\r
+ while (sym < (1 << kNumPosSlotBits * 2));\r
p->rc.range = range;\r
}\r
- \r
+\r
if (dist >= kStartPosModelIndex)\r
{\r
unsigned footerBits = ((posSlot >> 1) - 1);\r
if (dist < kNumFullDistances)\r
{\r
unsigned base = ((2 | (posSlot & 1)) << footerBits);\r
- RcTree_ReverseEncode(&p->rc, p->posEncoders + base, footerBits, dist - base);\r
+ RcTree_ReverseEncode(&p->rc, p->posEncoders + base, footerBits, (unsigned)(dist /* - base */));\r
}\r
else\r
{\r
bit = dist & 1; dist >>= 1; RC_BIT(&p->rc, p->posAlignEncoder + m, bit); m = (m << 1) + bit;\r
bit = dist & 1; RC_BIT(&p->rc, p->posAlignEncoder + m, bit);\r
p->rc.range = range;\r
- p->alignPriceCount++;\r
+ // p->alignPriceCount++;\r
}\r
}\r
}\r
}\r
}\r
\r
- nowPos32 += len;\r
+ nowPos32 += (UInt32)len;\r
p->additionalOffset -= len;\r
- \r
+\r
if (p->additionalOffset == 0)\r
{\r
UInt32 processed;\r
\r
if (!p->fastMode)\r
{\r
- if (p->matchPriceCount >= (1 << 7))\r
+ /*\r
+ if (p->alignPriceCount >= 16) // kAlignTableSize\r
+ FillAlignPrices(p);\r
+ if (p->matchPriceCount >= 128)\r
FillDistancesPrices(p);\r
- if (p->alignPriceCount >= kAlignTableSize)\r
+ if (p->lenEnc.counter <= 0)\r
+ LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, &p->lenProbs, p->ProbPrices);\r
+ */\r
+ if (p->matchPriceCount >= 64)\r
+ {\r
FillAlignPrices(p);\r
+ // { int y; for (y = 0; y < 100; y++) {\r
+ FillDistancesPrices(p);\r
+ // }}\r
+ LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, &p->lenProbs, p->ProbPrices);\r
+ }\r
+ if (p->repLenEncCounter <= 0)\r
+ {\r
+ p->repLenEncCounter = REP_LEN_COUNT;\r
+ LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, &p->repLenProbs, p->ProbPrices);\r
+ }\r
}\r
- \r
+\r
if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0)\r
break;\r
processed = nowPos32 - startPos32;\r
- \r
+\r
if (maxPackSize)\r
{\r
if (processed + kNumOpts + 300 >= maxUnpackSize\r
p->matchFinderObj = &p->matchFinderBase;\r
MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder);\r
}\r
- \r
+\r
return SZ_OK;\r
}\r
\r
\r
p->optEnd = 0;\r
p->optCur = 0;\r
+\r
+ {\r
+ for (i = 0; i < kNumOpts; i++)\r
+ p->opt[i].price = kInfinityPrice;\r
+ }\r
+\r
p->additionalOffset = 0;\r
\r
p->pbMask = (1 << p->pb) - 1;\r
p->lpMask = ((UInt32)0x100 << p->lp) - ((unsigned)0x100 >> p->lc);\r
}\r
\r
+\r
void LzmaEnc_InitPrices(CLzmaEnc *p)\r
{\r
if (!p->fastMode)\r
p->lenEnc.tableSize =\r
p->repLenEnc.tableSize =\r
p->numFastBytes + 1 - LZMA_MATCH_LEN_MIN;\r
+\r
+ p->repLenEncCounter = REP_LEN_COUNT;\r
+\r
LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, &p->lenProbs, p->ProbPrices);\r
LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, &p->repLenProbs, p->ProbPrices);\r
}\r
ISeqOutStream vt;\r
Byte *data;\r
SizeT rem;\r
- Bool overflow;\r
+ BoolInt overflow;\r
} CLzmaEnc_SeqOutStreamBuf;\r
\r
static size_t SeqOutStreamBuf_Write(const ISeqOutStream *pp, const void *data, size_t size)\r
}\r
\r
\r
-SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,\r
+SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit,\r
Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)\r
{\r
CLzmaEnc *p = (CLzmaEnc *)pp;\r
return SZ_ERROR_OUTPUT_EOF;\r
\r
res = LzmaEnc_CodeOneBlock(p, desiredPackSize, *unpackSize);\r
- \r
+\r
*unpackSize = (UInt32)(p->nowPos64 - nowPos64);\r
*destLen -= outStream.rem;\r
if (outStream.overflow)\r
}\r
}\r
}\r
- \r
+\r
LzmaEnc_Finish(p);\r
\r
/*\r
p->rc.outStream = &outStream.vt;\r
\r
res = LzmaEnc_MemPrepare(pp, src, srcLen, 0, alloc, allocBig);\r
- \r
+\r
if (res == SZ_OK)\r
{\r
res = LzmaEnc_Encode2(p, progress);\r
HISTORY of the LZMA SDK\r
-----------------------\r
\r
+19.00 2019-02-21\r
+-------------------------\r
+- Encryption strength for 7z archives was increased:\r
+ the size of random initialization vector was increased from 64-bit to 128-bit,\r
+ and the pseudo-random number generator was improved.\r
+- The bug in 7zIn.c code was fixed.\r
+\r
+\r
+18.06 2018-12-30\r
+-------------------------\r
+- The speed for LZMA/LZMA2 compressing was increased by 3-10%,\r
+ and there are minor changes in compression ratio.\r
+- Some bugs were fixed.\r
+- The bug in 7-Zip 18.02-18.05 was fixed:\r
+ There was memory leak in multithreading xz decoder - XzDecMt_Decode(),\r
+ if xz stream contains only one block.\r
+- The changes for MSVS compiler makefiles:\r
+ - the makefiles now use "PLATFORM" macroname with values (x64, x86, arm64)\r
+ instead of "CPU" macroname with values (AMD64, ARM64).\r
+ - the makefiles by default now use static version of the run-time library.\r
+\r
+\r
18.05 2018-04-30\r
-------------------------\r
-- The speed for LZMA/LZMA2 compressing was increased \r
- by 8% for fastest/fast compression levels and \r
+- The speed for LZMA/LZMA2 compressing was increased\r
+ by 8% for fastest/fast compression levels and\r
by 3% for normal/maximum compression levels.\r
- Previous versions of 7-Zip could work incorrectly in "Large memory pages" mode in\r
- Windows 10 because of some BUG with "Large Pages" in Windows 10. \r
+ Windows 10 because of some BUG with "Large Pages" in Windows 10.\r
Now 7-Zip doesn't use "Large Pages" on Windows 10 up to revision 1709 (16299).\r
- The BUG was fixed in Lzma2Enc.c\r
Lzma2Enc_Encode2() function worked incorretly,\r
\r
18.03 beta 2018-03-04\r
-------------------------\r
-- Asm\x86\LzmaDecOpt.asm: new optimized LZMA decoder written in asm \r
+- Asm\x86\LzmaDecOpt.asm: new optimized LZMA decoder written in asm\r
for x64 with about 30% higher speed than main version of LZMA decoder written in C.\r
- The speed for single-thread LZMA/LZMA2 decoder written in C was increased by 3%.\r
- 7-Zip now can use multi-threading for 7z/LZMA2 decoding,\r
18.00 beta 2019-01-10\r
-------------------------\r
- The BUG in xz encoder was fixed:\r
- There was memory leak of 16 KB for each file compressed with \r
+ There was memory leak of 16 KB for each file compressed with\r
xz compression method, if additional filter was used.\r
\r
\r
- Minor speed optimization for LZMA2 (xz and 7z) multi-threading compression.\r
7-Zip now uses additional memory buffers for multi-block LZMA2 compression.\r
CPU utilization was slightly improved.\r
-- 7-zip now creates multi-block xz archives by default. Block size can be \r
+- 7-zip now creates multi-block xz archives by default. Block size can be\r
specified with -ms[Size]{m|g} switch.\r
- xz decoder now can unpack random block from multi-block xz archives.\r
- 7-Zip command line: @listfile now doesn't work after -- switch.\r
\r
17.00 beta 2017-04-29\r
-------------------------\r
-- NewHandler.h / NewHandler.cpp: \r
+- NewHandler.h / NewHandler.cpp:\r
now it redefines operator new() only for old MSVC compilers (_MSC_VER < 1900).\r
- C/7zTypes.h : the names of variables in interface structures were changed (vt).\r
- Some bugs were fixed. 7-Zip could crash in some cases.\r
16.02 2016-05-21\r
-------------------------\r
- The BUG in 16.00 - 16.01 was fixed:\r
- Split Handler (SplitHandler.cpp) returned incorrect \r
+ Split Handler (SplitHandler.cpp) returned incorrect\r
total size value (kpidSize) for split archives.\r
\r
\r
16.01 2016-05-19\r
-------------------------- \r
+-------------------------\r
- Some internal changes to reduce the number of compiler warnings.\r
\r
\r
16.00 2016-05-10\r
-------------------------- \r
+-------------------------\r
- Some bugs were fixed.\r
\r
\r
15.12 2015-11-19\r
-------------------------- \r
+-------------------------\r
- The BUG in C version of 7z decoder was fixed:\r
7zDec.c : SzDecodeLzma2()\r
7z decoder could mistakenly report about decoding error for some 7z archives\r
that use LZMA2 compression method.\r
- The probability to get that mistaken decoding error report was about \r
- one error per 16384 solid blocks for solid blocks larger than 16 KB (compressed size). \r
+ The probability to get that mistaken decoding error report was about\r
+ one error per 16384 solid blocks for solid blocks larger than 16 KB (compressed size).\r
- The BUG (in 9.26-15.11) in C version of 7z decoder was fixed:\r
7zArcIn.c : SzReadHeader2()\r
- 7z decoder worked incorrectly for 7z archives that contain \r
- empty solid blocks, that can be placed to 7z archive, if some file is \r
+ 7z decoder worked incorrectly for 7z archives that contain\r
+ empty solid blocks, that can be placed to 7z archive, if some file is\r
unavailable for reading during archive creation.\r
\r
\r
15.09 beta 2015-10-16\r
-------------------------- \r
+-------------------------\r
- The BUG in LZMA / LZMA2 encoding code was fixed.\r
The BUG in LzFind.c::MatchFinder_ReadBlock() function.\r
If input data size is larger than (4 GiB - dictionary_size),\r
the following code worked incorrectly:\r
- - LZMA : LzmaEnc_MemEncode(), LzmaEncode() : LZMA encoding functions \r
- for compressing from memory to memory. \r
+ - LZMA : LzmaEnc_MemEncode(), LzmaEncode() : LZMA encoding functions\r
+ for compressing from memory to memory.\r
That BUG is not related to LZMA encoder version that works via streams.\r
- - LZMA2 : multi-threaded version of LZMA2 encoder worked incorrectly, if \r
- default value of chunk size (CLzma2EncProps::blockSize) is changed \r
+ - LZMA2 : multi-threaded version of LZMA2 encoder worked incorrectly, if\r
+ default value of chunk size (CLzma2EncProps::blockSize) is changed\r
to value larger than (4 GiB - dictionary_size).\r
\r
\r
9.38 beta 2015-01-03\r
-------------------------- \r
+-------------------------\r
- The BUG in 9.31-9.37 was fixed:\r
IArchiveGetRawProps interface was disabled for 7z archives.\r
- The BUG in 9.26-9.36 was fixed:\r
\r
\r
9.36 beta 2014-12-26\r
-------------------------- \r
+-------------------------\r
- The BUG in command line version was fixed:\r
7-Zip created temporary archive in current folder during update archive\r
- operation, if -w{Path} switch was not specified. \r
+ operation, if -w{Path} switch was not specified.\r
The fixed 7-Zip creates temporary archive in folder that contains updated archive.\r
- The BUG in 9.33-9.35 was fixed:\r
7-Zip silently ignored file reading errors during 7z or gz archive creation,\r
\r
\r
9.35 beta 2014-12-07\r
-------------------------- \r
+-------------------------\r
- 7zr.exe now support AES encryption.\r
- SFX modules were added to LZMA SDK\r
- Some bugs were fixed.\r
\r
\r
9.21 beta 2011-04-11\r
-------------------------- \r
+-------------------------\r
- New class FString for file names at file systems.\r
- Speed optimization in CRC code for big-endian CPUs.\r
- The BUG in Lzma2Dec.c was fixed:\r
\r
\r
9.18 beta 2010-11-02\r
-------------------------- \r
+-------------------------\r
- New small SFX module for installers (SfxSetup).\r
\r
\r
9.11 beta 2010-03-15\r
-------------------------\r
- PPMd compression method support\r
- \r
+\r
\r
9.09 2009-12-12\r
-------------------------\r
4.61 beta 2008-11-23\r
-------------------------\r
- The bug in ANSI-C LZMA Decoder was fixed:\r
- If encoded stream was corrupted, decoder could access memory \r
+ If encoded stream was corrupted, decoder could access memory\r
outside of allocated range.\r
- Some changes in ANSI-C 7z Decoder interfaces.\r
- LZMA SDK is placed in the public domain.\r
4.59 beta 2008-08-13\r
-------------------------\r
- The bug was fixed:\r
- LZMA Encoder in fast compression mode could access memory outside of \r
+ LZMA Encoder in fast compression mode could access memory outside of\r
allocated range in some rare cases.\r
\r
\r
\r
4.57 2007-12-12\r
-------------------------\r
-- Speed optimizations in ?++ LZMA Decoder. \r
+- Speed optimizations in ?++ LZMA Decoder.\r
- Small changes for more compatibility with some C/C++ compilers.\r
\r
\r
- now it supports BCJ and BCJ2 filters\r
- now it supports files larger than 4 GB.\r
- now it supports "Last Write Time" field for files.\r
-- C++ code for .7z archives compressing/decompressing from 7-zip \r
+- C++ code for .7z archives compressing/decompressing from 7-zip\r
was included to LZMA SDK.\r
- \r
+\r
\r
4.43 2006-06-04\r
-------------------------\r
- Small changes for more compatibility with some C/C++ compilers.\r
- \r
+\r
\r
4.42 2006-05-15\r
-------------------------\r
- Small changes in .h files in ANSI-C version.\r
- \r
+\r
\r
4.39 beta 2006-04-14\r
-------------------------\r
- The bug in versions 4.33b:4.38b was fixed:\r
- C++ version of LZMA encoder could not correctly compress \r
+ C++ version of LZMA encoder could not correctly compress\r
files larger than 2 GB with HC4 match finder (-mfhc4).\r
- \r
+\r
\r
4.37 beta 2005-04-06\r
-------------------------\r
-- Fixes in C++ code: code could no be compiled if _NO_EXCEPTIONS was defined. \r
+- Fixes in C++ code: code could no be compiled if _NO_EXCEPTIONS was defined.\r
\r
\r
4.35 beta 2005-03-02\r
-------------------------\r
- The bug was fixed in C++ version of LZMA Decoder:\r
- If encoded stream was corrupted, decoder could access memory \r
+ If encoded stream was corrupted, decoder could access memory\r
outside of allocated range.\r
\r
\r
\r
4.17 2005-04-18\r
-------------------------\r
-- New example for RAM->RAM compressing/decompressing: \r
+- New example for RAM->RAM compressing/decompressing:\r
LZMA + BCJ (filter for x86 code):\r
- LzmaRam.h\r
- LzmaRam.cpp\r
\r
4.16 2005-03-29\r
-------------------------\r
-- The bug was fixed in LzmaDecode.c (ANSI-C LZMA Decoder): \r
+- The bug was fixed in LzmaDecode.c (ANSI-C LZMA Decoder):\r
If _LZMA_OUT_READ was defined, and if encoded stream was corrupted,\r
decoder could access memory outside of allocated range.\r
- Speed optimization of ANSI-C LZMA Decoder (now it's about 20% faster).\r
- Old version of LZMA Decoder now is in file LzmaDecodeSize.c. \r
+ Old version of LZMA Decoder now is in file LzmaDecodeSize.c.\r
LzmaDecodeSize.c can provide slightly smaller code than LzmaDecode.c\r
- Small speed optimization in LZMA C++ code\r
- filter for SPARC's code was added\r
\r
4.05 2004-08-25\r
-------------------------\r
-- Source code of filters for x86, IA-64, ARM, ARM-Thumb \r
+- Source code of filters for x86, IA-64, ARM, ARM-Thumb\r
and PowerPC code was included to SDK\r
- Some internal minor changes\r
\r
\r
4.03 2004-06-18\r
-------------------------\r
-- "Benchmark" command was added. It measures compressing \r
- and decompressing speed and shows rating values. \r
+- "Benchmark" command was added. It measures compressing\r
+ and decompressing speed and shows rating values.\r
Also it checks hardware errors.\r
\r
\r
\r
HISTORY of the LZMA\r
-------------------\r
- 2001-2008: Improvements to LZMA compressing/decompressing code, \r
+ 2001-2008: Improvements to LZMA compressing/decompressing code,\r
keeping compatibility with original LZMA format\r
1996-2001: Development of LZMA compression format\r
\r
\r
2001-08-30: LZMA compression was added to 7-Zip\r
1999-01-02: First version of 7-Zip was released\r
- \r
+\r
\r
End of document\r