]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools LzmaCompress: Update LZMA to new 19.00 version
authorLiu, WeiX C <weix.c.liu@intel.com>
Tue, 5 Jan 2021 06:14:02 +0000 (14:14 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 8 Jan 2021 10:03:53 +0000 (10:03 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3101
New formal release in https://www.7-zip.org/sdk.html is 19.00.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Wei Liu <weix.c.liu@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
12 files changed:
BaseTools/Source/C/LzmaCompress/LZMA-SDK-README.txt
BaseTools/Source/C/LzmaCompress/LzmaCompress.c
BaseTools/Source/C/LzmaCompress/Sdk/C/7zTypes.h
BaseTools/Source/C/LzmaCompress/Sdk/C/7zVersion.h
BaseTools/Source/C/LzmaCompress/Sdk/C/CpuArch.h
BaseTools/Source/C/LzmaCompress/Sdk/C/LzFind.c
BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.c
BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.h
BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c
BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt
BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-sdk.txt

index 7cf967a774013c69397a619ca68546a8f3a53d68..b2338e2598e45e4f05a29256e02aff059fc27a89 100644 (file)
@@ -1,3 +1,3 @@
-LzmaCompress is based on the LZMA SDK 18.05.  LZMA SDK 18.05\r
-was placed in the public domain on 2018-04-30.  It was\r
+LzmaCompress is based on the LZMA SDK 19.00.  LZMA SDK 19.00\r
+was placed in the public domain on 2019-02-21.  It was\r
 released on the http://www.7-zip.org/sdk.html website.\r
index bebdb9aa84a15da524443b13b63dc5aede6dbd56..bf4706ee2357e96b6e365942a55877356ea80d39 100644 (file)
@@ -1,9 +1,9 @@
 /** @file\r
   LZMA Compress/Decompress tool (LzmaCompress)\r
 \r
-  Based on LZMA SDK 18.05:\r
+  Based on LZMA SDK 19.00:\r
     LzmaUtil.c -- Test application for LZMA compression\r
-    2018-04-30 : Igor Pavlov : Public domain\r
+    2019-02-21 : Igor Pavlov : Public domain\r
 \r
   Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
@@ -39,7 +39,7 @@ const char *kCantAllocateMessage = "Can not allocate memory";
 const char *kDataErrorMessage = "Data error";\r
 const char *kInvalidParamValMessage = "Invalid parameter value";\r
 \r
-static Bool mQuietMode = False;\r
+static BoolInt mQuietMode = False;\r
 static CONVERTER_TYPE mConType = NoConverter;\r
 \r
 UINT64 mDictionarySize = 28;\r
@@ -244,7 +244,7 @@ int main2(int numArgs, const char *args[], char *rs)
   CFileOutStream outStream;\r
   int res;\r
   int encodeMode = 0;\r
-  Bool modeWasSet = False;\r
+  BoolInt modeWasSet = False;\r
   const char *inputFile = NULL;\r
   const char *outputFile = "file.tmp";\r
   int param;\r
index 4977cdaa66d96b4fe8450c77d2e7464c9b4bbc60..593f5aa2597e37276179796d75d21f9acf043f4e 100644 (file)
@@ -1,5 +1,5 @@
 /* 7zTypes.h -- Basic types\r
-2017-07-17 : Igor Pavlov : Public domain */\r
+2018-08-04 : Igor Pavlov : Public domain */\r
 \r
 #ifndef __7Z_TYPES_H\r
 #define __7Z_TYPES_H\r
@@ -103,7 +103,8 @@ typedef UInt32 SizeT;
 typedef size_t SizeT;\r
 #endif\r
 \r
-typedef int Bool;\r
+typedef int BoolInt;\r
+/* typedef BoolInt Bool; */\r
 #define True 1\r
 #define False 0\r
 \r
index ed3aa94270c96d25df6f3973fa52adbc274115bf..0074c64be96f1527b652f7b51f9c6cb6f6713eff 100644 (file)
@@ -1,7 +1,7 @@
-#define MY_VER_MAJOR 18\r
-#define MY_VER_MINOR 05\r
+#define MY_VER_MAJOR 19\r
+#define MY_VER_MINOR 00\r
 #define MY_VER_BUILD 0\r
-#define MY_VERSION_NUMBERS "18.05"\r
+#define MY_VERSION_NUMBERS "19.00"\r
 #define MY_VERSION MY_VERSION_NUMBERS\r
 \r
 #ifdef MY_CPU_NAME\r
@@ -10,7 +10,7 @@
   #define MY_VERSION_CPU MY_VERSION\r
 #endif\r
 \r
-#define MY_DATE "2018-04-30"\r
+#define MY_DATE "2019-02-21"\r
 #undef MY_COPYRIGHT\r
 #undef MY_VERSION_COPYRIGHT_DATE\r
 #define MY_AUTHOR_NAME "Igor Pavlov"\r
index 7fb27282c721a077782daf16bea7d09101853af4..5f74c1c0cbd7430deedd638da4e966c1176205d0 100644 (file)
@@ -1,5 +1,5 @@
 /* CpuArch.h -- CPU specific code\r
-2017-09-04 : Igor Pavlov : Public domain */\r
+2018-02-18 : Igor Pavlov : Public domain */\r
 \r
 #ifndef __CPU_ARCH_H\r
 #define __CPU_ARCH_H\r
@@ -318,15 +318,16 @@ enum
 \r
 void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d);\r
 \r
-Bool x86cpuid_CheckAndRead(Cx86cpuid *p);\r
+BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p);\r
 int x86cpuid_GetFirm(const Cx86cpuid *p);\r
 \r
 #define x86cpuid_GetFamily(ver) (((ver >> 16) & 0xFF0) | ((ver >> 8) & 0xF))\r
 #define x86cpuid_GetModel(ver)  (((ver >> 12) &  0xF0) | ((ver >> 4) & 0xF))\r
 #define x86cpuid_GetStepping(ver) (ver & 0xF)\r
 \r
