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.web09.5131.1608772438889021982 for ; Wed, 23 Dec 2020 17:14:02 -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 ; Thu, 24 Dec 2020 09:13:53 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: , Cc: "'Laszlo Ersek'" References: <20201215020651.1912-1-weix.c.liu@intel.com> <002101d6d414$25881cc0$70985640$@byosoft.com.cn> <012101d6d736$19e74100$4db5c300$@byosoft.com.cn> In-Reply-To: Subject: =?UTF-8?B?5Zue5aSNOiBbZWRrMi1kZXZlbF0gW1BBVENIIDEvMl0gQmFzZVRvb2xzIEx6bWFDb21wcmVzczogVXBkYXRlIExaTUEgdG8gbmV3IDE5LjAwIHZlcnNpb24=?= Date: Thu, 24 Dec 2020 09:13:55 +0800 Message-ID: <00e101d6d992$0cfa6f40$26ef4dc0$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQJlp24ulGDDLEBUgWRGrTLtaL2vYgE4s0rQAXIdIN0DXDytDgEtnT33qK4voiA= Content-Type: multipart/alternative; boundary="----=_NextPart_000_00E2_01D6D9D5.1B4B4EF0" Content-Language: zh-cn ------=_NextPart_000_00E2_01D6D9D5.1B4B4EF0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I have no other comments. Reviewed-by: Liming Gao =20 =E5=8F=91=E4=BB=B6=E4=BA=BA: bounce+27952+69316+4905953+8761045@groups.io = =E4=BB=A3=E8=A1=A8 Liu, WeiX= C =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2020=E5=B9=B412=E6=9C=8821=E6=97=A5 = 15:26 =E6=94=B6=E4=BB=B6=E4=BA=BA: gaoliming ; devel@e= dk2.groups.io =E6=8A=84=E9=80=81: 'Laszlo Ersek' =E4=B8=BB=E9=A2=98: Re: [edk2-devel] [PATCH 1/2] BaseTools LzmaCompress: U= pdate LZMA to new 19.00 version =20 Yes. Liming, I have also checked boot functionality (boot to shell) and im= age size. All pass and no size change. =20 For windows: Base e6ae24e1d676bb2bdc0fc715b49b04908f41fc10 For linux: Base e6ae24e1d676bb2bdc0fc715b49b04908f41fc10 =20 Thanks & BRs, LIUWEI =20 From: gaoliming >=20 Sent: 2020=E5=B9=B412=E6=9C=8821=E6=97=A5 9:11 To: Liu, WeiX C >; dev= el@edk2.groups.io =20 Cc: 'Laszlo Ersek' > Subject: =E5=9B=9E=E5=A4=8D: [PATCH 1/2] BaseTools LzmaCompress: Update LZ= MA to new 19.00 version =20 Do you verify the boot functionality (boot to shell)? Do you collect the i= mage 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 =20 =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 >; dev= el@edk2.groups.io =20 Cc: 'Laszlo Ersek' > Subject: =E5=9B=9E=E5=A4=8D: [PATCH 1/2] BaseTools LzmaCompress: Update LZ= MA to new 19.00 version =20 Wei: Can you list the unit test for this patch? Which tool chain and arch hav= e 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 Er= sek > > =E4=B8=BB=E9=A2=98: [PATCH 1/2] BaseTools LzmaCompress: Update LZMA to n= ew 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 + ((del= ta > > _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 po= s, > 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 + ((del= ta > > _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 (cod= e << 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 (CLzmaP= rob)(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 (ran= ge >> > kNumBitModelTotalBits) * ttt; if (code < bound) >=20 > +#define IF_BIT_0_CHECK(p) ttt =3D *(p); NORMALIZE_CHECK; bound =3D (ran= ge >> > 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 - tt= t) >> > 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) + (symb= ol >>=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))) & (kBitModelTot= al - > 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))) & (kBitModelTot= al - > 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]; le= n++); >=20 > + for (len =3D 2; len < numAvail && data[len] =3D=3D data2[len]; le= n++) >=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, posSta= te); >=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, sta= te, > 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, posStat= e2); >=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, state= 2, > 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, kNumPosSlotBi= ts, > 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[s= ymbol], > bit); >=20 > - bit =3D symbol & 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[s= ymbol], > bit); >=20 > - bit =3D symbol & 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[s= ymbol], > bit); >=20 > - bit =3D symbol & 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[s= ymbol], > bit); >=20 > - bit =3D symbol & 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[s= ymbol], > 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], b= it); >=20 > + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[sym], b= it); >=20 > + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[sym], b= it); >=20 > + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[sym], b= it); >=20 > + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[sym], b= it); >=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; posSlo= t++) >=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_00E2_01D6D9D5.1B4B4EF0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

I have no other comments. Reviewed-by: Liming Gao= <gaoliming@byosoft.com.cn>

 

=E5=8F=91=E4=BB=B6=E4=BA=BA: bounce+27952+69316+4905953+8761045@groups.io <boun= ce+27952+69316+4905953+8761045@groups.io> =E4=BB=A3=E8=A1=A8 Liu, WeiX C
=E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4= : 2020=E5=B9=B412=E6=9C=882= 1=E6=97=A5 15:26
=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: [edk2-devel] [PATCH 1/2] BaseTools Lz= maCompress: Update LZMA to new 19.00 version

 <= /p>

Yes. Liming, I have also checked= boot functionality (boot to shell) and image size. All pass and no size ch= ange.

&nb= sp;

For windows: Ba= se e6ae24e1d676bb2bdc0fc715b49b04908f41fc10

For linux: Base e6ae2= 4e1d676bb2bdc0fc715b49b04908f41fc10

 

Thanks & BRs,

= LIUWEI

 

= From: gaoliming <gaoliming@byosoft.com.cn> <= br>Sent: 2020=E5=B9=B412=E6=9C=8821=E6=97=A5 9:11
To: Liu, WeiX C <weix.c.liu@intel.com>; devel@edk2.groups.io
Cc: 'Laszlo Ersek' <lersek@redhat.com>
Subject:=
=E5=9B=9E=E5=A4=8D: [PATCH 1/2] BaseTo= ols LzmaCompress: Update LZMA to new 19.00 version

 

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

 

Thanks

Lim= ing

=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:<= /span> 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<= span lang=3DEN-US>: 'Laszlo Ersek' <lersek@redhat.com>
=E4= =B8=BB=E9=A2=98: RE: [PAT= CH 1/2] BaseTools LzmaCompress: Update LZMA to new 19.00 version=

=  

Hi liming,

 

I listed unittest resu= lt as below with Ovmf build,  cause I have no apple machine so only li= st VS=E3=80=81= GCC 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=88= 17=E6=97=A5 9:30

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

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

Subject: =E5=9B=9E=E5=A4=8D: [PATC= H 1/2] BaseTools LzmaCompress: Update LZMA to new 19.00 version<= /span>

 

Wei:

=

  Can you list the unit tes= t 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.

 <= /o:p>

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>

> <= span style=3D'font-family:=E7=AD=89=E7=BA=BF'>=E5=8F=91=E9=80=81=E6=97=B6= =E9=97=B4: 2020=E5=B9=B412=E6=9C=8815<= /span>=E6=97=A5 10:07

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

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

> &l= t;gaoliming@byosoft.com.cn&= gt;; Laszlo Ersek <lersek@redhat.co= m>

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

> version

>

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

> New formal r= elease 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/LzmaCompr= ess/LZMA-SDK-README.txt      |   4<= /o:p>

> ++--

>  BaseTo= ols/Source/C/LzmaCompress/LzmaCompress.c      = ;     |   8

> ++++----

>  BaseTools/Source/C/LzmaCompr= ess/Sdk/C/7zTypes.h          |=    5

> +++--

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

> ++++----

>  BaseTools/Source/C/LzmaC= ompress/Sdk/C/CpuArch.h        &nbs= p; |   9

> +++++----

>  BaseTools/Source/C/LzmaCompress/Sdk/C/LzFind.c&nbs= p;          | 164

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

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

> ---------------------------------<= /span>

>  BaseTools/S= ource/C/LzmaCompress/Sdk/C/LzFindMt.c      &n= bsp;  | 117

> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

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

>  BaseTools/Source/C/LzmaCom= press/Sdk/C/LzFindMt.h         |&nb= sp; 14

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

>  BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c  =         |  32

=

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

>&= nbsp; BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c   &nbs= p;      | 733

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

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

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

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

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

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

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

> 

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

=

----

> 

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

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

> 

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

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

> ---------------------------------<= o:p>

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

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

&= gt;  BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-sdk.txt  &= nbsp;  |   2 +-

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

&= gt;

> d= iff --git a/BaseTools/Source/C/LzmaCompress/LZMA-SDK-README.txt<= /span>

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

> index 7cf967a774..b2338e2598 100644

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

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

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

> -LzmaCompress is based on the LZMA SDK 18.05.&n= bsp; LZMA SDK 18.05

>

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

>

> +LzmaCompress i= s based on the LZMA SDK 19.00.  LZMA SDK 19.00

>

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

>

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

>

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

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

> index bebdb9aa84= ..bf4706ee23 100644

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

> +++ b/BaseToo= ls/Source/C/LzmaCompress/LzmaCompress.c

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

>  /** @file

>

>    LZMA Com= press/Decompress tool (LzmaCompress)

>

>

>

> -  Based on LZMA SDK 18.05:

>

> +  Based on LZMA SDK 19.00:

>

>  &= nbsp;   LzmaUtil.c -- Test application for LZMA compression<= /o:p>

> =

> -  &nb= sp; 2018-04-30 : Igor Pavlov : Public domain

>

> +    2019-02-21 : Igor P= avlov : 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";

>  co= nst char *kDataErrorMessage =3D "Data error";

>

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

<= p class=3DMsoPlainText>>

>

>

> -static Bool mQuietMode =3D False;

>

> +static BoolInt mQu= ietMode =3D False;

>

>  static CONVERTER_TYPE mConType =3D NoConverter;<= /span>

>

>

=

>

>  UINT64 mDictionarySize =3D= 28;

> <= o:p>

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

>  &nb= sp; CFileOutStream outStream;

= >

>    int res;

>

>    int encodeMode =3D 0;=

> =

> -  Bo= ol modeWasSet =3D False;

>

> +  BoolInt modeWasSet =3D False;

<= p class=3DMsoPlainText>>

>    const char *inp= utFile =3D NULL;

>

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

>

>  &n= bsp; int param;

>

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

> b/BaseTools/Sou= rce/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

<= p class=3DMsoPlainText>>

>  #define __7Z_TYPES_H

> <= /span>

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

>  typedef size_t SizeT;

>

>  #endif

>

>

>

> -typedef int Bool;

>

> +typedef int BoolInt;

> =

> +/* typedef BoolInt Boo= l; */

> =

> = #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<= /o:p>

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

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

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

> -#define MY_VER_MAJOR 18

>

> -#define MY_VER_MINOR 05

>

> +#define MY_VER_MAJO= R 19

> <= o:p>

> +#defi= ne MY_VER_MINOR 00

>

>  #define MY_VER_BUILD 0

>

> -#define MY_VERSION_NUMBERS "18.05"

>

> +#define MY_= VERSION_NUMBERS "19.00"

>

<= span lang=3DEN-US>>  #define MY_VERSION MY_VERSION_NUMBERS

>

> <= /p>

>

>  #ifdef MY_CPU_NAME=

>

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

>&nbs= p;   #define MY_VERSION_CPU MY_VERSION

>

>  #endif

=

>

>

>

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

> =

> +#define M= Y_DATE "2019-02-21"

= >

>  #undef MY_COPYRIGHT

>

>  #undef MY_VERSION_COPYRIGHT_DATE<= o:p>

> <= /o:p>

>  #defi= ne 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..5f= 74c1c0cb 100644

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

> +++ b/BaseTools/S= ource/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 */

>

> <= /span>

>

>  #ifndef __CPU_AR= CH_H

> <= o:p>

>  = #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 x86= cpuid_GetFirm(const Cx86cpuid *p);

>

= >

>

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

0xF))

>

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

<= p class=3DMsoPlainText>> 0xF))

<= p class=3DMsoPlainText>>

>  #define x86cpuid_GetSteppin= g(ver) (ver & 0xF)

>

>

>

= > -Bool CPU_Is_InOrder();

<= span lang=3DEN-US>>

> -Bool CPU_Is_Aes_Supported();

>

> +BoolInt CPU_Is_InOrder();<= /span>

>

> +BoolInt CPU_Is_Aes_Su= pported();

= >

> = +BoolInt CPU_IsSupported_PageGB();

>

= >

>

>  #endif

>

>

>

> diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFind.c<= /o:p>

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

> index 6ea82a9b53..4eefc17dd2 100644

> --- a/BaseToo= ls/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&quo= t;

>

>

>

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

> MatchFinder_SetDefaultSettings(CMatchFinder *p)

>

>

>  void MatchFinder_Construct(C= MatchFinder *p)

>

= >  {

>

>= ; -  UInt32 i;

>

> +  unsigned i;

= >

>    p->bufferBase =3D NULL;<= /span>

>

>    p-&g= t;directInput =3D 0;

>

>    p->hash =3D NULL;

>

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

= >

>

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

>

>    {

>

> -  =   UInt32 r =3D i;

>

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

>

=

>    &nbs= p; unsigned j;

>

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

> =

>    =     r =3D (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r &= amp; 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<= o:p>

> MatchF= inder_CheckLimits(CMatchFinder *p)

>    MatchFinder_SetLimits(p);

>

>  }<= /o:p>

> =

>

>

> -static UInt32 * Hc_GetMat= chesSpec(UInt32 lenLimit, UInt32 curMatch,

> UInt32 pos, const Byte *cur, CLzRef *s= on,

>

> +<= /o:p>

> =

> +/*

> =

> +  (lenLimit > = maxLen)

>= ;

> +*/=

> =

> +MY_FORCE_= INLINE

>=

> +sta= tic UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch,

> UInt32 pos, co= nst Byte *cur, CLzRef *son,

>

>      UInt32 _cyclicBufferPos, UIn= t32 _cyclicBufferSize, UInt32 cutValue,

>

> -    UInt32 *distances, UInt32 = maxLen)

>= ;

> +&n= bsp;   UInt32 *distances, unsigned maxLen)

<= p class=3DMsoPlainText>>

>  {

>

> +  /*

>

>    son[_cyclicBuffe= rPos] =3D curMatch;

>

>    for (;;)

>

>    {

>

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

> UInt32 curMatch, UInt32 pos,

>    &nb= sp;         break;

>

=

>    &nbs= p;     if (maxLen < len)

>

>      &nb= sp;   {

>

> -          *distance= s++ =3D maxLen =3D len;

>

> +          maxL= en =3D len;

>

>= +          *distances++ =3D l= en;

>

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

>

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

>

>           =    return distances;

>

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

>= ; lenLimit, UInt32 curMatch, UInt32 pos,

>       = ; }

>

> &n= bsp;    }

>

>    }

>

= > +  */

>

= > +

>

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

>

=

> +  son[_cyclicBufferPo= s] =3D curMatch;

>

> +  do

>

> +  {

>

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

>

<= p class=3DMsoPlainText>> +    if (delt= a >=3D _cyclicBufferSize)

<= span lang=3DEN-US>>

> +      break;<= /p>

>

> +    {

>

> +   = ;   ptrdiff_t diff;

= >

> +      curMatch =3D son[_cyclic= BufferPos - delta + ((delta >

_cyclicBufferPos) ?

> _cyclicBufferSize : 0)];

>

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

>

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

>

> +      {

>

> +     &nb= sp;  const Byte *c =3D cur;

>

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

>

> +        {

>

> +     &nb= sp;    if (++c =3D=3D lim)

>

> +       &= nbsp;  {

>

&g= t; +            dist= ances[0] =3D (UInt32)(lim - cur);

>

<= span lang=3DEN-US>> +        &nb= sp;   distances[1] =3D delta - 1;

>

> +      &n= bsp;     return distances + 2;

>

> +     &nb= sp;    }

>

> +        }

>

> +    =     {

>

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

<= span lang=3DEN-US>>

> +          i= f (maxLen < len)

>

> +          {

>

> +   = ;         maxLen =3D len;

>

> +   &= nbsp;        distances[0] =3D (UInt32)le= n;

>

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

>

= > +            di= stances +=3D 2;

>

= > +          }

> =

> +   &nbs= p;    }

>

> +      }

>

> +    }

> =

> +  }

> <= /p>

> +  while (--cutValu= e);

>

> +<= /o:p>

> =

> +  return d= istances;

&= gt;

>&n= bsp; }

>=

>

>

> +

> =

> +MY_FORCE_INLINE

> <= /span>

>  UInt32 * Ge= tMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos,

> const Byte *cur, CLzR= ef *son,

&g= t;

>&nb= sp;     UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSi= ze, UInt32 cutValue,

>

>      UInt32 *distances, UInt32 maxLen)

>

>  {=

>

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

>

> -  CLzRef *ptr1 =3D son + (_c= yclicBufferPos << 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 (;;= )

>

> &nbs= p;  {

= >

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

> =

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

> curMatch, UInt32 pos, const Byt

> &nb= sp;      return distances;

>

>      }

>

>  &n= bsp;   {

>

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

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

>= ;

> +&n= bsp;     CLzRef *pair =3D son + ((size_t)(_cyclicBuffer= Pos - delta + ((delta >

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

>

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

>

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

>

=

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

=

>

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

>

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

= >

>&= nbsp;       {

>

>      &nbs= p;   if (++len !=3D lenLimit && pb[len] =3D=3D cur[len])<= o:p>

> <= /o:p>

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

<= p class=3DMsoPlainText>> UInt32 curMatch, UInt32 pos,= const Byt

= >            = ;    break;

>

>          if (m= axLen < len)

>

= >          {

>

> -    =       *distances++ =3D maxLen =3D len;<= /span>

>

> +   &nb= sp;      maxLen =3D (UInt32)len;=

>

<= p class=3DMsoPlainText>> +    &nb= sp;     *distances++ =3D (UInt32)len;=

>

<= p class=3DMsoPlainText>>     = ;       *distances++ =3D delta - 1;

>

>   &nb= sp;        if (len =3D=3D lenLimit)=

>

>   &nb= sp;        {

<= p class=3DMsoPlainText>>

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

=

>

> +     &= nbsp;      *ptr1 =3D pair0;

<= p class=3DMsoPlainText>>

>     &nbs= p;        *ptr0 =3D pair[1];<= /span>

>

>    = ;          return distances;

>

>  &= nbsp;         }

>

> @@ -468,9 +522,9 @@ UInt32 * G= etMatchesSpec1(UInt32 lenLimit, UInt32

> curMatch, UInt32 pos, const Byt=

>  static voi= d SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos,<= /span>

> const Byte *cur, = CLzRef *son,

>

>= ;      UInt32 _cyclicBufferPos, UInt32 _cyclicBuff= erSize, UInt32 cutValue)

>

>  {

>

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

> =

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

>

> -  UInt32 len0 =3D 0, le= n1 =3D 0;

&= gt;

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

>

> +  CLzRe= f *ptr1 =3D son + ((size_t)_cyclicBufferPos << 1);<= /p>

>

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

>

>=     for (;;)

>

>    {

>

>      UInt32 delta =3D po= s - curMatch;

>

&g= t; @@ -480,9 +534,9 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32<= o:p>

> curMat= ch, UInt32 pos, const

>        return;

>

>   &nb= sp;  }

>

>=       {

>

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

> _cyclicBufferPos) ? _cyclicBufferS= ize : 0)) << 1);

>

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

> _cyclicBufferPos) ? _cyclicBufferS= ize : 0)) << 1);

>

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

>

&g= t; -      UInt32 len =3D (len0 < len1 ? len0 : = len1);

>=

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

>

> &nbs= p;      if (pb[len] =3D=3D cur[len])

> <= /p>

>    &= nbsp;   {

>

>          while (++le= n !=3D lenLimit)

>

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

> UInt32 c= urMatch, UInt32 pos, const

>    p->buffer++; \<= /p>

>

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

>

>

>

> -#define MOVE_POS_RET MOVE_POS return o= ffset;

>=

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

>

>

>

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

>

>

>

= >  #define GET_MATCHES_HEADER2(minLen, ret_op) \<= /p>

>

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

>

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

MatchFinder_MovePos(p);

> ret_op; }} \

>

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

>

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

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

>

>    cur =3D p-&= gt;buffer;

= >

> =

> =

>  #def= ine GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen,

> return 0)

> =

> @@ -535,22 +589,22 @@ s= tatic void MatchFinder_MovePos(CMatchFinder

> *p) { MOVE_POS; }

>  #define MF_PARAM= S(p) p->pos, p->buffer, p->son, p->cyclicBufferPos,<= /span>

> p->cyclicBuffe= rSize, p->cutValue

>

>

>

>=   #define GET_MATCHES_FOOTER(offset, maxLen) \

>

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

>

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

>

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

> MF_PARAMS(p), \

>

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

>

>=

>

>  #de= fine SKIP_FOOTER \

>

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

>

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

> MOVE_POS;<= /span>

>

>

=

>

>  #define UPDATE_maxLen { \<= o:p>

> <= /o:p>

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

>

=

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

>

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

>

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

>

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

>

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

>

= >

>

>  static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder = *p, UInt32

= > *distances)

>

>  {

>

&g= t; -  UInt32 offset;

>

> +  unsigned offset;

>

>    GET_MATCHES_HEADER(2)

> <= /span>

>   = HASH2_CALC;

>

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

>

> @@ -561,7 +615,7 @@ static UInt32<= o:p>

> Bt2_Ma= tchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)<= /p>

>

>

>  UInt32 Bt3Zip_MatchFinder_Ge= tMatches(CMatchFinder *p, UInt32

> *distances)

>

>  {

>

> -  UInt32 offset;

>

> +  unsigned offset;

> <= /p>

>    GET_MA= TCHES_HEADER(3)

>

= >    HASH_ZIP_CALC;

>

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

>

> @@ -572,7 +6= 26,8 @@ UInt32

> Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)<= o:p>

> <= /o:p>

> =

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

> *distances)

>

>  {=

>

<= p class=3DMsoPlainText>> -  UInt32 h2, d2, maxLe= n, offset, pos;

>

= > +  UInt32 h2, d2, pos;

>

> +  unsigned maxLen, offset;

>

>    UInt32 *hash;=

> =

>  = ;  GET_MATCHES_HEADER(3)

= >

>

>

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

> Bt3_MatchFinder_GetMatches(CMatchF= inder *p, UInt32 *distances)

<= span lang=3DEN-US>>    if (d2 < p->cyclicBufferSize= && *(cur - d2) =3D=3D *cur)

>

>    {

>

>      UPDATE_ma= xLen

> <= o:p>

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

>

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

> =

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

>

>      offs= et =3D 2;

&= gt;

>&n= bsp;     if (maxLen =3D=3D lenLimit)<= /p>

>

>     = {

>

> - &= nbsp;    SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));<= o:p>

> <= /o:p>

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

> <= o:p>

> &= nbsp;      MOVE_POS_RET;

>

>      }

>

>  &n= bsp; }

