From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web08.32973.1608513044223450544 for ; Sun, 20 Dec 2020 17:10:48 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaoliming@byosoft.com.cn) Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Mon, 21 Dec 2020 09:10:41 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: "'Liu, WeiX C'" , Cc: "'Laszlo Ersek'" References: <20201215020651.1912-1-weix.c.liu@intel.com> <002101d6d414$25881cc0$70985640$@byosoft.com.cn> In-Reply-To: Subject: =?UTF-8?B?5Zue5aSNOiBbUEFUQ0ggMS8yXSBCYXNlVG9vbHMgTHptYUNvbXByZXNzOiBVcGRhdGUgTFpNQSB0byBuZXcgMTkuMDAgdmVyc2lvbg==?= Date: Mon, 21 Dec 2020 09:10:41 +0800 Message-ID: <012101d6d736$19e74100$4db5c300$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQJlp24ulGDDLEBUgWRGrTLtaL2vYgE4s0rQAXIdIN2ozcZ2IA== Content-Type: multipart/alternative; boundary="----=_NextPart_000_0122_01D6D779.283847C0" Content-Language: zh-cn ------=_NextPart_000_0122_01D6D779.283847C0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Do you verify the boot functionality (boot to shell)? Do you collect the = image size (old LZMA version and new LZMA version)?=20 =20 Thanks Liming =E5=8F=91=E4=BB=B6=E4=BA=BA: Liu, WeiX C =20 =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: = 2020=E5=B9=B412=E6=9C=8820=E6=97=A5 21:34 =E6=94=B6=E4=BB=B6=E4=BA=BA: gaoliming ; = devel@edk2.groups.io =E6=8A=84=E9=80=81: 'Laszlo Ersek' =E4=B8=BB=E9=A2=98: RE: [PATCH 1/2] BaseTools LzmaCompress: Update LZMA = to new 19.00 version =20 Hi liming, =20 I listed unittest result as below with Ovmf build, cause I have no = apple machine so only list VS=E3=80=81GCC and clang tool chain . =20 =20 VS2019 GCC5 CLANGPDB IA32 Pass Pass Pass X64 Pass Pass Pass IA32x64 Pass Pass Pass =20 =20 -----Original Message----- From: gaoliming >=20 Sent: 2020=E5=B9=B412=E6=9C=8817=E6=97=A5 9:30 To: Liu, WeiX C >; = devel@edk2.groups.io =20 Cc: 'Laszlo Ersek' > Subject: =E5=9B=9E=E5=A4=8D: [PATCH 1/2] BaseTools LzmaCompress: Update = LZMA to new 19.00 version =20 Wei: Can you list the unit test for this patch? Which tool chain and arch = have been verified?=20 =20 Because LZMA is well used, I request to verify it on VS, GCC, XCODE = and CLANG tool chain for the different ARCHs. =20 Thanks Liming > -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- > =E5=8F=91=E4=BB=B6=E4=BA=BA: Wei Liu > > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: = 2020=E5=B9=B412=E6=9C=8815=E6=97=A5 10:07 > =E6=94=B6=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io = =20 > =E6=8A=84=E9=80=81: Wei Liu >; Liming Gao > >; Laszlo = Ersek > > =E4=B8=BB=E9=A2=98: [PATCH 1/2] BaseTools LzmaCompress: Update LZMA to = new 19.00 > version >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3101 > New formal release in https://www.7-zip.org/sdk.html is 19.00. >=20 > Cc: Liming Gao > >=20 > Cc: Laszlo Ersek > > Signed-off-by: Wei Liu > > --- > BaseTools/Source/C/LzmaCompress/LZMA-SDK-README.txt | 4 > ++-- > BaseTools/Source/C/LzmaCompress/LzmaCompress.c | 8 > ++++---- > BaseTools/Source/C/LzmaCompress/Sdk/C/7zTypes.h | 5 > +++-- > BaseTools/Source/C/LzmaCompress/Sdk/C/7zVersion.h | 8 > ++++---- > BaseTools/Source/C/LzmaCompress/Sdk/C/CpuArch.h | 9 > +++++---- > BaseTools/Source/C/LzmaCompress/Sdk/C/LzFind.c | 164 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > +++++++++++++++++++++++++++++++++++++++++++++++++-------------------- > --------------------------------- > BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.c | 117 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > +++++++++++++------------------------------------------ > BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.h | 14 > +++++++------- > BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c | 32 > ++++++++++++++++---------------- > BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | 733 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >=20 ++++++++++++++++++++++++++-----------------------------------------------= --- ---- >=20 -------------------------------------------------------------------------= --- ----------------- >=20 -------------------------------------------------------------------------= --- ----------------- > --------------------------------- > BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt | 22 > ++++++++++++++++++++++ > BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-sdk.txt | 2 +- > 12 files changed, 710 insertions(+), 408 deletions(-) >=20 > diff --git a/BaseTools/Source/C/LzmaCompress/LZMA-SDK-README.txt > b/BaseTools/Source/C/LzmaCompress/LZMA-SDK-README.txt > index 7cf967a774..b2338e2598 100644 > --- a/BaseTools/Source/C/LzmaCompress/LZMA-SDK-README.txt > +++ b/BaseTools/Source/C/LzmaCompress/LZMA-SDK-README.txt > @@ -1,3 +1,3 @@ > -LzmaCompress is based on the LZMA SDK 18.05. LZMA SDK 18.05 >=20 > -was placed in the public domain on 2018-04-30. It was >=20 > +LzmaCompress is based on the LZMA SDK 19.00. LZMA SDK 19.00 >=20 > +was placed in the public domain on 2019-02-21. It was >=20 > released on the http://www.7-zip.org/sdk.html website. >=20 > diff --git a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c > b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c > index bebdb9aa84..bf4706ee23 100644 > --- a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c > +++ b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c > @@ -1,9 +1,9 @@ > /** @file >=20 > LZMA Compress/Decompress tool (LzmaCompress) >=20 >=20 >=20 > - Based on LZMA SDK 18.05: >=20 > + Based on LZMA SDK 19.00: >=20 > LzmaUtil.c -- Test application for LZMA compression >=20 > - 2018-04-30 : Igor Pavlov : Public domain >=20 > + 2019-02-21 : Igor Pavlov : Public domain >=20 >=20 >=20 > Copyright (c) 2006 - 2019, Intel Corporation. All rights = reserved.
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @@ -39,7 +39,7 @@ const char *kCantAllocateMessage =3D "Can not = allocate > memory"; > const char *kDataErrorMessage =3D "Data error"; >=20 > const char *kInvalidParamValMessage =3D "Invalid parameter value"; >=20 >=20 >=20 > -static Bool mQuietMode =3D False; >=20 > +static BoolInt mQuietMode =3D False; >=20 > static CONVERTER_TYPE mConType =3D NoConverter; >=20 >=20 >=20 > UINT64 mDictionarySize =3D 28; >=20 > @@ -244,7 +244,7 @@ int main2(int numArgs, const char *args[], char = *rs) > CFileOutStream outStream; >=20 > int res; >=20 > int encodeMode =3D 0; >=20 > - Bool modeWasSet =3D False; >=20 > + BoolInt modeWasSet =3D False; >=20 > const char *inputFile =3D NULL; >=20 > const char *outputFile =3D "file.tmp"; >=20 > int param; >=20 > diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/7zTypes.h > b/BaseTools/Source/C/LzmaCompress/Sdk/C/7zTypes.h > index 4977cdaa66..593f5aa259 100644 > --- a/BaseTools/Source/C/LzmaCompress/Sdk/C/7zTypes.h > +++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/7zTypes.h > @@ -1,5 +1,5 @@ > /* 7zTypes.h -- Basic types >=20 > -2017-07-17 : Igor Pavlov : Public domain */ >=20 > +2018-08-04 : Igor Pavlov : Public domain */ >=20 >=20 >=20 > #ifndef __7Z_TYPES_H >=20 > #define __7Z_TYPES_H >=20 > @@ -103,7 +103,8 @@ typedef UInt32 SizeT; > typedef size_t SizeT; >=20 > #endif >=20 >=20 >=20 > -typedef int Bool; >=20 > +typedef int BoolInt; >=20 > +/* typedef BoolInt Bool; */ >=20 > #define True 1 >=20 > #define False 0 >=20 >=20 >=20 > diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/7zVersion.h > b/BaseTools/Source/C/LzmaCompress/Sdk/C/7zVersion.h > index ed3aa94270..0074c64be9 100644 > --- a/BaseTools/Source/C/LzmaCompress/Sdk/C/7zVersion.h > +++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/7zVersion.h > @@ -1,7 +1,7 @@ > -#define MY_VER_MAJOR 18 >=20 > -#define MY_VER_MINOR 05 >=20 > +#define MY_VER_MAJOR 19 >=20 > +#define MY_VER_MINOR 00 >=20 > #define MY_VER_BUILD 0 >=20 > -#define MY_VERSION_NUMBERS "18.05" >=20 > +#define MY_VERSION_NUMBERS "19.00" >=20 > #define MY_VERSION MY_VERSION_NUMBERS >=20 >=20 >=20 > #ifdef MY_CPU_NAME >=20 > @@ -10,7 +10,7 @@ > #define MY_VERSION_CPU MY_VERSION >=20 > #endif >=20 >=20 >=20 > -#define MY_DATE "2018-04-30" >=20 > +#define MY_DATE "2019-02-21" >=20 > #undef MY_COPYRIGHT >=20 > #undef MY_VERSION_COPYRIGHT_DATE >=20 > #define MY_AUTHOR_NAME "Igor Pavlov" >=20 > diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/CpuArch.h > b/BaseTools/Source/C/LzmaCompress/Sdk/C/CpuArch.h > index 7fb27282c7..5f74c1c0cb 100644 > --- a/BaseTools/Source/C/LzmaCompress/Sdk/C/CpuArch.h > +++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/CpuArch.h > @@ -1,5 +1,5 @@ > /* CpuArch.h -- CPU specific code >=20 > -2017-09-04 : Igor Pavlov : Public domain */ >=20 > +2018-02-18 : Igor Pavlov : Public domain */ >=20 >=20 >=20 > #ifndef __CPU_ARCH_H >=20 > #define __CPU_ARCH_H >=20 > @@ -318,15 +318,16 @@ enum >=20 >=20 > void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d); >=20 >=20 >=20 > -Bool x86cpuid_CheckAndRead(Cx86cpuid *p); >=20 > +BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p); >=20 > int x86cpuid_GetFirm(const Cx86cpuid *p); >=20 >=20 >=20 > #define x86cpuid_GetFamily(ver) (((ver >> 16) & 0xFF0) | ((ver >> 8) = & 0xF)) >=20 > #define x86cpuid_GetModel(ver) (((ver >> 12) & 0xF0) | ((ver >> 4) = & > 0xF)) >=20 > #define x86cpuid_GetStepping(ver) (ver & 0xF) >=20 >=20 >=20 > -Bool CPU_Is_InOrder(); >=20 > -Bool CPU_Is_Aes_Supported(); >=20 > +BoolInt CPU_Is_InOrder(); >=20 > +BoolInt CPU_Is_Aes_Supported(); >=20 > +BoolInt CPU_IsSupported_PageGB(); >=20 >=20 >=20 > #endif >=20 >=20 >=20 > diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFind.c > b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFind.c > index 6ea82a9b53..4eefc17dd2 100644 > --- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFind.c > +++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFind.c > @@ -1,5 +1,5 @@ > /* LzFind.c -- Match finder for LZ algorithms >=20 > -2017-06-10 : Igor Pavlov : Public domain */ >=20 > +2018-07-08 : Igor Pavlov : Public domain */ >=20 >=20 >=20 > #include "Precomp.h" >=20 >=20 >=20 > @@ -138,7 +138,7 @@ static void > MatchFinder_SetDefaultSettings(CMatchFinder *p) >=20 >=20 > void MatchFinder_Construct(CMatchFinder *p) >=20 > { >=20 > - UInt32 i; >=20 > + unsigned i; >=20 > p->bufferBase =3D NULL; >=20 > p->directInput =3D 0; >=20 > p->hash =3D NULL; >=20 > @@ -147,7 +147,7 @@ void MatchFinder_Construct(CMatchFinder *p) >=20 >=20 > for (i =3D 0; i < 256; i++) >=20 > { >=20 > - UInt32 r =3D i; >=20 > + UInt32 r =3D (UInt32)i; >=20 > unsigned j; >=20 > for (j =3D 0; j < 8; j++) >=20 > r =3D (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1))); >=20 > @@ -368,6 +368,8 @@ static void MatchFinder_Normalize(CMatchFinder *p) > MatchFinder_ReduceOffsets(p, subValue); >=20 > } >=20 >=20 >=20 > + >=20 > +MY_NO_INLINE >=20 > static void MatchFinder_CheckLimits(CMatchFinder *p) >=20 > { >=20 > if (p->pos =3D=3D kMaxValForNormalize) >=20 > @@ -379,10 +381,16 @@ static void > MatchFinder_CheckLimits(CMatchFinder *p) > MatchFinder_SetLimits(p); >=20 > } >=20 >=20 >=20 > -static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, > UInt32 pos, const Byte *cur, CLzRef *son, >=20 > + >=20 > +/* >=20 > + (lenLimit > maxLen) >=20 > +*/ >=20 > +MY_FORCE_INLINE >=20 > +static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, > UInt32 pos, const Byte *cur, CLzRef *son, >=20 > UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 = cutValue, >=20 > - UInt32 *distances, UInt32 maxLen) >=20 > + UInt32 *distances, unsigned maxLen) >=20 > { >=20 > + /* >=20 > son[_cyclicBufferPos] =3D curMatch; >=20 > for (;;) >=20 > { >=20 > @@ -400,7 +408,8 @@ static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, > UInt32 curMatch, UInt32 pos, > break; >=20 > if (maxLen < len) >=20 > { >=20 > - *distances++ =3D maxLen =3D len; >=20 > + maxLen =3D len; >=20 > + *distances++ =3D len; >=20 > *distances++ =3D delta - 1; >=20 > if (len =3D=3D lenLimit) >=20 > return distances; >=20 > @@ -408,15 +417,58 @@ static UInt32 * Hc_GetMatchesSpec(UInt32 > lenLimit, UInt32 curMatch, UInt32 pos, > } >=20 > } >=20 > } >=20 > + */ >=20 > + >=20 > + const Byte *lim =3D cur + lenLimit; >=20 > + son[_cyclicBufferPos] =3D curMatch; >=20 > + do >=20 > + { >=20 > + UInt32 delta =3D pos - curMatch; >=20 > + if (delta >=3D _cyclicBufferSize) >=20 > + break; >=20 > + { >=20 > + ptrdiff_t diff; >=20 > + curMatch =3D son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? > _cyclicBufferSize : 0)]; >=20 > + diff =3D (ptrdiff_t)0 - delta; >=20 > + if (cur[maxLen] =3D=3D cur[maxLen + diff]) >=20 > + { >=20 > + const Byte *c =3D cur; >=20 > + while (*c =3D=3D c[diff]) >=20 > + { >=20 > + if (++c =3D=3D lim) >=20 > + { >=20 > + distances[0] =3D (UInt32)(lim - cur); >=20 > + distances[1] =3D delta - 1; >=20 > + return distances + 2; >=20 > + } >=20 > + } >=20 > + { >=20 > + unsigned len =3D (unsigned)(c - cur); >=20 > + if (maxLen < len) >=20 > + { >=20 > + maxLen =3D len; >=20 > + distances[0] =3D (UInt32)len; >=20 > + distances[1] =3D delta - 1; >=20 > + distances +=3D 2; >=20 > + } >=20 > + } >=20 > + } >=20 > + } >=20 > + } >=20 > + while (--cutValue); >=20 > + >=20 > + return distances; >=20 > } >=20 >=20 >=20 > + >=20 > +MY_FORCE_INLINE >=20 > UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 = pos, > const Byte *cur, CLzRef *son, >=20 > UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 = cutValue, >=20 > UInt32 *distances, UInt32 maxLen) >=20 > { >=20 > - CLzRef *ptr0 =3D son + (_cyclicBufferPos << 1) + 1; >=20 > - CLzRef *ptr1 =3D son + (_cyclicBufferPos << 1); >=20 > - UInt32 len0 =3D 0, len1 =3D 0; >=20 > + CLzRef *ptr0 =3D son + ((size_t)_cyclicBufferPos << 1) + 1; >=20 > + CLzRef *ptr1 =3D son + ((size_t)_cyclicBufferPos << 1); >=20 > + unsigned len0 =3D 0, len1 =3D 0; >=20 > for (;;) >=20 > { >=20 > UInt32 delta =3D pos - curMatch; >=20 > @@ -426,9 +478,10 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 > curMatch, UInt32 pos, const Byt > return distances; >=20 > } >=20 > { >=20 > - CLzRef *pair =3D son + ((_cyclicBufferPos - delta + ((delta > > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); >=20 > + CLzRef *pair =3D son + ((size_t)(_cyclicBufferPos - delta + = ((delta > > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); >=20 > const Byte *pb =3D cur - delta; >=20 > - UInt32 len =3D (len0 < len1 ? len0 : len1); >=20 > + unsigned len =3D (len0 < len1 ? len0 : len1); >=20 > + UInt32 pair0 =3D pair[0]; >=20 > if (pb[len] =3D=3D cur[len]) >=20 > { >=20 > if (++len !=3D lenLimit && pb[len] =3D=3D cur[len]) >=20 > @@ -437,11 +490,12 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, > UInt32 curMatch, UInt32 pos, const Byt > break; >=20 > if (maxLen < len) >=20 > { >=20 > - *distances++ =3D maxLen =3D len; >=20 > + maxLen =3D (UInt32)len; >=20 > + *distances++ =3D (UInt32)len; >=20 > *distances++ =3D delta - 1; >=20 > if (len =3D=3D lenLimit) >=20 > { >=20 > - *ptr1 =3D pair[0]; >=20 > + *ptr1 =3D pair0; >=20 > *ptr0 =3D pair[1]; >=20 > return distances; >=20 > } >=20 > @@ -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, >=20 > UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 = cutValue) >=20 > { >=20 > - CLzRef *ptr0 =3D son + (_cyclicBufferPos << 1) + 1; >=20 > - CLzRef *ptr1 =3D son + (_cyclicBufferPos << 1); >=20 > - UInt32 len0 =3D 0, len1 =3D 0; >=20 > + CLzRef *ptr0 =3D son + ((size_t)_cyclicBufferPos << 1) + 1; >=20 > + CLzRef *ptr1 =3D son + ((size_t)_cyclicBufferPos << 1); >=20 > + unsigned len0 =3D 0, len1 =3D 0; >=20 > for (;;) >=20 > { >=20 > UInt32 delta =3D pos - curMatch; >=20 > @@ -480,9 +534,9 @@ static void SkipMatchesSpec(UInt32 lenLimit, = UInt32 > curMatch, UInt32 pos, const > return; >=20 > } >=20 > { >=20 > - CLzRef *pair =3D son + ((_cyclicBufferPos - delta + ((delta > > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); >=20 > + CLzRef *pair =3D son + ((size_t)(_cyclicBufferPos - delta + = ((delta > > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); >=20 > const Byte *pb =3D cur - delta; >=20 > - UInt32 len =3D (len0 < len1 ? len0 : len1); >=20 > + unsigned len =3D (len0 < len1 ? len0 : len1); >=20 > if (pb[len] =3D=3D cur[len]) >=20 > { >=20 > while (++len !=3D lenLimit) >=20 > @@ -520,13 +574,13 @@ static void SkipMatchesSpec(UInt32 lenLimit, > UInt32 curMatch, UInt32 pos, const > p->buffer++; \ >=20 > if (++p->pos =3D=3D p->posLimit) MatchFinder_CheckLimits(p); >=20 >=20 >=20 > -#define MOVE_POS_RET MOVE_POS return offset; >=20 > +#define MOVE_POS_RET MOVE_POS return (UInt32)offset; >=20 >=20 >=20 > static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; } >=20 >=20 >=20 > #define GET_MATCHES_HEADER2(minLen, ret_op) \ >=20 > - UInt32 lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \ >=20 > - lenLimit =3D p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); > ret_op; }} \ >=20 > + unsigned lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \ >=20 > + lenLimit =3D (unsigned)p->lenLimit; { if (lenLimit < minLen) > { MatchFinder_MovePos(p); ret_op; }} \ >=20 > cur =3D p->buffer; >=20 >=20 >=20 > #define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, > return 0) >=20 > @@ -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 >=20 >=20 >=20 > #define GET_MATCHES_FOOTER(offset, maxLen) \ >=20 > - offset =3D (UInt32)(GetMatchesSpec1(lenLimit, curMatch, = MF_PARAMS(p), \ >=20 > - distances + offset, maxLen) - distances); MOVE_POS_RET; >=20 > + offset =3D (unsigned)(GetMatchesSpec1((UInt32)lenLimit, curMatch, > MF_PARAMS(p), \ >=20 > + distances + offset, (UInt32)maxLen) - distances); MOVE_POS_RET; >=20 >=20 >=20 > #define SKIP_FOOTER \ >=20 > - SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS; >=20 > + SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); > MOVE_POS; >=20 >=20 >=20 > #define UPDATE_maxLen { \ >=20 > ptrdiff_t diff =3D (ptrdiff_t)0 - d2; \ >=20 > const Byte *c =3D cur + maxLen; \ >=20 > const Byte *lim =3D cur + lenLimit; \ >=20 > for (; c !=3D lim; c++) if (*(c + diff) !=3D *c) break; \ >=20 > - maxLen =3D (UInt32)(c - cur); } >=20 > + maxLen =3D (unsigned)(c - cur); } >=20 >=20 >=20 > static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 > *distances) >=20 > { >=20 > - UInt32 offset; >=20 > + unsigned offset; >=20 > GET_MATCHES_HEADER(2) >=20 > HASH2_CALC; >=20 > curMatch =3D p->hash[hv]; >=20 > @@ -561,7 +615,7 @@ static UInt32 > Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) >=20 >=20 > UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 > *distances) >=20 > { >=20 > - UInt32 offset; >=20 > + unsigned offset; >=20 > GET_MATCHES_HEADER(3) >=20 > HASH_ZIP_CALC; >=20 > curMatch =3D p->hash[hv]; >=20 > @@ -572,7 +626,8 @@ UInt32 > Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) >=20 >=20 > static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 > *distances) >=20 > { >=20 > - UInt32 h2, d2, maxLen, offset, pos; >=20 > + UInt32 h2, d2, pos; >=20 > + unsigned maxLen, offset; >=20 > UInt32 *hash; >=20 > GET_MATCHES_HEADER(3) >=20 >=20 >=20 > @@ -594,12 +649,12 @@ static UInt32 > Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) > if (d2 < p->cyclicBufferSize && *(cur - d2) =3D=3D *cur) >=20 > { >=20 > UPDATE_maxLen >=20 > - distances[0] =3D maxLen; >=20 > + distances[0] =3D (UInt32)maxLen; >=20 > distances[1] =3D d2 - 1; >=20 > offset =3D 2; >=20 > if (maxLen =3D=3D lenLimit) >=20 > { >=20 > - SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); >=20 > + SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); >=20 > MOVE_POS_RET; >=20 > } >=20 > } >=20 > @@ -609,7 +664,8 @@ static UInt32 > Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) >=20 >=20 > static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 > *distances) >=20 > { >=20 > - UInt32 h2, h3, d2, d3, maxLen, offset, pos; >=20 > + UInt32 h2, h3, d2, d3, pos; >=20 > + unsigned maxLen, offset; >=20 > UInt32 *hash; >=20 > GET_MATCHES_HEADER(4) >=20 >=20 >=20 > @@ -618,12 +674,12 @@ static UInt32 > Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) > hash =3D p->hash; >=20 > pos =3D p->pos; >=20 >=20 >=20 > - d2 =3D pos - hash[ h2]; >=20 > + d2 =3D pos - hash [h2]; >=20 > d3 =3D pos - (hash + kFix3HashSize)[h3]; >=20 >=20 >=20 > curMatch =3D (hash + kFix4HashSize)[hv]; >=20 >=20 >=20 > - hash[ h2] =3D pos; >=20 > + hash [h2] =3D pos; >=20 > (hash + kFix3HashSize)[h3] =3D pos; >=20 > (hash + kFix4HashSize)[hv] =3D pos; >=20 >=20 >=20 > @@ -632,7 +688,8 @@ static UInt32 > Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) >=20 >=20 > if (d2 < p->cyclicBufferSize && *(cur - d2) =3D=3D *cur) >=20 > { >=20 > - distances[0] =3D maxLen =3D 2; >=20 > + maxLen =3D 2; >=20 > + distances[0] =3D 2; >=20 > distances[1] =3D d2 - 1; >=20 > offset =3D 2; >=20 > } >=20 > @@ -648,10 +705,10 @@ static UInt32 > Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) > if (offset !=3D 0) >=20 > { >=20 > UPDATE_maxLen >=20 > - distances[(size_t)offset - 2] =3D maxLen; >=20 > + distances[(size_t)offset - 2] =3D (UInt32)maxLen; >=20 > if (maxLen =3D=3D lenLimit) >=20 > { >=20 > - SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); >=20 > + SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); >=20 > MOVE_POS_RET; >=20 > } >=20 > } >=20 > @@ -674,13 +731,13 @@ static UInt32 > Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) > hash =3D p->hash; >=20 > pos =3D p->pos; >=20 >=20 >=20 > - d2 =3D pos - hash[ h2]; >=20 > + d2 =3D pos - hash [h2]; >=20 > d3 =3D pos - (hash + kFix3HashSize)[h3]; >=20 > d4 =3D pos - (hash + kFix4HashSize)[h4]; >=20 >=20 >=20 > curMatch =3D (hash + kFix5HashSize)[hv]; >=20 >=20 >=20 > - hash[ h2] =3D pos; >=20 > + hash [h2] =3D pos; >=20 > (hash + kFix3HashSize)[h3] =3D pos; >=20 > (hash + kFix4HashSize)[h4] =3D pos; >=20 > (hash + kFix5HashSize)[hv] =3D pos; >=20 > @@ -741,7 +798,8 @@ static UInt32 > Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) >=20 >=20 > static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 > *distances) >=20 > { >=20 > - UInt32 h2, h3, d2, d3, maxLen, offset, pos; >=20 > + UInt32 h2, h3, d2, d3, pos; >=20 > + unsigned maxLen, offset; >=20 > UInt32 *hash; >=20 > GET_MATCHES_HEADER(4) >=20 >=20 >=20 > @@ -750,12 +808,11 @@ static UInt32 > Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) > hash =3D p->hash; >=20 > pos =3D p->pos; >=20 >=20 >=20 > - d2 =3D pos - hash[ h2]; >=20 > + d2 =3D pos - hash [h2]; >=20 > d3 =3D pos - (hash + kFix3HashSize)[h3]; >=20 > - >=20 > curMatch =3D (hash + kFix4HashSize)[hv]; >=20 >=20 >=20 > - hash[ h2] =3D pos; >=20 > + hash [h2] =3D pos; >=20 > (hash + kFix3HashSize)[h3] =3D pos; >=20 > (hash + kFix4HashSize)[hv] =3D pos; >=20 >=20 >=20 > @@ -764,7 +821,8 @@ static UInt32 > Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) >=20 >=20 > if (d2 < p->cyclicBufferSize && *(cur - d2) =3D=3D *cur) >=20 > { >=20 > - distances[0] =3D maxLen =3D 2; >=20 > + maxLen =3D 2; >=20 > + distances[0] =3D 2; >=20 > distances[1] =3D d2 - 1; >=20 > offset =3D 2; >=20 > } >=20 > @@ -780,7 +838,7 @@ static UInt32 > Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) > if (offset !=3D 0) >=20 > { >=20 > UPDATE_maxLen >=20 > - distances[(size_t)offset - 2] =3D maxLen; >=20 > + distances[(size_t)offset - 2] =3D (UInt32)maxLen; >=20 > if (maxLen =3D=3D lenLimit) >=20 > { >=20 > p->son[p->cyclicBufferPos] =3D curMatch; >=20 > @@ -791,7 +849,7 @@ static UInt32 > Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) > if (maxLen < 3) >=20 > maxLen =3D 3; >=20 >=20 >=20 > - offset =3D (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, = MF_PARAMS(p), >=20 > + offset =3D (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch, > MF_PARAMS(p), >=20 > distances + offset, maxLen) - (distances)); >=20 > MOVE_POS_RET >=20 > } >=20 > @@ -808,13 +866,13 @@ static UInt32 > Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) > hash =3D p->hash; >=20 > pos =3D p->pos; >=20 >=20 >=20 > - d2 =3D pos - hash[ h2]; >=20 > + d2 =3D pos - hash [h2]; >=20 > d3 =3D pos - (hash + kFix3HashSize)[h3]; >=20 > d4 =3D pos - (hash + kFix4HashSize)[h4]; >=20 >=20 >=20 > curMatch =3D (hash + kFix5HashSize)[hv]; >=20 >=20 >=20 > - hash[ h2] =3D pos; >=20 > + hash [h2] =3D pos; >=20 > (hash + kFix3HashSize)[h3] =3D pos; >=20 > (hash + kFix4HashSize)[h4] =3D pos; >=20 > (hash + kFix5HashSize)[hv] =3D pos; >=20 > @@ -877,12 +935,12 @@ static UInt32 > Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) >=20 >=20 > UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 > *distances) >=20 > { >=20 > - UInt32 offset; >=20 > + unsigned offset; >=20 > GET_MATCHES_HEADER(3) >=20 > HASH_ZIP_CALC; >=20 > curMatch =3D p->hash[hv]; >=20 > p->hash[hv] =3D p->pos; >=20 > - offset =3D (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, = MF_PARAMS(p), >=20 > + offset =3D (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch, > MF_PARAMS(p), >=20 > distances, 2) - (distances)); >=20 > MOVE_POS_RET >=20 > } >=20 > @@ -940,7 +998,7 @@ static void Bt4_MatchFinder_Skip(CMatchFinder *p, > UInt32 num) > HASH4_CALC; >=20 > hash =3D p->hash; >=20 > curMatch =3D (hash + kFix4HashSize)[hv]; >=20 > - hash[ h2] =3D >=20 > + hash [h2] =3D >=20 > (hash + kFix3HashSize)[h3] =3D >=20 > (hash + kFix4HashSize)[hv] =3D p->pos; >=20 > SKIP_FOOTER >=20 > @@ -959,7 +1017,7 @@ static void Bt5_MatchFinder_Skip(CMatchFinder *p, > UInt32 num) > HASH5_CALC; >=20 > hash =3D p->hash; >=20 > curMatch =3D (hash + kFix5HashSize)[hv]; >=20 > - hash[ h2] =3D >=20 > + hash [h2] =3D >=20 > (hash + kFix3HashSize)[h3] =3D >=20 > (hash + kFix4HashSize)[h4] =3D >=20 > (hash + kFix5HashSize)[hv] =3D p->pos; >=20 > @@ -979,7 +1037,7 @@ static void Hc4_MatchFinder_Skip(CMatchFinder *p, > UInt32 num) > HASH4_CALC; >=20 > hash =3D p->hash; >=20 > curMatch =3D (hash + kFix4HashSize)[hv]; >=20 > - hash[ h2] =3D >=20 > + hash [h2] =3D >=20 > (hash + kFix3HashSize)[h3] =3D >=20 > (hash + kFix4HashSize)[hv] =3D p->pos; >=20 > p->son[p->cyclicBufferPos] =3D curMatch; >=20 > @@ -999,7 +1057,7 @@ static void Hc5_MatchFinder_Skip(CMatchFinder *p, > UInt32 num) > HASH5_CALC; >=20 > hash =3D p->hash; >=20 > curMatch =3D hash + kFix5HashSize)[hv]; >=20 > - hash[ h2] =3D >=20 > + hash [h2] =3D >=20 > (hash + kFix3HashSize)[h3] =3D >=20 > (hash + kFix4HashSize)[h4] =3D >=20 > (hash + kFix5HashSize)[hv] =3D p->pos; >=20 > diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.c > b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.c > index 2563824fcd..df32146f92 100644 > --- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.c > +++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.c > @@ -1,5 +1,5 @@ > /* LzFindMt.c -- multithreaded Match finder for LZ algorithms >=20 > -2017-06-10 : Igor Pavlov : Public domain */ >=20 > +2018-12-29 : Igor Pavlov : Public domain */ >=20 >=20 >=20 > #include "Precomp.h" >=20 >=20 >=20 > @@ -232,38 +232,57 @@ static void > MatchFinderMt_GetNextBlock_Hash(CMatchFinderMt *p) >=20 >=20 > #define kEmptyHashValue 0 >=20 >=20 >=20 > -/* #define MFMT_GM_INLINE */ >=20 > +#define MFMT_GM_INLINE >=20 >=20 >=20 > #ifdef MFMT_GM_INLINE >=20 >=20 >=20 > -#define NO_INLINE MY_FAST_CALL >=20 > +/* >=20 > + we use size_t for _cyclicBufferPos instead of UInt32 >=20 > + to eliminate "movsx" BUG in old MSVC x64 compiler. >=20 > +*/ >=20 >=20 >=20 > -static Int32 NO_INLINE GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, > const Byte *cur, CLzRef *son, >=20 > - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 = _cutValue, >=20 > - UInt32 *_distances, UInt32 _maxLen, const UInt32 *hash, Int32 = limit, > UInt32 size, UInt32 *posRes) >=20 > +MY_NO_INLINE >=20 > +static UInt32 *GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const = Byte > *cur, CLzRef *son, >=20 > + size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 = _cutValue, >=20 > + UInt32 *distances, UInt32 _maxLen, const UInt32 *hash, const = UInt32 > *limit, UInt32 size, UInt32 *posRes) >=20 > { >=20 > do >=20 > { >=20 > - UInt32 *distances =3D _distances + 1; >=20 > - UInt32 curMatch =3D pos - *hash++; >=20 > + UInt32 *_distances =3D ++distances; >=20 > + UInt32 delta =3D *hash++; >=20 >=20 >=20 > - CLzRef *ptr0 =3D son + (_cyclicBufferPos << 1) + 1; >=20 > - CLzRef *ptr1 =3D son + (_cyclicBufferPos << 1); >=20 > - UInt32 len0 =3D 0, len1 =3D 0; >=20 > + CLzRef *ptr0 =3D son + ((size_t)_cyclicBufferPos << 1) + 1; >=20 > + CLzRef *ptr1 =3D son + ((size_t)_cyclicBufferPos << 1); >=20 > + unsigned len0 =3D 0, len1 =3D 0; >=20 > UInt32 cutValue =3D _cutValue; >=20 > - UInt32 maxLen =3D _maxLen; >=20 > - for (;;) >=20 > + unsigned maxLen =3D (unsigned)_maxLen; >=20 > + >=20 > + /* >=20 > + if (size > 1) >=20 > { >=20 > - UInt32 delta =3D pos - curMatch; >=20 > - if (cutValue-- =3D=3D 0 || delta >=3D _cyclicBufferSize) >=20 > + UInt32 delta =3D *hash; >=20 > + if (delta < _cyclicBufferSize) >=20 > { >=20 > - *ptr0 =3D *ptr1 =3D kEmptyHashValue; >=20 > - break; >=20 > + UInt32 cyc1 =3D _cyclicBufferPos + 1; >=20 > + CLzRef *pair =3D son + ((size_t)(cyc1 - delta + ((delta > cyc1) = ? > _cyclicBufferSize : 0)) << 1); >=20 > + Byte b =3D *(cur + 1 - delta); >=20 > + _distances[0] =3D pair[0]; >=20 > + _distances[1] =3D b; >=20 > } >=20 > + } >=20 > + */ >=20 > + if (cutValue =3D=3D 0 || delta >=3D _cyclicBufferSize) >=20 > + { >=20 > + *ptr0 =3D *ptr1 =3D kEmptyHashValue; >=20 > + } >=20 > + else >=20 > + for(;;) >=20 > + { >=20 > { >=20 > - CLzRef *pair =3D son + ((_cyclicBufferPos - delta + ((delta > > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); >=20 > + CLzRef *pair =3D son + ((size_t)(_cyclicBufferPos - delta + > ((_cyclicBufferPos < delta) ? _cyclicBufferSize : 0)) << 1); >=20 > const Byte *pb =3D cur - delta; >=20 > - UInt32 len =3D (len0 < len1 ? len0 : len1); >=20 > + unsigned len =3D (len0 < len1 ? len0 : len1); >=20 > + UInt32 pair0 =3D *pair; >=20 > if (pb[len] =3D=3D cur[len]) >=20 > { >=20 > if (++len !=3D lenLimit && pb[len] =3D=3D cur[len]) >=20 > @@ -272,54 +291,66 @@ static Int32 NO_INLINE GetMatchesSpecN(UInt32 > lenLimit, UInt32 pos, const Byte * > break; >=20 > if (maxLen < len) >=20 > { >=20 > - *distances++ =3D maxLen =3D len; >=20 > + maxLen =3D len; >=20 > + *distances++ =3D (UInt32)len; >=20 > *distances++ =3D delta - 1; >=20 > if (len =3D=3D lenLimit) >=20 > { >=20 > - *ptr1 =3D pair[0]; >=20 > - *ptr0 =3D pair[1]; >=20 > + UInt32 pair1 =3D pair[1]; >=20 > + *ptr1 =3D pair0; >=20 > + *ptr0 =3D pair1; >=20 > break; >=20 > } >=20 > } >=20 > } >=20 > - if (pb[len] < cur[len]) >=20 > - { >=20 > - *ptr1 =3D curMatch; >=20 > - ptr1 =3D pair + 1; >=20 > - curMatch =3D *ptr1; >=20 > - len1 =3D len; >=20 > - } >=20 > - else >=20 > { >=20 > - *ptr0 =3D curMatch; >=20 > - ptr0 =3D pair; >=20 > - curMatch =3D *ptr0; >=20 > - len0 =3D len; >=20 > + UInt32 curMatch =3D pos - delta; >=20 > + // delta =3D pos - *pair; >=20 > + // delta =3D pos - pair[((UInt32)pb[len] - (UInt32)cur[len]) = >> 31]; >=20 > + if (pb[len] < cur[len]) >=20 > + { >=20 > + delta =3D pos - pair[1]; >=20 > + *ptr1 =3D curMatch; >=20 > + ptr1 =3D pair + 1; >=20 > + len1 =3D len; >=20 > + } >=20 > + else >=20 > + { >=20 > + delta =3D pos - *pair; >=20 > + *ptr0 =3D curMatch; >=20 > + ptr0 =3D pair; >=20 > + len0 =3D len; >=20 > + } >=20 > } >=20 > } >=20 > + if (--cutValue =3D=3D 0 || delta >=3D _cyclicBufferSize) >=20 > + { >=20 > + *ptr0 =3D *ptr1 =3D kEmptyHashValue; >=20 > + break; >=20 > + } >=20 > } >=20 > pos++; >=20 > _cyclicBufferPos++; >=20 > cur++; >=20 > { >=20 > UInt32 num =3D (UInt32)(distances - _distances); >=20 > - *_distances =3D num - 1; >=20 > - _distances +=3D num; >=20 > - limit -=3D num; >=20 > + _distances[-1] =3D num; >=20 > } >=20 > } >=20 > - while (limit > 0 && --size !=3D 0); >=20 > + while (distances < limit && --size !=3D 0); >=20 > *posRes =3D pos; >=20 > - return limit; >=20 > + return distances; >=20 > } >=20 >=20 >=20 > #endif >=20 >=20 >=20 > + >=20 > + >=20 > static void BtGetMatches(CMatchFinderMt *p, UInt32 *distances) >=20 > { >=20 > UInt32 numProcessed =3D 0; >=20 > UInt32 curPos =3D 2; >=20 > - UInt32 limit =3D kMtBtBlockSize - (p->matchMaxLen * 2); >=20 > + UInt32 limit =3D kMtBtBlockSize - (p->matchMaxLen * 2); // * 2 >=20 >=20 >=20 > distances[1] =3D p->hashNumAvail; >=20 >=20 >=20 > @@ -369,8 +400,10 @@ static void BtGetMatches(CMatchFinderMt *p, > UInt32 *distances) > #else >=20 > { >=20 > UInt32 posRes; >=20 > - curPos =3D limit - GetMatchesSpecN(lenLimit, pos, p->buffer, p->son, > cyclicBufferPos, p->cyclicBufferSize, p->cutValue, >=20 > - distances + curPos, p->numHashBytes - 1, p->hashBuf + > p->hashBufPos, (Int32)(limit - curPos), size, &posRes); >=20 > + curPos =3D (UInt32)(GetMatchesSpecN(lenLimit, pos, p->buffer, > p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue, >=20 > + distances + curPos, p->numHashBytes - 1, p->hashBuf + > p->hashBufPos, >=20 > + distances + limit, >=20 > + size, &posRes) - distances); >=20 > p->hashBufPos +=3D posRes - pos; >=20 > cyclicBufferPos +=3D posRes - pos; >=20 > p->buffer +=3D posRes - pos; >=20 > diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.h > b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.h > index 3d86c788f3..fdd17008c2 100644 > --- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.h > +++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.h > @@ -1,5 +1,5 @@ > /* LzFindMt.h -- multithreaded Match finder for LZ algorithms >=20 > -2017-04-03 : Igor Pavlov : Public domain */ >=20 > +2018-07-04 : Igor Pavlov : Public domain */ >=20 >=20 >=20 > #ifndef __LZ_FIND_MT_H >=20 > #define __LZ_FIND_MT_H >=20 > @@ -19,10 +19,10 @@ EXTERN_C_BEGIN >=20 >=20 > typedef struct _CMtSync >=20 > { >=20 > - Bool wasCreated; >=20 > - Bool needStart; >=20 > - Bool exit; >=20 > - Bool stopWriting; >=20 > + BoolInt wasCreated; >=20 > + BoolInt needStart; >=20 > + BoolInt exit; >=20 > + BoolInt stopWriting; >=20 >=20 >=20 > CThread thread; >=20 > CAutoResetEvent canStart; >=20 > @@ -30,8 +30,8 @@ typedef struct _CMtSync > CAutoResetEvent wasStopped; >=20 > CSemaphore freeSemaphore; >=20 > CSemaphore filledSemaphore; >=20 > - Bool csWasInitialized; >=20 > - Bool csWasEntered; >=20 > + BoolInt csWasInitialized; >=20 > + BoolInt csWasEntered; >=20 > CCriticalSection cs; >=20 > UInt32 numProcessedBlocks; >=20 > } CMtSync; >=20 > diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c > b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c > index 962b94bb63..4d1576419f 100644 > --- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c > +++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c > @@ -1,13 +1,13 @@ > /* LzmaDec.c -- LZMA Decoder >=20 > -2018-02-28 : Igor Pavlov : Public domain */ >=20 > +2018-07-04 : Igor Pavlov : Public domain */ >=20 >=20 >=20 > #include "Precomp.h" >=20 >=20 >=20 > +#include >=20 > + >=20 > /* #include "CpuArch.h" */ >=20 > #include "LzmaDec.h" >=20 >=20 >=20 > -#include >=20 > - >=20 > #define kNumTopBits 24 >=20 > #define kTopValue ((UInt32)1 << kNumTopBits) >=20 >=20 >=20 > @@ -19,7 +19,7 @@ >=20 >=20 > #define NORMALIZE if (range < kTopValue) { range <<=3D 8; code =3D = (code << 8) > | (*buf++); } >=20 >=20 >=20 > -#define IF_BIT_0(p) ttt =3D *(p); NORMALIZE; bound =3D (range >> > kNumBitModelTotalBits) * ttt; if (code < bound) >=20 > +#define IF_BIT_0(p) ttt =3D *(p); NORMALIZE; bound =3D (range >> > kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound) >=20 > #define UPDATE_0(p) range =3D bound; *(p) =3D (CLzmaProb)(ttt + > ((kBitModelTotal - ttt) >> kNumMoveBits)); >=20 > #define UPDATE_1(p) range -=3D bound; code -=3D bound; *(p) =3D = (CLzmaProb)(ttt > - (ttt >> kNumMoveBits)); >=20 > #define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \ >=20 > @@ -66,7 +66,7 @@ >=20 >=20 > #define NORMALIZE_CHECK if (range < kTopValue) { if (buf >=3D = bufLimit) > return DUMMY_ERROR; range <<=3D 8; code =3D (code << 8) | (*buf++); } >=20 >=20 >=20 > -#define IF_BIT_0_CHECK(p) ttt =3D *(p); NORMALIZE_CHECK; bound =3D = (range >> > kNumBitModelTotalBits) * ttt; if (code < bound) >=20 > +#define IF_BIT_0_CHECK(p) ttt =3D *(p); NORMALIZE_CHECK; bound =3D = (range >> > kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound) >=20 > #define UPDATE_0_CHECK range =3D bound; >=20 > #define UPDATE_1_CHECK range -=3D bound; code -=3D bound; >=20 > #define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ >=20 > @@ -539,7 +539,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec > *p, SizeT limit, const Byte *bufLimit > curLen =3D ((rem < len) ? (unsigned)rem : len); >=20 > pos =3D dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0); >=20 >=20 >=20 > - processedPos +=3D curLen; >=20 > + processedPos +=3D (UInt32)curLen; >=20 >=20 >=20 > len -=3D curLen; >=20 > if (curLen <=3D dicBufSize - pos) >=20 > @@ -547,7 +547,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec > *p, SizeT limit, const Byte *bufLimit > Byte *dest =3D dic + dicPos; >=20 > ptrdiff_t src =3D (ptrdiff_t)pos - (ptrdiff_t)dicPos; >=20 > const Byte *lim =3D dest + curLen; >=20 > - dicPos +=3D curLen; >=20 > + dicPos +=3D (SizeT)curLen; >=20 > do >=20 > *(dest) =3D (Byte)*(dest + src); >=20 > while (++dest !=3D lim); >=20 > @@ -572,14 +572,14 @@ int MY_FAST_CALL > LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit > p->buf =3D buf; >=20 > p->range =3D range; >=20 > p->code =3D code; >=20 > - p->remainLen =3D len; >=20 > + p->remainLen =3D (UInt32)len; >=20 > p->dicPos =3D dicPos; >=20 > p->processedPos =3D processedPos; >=20 > p->reps[0] =3D rep0; >=20 > p->reps[1] =3D rep1; >=20 > p->reps[2] =3D rep2; >=20 > p->reps[3] =3D rep3; >=20 > - p->state =3D state; >=20 > + p->state =3D (UInt32)state; >=20 >=20 >=20 > return SZ_OK; >=20 > } >=20 > @@ -601,8 +601,8 @@ static void MY_FAST_CALL > LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) > if (p->checkDicSize =3D=3D 0 && p->prop.dicSize - p->processedPos = <=3D len) >=20 > p->checkDicSize =3D p->prop.dicSize; >=20 >=20 >=20 > - p->processedPos +=3D len; >=20 > - p->remainLen -=3D len; >=20 > + p->processedPos +=3D (UInt32)len; >=20 > + p->remainLen -=3D (UInt32)len; >=20 > while (len !=3D 0) >=20 > { >=20 > len--; >=20 > @@ -850,7 +850,7 @@ static ELzmaDummy LzmaDec_TryDummy(const > CLzmaDec *p, const Byte *buf, SizeT inS > } >=20 >=20 >=20 >=20 >=20 > -void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool = initState) >=20 > +void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt > initState) >=20 > { >=20 > p->remainLen =3D kMatchSpecLenStart + 1; >=20 > p->tempBufSize =3D 0; >=20 > @@ -979,10 +979,10 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT > dicLimit, const Byte *src, SizeT *sr > p->tempBufSize =3D rem; >=20 > if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) >=20 > { >=20 > - int dummyRes =3D LzmaDec_TryDummy(p, p->tempBuf, rem); >=20 > + int dummyRes =3D LzmaDec_TryDummy(p, p->tempBuf, > (SizeT)rem); >=20 > if (dummyRes =3D=3D DUMMY_ERROR) >=20 > { >=20 > - (*srcLen) +=3D lookAhead; >=20 > + (*srcLen) +=3D (SizeT)lookAhead; >=20 > *status =3D LZMA_STATUS_NEEDS_MORE_INPUT; >=20 > return SZ_OK; >=20 > } >=20 > @@ -1005,9 +1005,9 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT > dicLimit, const Byte *src, SizeT *sr > return SZ_ERROR_FAIL; /* some internal error */ >=20 > lookAhead -=3D rem; >=20 > } >=20 > - (*srcLen) +=3D lookAhead; >=20 > + (*srcLen) +=3D (SizeT)lookAhead; >=20 > src +=3D lookAhead; >=20 > - inSize -=3D lookAhead; >=20 > + inSize -=3D (SizeT)lookAhead; >=20 > p->tempBufSize =3D 0; >=20 > } >=20 > } >=20 > diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c > b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c > index e281716fee..14086fc4f9 100644 > --- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c > +++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c > @@ -1,5 +1,5 @@ > /* LzmaEnc.c -- LZMA Encoder >=20 > -2018-04-29 : Igor Pavlov : Public domain */ >=20 > +2019-01-10: Igor Pavlov : Public domain */ >=20 >=20 >=20 > #include "Precomp.h" >=20 >=20 >=20 > @@ -38,6 +38,8 @@ static unsigned g_STAT_OFFSET =3D 0; > #define kNumBitPriceShiftBits 4 >=20 > #define kBitPrice (1 << kNumBitPriceShiftBits) >=20 >=20 >=20 > +#define REP_LEN_COUNT 64 >=20 > + >=20 > void LzmaEncProps_Init(CLzmaEncProps *p) >=20 > { >=20 > p->level =3D 5; >=20 > @@ -183,8 +185,11 @@ typedef struct > } COptimal; >=20 >=20 >=20 >=20 >=20 > -#define kNumOpts (1 << 12) >=20 > -#define kPackReserve (1 + kNumOpts * 2) >=20 > +// 18.06 >=20 > +#define kNumOpts (1 << 11) >=20 > +#define kPackReserve (kNumOpts * 8) >=20 > +// #define kNumOpts (1 << 12) >=20 > +// #define kPackReserve (1 + kNumOpts * 2) >=20 >=20 >=20 > #define kNumLenToPosStates 4 >=20 > #define kNumPosSlotBits 6 >=20 > @@ -236,10 +241,18 @@ typedef struct > typedef struct >=20 > { >=20 > unsigned tableSize; >=20 > - unsigned counters[LZMA_NUM_PB_STATES_MAX]; >=20 > UInt32 prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal]; >=20 > + // UInt32 prices1[LZMA_NUM_PB_STATES_MAX][kLenNumLowSymbols * > 2]; >=20 > + // UInt32 prices2[kLenNumSymbolsTotal]; >=20 > } CLenPriceEnc; >=20 >=20 >=20 > +#define GET_PRICE_LEN(p, posState, len) \ >=20 > + ((p)->prices[posState][(size_t)(len) - LZMA_MATCH_LEN_MIN]) >=20 > + >=20 > +/* >=20 > +#define GET_PRICE_LEN(p, posState, len) \ >=20 > + ((p)->prices2[(size_t)(len) - 2] + ((p)->prices1[posState][((len) = - 2) & > (kLenNumLowSymbols * 2 - 1)] & (((len) - 2 - kLenNumLowSymbols * 2) >> 9))) >=20 > +*/ >=20 >=20 >=20 > typedef struct >=20 > { >=20 > @@ -308,16 +321,18 @@ typedef struct > unsigned lc, lp, pb; >=20 > unsigned lclp; >=20 >=20 >=20 > - Bool fastMode; >=20 > - Bool writeEndMark; >=20 > - Bool finished; >=20 > - Bool multiThread; >=20 > - Bool needInit; >=20 > + BoolInt fastMode; >=20 > + BoolInt writeEndMark; >=20 > + BoolInt finished; >=20 > + BoolInt multiThread; >=20 > + BoolInt needInit; >=20 > + // BoolInt _maxMode; >=20 >=20 >=20 > UInt64 nowPos64; >=20 >=20 >=20 > unsigned matchPriceCount; >=20 > - unsigned alignPriceCount; >=20 > + // unsigned alignPriceCount; >=20 > + int repLenEncCounter; >=20 >=20 >=20 > unsigned distTableSize; >=20 >=20 >=20 > @@ -325,7 +340,7 @@ typedef struct > SRes result; >=20 >=20 >=20 > #ifndef _7ZIP_ST >=20 > - Bool mtMode; >=20 > + BoolInt mtMode; >=20 > // begin of CMatchFinderMt is used in LZ thread >=20 > CMatchFinderMt matchFinderMt; >=20 > // end of CMatchFinderMt is used in BT and HASH threads >=20 > @@ -458,6 +473,7 @@ SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const > CLzmaEncProps *props2) > p->lp =3D props.lp; >=20 > p->pb =3D props.pb; >=20 > p->fastMode =3D (props.algo =3D=3D 0); >=20 > + // p->_maxMode =3D True; >=20 > p->matchFinderBase.btMode =3D (Byte)(props.btMode ? 1 : 0); >=20 > { >=20 > unsigned numHashBytes =3D 4; >=20 > @@ -618,9 +634,9 @@ static void RangeEnc_FlushData(CRangeEnc *p) >=20 >=20 > #ifdef _LZMA_ENC_USE_BRANCH >=20 >=20 >=20 > -#define RC_BIT(p, prob, symbol) { \ >=20 > +#define RC_BIT(p, prob, bit) { \ >=20 > RC_BIT_PRE(p, prob) \ >=20 > - if (symbol =3D=3D 0) { range =3D newBound; ttt +=3D (kBitModelTotal = - ttt) >> > kNumMoveBits; } \ >=20 > + if (bit =3D=3D 0) { range =3D newBound; ttt +=3D (kBitModelTotal - = ttt) >> > kNumMoveBits; } \ >=20 > else { (p)->low +=3D newBound; range -=3D newBound; ttt -=3D ttt >> > kNumMoveBits; } \ >=20 > *(prob) =3D (CLzmaProb)ttt; \ >=20 > RC_NORM(p) \ >=20 > @@ -628,15 +644,15 @@ static void RangeEnc_FlushData(CRangeEnc *p) >=20 >=20 > #else >=20 >=20 >=20 > -#define RC_BIT(p, prob, symbol) { \ >=20 > +#define RC_BIT(p, prob, bit) { \ >=20 > UInt32 mask; \ >=20 > RC_BIT_PRE(p, prob) \ >=20 > - mask =3D 0 - (UInt32)symbol; \ >=20 > + mask =3D 0 - (UInt32)bit; \ >=20 > range &=3D mask; \ >=20 > mask &=3D newBound; \ >=20 > range -=3D mask; \ >=20 > (p)->low +=3D mask; \ >=20 > - mask =3D (UInt32)symbol - 1; \ >=20 > + mask =3D (UInt32)bit - 1; \ >=20 > range +=3D newBound & mask; \ >=20 > mask &=3D (kBitModelTotal - ((1 << kNumMoveBits) - 1)); \ >=20 > mask +=3D ((1 << kNumMoveBits) - 1); \ >=20 > @@ -673,42 +689,42 @@ static void RangeEnc_EncodeBit_0(CRangeEnc *p, > CLzmaProb *prob) > p->range =3D range; >=20 > } >=20 >=20 >=20 > -static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 = symbol) >=20 > +static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 sym) >=20 > { >=20 > UInt32 range =3D p->range; >=20 > - symbol |=3D 0x100; >=20 > + sym |=3D 0x100; >=20 > do >=20 > { >=20 > UInt32 ttt, newBound; >=20 > - // RangeEnc_EncodeBit(p, probs + (symbol >> 8), (symbol >> 7) & = 1); >=20 > - CLzmaProb *prob =3D probs + (symbol >> 8); >=20 > - UInt32 bit =3D (symbol >> 7) & 1; >=20 > - symbol <<=3D 1; >=20 > + // RangeEnc_EncodeBit(p, probs + (sym >> 8), (sym >> 7) & 1); >=20 > + CLzmaProb *prob =3D probs + (sym >> 8); >=20 > + UInt32 bit =3D (sym >> 7) & 1; >=20 > + sym <<=3D 1; >=20 > RC_BIT(p, prob, bit); >=20 > } >=20 > - while (symbol < 0x10000); >=20 > + while (sym < 0x10000); >=20 > p->range =3D range; >=20 > } >=20 >=20 >=20 > -static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, = UInt32 > symbol, UInt32 matchByte) >=20 > +static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, > UInt32 sym, UInt32 matchByte) >=20 > { >=20 > UInt32 range =3D p->range; >=20 > UInt32 offs =3D 0x100; >=20 > - symbol |=3D 0x100; >=20 > + sym |=3D 0x100; >=20 > do >=20 > { >=20 > UInt32 ttt, newBound; >=20 > CLzmaProb *prob; >=20 > UInt32 bit; >=20 > matchByte <<=3D 1; >=20 > - // RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + = (symbol >>=20 > 8)), (symbol >> 7) & 1); >=20 > - prob =3D probs + (offs + (matchByte & offs) + (symbol >> 8)); >=20 > - bit =3D (symbol >> 7) & 1; >=20 > - symbol <<=3D 1; >=20 > - offs &=3D ~(matchByte ^ symbol); >=20 > + // RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + = (sym >> > 8)), (sym >> 7) & 1); >=20 > + prob =3D probs + (offs + (matchByte & offs) + (sym >> 8)); >=20 > + bit =3D (sym >> 7) & 1; >=20 > + sym <<=3D 1; >=20 > + offs &=3D ~(matchByte ^ sym); >=20 > RC_BIT(p, prob, bit); >=20 > } >=20 > - while (symbol < 0x10000); >=20 > + while (sym < 0x10000); >=20 > p->range =3D range; >=20 > } >=20 >=20 >=20 > @@ -739,11 +755,11 @@ static void LzmaEnc_InitPriceTables(CProbPrice > *ProbPrices) > } >=20 >=20 >=20 >=20 >=20 > -#define GET_PRICE(prob, symbol) \ >=20 > - p->ProbPrices[((prob) ^ (unsigned)(((-(int)(symbol))) & = (kBitModelTotal - > 1))) >> kNumMoveReducingBits]; >=20 > +#define GET_PRICE(prob, bit) \ >=20 > + p->ProbPrices[((prob) ^ (unsigned)(((-(int)(bit))) & = (kBitModelTotal - 1))) >> > kNumMoveReducingBits]; >=20 >=20 >=20 > -#define GET_PRICEa(prob, symbol) \ >=20 > - ProbPrices[((prob) ^ (unsigned)((-((int)(symbol))) & = (kBitModelTotal - > 1))) >> kNumMoveReducingBits]; >=20 > +#define GET_PRICEa(prob, bit) \ >=20 > + ProbPrices[((prob) ^ (unsigned)((-((int)(bit))) & = (kBitModelTotal - 1))) >> > kNumMoveReducingBits]; >=20 >=20 >=20 > #define GET_PRICE_0(prob) p->ProbPrices[(prob) >> > kNumMoveReducingBits] >=20 > #define GET_PRICE_1(prob) p->ProbPrices[((prob) ^ (kBitModelTotal - = 1)) >>=20 > kNumMoveReducingBits] >=20 > @@ -752,48 +768,48 @@ static void LzmaEnc_InitPriceTables(CProbPrice > *ProbPrices) > #define GET_PRICEa_1(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) = >> > kNumMoveReducingBits] >=20 >=20 >=20 >=20 >=20 > -static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 symbol, const > CProbPrice *ProbPrices) >=20 > +static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 sym, = const > CProbPrice *ProbPrices) >=20 > { >=20 > UInt32 price =3D 0; >=20 > - symbol |=3D 0x100; >=20 > + sym |=3D 0x100; >=20 > do >=20 > { >=20 > - unsigned bit =3D symbol & 1; >=20 > - symbol >>=3D 1; >=20 > - price +=3D GET_PRICEa(probs[symbol], bit); >=20 > + unsigned bit =3D sym & 1; >=20 > + sym >>=3D 1; >=20 > + price +=3D GET_PRICEa(probs[sym], bit); >=20 > } >=20 > - while (symbol >=3D 2); >=20 > + while (sym >=3D 2); >=20 > return price; >=20 > } >=20 >=20 >=20 >=20 >=20 > -static UInt32 LitEnc_Matched_GetPrice(const CLzmaProb *probs, UInt32 > symbol, UInt32 matchByte, const CProbPrice *ProbPrices) >=20 > +static UInt32 LitEnc_Matched_GetPrice(const CLzmaProb *probs, UInt32 > sym, UInt32 matchByte, const CProbPrice *ProbPrices) >=20 > { >=20 > UInt32 price =3D 0; >=20 > UInt32 offs =3D 0x100; >=20 > - symbol |=3D 0x100; >=20 > + sym |=3D 0x100; >=20 > do >=20 > { >=20 > matchByte <<=3D 1; >=20 > - price +=3D GET_PRICEa(probs[offs + (matchByte & offs) + (symbol = >> 8)], > (symbol >> 7) & 1); >=20 > - symbol <<=3D 1; >=20 > - offs &=3D ~(matchByte ^ symbol); >=20 > + price +=3D GET_PRICEa(probs[offs + (matchByte & offs) + (sym >> = 8)], > (sym >> 7) & 1); >=20 > + sym <<=3D 1; >=20 > + offs &=3D ~(matchByte ^ sym); >=20 > } >=20 > - while (symbol < 0x10000); >=20 > + while (sym < 0x10000); >=20 > return price; >=20 > } >=20 >=20 >=20 >=20 >=20 > -static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, > unsigned numBits, UInt32 symbol) >=20 > +static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, > unsigned numBits, unsigned sym) >=20 > { >=20 > UInt32 range =3D rc->range; >=20 > unsigned m =3D 1; >=20 > do >=20 > { >=20 > UInt32 ttt, newBound; >=20 > - unsigned bit =3D symbol & 1; >=20 > + unsigned bit =3D sym & 1; >=20 > // RangeEnc_EncodeBit(rc, probs + m, bit); >=20 > - symbol >>=3D 1; >=20 > + sym >>=3D 1; >=20 > RC_BIT(rc, probs + m, bit); >=20 > m =3D (m << 1) | bit; >=20 > } >=20 > @@ -812,37 +828,37 @@ static void LenEnc_Init(CLenEnc *p) > p->high[i] =3D kProbInitValue; >=20 > } >=20 >=20 >=20 > -static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, unsigned symbol, > unsigned posState) >=20 > +static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, unsigned sym, > unsigned posState) >=20 > { >=20 > UInt32 range, ttt, newBound; >=20 > CLzmaProb *probs =3D p->low; >=20 > range =3D rc->range; >=20 > RC_BIT_PRE(rc, probs); >=20 > - if (symbol >=3D kLenNumLowSymbols) >=20 > + if (sym >=3D kLenNumLowSymbols) >=20 > { >=20 > RC_BIT_1(rc, probs); >=20 > probs +=3D kLenNumLowSymbols; >=20 > RC_BIT_PRE(rc, probs); >=20 > - if (symbol >=3D kLenNumLowSymbols * 2) >=20 > + if (sym >=3D kLenNumLowSymbols * 2) >=20 > { >=20 > RC_BIT_1(rc, probs); >=20 > rc->range =3D range; >=20 > - // RcTree_Encode(rc, p->high, kLenNumHighBits, symbol - > kLenNumLowSymbols * 2); >=20 > - LitEnc_Encode(rc, p->high, symbol - kLenNumLowSymbols * 2); >=20 > + // RcTree_Encode(rc, p->high, kLenNumHighBits, sym - > kLenNumLowSymbols * 2); >=20 > + LitEnc_Encode(rc, p->high, sym - kLenNumLowSymbols * 2); >=20 > return; >=20 > } >=20 > - symbol -=3D kLenNumLowSymbols; >=20 > + sym -=3D kLenNumLowSymbols; >=20 > } >=20 >=20 >=20 > - // RcTree_Encode(rc, probs + (posState << kLenNumLowBits), > kLenNumLowBits, symbol); >=20 > + // RcTree_Encode(rc, probs + (posState << kLenNumLowBits), > kLenNumLowBits, sym); >=20 > { >=20 > unsigned m; >=20 > unsigned bit; >=20 > RC_BIT_0(rc, probs); >=20 > probs +=3D (posState << (1 + kLenNumLowBits)); >=20 > - bit =3D (symbol >> 2) ; RC_BIT(rc, probs + 1, bit); m =3D (1 = << 1) + bit; >=20 > - bit =3D (symbol >> 1) & 1; RC_BIT(rc, probs + m, bit); m =3D (m = << 1) + bit; >=20 > - bit =3D symbol & 1; RC_BIT(rc, probs + m, bit); >=20 > + bit =3D (sym >> 2) ; RC_BIT(rc, probs + 1, bit); m =3D (1 << = 1) + bit; >=20 > + bit =3D (sym >> 1) & 1; RC_BIT(rc, probs + m, bit); m =3D (m << = 1) + bit; >=20 > + bit =3D sym & 1; RC_BIT(rc, probs + m, bit); >=20 > rc->range =3D range; >=20 > } >=20 > } >=20 > @@ -863,50 +879,93 @@ static void SetPrices_3(const CLzmaProb *probs, > UInt32 startPrice, UInt32 *price > } >=20 >=20 >=20 >=20 >=20 > -MY_NO_INLINE static void MY_FAST_CALL LenPriceEnc_UpdateTable( >=20 > - CLenPriceEnc *p, unsigned posState, >=20 > +MY_NO_INLINE static void MY_FAST_CALL LenPriceEnc_UpdateTables( >=20 > + CLenPriceEnc *p, >=20 > + unsigned numPosStates, >=20 > const CLenEnc *enc, >=20 > const CProbPrice *ProbPrices) >=20 > { >=20 > - // int y; for (y =3D 0; y < 100; y++) { >=20 > - UInt32 a; >=20 > - unsigned i, numSymbols; >=20 > + UInt32 b; >=20 > + >=20 > + { >=20 > + unsigned prob =3D enc->low[0]; >=20 > + UInt32 a, c; >=20 > + unsigned posState; >=20 > + b =3D GET_PRICEa_1(prob); >=20 > + a =3D GET_PRICEa_0(prob); >=20 > + c =3D b + GET_PRICEa_0(enc->low[kLenNumLowSymbols]); >=20 > + for (posState =3D 0; posState < numPosStates; posState++) >=20 > + { >=20 > + UInt32 *prices =3D p->prices[posState]; >=20 > + const CLzmaProb *probs =3D enc->low + (posState << (1 + > kLenNumLowBits)); >=20 > + SetPrices_3(probs, a, prices, ProbPrices); >=20 > + SetPrices_3(probs + kLenNumLowSymbols, c, prices + > kLenNumLowSymbols, ProbPrices); >=20 > + } >=20 > + } >=20 >=20 >=20 > - UInt32 *prices =3D p->prices[posState]; >=20 > + /* >=20 > { >=20 > - const CLzmaProb *probs =3D enc->low + (posState << (1 + > kLenNumLowBits)); >=20 > - SetPrices_3(probs, GET_PRICEa_0(enc->low[0]), prices, = ProbPrices); >=20 > + unsigned i; >=20 > + UInt32 b; >=20 > + a =3D GET_PRICEa_0(enc->low[0]); >=20 > + for (i =3D 0; i < kLenNumLowSymbols; i++) >=20 > + p->prices2[i] =3D a; >=20 > a =3D GET_PRICEa_1(enc->low[0]); >=20 > - SetPrices_3(probs + kLenNumLowSymbols, a + > GET_PRICEa_0(enc->low[kLenNumLowSymbols]), prices + > kLenNumLowSymbols, ProbPrices); >=20 > + b =3D a + GET_PRICEa_0(enc->low[kLenNumLowSymbols]); >=20 > + for (i =3D kLenNumLowSymbols; i < kLenNumLowSymbols * 2; i++) >=20 > + p->prices2[i] =3D b; >=20 > a +=3D GET_PRICEa_1(enc->low[kLenNumLowSymbols]); >=20 > } >=20 > - numSymbols =3D p->tableSize; >=20 > - p->counters[posState] =3D numSymbols; >=20 > - for (i =3D kLenNumLowSymbols * 2; i < numSymbols; i +=3D 1) >=20 > + */ >=20 > + >=20 > + // p->counter =3D numSymbols; >=20 > + // p->counter =3D 64; >=20 > + >=20 > { >=20 > - prices[i] =3D a + >=20 > - // RcTree_GetPrice(enc->high, kLenNumHighBits, i - > kLenNumLowSymbols * 2, ProbPrices); >=20 > - LitEnc_GetPrice(enc->high, i - kLenNumLowSymbols * 2, > ProbPrices); >=20 > - /* >=20 > - unsigned sym =3D (i - kLenNumLowSymbols * 2) >> 1; >=20 > - UInt32 price =3D a + RcTree_GetPrice(enc->high, kLenNumHighBits - = 1, > sym, ProbPrices); >=20 > - UInt32 prob =3D enc->high[(1 << 7) + sym]; >=20 > - prices[i ] =3D price + GET_PRICEa_0(prob); >=20 > - prices[i + 1] =3D price + GET_PRICEa_1(prob); >=20 > - */ >=20 > - } >=20 > - // } >=20 > -} >=20 > + unsigned i =3D p->tableSize; >=20 > + >=20 > + if (i > kLenNumLowSymbols * 2) >=20 > + { >=20 > + const CLzmaProb *probs =3D enc->high; >=20 > + UInt32 *prices =3D p->prices[0] + kLenNumLowSymbols * 2; >=20 > + i -=3D kLenNumLowSymbols * 2 - 1; >=20 > + i >>=3D 1; >=20 > + b +=3D GET_PRICEa_1(enc->low[kLenNumLowSymbols]); >=20 > + do >=20 > + { >=20 > + /* >=20 > + p->prices2[i] =3D a + >=20 > + // RcTree_GetPrice(enc->high, kLenNumHighBits, i - > kLenNumLowSymbols * 2, ProbPrices); >=20 > + LitEnc_GetPrice(probs, i - kLenNumLowSymbols * 2, = ProbPrices); >=20 > + */ >=20 > + // UInt32 price =3D a + RcTree_GetPrice(probs, = kLenNumHighBits - 1, > sym, ProbPrices); >=20 > + unsigned sym =3D --i + (1 << (kLenNumHighBits - 1)); >=20 > + UInt32 price =3D b; >=20 > + do >=20 > + { >=20 > + unsigned bit =3D sym & 1; >=20 > + sym >>=3D 1; >=20 > + price +=3D GET_PRICEa(probs[sym], bit); >=20 > + } >=20 > + while (sym >=3D 2); >=20 >=20 >=20 > -static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, unsigned > numPosStates, >=20 > - const CLenEnc *enc, >=20 > - const CProbPrice *ProbPrices) >=20 > -{ >=20 > - unsigned posState; >=20 > - for (posState =3D 0; posState < numPosStates; posState++) >=20 > - LenPriceEnc_UpdateTable(p, posState, enc, ProbPrices); >=20 > -} >=20 > + { >=20 > + unsigned prob =3D probs[(size_t)i + (1 << (kLenNumHighBits = - 1))]; >=20 > + prices[(size_t)i * 2 ] =3D price + GET_PRICEa_0(prob); >=20 > + prices[(size_t)i * 2 + 1] =3D price + GET_PRICEa_1(prob); >=20 > + } >=20 > + } >=20 > + while (i); >=20 >=20 >=20 > + { >=20 > + unsigned posState; >=20 > + size_t num =3D (p->tableSize - kLenNumLowSymbols * 2) * > sizeof(p->prices[0][0]); >=20 > + for (posState =3D 1; posState < numPosStates; posState++) >=20 > + memcpy(p->prices[posState] + kLenNumLowSymbols * 2, > p->prices[0] + kLenNumLowSymbols * 2, num); >=20 > + } >=20 > + } >=20 > + } >=20 > +} >=20 >=20 >=20 > /* >=20 > #ifdef SHOW_STAT >=20 > @@ -917,7 +976,7 @@ static void LenPriceEnc_UpdateTables(CLenPriceEnc > *p, unsigned numPosStates, >=20 >=20 > #define MOVE_POS(p, num) { \ >=20 > p->additionalOffset +=3D (num); \ >=20 > - p->matchFinder.Skip(p->matchFinderObj, (num)); } >=20 > + p->matchFinder.Skip(p->matchFinderObj, (UInt32)(num)); } >=20 >=20 >=20 >=20 >=20 > static unsigned ReadMatchDistances(CLzmaEnc *p, unsigned = *numPairsRes) >=20 > @@ -954,7 +1013,8 @@ static unsigned ReadMatchDistances(CLzmaEnc *p, > unsigned *numPairsRes) > const Byte *p2 =3D p1 + len; >=20 > ptrdiff_t dif =3D (ptrdiff_t)-1 - p->matches[(size_t)numPairs = - 1]; >=20 > const Byte *lim =3D p1 + numAvail; >=20 > - for (; p2 !=3D lim && *p2 =3D=3D p2[dif]; p2++); >=20 > + for (; p2 !=3D lim && *p2 =3D=3D p2[dif]; p2++) >=20 > + {} >=20 > return (unsigned)(p2 - p1); >=20 > } >=20 > } >=20 > @@ -977,7 +1037,7 @@ static unsigned ReadMatchDistances(CLzmaEnc *p, > unsigned *numPairsRes) > + GET_PRICE_1(p->isRep[state]) \ >=20 > + GET_PRICE_0(p->isRepG0[state]) >=20 >=20 >=20 > - >=20 > +MY_FORCE_INLINE >=20 > static UInt32 GetPrice_PureRep(const CLzmaEnc *p, unsigned repIndex, > size_t state, size_t posState) >=20 > { >=20 > UInt32 price; >=20 > @@ -1011,14 +1071,14 @@ static unsigned Backward(CLzmaEnc *p, > unsigned cur) > for (;;) >=20 > { >=20 > UInt32 dist =3D p->opt[cur].dist; >=20 > - UInt32 len =3D p->opt[cur].len; >=20 > - UInt32 extra =3D p->opt[cur].extra; >=20 > + unsigned len =3D (unsigned)p->opt[cur].len; >=20 > + unsigned extra =3D (unsigned)p->opt[cur].extra; >=20 > cur -=3D len; >=20 >=20 >=20 > if (extra) >=20 > { >=20 > wr--; >=20 > - p->opt[wr].len =3D len; >=20 > + p->opt[wr].len =3D (UInt32)len; >=20 > cur -=3D extra; >=20 > len =3D extra; >=20 > if (extra =3D=3D 1) >=20 > @@ -1045,7 +1105,7 @@ static unsigned Backward(CLzmaEnc *p, unsigned > cur) >=20 >=20 > wr--; >=20 > p->opt[wr].dist =3D dist; >=20 > - p->opt[wr].len =3D len; >=20 > + p->opt[wr].len =3D (UInt32)len; >=20 > } >=20 > } >=20 >=20 >=20 > @@ -1102,7 +1162,8 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 > position) > repLens[i] =3D 0; >=20 > continue; >=20 > } >=20 > - for (len =3D 2; len < numAvail && data[len] =3D=3D data2[len]; = len++); >=20 > + for (len =3D 2; len < numAvail && data[len] =3D=3D data2[len]; = len++) >=20 > + {} >=20 > repLens[i] =3D len; >=20 > if (len > repLens[repMaxIndex]) >=20 > repMaxIndex =3D i; >=20 > @@ -1111,7 +1172,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 > position) > if (repLens[repMaxIndex] >=3D p->numFastBytes) >=20 > { >=20 > unsigned len; >=20 > - p->backRes =3D repMaxIndex; >=20 > + p->backRes =3D (UInt32)repMaxIndex; >=20 > len =3D repLens[repMaxIndex]; >=20 > MOVE_POS(p, len - 1) >=20 > return len; >=20 > @@ -1128,8 +1189,12 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) >=20 >=20 > curByte =3D *data; >=20 > matchByte =3D *(data - reps[0]); >=20 > + >=20 > + last =3D repLens[repMaxIndex]; >=20 > + if (last <=3D mainLen) >=20 > + last =3D mainLen; >=20 >=20 >=20 > - if (mainLen < 2 && curByte !=3D matchByte && repLens[repMaxIndex] = < > 2) >=20 > + if (last < 2 && curByte !=3D matchByte) >=20 > { >=20 > p->backRes =3D MARK_LIT; >=20 > return 1; >=20 > @@ -1146,13 +1211,14 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) > LitEnc_Matched_GetPrice(probs, curByte, matchByte, > p->ProbPrices) : >=20 > LitEnc_GetPrice(probs, curByte, p->ProbPrices)); >=20 > } >=20 > - >=20 > + >=20 > MakeAs_Lit(&p->opt[1]); >=20 >=20 >=20 > matchPrice =3D GET_PRICE_1(p->isMatch[p->state][posState]); >=20 > repMatchPrice =3D matchPrice + GET_PRICE_1(p->isRep[p->state]); >=20 >=20 >=20 > - if (matchByte =3D=3D curByte) >=20 > + // 18.06 >=20 > + if (matchByte =3D=3D curByte && repLens[0] =3D=3D 0) >=20 > { >=20 > UInt32 shortRepPrice =3D repMatchPrice + GetPrice_ShortRep(p, > p->state, posState); >=20 > if (shortRepPrice < p->opt[1].price) >=20 > @@ -1160,16 +1226,13 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) > p->opt[1].price =3D shortRepPrice; >=20 > MakeAs_ShortRep(&p->opt[1]); >=20 > } >=20 > + if (last < 2) >=20 > + { >=20 > + p->backRes =3D p->opt[1].dist; >=20 > + return 1; >=20 > + } >=20 > } >=20 > - >=20 > - last =3D (mainLen >=3D repLens[repMaxIndex] ? mainLen : > repLens[repMaxIndex]); >=20 > - >=20 > - if (last < 2) >=20 > - { >=20 > - p->backRes =3D p->opt[1].dist; >=20 > - return 1; >=20 > - } >=20 > - >=20 > + >=20 > p->opt[1].len =3D 1; >=20 >=20 >=20 > p->opt[0].reps[0] =3D reps[0]; >=20 > @@ -1177,13 +1240,6 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) > p->opt[0].reps[2] =3D reps[2]; >=20 > p->opt[0].reps[3] =3D reps[3]; >=20 >=20 >=20 > - { >=20 > - unsigned len =3D last; >=20 > - do >=20 > - p->opt[len--].price =3D kInfinityPrice; >=20 > - while (len >=3D 2); >=20 > - } >=20 > - >=20 > // ---------- REP ---------- >=20 >=20 >=20 > for (i =3D 0; i < LZMA_NUM_REPS; i++) >=20 > @@ -1195,13 +1251,13 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) > price =3D repMatchPrice + GetPrice_PureRep(p, i, p->state, = posState); >=20 > do >=20 > { >=20 > - UInt32 price2 =3D price + > p->repLenEnc.prices[posState][(size_t)repLen - 2]; >=20 > + UInt32 price2 =3D price + GET_PRICE_LEN(&p->repLenEnc, = posState, > repLen); >=20 > COptimal *opt =3D &p->opt[repLen]; >=20 > if (price2 < opt->price) >=20 > { >=20 > opt->price =3D price2; >=20 > - opt->len =3D repLen; >=20 > - opt->dist =3D i; >=20 > + opt->len =3D (UInt32)repLen; >=20 > + opt->dist =3D (UInt32)i; >=20 > opt->extra =3D 0; >=20 > } >=20 > } >=20 > @@ -1211,38 +1267,41 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) >=20 >=20 > // ---------- MATCH ---------- >=20 > { >=20 > - unsigned len =3D ((repLens[0] >=3D 2) ? repLens[0] + 1 : 2); >=20 > + unsigned len =3D repLens[0] + 1; >=20 > if (len <=3D mainLen) >=20 > { >=20 > unsigned offs =3D 0; >=20 > UInt32 normalMatchPrice =3D matchPrice + > GET_PRICE_0(p->isRep[p->state]); >=20 >=20 >=20 > - while (len > matches[offs]) >=20 > - offs +=3D 2; >=20 > + if (len < 2) >=20 > + len =3D 2; >=20 > + else >=20 > + while (len > matches[offs]) >=20 > + offs +=3D 2; >=20 >=20 >=20 > for (; ; len++) >=20 > { >=20 > COptimal *opt; >=20 > UInt32 dist =3D matches[(size_t)offs + 1]; >=20 > - UInt32 price2 =3D normalMatchPrice + > p->lenEnc.prices[posState][(size_t)len - LZMA_MATCH_LEN_MIN]; >=20 > + UInt32 price =3D normalMatchPrice + > GET_PRICE_LEN(&p->lenEnc, posState, len); >=20 > unsigned lenToPosState =3D GetLenToPosState(len); >=20 >=20 >=20 > if (dist < kNumFullDistances) >=20 > - price2 +=3D p->distancesPrices[lenToPosState][dist & > (kNumFullDistances - 1)]; >=20 > + price +=3D p->distancesPrices[lenToPosState][dist & > (kNumFullDistances - 1)]; >=20 > else >=20 > { >=20 > unsigned slot; >=20 > GetPosSlot2(dist, slot); >=20 > - price2 +=3D p->alignPrices[dist & kAlignMask]; >=20 > - price2 +=3D p->posSlotPrices[lenToPosState][slot]; >=20 > + price +=3D p->alignPrices[dist & kAlignMask]; >=20 > + price +=3D p->posSlotPrices[lenToPosState][slot]; >=20 > } >=20 >=20 >=20 > opt =3D &p->opt[len]; >=20 >=20 >=20 > - if (price2 < opt->price) >=20 > + if (price < opt->price) >=20 > { >=20 > - opt->price =3D price2; >=20 > - opt->len =3D len; >=20 > + opt->price =3D price; >=20 > + opt->len =3D (UInt32)len; >=20 > opt->dist =3D dist + LZMA_NUM_REPS; >=20 > opt->extra =3D 0; >=20 > } >=20 > @@ -1277,16 +1336,43 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) >=20 >=20 > for (;;) >=20 > { >=20 > - UInt32 numAvail, numAvailFull; >=20 > + unsigned numAvail; >=20 > + UInt32 numAvailFull; >=20 > unsigned newLen, numPairs, prev, state, posState, startLen; >=20 > - UInt32 curPrice, litPrice, matchPrice, repMatchPrice; >=20 > - Bool nextIsLit; >=20 > + UInt32 litPrice, matchPrice, repMatchPrice; >=20 > + BoolInt nextIsLit; >=20 > Byte curByte, matchByte; >=20 > const Byte *data; >=20 > COptimal *curOpt, *nextOpt; >=20 >=20 >=20 > if (++cur =3D=3D last) >=20 > - return Backward(p, cur); >=20 > + break; >=20 > + >=20 > + // 18.06 >=20 > + if (cur >=3D kNumOpts - 64) >=20 > + { >=20 > + unsigned j, best; >=20 > + UInt32 price =3D p->opt[cur].price; >=20 > + best =3D cur; >=20 > + for (j =3D cur + 1; j <=3D last; j++) >=20 > + { >=20 > + UInt32 price2 =3D p->opt[j].price; >=20 > + if (price >=3D price2) >=20 > + { >=20 > + price =3D price2; >=20 > + best =3D j; >=20 > + } >=20 > + } >=20 > + { >=20 > + unsigned delta =3D best - cur; >=20 > + if (delta !=3D 0) >=20 > + { >=20 > + MOVE_POS(p, delta); >=20 > + } >=20 > + } >=20 > + cur =3D best; >=20 > + break; >=20 > + } >=20 >=20 >=20 > newLen =3D ReadMatchDistances(p, &numPairs); >=20 >=20 >=20 > @@ -1294,15 +1380,24 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) > { >=20 > p->numPairs =3D numPairs; >=20 > p->longestMatchLen =3D newLen; >=20 > - return Backward(p, cur); >=20 > + break; >=20 > } >=20 >=20 >=20 > curOpt =3D &p->opt[cur]; >=20 > + >=20 > + position++; >=20 > + >=20 > + // we need that check here, if skip_items in p->opt are possible >=20 > + /* >=20 > + if (curOpt->price >=3D kInfinityPrice) >=20 > + continue; >=20 > + */ >=20 > + >=20 > prev =3D cur - curOpt->len; >=20 > - >=20 > + >=20 > if (curOpt->len =3D=3D 1) >=20 > { >=20 > - state =3D p->opt[prev].state; >=20 > + state =3D (unsigned)p->opt[prev].state; >=20 > if (IsShortRep(curOpt)) >=20 > state =3D kShortRepNextStates[state]; >=20 > else >=20 > @@ -1316,14 +1411,14 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) >=20 >=20 > if (curOpt->extra) >=20 > { >=20 > - prev -=3D curOpt->extra; >=20 > + prev -=3D (unsigned)curOpt->extra; >=20 > state =3D kState_RepAfterLit; >=20 > if (curOpt->extra =3D=3D 1) >=20 > - state =3D (dist < LZMA_NUM_REPS) ? kState_RepAfterLit : > kState_MatchAfterLit; >=20 > + state =3D (dist < LZMA_NUM_REPS ? kState_RepAfterLit : > kState_MatchAfterLit); >=20 > } >=20 > else >=20 > { >=20 > - state =3D p->opt[prev].state; >=20 > + state =3D (unsigned)p->opt[prev].state; >=20 > if (dist < LZMA_NUM_REPS) >=20 > state =3D kRepNextStates[state]; >=20 > else >=20 > @@ -1379,7 +1474,6 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 > position) > curByte =3D *data; >=20 > matchByte =3D *(data - reps[0]); >=20 >=20 >=20 > - position++; >=20 > posState =3D (position & p->pbMask); >=20 >=20 >=20 > /* >=20 > @@ -1391,13 +1485,25 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) > < MATCH [ : LIT : REP_0 ] >=20 > */ >=20 >=20 >=20 > - curPrice =3D curOpt->price; >=20 > - litPrice =3D curPrice + GET_PRICE_0(p->isMatch[state][posState]); >=20 > + { >=20 > + UInt32 curPrice =3D curOpt->price; >=20 > + unsigned prob =3D p->isMatch[state][posState]; >=20 > + matchPrice =3D curPrice + GET_PRICE_1(prob); >=20 > + litPrice =3D curPrice + GET_PRICE_0(prob); >=20 > + } >=20 >=20 >=20 > nextOpt =3D &p->opt[(size_t)cur + 1]; >=20 > nextIsLit =3D False; >=20 >=20 >=20 > - // if (litPrice >=3D nextOpt->price) litPrice =3D 0; else // = 18.new >=20 > + // here we can allow skip_items in p->opt, if we don't check > (nextOpt->price < kInfinityPrice) >=20 > + // 18.new.06 >=20 > + if ((nextOpt->price < kInfinityPrice >=20 > + // && !IsLitState(state) >=20 > + && matchByte =3D=3D curByte) >=20 > + || litPrice > nextOpt->price >=20 > + ) >=20 > + litPrice =3D 0; >=20 > + else >=20 > { >=20 > const CLzmaProb *probs =3D LIT_PROBS(position, *(data - 1)); >=20 > litPrice +=3D (!IsLitState(state) ? >=20 > @@ -1413,21 +1519,32 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) > } >=20 > } >=20 >=20 >=20 > - matchPrice =3D curPrice + = GET_PRICE_1(p->isMatch[state][posState]); >=20 > repMatchPrice =3D matchPrice + GET_PRICE_1(p->isRep[state]); >=20 >=20 >=20 > + numAvailFull =3D p->numAvail; >=20 > + { >=20 > + unsigned temp =3D kNumOpts - 1 - cur; >=20 > + if (numAvailFull > temp) >=20 > + numAvailFull =3D (UInt32)temp; >=20 > + } >=20 > + >=20 > + // 18.06 >=20 > // ---------- SHORT_REP ---------- >=20 > - // if (IsLitState(state)) // 18.new >=20 > + if (IsLitState(state)) // 18.new >=20 > if (matchByte =3D=3D curByte) >=20 > - // if (repMatchPrice < nextOpt->price) // 18.new >=20 > - if (nextOpt->len < 2 >=20 > + if (repMatchPrice < nextOpt->price) // 18.new >=20 > + // if (numAvailFull < 2 || data[1] !=3D *(data - reps[0] + 1)) >=20 > + if ( >=20 > + // nextOpt->price >=3D kInfinityPrice || >=20 > + nextOpt->len < 2 // we can check nextOpt->len, if skip = items > are not allowed in p->opt >=20 > || (nextOpt->dist !=3D 0 >=20 > - && nextOpt->extra <=3D 1 // 17.old >=20 > - )) >=20 > + // && nextOpt->extra <=3D 1 // 17.old >=20 > + ) >=20 > + ) >=20 > { >=20 > UInt32 shortRepPrice =3D repMatchPrice + GetPrice_ShortRep(p, = state, > posState); >=20 > - if (shortRepPrice <=3D nextOpt->price) // 17.old >=20 > - // if (shortRepPrice < nextOpt->price) // 18.new >=20 > + // if (shortRepPrice <=3D nextOpt->price) // 17.old >=20 > + if (shortRepPrice < nextOpt->price) // 18.new >=20 > { >=20 > nextOpt->price =3D shortRepPrice; >=20 > nextOpt->len =3D 1; >=20 > @@ -1436,13 +1553,6 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) > } >=20 > } >=20 >=20 >=20 > - numAvailFull =3D p->numAvail; >=20 > - { >=20 > - UInt32 temp =3D kNumOpts - 1 - cur; >=20 > - if (numAvailFull > temp) >=20 > - numAvailFull =3D temp; >=20 > - } >=20 > - >=20 > if (numAvailFull < 2) >=20 > continue; >=20 > numAvail =3D (numAvailFull <=3D p->numFastBytes ? numAvailFull : > p->numFastBytes); >=20 > @@ -1451,9 +1561,8 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 > position) >=20 >=20 > // ---------- LIT : REP_0 ---------- >=20 >=20 >=20 > - if ( >=20 > - // litPrice !=3D 0 && // 18.new >=20 > - !nextIsLit >=20 > + if (!nextIsLit >=20 > + && litPrice !=3D 0 // 18.new >=20 > && matchByte !=3D curByte >=20 > && numAvailFull > 2) >=20 > { >=20 > @@ -1465,8 +1574,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 > position) > if (limit > numAvailFull) >=20 > limit =3D numAvailFull; >=20 > for (len =3D 3; len < limit && data[len] =3D=3D data2[len]; = len++) >=20 > - { >=20 > - } >=20 > + {} >=20 >=20 >=20 > { >=20 > unsigned state2 =3D kLiteralNextStates[state]; >=20 > @@ -1474,8 +1582,9 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 > position) > UInt32 price =3D litPrice + GetPrice_Rep_0(p, state2, = posState2); >=20 > { >=20 > unsigned offset =3D cur + len; >=20 > - while (last < offset) >=20 > - p->opt[++last].price =3D kInfinityPrice; >=20 > + >=20 > + if (last < offset) >=20 > + last =3D offset; >=20 >=20 >=20 > // do >=20 > { >=20 > @@ -1483,14 +1592,14 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) > COptimal *opt; >=20 > len--; >=20 > // price2 =3D price + GetPrice_Len_Rep_0(p, len, = state2, > posState2); >=20 > - price2 =3D price + p->repLenEnc.prices[posState2][len - > LZMA_MATCH_LEN_MIN]; >=20 > + price2 =3D price + GET_PRICE_LEN(&p->repLenEnc, > posState2, len); >=20 >=20 >=20 > opt =3D &p->opt[offset]; >=20 > // offset--; >=20 > if (price2 < opt->price) >=20 > { >=20 > opt->price =3D price2; >=20 > - opt->len =3D len; >=20 > + opt->len =3D (UInt32)len; >=20 > opt->dist =3D 0; >=20 > opt->extra =3D 1; >=20 > } >=20 > @@ -1502,6 +1611,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 > position) > } >=20 >=20 >=20 > startLen =3D 2; /* speed optimization */ >=20 > + >=20 > { >=20 > // ---------- REP ---------- >=20 > unsigned repIndex =3D 0; // 17.old >=20 > @@ -1514,24 +1624,28 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) > if (data[0] !=3D data2[0] || data[1] !=3D data2[1]) >=20 > continue; >=20 >=20 >=20 > - for (len =3D 2; len < numAvail && data[len] =3D=3D = data2[len]; len++); >=20 > + for (len =3D 2; len < numAvail && data[len] =3D=3D = data2[len]; len++) >=20 > + {} >=20 >=20 >=20 > // if (len < startLen) continue; // 18.new: speed = optimization >=20 >=20 >=20 > - while (last < cur + len) >=20 > - p->opt[++last].price =3D kInfinityPrice; >=20 > + { >=20 > + unsigned offset =3D cur + len; >=20 > + if (last < offset) >=20 > + last =3D offset; >=20 > + } >=20 > { >=20 > unsigned len2 =3D len; >=20 > price =3D repMatchPrice + GetPrice_PureRep(p, repIndex, = state, > posState); >=20 > do >=20 > { >=20 > - UInt32 price2 =3D price + > p->repLenEnc.prices[posState][(size_t)len2 - 2]; >=20 > + UInt32 price2 =3D price + GET_PRICE_LEN(&p->repLenEnc, > posState, len2); >=20 > COptimal *opt =3D &p->opt[cur + len2]; >=20 > if (price2 < opt->price) >=20 > { >=20 > opt->price =3D price2; >=20 > - opt->len =3D len2; >=20 > - opt->dist =3D repIndex; >=20 > + opt->len =3D (UInt32)len2; >=20 > + opt->dist =3D (UInt32)repIndex; >=20 > opt->extra =3D 0; >=20 > } >=20 > } >=20 > @@ -1551,15 +1665,14 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) > if (limit > numAvailFull) >=20 > limit =3D numAvailFull; >=20 >=20 >=20 > - for (; len2 < limit && data[len2] =3D=3D data2[len2]; = len2++); >=20 > - >=20 > - len2 -=3D len; >=20 > - if (len2 >=3D 3) >=20 > + len2 +=3D 2; >=20 > + if (len2 <=3D limit) >=20 > + if (data[len2 - 2] =3D=3D data2[len2 - 2]) >=20 > + if (data[len2 - 1] =3D=3D data2[len2 - 1]) >=20 > { >=20 > unsigned state2 =3D kRepNextStates[state]; >=20 > unsigned posState2 =3D (position + len) & p->pbMask; >=20 > - price +=3D >=20 > - p->repLenEnc.prices[posState][(size_t)len - 2] >=20 > + price +=3D GET_PRICE_LEN(&p->repLenEnc, posState, len) >=20 > + GET_PRICE_0(p->isMatch[state2][posState2]) >=20 > + LitEnc_Matched_GetPrice(LIT_PROBS(position + len, > data[(size_t)len - 1]), >=20 > data[len], data2[len], p->ProbPrices); >=20 > @@ -1570,31 +1683,40 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) >=20 >=20 >=20 >=20 > price +=3D GetPrice_Rep_0(p, state2, posState2); >=20 > + >=20 > + for (; len2 < limit && data[len2] =3D=3D data2[len2]; = len2++) >=20 > + {} >=20 > + >=20 > + len2 -=3D len; >=20 > + // if (len2 >=3D 3) >=20 > + { >=20 > { >=20 > unsigned offset =3D cur + len + len2; >=20 > - while (last < offset) >=20 > - p->opt[++last].price =3D kInfinityPrice; >=20 > + >=20 > + if (last < offset) >=20 > + last =3D offset; >=20 > // do >=20 > { >=20 > - unsigned price2; >=20 > + UInt32 price2; >=20 > COptimal *opt; >=20 > len2--; >=20 > // price2 =3D price + GetPrice_Len_Rep_0(p, len2, = state2, > posState2); >=20 > - price2 =3D price + = p->repLenEnc.prices[posState2][len2 - > LZMA_MATCH_LEN_MIN]; >=20 > + price2 =3D price + GET_PRICE_LEN(&p->repLenEnc, > posState2, len2); >=20 >=20 >=20 > opt =3D &p->opt[offset]; >=20 > // offset--; >=20 > if (price2 < opt->price) >=20 > { >=20 > opt->price =3D price2; >=20 > - opt->len =3D len2; >=20 > + opt->len =3D (UInt32)len2; >=20 > opt->extra =3D (CExtra)(len + 1); >=20 > - opt->dist =3D repIndex; >=20 > + opt->dist =3D (UInt32)repIndex; >=20 > } >=20 > } >=20 > // while (len2 >=3D 3); >=20 > } >=20 > } >=20 > + } >=20 > } >=20 > } >=20 > } >=20 > @@ -1606,17 +1728,23 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) > { >=20 > newLen =3D numAvail; >=20 > for (numPairs =3D 0; newLen > matches[numPairs]; numPairs +=3D = 2); >=20 > - matches[numPairs] =3D newLen; >=20 > + matches[numPairs] =3D (UInt32)newLen; >=20 > numPairs +=3D 2; >=20 > } >=20 >=20 >=20 > + // startLen =3D 2; /* speed optimization */ >=20 > + >=20 > if (newLen >=3D startLen) >=20 > { >=20 > UInt32 normalMatchPrice =3D matchPrice + > GET_PRICE_0(p->isRep[state]); >=20 > UInt32 dist; >=20 > unsigned offs, posSlot, len; >=20 > - while (last < cur + newLen) >=20 > - p->opt[++last].price =3D kInfinityPrice; >=20 > + >=20 > + { >=20 > + unsigned offset =3D cur + newLen; >=20 > + if (last < offset) >=20 > + last =3D offset; >=20 > + } >=20 >=20 >=20 > offs =3D 0; >=20 > while (startLen > matches[offs]) >=20 > @@ -1628,27 +1756,29 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) >=20 >=20 > for (len =3D /*2*/ startLen; ; len++) >=20 > { >=20 > - UInt32 price =3D normalMatchPrice + > p->lenEnc.prices[posState][(size_t)len - LZMA_MATCH_LEN_MIN]; >=20 > + UInt32 price =3D normalMatchPrice + GET_PRICE_LEN(&p->lenEnc, > posState, len); >=20 > { >=20 > COptimal *opt; >=20 > - unsigned lenToPosState =3D len - 2; lenToPosState =3D > GetLenToPosState2(lenToPosState); >=20 > + unsigned lenNorm =3D len - 2; >=20 > + lenNorm =3D GetLenToPosState2(lenNorm); >=20 > if (dist < kNumFullDistances) >=20 > - price +=3D p->distancesPrices[lenToPosState][dist & > (kNumFullDistances - 1)]; >=20 > + price +=3D p->distancesPrices[lenNorm][dist & > (kNumFullDistances - 1)]; >=20 > else >=20 > - price +=3D p->posSlotPrices[lenToPosState][posSlot] + > p->alignPrices[dist & kAlignMask]; >=20 > + price +=3D p->posSlotPrices[lenNorm][posSlot] + > p->alignPrices[dist & kAlignMask]; >=20 >=20 >=20 > opt =3D &p->opt[cur + len]; >=20 > if (price < opt->price) >=20 > { >=20 > opt->price =3D price; >=20 > - opt->len =3D len; >=20 > + opt->len =3D (UInt32)len; >=20 > opt->dist =3D dist + LZMA_NUM_REPS; >=20 > opt->extra =3D 0; >=20 > } >=20 > } >=20 >=20 >=20 > - if (/*_maxMode && */ len =3D=3D matches[offs]) >=20 > + if (len =3D=3D matches[offs]) >=20 > { >=20 > + // if (p->_maxMode) { >=20 > // MATCH : LIT : REP_0 >=20 >=20 >=20 > const Byte *data2 =3D data - dist - 1; >=20 > @@ -1657,11 +1787,17 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) > if (limit > numAvailFull) >=20 > limit =3D numAvailFull; >=20 >=20 >=20 > - for (; len2 < limit && data[len2] =3D=3D data2[len2]; = len2++); >=20 > + len2 +=3D 2; >=20 > + if (len2 <=3D limit) >=20 > + if (data[len2 - 2] =3D=3D data2[len2 - 2]) >=20 > + if (data[len2 - 1] =3D=3D data2[len2 - 1]) >=20 > + { >=20 > + for (; len2 < limit && data[len2] =3D=3D data2[len2]; = len2++) >=20 > + {} >=20 >=20 >=20 > len2 -=3D len; >=20 >=20 >=20 > - if (len2 >=3D 3) >=20 > + // if (len2 >=3D 3) >=20 > { >=20 > unsigned state2 =3D kMatchNextStates[state]; >=20 > unsigned posState2 =3D (position + len) & p->pbMask; >=20 > @@ -1677,27 +1813,30 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) > price +=3D GetPrice_Rep_0(p, state2, posState2); >=20 >=20 >=20 > offset =3D cur + len + len2; >=20 > - while (last < offset) >=20 > - p->opt[++last].price =3D kInfinityPrice; >=20 > + >=20 > + if (last < offset) >=20 > + last =3D offset; >=20 > // do >=20 > { >=20 > UInt32 price2; >=20 > COptimal *opt; >=20 > len2--; >=20 > // price2 =3D price + GetPrice_Len_Rep_0(p, len2, = state2, > posState2); >=20 > - price2 =3D price + p->repLenEnc.prices[posState2][len2 = - > LZMA_MATCH_LEN_MIN]; >=20 > + price2 =3D price + GET_PRICE_LEN(&p->repLenEnc, > posState2, len2); >=20 > opt =3D &p->opt[offset]; >=20 > // offset--; >=20 > if (price2 < opt->price) >=20 > { >=20 > opt->price =3D price2; >=20 > - opt->len =3D len2; >=20 > + opt->len =3D (UInt32)len2; >=20 > opt->extra =3D (CExtra)(len + 1); >=20 > opt->dist =3D dist + LZMA_NUM_REPS; >=20 > } >=20 > } >=20 > // while (len2 >=3D 3); >=20 > } >=20 > + >=20 > + } >=20 >=20 >=20 > offs +=3D 2; >=20 > if (offs =3D=3D numPairs) >=20 > @@ -1709,6 +1848,12 @@ static unsigned GetOptimum(CLzmaEnc *p, > UInt32 position) > } >=20 > } >=20 > } >=20 > + >=20 > + do >=20 > + p->opt[last].price =3D kInfinityPrice; >=20 > + while (--last); >=20 > + >=20 > + return Backward(p, cur); >=20 > } >=20 >=20 >=20 >=20 >=20 > @@ -1735,6 +1880,7 @@ static unsigned GetOptimumFast(CLzmaEnc *p) > p->backRes =3D MARK_LIT; >=20 > if (numAvail < 2) >=20 > return 1; >=20 > + // if (mainLen < 2 && p->state =3D=3D 0) return 1; // 18.06.notused >=20 > if (numAvail > LZMA_MATCH_LEN_MAX) >=20 > numAvail =3D LZMA_MATCH_LEN_MAX; >=20 > data =3D p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - = 1; >=20 > @@ -1746,10 +1892,11 @@ static unsigned GetOptimumFast(CLzmaEnc *p) > const Byte *data2 =3D data - p->reps[i]; >=20 > if (data[0] !=3D data2[0] || data[1] !=3D data2[1]) >=20 > continue; >=20 > - for (len =3D 2; len < numAvail && data[len] =3D=3D data2[len]; = len++); >=20 > + for (len =3D 2; len < numAvail && data[len] =3D=3D data2[len]; = len++) >=20 > + {} >=20 > if (len >=3D p->numFastBytes) >=20 > { >=20 > - p->backRes =3D i; >=20 > + p->backRes =3D (UInt32)i; >=20 > MOVE_POS(p, len - 1) >=20 > return len; >=20 > } >=20 > @@ -1793,7 +1940,7 @@ static unsigned GetOptimumFast(CLzmaEnc *p) > || (repLen + 2 >=3D mainLen && mainDist >=3D (1 << 9)) >=20 > || (repLen + 3 >=3D mainLen && mainDist >=3D (1 << 15))) >=20 > { >=20 > - p->backRes =3D repIndex; >=20 > + p->backRes =3D (UInt32)repIndex; >=20 > MOVE_POS(p, repLen - 1) >=20 > return repLen; >=20 > } >=20 > @@ -1932,23 +2079,22 @@ MY_NO_INLINE static SRes Flush(CLzmaEnc *p, > UInt32 nowPos) > } >=20 >=20 >=20 >=20 >=20 > - >=20 > -static void FillAlignPrices(CLzmaEnc *p) >=20 > +MY_NO_INLINE static void FillAlignPrices(CLzmaEnc *p) >=20 > { >=20 > unsigned i; >=20 > const CProbPrice *ProbPrices =3D p->ProbPrices; >=20 > const CLzmaProb *probs =3D p->posAlignEncoder; >=20 > - p->alignPriceCount =3D 0; >=20 > + // p->alignPriceCount =3D 0; >=20 > for (i =3D 0; i < kAlignTableSize / 2; i++) >=20 > { >=20 > UInt32 price =3D 0; >=20 > - unsigned symbol =3D i; >=20 > + unsigned sym =3D i; >=20 > unsigned m =3D 1; >=20 > unsigned bit; >=20 > UInt32 prob; >=20 > - bit =3D symbol & 1; symbol >>=3D 1; price +=3D = GET_PRICEa(probs[m], bit); m =3D > (m << 1) + bit; >=20 > - bit =3D symbol & 1; symbol >>=3D 1; price +=3D = GET_PRICEa(probs[m], bit); m =3D > (m << 1) + bit; >=20 > - bit =3D symbol & 1; symbol >>=3D 1; price +=3D = GET_PRICEa(probs[m], bit); m =3D > (m << 1) + bit; >=20 > + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[m], = bit); m =3D (m > << 1) + bit; >=20 > + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[m], = bit); m =3D (m > << 1) + bit; >=20 > + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[m], = bit); m =3D (m > << 1) + bit; >=20 > prob =3D probs[m]; >=20 > p->alignPrices[i ] =3D price + GET_PRICEa_0(prob); >=20 > p->alignPrices[i + 8] =3D price + GET_PRICEa_1(prob); >=20 > @@ -1957,78 +2103,97 @@ static void FillAlignPrices(CLzmaEnc *p) > } >=20 >=20 >=20 >=20 >=20 > -static void FillDistancesPrices(CLzmaEnc *p) >=20 > +MY_NO_INLINE static void FillDistancesPrices(CLzmaEnc *p) >=20 > { >=20 > + // int y; for (y =3D 0; y < 100; y++) { >=20 > + >=20 > UInt32 tempPrices[kNumFullDistances]; >=20 > - unsigned i, lenToPosState; >=20 > + unsigned i, lps; >=20 >=20 >=20 > const CProbPrice *ProbPrices =3D p->ProbPrices; >=20 > p->matchPriceCount =3D 0; >=20 >=20 >=20 > - for (i =3D kStartPosModelIndex; i < kNumFullDistances; i++) >=20 > + for (i =3D kStartPosModelIndex / 2; i < kNumFullDistances / 2; i++) >=20 > { >=20 > unsigned posSlot =3D GetPosSlot1(i); >=20 > - unsigned footerBits =3D ((posSlot >> 1) - 1); >=20 > + unsigned footerBits =3D (posSlot >> 1) - 1; >=20 > unsigned base =3D ((2 | (posSlot & 1)) << footerBits); >=20 > + const CLzmaProb *probs =3D p->posEncoders + (size_t)base * 2; >=20 > // tempPrices[i] =3D RcTree_ReverseGetPrice(p->posEncoders + = base, > footerBits, i - base, p->ProbPrices); >=20 > - >=20 > - const CLzmaProb *probs =3D p->posEncoders + base; >=20 > UInt32 price =3D 0; >=20 > unsigned m =3D 1; >=20 > - unsigned symbol =3D i - base; >=20 > + unsigned sym =3D i; >=20 > + unsigned offset =3D (unsigned)1 << footerBits; >=20 > + base +=3D i; >=20 > + >=20 > + if (footerBits) >=20 > do >=20 > { >=20 > - unsigned bit =3D symbol & 1; >=20 > - symbol >>=3D 1; >=20 > + unsigned bit =3D sym & 1; >=20 > + sym >>=3D 1; >=20 > price +=3D GET_PRICEa(probs[m], bit); >=20 > m =3D (m << 1) + bit; >=20 > } >=20 > while (--footerBits); >=20 > - tempPrices[i] =3D price; >=20 > + >=20 > + { >=20 > + unsigned prob =3D probs[m]; >=20 > + tempPrices[base ] =3D price + GET_PRICEa_0(prob); >=20 > + tempPrices[base + offset] =3D price + GET_PRICEa_1(prob); >=20 > + } >=20 > } >=20 >=20 >=20 > - for (lenToPosState =3D 0; lenToPosState < kNumLenToPosStates; > lenToPosState++) >=20 > + for (lps =3D 0; lps < kNumLenToPosStates; lps++) >=20 > { >=20 > - unsigned posSlot; >=20 > - const CLzmaProb *encoder =3D p->posSlotEncoder[lenToPosState]; >=20 > - UInt32 *posSlotPrices =3D p->posSlotPrices[lenToPosState]; >=20 > - unsigned distTableSize =3D p->distTableSize; >=20 > - const CLzmaProb *probs =3D encoder; >=20 > - for (posSlot =3D 0; posSlot < distTableSize; posSlot +=3D 2) >=20 > + unsigned slot; >=20 > + unsigned distTableSize2 =3D (p->distTableSize + 1) >> 1; >=20 > + UInt32 *posSlotPrices =3D p->posSlotPrices[lps]; >=20 > + const CLzmaProb *probs =3D p->posSlotEncoder[lps]; >=20 > + >=20 > + for (slot =3D 0; slot < distTableSize2; slot++) >=20 > { >=20 > - // posSlotPrices[posSlot] =3D RcTree_GetPrice(encoder, > kNumPosSlotBits, posSlot, p->ProbPrices); >=20 > - UInt32 price =3D 0; >=20 > + // posSlotPrices[slot] =3D RcTree_GetPrice(encoder, = kNumPosSlotBits, > slot, p->ProbPrices); >=20 > + UInt32 price; >=20 > unsigned bit; >=20 > - unsigned symbol =3D (posSlot >> 1) + (1 << (kNumPosSlotBits - = 1)); >=20 > - UInt32 prob; >=20 > - bit =3D symbol & 1; symbol >>=3D 1; price +=3D = GET_PRICEa(probs[symbol], > bit); >=20 > - bit =3D symbol & 1; symbol >>=3D 1; price +=3D = GET_PRICEa(probs[symbol], > bit); >=20 > - bit =3D symbol & 1; symbol >>=3D 1; price +=3D = GET_PRICEa(probs[symbol], > bit); >=20 > - bit =3D symbol & 1; symbol >>=3D 1; price +=3D = GET_PRICEa(probs[symbol], > bit); >=20 > - bit =3D symbol & 1; symbol >>=3D 1; price +=3D = GET_PRICEa(probs[symbol], > bit); >=20 > - prob =3D probs[(posSlot >> 1) + (1 << (kNumPosSlotBits - 1))]; >=20 > - posSlotPrices[posSlot ] =3D price + GET_PRICEa_0(prob); >=20 > - posSlotPrices[posSlot + 1] =3D price + GET_PRICEa_1(prob); >=20 > + unsigned sym =3D slot + (1 << (kNumPosSlotBits - 1)); >=20 > + unsigned prob; >=20 > + bit =3D sym & 1; sym >>=3D 1; price =3D GET_PRICEa(probs[sym], = bit); >=20 > + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[sym], = bit); >=20 > + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[sym], = bit); >=20 > + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[sym], = bit); >=20 > + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[sym], = bit); >=20 > + prob =3D probs[(size_t)slot + (1 << (kNumPosSlotBits - 1))]; >=20 > + posSlotPrices[(size_t)slot * 2 ] =3D price + = GET_PRICEa_0(prob); >=20 > + posSlotPrices[(size_t)slot * 2 + 1] =3D price + = GET_PRICEa_1(prob); >=20 > } >=20 > - for (posSlot =3D kEndPosModelIndex; posSlot < distTableSize; = posSlot++) >=20 > - posSlotPrices[posSlot] +=3D ((UInt32)(((posSlot >> 1) - 1) - > kNumAlignBits) << kNumBitPriceShiftBits); >=20 > - >=20 > + >=20 > { >=20 > - UInt32 *distancesPrices =3D p->distancesPrices[lenToPosState]; >=20 > + UInt32 delta =3D ((UInt32)((kEndPosModelIndex / 2 - 1) - > kNumAlignBits) << kNumBitPriceShiftBits); >=20 > + for (slot =3D kEndPosModelIndex / 2; slot < distTableSize2; = slot++) >=20 > { >=20 > - distancesPrices[0] =3D posSlotPrices[0]; >=20 > - distancesPrices[1] =3D posSlotPrices[1]; >=20 > - distancesPrices[2] =3D posSlotPrices[2]; >=20 > - distancesPrices[3] =3D posSlotPrices[3]; >=20 > + posSlotPrices[(size_t)slot * 2 ] +=3D delta; >=20 > + posSlotPrices[(size_t)slot * 2 + 1] +=3D delta; >=20 > + delta +=3D ((UInt32)1 << kNumBitPriceShiftBits); >=20 > } >=20 > + } >=20 > + >=20 > + { >=20 > + UInt32 *dp =3D p->distancesPrices[lps]; >=20 > + >=20 > + dp[0] =3D posSlotPrices[0]; >=20 > + dp[1] =3D posSlotPrices[1]; >=20 > + dp[2] =3D posSlotPrices[2]; >=20 > + dp[3] =3D posSlotPrices[3]; >=20 > + >=20 > for (i =3D 4; i < kNumFullDistances; i +=3D 2) >=20 > { >=20 > UInt32 slotPrice =3D posSlotPrices[GetPosSlot1(i)]; >=20 > - distancesPrices[i ] =3D slotPrice + tempPrices[i]; >=20 > - distancesPrices[i + 1] =3D slotPrice + tempPrices[i + 1]; >=20 > + dp[i ] =3D slotPrice + tempPrices[i]; >=20 > + dp[i + 1] =3D slotPrice + tempPrices[i + 1]; >=20 > } >=20 > } >=20 > } >=20 > + // } >=20 > } >=20 >=20 >=20 >=20 >=20 > @@ -2245,10 +2410,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc > *p, UInt32 maxPackSize, UInt32 maxUnpa > if (len !=3D 1) >=20 > { >=20 > LenEnc_Encode(&p->repLenProbs, &p->rc, len - > LZMA_MATCH_LEN_MIN, posState); >=20 > - if (!p->fastMode) >=20 > - if (--p->repLenEnc.counters[posState] =3D=3D 0) >=20 > - LenPriceEnc_UpdateTable(&p->repLenEnc, posState, > &p->repLenProbs, p->ProbPrices); >=20 > - >=20 > + --p->repLenEncCounter; >=20 > p->state =3D kRepNextStates[p->state]; >=20 > } >=20 > } >=20 > @@ -2260,9 +2422,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, > UInt32 maxPackSize, UInt32 maxUnpa > p->state =3D kMatchNextStates[p->state]; >=20 >=20 >=20 > LenEnc_Encode(&p->lenProbs, &p->rc, len - > LZMA_MATCH_LEN_MIN, posState); >=20 > - if (!p->fastMode) >=20 > - if (--p->lenEnc.counters[posState] =3D=3D 0) >=20 > - LenPriceEnc_UpdateTable(&p->lenEnc, posState, > &p->lenProbs, p->ProbPrices); >=20 > + // --p->lenEnc.counter; >=20 >=20 >=20 > dist -=3D LZMA_NUM_REPS; >=20 > p->reps[3] =3D p->reps[2]; >=20 > @@ -2274,17 +2434,17 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc > *p, UInt32 maxPackSize, UInt32 maxUnpa > GetPosSlot(dist, posSlot); >=20 > // RcTree_Encode_PosSlot(&p->rc, > p->posSlotEncoder[GetLenToPosState(len)], posSlot); >=20 > { >=20 > - UInt32 symbol =3D posSlot + (1 << kNumPosSlotBits); >=20 > + UInt32 sym =3D (UInt32)posSlot + (1 << kNumPosSlotBits); >=20 > range =3D p->rc.range; >=20 > probs =3D p->posSlotEncoder[GetLenToPosState(len)]; >=20 > do >=20 > { >=20 > - CLzmaProb *prob =3D probs + (symbol >> kNumPosSlotBits); >=20 > - UInt32 bit =3D (symbol >> (kNumPosSlotBits - 1)) & 1; >=20 > - symbol <<=3D 1; >=20 > + CLzmaProb *prob =3D probs + (sym >> kNumPosSlotBits); >=20 > + UInt32 bit =3D (sym >> (kNumPosSlotBits - 1)) & 1; >=20 > + sym <<=3D 1; >=20 > RC_BIT(&p->rc, prob, bit); >=20 > } >=20 > - while (symbol < (1 << kNumPosSlotBits * 2)); >=20 > + while (sym < (1 << kNumPosSlotBits * 2)); >=20 > p->rc.range =3D range; >=20 > } >=20 >=20 >=20 > @@ -2295,7 +2455,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, > UInt32 maxPackSize, UInt32 maxUnpa > if (dist < kNumFullDistances) >=20 > { >=20 > unsigned base =3D ((2 | (posSlot & 1)) << footerBits); >=20 > - RcTree_ReverseEncode(&p->rc, p->posEncoders + base, > footerBits, dist - base); >=20 > + RcTree_ReverseEncode(&p->rc, p->posEncoders + base, > footerBits, (unsigned)(dist /* - base */)); >=20 > } >=20 > else >=20 > { >=20 > @@ -2331,14 +2491,14 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc > *p, UInt32 maxPackSize, UInt32 maxUnpa > bit =3D dist & 1; dist >>=3D 1; RC_BIT(&p->rc, > p->posAlignEncoder + m, bit); m =3D (m << 1) + bit; >=20 > bit =3D dist & 1; RC_BIT(&p->rc, > p->posAlignEncoder + m, bit); >=20 > p->rc.range =3D range; >=20 > - p->alignPriceCount++; >=20 > + // p->alignPriceCount++; >=20 > } >=20 > } >=20 > } >=20 > } >=20 > } >=20 >=20 >=20 > - nowPos32 +=3D len; >=20 > + nowPos32 +=3D (UInt32)len; >=20 > p->additionalOffset -=3D len; >=20 >=20 >=20 > if (p->additionalOffset =3D=3D 0) >=20 > @@ -2347,10 +2507,27 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc > *p, UInt32 maxPackSize, UInt32 maxUnpa >=20 >=20 > if (!p->fastMode) >=20 > { >=20 > - if (p->matchPriceCount >=3D (1 << 7)) >=20 > + /* >=20 > + if (p->alignPriceCount >=3D 16) // kAlignTableSize >=20 > + FillAlignPrices(p); >=20 > + if (p->matchPriceCount >=3D 128) >=20 > FillDistancesPrices(p); >=20 > - if (p->alignPriceCount >=3D kAlignTableSize) >=20 > + if (p->lenEnc.counter <=3D 0) >=20 > + LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, > &p->lenProbs, p->ProbPrices); >=20 > + */ >=20 > + if (p->matchPriceCount >=3D 64) >=20 > + { >=20 > FillAlignPrices(p); >=20 > + // { int y; for (y =3D 0; y < 100; y++) { >=20 > + FillDistancesPrices(p); >=20 > + // }} >=20 > + LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, > &p->lenProbs, p->ProbPrices); >=20 > + } >=20 > + if (p->repLenEncCounter <=3D 0) >=20 > + { >=20 > + p->repLenEncCounter =3D REP_LEN_COUNT; >=20 > + LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, > &p->repLenProbs, p->ProbPrices); >=20 > + } >=20 > } >=20 >=20 >=20 > if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) = =3D=3D 0) >=20 > @@ -2490,12 +2667,19 @@ void LzmaEnc_Init(CLzmaEnc *p) >=20 >=20 > p->optEnd =3D 0; >=20 > p->optCur =3D 0; >=20 > + >=20 > + { >=20 > + for (i =3D 0; i < kNumOpts; i++) >=20 > + p->opt[i].price =3D kInfinityPrice; >=20 > + } >=20 > + >=20 > p->additionalOffset =3D 0; >=20 >=20 >=20 > p->pbMask =3D (1 << p->pb) - 1; >=20 > p->lpMask =3D ((UInt32)0x100 << p->lp) - ((unsigned)0x100 >> = p->lc); >=20 > } >=20 >=20 >=20 > + >=20 > void LzmaEnc_InitPrices(CLzmaEnc *p) >=20 > { >=20 > if (!p->fastMode) >=20 > @@ -2507,6 +2691,9 @@ void LzmaEnc_InitPrices(CLzmaEnc *p) > p->lenEnc.tableSize =3D >=20 > p->repLenEnc.tableSize =3D >=20 > p->numFastBytes + 1 - LZMA_MATCH_LEN_MIN; >=20 > + >=20 > + p->repLenEncCounter =3D REP_LEN_COUNT; >=20 > + >=20 > LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, &p->lenProbs, > p->ProbPrices); >=20 > LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, = &p->repLenProbs, > p->ProbPrices); >=20 > } >=20 > @@ -2583,7 +2770,7 @@ typedef struct > ISeqOutStream vt; >=20 > Byte *data; >=20 > SizeT rem; >=20 > - Bool overflow; >=20 > + BoolInt overflow; >=20 > } CLzmaEnc_SeqOutStreamBuf; >=20 >=20 >=20 > static size_t SeqOutStreamBuf_Write(const ISeqOutStream *pp, const = void > *data, size_t size) >=20 > @@ -2615,7 +2802,7 @@ const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle > pp) > } >=20 >=20 >=20 >=20 >=20 > -SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, >=20 > +SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit, >=20 > Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 > *unpackSize) >=20 > { >=20 > CLzmaEnc *p =3D (CLzmaEnc *)pp; >=20 > diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt > b/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt > index d7426d38a4..04f9d98e7d 100644 > --- a/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt > +++ b/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt > @@ -1,6 +1,28 @@ > HISTORY of the LZMA SDK >=20 > ----------------------- >=20 >=20 >=20 > +19.00 2019-02-21 >=20 > +------------------------- >=20 > +- Encryption strength for 7z archives was increased: >=20 > + the size of random initialization vector was increased from 64-bit = to > 128-bit, >=20 > + and the pseudo-random number generator was improved. >=20 > +- The bug in 7zIn.c code was fixed. >=20 > + >=20 > + >=20 > +18.06 2018-12-30 >=20 > +------------------------- >=20 > +- The speed for LZMA/LZMA2 compressing was increased by 3-10%, >=20 > + and there are minor changes in compression ratio. >=20 > +- Some bugs were fixed. >=20 > +- The bug in 7-Zip 18.02-18.05 was fixed: >=20 > + There was memory leak in multithreading xz decoder - > XzDecMt_Decode(), >=20 > + if xz stream contains only one block. >=20 > +- The changes for MSVS compiler makefiles: >=20 > + - the makefiles now use "PLATFORM" macroname with values (x64, = x86, > arm64) >=20 > + instead of "CPU" macroname with values (AMD64, ARM64). >=20 > + - the makefiles by default now use static version of the run-time library. >=20 > + >=20 > + >=20 > 18.05 2018-04-30 >=20 > ------------------------- >=20 > - The speed for LZMA/LZMA2 compressing was increased >=20 > diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-sdk.txt > b/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-sdk.txt > index a3deb20943..e17cd4fe1a 100644 > --- a/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-sdk.txt > +++ b/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-sdk.txt > @@ -1,4 +1,4 @@ > -LZMA SDK 18.05 >=20 > +LZMA SDK 19.00 >=20 > -------------- >=20 >=20 >=20 > LZMA SDK provides the documentation, samples, header files, >=20 > -- > 2.27.0.windows.1 =20 =20 =20 ------=_NextPart_000_0122_01D6D779.283847C0 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable

Do you verify = the boot functionality (boot to shell)? Do you collect the image size = (old LZMA version and new LZMA version)?

 

Thanks

Liming

=E5=8F=91=E4=BB=B6=E4=BA=BA: Liu, WeiX C = <weix.c.liu@intel.com>
=E5=8F=91=E9=80=81=E6=97=B6=E9=97= =B4: 2020=E5=B9=B412=E6=9C=8820=E6=97=A5 = 21:34
=E6=94=B6=E4=BB=B6=E4=BA=BA: gaoliming = <gaoliming@byosoft.com.cn>; = devel@edk2.groups.io
=E6=8A=84=E9=80=81: 'Laszlo Ersek' = <lersek@redhat.com>
=E4=B8=BB=E9=A2=98: RE: [PATCH 1/2] BaseTools = LzmaCompress: Update LZMA to new 19.00 = version

 

Hi liming,

 

I listed unittest result as below = with Ovmf build,  cause I have no apple machine so only list = VS=E3=80=81GCC and clang tool chain .

 

 

VS2019

GCC5

CLANGPDB

IA32

Pass

Pass

Pass

X64

Pass

Pass

Pass

IA32x64

Pass

Pass

Pass

 

 

-----Original = Message-----

From: gaoliming <gaoliming@byosoft.com.cn>=