-Bool CPU_Is_InOrder();\r
-Bool CPU_Is_Aes_Supported();\r
+BoolInt CPU_Is_InOrder();\r
+BoolInt CPU_Is_Aes_Supported();\r
+BoolInt CPU_IsSupported_PageGB();\r
 \r
 #endif\r
 \r
index 6ea82a9b53449a2927f5003053561504b525a1e1..f89c9ddd7de3d9acf6020293696d47c388a57958 100644 (file)
@@ -1,5 +1,5 @@
 /* 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
@@ -73,7 +73,7 @@ static void MatchFinder_ReadBlock(CMatchFinder *p)
       p->streamEndWasReached = 1;\r
     return;\r
   }\r
-  \r
+\r
   for (;;)\r
   {\r
     Byte *dest = p->buffer + (p->streamPos - p->pos);\r
@@ -138,7 +138,7 @@ static void MatchFinder_SetDefaultSettings(CMatchFinder *p)
 \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
@@ -147,7 +147,7 @@ void MatchFinder_Construct(CMatchFinder *p)
 \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
@@ -180,24 +180,24 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
     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
@@ -243,7 +243,7 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
       p->historySize = historySize;\r
       p->hashSizeSum = hs;\r
       p->cyclicBufferSize = newCyclicBufferSize;\r
-      \r
+\r
       numSons = newCyclicBufferSize;\r
       if (p->btMode)\r
         numSons <<= 1;\r
@@ -251,11 +251,11 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
 \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
@@ -272,11 +272,11 @@ static void MatchFinder_SetLimits(CMatchFinder *p)
 {\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
@@ -284,10 +284,10 @@ static void MatchFinder_SetLimits(CMatchFinder *p)
   }\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
@@ -326,10 +326,10 @@ void MatchFinder_Init_3(CMatchFinder *p, int readData)
   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
@@ -341,7 +341,7 @@ void MatchFinder_Init(CMatchFinder *p)
   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
@@ -368,6 +368,8 @@ static void MatchFinder_Normalize(CMatchFinder *p)
   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
@@ -379,10 +381,16 @@ static void MatchFinder_CheckLimits(CMatchFinder *p)
   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
@@ -400,7 +408,8 @@ static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos,
             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
@@ -408,15 +417,58 @@ static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos,
       }\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
@@ -426,9 +478,10 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt
       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
@@ -437,11 +490,12 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt
               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
@@ -468,9 +522,9 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt
 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
@@ -480,9 +534,9 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const
       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
@@ -520,13 +574,13 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const
   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
@@ -535,22 +589,22 @@ static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
 #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
@@ -561,7 +615,7 @@ static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 \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
@@ -572,7 +626,8 @@ UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 \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
@@ -584,7 +639,7 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
   d2 = pos - hash[h2];\r
 \r
   curMatch = (hash + kFix3HashSize)[hv];\r
-  \r
+\r
   hash[h2] = pos;\r
   (hash + kFix3HashSize)[hv] = pos;\r
 \r
@@ -594,22 +649,23 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
   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
@@ -618,25 +674,26 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
   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
@@ -644,21 +701,21 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
     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
@@ -674,13 +731,13 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
   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
@@ -710,7 +767,7 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
     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
@@ -720,7 +777,7 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
     offset += 2;\r
     d2 = d4;\r
   }\r
-  \r
+\r
   if (offset != 0)\r
   {\r
     UPDATE_maxLen\r
@@ -734,14 +791,15 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 \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
@@ -749,13 +807,12 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 \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
@@ -764,11 +821,12 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 \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
@@ -776,22 +834,22 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
     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
@@ -807,14 +865,14 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 \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
@@ -844,7 +902,7 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
     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
@@ -854,7 +912,7 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
     offset += 2;\r
     d2 = d4;\r
   }\r
-  \r
+\r
   if (offset != 0)\r
   {\r
     UPDATE_maxLen\r
@@ -865,7 +923,7 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
       MOVE_POS_RET;\r
     }\r
   }\r
-  \r
+\r
   if (maxLen < 4)\r
     maxLen = 4;\r
 \r
@@ -877,12 +935,12 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
 \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
@@ -940,7 +998,7 @@ static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
     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
@@ -959,7 +1017,7 @@ static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
     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
@@ -979,7 +1037,7 @@ static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
     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
@@ -999,7 +1057,7 @@ static void Hc5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
     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
index 2563824fcdef0bbad7d3148e2f3050f760e3098f..df32146f920a64d625f57413a9d1a993acfdd20c 100644 (file)
@@ -1,5 +1,5 @@
 /* LzFindMt.c -- multithreaded Match finder for LZ algorithms\r
-2017-06-10 : Igor Pavlov : Public domain */\r
+2018-12-29 : Igor Pavlov : Public domain */\r
 \r
 #include "Precomp.h"\r
 \r