>=

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

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

>

>=

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

> *distances)

>

>  {<= /o:p>

> =

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

>

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

>

> +  unsigned maxLen, = offset;

>= ;

>&nbs= p;   UInt32 *hash;

<= span lang=3DEN-US>>

>    GET_MATCHES_HEADER(4)=

>

<= p class=3DMsoPlainText>>

>

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

> Bt4_Matc= hFinder_GetMatches(CMatchFinder *p, UInt32 *distances)

>    hash =3D= p->hash;

>

>= ;    pos =3D p->pos;

>

>

<= span lang=3DEN-US>>

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

>

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

>

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

= >

> =

> =

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

>

>

>

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

>

> +  hash&= nbsp;           &nbs= p;     [h2] =3D pos;

>

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

&= gt;

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

<= p class=3DMsoPlainText>>

>

>

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

> Bt4_MatchFinder= _GetMatches(CMatchFinder *p, UInt32 *distances)

>

>

>    if (d2 < p->cyclicB= ufferSize && *(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;

>= ;

>&nbs= p;   }

>

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

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

>    if (offset !=3D 0)

>

>    {<= /span>

>

>    = ;  UPDATE_maxLen

>

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

>

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

>

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

<= span lang=3DEN-US>>

>      {

>

> -      Sk= ipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));

>

> +      Sk= ipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p));<= /p>

>

>     =    MOVE_POS_RET;

>

>      }

>

>    }<= /p>

>

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

>= Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)<= /span>

>   = hash =3D p->hash;

>

>    pos =3D p->pos;

>

>

>

> -  d2 =3D pos - hash[   &nbs= p;            h2];

>

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

>

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

>

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

>

> <= /span>

>

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

>

>

>

> -  hash[       &nbs= p;        h2] =3D pos;=

>

<= p class=3DMsoPlainText>> +  hash  &nbs= p;            &= nbsp;  [h2] =3D pos;

>

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

> <= /span>

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

>

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

> <= o:p>

> @@ -74= 1,7 +798,8 @@ static UInt32

> Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *d= istances)

&= gt;

> <= o:p>

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

> *distances)=

>

>  {

>

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

>

<= span lang=3DEN-US>> +  UInt32 h2, h3, d2, d3, pos;

>

=

> +  unsigned maxLen, of= fset;

> =

> =    UInt32 *hash;

>

>    GET_MATCHES_HEADER(4)

>

>

>

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

> Hc4_Match= Finder_GetMatches(CMatchFinder *p, UInt32 *distances)

=

>    hash =3D = p->hash;

>

>=     pos =3D p->pos;

>

>

>

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

>

> +  d2 =3D pos - h= ash            =       [h2];

>

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

&= gt;

> -=

> =

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

>

>

>

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

>

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

>

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

&= gt;

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

<= p class=3DMsoPlainText>>

>

>

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

> Hc4_MatchFinder= _GetMatches(CMatchFinder *p, UInt32 *distances)

>

>

>    if (d2 < p->cyclicB= ufferSize && *(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;

>= ;

>&nbs= p;   }

>

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

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

>    if (offset !=3D 0)

<= p class=3DMsoPlainText>>

>    {

> <= /p>

>    &= nbsp; UPDATE_maxLen

>

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

>

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

>

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

>

>      {

>

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

>

> @@ -791,7 +849,7 @@ static UInt= 32

> Hc4= _MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)

>    if = (maxLen < 3)

>

= >      maxLen =3D 3;

>

>

>

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

>

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

> MF_PARAMS(p),

<= span lang=3DEN-US>>

>        distances + off= set, maxLen) - (distances));

<= span lang=3DEN-US>>

>    MOVE_POS_RET

>

>  }

>

> @@ -808,13 +866,13 @@ static UInt3= 2

> Hc5_= MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)

>    hash= =3D p->hash;

>

>    pos =3D p->pos;

>

>

>

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

> <= /span>

> +  d2 =3D po= s - hash           &= nbsp;      [h2];

>

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

>

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

> =

>

<= p class=3DMsoPlainText>>

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

>

>

>

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

>

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

>

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

>

<= p class=3DMsoPlainText>>    (hash + kF= ix4HashSize)[h4] =3D pos;

>

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

> <= /span>

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

> Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distance= s)

>

>

>  UInt32 = Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32

=

> *distances)

>

>  {<= /p>

>

> -  UInt32 offset;

> <= /span>

> +  unsigned = offset;

>= ;

>&nbs= p;   GET_MATCHES_HEADER(3)

>

>    HASH_ZIP_CALC;

>

=

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

>

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

>

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

>

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

> MF_PARAMS(p),

>

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

>

>    MOVE_POS_RET

>

>  }

>

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

> UInt32 num)

>      HASH4_CALC;

>

>  &n= bsp;   hash =3D p->hash;

>

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

>

> -    hash[      = ;          h2] =3D<= /span>

>

> +    ha= sh            &= nbsp;     [h2] =3D

>

>      (hash + kFix3Hash= Size)[h3] =3D

>

&g= t;      (hash + kFix4HashSize)[hv] =3D p->pos;<= o:p>

> <= /o:p>

>  =     SKIP_FOOTER

>

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

> UInt32 num)

>      HASH5_CALC;=

>

<= p class=3DMsoPlainText>>     = ; hash =3D p->hash;

>

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

= >

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

>

> +    hash &nbs= p;            &= nbsp;   [h2] =3D

>

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

> <= o:p>

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

>

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

>

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

> UInt32 num)

>      HASH4_CALC;

>

>   &= nbsp;  hash =3D p->hash;

>

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

>

> -    hash[      &nbs= p;         h2] =3D

>

=

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

>

<= span lang=3DEN-US>>      (hash + kFix3HashSize)= [h3] =3D

&g= t;

>&nb= sp;     (hash + kFix4HashSize)[hv] =3D p->pos;<= /o:p>

> =

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

>

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

> UInt32 num)

<= p class=3DMsoPlainText>>     = ; HASH5_CALC;

>

&g= t;      hash =3D p->hash;

=

>

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

>

> -    hash[    = ;            h2] =3D=

> =

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

>

>      (has= h + kFix3HashSize)[h3] =3D

>

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

> <= o:p>

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

>

> diff --git a/BaseToo= ls/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/S= dk/C/LzFindMt.c

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