Sent: = 2020=E5=B9=B412=E6=9C=8817=E6=97=A5 9:30

To: Liu, WeiX C <weix.c.liu@intel.com>; devel@edk2.groups.io<= /span>

Cc: 'Laszlo Ersek' = <lersek@redhat.com>

Subject: =E5=9B=9E=E5=A4=8D: [PATCH 1/2] BaseTools LzmaCompress: Update LZMA to new = 19.00 version

 

Wei:

  Can you list the unit test for this patch? Which = tool chain and arch have

been verified? =

 

  Because LZMA is well used, I request to verify it on = VS, GCC, XCODE and

CLANG tool chain for the different = ARCHs.

 

Thanks

Liming

> -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB= =B6-----

> =E5=8F=91=E4=BB=B6=E4=BA=BA: Wei Liu <weix.c.liu@intel.com>

> = =E5=8F=91=E9=80=81=E6=97=B6=E9=97= =B4: 2020=E5=B9=B412=E6=9C=8815=E6=97=A5 10:07

> =E6=94=B6=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io<= /span>

> =E6=8A=84=E9=80=81: Wei Liu <weix.c.liu@intel.com>; = Liming Gao

> <gaoliming@byosoft.com.cn>= ; Laszlo Ersek <lersek@redhat.com>

> =E4=B8=BB=E9=A2=98: [PATCH 1/2] BaseTools LzmaCompress: Update LZMA to new = 19.00