@@ -232,38 +232,57 @@ static void MatchFinderMt_GetNextBlock_Hash(CMatchFinderMt *p)
 \r
 #define kEmptyHashValue 0\r
 \r
-/* #define MFMT_GM_INLINE */\r
+#define MFMT_GM_INLINE\r
 \r
 #ifdef MFMT_GM_INLINE\r
 \r
-#define NO_INLINE MY_FAST_CALL\r
+/*\r
+  we use size_t for _cyclicBufferPos instead of UInt32\r
+  to eliminate "movsx" BUG in old MSVC x64 compiler.\r
+*/\r
 \r
-static Int32 NO_INLINE GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *cur, CLzRef *son,\r
-    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,\r
-    UInt32 *_distances, UInt32 _maxLen, const UInt32 *hash, Int32 limit, UInt32 size, UInt32 *posRes)\r
+MY_NO_INLINE\r
+static UInt32 *GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *cur, CLzRef *son,\r
+    size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,\r
+    UInt32 *distances, UInt32 _maxLen, const UInt32 *hash, const UInt32 *limit, UInt32 size, UInt32 *posRes)\r
 {\r
   do\r
   {\r
-  UInt32 *distances = _distances + 1;\r
-  UInt32 curMatch = pos - *hash++;\r
+  UInt32 *_distances = ++distances;\r
+  UInt32 delta = *hash++;\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
   UInt32 cutValue = _cutValue;\r
-  UInt32 maxLen = _maxLen;\r
-  for (;;)\r
+  unsigned maxLen = (unsigned)_maxLen;\r
+\r
+  /*\r
+  if (size > 1)\r
   {\r
-    UInt32 delta = pos - curMatch;\r
-    if (cutValue-- == 0 || delta >= _cyclicBufferSize)\r
+    UInt32 delta = *hash;\r
+    if (delta < _cyclicBufferSize)\r
     {\r
-      *ptr0 = *ptr1 = kEmptyHashValue;\r
-      break;\r
+      UInt32 cyc1 = _cyclicBufferPos + 1;\r
+      CLzRef *pair = son + ((size_t)(cyc1 - delta + ((delta > cyc1) ? _cyclicBufferSize : 0)) << 1);\r
+      Byte b = *(cur + 1 - delta);\r
+      _distances[0] = pair[0];\r
+      _distances[1] = b;\r
     }\r
+  }\r
+  */\r
+  if (cutValue == 0 || delta >= _cyclicBufferSize)\r
+  {\r
+    *ptr0 = *ptr1 = kEmptyHashValue;\r
+  }\r
+  else\r
+  for(;;)\r
+  {\r
     {\r
-      CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);\r
+      CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((_cyclicBufferPos < delta) ? _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;\r
       if (pb[len] == cur[len])\r
       {\r
         if (++len != lenLimit && pb[len] == cur[len])\r
@@ -272,54 +291,66 @@ static Int32 NO_INLINE GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *
               break;\r
         if (maxLen < len)\r
         {\r
-          *distances++ = maxLen = len;\r
+          maxLen = len;\r
+          *distances++ = (UInt32)len;\r
           *distances++ = delta - 1;\r
           if (len == lenLimit)\r
           {\r
-            *ptr1 = pair[0];\r
-            *ptr0 = pair[1];\r
+            UInt32 pair1 = pair[1];\r
+            *ptr1 = pair0;\r
+            *ptr0 = pair1;\r
             break;\r
           }\r
         }\r
       }\r
-      if (pb[len] < cur[len])\r
-      {\r
-        *ptr1 = curMatch;\r
-        ptr1 = pair + 1;\r
-        curMatch = *ptr1;\r
-        len1 = len;\r
-      }\r
-      else\r
       {\r
-        *ptr0 = curMatch;\r
-        ptr0 = pair;\r
-        curMatch = *ptr0;\r
-        len0 = len;\r
+        UInt32 curMatch = pos - delta;\r
+        // delta = pos - *pair;\r
+        // delta = pos - pair[((UInt32)pb[len] - (UInt32)cur[len]) >> 31];\r
+        if (pb[len] < cur[len])\r
+        {\r
+          delta = pos - pair[1];\r
+          *ptr1 = curMatch;\r
+          ptr1 = pair + 1;\r
+          len1 = len;\r
+        }\r
+        else\r
+        {\r
+          delta = pos - *pair;\r
+          *ptr0 = curMatch;\r
+          ptr0 = pair;\r
+          len0 = len;\r
+        }\r
       }\r
     }\r
+    if (--cutValue == 0 || delta >= _cyclicBufferSize)\r
+    {\r
+      *ptr0 = *ptr1 = kEmptyHashValue;\r
+      break;\r
+    }\r
   }\r
   pos++;\r
   _cyclicBufferPos++;\r
   cur++;\r
   {\r
     UInt32 num = (UInt32)(distances - _distances);\r
-    *_distances = num - 1;\r
-    _distances += num;\r
-    limit -= num;\r
+    _distances[-1] = num;\r
   }\r
   }\r
-  while (limit > 0 && --size != 0);\r
+  while (distances < limit && --size != 0);\r
   *posRes = pos;\r
-  return limit;\r
+  return distances;\r
 }\r
 \r
 #endif\r
 \r