> @@ -1,5 +1,5 @@<= o:p>

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

> <= /p>

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

>

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

>

>

>

>  #include "Precomp.h"

>

>

> =

> @@ -232,38 +232,57 @@ s= tatic void

= > MatchFinderMt_GetNextBlock_Hash(CMatchFinderMt *p)

>

>

>  #define kEmptyHashValue 0

>

>

> =

> -/* #define MFMT_GM_INL= INE */

>=

> +#de= fine MFMT_GM_INLINE

>

>

= >

>&= nbsp; #ifdef MFMT_GM_INLINE

>

>

>

> -#define NO_INLINE MY_FAST_CALL

>

> +/*

>

= > +  we use size_t for _cyclicBufferPos instead = of UInt32

&= gt;

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

>

> +*/

>

>

>

> -static Int32 NO_INLINE GetMatches= SpecN(UInt32 lenLimit, UInt32 pos,

> const Byte *cur, CLzRef *son,

>

=

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

> <= /p>

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

> UInt32 size, UIn= t32 *posRes)

>

>= ; +MY_NO_INLINE

>

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

> *cur= , CLzRef *son,

>

&= gt; +    size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, = UInt32 _cutValue,

>

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

> *limit, UInt32 size, UInt32 *posRes)

=

>

>  {

>

>    do

> <= /p>

>    {=

>

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

>

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

> =

> +  UInt32 *_distan= ces =3D ++distances;

>

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

>

>

>

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

>

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

>

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

>

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

&g= t;

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

>

> +  unsigned l= en0 =3D 0, len1 =3D 0;

>

>    UInt32 cutValue =3D _cutValue;<= /span>

>

> -  UInt32 maxLen = = =3D _maxLen;

>

&g= t; -  for (;;)

>

> +  unsigned maxLen =3D (unsigned)_maxLen;<= /p>

>

> +

>

> +  /*

>

> +  if (size > 1)

> <= /p>

>    {=

>

> -  &n= bsp; UInt32 delta =3D pos - curMatch;

>

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

>

> +    UInt32 delta =3D *hash;=

>

> +    i= f (delta < _cyclicBufferSize)

>

>      {

=

>

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

>

> -      break;=

>

> +   &n= bsp;  UInt32 cyc1 =3D _cyclicBufferPos + 1;

>

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

> _cyclicBufferS= ize : 0)) << 1);

>

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

>

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

>

> +      _d= istances[1] =3D b;

>

>      }

>

> +  }

>

> +  */

>

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

>

> +  {

>

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

>

> +  }=

>

> +  else

>

> +  for(;= ;)

>

> +  = {

>

> &nbs= p;    {

>

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

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

>

>= ; +      CLzRef *pair =3D son + ((size_t)(_cyclicB= ufferPos - delta +

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

&= gt;

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

>

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

>

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

>

> +    =   UInt32 pair0 =3D *pair;

>

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

>

>        {

=

>

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

>=

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

> lenLimit, UInt32 = pos, const Byte *

>          &= nbsp;     break;

>

>        &n= bsp; if (maxLen < len)

>

>          {=

>

> -  &n= bsp;       *distances++ =3D maxLen =3D len;

>

> +  = ;        maxLen =3D len;

>

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

>

>    &nb= sp;       *distances++ =3D delta - 1;

>

>   &= nbsp;        if (len =3D=3D lenLimit)

>

>  &n= bsp;         {

>

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

>

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

>

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

>

> +   &n= bsp;        *ptr1 =3D pair0;<= /span>

>

> +   &nb= sp;        *ptr0 =3D pair1;

> =

>    =           break;

> <= /p>

>    &= nbsp;       }

>

>      &nbs= p;   }

>

>        }

>

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

>

> -      {

>

> -     &nb= sp;  *ptr1 =3D curMatch;

= >

> -        ptr1 =3D pai= r + 1;

>=

> -&nb= sp;       curMatch =3D *ptr1;

>

> -    &= nbsp;   len1 =3D len;

>

> -      }

>

> -     = else

> =

> =        {

>

> -        *pt= r0 =3D curMatch;

>

> -        ptr0 =3D pair;=

>

> -   &n= bsp;    curMatch =3D *ptr0;

>

> -       = len0 =3D len;

>

&= gt; +        UInt32 curMatch =3D pos - d= elta;

> =

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

>

> +   &n= bsp;    // delta =3D pos - pair[((UInt32)pb[len] - (UInt32)c= ur[len]) >>

31];

>

&= gt; +        if (pb[len] < cur[len])<= o:p>

> <= /o:p>

> + &nbs= p;      {

>

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

= >

> +          = *ptr1 =3D curMatch;

>

> +          ptr1 =3D = pair + 1;

&= gt;

> +=           len1 =3D len;

> <= /span>

> +  &nbs= p;     }

<= span lang=3DEN-US>>

> +        else

>

> +   =      {

>

> +          del= ta =3D pos - *pair;

>

> +          *ptr0 =3D= curMatch;

= >

> = +          ptr0 =3D pair;=

>

> +  &n= bsp;       len0 =3D len;

>

> +     =    }

>

&= gt;        }

>

>      }

> <= /span>

> +  &nbs= p; if (--cutValue =3D=3D 0 || delta >=3D _cyclicBufferSize)

> =

> +    {

>

> +  = ;    *ptr0 =3D *ptr1 =3D kEmptyHashValue;<= /p>

>

> +    &nbs= p; break;

&= gt;

> +=     }

>

>    }

= >

>    pos++;

>

>    _cyclicBufferPos++;

>

>  &= nbsp; cur++;

>

>= ;    {

>

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

>

&= gt; -    *_distances =3D num - 1;

>

> -    _distances += =3D num;

&= gt;

> -=     limit -=3D num;

>

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

>

>    = }

>

> &nbs= p;  }

= >

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

>

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

>

>    *posRes =3D pos;

>

> -  return limit;

>

> +  return dist= ances;

>=

> = ; }

>

>

> <= /span>

>  #endif=

>

>

>

> +

>

> +

>

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

>

>  {

>

>    UInt32 numProcessed =3D 0;

>

>    UInt32 c= urPos =3D 2;

>

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

> <= /span>

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

> =

>

<= p class=3DMsoPlainText>>

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

>

>

>

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

> UInt32 *dis= tances)

>= ;        #else

>

>      = ;  {

&= gt;

>&n= bsp;         UInt32 posRes;

>

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

p->son,

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

>

> -   &= nbsp;        distances + curPos, p->n= umHashBytes - 1, p->hashBuf +

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

>

&= gt; +        curPos =3D (UInt32)(GetMatc= hesSpecN(lenLimit, pos, p->buffer,

> p->son, cyclicBufferPos, p->cyclicBuf= ferSize, p->cutValue,

>

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

> p->hashBuf= Pos,

> <= o:p>

> + = ;           distances + l= imit,

> =

> +&nbs= p;           size, &p= osRes) - distances);

>

>          p->hashB= ufPos +=3D posRes - pos;

>

>          cyclic= BufferPos +=3D posRes - pos;

<= span lang=3DEN-US>>

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

<= span lang=3DEN-US>>

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

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

> index 3d86c788f3..fdd17008c2 10= 0644

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

=

> +++ b/BaseTools/Source/C/Lz= maCompress/Sdk/C/LzFindMt.h

> @@ -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 */

>

>

= >

>&= nbsp; #ifndef __LZ_FIND_MT_H

<= span lang=3DEN-US>>

>  #define __LZ_FIND_MT_H

>

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

>

>

>  typedef struct= _CMtSync

&= gt;

>&n= bsp; {

>=

> -&nb= sp; Bool wasCreated;

>

> -  Bool needStart;

>

<= span lang=3DEN-US>> -  Bool exit;

>

> -  Bool stopWriting;<= /p>

>

> +  BoolInt wasCreated;

>

> +  Bool= Int needStart;

>

&= gt; +  BoolInt exit;

>

> +  BoolInt stopWriting;

>

>

>

>    CThread thread;

>

>    CAutoRes= etEvent canStart;

>

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

>    CAutoResetE= vent wasStopped;

>

>    CSemaphore freeSemaphore;

>

>    CSemaphore fille= dSemaphore;

>

>= -  Bool csWasInitialized;

>

> -  Bool csWasEntered;

>

> +  BoolInt csWasInitialized;=

>

> +  BoolInt= csWasEntered;

>

&= gt;    CCriticalSection cs;

>

>    UInt32 numProcessedBlocks= ;

>

>  } C= MtSync;

>= ;

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

> b/BaseTools/Source/C/Lz= maCompress/Sdk/C/LzmaDec.c

> index 962b94bb63..4d1576419f 100644<= /p>

> --- 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 doma= in */

> =

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

>

>

= >

>  #include "Precomp.h"

>

>

>

> +#include <string.h>

> =

> +

=

>

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

= >

>&= nbsp; #include "LzmaDec.h"

>

>

>

> -#include <string.h>

>

> -

>

<= span lang=3DEN-US>>  #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 &= gt;>

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

<= p class=3DMsoPlainText>>

> +#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 +=

> ((kBi= tModelTotal - ttt) >> kNumMoveBits));

>

>  #define UPDATE_1(p) range -=3D bo= und; 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_CHEC= K; bound =3D (range >>

<= span lang=3DEN-US>> kNumBitModelTotalBits) * ttt; if (code < bound)

>

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

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

>

>  #define UPDATE_0_CHECK range= =3D bound;

>

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

>

>  #define GET_BIT= 2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \

>

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

> *p, SizeT limit, const Byte *bufLimit

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

>

> &nbs= p;        pos =3D dicPos - rep0 + (dicPo= s < rep0 ? dicBufSize : 0);

>

>

>

> -        processedPos +=3D cur= Len;

> <= o:p>

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

>

>

> <= /p>

>    &= nbsp;     len -=3D curLen;

>

>      &nbs= p;   if (curLen <=3D dicBufSize - pos)

>

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

<= span lang=3DEN-US>> *p, SizeT limit, const Byte *bufLimit

>   &nb= sp;        Byte *dest =3D dic + dicPos;<= o:p>

> <= /o:p>

>  =           ptrdiff_t src =3D (p= trdiff_t)pos - (ptrdiff_t)dicPos;

>

<= span lang=3DEN-US>>         = ;   const Byte *lim =3D dest + curLen;

>

> -     &nb= sp;    dicPos +=3D curLen;

>

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

>

>        =     do

>

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

>

>      &nbs= p;     while (++dest !=3D lim);

>

> @@ -572,14 +572,14 @@ int MY_FAST_= CALL

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

>    = p->buf =3D buf;

>

>    p->range =3D range;

>

>    p->code =3D c= ode;

> <= o:p>

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

>

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

>

>    p->dicPo= s =3D dicPos;

>

&g= t;    p->processedPos =3D processedPos;=

>

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

>

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

>

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

>

> &nb= sp;  p->reps[3] =3D rep3;

>

<= span lang=3DEN-US>> -  p->state =3D state;

=

>

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

>=

>

>

>  &nb= sp; return SZ_OK;

>

>  }

>

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

> LzmaDec_WriteRem(CLzmaDec = *p, SizeT limit)

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

> <= /p>

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

>

>

>

> -    p->processe= dPos +=3D len;

>

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

>

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

>

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

> <= /span>

>   =    while (len !=3D 0)

>

>      {

<= p class=3DMsoPlainText>>

>     &nbs= p;  len--;

>

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

> CLzmaDec *p, co= nst Byte *buf, SizeT inS

>  }

>

>

>

>

>=

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

> <= /span>

> +void LzmaDec_Ini= tDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt

> initState)

>

>  {

<= p class=3DMsoPlainText>>

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

<= span lang=3DEN-US>>

>    p->tempBufSize =3D 0;

>

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

> dicLimit, const Byte *src, SizeT *sr

> &nbs= p;        p->tempBufSize =3D rem;

>

>  &nb= sp;       if (rem < LZMA_REQUIRED_INPUT_MA= X || checkEndMarkNow)

>

>          {

>

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

>

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

> (SizeT)rem);

>

>      = ;      if (dummyRes =3D=3D DUMMY_ERROR)=

>

>   &nbs= p;        {

>

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

>

> +     =        (*srcLen) +=3D (SizeT)lookAhead;<= /o:p>

> =

>   = ;           *status =3D L= ZMA_STATUS_NEEDS_MORE_INPUT;

<= span lang=3DEN-US>>

>         &nbs= p;    return SZ_OK;

>

= >        &nbs= p;   }

>

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

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

>         =      return SZ_ERROR_FAIL; /* some internal error */

>

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

>

>  &n= bsp;       }

>

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

>

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

>

>          src +=3D lo= okAhead;

&g= t;

> -&= nbsp;       inSize -=3D lookAhead;=

>

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

<= p class=3DMsoPlainText>>

>     &nbs= p;    p->tempBufSize =3D 0;

>

>      &nbs= p; }

> <= o:p>

> &= nbsp;  }

>

&g= t; diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c<= /span>

> b/BaseTools/Sourc= e/C/LzmaCompress/Sdk/C/LzmaEnc.c

> index e281716fee..14086fc4f9 100644

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

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

&g= t; @@ -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"

> =

>

<= p class=3DMsoPlainText>>

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

>  #define kNumBitPriceShiftBits 4

=

>

>  #define kBitPrice (1 <&= lt; kNumBitPriceShiftBits)

>

>

>

> +#define REP_LEN_COUNT 64

>

> +

>

>  void LzmaEncProps_Init(CLzmaEncProps *p)

> <= /p>

>  {

>

=

>    p->lev= el =3D 5;

&= gt;

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

>  } COptimal;

>

>

>

>

>

> -#define kNumOpts (1 << 12)

>

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

>=

> +// = 18.06

> =

> +#def= ine kNumOpts (1 << 11)

<= span lang=3DEN-US>>

> +#define kPackReserve (kNumOpts * 8)

>

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

> =

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

>

>

<= span lang=3DEN-US>>

>  #define kNumLenToPosStates 4

<= p class=3DMsoPlainText>>

>  #define kNumPosSlotBits 6

>

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

>  typedef struct

>

>  {

>

>    unsigned tableSize;<= /span>

>

> -  unsigned count= ers[LZMA_NUM_PB_STATES_MAX];

<= span lang=3DEN-US>>

>    UInt32 prices[LZMA_NUM_PB_STATES_MAX][k= LenNumSymbolsTotal];

>

> +  // UInt32 prices1[LZMA_NUM_PB_STATES_MAX][kLenNumLowSymbo= ls *

> 2= ];

>

> +  = // UInt32 prices2[kLenNumSymbolsTotal];

>

>  } CLenPriceEnc;

>

>

>

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

>

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

>

> +

> <= /p>

> +/*

>

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

>

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

2) &

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

9)))

>

&= gt; +*/

