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