+\r
+\r
 static void BtGetMatches(CMatchFinderMt *p, UInt32 *distances)\r
 {\r
   UInt32 numProcessed = 0;\r
   UInt32 curPos = 2;\r
-  UInt32 limit = kMtBtBlockSize - (p->matchMaxLen * 2);\r
+  UInt32 limit = kMtBtBlockSize - (p->matchMaxLen * 2); //  * 2\r
   \r
   distances[1] = p->hashNumAvail;\r
   \r
@@ -369,8 +400,10 @@ static void BtGetMatches(CMatchFinderMt *p, UInt32 *distances)
       #else\r
       {\r
         UInt32 posRes;\r
-        curPos = limit - GetMatchesSpecN(lenLimit, pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue,\r
-            distances + curPos, p->numHashBytes - 1, p->hashBuf + p->hashBufPos, (Int32)(limit - curPos), size, &posRes);\r
+        curPos = (UInt32)(GetMatchesSpecN(lenLimit, pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue,\r
+            distances + curPos, p->numHashBytes - 1, p->hashBuf + p->hashBufPos,\r
+            distances + limit,\r
+            size, &posRes) - distances);\r
         p->hashBufPos += posRes - pos;\r
         cyclicBufferPos += posRes - pos;\r
         p->buffer += posRes - pos;\r
index 3d86c788f3f90f0af40a7cb7bc69b82191e65c2f..fdd17008c236c0db5ff15f03456f8bef83cb06d8 100644 (file)
@@ -1,5 +1,5 @@
 /* LzFindMt.h -- multithreaded Match finder for LZ algorithms\r
-2017-04-03 : Igor Pavlov : Public domain */\r
+2018-07-04 : Igor Pavlov : Public domain */\r
 \r
 #ifndef __LZ_FIND_MT_H\r
 #define __LZ_FIND_MT_H\r
@@ -19,10 +19,10 @@ EXTERN_C_BEGIN
 \r
 typedef struct _CMtSync\r
 {\r
-  Bool wasCreated;\r
-  Bool needStart;\r
-  Bool exit;\r
-  Bool stopWriting;\r
+  BoolInt wasCreated;\r
+  BoolInt needStart;\r
+  BoolInt exit;\r
+  BoolInt stopWriting;\r
 \r
   CThread thread;\r
   CAutoResetEvent canStart;\r
@@ -30,8 +30,8 @@ typedef struct _CMtSync
   CAutoResetEvent wasStopped;\r
   CSemaphore freeSemaphore;\r
   CSemaphore filledSemaphore;\r
-  Bool csWasInitialized;\r
-  Bool csWasEntered;\r
+  BoolInt csWasInitialized;\r
+  BoolInt csWasEntered;\r
   CCriticalSection cs;\r
   UInt32 numProcessedBlocks;\r
 } CMtSync;\r
index 962b94bb633847135e4a53724e3d385b1e6c290e..4d1576419fde2699ac13e59859ab2f2a6246a85f 100644 (file)
@@ -1,13 +1,13 @@
 /* LzmaDec.c -- LZMA Decoder\r
-2018-02-28 : Igor Pavlov : Public domain */\r
+2018-07-04 : Igor Pavlov : Public domain */\r
 \r
 #include "Precomp.h"\r
 \r
+#include <string.h>\r
+\r
 /* #include "CpuArch.h" */\r
 #include "LzmaDec.h"\r
 \r
-#include <string.h>\r
-\r
 #define kNumTopBits 24\r
 #define kTopValue ((UInt32)1 << kNumTopBits)\r
 \r
@@ -19,7 +19,7 @@
 \r
 #define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }\r
 \r
-#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)\r
+#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound)\r
 #define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));\r
 #define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));\r
 #define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \\r
@@ -66,7 +66,7 @@
 \r
 #define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }\r
 \r
-#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)\r
+#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound)\r
 #define UPDATE_0_CHECK range = bound;\r
 #define UPDATE_1_CHECK range -= bound; code -= bound;\r
 #define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \\r
@@ -539,7 +539,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit
         curLen = ((rem < len) ? (unsigned)rem : len);\r
         pos = dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0);\r
 \r
-        processedPos += curLen;\r
+        processedPos += (UInt32)curLen;\r
 \r
         len -= curLen;\r
         if (curLen <= dicBufSize - pos)\r
@@ -547,7 +547,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit
           Byte *dest = dic + dicPos;\r
           ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;\r
           const Byte *lim = dest + curLen;\r
-          dicPos += curLen;\r
+          dicPos += (SizeT)curLen;\r
           do\r
             *(dest) = (Byte)*(dest + src);\r
           while (++dest != lim);\r
@@ -572,14 +572,14 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit
   p->buf = buf;\r
   p->range = range;\r
   p->code = code;\r
-  p->remainLen = len;\r
+  p->remainLen = (UInt32)len;\r
   p->dicPos = dicPos;\r
   p->processedPos = processedPos;\r
   p->reps[0] = rep0;\r
   p->reps[1] = rep1;\r
   p->reps[2] = rep2;\r
   p->reps[3] = rep3;\r
-  p->state = state;\r
+  p->state = (UInt32)state;\r
 \r
   return SZ_OK;\r
 }\r