>= ;

>

>

>  typedef= struct

>= ;

>&nbs= p; {

> <= o:p>

> @@ -30= 8,16 +321,18 @@ typedef struct

>    unsigned lc, lp, pb;<= /span>

>

>    unsi= gned lclp;

= >

> =

> =

> -  Bo= ol fastMode;

>

>= ; -  Bool writeEndMark;

<= span lang=3DEN-US>>

> -  Bool finished;

>

> -  Bool multiThread;

>

> -  Bool needInit;

>

> +  BoolInt fa= stMode;

>= ;

> +&n= bsp; BoolInt writeEndMark;

>

> +  BoolInt finished;

>

> +  BoolInt multiThread;

>

> +  BoolInt needInit;<= o:p>

> <= /o:p>

> +  // = BoolInt _maxMode;

>

>

= >

>&= nbsp;   UInt64 nowPos64;

>

= >

>

>    unsigned matchPriceCount;

>

=

> -  unsigned alignPrice= Count;

>=

> +&nb= sp; // unsigned alignPriceCount;

>

> +  int repLenEncCounter;

>

>

>

>    unsigned distTableSize;

>

>

> =

> @@ -325,7 +340,7 @@ typ= edef struct

>    SRes result;

>

>

>

>    #ifndef _7ZIP_ST

>

> -  Bool mtMode;

> <= /p>

> +  BoolInt mtMode;<= o:p>

> <= /o:p>

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

>

>    CMatchFinderM= t matchFinderMt;

>

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

> <= o:p>

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

> CLzmaEncProps *props= 2)

>&nbs= p;   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);

> <= /p>

>    {=

>

>  &nbs= p;   unsigned numHashBytes =3D 4;

>

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

>

>

>  #ifdef _LZMA_ENC_USE_BRANCH

>

>

>

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

> =

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

= >

>&= nbsp;   RC_BIT_PRE(p, prob) \

>

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

> kNumMoveBits; } \

>

=

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

> kNumMoveBits; } \

>

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

>= ; kNumMoveBits; } \

>

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

>

<= p class=3DMsoPlainText>>    RC_NORM(p)= \

>

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

>

=

>

>  #else

>

>

>

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

>

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

>

>    UInt32 mask; \

>

>    RC_BIT_PRE(p, prob) \

>

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

>

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

>

>    range &=3D m= ask; \

>=

> = ;   mask &=3D newBound; \

>

>    range -=3D mask; \

>

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

>

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

=

>

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

>

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

>

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

>

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

>

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

&g= t; CLzmaProb *prob)

>    p->range =3D range;

>

>  }

<= p class=3DMsoPlainText>>

>

>

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

>

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

>

= >  {

>

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

>

> -  symbol |=3D 0x100;

>

> +  sym |=3D 0= x100;

> =

> =    do

>

= >    {

>

>      UInt32 ttt, newBound;

>

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

&= gt;

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

>

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

>

> -    symbol <<=3D = 1;

>

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

>

&= gt; +    CLzmaProb *prob =3D probs + (sym >> 8);<= /o:p>

> =

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

>

> +    sym <<=3D 1;<= o:p>

> <= /o:p>

>  =     RC_BIT(p, prob, bit);

>

>    }

>

> -  while (symbol < 0x10000= );

>

> +  = while (sym < 0x10000);

>

>    p->range =3D range;

>

>  }

<= p class=3DMsoPlainText>>

>

>

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

= > symbol, UInt32 matchByte)

>

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

> UInt32 sym, UInt32 matchByte)

>

>  {

<= p class=3DMsoPlainText>>

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

>

>    UInt32 offs =3D 0x100;

>

> -  symbol |=3D 0x100;

>

> +  sym |=3D 0= x100;

> =

> =    do

>

= >    {

>

>      UInt32 ttt, newBound;

>

>   &n= bsp;  CLzmaProb *prob;

>

>      UInt32 bit;

>

=

>    &nbs= p; matchByte <<=3D 1;

>

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

>> 

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

> <= /span>

> -  &nbs= p; prob =3D probs + (offs + (matchByte & offs) + (symbol >> 8));<= o:p>

> <= /o:p>

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

>

> -    symbol <<=3D = 1;

>

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

>

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

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

>

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

>

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

>

> +    sy= m <<=3D 1;

>

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

>

>    &nb= sp; RC_BIT(p, prob, bit);

>

>    }

>

= > -  while (symbol < 0x10000);

>

> +  while (sym < 0= x10000);

&g= t;

>&nb= sp;   p->range =3D range;

>

>  }

>

>

>

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

&g= t; *ProbPrices)

>  }

>

>

= >

> =

> =

> -#define G= ET_PRICE(prob, symbol) \

>

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

-

> 1))) >> kNumMoveReducingBits];

>

> +#define GET_PRICE(prob, bit) \

>

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

1))) >>=

> kNumM= oveReducingBits];

>

>

= >

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

>

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

-

> 1))) >> kNumMoveReducingBits];=

>

> +#define GET_PR= ICEa(prob, bit) \

>

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

1))) >>

> kNumMoveReducingBits];

<= p class=3DMsoPlainText>>

>

>

>  #define GET_PRICE_0(prob) p->ProbP= rices[(prob) >>

> kNumMoveReducingBits]

>

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

>> 

> kNumMoveReducingBits]

<= p class=3DMsoPlainText>>

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

> *ProbPrices)

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

> kNumMoveReducingBits]

> =

>

<= p class=3DMsoPlainText>>

>

>

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

const

> CProbPrice *ProbPrices)

>

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

> CProbPrice *ProbPrices)

>

>  {

>

>    UInt32 price =3D 0;

>

> -  symb= ol |=3D 0x100;

>

&= gt; +  sym |=3D 0x100;

>

>    do

>

>    {

>

> -    unsigned bit =3D sy= mbol & 1;

>

&g= t; -    symbol >>=3D 1;

>

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

>

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

>

> +    s= ym >>=3D 1;

>

> +    price +=3D GET_PRICEa(probs[sym], bit);<= /o:p>

> =

>   = ; }

>

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

>

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

>

>    return price;

>

>  }=

>

>

>

>

>

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

> symbol, UInt32 matchByte, const CProbPrice *ProbPr= ices)

> =

> +stat= ic UInt32 LitEnc_Matched_GetPrice(const CLzmaProb *probs, UInt32=

> sym, UInt32 matc= hByte, const CProbPrice *ProbPrices)

>

>  {

>

<= span lang=3DEN-US>>    UInt32 price =3D 0;

>

>    UInt32 = offs =3D 0x100;

>

= > -  symbol |=3D 0x100;

>

> +  sym |=3D 0x100;

>

>    do<= /p>

>

>    {

>

>   &nb= sp;  matchByte <<=3D 1;

>

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

> (symbol >> 7) & 1);<= o:p>

> <= /o:p>

> - &nbs= p;  symbol <<=3D 1;

>

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

>

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

> (sym >> 7) & 1);

>

> +    sym <<=3D 1;<= /span>

>

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

>

>    }

>

> -  while (symbol < 0x10000);

>

> +  while (sym = < 0x10000);

>

&= gt;    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, newB= ound;

> =

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

>

> +    unsigned bit =3D s= ym & 1;

>

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

>

> -  = ;  symbol >>=3D 1;

= >

> +    sym >>=3D 1;=

>

<= p class=3DMsoPlainText>>     = ; RC_BIT(rc, probs + m, bit);

= >

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

>

> &nbs= p;  }

= >

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

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

>

>  }

>

>

>

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

> unsigned posState)

>

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

>= ; unsigned posState)

>

>  {

>

>    UInt32 range, ttt, newBound;<= /p>

>

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

>

>    range =3D rc->range;

>

>    RC_BIT_PRE(rc, p= robs);

>=

> -&nb= sp; if (symbol >=3D kLenNumLowSymbols)

>

> +  if (sym >=3D kLenNumLowSymbols)

>

>  &= nbsp; {

>= ;

>&nbs= p;     RC_BIT_1(rc, probs);

>

>      probs += =3D kLenNumLowSymbols;

>

>      RC_BIT_PRE(rc, probs);

>

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

>

> +    if (sym >=3D kLe= nNumLowSymbols * 2)

>

>      {

>

>        RC= _BIT_1(rc, probs);

>

>        rc->range =3D range;=

> =

> - &nb= sp;    // RcTree_Encode(rc, p->high, kLenNumHighBits, sym= bol -

> = 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);

>

>    &n= bsp;   return;

>

>      }

>

> -    symbol -=3D kLenNum= LowSymbols;

>

>= +    sym -=3D kLenNumLowSymbols;

>

>    }

>

>

>

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

> kLenNumLowBits, symbol);=

>

<= p class=3DMsoPlainText>> +  // RcTree_Encode(rc,= probs + (posState << kLenNumLowBits),

> kLenNumLowBits, sym);

> =

>    {

>

>  &nb= sp;   unsigned m;

>

>      unsigned bit;

>

>    &n= bsp; RC_BIT_0(rc, probs);

>

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

>

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

bit;

<= p class=3DMsoPlainText>>

> -    bit =3D (symb= ol >> 1) & 1; RC_BIT(rc, probs + m, bit); m =3D (m << 1) +<= o:p>

bit;

> <= /span>

> -   &nb= sp;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;<= /p>

>

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

> =

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

>

>      rc->range =3D range;

>

>  &= nbsp; }

>= ;

>&nbs= p; }

> <= o:p>

> @@ -86= 3,50 +879,93 @@ static void SetPrices_3(const CLzmaProb *probs,<= /span>

> UInt32 startPrice= , UInt32 *price

>  }

>

>

= >

> =

> =

> -MY_NO_INL= INE static void MY_FAST_CALL LenPriceEnc_UpdateTable(

=

>

> -    CLenPriceEnc= *p, unsigned posState,

>

> +MY_NO_INLINE static void MY_FAST_CALL LenPriceEnc_UpdateTab= les(

> <= o:p>

> + = ;   CLenPriceEnc *p,

>

> +    unsigned numPosStates,

> =

>    =   const CLenEnc *enc,

>

>      const CProbPrice *ProbPrices)=

> =

>  {

>

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

>

> -  UInt32 a;

>

> -  unsigned i, numSymbols;

>

> +  UInt32 b;<= o:p>

> <= /o:p>

> +

>

> +  {=

>

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

>

> +    UInt32 a, c;

>

> +    unsigned po= sState;

>= ;

> +&n= bsp;   b =3D GET_PRICEa_1(prob);

>

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

>

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

>

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

> =

> +    {

>

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

> =

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

> kLenNum= LowBits));

= >

> = +      SetPrices_3(probs, a, prices, ProbPrices);<= o:p>

> <= /o:p>

> + &nbs= p;    SetPrices_3(probs + kLenNumLowSymbols, c, prices +

> kLenNumLo= wSymbols, ProbPrices);

>

> +    }

>

> +  }

>

>

>

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

>

> +  /*

>

>    {<= o:p>

> <= /o:p>

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

> kLenNum= LowBits));

= >

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

>

&= gt; +    unsigned i;

>

> +    UInt32 b;

>

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

>

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

> <= o:p>

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

>

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

>

= > -    SetPrices_3(probs + kLenNumLowS= ymbols, a +

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

> kLenNumLowSymbols, P= robPrices);

>

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

>

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

> =

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

>

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

>

>    }

>

> -  numSymbols =3D p->t= ableSize;

&= gt;

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

>

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

>

> +  */

>

> +

>

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

>

> +  // p->counter =3D 6= 4;

>

> +

> <= /span>

>   = {

>

> - &= nbsp;  prices[i] =3D a +

= >

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

> kLenNumLowSymbols * 2, ProbPrices);

>

> -   &= nbsp;   LitEnc_GetPrice(enc->high, i - kLenNumLowSymbols * 2,<= o:p>

> ProbPr= ices);

>=

> -&nb= sp;   /*

>

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

>

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

> sym, ProbPrices);

>

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

>

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

>

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

>

> -  &n= bsp; */

>= ;

> -&n= bsp; }

>=

> -&nb= sp; // }

&g= t;

> -}=

> =

> + &nb= sp;  unsigned i =3D p->tableSize;

>

> +

>

> +    if (i > kLenNumLowSymbols * 2)=

> =

> + &nb= sp;  {

>

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

>

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

> <= o:p>

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

>

> +    &= nbsp; i >>=3D 1;

>

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

>

> +      do

>

> +      {<= o:p>

> <= /o:p>

> + &nbs= p;      /*

>

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

>

> +        // RcTree_GetPrice(en= c->high, kLenNumHighBits, i -

> kLenNumLowSymbols * 2, ProbPrices);

> =

> +   &nbs= p;    LitEnc_GetPrice(probs, i - kLenNumLowSymbols * 2, Prob= Prices);

&g= t;

> +&= nbsp;       */

>

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

> sym, Pro= bPrices);

&= gt;

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

>

> +        UInt32 price = =3D b;

>= ;

> +&n= bsp;       do

>

> +      &n= bsp; {

>=

> +&nb= sp;         unsigned bit =3D sym &a= mp; 1;

>=

> +&nb= sp;         sym >>=3D 1;=

>

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

> =

> +&nbs= p;       }

>

> +        w= hile (sym >=3D 2);

>

>

>

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

> numPosStates,

>

> -  =   const CLenEnc *enc,

>

> -    const CProbPrice *ProbPrices)

>

> -{=

>

<= p class=3DMsoPlainText>> -  unsigned posState;

>

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

>

> -    LenPriceE= nc_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 p= rice + GET_PRICEa_1(prob);

>

> +        }

> <= /p>

> +    = ;  }

&= gt;

> +=       while (i);

>

>

>

> +      {

>

> +     =    unsigned posState;

>

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

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

>

> +  &n= bsp;     for (posState =3D 1; posState < numPosState= s; posState++)

>

&= gt; +          memcpy(p->pr= ices[posState] + kLenNumLowSymbols * 2,

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

> =

> +&nbs= p;     }

<= span lang=3DEN-US>>

> +    }

>

> +  }

>

> +}

>

>

>