> version

>

> REF: https://bu= gzilla.tianocore.org/show_bug.cgi?id=3D3101

> New formal release in https://www.7-zip.org/sdk.html is 19.00.

>

> Cc: Liming Gao <gaoliming@byosoft.com.cn>=

> =

> = Cc: Laszlo Ersek <lersek@redhat.com>

> Signed-off-by: = Wei Liu <weix.c.liu@intel.com>

> = ---

>  = BaseTools/Source/C/LzmaCompress/LZMA-SDK-README.txt   &nbs= p;  |   4

> = ++--

>  = BaseTools/Source/C/LzmaCompress/LzmaCompress.c    &nb= sp;      |   = 8

> = ++++----

>  = BaseTools/Source/C/LzmaCompress/Sdk/C/7zTypes.h    &n= bsp;     |   5

> = +++--

>  = BaseTools/Source/C/LzmaCompress/Sdk/C/7zVersion.h    =     |   8

> = ++++----

>  = BaseTools/Source/C/LzmaCompress/Sdk/C/CpuArch.h    &n= bsp;     |   9

> = +++++----

>  = BaseTools/Source/C/LzmaCompress/Sdk/C/LzFind.c    &nb= sp;      | 164

> = ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=

> = +++++++++++++++++++++++++++++++++++++++++++++++++--------------------

> = ---------------------------------

>  = BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.c    &= nbsp;    | 117

> = ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=

> = +++++++++++++------------------------------------------=

>  = BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.h    &= nbsp;    |  14

> = +++++++-------

>  = BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c    &n= bsp;     |  32

> = ++++++++++++++++----------------

>  = BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c    &n= bsp;     | 733

> = ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=

> = ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=

> = ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=

> = ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=

> = ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=

> = ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=

> = ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=

> 

++++++++++++++++++++++++++----------------------------------= ----------------

----

> 

------------------------------------------------------------= ----------------

-----------------

> 

------------------------------------------------------------= ----------------

-----------------

> = ---------------------------------

>  = BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt |  = 22

> = ++++++++++++++++++++++

>  = BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-sdk.txt   &nb= sp; |   2 +-

>  12 files changed, 710 = insertions(+), 408 deletions(-)

>

> diff --git = a/BaseTools/Source/C/LzmaCompress/LZMA-SDK-README.txt

> = b/BaseTools/Source/C/LzmaCompress/LZMA-SDK-README.txt

> index = 7cf967a774..b2338e2598 100644

> --- = a/BaseTools/Source/C/LzmaCompress/LZMA-SDK-README.txt

> +++ = b/BaseTools/Source/C/LzmaCompress/LZMA-SDK-README.txt

> @@ -1,3 +1,3 = @@

> = -LzmaCompress is based on the LZMA SDK 18.05.  LZMA SDK = 18.05

>

> -was placed in the public domain on 2018-04-30.  = It was

>

> +LzmaCompress is based on the LZMA SDK 19.00.  = LZMA SDK 19.00

>

> +was placed in the public domain on 2019-02-21.  = It was

>

>  released on the http://www.7-zip.org/sdk.html = website.

>

> diff --git = a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c

> = b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c

> index = bebdb9aa84..bf4706ee23 100644

> --- = a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c

> +++ = b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c

> @@ -1,9 +1,9 = @@

>  /** @file

>

>    LZMA = Compress/Decompress tool (LzmaCompress)

>

>

>

> -  Based on LZMA SDK = 18.05:

>

> +  Based on LZMA SDK = 19.00:

>

>      LzmaUtil.c -- Test = application for LZMA compression

>

> -    = 2018-04-30 : Igor Pavlov : Public domain

>

> +    = 2019-02-21 : Igor Pavlov : Public domain

>

>

>

>    Copyright = (c) 2006 - 2019, Intel Corporation. All rights = reserved.<BR>

>

>    SPDX-License-Identifier: = BSD-2-Clause-Patent

>

> @@ -39,7 +39,7 @@ const char *kCantAllocateMessage =3D = "Can not allocate

> = memory";

>  const char *kDataErrorMessage =3D "Data = error";

>

>  const char *kInvalidParamValMessage =3D = "Invalid parameter value";

>

>

>

> -static Bool mQuietMode =3D = False;

>

> +static BoolInt mQuietMode =3D = False;

>

>  static CONVERTER_TYPE mConType =3D = NoConverter;

>

>

>

>  UINT64 mDictionarySize =3D = 28;

> =

> @@ = -244,7 +244,7 @@ int main2(int numArgs, const char *args[], char = *rs)

>    CFileOutStream = outStream;

>

>    int res;

>

>    int = encodeMode =3D 0;

>

> -  Bool modeWasSet =3D = False;

>

> +  BoolInt modeWasSet =3D = False;

>

>    const char *inputFile =3D = NULL;

>

>    const char *outputFile =3D = "file.tmp";

>

>    int param;

>

> diff --git = a/BaseTools/Source/C/LzmaCompress/Sdk/C/7zTypes.h

> = b/BaseTools/Source/C/LzmaCompress/Sdk/C/7zTypes.h

> index = 4977cdaa66..593f5aa259 100644

> --- = a/BaseTools/Source/C/LzmaCompress/Sdk/C/7zTypes.h

> +++ = b/BaseTools/Source/C/LzmaCompress/Sdk/C/7zTypes.h

> @@ -1,5 +1,5 = @@

>  /* 7zTypes.h -- Basic = types

>

> -2017-07-17 : Igor Pavlov : Public domain = */