@@ -601,8 +601,8 @@ static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
     if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len)\r
       p->checkDicSize = p->prop.dicSize;\r
 \r
-    p->processedPos += len;\r
-    p->remainLen -= len;\r
+    p->processedPos += (UInt32)len;\r
+    p->remainLen -= (UInt32)len;\r
     while (len != 0)\r
     {\r
       len--;\r
@@ -850,7 +850,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
 }\r
 \r
 \r
-void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)\r
+void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState)\r
 {\r
   p->remainLen = kMatchSpecLenStart + 1;\r
   p->tempBufSize = 0;\r
@@ -979,10 +979,10 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
         p->tempBufSize = rem;\r
         if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)\r
         {\r
-          int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem);\r
+          int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, (SizeT)rem);\r
           if (dummyRes == DUMMY_ERROR)\r
           {\r
-            (*srcLen) += lookAhead;\r
+            (*srcLen) += (SizeT)lookAhead;\r
             *status = LZMA_STATUS_NEEDS_MORE_INPUT;\r
             return SZ_OK;\r
           }\r
@@ -1005,9 +1005,9 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
             return SZ_ERROR_FAIL; /* some internal error */\r
           lookAhead -= rem;\r
         }\r
-        (*srcLen) += lookAhead;\r
+        (*srcLen) += (SizeT)lookAhead;\r
         src += lookAhead;\r