>  /*

>

>    #ifdef SHOW_STAT

>

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

> *p, unsigned numPosStates,

>

>

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

>

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

>

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

>

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

>

>

>

>

>

>  static unsigned ReadMatchDistances(CLzmaEnc *p, unsigned *n= umPairsRes)

>

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

> unsigned *n= umPairsRes)

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

>

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

=

>

>     &nb= sp;    const Byte *lim =3D p1 + numAvail;<= /p>

>

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

>

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

= >

> = +        {}

>

>      &nbs= p;   return (unsigned)(p2 - p1);

>

>        }=

> =

>  = ;    }

>

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

> u= nsigned *numPairsRes)

>    + GET_PRICE_1(p->isRep[state]) \<= /o:p>

> =

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

>

>

>

> -

>

> +MY_FORCE_INLINE

>

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

> size_t state, size_t posState)

>

>  {

>

>    UInt32 price;

>

=

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

> unsigned cur)

>    for (;;)<= /span>

>

>    {

>

>  &n= bsp;   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 ex= tra =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 ex= tra;

> <= o:p>

> &= nbsp;      len =3D extra;

>

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

>

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

= > cur)

&= gt;

> <= o:p>

> &= nbsp;    wr--;

= >

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

>

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

>

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

>= ;

>&nbs= p;   }

>

>  }

>

&g= t;

>

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

> position)

>  &nbs= p;       repLens[i] =3D 0;<= /p>

>

>     =      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++)

>

> +      {}

>

>  &nb= sp;     repLens[i] =3D len;

>

>      &nb= sp; if (len > repLens[repMaxIndex])

>

>        =   repMaxIndex =3D i;

>

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

&g= t; position)

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

>

&= gt;      {

>

>        unsigned= len;

> =

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

>

<= p class=3DMsoPlainText>> +    &nb= sp; p->backRes =3D (UInt32)repMaxIndex;

>

>        l= en =3D repLens[repMaxIndex];

<= span lang=3DEN-US>>

>        MOVE_POS(p, len= - 1)

> =

> =        return len;

>

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

<= span lang=3DEN-US>> UInt32 position)

>

>

= >      curByte =3D *data;

>

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

>

> +

>

> +    last =3D repLens[repMax= Index];

>= ;

> +&n= bsp;   if (last <=3D mainLen)

>

> +      last =3D ma= inLen;

>=

>

>

> -  &= nbsp; if (mainLen < 2 && curByte !=3D matchByte && repLe= ns[repMaxIndex] <

> 2)

>

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

> =

> =      {

>

>        p->backRes =3D= MARK_LIT;

= >

>&= nbsp;       return 1;

>

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

= > UInt32 position)

>       = ;     LitEnc_Matched_GetPrice(probs, curByte, matchByte= ,

> p-&g= t;ProbPrices) :

>

= >            LitE= nc_GetPrice(probs, curByte, p->ProbPrices));

>

>      }

> <= /span>

> -

>

> +

>

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

>

>

>

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

>

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

>

>

>

> -    if (matchByte =3D=3D curByte)<= /o:p>

> =

> +  &nb= sp; // 18.06

>

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

= >

>&= nbsp;     {

>

>        UInt32 short= RepPrice =3D repMatchPrice + GetPrice_ShortRep(p,

> p->state, posState);

>

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

>

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

> UInt32 position)=

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

> <= /span>

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

>

>  &n= bsp;     }

>

> +      if (last < 2)

> <= /span>

> +  &nbs= p;   {

>

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

>

>= +        return 1;

>

> +     = }

>

> &nb= sp;    }

>

> -

>

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

&= gt; repLens[repMaxIndex]);

>

> -

>

> -    if (last < 2)

>

> -    {=

>

<= p class=3DMsoPlainText>> -    &nb= sp; p->backRes =3D p->opt[1].dist;

>

> -      return 1;

>

> -  &= nbsp; }

>= ;

> -

>

> +=

>

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

>

>

>

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

>

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

> UInt32 position)

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

>

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

= >

>

>

> -    {

>

> -      unsigned len =3D last;=

> =

> - &nb= sp;    do

>

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

>

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

>

> -  &n= bsp; }

>=

> -

>

>  &n= bsp;   // ---------- REP ----------

>

>

>

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

>

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

> UInt32= position)

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

>

>      &nbs= p; do

> =

> =        {

>

> -        UIn= t32 price2 =3D price +

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

>

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

> repLen);

<= span lang=3DEN-US>>

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

>

>        =   if (price2 < opt->price)

>

>        &= nbsp; {

>= ;

>&nbs= p;           opt->pric= e =3D price2;

>

&g= t; -          opt->len =3D = repLen;

>= ;

> -&n= bsp;         opt->dist =3D i;

>

> +  =         opt->len =3D (UInt32)repLen;<= o:p>

> <= /o:p>

> + &nbs= p;        opt->dist =3D (UInt32)i;

>

>  &n= bsp;         opt->extra =3D 0;

>

>  &= nbsp;       }

>

>       &nb= sp;}

> <= o:p>

> @@ -12= 11,38 +1267,41 @@ static unsigned GetOptimum(CLzmaEnc *p,=

> UInt32 position)

> <= /span>

>

>    = ;  // ---------- MATCH ----------

>

>      {

>

> -    &= nbsp; unsigned len  =3D ((repLens[0] >=3D 2) ? repLens[0] + 1 : 2);=

> =

> + &nb= sp;    unsigned len =3D repLens[0] + 1;

>

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

>

>        {

> <= /span>

>   =        unsigned offs =3D 0;=

>

<= p class=3DMsoPlainText>>     = ;     UInt32 normalMatchPrice =3D matchPrice +

> GET_PRICE_0(p-= >isRep[p->state]);

>

>

>

= > -        while (len > matches[of= fs])

> <= o:p>

> - = ;         offs +=3D 2;

> =

> +   &nbs= p;    if (len < 2)

>

> +        =   len =3D 2;

>

> +        else

>

=

> +    &n= bsp;     while (len > matches[offs])

>

> +    &= nbsp;       offs +=3D 2;

>

>

>

>      &nbs= p;   for (; ; len++)

>

>          {=

> =

>  = ;          COptimal *opt;=

>

>  &nbs= p;         UInt32 dist =3D matches[= (size_t)offs + 1];

>

> -          UInt32 pr= ice2 =3D normalMatchPrice +

> p->lenEnc.prices[posState][(size_t)len - LZMA_MATC= H_LEN_MIN];

>

>= +          UInt32 price =3D n= ormalMatchPrice +

> GET_PRICE_LEN(&p->lenEnc, posState, len);<= /span>

>

>    = ;        unsigned lenToPosState =3D GetL= enToPosState(len);

>

>

= >

>&= nbsp;           if (dist = < kNumFullDistances)

>

> -          = ;  price2 +=3D p->distancesPrices[lenToPosState][dist &

> (kNumFullDist= ances - 1)];

>

>= ; +            price= +=3D p->distancesPrices[lenToPosState][dist &

=

> (kNumFullDistances - 1)];

>

>  &= nbsp;         else

>

=

>    &nbs= p;       {

>

>       &nbs= p;      unsigned slot;

>

>      &nb= sp;       GetPosSlot2(dist, slot);=

>

> -   &n= bsp;        price2 +=3D p->alignPrice= s[dist & kAlignMask];

>

> -          = ;  price2 +=3D p->posSlotPrices[lenToPosState][slot];

> <= /p>

> +    = ;        price +=3D p->alignPrices[di= st & kAlignMask];

>

> +          &nb= sp; price +=3D p->posSlotPrices[lenToPosState][slot];<= /p>

>

>     =        }

>

>

<= span lang=3DEN-US>>

>         &nbs= p;  opt =3D &p->opt[len];

>

>

>

> -          if= (price2 < opt->price)

<= span lang=3DEN-US>>

> +          i= f (price < opt->price)

<= span lang=3DEN-US>>

>         &nbs= p;  {

= >

> = -            opt->= ;price =3D price2;

>

> -           &nb= sp;opt->len =3D len;

>

> +          = ;  opt->price =3D price;

>

> +        &nbs= p;   opt->len =3D (UInt32)len;

>

>      &nbs= p;       opt->dist =3D dist + LZMA_NUM_REP= S;

>

> &nb= sp;            opt-&= gt;extra =3D 0;

>

= >            }

>

> @@ -1277,16 += 1336,43 @@ static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 position)

> <= /p>

>

>    for (;;)

>

>  &n= bsp; {

>=

> -&nb= sp;   UInt32 numAvail, numAvailFull;

>

> +    unsigned numAvail;<= o:p>

> <= /o:p>

> + &nbs= p;  UInt32 numAvailFull;

= >

>      unsigned newLen, numPairs,= prev, state, posState, startLen;

>

<= span lang=3DEN-US>> -    UInt32 curPrice, litPrice, match= Price, repMatchPrice;

>

> -    Bool nextIsLit;

>

> +    UInt32 litPrice, ma= tchPrice, repMatchPrice;

>

> +    BoolInt nextIsLit;

=

>

>      By= te curByte, matchByte;

>

>      const Byte *data;

> =

>    =   COptimal *curOpt, *nextOpt;

>

= >

>

>      if (++cur =3D=3D last)

>

> -   = ;   return Backward(p, cur);

>

> +      break;

>

> +=

>

<= p class=3DMsoPlainText>> +    // 18.06=

> =

> + &nb= sp;  if (cur >=3D kNumOpts - 64)

>

> +    {

>

> +      un= signed j, best;

>

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

> =

> + &nb= sp;    best =3D cur;

>

> +      for (j =3D cur + 1= ; j <=3D last; j++)

>

> +      {

>

> +     &nb= sp;  UInt32 price2 =3D p->opt[j].price;

>

> +      &= nbsp; if (price >=3D price2)

>

> +        {

>

> +   =        price =3D price2;

>

> +     =      best =3D j;

>

> +        }

>

> +  &= nbsp;   }

>

> +      {

>

> +      &n= bsp; unsigned delta =3D best - cur;

>

> +        if (de= lta !=3D 0)

>

>= +        {

>

> +      &n= bsp;   MOVE_POS(p, delta);

>

> +        }

>

> +  &= nbsp;   }

>

> +      cur =3D best;

>

> +     = ; break;

&g= t;

> +&= nbsp;   }

>

>

= >

>&= nbsp;     newLen =3D ReadMatchDistances(p, &numPair= s);

>

>

> <= /span>

> @@ -1294,15 +1380= ,24 @@ static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 position)=

>    =   {

&g= t;

>&nb= sp;       p->numPairs =3D numPairs;

> <= /span>

>   =      p->longestMatchLen =3D newLen;

>

=

> -    &n= bsp; return Backward(p, cur);

= >

> +      break;=

>

<= p class=3DMsoPlainText>>     = ; }

>

>

> <= /span>

>   =    curOpt =3D &p->opt[cur];

>

> +

>

> +    position++;

>

=

> +

>

> +    // we need tha= t check here, if skip_items in p->opt are possible

=

>

> +    /*

>

> +    = if (curOpt->price >=3D kInfinityPrice)

>

> +      continu= e;

>

> + &= nbsp;  */

>

&= gt; +

> =

> =      prev =3D cur - curOpt->len;

>

> -

>

> +

>

>      if (curOpt->len= =3D=3D 1)

= >

>&= nbsp;     {

>

> -      state =3D p->opt[pr= ev].state;

= >

> = +      state =3D (unsigned)p->opt[prev].state;<= o:p>

> <= /o:p>

>  =       if (IsShortRep(curOpt))

>

>     &n= bsp;    state =3D kShortRepNextStates[state];

>

>    &n= bsp;   else

>

> @@ -1316,14 +1411,14 @@ static unsigned GetOptimum(CLzmaEnc *p,<= o:p>

> UInt32= position)

= >

> =

> =        if (curOpt->extra)

>

=

>    &nbs= p;   {

>

> -        prev -=3D curOpt->extr= a;

>

> + &= nbsp;      prev -=3D (unsigned)curOpt->extra;

>

>  &= nbsp;       state =3D kState_RepAfterLit;

>

>  &nb= sp;       if (curOpt->extra =3D=3D 1)=

>

> -  &n= bsp;       state =3D (dist < LZMA_NUM_REPS= ) ? kState_RepAfterLit :

> kState_MatchAfterLit;

>

> +       &n= bsp;  state =3D (dist < LZMA_NUM_REPS ? kState_RepAfterLit :

> kState_Match= AfterLit);

= >

>&= nbsp;       }

>

>      &nbs= p; else

>= ;

>&nbs= p;       {

>

> -        s= tate =3D p->opt[prev].state;

>

> +        state =3D = (unsigned)p->opt[prev].state;

>

>         = if (dist < LZMA_NUM_REPS)

= >

>         &nb= sp;  state =3D kRepNextStates[state];

>

>       &n= bsp;  else

>

= > @@ -1379,7 +1474,6 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32

> positio= n)

>&nbs= p;     curByte =3D *data;

>

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

>

>

>

= > -    position++;

>

>      posState =3D (posit= ion & p->pbMask);

>

>

>

= >      /*

>

> @@ -1391,13 +1485,25 @@ static unsigned GetOptim= um(CLzmaEnc *p,

> UInt32 position)

>         <&n= bsp; MATCH  [ : LIT : REP_0 ]

>

= >      */<= /p>

>

>

>

> -    curPrice =3D curOpt= ->price;

>

>= -    litPrice =3D curPrice + GET_PRICE_0(p->isMatch[stat= e][posState]);

>

&= gt; +    {

>

> +      UInt32 curPrice =3D curOpt-&= gt;price;

&= gt;

> +=       unsigned prob =3D p->isMatch[state][posSt= ate];

> =

> +&nbs= p;     matchPrice =3D curPrice + GET_PRICE_1(prob);

>

> +  &= nbsp;   litPrice =3D curPrice + GET_PRICE_0(prob);

>

> +    }

>

>

> <= /p>

>    &= nbsp; nextOpt =3D &p->opt[(size_t)cur + 1];

>

>      next= IsLit =3D False;

>

>

>=

> -&nb= sp;   // if (litPrice >=3D nextOpt->price) litPrice =3D 0; = else // 18.new

>

&= gt; +    // here we can allow skip_items in p->opt, if we= don't check

> (nextOpt->price < kInfinityPrice)

>

> +    // 18.new.06

> <= /span>

> +  &nbs= p; if ((nextOpt->price < kInfinityPrice

>

> +      &n= bsp; // && !IsLitState(state)

>

> +        &= ;& matchByte =3D=3D curByte)

>

> +        || litPri= ce > nextOpt->price

>

> +        )

>

> +    =   litPrice =3D 0;

>

> +    else

>

>      {

>

>    &n= bsp;   const CLzmaProb *probs =3D LIT_PROBS(position, *(data - 1)= );

>

> &nb= sp;      litPrice +=3D (!IsLitState(state) ?<= /o:p>

> =

> @@ -1413,21 +151= 9,32 @@ static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 position)

>    = ;    }

>

>      }

>

>

>

> -    matchPrice =3D curPrice + GET_PRI= CE_1(p->isMatch[state][posState]);

>

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

>

>

>

> +    numAvailFull =3D p->numAva= il;

>

> + =    {

>

&= gt; +      unsigned temp =3D kNumOpts - 1 - cur;

>

> +  = ;    if (numAvailFull > temp)

>

> +      &= nbsp; numAvailFull =3D (UInt32)temp;

>

> +    }