> =

> = +2018-08-04 : Igor Pavlov : Public domain */

>

>

>

>  #ifndef = __7Z_TYPES_H

>

>  #define __7Z_TYPES_H

>

> @@ -103,7 +103,8 @@ typedef = UInt32 SizeT;

>  typedef size_t SizeT;

>

>  = #endif

>

>

>

> -typedef int Bool;

>

> +typedef int = BoolInt;

>

> +/* typedef BoolInt Bool; */

>

>  #define True = 1

> =

>  #define False 0

>

>

>

> diff --git = a/BaseTools/Source/C/LzmaCompress/Sdk/C/7zVersion.h

=

> = b/BaseTools/Source/C/LzmaCompress/Sdk/C/7zVersion.h

=

> index = ed3aa94270..0074c64be9 100644

> --- = a/BaseTools/Source/C/LzmaCompress/Sdk/C/7zVersion.h

=

> +++ = b/BaseTools/Source/C/LzmaCompress/Sdk/C/7zVersion.h

=

> @@ -1,7 +1,7 = @@

> = -#define MY_VER_MAJOR 18

>

> -#define MY_VER_MINOR = 05

> =

> = +#define MY_VER_MAJOR 19

>

> +#define MY_VER_MINOR = 00

> =

>  #define MY_VER_BUILD 0

>

> -#define MY_VERSION_NUMBERS = "18.05"

>

> +#define MY_VERSION_NUMBERS = "19.00"

>

>  #define MY_VERSION = MY_VERSION_NUMBERS

>

>

>

>  #ifdef MY_CPU_NAME

>

> @@ -10,7 +10,7 = @@

>    #define MY_VERSION_CPU = MY_VERSION

>

>  #endif

>

>

>

> -#define MY_DATE = "2018-04-30"

>

> +#define MY_DATE = "2019-02-21"

>

>  #undef = MY_COPYRIGHT

>

>  #undef = MY_VERSION_COPYRIGHT_DATE

>

>  #define = MY_AUTHOR_NAME "Igor Pavlov"

>

> diff --git = a/BaseTools/Source/C/LzmaCompress/Sdk/C/CpuArch.h

> = b/BaseTools/Source/C/LzmaCompress/Sdk/C/CpuArch.h

> index = 7fb27282c7..5f74c1c0cb 100644

> --- = a/BaseTools/Source/C/LzmaCompress/Sdk/C/CpuArch.h

> +++ = b/BaseTools/Source/C/LzmaCompress/Sdk/C/CpuArch.h

> @@ -1,5 +1,5 = @@

>  /* CpuArch.h -- CPU specific = code

>

> -2017-09-04 : Igor Pavlov : Public domain = */

> =

> = +2018-02-18 : Igor Pavlov : Public domain */

>

>

>

>  #ifndef = __CPU_ARCH_H

>

>  #define __CPU_ARCH_H

>

> @@ -318,15 +318,16 @@ = enum

>

>

>  void MyCPUID(UInt32 function, UInt32 *a, UInt32 = *b, UInt32 *c, UInt32

*d);

>

>

>

> -Bool x86cpuid_CheckAndRead(Cx86cpuid = *p);

>

> +BoolInt x86cpuid_CheckAndRead(Cx86cpuid = *p);

>

>  int x86cpuid_GetFirm(const Cx86cpuid = *p);

>

>

>

>  #define x86cpuid_GetFamily(ver) (((ver >> = 16) & 0xFF0) | ((ver >> 8) &

0xF))

>

>  #define = x86cpuid_GetModel(ver)  (((ver >> 12) &  0xF0) | = ((ver >> 4) &

> = 0xF))

>

>  #define x86cpuid_GetStepping(ver) (ver & = 0xF)

>

>

>

> -Bool CPU_Is_InOrder();

>

> -Bool = CPU_Is_Aes_Supported();

>

> +BoolInt = CPU_Is_InOrder();

>

> +BoolInt = CPU_Is_Aes_Supported();

>

> +BoolInt = CPU_IsSupported_PageGB();

>

>

>

>  = #endif

>

>

>

> diff --git = a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFind.c

> = b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFind.c

> index = 6ea82a9b53..4eefc17dd2 100644

> --- = a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFind.c

> +++ = b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFind.c

> @@ -1,5 +1,5 = @@

>  /* LzFind.c -- Match finder for LZ = algorithms

>

> -2017-06-10 : Igor Pavlov : Public domain = */

> =

> = +2018-07-08 : Igor Pavlov : Public domain */

>

>

>

>  #include = "Precomp.h"

>

>

>

> @@ -138,7 +138,7 @@ static = void

> MatchFinder_SetDefaultSettings(CMatchFinder = *p)

> =

> =

>  void MatchFinder_Construct(CMatchFinder = *p)

> =

>  {

>

> -  UInt32 = i;

> =

> = +  unsigned i;

>

>    p->bufferBase =3D = NULL;

>

>    p->directInput =3D = 0;

> =

>    p->hash =3D = NULL;

>

> @@ -147,7 +147,7 @@ void = MatchFinder_Construct(CMatchFinder *p)

>

>

>    for (i = =3D 0; i < 256; i++)

>

>    = {

> =

> = -    UInt32 r =3D i;

>

> +    UInt32 = r =3D (UInt32)i;

>

>      unsigned = j;

> =

>      for (j =3D 0; j < 8; = j++)

>

>        r =3D (r = >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & = 1)));

>

> @@ -368,6 +368,8 @@ static void = MatchFinder_Normalize(CMatchFinder *p)

>    = MatchFinder_ReduceOffsets(p, subValue);

>

>  = }

> =

> =

> =

> = +

> =

> = +MY_NO_INLINE

>

>  static void MatchFinder_CheckLimits(CMatchFinder = *p)

> =

>  {

>

>    if = (p->pos =3D=3D kMaxValForNormalize)

>

> @@ -379,10 +381,16 @@ = static void

> MatchFinder_CheckLimits(CMatchFinder = *p)

>    = MatchFinder_SetLimits(p);

>

>  = }

> =

> =

> =

> = -static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 = curMatch,

> UInt32 pos, const Byte *cur, CLzRef = *son,

>

> +

>

> +/*

>

> +  (lenLimit > maxLen)

>

> +*/

>

> = +MY_FORCE_INLINE

>

> +static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, = UInt32 curMatch,

> UInt32 pos, const Byte *cur, CLzRef = *son,

>

>      UInt32 _cyclicBufferPos, = UInt32 _cyclicBufferSize, UInt32 cutValue,

>

> -    UInt32 = *distances, UInt32 maxLen)

>

> +    UInt32 = *distances, unsigned maxLen)

>

>  = {

> =

> = +  /*

>

>    son[_cyclicBufferPos] =3D = curMatch;

>

>    for (;;)

>

>    = {

> =

> @@ = -400,7 +408,8 @@ static UInt32 * Hc_GetMatchesSpec(UInt32 = lenLimit,

> UInt32 curMatch, UInt32 pos,

>         &n= bsp;    break;

>

>          = if (maxLen < len)

>

>          = {

> =

> = -          *distances++ =3D = maxLen =3D len;

>

> = +          maxLen =3D = len;

>

> = +          *distances++ =3D = len;

>

>         &n= bsp;  *distances++ =3D delta - 1;

>

>         &n= bsp;  if (len =3D=3D lenLimit)

>

>         &n= bsp;    return distances;

>

> @@ -408,15 +417,58 @@ = static UInt32 * Hc_GetMatchesSpec(UInt32

> lenLimit, UInt32 curMatch, = UInt32 pos,

>        = }

> =

>      = }

> =

>    }

>

> +  = */

> =

> = +

> =

> = +  const Byte *lim =3D cur + lenLimit;

>

> +  = son[_cyclicBufferPos] =3D curMatch;

>

> +  = do

> =

> = +  {

>

> +    UInt32 delta =3D pos - = curMatch;

>

> +    if (delta >=3D = _cyclicBufferSize)

>

> +      = break;

>

> +    {

>

> = +      ptrdiff_t diff;

>

> = +      curMatch =3D son[_cyclicBufferPos - = delta + ((delta >

_cyclicBufferPos) ?

> _cyclicBufferSize : = 0)];

>

> +      diff =3D (ptrdiff_t)0 = - delta;

>

> +      if (cur[maxLen] =3D=3D = cur[maxLen + diff])

>

> +      = {

> =

> = +        const Byte *c =3D = cur;

>

> +        while (*c = =3D=3D c[diff])

>

> +        = {

> =

> = +          if (++c =3D=3D = lim)

>

> = +          = {

> =

> = +            = distances[0] =3D (UInt32)(lim - cur);

>

> = +            = distances[1] =3D delta - 1;

>

> = +            = return distances + 2;

>

> = +          = }

> =

> = +        }

>

> = +        {

>

> = +          unsigned len =3D = (unsigned)(c - cur);

>

> = +          if (maxLen < = len)

>

> = +          = {

> =

> = +            = maxLen =3D len;

>

> = +            = distances[0] =3D (UInt32)len;

>

> = +            = distances[1] =3D delta - 1;

>

> = +            = distances +=3D 2;

>

> = +          = }

> =

> = +        }

>

> = +      }

>

> +    = }

> =

> = +  }

>

> +  while (--cutValue);

>

> +

>

> +  return = distances;

>

>  }

>

>

>

> +

>

> = +MY_FORCE_INLINE

>

>  UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 = curMatch, UInt32 pos,

> const Byte *cur, CLzRef *son,

>

>      UInt32 _cyclicBufferPos, = UInt32 _cyclicBufferSize, UInt32 cutValue,

>

>      UInt32 *distances, = UInt32 maxLen)

>

>  {

>

> -  CLzRef *ptr0 =3D = son + (_cyclicBufferPos << 1) + 1;

>

> -  CLzRef *ptr1 =3D = son + (_cyclicBufferPos << 1);

>

> -  UInt32 len0 =3D 0, = len1 =3D 0;

>

> +  CLzRef *ptr0 =3D son + = ((size_t)_cyclicBufferPos << 1) + 1;

>

> +  CLzRef *ptr1 =3D = son + ((size_t)_cyclicBufferPos << 1);

>

> +  unsigned len0 =3D = 0, len1 =3D 0;

>

>    for (;;)

>

>    = {

> =

>      UInt32 delta =3D pos - = curMatch;

>

> @@ -426,9 +478,10 @@ UInt32 * GetMatchesSpec1(UInt32 = lenLimit, UInt32

> curMatch, UInt32 pos, const = Byt

>        return = distances;

>

>      = }

> =

>      = {

> =

> = -      CLzRef *pair =3D son + = ((_cyclicBufferPos - delta + ((delta >

> _cyclicBufferPos) ? = _cyclicBufferSize : 0)) << 1);

>

> = +      CLzRef *pair =3D son + = ((size_t)(_cyclicBufferPos - delta + ((delta = >

> _cyclicBufferPos) ? _cyclicBufferSize : 0)) << = 1);

> =

>        const Byte = *pb =3D cur - delta;

>

> -      UInt32 len =3D (len0 = < len1 ? len0 : len1);

>

> = +      unsigned len =3D (len0 < len1 ? len0 = : len1);

>

> +      UInt32 pair0 =3D = pair[0];

>

>        if (pb[len] = =3D=3D cur[len])

>

>        = {

> =

>          = if (++len !=3D lenLimit && pb[len] =3D=3D = cur[len])

>

> @@ -437,11 +490,12 @@ UInt32 * GetMatchesSpec1(UInt32 = lenLimit,

> UInt32 curMatch, UInt32 pos, const = Byt

>         &n= bsp;      break;

>

>          = if (maxLen < len)

>

>          = {

> =

> = -          *distances++ =3D = maxLen =3D len;

>

> = +          maxLen =3D = (UInt32)len;

>

> = +          *distances++ =3D = (UInt32)len;

>

>         &n= bsp;  *distances++ =3D delta - 1;

>

>         &n= bsp;  if (len =3D=3D lenLimit)

>

> =            {<= /o:p>

> =

> = -            = *ptr1 =3D pair[0];

>

> = +            = *ptr1 =3D pair0;

>

>         &n= bsp;    *ptr0 =3D pair[1];

>

>         &n= bsp;    return distances;

>

>         &n= bsp;  }

>

> @@ -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,

>

>      UInt32 _cyclicBufferPos, = UInt32 _cyclicBufferSize, UInt32 cutValue)

>

>  = {

> =

> = -  CLzRef *ptr0 =3D son + (_cyclicBufferPos << 1) + = 1;

> =

> = -  CLzRef *ptr1 =3D son + (_cyclicBufferPos << = 1);

> =

> = -  UInt32 len0 =3D 0, len1 =3D 0;

>

> +  CLzRef *ptr0 =3D = son + ((size_t)_cyclicBufferPos << 1) + 1;

>

> +  CLzRef *ptr1 =3D = son + ((size_t)_cyclicBufferPos << 1);

>

> +  unsigned len0 =3D = 0, len1 =3D 0;

>

>    for (;;)

>

>    = {

> =

>      UInt32 delta =3D pos - = curMatch;

>

> @@ -480,9 +534,9 @@ static void SkipMatchesSpec(UInt32 = lenLimit, UInt32

> curMatch, UInt32 pos, const

>        = return;

>

>      = }

> =

>      = {

> =

> = -      CLzRef *pair =3D son + = ((_cyclicBufferPos - delta + ((delta >

> _cyclicBufferPos) ? = _cyclicBufferSize : 0)) << 1);

>

> = +      CLzRef *pair =3D son + = ((size_t)(_cyclicBufferPos - delta + ((delta = >

> _cyclicBufferPos) ? _cyclicBufferSize : 0)) << = 1);

> =

>        const Byte = *pb =3D cur - delta;

>

> -      UInt32 len =3D (len0 = < len1 ? len0 : len1);

>

> = +      unsigned len =3D (len0 < len1 ? len0 = : len1);

>

>        if (pb[len] = =3D=3D cur[len])

>

>        = {

> =

>          = while (++len !=3D lenLimit)

>

> @@ -520,13 +574,13 @@ = static void SkipMatchesSpec(UInt32 lenLimit,

> UInt32 curMatch, UInt32 = pos, const

>    p->buffer++; = \

> =

>    if (++p->pos =3D=3D = p->posLimit) MatchFinder_CheckLimits(p);

>

>

>

> -#define MOVE_POS_RET = MOVE_POS return offset;

>

> +#define MOVE_POS_RET = MOVE_POS return (UInt32)offset;

>

>

>

>  static void = MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; = }

> =

> =

> =

>  #define GET_MATCHES_HEADER2(minLen, ret_op) = \

> =

> = -  UInt32 lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; = \

> =

> = -  lenLimit =3D p->lenLimit; { if (lenLimit < minLen) = {

MatchFinder_MovePos(p);

> ret_op; }} = \

> =

> = +  unsigned lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; = \

> =

> = +  lenLimit =3D (unsigned)p->lenLimit; { if (lenLimit < = minLen)

> { MatchFinder_MovePos(p); ret_op; }} = \

> =

>    cur =3D = p->buffer;

>

>

>

>  #define GET_MATCHES_HEADER(minLen) = GET_MATCHES_HEADER2(minLen,

> return = 0)

> =

> @@ = -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

>

>

>

>  #define GET_MATCHES_FOOTER(offset, maxLen) = \

> =

> = -  offset =3D (UInt32)(GetMatchesSpec1(lenLimit, curMatch, = MF_PARAMS(p), \

>

> -  distances + offset, maxLen) - distances); = MOVE_POS_RET;

>

> +  offset =3D = (unsigned)(GetMatchesSpec1((UInt32)lenLimit, = curMatch,

> MF_PARAMS(p), \

>

> +  distances + offset, = (UInt32)maxLen) - distances); MOVE_POS_RET;

>

>

>

>  #define SKIP_FOOTER = \

> =

> = -  SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); = MOVE_POS;

>

> +  SkipMatchesSpec((UInt32)lenLimit, curMatch, = MF_PARAMS(p));

> MOVE_POS;

>

>

>

>  #define UPDATE_maxLen = { \

> =

>      ptrdiff_t diff =3D = (ptrdiff_t)0 - d2; \

>

>      const Byte *c =3D cur + = maxLen; \

>

>      const Byte *lim =3D cur = + lenLimit; \

>

>      for (; c !=3D lim; c++) = if (*(c + diff) !=3D *c) break; \

>

> -    maxLen = =3D (UInt32)(c - cur); }

>

> +    maxLen = =3D (unsigned)(c - cur); }

>

>

>

>  static UInt32 = Bt2_MatchFinder_GetMatches(CMatchFinder *p, = UInt32

> *distances)

>

>  = {

> =

> = -  UInt32 offset;

>

> +  unsigned = offset;

>

>    = GET_MATCHES_HEADER(2)

>

>    HASH2_CALC;

>

>    curMatch = =3D p->hash[hv];

>

> @@ -561,7 +615,7 @@ static = UInt32

> Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 = *distances)

>

>

>  UInt32 = Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, = UInt32

> *distances)

>

>  = {

> =

> = -  UInt32 offset;

>

> +  unsigned = offset;

>

>    = GET_MATCHES_HEADER(3)

>

>    = HASH_ZIP_CALC;

>

>    curMatch =3D = p->hash[hv];

>

> @@ -572,7 +626,8 @@ UInt32

> = Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 = *distances)

>

>

>  static UInt32 = Bt3_MatchFinder_GetMatches(CMatchFinder *p, = UInt32

> *distances)

>

>  = {

> =

> = -  UInt32 h2, d2, maxLen, offset, pos;

>

> +  UInt32 h2, d2, = pos;

>

> +  unsigned maxLen, = offset;

>

>    UInt32 = *hash;

>

>    = GET_MATCHES_HEADER(3)

>

>

>

> @@ -594,12 +649,12 @@ static = UInt32

> Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 = *distances)

>    if (d2 < p->cyclicBufferSize = && *(cur - d2) =3D=3D *cur)

>

>    = {

> =

>      = UPDATE_maxLen

>

> -    distances[0] =3D = maxLen;

>

> +    distances[0] =3D = (UInt32)maxLen;

>

>      distances[1] =3D d2 - = 1;

> =

>      offset =3D = 2;

> =

>      if (maxLen =3D=3D = lenLimit)

>

>      = {

> =

> = -      SkipMatchesSpec(lenLimit, curMatch, = MF_PARAMS(p));

>

> +      = SkipMatchesSpec((UInt32)lenLimit, curMatch, = MF_PARAMS(p));

>

>        = MOVE_POS_RET;

>

>      = }

> =

>    }

>

> @@ -609,7 +664,8 @@ static = UInt32

> Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 = *distances)

>

>

>  static UInt32 = Bt4_MatchFinder_GetMatches(CMatchFinder *p, = UInt32

> *distances)

>

>  = {

> =

> = -  UInt32 h2, h3, d2, d3, maxLen, offset, = pos;

>

> +  UInt32 h2, h3, d2, d3, = pos;

>

> +  unsigned maxLen, = offset;

>

>    UInt32 = *hash;

>

>    = GET_MATCHES_HEADER(4)

>

>

>

> @@ -618,12 +674,12 @@ static = UInt32

> Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 = *distances)

>    hash =3D = p->hash;

>

>    pos =3D = p->pos;

>

>

>

> -  d2 =3D pos - = hash[           &n= bsp;    h2];

>

> +  d2 =3D pos - = hash           &nb= sp;      [h2];

>

>    d3 =3D = pos - (hash + kFix3HashSize)[h3];

>

>

>

>    curMatch = =3D (hash + kFix4HashSize)[hv];

>

>

>

> -  = hash[           &n= bsp;    h2] =3D pos;

>

> +  = hash           &nb= sp;      [h2] =3D pos;

>

>    (hash + = kFix3HashSize)[h3] =3D pos;

>

>    (hash + = kFix4HashSize)[hv] =3D pos;

>

>

>

> @@ -632,7 +688,8 @@ static = UInt32

> Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 = *distances)

>

>

>    if (d2 < p->cyclicBufferSize = && *(cur - d2) =3D=3D *cur)

>

>    = {

> =

> = -    distances[0] =3D maxLen =3D = 2;

> =

> = +    maxLen =3D 2;

>

> +    = distances[0] =3D 2;

>

>      distances[1] =3D d2 - = 1;

> =

>      offset =3D = 2;

> =

>    }

>

> @@ -648,10 +705,10 @@ = static UInt32

> Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 = *distances)

>    if (offset !=3D = 0)

> =

>    {

>

>      = UPDATE_maxLen

>

> -    distances[(size_t)offset - 2] =3D = maxLen;

>

> +    distances[(size_t)offset - 2] =3D = (UInt32)maxLen;

>

>      if (maxLen =3D=3D = lenLimit)

>

>      = {

> =

> = -      SkipMatchesSpec(lenLimit, curMatch, = MF_PARAMS(p));

>

> +      = SkipMatchesSpec((UInt32)lenLimit, curMatch, = MF_PARAMS(p));

>

>        = MOVE_POS_RET;

>

>      = }

> =

>    }

>

> @@ -674,13 +731,13 @@ = static UInt32

> Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 = *distances)

>    hash =3D = p->hash;

>

>    pos =3D = p->pos;

>

>

>

> -  d2 =3D pos - = hash[           &n= bsp;    h2];

>

> +  d2 =3D pos - = hash           &nb= sp;      [h2];

>

>    d3 =3D = pos - (hash + kFix3HashSize)[h3];

>

>    d4 =3D = pos - (hash + kFix4HashSize)[h4];

>

>

>

>    curMatch = =3D (hash + kFix5HashSize)[hv];

>

>

>

> -  = hash[           &n= bsp;    h2] =3D pos;

>

> +  = hash           &nb= sp;      [h2] =3D pos;

>

>    (hash + = kFix3HashSize)[h3] =3D pos;

>

>    (hash + = kFix4HashSize)[h4] =3D pos;

>

>    (hash + = kFix5HashSize)[hv] =3D pos;

>

> @@ -741,7 +798,8 @@ static = UInt32

> Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 = *distances)

>

>

>  static UInt32 = Hc4_MatchFinder_GetMatches(CMatchFinder *p, = UInt32

> *distances)

>

>  = {

> =

> = -  UInt32 h2, h3, d2, d3, maxLen, offset, = pos;

>

> +  UInt32 h2, h3, d2, d3, = pos;

>

> +  unsigned maxLen, = offset;

>

>    UInt32 = *hash;

>

>    = GET_MATCHES_HEADER(4)

>

>

>

> @@ -750,12 +808,11 @@ static = UInt32

> Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 = *distances)

>    hash =3D = p->hash;

>

>    pos =3D = p->pos;

>

>

>

> -  d2 =3D pos - = hash[           &n= bsp;    h2];

>

> +  d2 =3D pos - = hash           &nb= sp;      [h2];

>

>    d3 =3D = pos - (hash + kFix3HashSize)[h3];

>

> -

>

>    curMatch = =3D (hash + kFix4HashSize)[hv];

>

>

>

> -  = hash[           &n= bsp;    h2] =3D pos;

>

> +  = hash        =           [h2] =3D = pos;

>

>    (hash + kFix3HashSize)[h3] =3D = pos;

>

>    (hash + kFix4HashSize)[hv] =3D = pos;

>

>

>

> @@ -764,7 +821,8 @@ static = UInt32

> Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 = *distances)

>

>

>    if (d2 < p->cyclicBufferSize = && *(cur - d2) =3D=3D *cur)

>

>    = {

> =

> = -    distances[0] =3D maxLen =3D = 2;

> =

> = +    maxLen =3D 2;

>

> +    = distances[0] =3D 2;

>

>      distances[1] =3D d2 - = 1;

> =

>      offset =3D = 2;

> =

>    }

>

> @@ -780,7 +838,7 @@ static = UInt32

> Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 = *distances)

>    if (offset !=3D = 0)

> =

>    {

>

>      = UPDATE_maxLen

>

> -    distances[(size_t)offset - 2] =3D = maxLen;

>

> +    distances[(size_t)offset - 2] =3D = (UInt32)maxLen;

>

>      if (maxLen =3D=3D = lenLimit)

>

>      = {

> =

>        = p->son[p->cyclicBufferPos] =3D curMatch;

>

> @@ -791,7 +849,7 @@ static = UInt32

> Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 = *distances)

>    if (maxLen < = 3)

> =

>      maxLen =3D = 3;

> =

> =

> =

> = -  offset =3D (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, = MF_PARAMS(p),

>

> +  offset =3D = (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch,

> = MF_PARAMS(p),

>

>        distances + = offset, maxLen) - (distances));

>

>    = MOVE_POS_RET

>

>  }

>

> @@ -808,13 +866,13 @@ = static UInt32

> Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 = *distances)

>    hash =3D = p->hash;

>

>    pos =3D = p->pos;

>

>

>

> -  d2 =3D pos - = hash[           &n= bsp;    h2];

>

> +  d2 =3D pos - = hash           &nb= sp;      [h2];

>

>    d3 =3D = pos - (hash + kFix3HashSize)[h3];

>

>    d4 =3D = pos - (hash + kFix4HashSize)[h4];

>

>

>

>    curMatch = =3D (hash + kFix5HashSize)[hv];

>

>

>

> -  = hash[           &n= bsp;    h2] =3D pos;

>

> +  = hash       =            [h2] = =3D pos;

>

>    (hash + kFix3HashSize)[h3] =3D = pos;

>

>    (hash + kFix4HashSize)[h4] =3D = pos;

>

>    (hash + kFix5HashSize)[hv] =3D = pos;

>

> @@ -877,12 +935,12 @@ static = UInt32

> Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 = *distances)

>

>

>  UInt32 = Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, = UInt32

> *distances)

>

>  = {

> =

> = -  UInt32 offset;

>

> +  unsigned = offset;

>

>    = GET_MATCHES_HEADER(3)

>

>    = HASH_ZIP_CALC;

>

>    curMatch =3D = p->hash[hv];

>

>    p->hash[hv] =3D = p->pos;

>

> -  offset =3D = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, = MF_PARAMS(p),

>

> +  offset =3D = (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch,

> = MF_PARAMS(p),

>

>        distances, = 2) - (distances));

>

>    MOVE_POS_RET

>

>  = }

> =

> @@ = -940,7 +998,7 @@ static void Bt4_MatchFinder_Skip(CMatchFinder = *p,

> = UInt32 num)

>      = HASH4_CALC;

>

>      hash =3D = p->hash;

>

>      curMatch =3D (hash + = kFix4HashSize)[hv];

>

> -    = hash[           &n= bsp;    h2] =3D

>

> +    = hash           &nb= sp;      [h2] =3D

>

>      (hash + = kFix3HashSize)[h3] =3D

>

>      (hash + = kFix4HashSize)[hv] =3D p->pos;

>

>      = SKIP_FOOTER

>

> @@ -959,7 +1017,7 @@ static void = Bt5_MatchFinder_Skip(CMatchFinder *p,

> UInt32 = num)

>      = HASH5_CALC;

>

>      hash =3D = p->hash;

>

>      curMatch =3D (hash + = kFix5HashSize)[hv];

>

> -    = hash[           &n= bsp;    h2] =3D

>

> +    = hash           &nb= sp;      [h2] =3D

>

>      (hash + = kFix3HashSize)[h3] =3D

>

>      (hash + = kFix4HashSize)[h4] =3D

>

>      (hash + = kFix5HashSize)[hv] =3D p->pos;

>

> @@ -979,7 +1037,7 @@ static = void Hc4_MatchFinder_Skip(CMatchFinder *p,

> UInt32 = num)

>    =   HASH4_CALC;

>

>      hash =3D = p->hash;

>

>      curMatch =3D (hash + = kFix4HashSize)[hv];

>

> -    = hash[           &n= bsp;    h2] =3D

>

> +    = hash           &nb= sp;      [h2] =3D

>

>      (hash + = kFix3HashSize)[h3] =3D

>

>      (hash + = kFix4HashSize)[hv] =3D p->pos;

>

> =      p->son[p->cyclicBufferPos] =3D = curMatch;

>

> @@ -999,7 +1057,7 @@ static void = Hc5_MatchFinder_Skip(CMatchFinder *p,

> UInt32 = num)

>      = HASH5_CALC;

>

>      hash =3D = p->hash;

>

>      curMatch =3D hash + = kFix5HashSize)[hv];

>

> -    = hash[           &n= bsp;    h2] =3D

>

> +    = hash           &nb= sp;      [h2] =3D

>

>      (hash + = kFix3HashSize)[h3] =3D

>

>      (hash + = kFix4HashSize)[h4] =3D

>

>      (hash + = kFix5HashSize)[hv] =3D p->pos;

>

> diff --git = a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.c

<= p class=3DMsoPlainText>> = b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.c

<= p class=3DMsoPlainText>> index = 2563824fcd..df32146f92 100644

> --- = a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.c

<= p class=3DMsoPlainText>> +++ = b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.c

<= p class=3DMsoPlainText>> @@ -1,5 +1,5 = @@

>  /* LzFindMt.c -- multithreaded Match finder for = LZ algorithms

>

> -2017-06-10 : Igor Pavlov : Public domain = */

> =

> = +2018-12-29 : Igor Pavlov : Public domain */

>

>

>

>  #include = "Precomp.h"

>

>

>

> @@ -232,38 +232,57 @@ static = void

> MatchFinderMt_GetNextBlock_Hash(CMatchFinderMt = *p)

> =

> =

>  #define kEmptyHashValue = 0

> =

> =

> =

> = -/* #define MFMT_GM_INLINE */

>

> +#define = MFMT_GM_INLINE

>

>

>

>  #ifdef MFMT_GM_INLINE

>

>

>

> -#define NO_INLINE = MY_FAST_CALL

>

> +/*

>

> +  we use size_t for _cyclicBufferPos instead of = UInt32

>

> +  to eliminate "movsx" BUG in old MSVC = x64 compiler.

>

> +*/

>

>

>

> -static Int32 NO_INLINE GetMatchesSpecN(UInt32 = lenLimit, UInt32 pos,

> const Byte *cur, CLzRef *son,

>

> -    UInt32 = _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 = _cutValue,

>

> -    UInt32 *_distances, UInt32 = _maxLen, const UInt32 *hash, Int32 limit,

> UInt32 size, UInt32 = *posRes)

>

> +MY_NO_INLINE

>

> +static UInt32 = *GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const = Byte

> *cur, CLzRef *son,

>

> +    size_t = _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 = _cutValue,

>

> +    UInt32 *distances, UInt32 _maxLen, = const UInt32 *hash, const UInt32

> *limit, UInt32 size, UInt32 = *posRes)

>