-        inSize -= lookAhead;\r
+        inSize -= (SizeT)lookAhead;\r
         p->tempBufSize = 0;\r
       }\r
   }\r
index e281716fee1bfb5eb236c9e38dbd7116f53be58b..4e9b499f8d80dc4d6bc13515e7949030393c6e94 100644 (file)
@@ -1,5 +1,5 @@
 /* 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
@@ -38,6 +38,8 @@ static unsigned g_STAT_OFFSET = 0;
 #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
@@ -52,7 +54,7 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p)
   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
@@ -74,7 +76,7 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p)
   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
@@ -124,7 +126,7 @@ static void LzmaEnc_FastPosInit(Byte *g_FastPos)
   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
@@ -183,8 +185,11 @@ typedef struct
 } 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
@@ -236,10 +241,18 @@ typedef struct
 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
@@ -273,7 +286,7 @@ typedef struct
 \r
   CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];\r
   CLzmaProb posEncoders[kNumFullDistances];\r
-  \r
+\r
   CLenEnc lenProbs;\r
   CLenEnc repLenProbs;\r
 \r
@@ -308,16 +321,18 @@ typedef struct
   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
@@ -325,7 +340,7 @@ typedef struct
   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
@@ -336,7 +351,7 @@ typedef struct
   #ifndef _7ZIP_ST\r
   Byte pad[128];\r
   #endif\r
-  \r
+\r
   // LZ thread\r
   CProbPrice ProbPrices[kBitModelTotal >> kNumMoveReducingBits];\r
 \r
@@ -355,7 +370,7 @@ typedef struct
   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
@@ -383,9 +398,9 @@ void LzmaEnc_SaveState(CLzmaEncHandle pp)
 {\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
@@ -414,9 +429,9 @@ void LzmaEnc_RestoreState(CLzmaEncHandle pp)
 \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
@@ -458,6 +473,7 @@ SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2)
   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
@@ -618,9 +634,9 @@ static void RangeEnc_FlushData(CRangeEnc *p)
 \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
@@ -628,15 +644,15 @@ static void RangeEnc_FlushData(CRangeEnc *p)
 \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
@@ -673,42 +689,42 @@ static void RangeEnc_EncodeBit_0(CRangeEnc *p, CLzmaProb *prob)
   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
@@ -739,11 +755,11 @@ static void LzmaEnc_InitPriceTables(CProbPrice *ProbPrices)
 }\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
@@ -752,48 +768,48 @@ static void LzmaEnc_InitPriceTables(CProbPrice *ProbPrices)
 #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
@@ -812,37 +828,37 @@ static void LenEnc_Init(CLenEnc *p)
     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
@@ -863,50 +879,93 @@ static void SetPrices_3(const CLzmaProb *probs, UInt32 startPrice, UInt32 *price
 }\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
@@ -914,21 +973,21 @@ static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, unsigned numPosStates,
   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
@@ -938,7 +997,7 @@ static unsigned ReadMatchDistances(CLzmaEnc *p, unsigned *numPairsRes)
       printf("%2u %6u   | ", p->matches[i], p->matches[i + 1]);\r
   }\r
   #endif\r
-  \r
+\r
   if (numPairs == 0)\r
     return 0;\r
   {\r
@@ -954,7 +1013,8 @@ static unsigned ReadMatchDistances(CLzmaEnc *p, unsigned *numPairsRes)
         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
@@ -976,8 +1036,8 @@ static unsigned ReadMatchDistances(CLzmaEnc *p, unsigned *numPairsRes)
   + 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
@@ -1011,14 +1071,14 @@ static unsigned Backward(CLzmaEnc *p, unsigned cur)
   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
@@ -1042,10 +1102,10 @@ static unsigned Backward(CLzmaEnc *p, unsigned cur)
       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
@@ -1068,9 +1128,9 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
     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
@@ -1078,7 +1138,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
       mainLen = p->longestMatchLen;\r
       numPairs = p->numPairs;\r
     }\r
-    \r
+\r
     numAvail = p->numAvail;\r
     if (numAvail < 2)\r
     {\r
@@ -1087,10 +1147,10 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
     }\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
@@ -1102,43 +1162,48 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
         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
@@ -1146,13 +1211,14 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
           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
@@ -1160,32 +1226,22 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
         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
@@ -1195,58 +1251,61 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
       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
@@ -1256,7 +1315,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
         }\r
       }\r
     }\r
-    \r
+\r
 \r
     cur = 0;\r
 \r
@@ -1272,37 +1331,73 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
   }\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
@@ -1316,14 +1411,14 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
 \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
@@ -1368,7 +1463,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
         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
@@ -1379,7 +1474,6 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
     curByte = *data;\r
     matchByte = *(data - reps[0]);\r
 \r
-    position++;\r
     posState = (position & p->pbMask);\r
 \r
     /*\r
@@ -1391,19 +1485,31 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
        <  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
@@ -1413,21 +1519,32 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
       }\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
@@ -1435,13 +1552,6 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
         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
@@ -1451,9 +1561,8 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
 \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
@@ -1465,32 +1574,32 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
         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
@@ -1500,8 +1609,9 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
         }\r
       }\r
     }\r
-    \r
+\r
     startLen = 2; /* speed optimization */\r