>

> +

>

> +    // 18.06<= /p>

>

>     = // ---------- SHORT_REP ----------

>

> -    // if (IsLitState(state)) // 1= 8.new

> =

> +&nbs= p;   if (IsLitState(state)) // 18.new

>

>      if (matc= hByte =3D=3D curByte)

>

> -    // if (repMatchPrice < nextOpt->price)= // 18.new

= >

> = -    if (nextOpt->len < 2

>

> +    if (repMatchPrice &= lt; nextOpt->price) // 18.new

>

> +    // if (numAvailFull < 2 || dat= a[1] !=3D *(data - reps[0] + 1))

>

> +    if (

>

> +      &n= bsp; // nextOpt->price >=3D kInfinityPrice ||

>

> +     &nb= sp;  nextOpt->len < 2   // we can check nextOpt->le= n, if skip items

> are not allowed in p->opt

>

>        = ;  || (nextOpt->dist !=3D 0

>

> -        &= nbsp;   && nextOpt->extra <=3D 1 // 17.old

>

> -   =      ))

>

> +         &nb= sp;  // && nextOpt->extra <=3D 1 // 17.old

> <= /p>

> +    = ;        )

>

> +      &n= bsp; )

>=

> = ;     {

>

>        UInt32 shortRepP= rice =3D repMatchPrice + GetPrice_ShortRep(p, state,

<= p class=3DMsoPlainText>> posState);=

>

<= p class=3DMsoPlainText>> -    &nb= sp; if (shortRepPrice <=3D nextOpt->price) // 17.old

>

=

> -    &n= bsp; // if (shortRepPrice < nextOpt->price)  // 18.new

>

> +   &= nbsp;  // if (shortRepPrice <=3D nextOpt->price) // 17.old<= /o:p>

> =

> +  &nb= sp;   if (shortRepPrice < nextOpt->price)  // 18.new

>

>  &= nbsp;     {

>

>          = nextOpt->price =3D shortRepPrice;

>

>        &n= bsp; nextOpt->len =3D 1;

>

> @@ -1436,13 +1553,6 @@ static unsigned GetOptimum(CLzmaEnc= *p,

> U= Int32 position)

>        }

=

>

>      }<= o:p>

> <= /o:p>

> =

>

> -    n= umAvailFull =3D p->numAvail;

>

> -    {

>

> -      UInt32 temp= =3D kNumOpts - 1 - cur;

>

> -      if (numAvailFull > temp)<= o:p>

> <= /o:p>

> - &nbs= p;      numAvailFull =3D temp;

>

> -    }

>

> -=

>

<= p class=3DMsoPlainText>>     = ; if (numAvailFull < 2)

>

>        continue;

>

>   &= nbsp;  numAvail =3D (numAvailFull <=3D p->numFastBytes ? numAvai= lFull :

>= ; p->numFastBytes);

>

> @@ -1451,9 +1561,8 @@ static unsigned GetOptimum(CLzmaEnc *p= , UInt32

&g= t; position)

>

>= ;

>&nbs= p;     // ---------- LIT : REP_0 ----------<= /span>

>

>

=

>

> -    if (

>

> -   = ;     // litPrice !=3D 0 && // 18.new

>

> -   &= nbsp;    !nextIsLit

>

= > +    if (!nextIsLit

>

=

> +    &n= bsp;   && litPrice !=3D 0 // 18.new

=

>

>     &nb= sp;    && matchByte !=3D curByte

>

>     &= nbsp;    && numAvailFull > 2)

>

>      = {

>

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

> position)<= /span>

>   =        if (limit > numAvailFull)

>

>   &nb= sp;        limit =3D numAvailFull;<= /o:p>

> =

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

>

> -        {=

> =

> - &nb= sp;      }

>

> +        {}

>

>

> <= /p>

>    &= nbsp;     {

>

>         &= nbsp;  unsigned state2 =3D kLiteralNextStates[state];

>

=

> @@ -1474,8 +1582,9 @@ stati= c unsigned GetOptimum(CLzmaEnc *p, UInt32

> position)

>      = ;      UInt32 price =3D litPrice + GetPrice_Rep_0(= p, state2, posState2);

>

>          &= nbsp; {

>= ;

>&nbs= p;             = unsigned offset =3D cur + len;

>

> -         =    while (last < offset)

>

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

> =

> +

>

> +   =          if (last < offset)=

>

> +  &n= bsp;           last =3D o= ffset;

>=

>

>

>  &nb= sp;           // do<= /o:p>

> =

>   = ;           {<= /span>

>

> @@ -1483,14 +1592,14 @= @ static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 position)

<= p class=3DMsoPlainText>>     = ;           COptimal *opt= ;

>

> &nbs= p;            &= nbsp; len--;

>

>= ;            &n= bsp;   // price2 =3D price + GetPrice_Len_Rep_0(p, len, state2,

> posStat= e2);

> <= o:p>

> - = ;             p= rice2 =3D price + p->repLenEnc.prices[posState2][len -=

> LZMA_MATCH_LEN_MIN];

>

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

> posState2, len);

>

>

>

>      = ;          opt =3D &p->= opt[offset];

>

>= ;            &n= bsp;   // offset--;

= >

>         &nb= sp;      if (price2 < opt->price)=

>

>   &nbs= p;            {=

>

>  &nbs= p;            &= nbsp;  opt->price =3D price2;

>

> -        = ;        opt->len =3D len;=

>

> +   &n= bsp;            opt-= >len =3D (UInt32)len;

>

>          &= nbsp;       opt->dist =3D 0;

> <= /p>

>    &= nbsp;            &nb= sp;opt->extra =3D 1;

>

>          &= nbsp;     }

>

> @@ -1502,6 +1611,7 @@ static unsigned GetOptimum(CLzma= Enc *p, UInt32

> position)

>      }

>

>

>

>      startLen =3D 2; /* = speed optimization */

>

> +

>

>= ;      {

>

<= span lang=3DEN-US>>        // -------= --- 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])

>

>          &= nbsp; continue;

>

= >

> =

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

>

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

= >

> = +        {}

>

>

>

>        &n= bsp; // if (len < startLen) continue; // 18.new: speed optimization=

>

>

>

> -    =     while (last < cur + len)

>

> -      &n= bsp;   p->opt[++last].price =3D kInfinityPrice;

>

> +    =     {

>

> +          unsigned = offset =3D cur + len;

>

> +          if (last= < offset)

>

&g= t; +            last= =3D offset;

>

>= ; +        }

>

>      &nb= sp;   {

>

>           = unsigned len2 =3D len;

>

>          &= nbsp; price =3D repMatchPrice + GetPrice_PureRep(p, repIndex, state,

> posState);

>

>  &= nbsp;         do<= /p>

>

>     =        {

>

> -       &nbs= p;    UInt32 price2 =3D price +

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

>

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

> posState, len2);=

> =

>  = ;            COptima= l *opt =3D &p->opt[cur + len2];

>

>        =       if (price2 < opt->price)

> <= /p>

>    &= nbsp;         {

>

>     &= nbsp;          opt->price = =3D price2;

>

>= ; -            =   opt->len =3D len2;

<= span lang=3DEN-US>>

> -         &n= bsp;    opt->dist =3D repIndex;

>

> +     &nb= sp;        opt->len =3D (UInt32)len2;=

> =

> + &nb= sp;            opt-&= gt;dist =3D (UInt32)repIndex;

= >

>         &nb= sp;      opt->extra =3D 0;

>

>     &n= bsp;        }

>

>      = ;      }

>

<= span lang=3DEN-US>> @@ -1551,15 +1665,14 @@ static unsigned GetOptimum(C= LzmaEnc *p,

> UInt32 position)

>          = ;  if (limit > numAvailFull)

>

>        &n= bsp;     limit =3D numAvailFull;

<= p class=3DMsoPlainText>>

>

>

> -       =    for (; len2 < limit && data[len2] =3D=3D data2[len2= ]; len2++);

>

>= -

>

> - &= nbsp;        len2 -=3D len;

> =

> -   &nbs= p;      if (len2 >=3D 3)

<= p class=3DMsoPlainText>>

> +     &n= bsp;    len2 +=3D 2;

>

> +        &= nbsp; if (len2 <=3D limit)

= >

> +          = if (data[len2 - 2] =3D=3D data2[len2 - 2])

>

> +       =    if (data[len2 - 1] =3D=3D data2[len2 - 1])

>

>     &= nbsp;      {

>

>        &= nbsp;     unsigned state2 =3D kRepNextStates[state];

>

>  &n= bsp;           unsigned p= osState2 =3D (position + len) & p->pbMask;

>

> -     &nb= sp;      price +=3D

>

> -      &n= bsp;           p->repL= enEnc.prices[posState][(size_t)len - 2]

>

> +       &nb= sp;    price +=3D GET_PRICE_LEN(&p->repLenEnc, posSta= te, len)

&g= t;

>&nb= sp;            =      + GET_PRICE_0(p->isMatch[state2][posState2])

>

>  &n= bsp;            = ;   + LitEnc_Matched_GetPrice(LIT_PROBS(position + len,

> data[(size_t)le= n - 1]),

&g= t;

>&nb= sp;            =          data[len], data2[len], p-&= gt;ProbPrices);

>

= > @@ -1570,31 +1683,40 @@ static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 posit= ion)

> <= o:p>

> <= /o:p>

> =

>

>   &nbs= p;          price +=3D GetPric= e_Rep_0(p, state2, posState2);

>

> +

>

> +          for (; l= en2 < limit && data[len2] =3D=3D data2[len2]; len2++)=

>

> +   &n= bsp;      {}

>

> +

<= span lang=3DEN-US>>

> +          l= en2 -=3D len;

>

&g= t; +          // if (len2 >= = =3D 3)

>= ;

> +&n= bsp;         {

>

>     &n= bsp;        {

>

>      = ;          unsigned offset =3D= cur + len + len2;

>

> -          &nbs= p;   while (last < offset)

>

> -       &nb= sp;        p->opt[++last].price =3D k= InfinityPrice;

>

&= gt; +

> =

> +&nbs= p;             = if (last < offset)

>

> +          &nb= sp;     last =3D offset;

>

>      &nbs= p;         // do<= /p>

>

>     =            {

> =

> -   &nbs= p;            unsign= ed price2;

= >

> = +            &n= bsp;   UInt32 price2;

>

>         &= nbsp;        COptimal *opt;

> =

>    =             &nb= sp; len2--;

>

>=             &nb= sp;     // price2 =3D price + GetPrice_Len_Rep_0(p, len= 2, state2,

= > posState2);

>

> -           &n= bsp;    price2 =3D price + p->repLenEnc.prices[posState2]= [len2 -

>= ; LZMA_MATCH_LEN_MIN];

>

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

> posState2, len2);

>

>

>

= >            = ;      opt =3D &p->opt[offset];<= /span>

>

>    = ;            &n= bsp; // offset--;

>

>           =        if (price2 < opt->price)

>

>   &= nbsp;           &nbs= p;  {

= >

>&= nbsp;           &nbs= p;       opt->price =3D price2;=

>

> -   &n= bsp;            = ;  opt->len =3D len2;

= >

> +         &= nbsp;        opt->len =3D (UInt32)len= 2;

>

> &nb= sp;            =       opt->extra =3D (CExtra)(len + 1);

>

> -   = ;            &n= bsp;  opt->dist =3D repIndex;

>

> +        = ;          opt->dist =3D (U= Int32)repIndex;

>

= >            = ;      }

>

<= span lang=3DEN-US>>         = ;       }

>

>        = ;        // while (len2 >=3D 3);=

>

>  &nbs= p;           }=

>

>   &nbs= p;        }

>

> +      &n= bsp;   }

>

>          }

>

>   &nb= sp;    }

>

>      }

>

> @@ -1606,17 +1728,23 @@ static unsigned= GetOptimum(CLzmaEnc *p,

> UInt32 position)

>      {

> <= /p>

>    &= nbsp;   newLen =3D numAvail;

>

>        for (= numPairs =3D 0; newLen > matches[numPairs]; numPairs +=3D 2);=

>

> -   &n= bsp;  matches[numPairs] =3D newLen;

>

> +      matches[numPa= irs] =3D (UInt32)newLen;

>

>        numPairs +=3D 2;

>

>  &= nbsp;   }

>

>

= >

> = +    // startLen =3D 2; /* speed optimization */<= /span>

>

> +

>

>      i= f (newLen >=3D startLen)

>