>  {

>

>    = do

> =

>    {

>

> -  UInt32 *distances = =3D _distances + 1;

>

> -  UInt32 curMatch =3D pos - = *hash++;

>

> +  UInt32 *_distances =3D = ++distances;

>

> +  UInt32 delta =3D = *hash++;

>

>

>

> -  CLzRef *ptr0 =3D son + (_cyclicBufferPos = << 1) + 1;

>

> -  CLzRef *ptr1 =3D son + (_cyclicBufferPos = << 1);

>

> -  UInt32 len0 =3D 0, len1 =3D = 0;

> =

> = +  CLzRef *ptr0 =3D son + ((size_t)_cyclicBufferPos << 1) + = 1;

> =

> = +  CLzRef *ptr1 =3D son + ((size_t)_cyclicBufferPos << = 1);

> =

> = +  unsigned len0 =3D 0, len1 =3D 0;

>

>    UInt32 = cutValue =3D _cutValue;

>

> -  UInt32 maxLen =3D = _maxLen;

>

> -  for (;;)

>

> +  unsigned maxLen =3D = (unsigned)_maxLen;

>

> +

>

> +  /*

>

> +  if (size > = 1)

> =

>    {

>

> -    UInt32 = delta =3D pos - curMatch;

>

> -    if = (cutValue-- =3D=3D 0 || delta >=3D = _cyclicBufferSize)

>

> +    UInt32 delta =3D = *hash;

>

> +    if (delta < = _cyclicBufferSize)

>

>      = {

> =

> = -      *ptr0 =3D *ptr1 =3D = kEmptyHashValue;

>

> -      = break;

>

> +      UInt32 cyc1 =3D = _cyclicBufferPos + 1;

>

> +      CLzRef *pair =3D son + = ((size_t)(cyc1 - delta + ((delta > cyc1) ?

> _cyclicBufferSize : 0)) = << 1);

>

> +      Byte b =3D *(cur + 1 - = delta);

>

> +      _distances[0] =3D = pair[0];

>

> +      _distances[1] =3D = b;

> =

>      = }

> =

> = +  }

>

> +  */

>

> +  if (cutValue =3D=3D = 0 || delta >=3D _cyclicBufferSize)

>

> +  = {

> =

> = +    *ptr0 =3D *ptr1 =3D = kEmptyHashValue;

>

> +  }

>

> +  = else

>

> +  for(;;)

>

> +  = {

> =

>      = {

> =

> = -      CLzRef *pair =3D son + = ((_cyclicBufferPos - delta + ((delta >

> _cyclicBufferPos) ? = _cyclicBufferSize : 0)) << 1);

>

> = +      CLzRef *pair =3D son + = ((size_t)(_cyclicBufferPos - delta +

> ((_cyclicBufferPos < = delta) ? _cyclicBufferSize : 0)) << 1);

>

>        const Byte = *pb =3D cur - delta;

>

> -      UInt32 len =3D (len0 = < len1 ? len0 : len1);

>

> = +      unsigned len =3D (len0 < len1 ? len0 = : len1);

>

> +      UInt32 pair0 =3D = *pair;

>

>        if (pb[len] = =3D=3D cur[len])

>

>        = {

> =

>          = if (++len !=3D lenLimit && pb[len] =3D=3D = cur[len])

>

> @@ -272,54 +291,66 @@ static Int32 NO_INLINE = GetMatchesSpecN(UInt32

> lenLimit, UInt32 pos, const = Byte *

>         &n= bsp;      break;

>

>          = if (maxLen < len)

>

>          = {

> =

> = -          *distances++ =3D = maxLen =3D len;

>

> = +          maxLen =3D = len;

>

> = +          *distances++ =3D = (UInt32)len;

>

>         &n= bsp;  *distances++ =3D delta - 1;

>

>         &n= bsp;  if (len =3D=3D lenLimit)

>

>         &n= bsp;  {

>

> = -            = *ptr1 =3D pair[0];

>

> = -            = *ptr0 =3D pair[1];

>

> = +            = UInt32 pair1 =3D pair[1];

>

> = +            = *ptr1 =3D pair0;

>

> = +            = *ptr0 =3D pair1;

>

>         &n= bsp;    break;

>

>         &n= bsp;  }

>

>          = }

> =

>        = }

> =

> = -      if (pb[len] < = cur[len])

>

> -      = {

> =

> = -        *ptr1 =3D = curMatch;

>

> -        ptr1 =3D = pair + 1;

>

> -        curMatch = =3D *ptr1;

>

> -        len1 =3D = len;

>

> -      = }

> =

> = -      else

>

>        = {

> =

> = -        *ptr0 =3D = curMatch;

>

> -        ptr0 =3D = pair;

>

> -        curMatch = =3D *ptr0;

>

> -        len0 =3D = len;

>

> +        UInt32 = curMatch =3D pos - delta;

>

> = +        // delta =3D pos - = *pair;

>

> +        // delta = =3D pos - pair[((UInt32)pb[len] - (UInt32)cur[len]) = >>

31];

>

> +        if = (pb[len] < cur[len])

>

> = +        {

>

> = +          delta =3D pos - = pair[1];

>

> = +          *ptr1 =3D = curMatch;

>

> = +          ptr1 =3D pair + = 1;

> =

> = +          len1 =3D = len;

>

> +        = }

> =

> = +        else

>

> = +        {

>

> = +          delta =3D pos - = *pair;

>

> = +          *ptr0 =3D = curMatch;

>

> = +          ptr0 =3D = pair;

>

> = +          len0 =3D = len;

>

> +        = }

> =

>        = }

> =

>      = }

> =

> = +    if (--cutValue =3D=3D 0 || delta >=3D = _cyclicBufferSize)

>

> +    {

>

> = +      *ptr0 =3D *ptr1 =3D = kEmptyHashValue;

>

> +      = break;

>

> +    }

>

>    = }

> =

>    pos++;

>

>    = _cyclicBufferPos++;

>

>    cur++;

>

>    = {

> =

>      UInt32 num =3D = (UInt32)(distances - _distances);

>

> -    = *_distances =3D num - 1;

>

> -    = _distances +=3D num;

>

> -    limit -=3D = num;

>

> +    _distances[-1] =3D = num;

>

>    }

>

>    = }

> =

> = -  while (limit > 0 && --size !=3D = 0);

> =

> = +  while (distances < limit && --size !=3D = 0);

> =

>    *posRes =3D = pos;

>

> -  return limit;

>

> +  return = distances;

>

>  }

>

>

>

>  = #endif

>

>

>

> +

>

> +

>

>  static void BtGetMatches(CMatchFinderMt *p, = UInt32 *distances)

>

>  {

>

>    UInt32 = numProcessed =3D 0;

>

>    UInt32 curPos =3D = 2;

> =

> = -  UInt32 limit =3D kMtBtBlockSize - (p->matchMaxLen * = 2);

> =

> = +  UInt32 limit =3D kMtBtBlockSize - (p->matchMaxLen * 2); = //  * 2

>

>

>

>    distances[1] =3D = p->hashNumAvail;

>

>

>

> @@ -369,8 +400,10 @@ static void = BtGetMatches(CMatchFinderMt *p,

> UInt32 = *distances)

>        = #else

>

>        = {

> =

>          = UInt32 posRes;

>

> -        curPos =3D = limit - GetMatchesSpecN(lenLimit, pos, = p->buffer,

p->son,

> cyclicBufferPos, = p->cyclicBufferSize, p->cutValue,

>

> = -            = distances + curPos, p->numHashBytes - 1, p->hashBuf = +

> = p->hashBufPos, (Int32)(limit - curPos), size, = &posRes);

>

> +        curPos =3D = (UInt32)(GetMatchesSpecN(lenLimit, pos, = p->buffer,

> p->son, cyclicBufferPos, p->cyclicBufferSize, = p->cutValue,

>

> = +            = distances + curPos, p->numHashBytes - 1, p->hashBuf = +

> = p->hashBufPos,

>

> = +            = distances + limit,

>

> = +            = size, &posRes) - distances);

>

>          = p->hashBufPos +=3D posRes - pos;

>

>          = cyclicBufferPos +=3D posRes - pos;

>

>          = p->buffer +=3D posRes - pos;

>

> diff --git = a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.h

<= p class=3DMsoPlainText>> = b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.h

<= p class=3DMsoPlainText>> index = 3d86c788f3..fdd17008c2 100644

> --- = a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.h

<= p class=3DMsoPlainText>> +++ = b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.h

<= p class=3DMsoPlainText>> @@ -1,5 +1,5 = @@

>  /* LzFindMt.h -- multithreaded Match finder for = LZ algorithms

>

> -2017-04-03 : Igor Pavlov : Public domain = */

> =

> = +2018-07-04 : Igor Pavlov : Public domain */

>

>

>

>  #ifndef = __LZ_FIND_MT_H

>

>  #define __LZ_FIND_MT_H

>

> @@ -19,10 +19,10 @@ = EXTERN_C_BEGIN

>

>

>  typedef struct _CMtSync

>

>  = {

> =

> = -  Bool wasCreated;

>

> -  Bool = needStart;

>

> -  Bool exit;

>

> -  Bool = stopWriting;

>

> +  BoolInt wasCreated;

>

> +  BoolInt = needStart;

>

> +  BoolInt exit;

>

> +  BoolInt = stopWriting;

>

>

>

>    CThread = thread;

>

>    CAutoResetEvent = canStart;

>

> @@ -30,8 +30,8 @@ typedef struct = _CMtSync

>    CAutoResetEvent = wasStopped;

>

>    CSemaphore = freeSemaphore;

>

>    CSemaphore = filledSemaphore;

>

> -  Bool csWasInitialized;

>

> -  Bool = csWasEntered;

>

> +  BoolInt = csWasInitialized;

>

> +  BoolInt csWasEntered;

>

>    = CCriticalSection cs;

>

>    UInt32 = numProcessedBlocks;

>

>  } CMtSync;

>

> diff --git = a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c

> = b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c

> index = 962b94bb63..4d1576419f 100644

> --- = a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c

> +++ = b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c

> @@ -1,13 +1,13 = @@

>  /* LzmaDec.c -- LZMA = Decoder

>

> -2018-02-28 : Igor Pavlov : Public domain = */

> =

> = +2018-07-04 : Igor Pavlov : Public domain */

>

>

>

>  #include = "Precomp.h"

>

>

>

> +#include <string.h>

>

> +

>

>  /* #include = "CpuArch.h" */

>

>  #include = "LzmaDec.h"

>

>

>

> -#include <string.h>

>

> -

>

>  #define kNumTopBits = 24

> =

>  #define kTopValue ((UInt32)1 << = kNumTopBits)

>

>

>

> @@ -19,7 +19,7 @@

>

>

>  #define NORMALIZE if = (range < kTopValue) { range <<=3D 8; code =3D (code = <<

8)

> | (*buf++); }

>

>

>

> -#define IF_BIT_0(p) ttt = =3D *(p); NORMALIZE; bound =3D (range >>

> kNumBitModelTotalBits) * = ttt; if (code < bound)

>

> +#define IF_BIT_0(p) ttt = =3D *(p); NORMALIZE; bound =3D (range >>

> kNumBitModelTotalBits) * = (UInt32)ttt; if (code < bound)

>

>  #define UPDATE_0(p) = range =3D bound; *(p) =3D (CLzmaProb)(ttt +

> ((kBitModelTotal - ttt) = >> kNumMoveBits));

>

>  #define UPDATE_1(p) = range -=3D bound; code -=3D bound; *(p) =3D = (CLzmaProb)(ttt

> - (ttt >> = kNumMoveBits));

>

>  #define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) = \

> =

> @@ = -66,7 +66,7 @@

>

>

>  #define NORMALIZE_CHECK if (range < = kTopValue) { if (buf >=3D bufLimit)

> return DUMMY_ERROR; range = <<=3D 8; code =3D (code << 8) | (*buf++); = }

> =

> =

> =

> = -#define IF_BIT_0_CHECK(p) ttt =3D *(p); NORMALIZE_CHECK; bound =3D = (range >>

> kNumBitModelTotalBits) * ttt; if (code < = bound)

>

> +#define IF_BIT_0_CHECK(p) ttt =3D *(p); = NORMALIZE_CHECK; bound =3D (range >>

> kNumBitModelTotalBits) * = (UInt32)ttt; if (code < bound)

>

>  #define = UPDATE_0_CHECK range =3D bound;

>

>  #define = UPDATE_1_CHECK range -=3D bound; code -=3D = bound;

>

>  #define GET_BIT2_CHECK(p, i, A0, A1) = IF_BIT_0_CHECK(p) \

>

> @@ -539,7 +539,7 @@ int MY_FAST_CALL = LZMA_DECODE_REAL(CLzmaDec

> *p, SizeT limit, const Byte = *bufLimit

>          = curLen =3D ((rem < len) ? (unsigned)rem : = len);

>

>          = pos =3D dicPos - rep0 + (dicPos < rep0 ? dicBufSize : = 0);

> =

> =

> =

> = -        processedPos +=3D = curLen;

>

> +        = processedPos +=3D (UInt32)curLen;

>

>

>

>          = len -=3D curLen;

>

>          = if (curLen <=3D dicBufSize - pos)

>

> @@ -547,7 +547,7 @@ int = MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec

> *p, SizeT limit, const Byte = *bufLimit

>         &n= bsp;  Byte *dest =3D dic + dicPos;

>

>         &n= bsp;  ptrdiff_t src =3D (ptrdiff_t)pos - = (ptrdiff_t)dicPos;

>

>         &n= bsp;  const Byte *lim =3D dest + curLen;

>

> = -          dicPos +=3D = curLen;

>

> = +          dicPos +=3D = (SizeT)curLen;

>

>         &n= bsp;  do

>

>         &n= bsp;    *(dest) =3D (Byte)*(dest + = src);

>

>         &n= bsp;  while (++dest !=3D lim);

>

> @@ -572,14 +572,14 @@ int = MY_FAST_CALL

> LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte = *bufLimit

>    p->buf =3D = buf;

>

>    p->range =3D = range;

>

>    p->code =3D = code;

>

> -  p->remainLen =3D = len;

>

> +  p->remainLen =3D = (UInt32)len;

>

>    p->dicPos =3D = dicPos;

>

>    p->processedPos =3D = processedPos;

>

>    p->reps[0] =3D = rep0;

>

>    p->reps[1] =3D = rep1;

>

>    p->reps[2] =3D = rep2;

>

>    p->reps[3] =3D = rep3;

>

> -  p->state =3D state;

>

> +  p->state =3D = (UInt32)state;

>

>

>

>    return = SZ_OK;

>

>  }

>

> @@ -601,8 +601,8 @@ static = void MY_FAST_CALL

> LzmaDec_WriteRem(CLzmaDec *p, SizeT = limit)

>      if (p->checkDicSize = =3D=3D 0 && p->prop.dicSize - p->processedPos <=3D = len)

>

>        = p->checkDicSize =3D p->prop.dicSize;

>

>

>

> -    = p->processedPos +=3D len;

>

> -    = p->remainLen -=3D len;

>

> +    = p->processedPos +=3D (UInt32)len;

>

> +    = p->remainLen -=3D (UInt32)len;

>

>      while (len !=3D = 0)

> =

>      = {

> =

>        = len--;

>

> @@ -850,7 +850,7 @@ static ELzmaDummy = LzmaDec_TryDummy(const

> CLzmaDec *p, const Byte = *buf, SizeT inS

>  }

>

>

>

>

>

> -void = LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool = initState)

>

> +void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt = initDic, BoolInt

> initState)

>

>  = {

> =

>    p->remainLen =3D = kMatchSpecLenStart + 1;

>

>    = p->tempBufSize =3D 0;

>

> @@ -979,10 +979,10 @@ SRes = LzmaDec_DecodeToDic(CLzmaDec *p, SizeT

> dicLimit, const Byte *src, = SizeT *sr

>          = p->tempBufSize =3D rem;

>

>          = if (rem < LZMA_REQUIRED_INPUT_MAX || = checkEndMarkNow)

>

>          = {

> =

> = -          int dummyRes =3D = LzmaDec_TryDummy(p, p->tempBuf, rem);

>

> = +          int dummyRes =3D = LzmaDec_TryDummy(p, p->tempBuf,

> = (SizeT)rem);

>

>         &n= bsp;  if (dummyRes =3D=3D DUMMY_ERROR)

>

>         &n= bsp;  {

>

> = -            = (*srcLen) +=3D lookAhead;

>

> = +            = (*srcLen) +=3D (SizeT)lookAhead;

>

>         &n= bsp;    *status =3D = LZMA_STATUS_NEEDS_MORE_INPUT;

>

>         &n= bsp;    return SZ_OK;

>

>         &n= bsp;  }

>

> @@ -1005,9 +1005,9 @@ SRes = LzmaDec_DecodeToDic(CLzmaDec *p, SizeT

> dicLimit, const Byte *src, = SizeT *sr

>         &n= bsp;    return SZ_ERROR_FAIL; /* some internal error = */

> =

>         &n= bsp;  lookAhead -=3D rem;

>

>          = }

> =

> = -        (*srcLen) +=3D = lookAhead;

>

> +        (*srcLen) = +=3D (SizeT)lookAhead;

>

>          = src +=3D lookAhead;

>

> -        inSize = -=3D lookAhead;

>

> +        inSize = -=3D (SizeT)lookAhead;

>

>          = p->tempBufSize =3D 0;

>

>        = }

> =

>    }

>

> diff --git = a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c

> = b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c

> index = e281716fee..14086fc4f9 100644

> --- = a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c

> +++ = b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c

> @@ -1,5 +1,5 = @@

>  /* LzmaEnc.c -- LZMA = Encoder

>

> -2018-04-29 : Igor Pavlov : Public domain = */

> =

> = +2019-01-10: Igor Pavlov : Public domain */

>

>

>

>  #include = "Precomp.h"

>

>

>

> @@ -38,6 +38,8 @@ static unsigned g_STAT_OFFSET =3D = 0;

>  #define kNumBitPriceShiftBits = 4

> =

>  #define kBitPrice (1 << = kNumBitPriceShiftBits)

>

>

>

> +#define REP_LEN_COUNT = 64

> =

> = +

> =

>  void LzmaEncProps_Init(CLzmaEncProps = *p)

> =

>  {

>

>    = p->level =3D 5;

>

> @@ -183,8 +185,11 @@ typedef = struct

>  } COptimal;

>

>

>

>

>

> -#define kNumOpts (1 = << 12)

>

> -#define kPackReserve (1 + kNumOpts * = 2)

> =

> = +// 18.06

>

> +#define kNumOpts (1 << = 11)

> =

> = +#define kPackReserve (kNumOpts * 8)

>

> +// #define kNumOpts (1 = << 12)

>

> +// #define kPackReserve (1 + kNumOpts * = 2)

> =

> =

> =

>  #define kNumLenToPosStates = 4

> =

>  #define kNumPosSlotBits = 6

> =

> @@ = -236,10 +241,18 @@ typedef struct

>  typedef = struct

>

>  {

>

>    unsigned = tableSize;

>

> -  unsigned = counters[LZMA_NUM_PB_STATES_MAX];

>

>    UInt32 = prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal];

> =

> = +  // UInt32 prices1[LZMA_NUM_PB_STATES_MAX][kLenNumLowSymbols = *

> = 2];

> =

> = +  // UInt32 prices2[kLenNumSymbolsTotal];

>

>  } = CLenPriceEnc;

>

>

>

> +#define GET_PRICE_LEN(p, posState, len) = \

> =

> = +    ((p)->prices[posState][(size_t)(len) - = LZMA_MATCH_LEN_MIN])

>

> +

>

> +/*

>

> +#define GET_PRICE_LEN(p, posState, len) = \

> =

> = +    ((p)->prices2[(size_t)(len) - 2] + = ((p)->prices1[posState][((len) -

2) &

> (kLenNumLowSymbols * 2 - = 1)] & (((len) - 2 - kLenNumLowSymbols * 2) = >>

9)))

>

> +*/

>

>

>

>  typedef struct

>

>  = {

> =

> @@ = -308,16 +321,18 @@ typedef struct

>    unsigned = lc, lp, pb;

>

>    unsigned = lclp;

>

>

>

> -  Bool fastMode;

>

> -  Bool = writeEndMark;

>

> -  Bool finished;

>

> -  Bool = multiThread;

>

> -  Bool needInit;

>

> +  BoolInt = fastMode;

>

> +  BoolInt writeEndMark;

>

> +  BoolInt = finished;

>

> +  BoolInt multiThread;

>

> +  BoolInt = needInit;

>

> +  // BoolInt _maxMode;

>

>

>

>    UInt64 = nowPos64;

>

>

>

>    unsigned = matchPriceCount;

>

> -  unsigned = alignPriceCount;

>

> +  // unsigned = alignPriceCount;

>

> +  int repLenEncCounter;

>

>

>

>    unsigned = distTableSize;

>

>

>

> @@ -325,7 +340,7 @@ typedef = struct

>    SRes result;

>

>

>

>    #ifndef = _7ZIP_ST

>

> -  Bool mtMode;

>

> +  BoolInt = mtMode;

>

>    // begin of CMatchFinderMt is used = in LZ thread

>

>    CMatchFinderMt = matchFinderMt;

>

>    // end of CMatchFinderMt is used in = BT and HASH threads

>

> @@ -458,6 +473,7 @@ SRes = LzmaEnc_SetProps(CLzmaEncHandle pp, const

> CLzmaEncProps = *props2)

>    p->lp =3D = props.lp;

>

>    p->pb =3D = props.pb;

>

>    p->fastMode =3D (props.algo = =3D=3D 0);

>

> +  // p->_maxMode =3D = True;

>

>    p->matchFinderBase.btMode =3D = (Byte)(props.btMode ? 1 : 0);

>

>    = {

> =

>      unsigned numHashBytes = =3D 4;

>

> @@ -618,9 +634,9 @@ static void = RangeEnc_FlushData(CRangeEnc *p)

>

>

>  #ifdef = _LZMA_ENC_USE_BRANCH

>

>

>

> -#define RC_BIT(p, prob, symbol) { = \

> =

> = +#define RC_BIT(p, prob, bit) { \

>

>    = RC_BIT_PRE(p, prob) \

>

> -  if (symbol =3D=3D 0) { range =3D newBound; ttt = +=3D (kBitModelTotal - ttt) >>

> kNumMoveBits; } = \

> =

> = +  if (bit =3D=3D 0) { range =3D newBound; ttt +=3D (kBitModelTotal = - ttt) >>

> kNumMoveBits; } \

>

>    else { = (p)->low +=3D newBound; range -=3D newBound; ttt -=3D ttt = >>

> kNumMoveBits; } \

>

>    *(prob) = =3D (CLzmaProb)ttt; \

>

>    RC_NORM(p) \

>

> @@ -628,15 +644,15 @@ = static void RangeEnc_FlushData(CRangeEnc *p)

>

>

>  = #else

>

>

>

> -#define RC_BIT(p, prob, symbol) { = \

> =

> = +#define RC_BIT(p, prob, bit) { \

>

>    UInt32 = mask; \

>

>    RC_BIT_PRE(p, prob) = \

> =

> = -  mask =3D 0 - (UInt32)symbol; \

>

> +  mask =3D 0 - = (UInt32)bit; \

>

>    range &=3D mask; = \

> =

>    mask &=3D newBound; = \

> =

>    range -=3D mask; = \

> =

>    (p)->low +=3D mask; = \

> =

> = -  mask =3D (UInt32)symbol - 1; \

>

> +  mask =3D = (UInt32)bit - 1; \

>

>    range +=3D newBound & mask; = \

> =

>    mask &=3D (kBitModelTotal - ((1 = << kNumMoveBits) - 1)); \

>

>    mask +=3D = ((1 << kNumMoveBits) - 1); \

>

> @@ -673,42 +689,42 @@ = static void RangeEnc_EncodeBit_0(CRangeEnc *p,

> CLzmaProb = *prob)

>    p->range =3D = range;

>

>  }

>

>

>

> -static void = LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 = symbol)

>

> +static void LitEnc_Encode(CRangeEnc *p, CLzmaProb = *probs, UInt32 sym)

>

>  {

>

>    UInt32 = range =3D p->range;

>

> -  symbol |=3D = 0x100;

>

> +  sym |=3D 0x100;

>

>    = do

> =

>    {

>

>      UInt32 ttt, = newBound;

>

> -    // RangeEnc_EncodeBit(p, probs + = (symbol >> 8), (symbol >> 7) & = 1);

> =

> = -    CLzmaProb *prob =3D probs + (symbol >> = 8);

> =

> = -    UInt32 bit =3D (symbol >> 7) & = 1;

> =

> = -    symbol <<=3D 1;

>

> +    // = RangeEnc_EncodeBit(p, probs + (sym >> 8), (sym >> 7) & = 1);

> =

> = +    CLzmaProb *prob =3D probs + (sym >> = 8);

> =

> = +    UInt32 bit =3D (sym >> 7) & = 1;

> =

> = +    sym <<=3D 1;

>

>      RC_BIT(p, prob, = bit);

>

>    }

>

> -  while (symbol < = 0x10000);

>

> +  while (sym < = 0x10000);

>

>    p->range =3D = range;

>

>  }

>

>

>

> -static void = LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, = UInt32

> symbol, UInt32 matchByte)

>

> +static void = LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb = *probs,

> UInt32 sym, UInt32 matchByte)

>

>  = {

> =

>    UInt32 range =3D = p->range;

>

>    UInt32 offs =3D = 0x100;

>

> -  symbol |=3D 0x100;

>

> +  sym |=3D = 0x100;

>

>    do

>

>    = {

> =

>      UInt32 ttt, = newBound;

>

>      CLzmaProb = *prob;

>

>      UInt32 = bit;

>

>      matchByte <<=3D = 1;

> =

> = -    // RangeEnc_EncodeBit(p, probs + (offs + (matchByte = & offs) + (symbol

>> 

> 8)), (symbol >> 7) = & 1);

>

> -    prob =3D probs + (offs + = (matchByte & offs) + (symbol >> 8));

>

> -    bit =3D = (symbol >> 7) & 1;

>

> -    symbol = <<=3D 1;

>

> -    offs &=3D ~(matchByte ^ = symbol);

>

> +    // RangeEnc_EncodeBit(p, probs + = (offs + (matchByte & offs) + (sym >>

> 8)), (sym >> 7) & = 1);

> =

> = +    prob =3D probs + (offs + (matchByte & offs) + = (sym >> 8));

>

> +    bit =3D (sym >> 7) & = 1;

> =

> = +    sym <<=3D 1;

>

> +    offs = &=3D ~(matchByte ^ sym);

>

>      RC_BIT(p, prob, = bit);

>

>    }

>

> -  while (symbol < = 0x10000);

>

> +  while (sym < = 0x10000);

>

>    p->range =3D = range;

>

>  }

>

>

>

> @@ -739,11 +755,11 @@ = static void LzmaEnc_InitPriceTables(CProbPrice

> = *ProbPrices)

>  }

>

>

>

>

>

> -#define GET_PRICE(prob, = symbol) \

>

> -  p->ProbPrices[((prob) ^ = (unsigned)(((-(int)(symbol))) & = (kBitModelTotal

-

> 1))) >> = kNumMoveReducingBits];

>

> +#define GET_PRICE(prob, = bit) \

>

> +  p->ProbPrices[((prob) ^ = (unsigned)(((-(int)(bit))) & (kBitModelTotal = -

1))) = >>

> kNumMoveReducingBits];

>

>

>

> -#define GET_PRICEa(prob, = symbol) \

>

> -     ProbPrices[((prob) ^ = (unsigned)((-((int)(symbol))) & = (kBitModelTotal

-

> 1))) >> = kNumMoveReducingBits];

>

> +#define GET_PRICEa(prob, = bit) \

>

> +     ProbPrices[((prob) ^ = (unsigned)((-((int)(bit))) & (kBitModelTotal = -

1))) = >>

> kNumMoveReducingBits];

>

>

>

>  #define = GET_PRICE_0(prob) p->ProbPrices[(prob) = >>

> kNumMoveReducingBits]

>

>  #define = GET_PRICE_1(prob) p->ProbPrices[((prob) ^ (kBitModelTotal - = 1))

>> 

> = kNumMoveReducingBits]

>

> @@ -752,48 +768,48 @@ static void = LzmaEnc_InitPriceTables(CProbPrice

> = *ProbPrices)

>  #define GET_PRICEa_1(prob) ProbPrices[((prob) ^ = (kBitModelTotal - 1)) >>

> = kNumMoveReducingBits]

>

>

>

>

>

> -static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, = UInt32 symbol,

const

> CProbPrice *ProbPrices)

>

> +static UInt32 = LitEnc_GetPrice(const CLzmaProb *probs, UInt32 sym, = const

> CProbPrice *ProbPrices)

>

>  = {

> =

>    UInt32 price =3D = 0;

> =

> = -  symbol |=3D 0x100;

>

> +  sym |=3D = 0x100;

>

>    do

>

>    = {

> =

> = -    unsigned bit =3D symbol & = 1;

> =

> = -    symbol >>=3D 1;

>

> -    price = +=3D GET_PRICEa(probs[symbol], bit);

>

> +    = unsigned bit =3D sym & 1;

>

> +    sym = >>=3D 1;

>

> +    price +=3D GET_PRICEa(probs[sym], = bit);

>

>    }

>

> -  while (symbol = >=3D 2);

>

> +  while (sym >=3D 2);

>

>    return = price;

>

>  }

>

>

>

>

>

> -static UInt32 = LitEnc_Matched_GetPrice(const CLzmaProb *probs, = UInt32

> symbol, UInt32 matchByte, const CProbPrice = *ProbPrices)

>

> +static UInt32 LitEnc_Matched_GetPrice(const CLzmaProb = *probs, UInt32

> sym, UInt32 matchByte, const CProbPrice = *ProbPrices)

>

>  {

>

>    UInt32 = price =3D 0;

>

>    UInt32 offs =3D = 0x100;

>

> -  symbol |=3D 0x100;

>

> +  sym |=3D = 0x100;

>

>    do

>

>    = {

> =

>      matchByte <<=3D = 1;

> =

> = -    price +=3D GET_PRICEa(probs[offs + (matchByte & = offs) + (symbol >> 8)],

> (symbol >> 7) & = 1);

> =

> = -    symbol <<=3D 1;

>

> -    offs = &=3D ~(matchByte ^ symbol);

>

> +    price = +=3D GET_PRICEa(probs[offs + (matchByte & offs) + (sym >> = 8)],

> (sym >> 7) & 1);

>

> +    sym = <<=3D 1;

>

> +    offs &=3D ~(matchByte ^ = sym);

>

>    }

>

> -  while (symbol < = 0x10000);

>

> +  while (sym < = 0x10000);

>

>    return = price;

>

>  }

>

>

>

>

>

> -static void = RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb = *probs,

> unsigned numBits, UInt32 = symbol)

>

> +static void RcTree_ReverseEncode(CRangeEnc *rc, = CLzmaProb *probs,

> unsigned numBits, unsigned = sym)

>

>  {

>

>    UInt32 = range =3D rc->range;

>

>    unsigned = m =3D 1;

>

>    do

>

>    = {

> =

>      UInt32 ttt, = newBound;

>

> -    unsigned bit =3D symbol & = 1;

> =

> = +    unsigned bit =3D sym & = 1;

> =

>      // = RangeEnc_EncodeBit(rc, probs + m, bit);

>

> -    symbol = >>=3D 1;

>

> +    sym >>=3D = 1;

> =

>      RC_BIT(rc, probs + m, = bit);

>

>      m =3D (m << 1) | = bit;

>

>    }

>

> @@ -812,37 +828,37 @@ = static void LenEnc_Init(CLenEnc *p)

>      p->high[i] =3D = kProbInitValue;

>

>  }

>

>

>

> -static void = LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, unsigned = symbol,

> unsigned posState)

>

> +static void = LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, unsigned = sym,

> unsigned posState)

>

>  = {

> =

>    UInt32 range, ttt, = newBound;

>

>    CLzmaProb *probs =3D = p->low;

>

>    range =3D = rc->range;

>

>    RC_BIT_PRE(rc, = probs);

>

> -  if (symbol >=3D = kLenNumLowSymbols)

>

> +  if (sym >=3D = kLenNumLowSymbols)

>

>    {

>

>      RC_BIT_1(rc, = probs);

>

>      probs +=3D = kLenNumLowSymbols;

>

>      RC_BIT_PRE(rc, = probs);

>

> -    if (symbol >=3D = kLenNumLowSymbols * 2)

>

> +    if (sym = >=3D kLenNumLowSymbols * 2)

>

>      = {

> =

>        RC_BIT_1(rc, = probs);

>

>        rc->range = =3D range;

>

> -      // RcTree_Encode(rc, = p->high, kLenNumHighBits, symbol -

> kLenNumLowSymbols * = 2);

> =

> = -      LitEnc_Encode(rc, p->high, symbol - = kLenNumLowSymbols * 2);

>

> = +      // RcTree_Encode(rc, p->high, = kLenNumHighBits, sym -

> kLenNumLowSymbols * = 2);

> =

> = +      LitEnc_Encode(rc, p->high, sym - = kLenNumLowSymbols * 2);

>

>        = return;

>

>      = }

> =

> = -    symbol -=3D = kLenNumLowSymbols;

>

> +    sym -=3D = kLenNumLowSymbols;

>

>    }

>

>

>

> -  // = RcTree_Encode(rc, probs + (posState << = kLenNumLowBits),

> kLenNumLowBits, symbol);

>

> +  // = RcTree_Encode(rc, probs + (posState << = kLenNumLowBits),

> kLenNumLowBits, sym);

>

>    = {

> =

>      unsigned = m;

> =

>      unsigned = bit;

>

>      RC_BIT_0(rc, = probs);

>

>      probs +=3D (posState = << (1 + kLenNumLowBits));

>

> -    bit =3D = (symbol >> 2)    ; RC_BIT(rc, probs + 1, bit); m = =3D (1 << 1) +

bit;

>

> -    bit =3D (symbol >> 1) & = 1; RC_BIT(rc, probs + m, bit); m =3D (m << 1) = +

bit;

>

> -    bit =3D  = symbol       & 1; RC_BIT(rc, probs + = m, bit);

>

> +    bit =3D (sym >> = 2)    ; RC_BIT(rc, probs + 1, bit); m =3D (1 << 1) = + bit;

>

> +    bit =3D (sym >> 1) & 1; = RC_BIT(rc, probs + m, bit); m =3D (m << 1) + = bit;

>

> +    bit =3D  = sym       & 1; RC_BIT(rc, probs + m, = bit);

>

>      rc->range =3D = range;

>

>    }

>

>  = }

> =

> @@ = -863,50 +879,93 @@ static void SetPrices_3(const CLzmaProb = *probs,

> UInt32 startPrice, UInt32 = *price

>  }

>

>

>

>

>