+\r
     {\r
       // ---------- REP ----------\r
       unsigned repIndex = 0; // 17.old\r
@@ -1513,31 +1623,35 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
         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
@@ -1550,51 +1664,59 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
           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
@@ -1606,49 +1728,57 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
     {\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
@@ -1656,12 +1786,18 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
           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
@@ -1677,28 +1813,31 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
             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
@@ -1709,6 +1848,12 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position)
       }\r
     }\r
   }\r
+\r
+  do\r
+    p->opt[last].price = kInfinityPrice;\r
+  while (--last);\r
+\r
+  return Backward(p, cur);\r
 }\r
 \r
 \r
@@ -1735,21 +1880,23 @@ static unsigned GetOptimumFast(CLzmaEnc *p)
   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
@@ -1768,7 +1915,7 @@ static unsigned GetOptimumFast(CLzmaEnc *p)
   }\r
 \r
   mainDist = 0; /* for GCC */\r
-  \r
+\r
   if (mainLen >= 2)\r
   {\r
     mainDist = p->matches[(size_t)numPairs - 1];\r
@@ -1793,18 +1940,18 @@ static unsigned GetOptimumFast(CLzmaEnc *p)
         || (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
@@ -1815,9 +1962,9 @@ static unsigned GetOptimumFast(CLzmaEnc *p)
         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
@@ -1833,7 +1980,7 @@ static unsigned GetOptimumFast(CLzmaEnc *p)
         break;\r
     }\r
   }\r
-  \r
+\r
   p->backRes = mainDist + LZMA_NUM_REPS;\r
   if (mainLen != 2)\r
   {\r
@@ -1859,7 +2006,7 @@ static void WriteEndMarker(CLzmaEnc *p, unsigned posState)
     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
@@ -1888,7 +2035,7 @@ static void WriteEndMarker(CLzmaEnc *p, unsigned posState)
     }\r
     while (--numBits);\r
   }\r
-   \r
+\r
   {\r
     // RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask);\r
     CLzmaProb *probs = p->posAlignEncoder;\r
@@ -1932,23 +2079,22 @@ MY_NO_INLINE static SRes Flush(CLzmaEnc *p, UInt32 nowPos)
 }\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