>      {

>

>      = ;  UInt32 normalMatchPrice =3D matchPrice +

> GET_PRICE_0(p->isRep[state]);=

> =

>  = ;      UInt32 dist;

>

>      &nbs= p; unsigned offs, posSlot, len;

>

> -      while (last < cur += newLen)

&g= t;

> -&= nbsp;       p->opt[++last].price =3D kInfi= nityPrice;

= >

> = +

>

> + &n= bsp;    {

>

> +        unsigned offset = = =3D cur + newLen;

>

> +        if (last < offset)=

> =

> + &nb= sp;        last =3D offset;

> =

> +   &nbs= p;  }

= >

> =

> =

>  = ;      offs =3D 0;

>

>      &nbs= p; while (startLen > matches[offs])

>

> @@ -1628,27 +1756,29 @@ static unsigned GetOpti= mum(CLzmaEnc *p,

> UInt32 position)

>

>

>        for (len =3D /*2*/= startLen; ; len++)

>

>        {

=

>

> -     &= nbsp;  UInt32 price =3D normalMatchPrice +

> p->lenEnc.prices[posState][(si= ze_t)len - LZMA_MATCH_LEN_MIN];

>

> +        UInt32 pri= ce =3D normalMatchPrice + GET_PRICE_LEN(&p->lenEnc,

> posState, len);

> <= /span>

>   =        {

>

>        =     COptimal *opt;

>

<= span lang=3DEN-US>> -         &n= bsp;unsigned lenToPosState =3D len - 2; lenToPosState =3D=

> GetLenToPosState2(lenTo= PosState);

= >

> = +          unsigned lenNorm = =3D len - 2;

>

&g= t; +          lenNorm =3D GetL= enToPosState2(lenNorm);

>

>          &= nbsp; if (dist < kNumFullDistances)

>

> -       &nbs= p;    price +=3D p->distancesPrices[lenToPosState][dist &= amp;

> (= kNumFullDistances - 1)];

>

> +          = ;  price +=3D p->distancesPrices[lenNorm][dist &

> (kNumFullDistances -= 1)];

> =

> =            else

>

> -   &= nbsp;        price +=3D p->posSlotPri= ces[lenToPosState][posSlot] +

= > p->alignPrices[dist & kAlignMask];

>

> +   &= nbsp;        price +=3D p->posSlotPri= ces[lenNorm][posSlot] +

> p->alignPrices[dist & kAlignMask];

>

>

>

>      = ;      opt =3D &p->opt[cur + len];

>

>   &n= bsp;        if (price < opt->price= )

>

> &nbs= p;          {

>

=

>    &nbs= p;         opt->price =3D price;=

> =

> - &nb= sp;          opt->len =3D l= en;

>

> + =            opt->len = =3D (UInt32)len;

>

>           =    opt->dist =3D dist + LZMA_NUM_REPS;

>

>      = ;        opt->extra =3D 0;=

>

>   &nbs= p;        }

>

>      &nbs= p;   }

>

>

>=

> -&nb= sp;       if (/*_maxMode && */ len = =3D=3D matches[offs])

>

> +        if (len =3D=3D m= atches[offs])

>

&g= t;          {

>

=

> +    &n= bsp;     // if (p->_maxMode) {

=

>

>     &nb= sp;      // MATCH : LIT : REP_0<= /p>

>

>

>

>      &nbs= p;     const Byte *data2 =3D data - dist - 1;

>

> @@ -1657,11 +1787,17= @@ static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 position)=

>    =         if (limit > numAvailFull)

>

>  &nb= sp;           limit =3D n= umAvailFull;

>

>= ;

>

> - &= nbsp;        for (; len2 < limit &= ;& data[len2] =3D=3D data2[len2]; len2++);

>

> +      &n= bsp;   len2 +=3D 2;

= >

> +          = if (len2 <=3D limit)

>

> +          if (= data[len2 - 2] =3D=3D data2[len2 - 2])

>

> +       &nbs= p;  if (data[len2 - 1] =3D=3D data2[len2 - 1])

>

> +     &nb= sp;    {

>

> +          for = (; len2 < limit && data[len2] =3D=3D data2[len2]; len2++)

> <= /span>

> +  &nbs= p;       {}

>

>

>

>         &= nbsp;  len2 -=3D len;

>

>

>

> -          if (len2 >= = =3D 3)

>= ;

> +&n= bsp;         // if (len2 >=3D 3)=

> =

>  = ;          {=

>

<= p class=3DMsoPlainText>>     = ;         unsigned state2 =3D kMatc= hNextStates[state];

>

>           =    unsigned posState2 =3D (position + len) & p->pbMask;

>

> @@ -1677,27 += 1813,30 @@ static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 position)

>   &n= bsp;          price +=3D GetPr= ice_Rep_0(p, state2, posState2);

>

>

>

>          &= nbsp;   offset =3D cur + len + len2;

>

> -      &n= bsp;     while (last < offset)

=

>

> -     &= nbsp;        p->opt[++last].price =3D= kInfinityPrice;

>

> +

>= ;

> +&n= bsp;           if (last &= lt; offset)

>

>= +            &= nbsp; last =3D offset;

>

>          &= nbsp;   // do

>

>          &= nbsp;   {

>

>           =      UInt32 price2;

>

>        = ;        COptimal *opt;

>

=

>    &nbs= p;           len2--;=

>

>  &nbs= p;             = // price2 =3D price + GetPrice_Len_Rep_0(p, len2, state2,=

> posState2);<= /span>

>

> -   &nb= sp;          price2 =3D price = + p->repLenEnc.prices[posState2][len2 -

> LZMA_MATCH_LEN_MIN];=

>

<= p class=3DMsoPlainText>> +    &nb= sp;         price2 =3D price + GET_= PRICE_LEN(&p->repLenEnc,

> posState2, len2);

>

>      &nbs= p;         opt =3D &p->opt[o= ffset];

>= ;

>&nbs= p;            &= nbsp;  // offset--;

>

>          &= nbsp;     if (price2 < opt->price)

>

>    &n= bsp;           {

>

>   &n= bsp;            = ;  opt->price =3D price2;

>

<= span lang=3DEN-US>> -        &nb= sp;       opt->len =3D len2;

> <= /p>

> +    = ;            opt->= ;len =3D (UInt32)len2;

>

>          &= nbsp;       opt->extra =3D (CExtra)(len + = 1);

>

> &n= bsp;            = ;    opt->dist =3D dist + LZMA_NUM_REPS;

>

=

>    &nbs= p;           }=

>

>   &nbs= p;          }

>

=

>    &nbs= p;         // while (len2 >=3D 3= );

>

> &nb= sp;          }

>

> +

>

> +     &nb= sp;    }

>

>

>

= >            offs= +=3D 2;

&g= t;

>&nb= sp;           if (offs = =3D=3D numPairs)

>

> @@ -1709,6 +1848,12 @@ static unsigned GetOptimum(CLzmaEnc *p,

> UInt32 p= osition)

&g= t;        }

>

>      }

>

>    = }

>

> +

>

> +  do

>

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

>

> +  while (--last);

>

> +

>

> +  return Backward(p, cur);

>

>  }=

>

>

>

>

>

> @@ -1735,6 +1880,7 @@ static unsig= ned GetOptimumFast(CLzmaEnc *p)

>    p->backRes =3D MARK_LIT;

>

>  &nb= sp; if (numAvail < 2)

>

>      return 1;

>

> +  // if (mainLen < 2 &= amp;& p->state =3D=3D 0) return 1; // 18.06.notused

>

=

>    if (numAv= ail > LZMA_MATCH_LEN_MAX)

<= span lang=3DEN-US>>

>      numAvail =3D LZMA_MATCH_LEN= _MAX;

> =

> =    data =3D p->matchFinder.GetPointerToCurrentPos(p->matchF= inderObj) - 1;

>

&= gt; @@ -1746,10 +1892,11 @@ static unsigned GetOptimumFast(CLzmaEnc *p)

> &nbs= p;    const Byte *data2 =3D data - p->reps[i];=

>

>   &nbs= p;  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++)=

>

<= p class=3DMsoPlainText>> +    {}<= /o:p>

> =

>   = ;   if (len >=3D p->numFastBytes)

>

>      {

>

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

>

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

>

= >        MOVE_POS(p, len - 1)

>

>   &= nbsp;    return len;

>

>      }<= /p>

>

> @@ -1793,7 +1940,7 @@ static = unsigned GetOptimumFast(CLzmaEnc *p)

>       &nb= sp;  || (repLen + 2 >=3D mainLen && mainDist >=3D (1 <= ;< 9))

&= gt;

>&n= bsp;         || (repLen + 3 >=3D= mainLen && mainDist >=3D (1 << 15)))

>

>    {<= /span>

>

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

>

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

>

>  &nbs= p;   MOVE_POS(p, repLen - 1)

>

>      return repLen;

>

>  &n= bsp; }

>=

> @@ -= 1932,23 +2079,22 @@ MY_NO_INLINE static SRes Flush(CLzmaEnc *p,<= /span>

> UInt32 nowPos)

>  }<= o:p>

> <= /o:p>

> =

>

>

>

> -

>

> -static void FillAlignPrices(CLzmaEnc *= p)

>

> +MY_NO_I= NLINE static void FillAlignPrices(CLzmaEnc *p)

>

>  {

>

>    unsigned i;

>

>    co= nst CProbPrice *ProbPrices =3D p->ProbPrices;

>

>    const CLzmaProb = *probs =3D p->posAlignEncoder;

>

<= span lang=3DEN-US>> -  p->alignPriceCount =3D 0;

>

> +  // p->alignPric= eCount =3D 0;

>

&g= t;    for (i =3D 0; i < kAlignTableSize / 2; i++)

>

>    = {

>

> &nbs= p;    UInt32 price =3D 0;

>

> -    unsigned symbol =3D i;

>

> +  =   unsigned sym =3D i;

>

>      unsigned m =3D 1;<= /span>

>

>    = ;  unsigned bit;

>

>      UInt32 prob;

=

>

> -    bit =3D symb= ol & 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[m], bit); m

=3D

> (m << 1)= + bit;

>= ;

> -&n= bsp;   bit =3D symbol & 1; symbol >>=3D 1; price +=3D G= ET_PRICEa(probs[m], bit); m

=3D

> (m << 1) + bit;

>

> -    bit =3D symbol & 1; symbo= l >>=3D 1; price +=3D GET_PRICEa(probs[m], bit); m<= /p>

=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

&g= t; << 1) + bit;

>

>      prob =3D probs[m];

>

>    &nb= sp; 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)

>  }=

>

<= p class=3DMsoPlainText>>

>

>

>

> -static void FillDistancesPrices(CLzmaEnc *p)

>

> +MY_NO_INLINE= static void FillDistancesPrices(CLzmaEnc *p)

>

>  {

>

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

>

>= +

>

> &nb= sp;  UInt32 tempPrices[kNumFullDistances];

>

> -  unsigned i, lenToPosState;

>

> +  unsign= ed i, lps;

= >

> =

> =

>  = ;  const CProbPrice *ProbPrices =3D p->ProbPrices;

>

=

>    p->mat= chPriceCount =3D 0;

>

>

= >

> = -  for (i =3D kStartPosModelIndex; i < kNumFullDistances; i++)=

>

> +  for (i = = =3D kStartPosModelIndex / 2; i < kNumFullDistances / 2; i++)=

>

>    {

>

>  &= nbsp;   unsigned posSlot =3D GetPosSlot1(i);

>

> -    unsigned fo= oterBits =3D ((posSlot >> 1) - 1);

>

> +    unsigned footerBits =3D (= posSlot >> 1) - 1;

>

>      unsigned base =3D ((2 | (posSl= ot & 1)) << footerBits);

>

= > +    const CLzmaProb *probs =3D p-&g= t;posEncoders + (size_t)base * 2;

>

<= span lang=3DEN-US>>      // tempPrices[i] =3D R= cTree_ReverseGetPrice(p->posEncoders + base,

> footerBits, i - base, p->ProbP= rices);

>= ;

> -

>

> -  = ;  const CLzmaProb *probs =3D p->posEncoders + base;

>

>    &n= bsp; UInt32 price =3D 0;

>

>      unsigned m =3D 1;

> =

> -    uns= igned symbol =3D i - base;

>

> +    unsigned sym =3D i;

>

> +    unsigned o= ffset =3D (unsigned)1 << footerBits;

>

> +    base +=3D i;=

>

> +

>

> +    if (footer= Bits)

> =

> =      do

>

>      {

>

> -      un= signed bit =3D symbol & 1;

>

> -      symbol >>=3D 1;

>

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

>

> +      sy= m >>=3D 1;

>

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

= >

>&= nbsp;       m =3D (m << 1) + bit;<= /o:p>

> =

>   = ;   }

>

= >      while (--footerBits);<= /p>

>

> -    tempPrice= s[i] =3D price;

>

= > +

>=

> +&nb= sp;   {

>

> +      unsigned prob =3D probs[m];<= /o:p>

> =

> +  &nb= sp;   tempPrices[base       &n= bsp; ] =3D price + GET_PRICEa_0(prob);

>

> +      tempPrices[base= + offset] =3D price + GET_PRICEa_1(prob);

>

> +    }

=

>

>    }

> =

>

<= p class=3DMsoPlainText>>

> -  for (lenToPosState =3D 0;= lenToPosState < kNumLenToPosStates;

> lenToPosState++)

>

> +  for (lps =3D 0; lps < k= NumLenToPosStates; lps++)

>

>    {

>

= > -    unsigned posSlot;

> <= /p>

> -    cons= t CLzmaProb *encoder =3D p->posSlotEncoder[lenToPosState];

> <= /p>

> -    UInt= 32 *posSlotPrices =3D p->posSlotPrices[lenToPosState];=

>

<= p class=3DMsoPlainText>> -    unsigned= distTableSize =3D p->distTableSize;

>

> -    const CLzmaProb *probs =3D= encoder;

&= gt;

> -=     for (posSlot =3D 0; posSlot < distTableSize; posSlot = +=3D 2)

>= ;

> +&n= bsp;   unsigned slot;

>

> +    unsigned distTableSize2 =3D (p->= ;distTableSize + 1) >> 1;

>

> +    UInt32 *posSlotPrices =3D p->po= sSlotPrices[lps];

>

> +    const CLzmaProb *probs =3D p->posSlotEncod= er[lps];

&g= t;

> +<= o:p>

> <= /o:p>

> + &nbs= p;  for (slot =3D 0; slot < distTableSize2; slot++)

>

>    &nb= sp; {

> =

> -&nbs= p;     // posSlotPrices[posSlot] =3D RcTree_GetPrice(en= coder,

>= kNumPosSlotBits, posSlot, p->ProbPrices);

>

> -      UInt32 = price =3D 0;

>

>= ; +      // posSlotPrices[slot] =3D RcTree_GetPric= e(encoder, kNumPosSlotBits,

> slot, p->ProbPrices);

>

> +      UInt32 = price;

>=

> = ;       unsigned bit;

>

> -      un= signed symbol =3D (posSlot >> 1) + (1 << (kNumPosSlotBits - 1))= ;

>

> - &n= bsp;    UInt32 prob;

>

> -      bit =3D symbol &am= p; 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[symbol],=

> bit);=

>

> -   &n= bsp;  bit =3D symbol & 1; symbol >>=3D 1; price +=3D GET_PRI= CEa(probs[symbol],

> bit);

>

> -      bit =3D symbol & 1; symbol &g= t;>=3D 1; price +=3D GET_PRICEa(probs[symbol],

> bit);

>

> -      bi= t =3D symbol & 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[sym= bol],

> = bit);

> =

> -&nbs= p;     bit =3D symbol & 1; symbol >>=3D 1; pr= ice +=3D GET_PRICEa(probs[symbol],

> bit);

>

= > -      prob =3D probs[(pos= Slot >> 1) + (1 << (kNumPosSlotBits - 1))];

>

> -     &nbs= p;posSlotPrices[posSlot    ] =3D price + GET_PRICEa_0(prob);=

> =

> - &nb= sp;    posSlotPrices[posSlot + 1] =3D price + GET_PRICEa_1(p= rob);

> =

> +&nbs= p;     unsigned sym =3D slot + (1 << (kNumPosSlot= Bits - 1));

>

>= +      unsigned prob;

>

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

>=

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

>

<= span lang=3DEN-US>> +      bit =3D sym & 1;= sym >>=3D 1; price +=3D GET_PRICEa(probs[sym], bit);

>

> +    &= nbsp; bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[s= ym], bit);

= >

> = +      bit =3D sym & 1; sym >>=3D 1; pri= ce +=3D GET_PRICEa(probs[sym], bit);

>

> +      prob =3D probs[(s= ize_t)slot + (1 << (kNumPosSlotBits - 1))];

>

> +      po= sSlotPrices[(size_t)slot * 2    ] =3D price + GET_PRICEa_0(p= rob);

> =

> +&nbs= p;     posSlotPrices[(size_t)slot * 2 + 1] =3D price + = GET_PRICEa_1(prob);