> -MY_NO_INLINE static void = MY_FAST_CALL LenPriceEnc_UpdateTable(

>

> -    = CLenPriceEnc *p, unsigned posState,

>

> +MY_NO_INLINE static void = MY_FAST_CALL LenPriceEnc_UpdateTables(

>

> +    = CLenPriceEnc *p,

>

> +    unsigned = numPosStates,

>

>      const CLenEnc = *enc,

>

>      const CProbPrice = *ProbPrices)

>

>  {

>

> -  // int y; for (y = =3D 0; y < 100; y++) {

>

> -  UInt32 = a;

> =

> = -  unsigned i, numSymbols;

>

> +  UInt32 = b;

> =

> = +

> =

> = +  {

>

> +    unsigned prob =3D = enc->low[0];

>

> +    UInt32 a, = c;

> =

> = +    unsigned posState;

>

> +    b =3D = GET_PRICEa_1(prob);

>

> +    a =3D = GET_PRICEa_0(prob);

>

> +    c =3D b + = GET_PRICEa_0(enc->low[kLenNumLowSymbols]);

>

> +    for = (posState =3D 0; posState < numPosStates; = posState++)

>

> +    {

>

> = +      UInt32 *prices =3D = p->prices[posState];

>

> = +      const CLzmaProb *probs =3D enc->low + = (posState << (1 +

> = kLenNumLowBits));

>

> +      SetPrices_3(probs, a, = prices, ProbPrices);

>

> +      SetPrices_3(probs + = kLenNumLowSymbols, c, prices +

> kLenNumLowSymbols, = ProbPrices);

>

> +    }

>

> +  = }

> =

> =

> =

> = -  UInt32 *prices =3D = p->prices[posState];

>

> +  = /*

> =

>    {

>

> -    const = CLzmaProb *probs =3D enc->low + (posState << (1 = +

> = kLenNumLowBits));

>

> -    SetPrices_3(probs, = GET_PRICEa_0(enc->low[0]), prices, = ProbPrices);

>

> +    unsigned = i;

> =

> = +    UInt32 b;

>

> +    a =3D = GET_PRICEa_0(enc->low[0]);

>

> +    for (i = =3D 0; i < kLenNumLowSymbols; i++)

>

> = +      p->prices2[i] =3D = a;

> =

>      a =3D = GET_PRICEa_1(enc->low[0]);

>

> -    = SetPrices_3(probs + kLenNumLowSymbols, a +

> = GET_PRICEa_0(enc->low[kLenNumLowSymbols]), prices = +

> = kLenNumLowSymbols, ProbPrices);

>

> +    b =3D a = + GET_PRICEa_0(enc->low[kLenNumLowSymbols]);

>

> +    for (i = =3D kLenNumLowSymbols; i < kLenNumLowSymbols * 2; = i++)

>

> +      p->prices2[i] =3D = b;

> =

>      a +=3D = GET_PRICEa_1(enc->low[kLenNumLowSymbols]);

>

>    = }

> =

> = -  numSymbols =3D p->tableSize;

>

> -  = p->counters[posState] =3D numSymbols;

>

> -  for (i =3D = kLenNumLowSymbols * 2; i < numSymbols; i +=3D = 1)

> =

> = +  */

>

> +

>

> +  // p->counter =3D = numSymbols;

>

> +  // p->counter =3D = 64;

> =

> = +

> =

>    {

>

> -    = prices[i] =3D a +

>

> -       // = RcTree_GetPrice(enc->high, kLenNumHighBits, i = -

> = kLenNumLowSymbols * 2, ProbPrices);

>

> = -       LitEnc_GetPrice(enc->high, i - = kLenNumLowSymbols * 2,

> = ProbPrices);

>

> -    /*

>

> -    = unsigned sym =3D (i - kLenNumLowSymbols * 2) >> = 1;

> =

> = -    UInt32 price =3D a + RcTree_GetPrice(enc->high, = kLenNumHighBits - 1,

> sym, ProbPrices);

>

> -    UInt32 = prob =3D enc->high[(1 << 7) + sym];

>

> -    = prices[i    ] =3D price + = GET_PRICEa_0(prob);

>

> -    prices[i + 1] =3D price + = GET_PRICEa_1(prob);

>

> -    */

>

> -  = }

> =

> = -  // }

>

> -}

>

> +    unsigned i =3D = p->tableSize;

>

> +

>

> +    if (i > kLenNumLowSymbols * = 2)

> =

> = +    {

>

> +      const CLzmaProb *probs = =3D enc->high;

>

> +      UInt32 *prices =3D = p->prices[0] + kLenNumLowSymbols * 2;

>

> = +      i -=3D kLenNumLowSymbols * 2 - = 1;

> =

> = +      i >>=3D 1;

>

> = +      b +=3D = GET_PRICEa_1(enc->low[kLenNumLowSymbols]);

>

> = +      do

>

> = +      {

>

> = +        /*

>

> = +        p->prices2[i] =3D a = +

> =

> = +        // = RcTree_GetPrice(enc->high, kLenNumHighBits, i = -

> = kLenNumLowSymbols * 2, ProbPrices);

>

> = +        LitEnc_GetPrice(probs, i - = kLenNumLowSymbols * 2, ProbPrices);

>

> = +        */

>

> = +        // UInt32 price =3D a + = RcTree_GetPrice(probs, kLenNumHighBits - 1,

> sym, = ProbPrices);

>

> +        unsigned = sym =3D --i + (1 << (kLenNumHighBits - = 1));

>

> +        UInt32 = price =3D b;

>

> +        = do

> =

> = +        {

>

> +  =         unsigned bit =3D sym = & 1;

>

> = +          sym >>=3D = 1;

> =

> = +          price +=3D = GET_PRICEa(probs[sym], bit);

>

> = +        }

>

> = +        while (sym >=3D = 2);

> =

> =

> =

> = -static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, = unsigned

> numPosStates,

>

> -    const = CLenEnc *enc,

>

> -    const CProbPrice = *ProbPrices)

>

> -{

>

> -  unsigned posState;

>

> -  for (posState =3D = 0; posState < numPosStates; posState++)

>

> -    = LenPriceEnc_UpdateTable(p, posState, enc, = ProbPrices);

>

> -}

>

> +        = {

> =

> = +          unsigned prob = =3D probs[(size_t)i + (1 << (kLenNumHighBits = -

1))];

>

> = +          prices[(size_t)i = * 2    ] =3D price + = GET_PRICEa_0(prob);

>

> = +          prices[(size_t)i = * 2 + 1] =3D price + GET_PRICEa_1(prob);

>

> = +        }

>

> = +      }

>

> = +      while (i);

>

>

>

> = +      {

>

> = +        unsigned = posState;

>

> +        size_t num = =3D (p->tableSize - kLenNumLowSymbols * 2) *

> = sizeof(p->prices[0][0]);

>

> = +        for (posState =3D 1; = posState < numPosStates; posState++)

>

> = +          = memcpy(p->prices[posState] + kLenNumLowSymbols * = 2,

> = p->prices[0] + kLenNumLowSymbols * 2, num);

>

> = +      }

>

> +    = }

> =

> = +  }

>

> +}

>

>

>

>  /*

>

>    #ifdef = SHOW_STAT

>

> @@ -917,7 +976,7 @@ static void = LenPriceEnc_UpdateTables(CLenPriceEnc

> *p, unsigned = numPosStates,

>

>

>  #define MOVE_POS(p, num) { = \

> =

>      p->additionalOffset = +=3D (num); \

>

> -    = p->matchFinder.Skip(p->matchFinderObj, (num)); = }

> =

> = +    p->matchFinder.Skip(p->matchFinderObj, = (UInt32)(num)); }

>

>

>

>

>

>  static unsigned ReadMatchDistances(CLzmaEnc *p, = unsigned *numPairsRes)

>

> @@ -954,7 +1013,8 @@ static = unsigned ReadMatchDistances(CLzmaEnc *p,

> unsigned = *numPairsRes)

>          = const Byte *p2 =3D p1 + len;

>

>          = ptrdiff_t dif =3D (ptrdiff_t)-1 - p->matches[(size_t)numPairs - = 1];

> =

>          = const Byte *lim =3D p1 + numAvail;

>

> = -        for (; p2 !=3D lim = && *p2 =3D=3D p2[dif]; p2++);

>

> = +        for (; p2 !=3D lim = && *p2 =3D=3D p2[dif]; p2++)

>

> = +        {}

>

>          = return (unsigned)(p2 - p1);

>

>        = }

> =

>      = }

> =

> @@ = -977,7 +1037,7 @@ static unsigned ReadMatchDistances(CLzmaEnc = *p,

> = unsigned *numPairsRes)

>    + = GET_PRICE_1(p->isRep[state]) \

>

>    + = GET_PRICE_0(p->isRepG0[state])

>

>

>

> -

>

> = +MY_FORCE_INLINE

>

>  static UInt32 GetPrice_PureRep(const CLzmaEnc = *p, unsigned repIndex,

> size_t state, size_t = posState)

>

>  {

>

>    UInt32 = price;

>

> @@ -1011,14 +1071,14 @@ static unsigned = Backward(CLzmaEnc *p,

> unsigned cur)

>    for = (;;)

>

>    {

>

>      UInt32 dist =3D = p->opt[cur].dist;

>

> -    UInt32 len =3D = p->opt[cur].len;

>

> -    UInt32 extra =3D = p->opt[cur].extra;

>

> +    unsigned len =3D = (unsigned)p->opt[cur].len;

>

> +    = unsigned extra =3D = (unsigned)p->opt[cur].extra;

>

>   =    cur -=3D len;

>

>

>

>      if = (extra)

>

>      = {

> =

>        = wr--;

>

> -      p->opt[wr].len =3D = len;

>

> +      p->opt[wr].len =3D = (UInt32)len;

>

>        cur -=3D = extra;

>

>        len =3D = extra;

>

>        if (extra = =3D=3D 1)

>

> @@ -1045,7 +1105,7 @@ static unsigned = Backward(CLzmaEnc *p, unsigned

> = cur)

>

>

>      = wr--;

>

>      p->opt[wr].dist =3D = dist;

>

> -    p->opt[wr].len =3D = len;

>

> +    p->opt[wr].len =3D = (UInt32)len;

>

>    }

>

>  = }

> =

> =

> =

> @@ = -1102,7 +1162,8 @@ static unsigned GetOptimum(CLzmaEnc *p, = UInt32

> position)

>          = repLens[i] =3D 0;

>

>          = continue;

>

>        = }

> =

> = -      for (len =3D 2; len < numAvail = && data[len] =3D=3D data2[len]; len++);

>

> = +      for (len =3D 2; len < numAvail = && data[len] =3D=3D data2[len]; len++)

>

> = +      {}

>

>        repLens[i] = =3D len;

>

>        if (len > = repLens[repMaxIndex])

>

>          = repMaxIndex =3D i;

>

> @@ -1111,7 +1172,7 @@ static unsigned = GetOptimum(CLzmaEnc *p, UInt32

> = position)

>      if (repLens[repMaxIndex] = >=3D p->numFastBytes)

>

>      = {

> =

>        unsigned = len;

>

> -      p->backRes =3D = repMaxIndex;

>

> +      p->backRes =3D = (UInt32)repMaxIndex;

>

>        len =3D = repLens[repMaxIndex];

>

>        MOVE_POS(p, = len - 1)

>

>        return = len;

>

> @@ -1128,8 +1189,12 @@ static unsigned = GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>

>

>      curByte =3D = *data;

>

>      matchByte =3D *(data - = reps[0]);

>

> +

>

> +    last =3D = repLens[repMaxIndex];

>

> +    if (last <=3D = mainLen)

>

> +      last =3D = mainLen;

>

>

>

> -    if (mainLen < 2 && = curByte !=3D matchByte && repLens[repMaxIndex] = <

> 2)

>

> +    if (last < 2 && curByte = !=3D matchByte)

>

>      = {

> =

>        = p->backRes =3D MARK_LIT;

>

>        return = 1;

> =

> @@ = -1146,13 +1211,14 @@ static unsigned GetOptimum(CLzmaEnc = *p,

> = UInt32 position)

>         &n= bsp;  LitEnc_Matched_GetPrice(probs, curByte, = matchByte,

> p->ProbPrices) :

>

>         &n= bsp;  LitEnc_GetPrice(probs, curByte, = p->ProbPrices));

>

>      = }

> =

> = -

> =

> = +

> =

>      = MakeAs_Lit(&p->opt[1]);

>

>

>

>      matchPrice =3D = GET_PRICE_1(p->isMatch[p->state][posState]);

<= p class=3DMsoPlainText>>

>      repMatchPrice =3D = matchPrice + = GET_PRICE_1(p->isRep[p->state]);

>

>

>

> -    if = (matchByte =3D=3D curByte)

>

> +    // = 18.06

>

> +    if (matchByte =3D=3D curByte = && repLens[0] =3D=3D 0)

>

>      = {

> =

>        UInt32 = shortRepPrice =3D repMatchPrice + = GetPrice_ShortRep(p,

> p->state, posState);

>

>        if = (shortRepPrice < p->opt[1].price)

>

> @@ -1160,16 +1226,13 @@ = static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>          = p->opt[1].price =3D shortRepPrice;

>

>          = MakeAs_ShortRep(&p->opt[1]);

>

>        = }

> =

> = +      if (last < 2)

>

> = +      {

>

> = +        p->backRes =3D = p->opt[1].dist;

>

> +        return = 1;

> =

> = +      }

>

>      = }

> =

> = -

> =

> = -    last =3D (mainLen >=3D repLens[repMaxIndex] ? = mainLen :

> repLens[repMaxIndex]);

>

> -

>

> -    if = (last < 2)

>

> -    {

>

> = -      p->backRes =3D = p->opt[1].dist;

>

> -      return = 1;

> =

> = -    }

>

> -

>

> +

>

>      p->opt[1].len =3D = 1;

> =

> =

> =

>      p->opt[0].reps[0] =3D = reps[0];

>

> @@ -1177,13 +1240,6 @@ static unsigned = GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>      p->opt[0].reps[2] =3D = reps[2];

>

>      p->opt[0].reps[3] =3D = reps[3];

>

>

>

> -    {

>

> = -      unsigned len =3D = last;

>

> -      = do

> =

> = -        p->opt[len--].price =3D = kInfinityPrice;

>

> -      while (len >=3D = 2);

> =

> = -    }

>

> -

>

>      // ---------- REP = ----------

>

>

>

>      for (i =3D 0; i < = LZMA_NUM_REPS; i++)

>

> @@ -1195,13 +1251,13 @@ static unsigned = GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>        price =3D = repMatchPrice + GetPrice_PureRep(p, i, p->state, = posState);

>

>        = do

> =

>        = {

> =

> = -        UInt32 price2 =3D price = +

> = p->repLenEnc.prices[posState][(size_t)repLen - = 2];

> =

> = +        UInt32 price2 =3D price + = GET_PRICE_LEN(&p->repLenEnc, posState,

> = repLen);

>

>          = COptimal *opt =3D &p->opt[repLen];

>

>          = if (price2 < opt->price)

>

>          = {

> =

>         &n= bsp;  opt->price =3D price2;

>

> = -          opt->len =3D = repLen;

>

> = -          opt->dist =3D = i;

> =

> = +          opt->len =3D = (UInt32)repLen;

>

> = +          opt->dist =3D = (UInt32)i;

>

>         &n= bsp;  opt->extra =3D 0;

>

>          = }

> =

>      =   }

>

> @@ -1211,38 +1267,41 @@ static unsigned = GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>

>

>      // ---------- MATCH = ----------

>

>      = {

> =

> = -      unsigned len  =3D ((repLens[0] = >=3D 2) ? repLens[0] + 1 : 2);

>

> = +      unsigned len =3D repLens[0] + = 1;

> =

>        if (len = <=3D mainLen)

>

>        = {

> =

>          = unsigned offs =3D 0;

>

>          = UInt32 normalMatchPrice =3D matchPrice +

> = GET_PRICE_0(p->isRep[p->state]);

>

>

>

> = -        while (len > = matches[offs])

>

> = -          offs +=3D = 2;

> =

> = +        if (len < = 2)

> =

> = +          len =3D = 2;

> =

> = +        else

>

> = +          while (len > = matches[offs])

>

> = +            offs = +=3D 2;

>

>

>

>          = for (; ; len++)

>

>          = {

> =

>         &n= bsp;  COptimal *opt;

>

>         &n= bsp;  UInt32 dist =3D matches[(size_t)offs + = 1];

> =

> = -          UInt32 price2 = =3D normalMatchPrice +

> = p->lenEnc.prices[posState][(size_t)len - = LZMA_MATCH_LEN_MIN];

>

> = +          UInt32 price =3D = normalMatchPrice +

> GET_PRICE_LEN(&p->lenEnc, posState, = len);

>

>         &n= bsp;  unsigned lenToPosState =3D = GetLenToPosState(len);

>

>

>

>         &n= bsp;  if (dist < kNumFullDistances)

>

> = -            = price2 +=3D p->distancesPrices[lenToPosState][dist = &

> (kNumFullDistances - 1)];

>

> = +            = price +=3D p->distancesPrices[lenToPosState][dist = &

> (kNumFullDistances - 1)];

>

>         &n= bsp;  else

>

>         &n= bsp;  {

>

>         &n= bsp;    unsigned slot;

>

>         &n= bsp;    GetPosSlot2(dist, slot);

>

> = -            = price2 +=3D p->alignPrices[dist & = kAlignMask];

>

> = -            = price2 +=3D = p->posSlotPrices[lenToPosState][slot];

>

> = +            = price +=3D p->alignPrices[dist & = kAlignMask];

>

> = +            = price +=3D = p->posSlotPrices[lenToPosState][slot];

>

>         &n= bsp;  }

>

>

>

>         &n= bsp;  opt =3D &p->opt[len];

>

>

>

> = -          if (price2 < = opt->price)

>

> = +          if (price < = opt->price)

>

>         &n= bsp;  {

>

> = -            = opt->price =3D price2;

>

> -    =         opt->len =3D = len;

>

> = +            = opt->price =3D price;

>

> = +            = opt->len =3D (UInt32)len;

>

>         &n= bsp;    opt->dist =3D dist + = LZMA_NUM_REPS;

>

>         &n= bsp;    opt->extra =3D 0;

>

>         &n= bsp;  }

>

> @@ -1277,16 +1336,43 @@ static unsigned = GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>

>

>    for (;;)

>

>    = {

> =

> = -    UInt32 numAvail, = numAvailFull;

>

> +    unsigned = numAvail;

>

> +    UInt32 = numAvailFull;

>

>      unsigned newLen, = numPairs, prev, state, posState, startLen;

>

> -    UInt32 = curPrice, litPrice, matchPrice, repMatchPrice;

>

> -    Bool = nextIsLit;

>

> +    UInt32 litPrice, matchPrice, = repMatchPrice;

>

> +    BoolInt = nextIsLit;

>

>      Byte curByte, = matchByte;

>

>      const Byte = *data;

>

>      COptimal *curOpt, = *nextOpt;

>

>

>

>      if (++cur =3D=3D = last)

>

> -      return Backward(p, = cur);

>

> +      = break;

>

> +

>

> +    // 18.06

>

> +    if (cur = >=3D kNumOpts - 64)

>

> +    = {

> =

> = +      unsigned j, = best;

>

> +      UInt32 price =3D = p->opt[cur].price;

>

> +      best =3D = cur;

>

> +      for (j =3D cur + 1; j = <=3D last; j++)

>

> +      = {

> =

> = +        UInt32 price2 =3D = p->opt[j].price;

>

> +        if (price = >=3D price2)

>

> +        = {

> =

> = +          price =3D = price2;

>

> = +          best =3D = j;

> =

> = +        }

>

> = +      }

>

> = +      {

>

> = +        unsigned delta =3D best - = cur;

>

> +        if (delta = !=3D 0)

>

> +        = {

> =

> = +          MOVE_POS(p, = delta);

>

> +        = }

> =

> = +      }

>

> = +      cur =3D best;

>

> = +      break;

>

> +    = }

> =

> =

> =

>      newLen =3D = ReadMatchDistances(p, &numPairs);

>

>

>

> @@ -1294,15 +1380,24 @@ = static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>      = {

> =

>        = p->numPairs =3D numPairs;

>

>        = p->longestMatchLen =3D newLen;

>

> = -      return Backward(p, = cur);

>

> +      = break;

>

>      = }

> =

> =

> =

>      curOpt =3D = &p->opt[cur];

>

> +

>

> +    = position++;

>

> +

>

> +    // we need that check here, if = skip_items in p->opt are possible

>

> +    = /*

> =

> = +    if (curOpt->price >=3D = kInfinityPrice)

>

> +      = continue;

>

> +    */

>

> +

>

>      prev =3D cur - = curOpt->len;

>

> -

>

> +

>

>      if (curOpt->len = =3D=3D 1)

>

>      = {

> =

> = -      state =3D = p->opt[prev].state;

>

> = +      state =3D = (unsigned)p->opt[prev].state;

>

>        if = (IsShortRep(curOpt))

>

>          = state =3D kShortRepNextStates[state];

>

>        = else

>

> @@ -1316,14 +1411,14 @@ static unsigned = GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>

>

>        if = (curOpt->extra)

>

>        = {

> =

> = -        prev -=3D = curOpt->extra;

>

> +        prev -=3D = (unsigned)curOpt->extra;

>

>          = state =3D kState_RepAfterLit;

>

>          = if (curOpt->extra =3D=3D 1)

>

> = -          state =3D (dist = < LZMA_NUM_REPS) ? kState_RepAfterLit :

> = kState_MatchAfterLit;

>

> = +          state =3D (dist = < LZMA_NUM_REPS ? kState_RepAfterLit :

> = kState_MatchAfterLit);

>

>        = }

> =

>        = else

>

>        = {

> =

> = -        state =3D = p->opt[prev].state;

>

> = +        state =3D = (unsigned)p->opt[prev].state;

>

>          = if (dist < LZMA_NUM_REPS)

>

>         &n= bsp;  state =3D kRepNextStates[state];

>

>          = else

>

> @@ -1379,7 +1474,6 @@ static unsigned = GetOptimum(CLzmaEnc *p, UInt32

> = position)

>      curByte =3D = *data;

>

>      matchByte =3D *(data - = reps[0]);

>

>

>

> -    = position++;

>

>      posState =3D (position = & p->pbMask);

>

>

>

>      = /*

> =

> @@ = -1391,13 +1485,25 @@ static unsigned GetOptimum(CLzmaEnc = *p,

> = UInt32 position)

>         = <  MATCH  [ : LIT : REP_0 ]

>

>      = */

> =

> =

> =

> = -    curPrice =3D = curOpt->price;

>

> -    litPrice =3D curPrice + = GET_PRICE_0(p->isMatch[state][posState]);

>

> +    = {

> =

> = +      UInt32 curPrice =3D = curOpt->price;

>

> +      unsigned prob =3D = p->isMatch[state][posState];

>

> = +      matchPrice =3D curPrice + = GET_PRICE_1(prob);

>

> +      litPrice =3D curPrice = + GET_PRICE_0(prob);

>

> +    }

>

>

>

>      nextOpt =3D = &p->opt[(size_t)cur + 1];

>

>      nextIsLit =3D = False;

>

>

>

> -    // if (litPrice >=3D = nextOpt->price) litPrice =3D 0; else // = 18.new

>

> +    // here we can allow skip_items in = p->opt, if we don't check

> (nextOpt->price < = kInfinityPrice)

>

> +    // = 18.new.06

>

> +    if ((nextOpt->price < = kInfinityPrice

>

> +        // = && !IsLitState(state)

>

> = +        && matchByte =3D=3D = curByte)

>

> +        || = litPrice > nextOpt->price

>

> = +        )

>

> = +      litPrice =3D 0;

>

> +    = else

>

>      = {

> =

>        const = CLzmaProb *probs =3D LIT_PROBS(position, *(data - = 1));

>

>        litPrice = +=3D (!IsLitState(state) ?

>

> @@ -1413,21 +1519,32 @@ = static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>        = }

> =

>      = }

> =

> =

> =

> = -    matchPrice =3D curPrice + = GET_PRICE_1(p->isMatch[state][posState]);

>

>      repMatchPrice =3D = matchPrice + GET_PRICE_1(p->isRep[state]);

>

>

>

> +    = numAvailFull =3D p->numAvail;

>

> +    = {

> =

> = +      unsigned temp =3D kNumOpts - 1 - = cur;

>

> +      if (numAvailFull > = temp)

>

> +        = numAvailFull =3D (UInt32)temp;

>

> +    = }

> =

> = +

> =

> = +    // 18.06

>

>      // ---------- SHORT_REP = ----------

>

> -    // if (IsLitState(state)) // = 18.new

>

> +    if (IsLitState(state)) // = 18.new

>

>      if (matchByte =3D=3D = curByte)

>

> -    // if (repMatchPrice < = nextOpt->price) // 18.new

>

> -    if = (nextOpt->len < 2

>

> +    if = (repMatchPrice < nextOpt->price) // 18.new

>

> +    // if = (numAvailFull < 2 || data[1] !=3D *(data - reps[0] + = 1))

> =

> = +    if (

>

> = +        // nextOpt->price >=3D = kInfinityPrice ||

>

> +        = nextOpt->len < 2   // we can check nextOpt->len, if = skip items

> are not allowed in p->opt

>

>          = || (nextOpt->dist !=3D 0

>

> = -            = && nextOpt->extra <=3D 1 // 17.old

>

> = -        ))

>

> = +            // = && nextOpt->extra <=3D 1 // 17.old

>

> = +            = )

> =

> = +        )

>

>      = {

> =

>        UInt32 = shortRepPrice =3D repMatchPrice + GetPrice_ShortRep(p, = state,

> posState);

>

> = -      if (shortRepPrice <=3D = nextOpt->price) // 17.old

>

> = -      // if (shortRepPrice < = nextOpt->price)  // 18.new

>

> = +      // if (shortRepPrice <=3D = nextOpt->price) // 17.old

>

> = +      if (shortRepPrice < = nextOpt->price)  // 18.new

>

>        = {

> =

>          = nextOpt->price =3D shortRepPrice;

>

>          = nextOpt->len =3D 1;

>

> @@ -1436,13 +1553,6 @@ = static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>        = }

> =

>      = }

> =

> =

> =

> = -    numAvailFull =3D = p->numAvail;

>

> -    {

>

> = -      UInt32 temp =3D kNumOpts - 1 - = cur;

>

> -      if (numAvailFull > = temp)

>

> -        = numAvailFull =3D temp;

>

> -    = }

> =

> = -

> =

>      if (numAvailFull < = 2)

> =

>        = continue;

>

>      numAvail =3D = (numAvailFull <=3D p->numFastBytes ? numAvailFull = :

> = p->numFastBytes);

>

> @@ -1451,9 +1561,8 @@ static unsigned = GetOptimum(CLzmaEnc *p, UInt32

> = position)

>

>

>      // ---------- LIT : = REP_0 ----------

>

>

>

> -    if (

>

> = -        // litPrice !=3D 0 = && // 18.new

>

> -        = !nextIsLit

>

> +    if = (!nextIsLit

>

> +        && = litPrice !=3D 0 // 18.new

>

>          = && matchByte !=3D curByte

>

>          = && numAvailFull > 2)

>

>      = {

> =

> @@ = -1465,8 +1574,7 @@ static unsigned GetOptimum(CLzmaEnc *p, = UInt32

> position)

>          = if (limit > numAvailFull)

>

>         &n= bsp;  limit =3D numAvailFull;

>

>         =  for (len =3D 3; len < limit && data[len] =3D=3D = data2[len]; len++)

>

> -        = {

> =

> = -        }

>

> = +        {}

>

>

>

>          = {

> =

>         &n= bsp;  unsigned state2 =3D = kLiteralNextStates[state];

>

> @@ -1474,8 +1582,9 @@ = static unsigned GetOptimum(CLzmaEnc *p, UInt32

> = position)

>         &n= bsp;  UInt32 price =3D litPrice + GetPrice_Rep_0(p, state2, = posState2);

>

>         &n= bsp;  {

>

>         &n= bsp;    unsigned offset =3D cur + = len;

>

> = -            = while (last < offset)

>

> = -            =   p->opt[++last].price =3D = kInfinityPrice;

>

> +

>

> = +            if = (last < offset)

>

> = +            =   last =3D offset;

>

>

>

>         &n= bsp;    // do

>

>         &n= bsp;    {

>

> @@ -1483,14 +1592,14 @@ = static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>         &n= bsp;      COptimal = *opt;

>

>         &n= bsp;      len--;

>

>         &n= bsp;      // price2 =3D price + = GetPrice_Len_Rep_0(p, len, state2,

> = posState2);

>

> = -            =   price2 =3D price + p->repLenEnc.prices[posState2][len = -

> = LZMA_MATCH_LEN_MIN];

>

> = +            =   price2 =3D price + = GET_PRICE_LEN(&p->repLenEnc,

> posState2, = len);

>

>

>

>         &n= bsp;      opt =3D = &p->opt[offset];

>

>         &n= bsp;      // offset--;

>

>         &n= bsp;      if (price2 < = opt->price)

>

>         &n= bsp;      {

>

>         &n= bsp;        opt->price =3D = price2;

>

> = -            =     opt->len =3D len;

>

> = +            =     opt->len =3D (UInt32)len;

>

>         &n= bsp;        opt->dist =3D = 0;

> =

>         &n= bsp;        opt->extra =3D = 1;

> =

>         &n= bsp;      }

>

> @@ -1502,6 +1611,7 @@ = static unsigned GetOptimum(CLzmaEnc *p, UInt32

> = position)

>      = }

> =

> =

> =

>      startLen =3D 2; /* speed = optimization */

>

> +

>

>      = {

> =

>        // = ---------- REP ----------

>

>        unsigned = repIndex =3D 0; // 17.old

>

> @@ -1514,24 +1624,28 @@ = static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>          = if (data[0] !=3D data2[0] || data[1] !=3D = data2[1])

>

>         &n= bsp;  continue;

>

>

>

> -        for (len = =3D 2; len < numAvail && data[len] =3D=3D data2[len]; = len++);

>

> +        for (len = =3D 2; len < numAvail && data[len] =3D=3D data2[len]; = len++)

>

> +        = {}

> =

> =

> =

>          = // if (len < startLen) continue; // 18.new: speed = optimization

>

>

>

> -        while = (last < cur + len)

>

> = -          = p->opt[++last].price =3D kInfinityPrice;

>

> = +        {

>

> = +          unsigned offset = =3D cur + len;

>

> = +          if (last < = offset)

>

> = +            last = =3D offset;

>

> +        = }

> =

>          = {

> =

>         &n= bsp;  unsigned len2 =3D len;

>

>         &n= bsp;  price =3D repMatchPrice + GetPrice_PureRep(p, repIndex, = state,

> posState);

>

>         &n= bsp;  do

>

>         &n= bsp;  {

>

> = -            = UInt32 price2 =3D price +

> = p->repLenEnc.prices[posState][(size_t)len2 - = 2];

> =

> = +            = UInt32 price2 =3D price + = GET_PRICE_LEN(&p->repLenEnc,

> posState, = len2);

>

>         &n= bsp;    COptimal *opt =3D &p->opt[cur + = len2];

>

>         &n= bsp;    if (price2 < = opt->price)

>

>         &n= bsp;    {

>

>         &n= bsp;      opt->price =3D = price2;

>

> = -            =   opt->len =3D len2;

>

> = -            =   opt->dist =3D repIndex;

>

> = +            =   opt->len =3D (UInt32)len2;

>

> = +            =   opt->dist =3D (UInt32)repIndex;

>

>         &n= bsp;      opt->extra =3D = 0;

> =

>         &n= bsp;    }

>

>         &n= bsp;  }

>

> @@ -1551,15 +1665,14 @@ static unsigned = GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>         &n= bsp;  if (limit > numAvailFull)

>

>         &n= bsp;    limit =3D numAvailFull;

>

>

>

> = -          for (; len2 < = limit && data[len2] =3D=3D data2[len2]; = len2++);

>

> -

>

> = -          len2 -=3D = len;

>

> = -          if (len2 >=3D = 3)

> =

> = +          len2 +=3D = 2;

> =

> = +          if (len2 <=3D = limit)

>

> = +          if (data[len2 - = 2] =3D=3D data2[len2 - 2])

>

> = +          if (data[len2 - = 1] =3D=3D data2[len2 - 1])

>

>         &n= bsp;  {

>

>         &n= bsp;    unsigned state2 =3D = kRepNextStates[state];

>

>         &n= bsp;    unsigned posState2 =3D (position + len) & = p->pbMask;

>

> = -            = price +=3D

>

> = -            =       = p->repLenEnc.prices[posState][(size_t)len - = 2]

> =

> = +            = price +=3D GET_PRICE_LEN(&p->repLenEnc, posState, = len)

>

>         &n= bsp;        + = GET_PRICE_0(p->isMatch[state2][posState2])

>

>         &n= bsp;        + = LitEnc_Matched_GetPrice(LIT_PROBS(position + = len,

> data[(size_t)len - 1]),

>

>         &n= bsp;            = data[len], data2[len], p->ProbPrices);

>

> @@ -1570,31 +1683,40 @@ = static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>

>

>

>

>         &n= bsp;    price +=3D GetPrice_Rep_0(p, state2, = posState2);

>

> +

>

> = +          for (; len2 < = limit && data[len2] =3D=3D data2[len2]; = len2++)

>

> = +          = {}

> =

> = +

> =

> = +          len2 -=3D = len;

>

> = +          // if (len2 = >=3D 3)

>

> = +          = {

> =

>         &n= bsp;    {

>

>         &n= bsp;      unsigned offset =3D cur + len + = len2;

>

> = -            =   while (last < offset)

>

> = -            =     p->opt[++last].price =3D = kInfinityPrice;

>

> +

>

> = +            =   if (last < offset)

>

> = +            =     last =3D offset;

>

>         &n= bsp;      // do

>

>         &n= bsp;      {

>

> = -            =     unsigned price2;

>

> = +            =     UInt32 price2;

>

>         &n= bsp;        COptimal = *opt;

>

>         &n= bsp;        = len2--;

>

>         &n= bsp;        // price2 =3D price + = GetPrice_Len_Rep_0(p, len2, state2,

> = posState2);

>

> = -            =     price2 =3D price + = p->repLenEnc.prices[posState2][len2 -

> = LZMA_MATCH_LEN_MIN];

>

> = +            =     price2 =3D price + = GET_PRICE_LEN(&p->repLenEnc,

> posState2, = len2);

>

>

>

>         &n= bsp;        opt =3D = &p->opt[offset];

>

>         &n= bsp;        // = offset--;

>

>         &n= bsp;        if (price2 < = opt->price)

>

>         &n= bsp;        {

>

>         &n= bsp;          opt->price = =3D price2;

>

> = -            =       opt->len =3D = len2;

>

> = +            =       opt->len =3D = (UInt32)len2;

>

>         &n= bsp;          opt->extra = =3D (CExtra)(len + 1);

>

> = -            =       opt->dist =3D = repIndex;

>

> = +            =       opt->dist =3D = (UInt32)repIndex;

>

>         &n= bsp;        }

>

>         &n= bsp;      }

>

>         &n= bsp;      // while (len2 >=3D = 3);

> =

>         &n= bsp;    }

>

>         &n= bsp;  }

>

> = +          = }

> =

>          = }

> =

>        = }

> =

>      = }

> =

> @@ = -1606,17 +1728,23 @@ static unsigned GetOptimum(CLzmaEnc = *p,

> = UInt32 position)

>      = {

> =

>        newLen =3D = numAvail;

>

>        for = (numPairs =3D 0; newLen > matches[numPairs]; numPairs +=3D = 2);

> =

> = -      matches[numPairs] =3D = newLen;

>

> +      matches[numPairs] =3D = (UInt32)newLen;

>

>        numPairs = +=3D 2;

>

>      = }

> =

> =

> =

> = +    // startLen =3D 2; /* speed optimization = */

> =

> = +

> =

>      if (newLen >=3D = startLen)

>

>      = {

> =

>        UInt32 = normalMatchPrice =3D matchPrice +

> = GET_PRICE_0(p->isRep[state]);

>

>        UInt32 = dist;

>

>        unsigned = offs, posSlot, len;

>

> -      while (last < cur + = newLen)

>

> -        = p->opt[++last].price =3D kInfinityPrice;

>

> +

>

> = +      {

>

> = +        unsigned offset =3D cur + = newLen;

>

> +        if (last = < offset)

>

> = +          last =3D = offset;

>

> +      = }

> =

> =

> =

>        offs =3D = 0;

> =

>        while = (startLen > matches[offs])

>

> @@ -1628,27 +1756,29 @@ = static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>

>

>        for (len =3D = /*2*/ startLen; ; len++)

>

>        = {

> =

> = -        UInt32 price =3D = normalMatchPrice +

> p->lenEnc.prices[posState][(size_t)len - = LZMA_MATCH_LEN_MIN];

>

> +        UInt32 = price =3D normalMatchPrice + = GET_PRICE_LEN(&p->lenEnc,

> posState, = len);

>

>          = {

> =

>         &n= bsp;  COptimal *opt;

>

> -  =         unsigned lenToPosState = =3D len - 2; lenToPosState =3D

> = GetLenToPosState2(lenToPosState);

>

> = +          unsigned lenNorm = =3D len - 2;

>

> = +          lenNorm =3D = GetLenToPosState2(lenNorm);

>

>         &n= bsp;  if (dist < kNumFullDistances)

>

> = -            = price +=3D p->distancesPrices[lenToPosState][dist = &

> (kNumFullDistances - 1)];

>

> = +            = price +=3D p->distancesPrices[lenNorm][dist = &

> (kNumFullDistances - 1)];

>

>         &n= bsp;  else

>

> = -            = price +=3D p->posSlotPrices[lenToPosState][posSlot] = +

> = p->alignPrices[dist & kAlignMask];

>

> = +            = price +=3D p->posSlotPrices[lenNorm][posSlot] = +

> = p->alignPrices[dist & kAlignMask];

>

>

>

>         &n= bsp;  opt =3D &p->opt[cur + len];

>

>         &n= bsp;  if (price < opt->price)

>

>         &n= bsp;  {

>

>         &n= bsp;    opt->price =3D price;

>

> = -            = opt->len =3D len;

>

> = +            = opt->len =3D (UInt32)len;

>

>         &n= bsp;    opt->dist =3D dist + = LZMA_NUM_REPS;

>

>         &n= bsp;    opt->extra =3D 0;

>

>         &n= bsp;  }

>

>          = }

> =

> =

> =

> = -        if (/*_maxMode && */ = len =3D=3D matches[offs])

>

> = +        if (len =3D=3D = matches[offs])

>

>          = {

> =

> = +          // if = (p->_maxMode) {

>

>         &n= bsp;  // MATCH : LIT : REP_0

>

>

>

>         &n= bsp;  const Byte *data2 =3D data - dist - = 1;

> =

> @@ = -1657,11 +1787,17 @@ static unsigned GetOptimum(CLzmaEnc = *p,

> = UInt32 position)

>         &n= bsp;  if (limit > numAvailFull)

>

>         &n= bsp;    limit =3D numAvailFull;

>

>

>

> = -          for (; len2 < = limit && data[len2] =3D=3D data2[len2]; = len2++);

>

> = +          len2 +=3D = 2;

> =

> = +          if (len2 <=3D = limit)

>

> = +          if (data[len2 - = 2] =3D=3D data2[len2 - 2])

>

> = +          if (data[len2 - = 1] =3D=3D data2[len2 - 1])

>

> = +          = {

> =

> = +          for (; len2 < = limit && data[len2] =3D=3D data2[len2]; = len2++)

>

> = +          = {}

> =

> =

> =

>         &n= bsp;  len2 -=3D len;

>

>

>

> = -          if (len2 >=3D = 3)

> =

> = +          // if (len2 = >=3D 3)

>

>         &n= bsp;  {

>

>         &n= bsp;    unsigned state2 =3D = kMatchNextStates[state];

>

>         &n= bsp;    unsigned posState2 =3D (position + len) & = p->pbMask;

>

> @@ -1677,27 +1813,30 @@ static unsigned = GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>         &n= bsp;    price +=3D GetPrice_Rep_0(p, state2, = posState2);

>

>

>

>         &n= bsp;    offset =3D cur + len + = len2;

>

> = -            = while (last < offset)

>

> = -            =   p->opt[++last].price =3D = kInfinityPrice;

>

> +

>

> = +            if = (last < offset)

>

> = +            =   last =3D offset;

>

>         &n= bsp;    // do

>

>         &n= bsp;    {

>

>         &n= bsp;      UInt32 = price2;

>

>         &n= bsp;      COptimal = *opt;

>

>         &n= bsp;      len2--;

>

>         &n= bsp;      // price2 =3D price + = GetPrice_Len_Rep_0(p, len2, state2,

> = posState2);

>

> = -            =   price2 =3D price + p->repLenEnc.prices[posState2][len2 = -

> = LZMA_MATCH_LEN_MIN];

>

> = +            =   price2 =3D price + = GET_PRICE_LEN(&p->repLenEnc,

> posState2, = len2);

>

>         &n= bsp;      opt =3D = &p->opt[offset];

>

>         &n= bsp;      // offset--;

>

>         &n= bsp;      if (price2 < = opt->price)

>

>         &n= bsp;      {

>

>         &n= bsp;        opt->price =3D = price2;

>

> = -            =     opt->len =3D len2;

>

> = +            =     opt->len =3D (UInt32)len2;

>

>         &n= bsp;        opt->extra =3D = (CExtra)(len + 1);

>

>         &n= bsp;        opt->dist =3D dist + = LZMA_NUM_REPS;

>

>         &n= bsp;      }

>

>         &n= bsp;    }

>

>         &n= bsp;    // while (len2 >=3D = 3);

> =

>         &n= bsp;  }

>

> +

>

> = +          = }

> =

> =

> =

>         &n= bsp;  offs +=3D 2;

>

>         &n= bsp;  if (offs =3D=3D numPairs)

>

> @@ -1709,6 +1848,12 @@ = static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 = position)

>        = }

> =

>      = }

> =

>    }