@@ -1957,78 +2103,97 @@ static void FillAlignPrices(CLzmaEnc *p)
 }\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
@@ -2037,7 +2202,7 @@ void LzmaEnc_Construct(CLzmaEnc *p)
 {\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
@@ -2081,7 +2246,7 @@ void LzmaEnc_Destruct(CLzmaEnc *p, ISzAllocPtr alloc, ISzAllocPtr allocBig)
   #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
@@ -2126,14 +2291,14 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpa
   }\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
@@ -2153,9 +2318,9 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpa
     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
@@ -2185,7 +2350,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpa
       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
@@ -2245,10 +2410,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpa
         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
@@ -2260,34 +2422,32 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpa
         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
@@ -2295,7 +2455,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpa
           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
@@ -2331,32 +2491,49 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpa
               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
@@ -2430,7 +2607,7 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAllocPtr alloc,
     p->matchFinderObj = &p->matchFinderBase;\r
     MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder);\r
   }\r
-  \r
+\r
   return SZ_OK;\r
 }\r
 \r
@@ -2490,12 +2667,19 @@ void LzmaEnc_Init(CLzmaEnc *p)
 \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
@@ -2507,6 +2691,9 @@ void LzmaEnc_InitPrices(CLzmaEnc *p)
   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
@@ -2583,7 +2770,7 @@ typedef struct
   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
@@ -2615,7 +2802,7 @@ const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
 }\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
@@ -2644,7 +2831,7 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
     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
@@ -2679,7 +2866,7 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
       }\r
     }\r
   }\r
-  \r
+\r
   LzmaEnc_Finish(p);\r
 \r
   /*\r
@@ -2751,7 +2938,7 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte
   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
index d7426d38a4dd80eb1d6dcd1334d72491714ea1f5..0f9560c7a63a12bcb8378e57773c0a5b9586ca53 100644 (file)
@@ -1,13 +1,35 @@
 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
@@ -16,7 +38,7 @@ HISTORY of the LZMA SDK
 \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
@@ -35,7 +57,7 @@ HISTORY of the LZMA SDK
 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
@@ -44,7 +66,7 @@ HISTORY of the LZMA SDK
 - 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
@@ -55,7 +77,7 @@ HISTORY of the LZMA SDK
 \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
@@ -76,51 +98,51 @@ HISTORY of the LZMA SDK
 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
@@ -128,10 +150,10 @@ HISTORY of the LZMA SDK
 \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
@@ -140,14 +162,14 @@ HISTORY of the LZMA SDK
 \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
@@ -155,7 +177,7 @@ HISTORY of the LZMA SDK
 \r
 \r
 9.18 beta      2010-11-02\r
--------------------------      \r
+-------------------------\r
 - New small SFX module for installers (SfxSetup).\r
 \r
 \r
@@ -168,7 +190,7 @@ HISTORY of the LZMA SDK
 9.11 beta      2010-03-15\r
 -------------------------\r
 - PPMd compression method support\r
-   \r
+\r
 \r
 9.09           2009-12-12\r
 -------------------------\r
@@ -202,7 +224,7 @@ HISTORY of the LZMA SDK
 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
@@ -216,7 +238,7 @@ HISTORY of the LZMA SDK
 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
@@ -229,7 +251,7 @@ HISTORY of the LZMA SDK
 \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
@@ -239,36 +261,36 @@ HISTORY of the LZMA SDK
      - 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
@@ -339,7 +361,7 @@ HISTORY of the LZMA SDK
 \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
@@ -350,11 +372,11 @@ HISTORY of the LZMA SDK
 \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
@@ -369,7 +391,7 @@ HISTORY of the LZMA SDK
 \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
@@ -381,8 +403,8 @@ HISTORY of the LZMA SDK
 \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
@@ -411,7 +433,7 @@ HISTORY of the LZMA SDK
 \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
@@ -419,6 +441,6 @@ HISTORY of the LZMA
 \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
index a3deb2094335a0ec22c0a295f8d5f875ea96a3bb..e17cd4fe1af2115def92efc0d8717c7a9489a67c 100644 (file)
@@ -1,4 +1,4 @@
-LZMA SDK 18.05\r
+LZMA SDK 19.00\r
 --------------\r
 \r
 LZMA SDK provides the documentation, samples, header files,\r