>

>      }

>

> -    for (posSlot =3D kEndPos= ModelIndex; posSlot < distTableSize; posSlot++)

>

> -      po= sSlotPrices[posSlot] +=3D ((UInt32)(((posSlot >> 1) - 1) -=

> kNumAlignBits) &= lt;< kNumBitPriceShiftBits);

>

> -

>

> +

>

>      {

>

> -      UInt32 *distance= sPrices =3D p->distancesPrices[lenToPosState];

>

> +      UI= nt32 delta =3D ((UInt32)((kEndPosModelIndex / 2 - 1) -

> kNumAlignBits) << kN= umBitPriceShiftBits);

>

> +      for (slot =3D kEndPosModelIndex = / 2; slot < distTableSize2; slot++)

>

>        {

>

> -  &= nbsp;     distancesPrices[0] =3D posSlotPrices[0];=

>

> -  &n= bsp;     distancesPrices[1] =3D posSlotPrices[1];<= /o:p>

> =

> -  &nb= sp;     distancesPrices[2] =3D posSlotPrices[2];

> <= /span>

> -  &nbs= p;     distancesPrices[3] =3D posSlotPrices[3];

>

> +   = ;     posSlotPrices[(size_t)slot * 2    = ] +=3D delta;

>

&g= t; +        posSlotPrices[(size_t)slot *= 2 + 1] +=3D delta;

>

> +        delta +=3D ((UInt32)1= << kNumBitPriceShiftBits);

>

<= span lang=3DEN-US>>        }

>

> +   = }

>

> +

> <= /span>

> +  &nbs= p; {

> <= o:p>

> + = ;     UInt32 *dp =3D p->distancesPrices[lps];

> <= /span>

> +

>

> +    &= nbsp; dp[0] =3D posSlotPrices[0];

>

<= span lang=3DEN-US>> +      dp[1] =3D posSlotPri= ces[1];

>= ;

> +&n= bsp;     dp[2] =3D posSlotPrices[2];<= /p>

>

> +    &nbs= p; dp[3] =3D posSlotPrices[3];

>

> +

>

>        for (i =3D 4; i < k= NumFullDistances; i +=3D 2)

>

>        {

>

>    &n= bsp;     UInt32 slotPrice =3D posSlotPrices[GetPosSlot1= (i)];

> =

> -&nbs= p;       distancesPrices[i    = ] =3D slotPrice + tempPrices[i];

>

> -        distances= Prices[i + 1] =3D slotPrice + tempPrices[i + 1];

>

> +     &nb= sp;  dp[i    ] =3D slotPrice + tempPrices[i];

>

> +   &= nbsp;    dp[i + 1] =3D slotPrice + tempPrices[i + 1];

> <= /span>

>   =      }

>

>      }

>

>    }<= /p>

>

> +  // }

>

=

>  }

>

>

>

>

>

> @@ -2245,10 +2410,7 @@ static SRes LzmaEnc_CodeOn= eBlock(CLzmaEnc

> *p, UInt32 maxPackSize, UInt32 maxUnpa

>     &nb= sp;    if (len !=3D 1)

>

>        &= nbsp; {

>= ;

>&nbs= p;           LenEnc_Encod= e(&p->repLenProbs, &p->rc, len -

> LZMA_MATCH_LEN_MIN, posState);

>

> -  &= nbsp;       if (!p->fastMode)

> =

> -   &nbs= p;        if (--p->repLenEnc.counters= [posState] =3D=3D 0)

>

> -          &nbs= p;   LenPriceEnc_UpdateTable(&p->repLenEnc, posState,=

> &p->= ;repLenProbs, p->ProbPrices);

>

> -

>

> +          --p-= >repLenEncCounter;

>

>           = ; p->state =3D kRepNextStates[p->state];

>

>      &nbs= p;   }

>

>        }

>

> @@ -2260,9 +2422,7 @@ static SRes = LzmaEnc_CodeOneBlock(CLzmaEnc *p,

> UInt32 maxPackSize, UInt32 maxUnpa

>   &= nbsp;      p->state =3D kMatchNextStates[p->= state];

>= ;

>

>

>  &n= bsp;       LenEnc_Encode(&p->lenProbs,= &p->rc, len -

> LZMA_MATCH_LEN_MIN, posState);

>

> -      &n= bsp; if (!p->fastMode)

>

> -          if (= --p->lenEnc.counters[posState] =3D=3D 0)

>

> -      &n= bsp;     LenPriceEnc_UpdateTable(&p->lenEnc, pos= State,

>= &p->lenProbs, p->ProbPrices);

>

> +        /= / --p->lenEnc.counter;

>

>

>

= >          dist -=3D LZMA_N= UM_REPS;

&g= t;

>&nb= sp;         p->reps[3] =3D p->= ;reps[2];

&= gt;

> @= @ -2274,17 +2434,17 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc=

> *p, UInt32 maxPa= ckSize, UInt32 maxUnpa

>          GetP= osSlot(dist, posSlot);

>

>          // RcT= ree_Encode_PosSlot(&p->rc,

> p->posSlotEncoder[GetLenToPosState(len)], po= sSlot);

>= ;

>&nbs= p;         {

<= p class=3DMsoPlainText>>

> -     &n= bsp;    UInt32 symbol =3D posSlot + (1 << kNumPosSlotB= its);

> =

> +&nbs= p;         UInt32 sym =3D (UInt32)p= osSlot + (1 << kNumPosSlotBits);

>

>        =     range =3D p->rc.range;

>

>      &nbs= p;     probs =3D p->posSlotEncoder[GetLenToPosState(= len)];

>=

> = ;           do=

>

>   &nbs= p;        {

>

> -      &n= bsp;     CLzmaProb *prob =3D probs + (symbol >> k= NumPosSlotBits);

>

> -            U= Int32 bit =3D (symbol >> (kNumPosSlotBits - 1)) & 1;

> =

> -   &nbs= p;        symbol <<=3D 1;

>

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

>

<= span lang=3DEN-US>> +        &nb= sp;   UInt32 bit =3D (sym >> (kNumPosSlotBits - 1)) & 1= ;

>

> + &n= bsp;          sym <<=3D = 1;

>

> &nb= sp;            RC_BI= T(&p->rc, prob, bit);

<= span lang=3DEN-US>>

>         &nbs= p;  }

= >

> = -          while (symbol < = (1 << kNumPosSlotBits * 2));

>

= > +        &n= bsp; while (sym < (1 << kNumPosSlotBits * 2));

>

>     &= nbsp;      p->rc.range =3D range;

> <= /p>

>    &= nbsp;     }

>

>

>

> @@ -2295,7 +2455,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc = *p,

> UI= nt32 maxPackSize, UInt32 maxUnpa

>        &= nbsp;   if (dist < kNumFullDistances)

>

>      = ;      {

>

<= span lang=3DEN-US>>         = ;     unsigned base =3D ((2 | (posSlot & 1)) <&l= t; footerBits);

>

= > -            Rc= Tree_ReverseEncode(&p->rc, p->posEncoders + base,

> footerBits, dist - ba= se);

> <= o:p>

> + = ;           RcTree_Revers= eEncode(&p->rc, p->posEncoders + base,

> footerBits, (unsigned)(dist /* -= base */));

>

>=             }

> <= /span>

>   =          else

=

>

>     &nb= sp;      {

>

> @@ -2331,14 +2491,14 @@ static SRes LzmaEnc_CodeOn= eBlock(CLzmaEnc

> *p, UInt32 maxPackSize, UInt32 maxUnpa

>     &nb= sp;          bit =3D dist &= ; 1; dist >>=3D 1; RC_BIT(&p->rc,

> p->posAlignEncoder + m, bit); m= =3D (m << 1) + bit;

>

>          =       bit =3D dist & 1;    = ;         RC_BIT(&p->rc,

> p->pos= AlignEncoder + m, bit);

>

>          &= nbsp;     p->rc.range =3D range;

>

> -     = ;         p->alignPriceCount++;<= o:p>

> <= /o:p>

> + &nbs= p;            // p-&= gt;alignPriceCount++;

>

>           = ;   }

>

= >            }

>

>  &n= bsp;       }

>

>        }=

> =

>  = ;    }

>

>

>

>= -    nowPos32 +=3D len;

>

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

> =

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

<= p class=3DMsoPlainText>>

>

>

>      if (p->add= itionalOffset =3D=3D 0)

>

> @@ -2347,10 +2507,27 @@ static SRes LzmaEnc_CodeOneBlock(CLz= maEnc

> = *p, UInt32 maxPackSize, UInt32 maxUnpa

>

>

<= span lang=3DEN-US>>        if (!p->= ;fastMode)

= >

>&= nbsp;       {

>

> -      &n= bsp; if (p->matchPriceCount >=3D (1 << 7))

>

> +     =    /*

>

= > +        if (p->alignPriceCount = >=3D 16) // kAlignTableSize

>

> +         = FillAlignPrices(p);

>

> +        if (p->matchPriceC= ount >=3D 128)

>

>           = FillDistancesPrices(p);

>

> -        if (p->alignP= riceCount >=3D kAlignTableSize)

>

= > +        if (p-&= gt;lenEnc.counter <=3D 0)

<= span lang=3DEN-US>>

> +          L= enPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb,<= /span>

> &p->lenPro= bs, p->ProbPrices);

>

> +        */

> <= /p>

> +    = ;    if (p->matchPriceCount >=3D 64)=

>

<= p class=3DMsoPlainText>> +     &n= bsp;  {

>

>           = FillAlignPrices(p);

>

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

>

> +        &= nbsp; FillDistancesPrices(p);

= >

> +          = // }}

> =

> +&nbs= p;         LenPriceEnc_UpdateTables= (&p->lenEnc, 1 << p->pb,

> &p->lenProbs, p->ProbPrices);<= o:p>

> <= /o:p>

> + &nbs= p;      }

>

= > +        if (p-&= gt;repLenEncCounter <=3D 0)

>

> +        {

>

> +   &= nbsp;      p->repLenEncCounter =3D REP_LEN_COUN= T;

>

> + &= nbsp;        LenPriceEnc_UpdateTables(&a= mp;p->repLenEnc, 1 << p->pb,

> &p->repLenProbs, p->ProbPrices= );

>

> + &= nbsp;      }

>

>        }=

>

>

>

>    &n= bsp;   if (p->matchFinder.GetNumAvailableBytes(p->matchFind= erObj) =3D=3D 0)

>

> @@ -2490,12 +2667,19 @@ void LzmaEnc_Init(CLzmaEnc *p)

>

>

>    p->optEnd= =3D 0;

>= ;

>&nbs= p;   p->optCur =3D 0;

>

= > +

>

> +  {

>

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

>

> +  &n= bsp;   p->opt[i].price =3D kInfinityPrice;

>

> +  }

>

> +

>

>    p->additionalOffse= t =3D 0;

&g= t;

>

>

>  &= nbsp; p->pbMask =3D (1 << p->pb) - 1;

>

>    p->lpMask =3D= ((UInt32)0x100 << p->lp) - ((unsigned)0x100 >> p->lc);

>

>  }=

>

>

>

> +

>

>  void LzmaEnc_InitPrices(CLzm= aEnc *p)

&g= t;

>&nb= sp; {

> =

> =    if (!p->fastMode)

>

<= span lang=3DEN-US>> @@ -2507,6 +2691,9 @@ void LzmaEnc_InitPrices(CLzmaE= nc *p)

>=     p->lenEnc.tableSize =3D

>

>    p->repLenEnc.table= Size =3D

&g= t;

>&nb= sp;       p->numFastBytes + 1 - LZMA_MATCH= _LEN_MIN;

&= gt;

> +=

> =

> +  p-= >repLenEncCounter =3D REP_LEN_COUNT;

>

> +

>

>    LenPriceEnc_UpdateTables(&p->l= enEnc, 1 << p->pb, &p->lenProbs,

> p->ProbPrices);

> <= /p>

>    LenPri= ceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, &p->re= pLenProbs,

= > p->ProbPrices);

>

>  }

>

> @@ -2583,7 +2770,7 @@ typedef struct

>    ISeqOutStre= am vt;

>=

> = ;   Byte *data;

>

>    SizeT rem;

>

> -  Bool overflow;

>

=

> +  BoolInt overflow;

>

>  } CLzm= aEnc_SeqOutStreamBuf;

>

>

>

>=   static size_t SeqOutStreamBuf_Write(const ISeqOutStream *pp, const v= oid

> *d= ata, size_t size)

>

> @@ -2615,7 +2802,7 @@ const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandl= e

> pp)<= o:p>

>  = }

>

>

>

> <= /p>

>

> -SRes LzmaEnc_CodeOneMemBlock= (CLzmaEncHandle pp, Bool reInit,

>

> +SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool= Int reInit,

>

>=       Byte *dest, size_t *destLen, UInt32 desiredP= ackSize, UInt32

> *unpackSize)

>

>  {

>

>    CLzmaEnc *p =3D (CLzmaEnc *)pp;=

>

> diff --git a/BaseTool= s/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt

> b/BaseTools/Source/C/LzmaCompres= s/Sdk/DOC/lzma-history.txt

> index d7426d38a4..04f9d98e7d 100644<= /p>

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

>

>  -----------------------<= o:p>

> <= /o:p>

> =

>

> +19.00  &nb= sp;       2019-02-21

>

> +-------------------------

>

> +- Encryption stre= ngth for 7z archives was increased:

>

> +  the size of random initialization vector w= as increased from 64-bit to

> 128-bit,

>

> +  and the pseudo-random number generator was impr= oved.

> =

> +- Th= e 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_De= code(),

>= ;

> +&n= bsp; if xz stream contains only one block.

>

> +- The changes for MSVS compiler makefiles:=

> =

> + &nb= sp; - the makefiles now use "PLATFORM" macroname with values (x64= , x86,

>= arm64)

>= ;

> +&n= bsp;    instead of "CPU" macroname with values (AM= D64, ARM64).

>

>= ; +   - the makefiles by default now use static version of the ru= n-time

libr= ary.

> <= o:p>

> +=

>

> +

> <= /p>

>  18.05  &= nbsp;       2018-04-30

<= p class=3DMsoPlainText>>

>  -------------------------

>

>  - The = speed for LZMA/LZMA2 compressing was increased

>

> diff --git a/BaseTools/Source/C/LzmaCom= press/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

&g= t; +++ b/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-sdk.txt

> @@ -1,4 +1,4 @@

> -LZMA SDK= 18.05

>=

> +LZM= A SDK 19.00

>

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

>

>

>

>=   LZMA SDK provides the documentation, samples, header files,

>

> --

> 2.27.0.windows.1<= /o:p>

 

 

 =

------=_NextPart_000_00E2_01D6D9D5.1B4B4EF0--