>

> +

>

> +  = do

> =

> = +    p->opt[last].price =3D = kInfinityPrice;

>

> +  while (--last);

>

> +

>

> +  return Backward(p, = cur);

>

>  }

>

>

>

>

>

> @@ -1735,6 +1880,7 @@ = static unsigned GetOptimumFast(CLzmaEnc *p)

>    = p->backRes =3D MARK_LIT;

>

>    if = (numAvail < 2)

>

>      return = 1;

> =

> = +  // if (mainLen < 2 && p->state =3D=3D 0) return 1; = // 18.06.notused

>

>    if (numAvail > = LZMA_MATCH_LEN_MAX)

>

>      numAvail =3D = LZMA_MATCH_LEN_MAX;

>

>    data =3D = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - = 1;

> =

> @@ = -1746,10 +1892,11 @@ static unsigned GetOptimumFast(CLzmaEnc = *p)

>      const Byte *data2 =3D = data - p->reps[i];

>

>      if (data[0] !=3D = data2[0] || data[1] !=3D data2[1])

>

>        = continue;

>

> -    for (len =3D 2; len < numAvail = && data[len] =3D=3D data2[len]; len++);

>

> +    for = (len =3D 2; len < numAvail && data[len] =3D=3D data2[len]; = len++)

>

> +    {}

>

>      if (len >=3D = p->numFastBytes)

>

>      = {

> =

> = -      p->backRes =3D = i;

> =

> = +      p->backRes =3D = (UInt32)i;

>

>        MOVE_POS(p, = len - 1)

>

>        return = len;

>

>      = }

> =

> @@ = -1793,7 +1940,7 @@ static unsigned GetOptimumFast(CLzmaEnc = *p)

>          = || (repLen + 2 >=3D mainLen && mainDist >=3D (1 << = 9))

> =

>          = || (repLen + 3 >=3D mainLen && mainDist >=3D (1 << = 15)))

>

>    {

>

> -    = p->backRes =3D repIndex;

>

> +    = p->backRes =3D (UInt32)repIndex;

>

>      MOVE_POS(p, repLen - = 1)

> =

>      return = repLen;

>

>    }

>

> @@ -1932,23 +2079,22 @@ = MY_NO_INLINE static SRes Flush(CLzmaEnc *p,

> UInt32 = nowPos)

>  }

>

>

>

>

>

> -

>

> -static void = FillAlignPrices(CLzmaEnc *p)

>

> +MY_NO_INLINE static void = FillAlignPrices(CLzmaEnc *p)

>

>  = {

> =

>    unsigned i;

>

>    const = CProbPrice *ProbPrices =3D p->ProbPrices;

>

>    const = CLzmaProb *probs =3D p->posAlignEncoder;

>

> -  = p->alignPriceCount =3D 0;

>

> +  // = p->alignPriceCount =3D 0;

>

>    for (i = =3D 0; i < kAlignTableSize / 2; i++)

>

>    = {

> =

>      UInt32 price =3D = 0;

> =

> = -    unsigned symbol =3D i;

>

> +    = unsigned sym =3D i;

>

>      unsigned m =3D = 1;

> =

>      unsigned = bit;

>

>      UInt32 = prob;

>

> -    bit =3D symbol & 1; symbol = >>=3D 1; price +=3D GET_PRICEa(probs[m], bit); = m

=3D

> (m << 1) + bit;

>

> -    bit =3D = symbol & 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[m], = bit); m

=3D

> (m << 1) + bit;

>

> -    bit =3D = symbol & 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[m], = bit); m

=3D

> (m << 1) + bit;

>

> +    bit =3D = sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[m], bit); m = =3D (m

> << 1) + bit;

>

> +    bit =3D = sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[m], bit); m = =3D (m

> << 1) + bit;

>

> +    bit =3D = sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[m], bit); m = =3D (m

> << 1) + bit;

>

>      prob =3D = probs[m];

>

>      = p->alignPrices[i    ] =3D price + = GET_PRICEa_0(prob);

>

>      p->alignPrices[i + 8] = =3D price + GET_PRICEa_1(prob);

>

> @@ -1957,78 +2103,97 @@ = static void FillAlignPrices(CLzmaEnc *p)

>  = }

> =

> =

> =

> =

> =

> = -static void FillDistancesPrices(CLzmaEnc *p)

>

> +MY_NO_INLINE static void = FillDistancesPrices(CLzmaEnc *p)

>

>  = {

> =

> = +  // int y; for (y =3D 0; y < 100; y++) = {

> =

> = +

> =

>    UInt32 = tempPrices[kNumFullDistances];

>

> -  unsigned i, = lenToPosState;

>

> +  unsigned i, lps;

>

>

>

>    const = CProbPrice *ProbPrices =3D p->ProbPrices;

>

>    = p->matchPriceCount =3D 0;

>

>

>

> -  for (i =3D = kStartPosModelIndex; i < kNumFullDistances; = i++)

>

> +  for (i =3D kStartPosModelIndex / 2; i < = kNumFullDistances / 2; i++)

>

>    = {

> =

>      unsigned posSlot =3D = GetPosSlot1(i);

>

> -    unsigned footerBits =3D ((posSlot = >> 1) - 1);

>

> +    unsigned footerBits =3D (posSlot = >> 1) - 1;

>

>      unsigned base =3D ((2 | = (posSlot & 1)) << footerBits);

>

> +    const = CLzmaProb *probs =3D p->posEncoders + (size_t)base * = 2;

> =

>      // tempPrices[i] =3D = RcTree_ReverseGetPrice(p->posEncoders + base,

> footerBits, i - base, = p->ProbPrices);

>

> -

>

> -    const CLzmaProb *probs =3D = p->posEncoders + base;

>

>      UInt32 price =3D = 0;

> =

>      unsigned m =3D = 1;

> =

> = -    unsigned symbol =3D i - = base;

>

> +    unsigned sym =3D = i;

> =

> = +    unsigned offset =3D (unsigned)1 << = footerBits;

>

> +    base +=3D = i;

> =

> = +

> =

> = +    if (footerBits)

>

>      = do

> =

>      = {

> =

> = -      unsigned bit =3D symbol & = 1;

> =

> = -      symbol >>=3D = 1;

> =

> = +      unsigned bit =3D sym & = 1;

> =

> = +      sym >>=3D = 1;

> =

>        price +=3D = GET_PRICEa(probs[m], bit);

>

>        m =3D (m = << 1) + bit;

>

>      = }

> =

>      while = (--footerBits);

>

> -    tempPrices[i] =3D = price;

>

> +

>

> +    {

>

> = +      unsigned prob =3D = probs[m];

>

> +      = tempPrices[base         ] =3D = price + GET_PRICEa_0(prob);

>

> = +      tempPrices[base + offset] =3D price + = GET_PRICEa_1(prob);

>

> +    }

>

>    = }

> =

> =

> =

> = -  for (lenToPosState =3D 0; lenToPosState < = kNumLenToPosStates;

> lenToPosState++)

>

> +  for (lps =3D 0; lps = < kNumLenToPosStates; lps++)

>

>    = {

> =

> = -    unsigned posSlot;

>

> -    const = CLzmaProb *encoder =3D = p->posSlotEncoder[lenToPosState];

>

> -    UInt32 = *posSlotPrices =3D = p->posSlotPrices[lenToPosState];

>

> -    = unsigned distTableSize =3D p->distTableSize;

>

> -    const = CLzmaProb *probs =3D encoder;

>

> -    for = (posSlot =3D 0; posSlot < distTableSize; posSlot +=3D = 2)

> =

> = +    unsigned slot;

>

> +    = unsigned distTableSize2 =3D (p->distTableSize + 1) >> = 1;

> =

> = +    UInt32 *posSlotPrices =3D = p->posSlotPrices[lps];

>

> +    const = CLzmaProb *probs =3D p->posSlotEncoder[lps];

>

> +

>

> +    for = (slot =3D 0; slot < distTableSize2; slot++)

>

>      = {

> =

> = -      // posSlotPrices[posSlot] =3D = RcTree_GetPrice(encoder,

> kNumPosSlotBits, posSlot, = p->ProbPrices);

>

> -      UInt32 price =3D = 0;

> =

> = +      // posSlotPrices[slot] =3D = RcTree_GetPrice(encoder, kNumPosSlotBits,

> slot, = p->ProbPrices);

>

> +      UInt32 = price;

>

>        unsigned = bit;

>

> -      unsigned symbol =3D = (posSlot >> 1) + (1 << (kNumPosSlotBits - = 1));

>

> -      UInt32 = prob;

>

> -      bit =3D symbol & = 1; symbol >>=3D 1; price +=3D = GET_PRICEa(probs[symbol],

> = bit);

>

> -      bit =3D symbol & = 1; symbol >>=3D 1; price +=3D = GET_PRICEa(probs[symbol],

> = bit);

>

> -      bit =3D symbol & = 1; symbol >>=3D 1; price +=3D = GET_PRICEa(probs[symbol],

> = bit);

>

> -      bit =3D symbol & = 1; symbol >>=3D 1; price +=3D = GET_PRICEa(probs[symbol],

> = bit);

>

> -      bit =3D symbol & = 1; symbol >>=3D 1; price +=3D = GET_PRICEa(probs[symbol],

> = bit);

>

> -      prob =3D = probs[(posSlot >> 1) + (1 << (kNumPosSlotBits - = 1))];

>

> - =      posSlotPrices[posSlot    ] = =3D price + GET_PRICEa_0(prob);

>

> = -      posSlotPrices[posSlot + 1] =3D price + = GET_PRICEa_1(prob);

>

> +      unsigned sym =3D slot = + (1 << (kNumPosSlotBits - 1));

>

> = +      unsigned prob;

>

> = +      bit =3D sym & 1; sym >>=3D 1; = price  =3D GET_PRICEa(probs[sym], bit);

>

> = +      bit =3D sym & 1; sym >>=3D 1; = price +=3D GET_PRICEa(probs[sym], bit);

>

> = +      bit =3D sym & 1; sym >>=3D 1; = price +=3D GET_PRICEa(probs[sym], bit);

>

> = +      bit =3D sym & 1; sym >>=3D 1; = price +=3D GET_PRICEa(probs[sym], bit);

>

> = +      bit =3D sym & 1; sym >>=3D 1; = price +=3D GET_PRICEa(probs[sym], bit);

>

> = +      prob =3D probs[(size_t)slot + (1 = << (kNumPosSlotBits - 1))];

>

> = +      posSlotPrices[(size_t)slot * = 2    ] =3D price + = GET_PRICEa_0(prob);

>

> +      = posSlotPrices[(size_t)slot * 2 + 1] =3D price + = GET_PRICEa_1(prob);

>

>      = }

> =

> = -    for (posSlot =3D kEndPosModelIndex; posSlot < = distTableSize; posSlot++)

>

> = -      posSlotPrices[posSlot] +=3D = ((UInt32)(((posSlot >> 1) - 1) -

> kNumAlignBits) << = kNumBitPriceShiftBits);

>

> -

>

> +

>

>      = {

> =

> = -      UInt32 *distancesPrices =3D = p->distancesPrices[lenToPosState];

>

> = +      UInt32 delta =3D = ((UInt32)((kEndPosModelIndex / 2 - 1) -

> kNumAlignBits) << = kNumBitPriceShiftBits);

>

> = +      for (slot =3D kEndPosModelIndex / 2; = slot < distTableSize2; slot++)

>

>        = {

> =

> = -        distancesPrices[0] =3D = posSlotPrices[0];

>

> -        = distancesPrices[1] =3D posSlotPrices[1];

>

> = -        distancesPrices[2] =3D = posSlotPrices[2];

>

> -        = distancesPrices[3] =3D posSlotPrices[3];

>

> = +        posSlotPrices[(size_t)slot * = 2    ] +=3D delta;

>

> = +        posSlotPrices[(size_t)slot * = 2 + 1] +=3D delta;

>

> +        delta +=3D = ((UInt32)1 << kNumBitPriceShiftBits);

>

>        = }

> =

> = +    }

>

> +

>

> +    {

>

> = +      UInt32 *dp =3D = p->distancesPrices[lps];

>

> +

>

> = +      dp[0] =3D = posSlotPrices[0];

>

> +      dp[1] =3D = posSlotPrices[1];

>

> +      dp[2] =3D = posSlotPrices[2];

>

> +      dp[3] =3D = posSlotPrices[3];

>

> +

>

>        for (i =3D = 4; i < kNumFullDistances; i +=3D 2)

>

>        = {

> =

>          = UInt32 slotPrice =3D = posSlotPrices[GetPosSlot1(i)];

>

> = -        = distancesPrices[i    ] =3D slotPrice + = tempPrices[i];

>

> -        = distancesPrices[i + 1] =3D slotPrice + tempPrices[i + = 1];

> =

> = +        dp[i    ] =3D = slotPrice + tempPrices[i];

>

> = +        dp[i + 1] =3D slotPrice + = tempPrices[i + 1];

>

>        = }

> =

>      = }

> =

>    }

>

> +  // = }

> =

>  }

>

>

>

>

>

> @@ -2245,10 +2410,7 @@ = static SRes LzmaEnc_CodeOneBlock(CLzmaEnc

> *p, UInt32 maxPackSize, = UInt32 maxUnpa

>          = if (len !=3D 1)

>

>          = {

> =

>         &n= bsp;  LenEnc_Encode(&p->repLenProbs, &p->rc, len = -

> = LZMA_MATCH_LEN_MIN, posState);

>

> = -          if = (!p->fastMode)

>

> = -            if = (--p->repLenEnc.counters[posState] =3D=3D 0)

>

> = -            =   LenPriceEnc_UpdateTable(&p->repLenEnc, = posState,

> &p->repLenProbs, = p->ProbPrices);

>

> -

>

> = +          = --p->repLenEncCounter;

>

>         &n= bsp;  p->state =3D = kRepNextStates[p->state];

>

>          = }

> =

>        = }

> =

> @@ = -2260,9 +2422,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc = *p,

> = UInt32 maxPackSize, UInt32 maxUnpa

>          = p->state =3D kMatchNextStates[p->state];

>

>

>

>          = LenEnc_Encode(&p->lenProbs, &p->rc, len = -

> = LZMA_MATCH_LEN_MIN, posState);

>

> = -        if = (!p->fastMode)

>

> = -          if = (--p->lenEnc.counters[posState] =3D=3D 0)

>

> = -            = LenPriceEnc_UpdateTable(&p->lenEnc, = posState,

> &p->lenProbs, = p->ProbPrices);

>

> +        // = --p->lenEnc.counter;

>

>

>

>          = dist -=3D LZMA_NUM_REPS;

>

>          = p->reps[3] =3D p->reps[2];

>

> @@ -2274,17 +2434,17 @@ = static SRes LzmaEnc_CodeOneBlock(CLzmaEnc

> *p, UInt32 maxPackSize, = UInt32 maxUnpa

>          = GetPosSlot(dist, posSlot);

>

>          = // RcTree_Encode_PosSlot(&p->rc,

> = p->posSlotEncoder[GetLenToPosState(len)], = posSlot);

>

>          = {

> =

> = -          UInt32 symbol = =3D posSlot + (1 << kNumPosSlotBits);

>

> = +          UInt32 sym =3D = (UInt32)posSlot + (1 << kNumPosSlotBits);

>

>         &n= bsp;  range =3D p->rc.range;

>

>         &n= bsp;  probs =3D = p->posSlotEncoder[GetLenToPosState(len)];

>

>         &n= bsp;  do

>

>         &n= bsp;  {

>

> = -            = CLzmaProb *prob =3D probs + (symbol >> = kNumPosSlotBits);

>

> = -            = UInt32 bit =3D (symbol >> (kNumPosSlotBits - 1)) & = 1;

> =

> = -            = symbol <<=3D 1;

>

> = +            = CLzmaProb *prob =3D probs + (sym >> = kNumPosSlotBits);

>

> = +            = UInt32 bit =3D (sym >> (kNumPosSlotBits - 1)) & = 1;

> =

> = +            sym = <<=3D 1;

>

>         &n= bsp;    RC_BIT(&p->rc, prob, = bit);

>

>         &n= bsp;  }

>

> = -          while (symbol = < (1 << kNumPosSlotBits * 2));

>

> = +          while (sym < = (1 << kNumPosSlotBits * 2));

>

>         &n= bsp;  p->rc.range =3D range;

>

>          = }

> =

> =

> =

> @@ = -2295,7 +2455,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc = *p,

> = UInt32 maxPackSize, UInt32 maxUnpa

>         &n= bsp;  if (dist < kNumFullDistances)

>

>         &n= bsp;  {

>

>         &n= bsp;    unsigned base =3D ((2 | (posSlot & 1)) = << footerBits);

>

> = -            = RcTree_ReverseEncode(&p->rc, p->posEncoders + = base,

> footerBits, dist - base);

>

> = +            = RcTree_ReverseEncode(&p->rc, p->posEncoders + = base,

> footerBits, (unsigned)(dist /* - base = */));

>

>         &n= bsp;  }

>

>         &n= bsp;  else

>

>         &n= bsp;  {

>

> @@ -2331,14 +2491,14 @@ static SRes = LzmaEnc_CodeOneBlock(CLzmaEnc

> *p, UInt32 maxPackSize, = UInt32 maxUnpa

>         &n= bsp;      bit =3D dist & 1; dist = >>=3D 1; RC_BIT(&p->rc,

> p->posAlignEncoder + m, = bit); m =3D (m << 1) + bit;

>

>         &n= bsp;      bit =3D dist & = 1;            = ; RC_BIT(&p->rc,

> p->posAlignEncoder + m, = bit);

>

>         &n= bsp;      p->rc.range =3D = range;

>

> = -            =   p->alignPriceCount++;

>

> = +            =   // p->alignPriceCount++;

>

>         &n= bsp;    }

>

>         &n= bsp;  }

>

>          = }

> =

>        = }

> =

>      = }

> =

> =

> =

> = -    nowPos32 +=3D len;

>

> +    = nowPos32 +=3D (UInt32)len;

>

>      p->additionalOffset = -=3D len;

>

>

>

>      if = (p->additionalOffset =3D=3D 0)

>

> @@ -2347,10 +2507,27 @@ = static SRes LzmaEnc_CodeOneBlock(CLzmaEnc

> *p, UInt32 maxPackSize, = UInt32 maxUnpa

>

>

>        if = (!p->fastMode)

>

>        = {

> =

> = -        if (p->matchPriceCount = >=3D (1 << 7))

>

> = +        /*

>

> = +        if (p->alignPriceCount = >=3D 16) // kAlignTableSize

>

> = +          = FillAlignPrices(p);

>

> +        if = (p->matchPriceCount >=3D 128)

>

>         &n= bsp;  FillDistancesPrices(p);

>

> -  =       if (p->alignPriceCount >=3D = kAlignTableSize)

>

> +        if = (p->lenEnc.counter <=3D 0)

>

> = +          = LenPriceEnc_UpdateTables(&p->lenEnc, 1 << = p->pb,

> &p->lenProbs, = p->ProbPrices);

>

> +        = */

> =

> = +        if (p->matchPriceCount = >=3D 64)

>

> + =        {

>

>         &n= bsp;  FillAlignPrices(p);

>

> = +          // { int y; for = (y =3D 0; y < 100; y++) {

>

> = +          = FillDistancesPrices(p);

>

> = +          // = }}

> =

> = +          = LenPriceEnc_UpdateTables(&p->lenEnc, 1 << = p->pb,

> &p->lenProbs, = p->ProbPrices);

>

> +        = }

> =

> = +        if (p->repLenEncCounter = <=3D 0)

>

> +        = {

> =

> = +          = p->repLenEncCounter =3D REP_LEN_COUNT;

>

> = +          = LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << = p->pb,

> &p->repLenProbs, = p->ProbPrices);

>

> +        = }

> =

>        = }

> =

> =

> =

>        if = (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) =3D=3D = 0)

> =

> @@ = -2490,12 +2667,19 @@ void LzmaEnc_Init(CLzmaEnc = *p)

> =

> =

>    p->optEnd =3D = 0;

> =

>    p->optCur =3D = 0;

> =

> = +

> =

> = +  {

>

> +    for (i =3D 0; i < kNumOpts; = i++)

>

> +      p->opt[i].price =3D = kInfinityPrice;

>

> +  }

>

> +

>

>    = p->additionalOffset =3D 0;

>

>

>

>    = p->pbMask =3D (1 << p->pb) - 1;

>

>    = p->lpMask =3D ((UInt32)0x100 << p->lp) - ((unsigned)0x100 = >> p->lc);

>

>  }

>

>

>

> +

>

>  void = LzmaEnc_InitPrices(CLzmaEnc *p)

>

>  = {

> =

>    if = (!p->fastMode)

>

> @@ -2507,6 +2691,9 @@ void LzmaEnc_InitPrices(CLzmaEnc = *p)

>    p->lenEnc.tableSize = =3D

> =

>    p->repLenEnc.tableSize = =3D

> =

>        = p->numFastBytes + 1 - LZMA_MATCH_LEN_MIN;

>

> +

>

> +  = p->repLenEncCounter =3D REP_LEN_COUNT;

>

> +

>

>    = LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, = &p->lenProbs,

> p->ProbPrices);

>

>    = LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, = &p->repLenProbs,

> = p->ProbPrices);

>

>  }

>

> @@ -2583,7 +2770,7 @@ = typedef struct

>    ISeqOutStream = vt;

> =

>    Byte *data;

>

>    SizeT = rem;

>

> -  Bool overflow;

>

> +  BoolInt = overflow;

>

>  } = CLzmaEnc_SeqOutStreamBuf;

>

>

>

>  static size_t = SeqOutStreamBuf_Write(const ISeqOutStream *pp, const = void

> *data, size_t size)

>

> @@ -2615,7 +2802,7 @@ const = Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle

> pp)

>  = }

> =

> =

> =

> =

> =

> = -SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool = reInit,

>

> +SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, = BoolInt reInit,

>

>      Byte *dest, size_t = *destLen, UInt32 desiredPackSize, UInt32

> = *unpackSize)

>

>  {

>

>    CLzmaEnc = *p =3D (CLzmaEnc *)pp;

>

> diff --git = a/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt

> = b/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt

> index = d7426d38a4..04f9d98e7d 100644

> --- = a/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt

> +++ = b/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt

> @@ -1,6 +1,28 = @@

>  HISTORY of the LZMA SDK

>

>  = -----------------------

>

>

>

> = +19.00          = 2019-02-21

>

> +-------------------------

>

> +- Encryption strength for = 7z archives was increased:

>

> +  the size of random = initialization vector was increased from 64-bit = to

> = 128-bit,

>

> +  and the pseudo-random number generator was = improved.

>

> +- The bug in 7zIn.c code was = fixed.

>

> +

>

> +

>

> = +18.06          = 2018-12-30

>

> +-------------------------

>

> +- The speed for LZMA/LZMA2 = compressing was increased by 3-10%,

>

> +  and there are minor = changes in compression ratio.

>

> +- Some bugs were = fixed.

>

> +- The bug in 7-Zip 18.02-18.05 was = fixed:

>

> +  There was memory leak in multithreading xz = decoder -

> XzDecMt_Decode(),

>

> +  if xz stream = contains only one block.

>

> +- The changes for MSVS = compiler makefiles:

>

> +   - the makefiles now use = "PLATFORM" macroname with values (x64, = x86,

> arm64)

>

> +     = instead of "CPU" macroname with values (AMD64, = ARM64).

>

> +   - the makefiles by default now use = static version of the run-time

library.

>

> +

>

> +

>

>  = 18.05          = 2018-04-30

>

>  = -------------------------

>

>  - The speed for = LZMA/LZMA2 compressing was increased

>

> diff --git = a/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-sdk.txt<= /p>

> = b/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-sdk.txt<= /p>

> index = a3deb20943..e17cd4fe1a 100644

> --- = a/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-sdk.txt<= /p>

> +++ = b/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-sdk.txt<= /p>

> @@ -1,4 +1,4 = @@

> = -LZMA SDK 18.05

>

> +LZMA SDK 19.00

>

>  = --------------

>

>

>

>  LZMA SDK provides the documentation, samples, = header files,

>

> --

> 2.27.0.windows.1

 

 

 

------=_NextPart_000_0122_01D6D779.283847C0--