From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web08.9307.1609227682129121093 for ; Mon, 28 Dec 2020 23:41:22 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: weix.c.liu@intel.com) IronPort-SDR: MYXjV27lDkdAFXICwkik9Q108+pmWg5TgCoW6R7A53vlJ2FrjlDxNFYXtjfesxD/2aqRFeTk+e mYMAL0JFWj2g== X-IronPort-AV: E=McAfee;i="6000,8403,9848"; a="156255713" X-IronPort-AV: E=Sophos;i="5.78,457,1599548400"; d="scan'208";a="156255713" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2020 23:41:20 -0800 IronPort-SDR: chrRSmNQG/EVaPoD2hYZ+AYBkMiR5qGHuJ4ntUlogqxBfPLJYefKTodCcYnbKYowF7bn/L5QF7 5ipdY/b4k/Bw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,457,1599548400"; d="scan'208";a="375962058" Received: from shwdeopenpsi138.ccr.corp.intel.com ([10.239.49.183]) by orsmga008.jf.intel.com with ESMTP; 28 Dec 2020 23:41:17 -0800 From: "Liu, WeiX C" To: devel@edk2.groups.io Cc: Wei Liu , Liming Gao Subject: [PATCH 1/2] BaseTools LzmaCompress: Update LZMA to new 19.00 version Date: Tue, 29 Dec 2020 15:37:43 +0800 Message-Id: <20201229073744.684-1-weix.c.liu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3101 New formal release in https://www.7-zip.org/sdk.html is 19.00. Cc: Liming Gao 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 | 232 +++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------= ----------------------------------------------------------------------- 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 | 907 +++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++----------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ----------------------------------------------------------------------- BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt | 114 +++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------= ---------------------------- BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-sdk.txt | 2 +- 12 files changed, 877 insertions(+), 575 deletions(-) diff --git a/BaseTools/Source/C/LzmaCompress/LZMA-SDK-README.txt b/BaseTool= s/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=0D -was placed in the public domain on 2018-04-30. It was=0D +LzmaCompress is based on the LZMA SDK 19.00. LZMA SDK 19.00=0D +was placed in the public domain on 2019-02-21. It was=0D released on the http://www.7-zip.org/sdk.html website.=0D diff --git a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c b/BaseTools/Sou= rce/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=0D LZMA Compress/Decompress tool (LzmaCompress)=0D =0D - Based on LZMA SDK 18.05:=0D + Based on LZMA SDK 19.00:=0D LzmaUtil.c -- Test application for LZMA compression=0D - 2018-04-30 : Igor Pavlov : Public domain=0D + 2019-02-21 : Igor Pavlov : Public domain=0D =0D Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D @@ -39,7 +39,7 @@ const char *kCantAllocateMessage =3D "Can not allocate me= mory"; const char *kDataErrorMessage =3D "Data error";=0D const char *kInvalidParamValMessage =3D "Invalid parameter value";=0D =0D -static Bool mQuietMode =3D False;=0D +static BoolInt mQuietMode =3D False;=0D static CONVERTER_TYPE mConType =3D NoConverter;=0D =0D UINT64 mDictionarySize =3D 28;=0D @@ -244,7 +244,7 @@ int main2(int numArgs, const char *args[], char *rs) CFileOutStream outStream;=0D int res;=0D int encodeMode =3D 0;=0D - Bool modeWasSet =3D False;=0D + BoolInt modeWasSet =3D False;=0D const char *inputFile =3D NULL;=0D const char *outputFile =3D "file.tmp";=0D int param;=0D diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/7zTypes.h b/BaseTools/So= urce/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=0D -2017-07-17 : Igor Pavlov : Public domain */=0D +2018-08-04 : Igor Pavlov : Public domain */=0D =0D #ifndef __7Z_TYPES_H=0D #define __7Z_TYPES_H=0D @@ -103,7 +103,8 @@ typedef UInt32 SizeT; typedef size_t SizeT;=0D #endif=0D =0D -typedef int Bool;=0D +typedef int BoolInt;=0D +/* typedef BoolInt Bool; */=0D #define True 1=0D #define False 0=0D =0D 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=0D -#define MY_VER_MINOR 05=0D +#define MY_VER_MAJOR 19=0D +#define MY_VER_MINOR 00=0D #define MY_VER_BUILD 0=0D -#define MY_VERSION_NUMBERS "18.05"=0D +#define MY_VERSION_NUMBERS "19.00"=0D #define MY_VERSION MY_VERSION_NUMBERS=0D =0D #ifdef MY_CPU_NAME=0D @@ -10,7 +10,7 @@ #define MY_VERSION_CPU MY_VERSION=0D #endif=0D =0D -#define MY_DATE "2018-04-30"=0D +#define MY_DATE "2019-02-21"=0D #undef MY_COPYRIGHT=0D #undef MY_VERSION_COPYRIGHT_DATE=0D #define MY_AUTHOR_NAME "Igor Pavlov"=0D diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/CpuArch.h b/BaseTools/So= urce/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=0D -2017-09-04 : Igor Pavlov : Public domain */=0D +2018-02-18 : Igor Pavlov : Public domain */=0D =0D #ifndef __CPU_ARCH_H=0D #define __CPU_ARCH_H=0D @@ -318,15 +318,16 @@ enum =0D void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d);= =0D =0D -Bool x86cpuid_CheckAndRead(Cx86cpuid *p);=0D +BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p);=0D int x86cpuid_GetFirm(const Cx86cpuid *p);=0D =0D #define x86cpuid_GetFamily(ver) (((ver >> 16) & 0xFF0) | ((ver >> 8) & 0xF= ))=0D #define x86cpuid_GetModel(ver) (((ver >> 12) & 0xF0) | ((ver >> 4) & 0xF= ))=0D #define x86cpuid_GetStepping(ver) (ver & 0xF)=0D =0D -Bool CPU_Is_InOrder();=0D -Bool CPU_Is_Aes_Supported();=0D +BoolInt CPU_Is_InOrder();=0D +BoolInt CPU_Is_Aes_Supported();=0D +BoolInt CPU_IsSupported_PageGB();=0D =0D #endif=0D =0D diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFind.c b/BaseTools/Sou= rce/C/LzmaCompress/Sdk/C/LzFind.c index 6ea82a9b53..f89c9ddd7d 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=0D -2017-06-10 : Igor Pavlov : Public domain */=0D +2018-07-08 : Igor Pavlov : Public domain */=0D =0D #include "Precomp.h"=0D =0D @@ -73,7 +73,7 @@ static void MatchFinder_ReadBlock(CMatchFinder *p) p->streamEndWasReached =3D 1;=0D return;=0D }=0D - =0D +=0D for (;;)=0D {=0D Byte *dest =3D p->buffer + (p->streamPos - p->pos);=0D @@ -138,7 +138,7 @@ static void MatchFinder_SetDefaultSettings(CMatchFinder= *p) =0D void MatchFinder_Construct(CMatchFinder *p)=0D {=0D - UInt32 i;=0D + unsigned i;=0D p->bufferBase =3D NULL;=0D p->directInput =3D 0;=0D p->hash =3D NULL;=0D @@ -147,7 +147,7 @@ void MatchFinder_Construct(CMatchFinder *p) =0D for (i =3D 0; i < 256; i++)=0D {=0D - UInt32 r =3D i;=0D + UInt32 r =3D (UInt32)i;=0D unsigned j;=0D for (j =3D 0; j < 8; j++)=0D r =3D (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1)));=0D @@ -180,24 +180,24 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 histor= ySize, ISzAllocPtr alloc)=0D {=0D UInt32 sizeReserv;=0D - =0D +=0D if (historySize > kMaxHistorySize)=0D {=0D MatchFinder_Free(p, alloc);=0D return 0;=0D }=0D - =0D +=0D sizeReserv =3D historySize >> 1;=0D if (historySize >=3D ((UInt32)3 << 30)) sizeReserv =3D historySize = >> 3;=0D else if (historySize >=3D ((UInt32)2 << 30)) sizeReserv =3D historySize = >> 2;=0D - =0D +=0D sizeReserv +=3D (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter)= / 2 + (1 << 19);=0D =0D p->keepSizeBefore =3D historySize + keepAddBufferBefore + 1;=0D p->keepSizeAfter =3D matchMaxLen + keepAddBufferAfter;=0D - =0D +=0D /* we need one additional byte, since we use MoveBlock after pos++ and b= efore dictionary using */=0D - =0D +=0D if (LzInWindow_Create(p, sizeReserv, alloc))=0D {=0D UInt32 newCyclicBufferSize =3D historySize + 1;=0D @@ -243,7 +243,7 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historyS= ize, p->historySize =3D historySize;=0D p->hashSizeSum =3D hs;=0D p->cyclicBufferSize =3D newCyclicBufferSize;=0D - =0D +=0D numSons =3D newCyclicBufferSize;=0D if (p->btMode)=0D numSons <<=3D 1;=0D @@ -251,11 +251,11 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 histor= ySize, =0D if (p->hash && p->numRefs =3D=3D newSize)=0D return 1;=0D - =0D +=0D MatchFinder_FreeThisClassMemory(p, alloc);=0D p->numRefs =3D newSize;=0D p->hash =3D AllocRefs(newSize, alloc);=0D - =0D +=0D if (p->hash)=0D {=0D p->son =3D p->hash + p->hashSizeSum;=0D @@ -272,11 +272,11 @@ static void MatchFinder_SetLimits(CMatchFinder *p) {=0D UInt32 limit =3D kMaxValForNormalize - p->pos;=0D UInt32 limit2 =3D p->cyclicBufferSize - p->cyclicBufferPos;=0D - =0D +=0D if (limit2 < limit)=0D limit =3D limit2;=0D limit2 =3D p->streamPos - p->pos;=0D - =0D +=0D if (limit2 <=3D p->keepSizeAfter)=0D {=0D if (limit2 > 0)=0D @@ -284,10 +284,10 @@ static void MatchFinder_SetLimits(CMatchFinder *p) }=0D else=0D limit2 -=3D p->keepSizeAfter;=0D - =0D +=0D if (limit2 < limit)=0D limit =3D limit2;=0D - =0D +=0D {=0D UInt32 lenLimit =3D p->streamPos - p->pos;=0D if (lenLimit > p->matchMaxLen)=0D @@ -326,10 +326,10 @@ void MatchFinder_Init_3(CMatchFinder *p, int readData) p->streamPos =3D p->cyclicBufferSize;=0D p->result =3D SZ_OK;=0D p->streamEndWasReached =3D 0;=0D - =0D +=0D if (readData)=0D MatchFinder_ReadBlock(p);=0D - =0D +=0D MatchFinder_SetLimits(p);=0D }=0D =0D @@ -341,7 +341,7 @@ void MatchFinder_Init(CMatchFinder *p) MatchFinder_Init_3(p, True);=0D }=0D =0D - =0D +=0D static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)=0D {=0D return (p->pos - p->historySize - 1) & kNormalizeMask;=0D @@ -368,6 +368,8 @@ static void MatchFinder_Normalize(CMatchFinder *p) MatchFinder_ReduceOffsets(p, subValue);=0D }=0D =0D +=0D +MY_NO_INLINE=0D static void MatchFinder_CheckLimits(CMatchFinder *p)=0D {=0D if (p->pos =3D=3D kMaxValForNormalize)=0D @@ -379,10 +381,16 @@ static void MatchFinder_CheckLimits(CMatchFinder *p) MatchFinder_SetLimits(p);=0D }=0D =0D -static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32= pos, const Byte *cur, CLzRef *son,=0D +=0D +/*=0D + (lenLimit > maxLen)=0D +*/=0D +MY_FORCE_INLINE=0D +static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt= 32 pos, const Byte *cur, CLzRef *son,=0D UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,=0D - UInt32 *distances, UInt32 maxLen)=0D + UInt32 *distances, unsigned maxLen)=0D {=0D + /*=0D son[_cyclicBufferPos] =3D curMatch;=0D for (;;)=0D {=0D @@ -400,7 +408,8 @@ static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt= 32 curMatch, UInt32 pos, break;=0D if (maxLen < len)=0D {=0D - *distances++ =3D maxLen =3D len;=0D + maxLen =3D len;=0D + *distances++ =3D len;=0D *distances++ =3D delta - 1;=0D if (len =3D=3D lenLimit)=0D return distances;=0D @@ -408,15 +417,58 @@ static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UI= nt32 curMatch, UInt32 pos, }=0D }=0D }=0D + */=0D +=0D + const Byte *lim =3D cur + lenLimit;=0D + son[_cyclicBufferPos] =3D curMatch;=0D + do=0D + {=0D + UInt32 delta =3D pos - curMatch;=0D + if (delta >=3D _cyclicBufferSize)=0D + break;=0D + {=0D + ptrdiff_t diff;=0D + curMatch =3D son[_cyclicBufferPos - delta + ((delta > _cyclicBufferP= os) ? _cyclicBufferSize : 0)];=0D + diff =3D (ptrdiff_t)0 - delta;=0D + if (cur[maxLen] =3D=3D cur[maxLen + diff])=0D + {=0D + const Byte *c =3D cur;=0D + while (*c =3D=3D c[diff])=0D + {=0D + if (++c =3D=3D lim)=0D + {=0D + distances[0] =3D (UInt32)(lim - cur);=0D + distances[1] =3D delta - 1;=0D + return distances + 2;=0D + }=0D + }=0D + {=0D + unsigned len =3D (unsigned)(c - cur);=0D + if (maxLen < len)=0D + {=0D + maxLen =3D len;=0D + distances[0] =3D (UInt32)len;=0D + distances[1] =3D delta - 1;=0D + distances +=3D 2;=0D + }=0D + }=0D + }=0D + }=0D + }=0D + while (--cutValue);=0D +=0D + return distances;=0D }=0D =0D +=0D +MY_FORCE_INLINE=0D UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, con= st Byte *cur, CLzRef *son,=0D UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,=0D UInt32 *distances, UInt32 maxLen)=0D {=0D - CLzRef *ptr0 =3D son + (_cyclicBufferPos << 1) + 1;=0D - CLzRef *ptr1 =3D son + (_cyclicBufferPos << 1);=0D - UInt32 len0 =3D 0, len1 =3D 0;=0D + CLzRef *ptr0 =3D son + ((size_t)_cyclicBufferPos << 1) + 1;=0D + CLzRef *ptr1 =3D son + ((size_t)_cyclicBufferPos << 1);=0D + unsigned len0 =3D 0, len1 =3D 0;=0D for (;;)=0D {=0D UInt32 delta =3D pos - curMatch;=0D @@ -426,9 +478,10 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMa= tch, UInt32 pos, const Byt return distances;=0D }=0D {=0D - CLzRef *pair =3D son + ((_cyclicBufferPos - delta + ((delta > _cycli= cBufferPos) ? _cyclicBufferSize : 0)) << 1);=0D + CLzRef *pair =3D son + ((size_t)(_cyclicBufferPos - delta + ((delta = > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);=0D const Byte *pb =3D cur - delta;=0D - UInt32 len =3D (len0 < len1 ? len0 : len1);=0D + unsigned len =3D (len0 < len1 ? len0 : len1);=0D + UInt32 pair0 =3D pair[0];=0D if (pb[len] =3D=3D cur[len])=0D {=0D if (++len !=3D lenLimit && pb[len] =3D=3D cur[len])=0D @@ -437,11 +490,12 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curM= atch, UInt32 pos, const Byt break;=0D if (maxLen < len)=0D {=0D - *distances++ =3D maxLen =3D len;=0D + maxLen =3D (UInt32)len;=0D + *distances++ =3D (UInt32)len;=0D *distances++ =3D delta - 1;=0D if (len =3D=3D lenLimit)=0D {=0D - *ptr1 =3D pair[0];=0D + *ptr1 =3D pair0;=0D *ptr0 =3D pair[1];=0D return distances;=0D }=0D @@ -468,9 +522,9 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMat= ch, UInt32 pos, const Byt static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, = const Byte *cur, CLzRef *son,=0D UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)=0D {=0D - CLzRef *ptr0 =3D son + (_cyclicBufferPos << 1) + 1;=0D - CLzRef *ptr1 =3D son + (_cyclicBufferPos << 1);=0D - UInt32 len0 =3D 0, len1 =3D 0;=0D + CLzRef *ptr0 =3D son + ((size_t)_cyclicBufferPos << 1) + 1;=0D + CLzRef *ptr1 =3D son + ((size_t)_cyclicBufferPos << 1);=0D + unsigned len0 =3D 0, len1 =3D 0;=0D for (;;)=0D {=0D UInt32 delta =3D pos - curMatch;=0D @@ -480,9 +534,9 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 cur= Match, UInt32 pos, const return;=0D }=0D {=0D - CLzRef *pair =3D son + ((_cyclicBufferPos - delta + ((delta > _cycli= cBufferPos) ? _cyclicBufferSize : 0)) << 1);=0D + CLzRef *pair =3D son + ((size_t)(_cyclicBufferPos - delta + ((delta = > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);=0D const Byte *pb =3D cur - delta;=0D - UInt32 len =3D (len0 < len1 ? len0 : len1);=0D + unsigned len =3D (len0 < len1 ? len0 : len1);=0D if (pb[len] =3D=3D cur[len])=0D {=0D while (++len !=3D lenLimit)=0D @@ -520,13 +574,13 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 c= urMatch, UInt32 pos, const p->buffer++; \=0D if (++p->pos =3D=3D p->posLimit) MatchFinder_CheckLimits(p);=0D =0D -#define MOVE_POS_RET MOVE_POS return offset;=0D +#define MOVE_POS_RET MOVE_POS return (UInt32)offset;=0D =0D static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }=0D =0D #define GET_MATCHES_HEADER2(minLen, ret_op) \=0D - UInt32 lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \=0D - lenLimit =3D p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos= (p); ret_op; }} \=0D + unsigned lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \=0D + lenLimit =3D (unsigned)p->lenLimit; { if (lenLimit < minLen) { MatchFind= er_MovePos(p); ret_op; }} \=0D cur =3D p->buffer;=0D =0D #define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0)=0D @@ -535,22 +589,22 @@ static void MatchFinder_MovePos(CMatchFinder *p) { MO= VE_POS; } #define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyc= licBufferSize, p->cutValue=0D =0D #define GET_MATCHES_FOOTER(offset, maxLen) \=0D - offset =3D (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \= =0D - distances + offset, maxLen) - distances); MOVE_POS_RET;=0D + offset =3D (unsigned)(GetMatchesSpec1((UInt32)lenLimit, curMatch, MF_PAR= AMS(p), \=0D + distances + offset, (UInt32)maxLen) - distances); MOVE_POS_RET;=0D =0D #define SKIP_FOOTER \=0D - SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;=0D + SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;=0D =0D #define UPDATE_maxLen { \=0D ptrdiff_t diff =3D (ptrdiff_t)0 - d2; \=0D const Byte *c =3D cur + maxLen; \=0D const Byte *lim =3D cur + lenLimit; \=0D for (; c !=3D lim; c++) if (*(c + diff) !=3D *c) break; \=0D - maxLen =3D (UInt32)(c - cur); }=0D + maxLen =3D (unsigned)(c - cur); }=0D =0D static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distance= s)=0D {=0D - UInt32 offset;=0D + unsigned offset;=0D GET_MATCHES_HEADER(2)=0D HASH2_CALC;=0D curMatch =3D p->hash[hv];=0D @@ -561,7 +615,7 @@ static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *= p, UInt32 *distances) =0D UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)=0D {=0D - UInt32 offset;=0D + unsigned offset;=0D GET_MATCHES_HEADER(3)=0D HASH_ZIP_CALC;=0D curMatch =3D p->hash[hv];=0D @@ -572,7 +626,8 @@ UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, U= Int32 *distances) =0D static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distance= s)=0D {=0D - UInt32 h2, d2, maxLen, offset, pos;=0D + UInt32 h2, d2, pos;=0D + unsigned maxLen, offset;=0D UInt32 *hash;=0D GET_MATCHES_HEADER(3)=0D =0D @@ -584,7 +639,7 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *= p, UInt32 *distances) d2 =3D pos - hash[h2];=0D =0D curMatch =3D (hash + kFix3HashSize)[hv];=0D - =0D +=0D hash[h2] =3D pos;=0D (hash + kFix3HashSize)[hv] =3D pos;=0D =0D @@ -594,22 +649,23 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder= *p, UInt32 *distances) if (d2 < p->cyclicBufferSize && *(cur - d2) =3D=3D *cur)=0D {=0D UPDATE_maxLen=0D - distances[0] =3D maxLen;=0D + distances[0] =3D (UInt32)maxLen;=0D distances[1] =3D d2 - 1;=0D offset =3D 2;=0D if (maxLen =3D=3D lenLimit)=0D {=0D - SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));=0D + SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p));=0D MOVE_POS_RET;=0D }=0D }=0D - =0D +=0D GET_MATCHES_FOOTER(offset, maxLen)=0D }=0D =0D static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distance= s)=0D {=0D - UInt32 h2, h3, d2, d3, maxLen, offset, pos;=0D + UInt32 h2, h3, d2, d3, pos;=0D + unsigned maxLen, offset;=0D UInt32 *hash;=0D GET_MATCHES_HEADER(4)=0D =0D @@ -618,25 +674,26 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder= *p, UInt32 *distances) hash =3D p->hash;=0D pos =3D p->pos;=0D =0D - d2 =3D pos - hash[ h2];=0D + d2 =3D pos - hash [h2];=0D d3 =3D pos - (hash + kFix3HashSize)[h3];=0D =0D curMatch =3D (hash + kFix4HashSize)[hv];=0D =0D - hash[ h2] =3D pos;=0D + hash [h2] =3D pos;=0D (hash + kFix3HashSize)[h3] =3D pos;=0D (hash + kFix4HashSize)[hv] =3D pos;=0D =0D maxLen =3D 0;=0D offset =3D 0;=0D - =0D +=0D if (d2 < p->cyclicBufferSize && *(cur - d2) =3D=3D *cur)=0D {=0D - distances[0] =3D maxLen =3D 2;=0D + maxLen =3D 2;=0D + distances[0] =3D 2;=0D distances[1] =3D d2 - 1;=0D offset =3D 2;=0D }=0D - =0D +=0D if (d2 !=3D d3 && d3 < p->cyclicBufferSize && *(cur - d3) =3D=3D *cur)=0D {=0D maxLen =3D 3;=0D @@ -644,21 +701,21 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder= *p, UInt32 *distances) offset +=3D 2;=0D d2 =3D d3;=0D }=0D - =0D +=0D if (offset !=3D 0)=0D {=0D UPDATE_maxLen=0D - distances[(size_t)offset - 2] =3D maxLen;=0D + distances[(size_t)offset - 2] =3D (UInt32)maxLen;=0D if (maxLen =3D=3D lenLimit)=0D {=0D - SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));=0D + SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p));=0D MOVE_POS_RET;=0D }=0D }=0D - =0D +=0D if (maxLen < 3)=0D maxLen =3D 3;=0D - =0D +=0D GET_MATCHES_FOOTER(offset, maxLen)=0D }=0D =0D @@ -674,13 +731,13 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder= *p, UInt32 *distances) hash =3D p->hash;=0D pos =3D p->pos;=0D =0D - d2 =3D pos - hash[ h2];=0D + d2 =3D pos - hash [h2];=0D d3 =3D pos - (hash + kFix3HashSize)[h3];=0D d4 =3D pos - (hash + kFix4HashSize)[h4];=0D =0D curMatch =3D (hash + kFix5HashSize)[hv];=0D =0D - hash[ h2] =3D pos;=0D + hash [h2] =3D pos;=0D (hash + kFix3HashSize)[h3] =3D pos;=0D (hash + kFix4HashSize)[h4] =3D pos;=0D (hash + kFix5HashSize)[hv] =3D pos;=0D @@ -710,7 +767,7 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *= p, UInt32 *distances) offset =3D 2;=0D d2 =3D d3;=0D }=0D - =0D +=0D if (d2 !=3D d4 && d4 < p->cyclicBufferSize=0D && *(cur - d4) =3D=3D *cur=0D && *(cur - d4 + 3) =3D=3D *(cur + 3))=0D @@ -720,7 +777,7 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *= p, UInt32 *distances) offset +=3D 2;=0D d2 =3D d4;=0D }=0D - =0D +=0D if (offset !=3D 0)=0D {=0D UPDATE_maxLen=0D @@ -734,14 +791,15 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder= *p, UInt32 *distances) =0D if (maxLen < 4)=0D maxLen =3D 4;=0D - =0D +=0D GET_MATCHES_FOOTER(offset, maxLen)=0D }=0D */=0D =0D static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distance= s)=0D {=0D - UInt32 h2, h3, d2, d3, maxLen, offset, pos;=0D + UInt32 h2, h3, d2, d3, pos;=0D + unsigned maxLen, offset;=0D UInt32 *hash;=0D GET_MATCHES_HEADER(4)=0D =0D @@ -749,13 +807,12 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder= *p, UInt32 *distances) =0D hash =3D p->hash;=0D pos =3D p->pos;=0D - =0D - d2 =3D pos - hash[ h2];=0D +=0D + d2 =3D pos - hash [h2];=0D d3 =3D pos - (hash + kFix3HashSize)[h3];=0D - =0D curMatch =3D (hash + kFix4HashSize)[hv];=0D =0D - hash[ h2] =3D pos;=0D + hash [h2] =3D pos;=0D (hash + kFix3HashSize)[h3] =3D pos;=0D (hash + kFix4HashSize)[hv] =3D pos;=0D =0D @@ -764,11 +821,12 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder= *p, UInt32 *distances) =0D if (d2 < p->cyclicBufferSize && *(cur - d2) =3D=3D *cur)=0D {=0D - distances[0] =3D maxLen =3D 2;=0D + maxLen =3D 2;=0D + distances[0] =3D 2;=0D distances[1] =3D d2 - 1;=0D offset =3D 2;=0D }=0D - =0D +=0D if (d2 !=3D d3 && d3 < p->cyclicBufferSize && *(cur - d3) =3D=3D *cur)=0D {=0D maxLen =3D 3;=0D @@ -776,22 +834,22 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder= *p, UInt32 *distances) offset +=3D 2;=0D d2 =3D d3;=0D }=0D - =0D +=0D if (offset !=3D 0)=0D {=0D UPDATE_maxLen=0D - distances[(size_t)offset - 2] =3D maxLen;=0D + distances[(size_t)offset - 2] =3D (UInt32)maxLen;=0D if (maxLen =3D=3D lenLimit)=0D {=0D p->son[p->cyclicBufferPos] =3D curMatch;=0D MOVE_POS_RET;=0D }=0D }=0D - =0D +=0D if (maxLen < 3)=0D maxLen =3D 3;=0D =0D - offset =3D (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),= =0D + offset =3D (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)= ,=0D distances + offset, maxLen) - (distances));=0D MOVE_POS_RET=0D }=0D @@ -807,14 +865,14 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder= *p, UInt32 *distances) =0D hash =3D p->hash;=0D pos =3D p->pos;=0D - =0D - d2 =3D pos - hash[ h2];=0D +=0D + d2 =3D pos - hash [h2];=0D d3 =3D pos - (hash + kFix3HashSize)[h3];=0D d4 =3D pos - (hash + kFix4HashSize)[h4];=0D =0D curMatch =3D (hash + kFix5HashSize)[hv];=0D =0D - hash[ h2] =3D pos;=0D + hash [h2] =3D pos;=0D (hash + kFix3HashSize)[h3] =3D pos;=0D (hash + kFix4HashSize)[h4] =3D pos;=0D (hash + kFix5HashSize)[hv] =3D pos;=0D @@ -844,7 +902,7 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *= p, UInt32 *distances) offset =3D 2;=0D d2 =3D d3;=0D }=0D - =0D +=0D if (d2 !=3D d4 && d4 < p->cyclicBufferSize=0D && *(cur - d4) =3D=3D *cur=0D && *(cur - d4 + 3) =3D=3D *(cur + 3))=0D @@ -854,7 +912,7 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *= p, UInt32 *distances) offset +=3D 2;=0D d2 =3D d4;=0D }=0D - =0D +=0D if (offset !=3D 0)=0D {=0D UPDATE_maxLen=0D @@ -865,7 +923,7 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *= p, UInt32 *distances) MOVE_POS_RET;=0D }=0D }=0D - =0D +=0D if (maxLen < 4)=0D maxLen =3D 4;=0D =0D @@ -877,12 +935,12 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder= *p, UInt32 *distances) =0D UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)=0D {=0D - UInt32 offset;=0D + unsigned offset;=0D GET_MATCHES_HEADER(3)=0D HASH_ZIP_CALC;=0D curMatch =3D p->hash[hv];=0D p->hash[hv] =3D p->pos;=0D - offset =3D (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),= =0D + offset =3D (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)= ,=0D distances, 2) - (distances));=0D MOVE_POS_RET=0D }=0D @@ -940,7 +998,7 @@ static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt3= 2 num) HASH4_CALC;=0D hash =3D p->hash;=0D curMatch =3D (hash + kFix4HashSize)[hv];=0D - hash[ h2] =3D=0D + hash [h2] =3D=0D (hash + kFix3HashSize)[h3] =3D=0D (hash + kFix4HashSize)[hv] =3D p->pos;=0D SKIP_FOOTER=0D @@ -959,7 +1017,7 @@ static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt= 32 num) HASH5_CALC;=0D hash =3D p->hash;=0D curMatch =3D (hash + kFix5HashSize)[hv];=0D - hash[ h2] =3D=0D + hash [h2] =3D=0D (hash + kFix3HashSize)[h3] =3D=0D (hash + kFix4HashSize)[h4] =3D=0D (hash + kFix5HashSize)[hv] =3D p->pos;=0D @@ -979,7 +1037,7 @@ static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt= 32 num) HASH4_CALC;=0D hash =3D p->hash;=0D curMatch =3D (hash + kFix4HashSize)[hv];=0D - hash[ h2] =3D=0D + hash [h2] =3D=0D (hash + kFix3HashSize)[h3] =3D=0D (hash + kFix4HashSize)[hv] =3D p->pos;=0D p->son[p->cyclicBufferPos] =3D curMatch;=0D @@ -999,7 +1057,7 @@ static void Hc5_MatchFinder_Skip(CMatchFinder *p, UInt= 32 num) HASH5_CALC;=0D hash =3D p->hash;=0D curMatch =3D hash + kFix5HashSize)[hv];=0D - hash[ h2] =3D=0D + hash [h2] =3D=0D (hash + kFix3HashSize)[h3] =3D=0D (hash + kFix4HashSize)[h4] =3D=0D (hash + kFix5HashSize)[hv] =3D p->pos;=0D diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.c b/BaseTools/S= ource/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=0D -2017-06-10 : Igor Pavlov : Public domain */=0D +2018-12-29 : Igor Pavlov : Public domain */=0D =0D #include "Precomp.h"=0D =0D @@ -232,38 +232,57 @@ static void MatchFinderMt_GetNextBlock_Hash(CMatchFin= derMt *p) =0D #define kEmptyHashValue 0=0D =0D -/* #define MFMT_GM_INLINE */=0D +#define MFMT_GM_INLINE=0D =0D #ifdef MFMT_GM_INLINE=0D =0D -#define NO_INLINE MY_FAST_CALL=0D +/*=0D + we use size_t for _cyclicBufferPos instead of UInt32=0D + to eliminate "movsx" BUG in old MSVC x64 compiler.=0D +*/=0D =0D -static Int32 NO_INLINE GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const = Byte *cur, CLzRef *son,=0D - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,=0D - UInt32 *_distances, UInt32 _maxLen, const UInt32 *hash, Int32 limit, U= Int32 size, UInt32 *posRes)=0D +MY_NO_INLINE=0D +static UInt32 *GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *cu= r, CLzRef *son,=0D + size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,=0D + UInt32 *distances, UInt32 _maxLen, const UInt32 *hash, const UInt32 *l= imit, UInt32 size, UInt32 *posRes)=0D {=0D do=0D {=0D - UInt32 *distances =3D _distances + 1;=0D - UInt32 curMatch =3D pos - *hash++;=0D + UInt32 *_distances =3D ++distances;=0D + UInt32 delta =3D *hash++;=0D =0D - CLzRef *ptr0 =3D son + (_cyclicBufferPos << 1) + 1;=0D - CLzRef *ptr1 =3D son + (_cyclicBufferPos << 1);=0D - UInt32 len0 =3D 0, len1 =3D 0;=0D + CLzRef *ptr0 =3D son + ((size_t)_cyclicBufferPos << 1) + 1;=0D + CLzRef *ptr1 =3D son + ((size_t)_cyclicBufferPos << 1);=0D + unsigned len0 =3D 0, len1 =3D 0;=0D UInt32 cutValue =3D _cutValue;=0D - UInt32 maxLen =3D _maxLen;=0D - for (;;)=0D + unsigned maxLen =3D (unsigned)_maxLen;=0D +=0D + /*=0D + if (size > 1)=0D {=0D - UInt32 delta =3D pos - curMatch;=0D - if (cutValue-- =3D=3D 0 || delta >=3D _cyclicBufferSize)=0D + UInt32 delta =3D *hash;=0D + if (delta < _cyclicBufferSize)=0D {=0D - *ptr0 =3D *ptr1 =3D kEmptyHashValue;=0D - break;=0D + UInt32 cyc1 =3D _cyclicBufferPos + 1;=0D + CLzRef *pair =3D son + ((size_t)(cyc1 - delta + ((delta > cyc1) ? _c= yclicBufferSize : 0)) << 1);=0D + Byte b =3D *(cur + 1 - delta);=0D + _distances[0] =3D pair[0];=0D + _distances[1] =3D b;=0D }=0D + }=0D + */=0D + if (cutValue =3D=3D 0 || delta >=3D _cyclicBufferSize)=0D + {=0D + *ptr0 =3D *ptr1 =3D kEmptyHashValue;=0D + }=0D + else=0D + for(;;)=0D + {=0D {=0D - CLzRef *pair =3D son + ((_cyclicBufferPos - delta + ((delta > _cycli= cBufferPos) ? _cyclicBufferSize : 0)) << 1);=0D + CLzRef *pair =3D son + ((size_t)(_cyclicBufferPos - delta + ((_cycli= cBufferPos < delta) ? _cyclicBufferSize : 0)) << 1);=0D const Byte *pb =3D cur - delta;=0D - UInt32 len =3D (len0 < len1 ? len0 : len1);=0D + unsigned len =3D (len0 < len1 ? len0 : len1);=0D + UInt32 pair0 =3D *pair;=0D if (pb[len] =3D=3D cur[len])=0D {=0D if (++len !=3D lenLimit && pb[len] =3D=3D cur[len])=0D @@ -272,54 +291,66 @@ static Int32 NO_INLINE GetMatchesSpecN(UInt32 lenLimi= t, UInt32 pos, const Byte * break;=0D if (maxLen < len)=0D {=0D - *distances++ =3D maxLen =3D len;=0D + maxLen =3D len;=0D + *distances++ =3D (UInt32)len;=0D *distances++ =3D delta - 1;=0D if (len =3D=3D lenLimit)=0D {=0D - *ptr1 =3D pair[0];=0D - *ptr0 =3D pair[1];=0D + UInt32 pair1 =3D pair[1];=0D + *ptr1 =3D pair0;=0D + *ptr0 =3D pair1;=0D break;=0D }=0D }=0D }=0D - if (pb[len] < cur[len])=0D - {=0D - *ptr1 =3D curMatch;=0D - ptr1 =3D pair + 1;=0D - curMatch =3D *ptr1;=0D - len1 =3D len;=0D - }=0D - else=0D {=0D - *ptr0 =3D curMatch;=0D - ptr0 =3D pair;=0D - curMatch =3D *ptr0;=0D - len0 =3D len;=0D + UInt32 curMatch =3D pos - delta;=0D + // delta =3D pos - *pair;=0D + // delta =3D pos - pair[((UInt32)pb[len] - (UInt32)cur[len]) >> 31= ];=0D + if (pb[len] < cur[len])=0D + {=0D + delta =3D pos - pair[1];=0D + *ptr1 =3D curMatch;=0D + ptr1 =3D pair + 1;=0D + len1 =3D len;=0D + }=0D + else=0D + {=0D + delta =3D pos - *pair;=0D + *ptr0 =3D curMatch;=0D + ptr0 =3D pair;=0D + len0 =3D len;=0D + }=0D }=0D }=0D + if (--cutValue =3D=3D 0 || delta >=3D _cyclicBufferSize)=0D + {=0D + *ptr0 =3D *ptr1 =3D kEmptyHashValue;=0D + break;=0D + }=0D }=0D pos++;=0D _cyclicBufferPos++;=0D cur++;=0D {=0D UInt32 num =3D (UInt32)(distances - _distances);=0D - *_distances =3D num - 1;=0D - _distances +=3D num;=0D - limit -=3D num;=0D + _distances[-1] =3D num;=0D }=0D }=0D - while (limit > 0 && --size !=3D 0);=0D + while (distances < limit && --size !=3D 0);=0D *posRes =3D pos;=0D - return limit;=0D + return distances;=0D }=0D =0D #endif=0D =0D +=0D +=0D static void BtGetMatches(CMatchFinderMt *p, UInt32 *distances)=0D {=0D UInt32 numProcessed =3D 0;=0D UInt32 curPos =3D 2;=0D - UInt32 limit =3D kMtBtBlockSize - (p->matchMaxLen * 2);=0D + UInt32 limit =3D kMtBtBlockSize - (p->matchMaxLen * 2); // * 2=0D =0D distances[1] =3D p->hashNumAvail;=0D =0D @@ -369,8 +400,10 @@ static void BtGetMatches(CMatchFinderMt *p, UInt32 *di= stances) #else=0D {=0D UInt32 posRes;=0D - curPos =3D limit - GetMatchesSpecN(lenLimit, pos, p->buffer, p->so= n, cyclicBufferPos, p->cyclicBufferSize, p->cutValue,=0D - distances + curPos, p->numHashBytes - 1, p->hashBuf + p->hashB= ufPos, (Int32)(limit - curPos), size, &posRes);=0D + curPos =3D (UInt32)(GetMatchesSpecN(lenLimit, pos, p->buffer, p->s= on, cyclicBufferPos, p->cyclicBufferSize, p->cutValue,=0D + distances + curPos, p->numHashBytes - 1, p->hashBuf + p->hashB= ufPos,=0D + distances + limit,=0D + size, &posRes) - distances);=0D p->hashBufPos +=3D posRes - pos;=0D cyclicBufferPos +=3D posRes - pos;=0D p->buffer +=3D posRes - pos;=0D diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzFindMt.h b/BaseTools/S= ource/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=0D -2017-04-03 : Igor Pavlov : Public domain */=0D +2018-07-04 : Igor Pavlov : Public domain */=0D =0D #ifndef __LZ_FIND_MT_H=0D #define __LZ_FIND_MT_H=0D @@ -19,10 +19,10 @@ EXTERN_C_BEGIN =0D typedef struct _CMtSync=0D {=0D - Bool wasCreated;=0D - Bool needStart;=0D - Bool exit;=0D - Bool stopWriting;=0D + BoolInt wasCreated;=0D + BoolInt needStart;=0D + BoolInt exit;=0D + BoolInt stopWriting;=0D =0D CThread thread;=0D CAutoResetEvent canStart;=0D @@ -30,8 +30,8 @@ typedef struct _CMtSync CAutoResetEvent wasStopped;=0D CSemaphore freeSemaphore;=0D CSemaphore filledSemaphore;=0D - Bool csWasInitialized;=0D - Bool csWasEntered;=0D + BoolInt csWasInitialized;=0D + BoolInt csWasEntered;=0D CCriticalSection cs;=0D UInt32 numProcessedBlocks;=0D } CMtSync;=0D diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaDec.c b/BaseTools/So= urce/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=0D -2018-02-28 : Igor Pavlov : Public domain */=0D +2018-07-04 : Igor Pavlov : Public domain */=0D =0D #include "Precomp.h"=0D =0D +#include =0D +=0D /* #include "CpuArch.h" */=0D #include "LzmaDec.h"=0D =0D -#include =0D -=0D #define kNumTopBits 24=0D #define kTopValue ((UInt32)1 << kNumTopBits)=0D =0D @@ -19,7 +19,7 @@ =0D #define NORMALIZE if (range < kTopValue) { range <<=3D 8; code =3D (code <= < 8) | (*buf++); }=0D =0D -#define IF_BIT_0(p) ttt =3D *(p); NORMALIZE; bound =3D (range >> kNumBitMo= delTotalBits) * ttt; if (code < bound)=0D +#define IF_BIT_0(p) ttt =3D *(p); NORMALIZE; bound =3D (range >> kNumBitMo= delTotalBits) * (UInt32)ttt; if (code < bound)=0D #define UPDATE_0(p) range =3D bound; *(p) =3D (CLzmaProb)(ttt + ((kBitMode= lTotal - ttt) >> kNumMoveBits));=0D #define UPDATE_1(p) range -=3D bound; code -=3D bound; *(p) =3D (CLzmaProb= )(ttt - (ttt >> kNumMoveBits));=0D #define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \=0D @@ -66,7 +66,7 @@ =0D #define NORMALIZE_CHECK if (range < kTopValue) { if (buf >=3D bufLimit) re= turn DUMMY_ERROR; range <<=3D 8; code =3D (code << 8) | (*buf++); }=0D =0D -#define IF_BIT_0_CHECK(p) ttt =3D *(p); NORMALIZE_CHECK; bound =3D (range = >> kNumBitModelTotalBits) * ttt; if (code < bound)=0D +#define IF_BIT_0_CHECK(p) ttt =3D *(p); NORMALIZE_CHECK; bound =3D (range = >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound)=0D #define UPDATE_0_CHECK range =3D bound;=0D #define UPDATE_1_CHECK range -=3D bound; code -=3D bound;=0D #define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \=0D @@ -539,7 +539,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT li= mit, const Byte *bufLimit curLen =3D ((rem < len) ? (unsigned)rem : len);=0D pos =3D dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0);=0D =0D - processedPos +=3D curLen;=0D + processedPos +=3D (UInt32)curLen;=0D =0D len -=3D curLen;=0D if (curLen <=3D dicBufSize - pos)=0D @@ -547,7 +547,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT li= mit, const Byte *bufLimit Byte *dest =3D dic + dicPos;=0D ptrdiff_t src =3D (ptrdiff_t)pos - (ptrdiff_t)dicPos;=0D const Byte *lim =3D dest + curLen;=0D - dicPos +=3D curLen;=0D + dicPos +=3D (SizeT)curLen;=0D do=0D *(dest) =3D (Byte)*(dest + src);=0D while (++dest !=3D lim);=0D @@ -572,14 +572,14 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT = limit, const Byte *bufLimit p->buf =3D buf;=0D p->range =3D range;=0D p->code =3D code;=0D - p->remainLen =3D len;=0D + p->remainLen =3D (UInt32)len;=0D p->dicPos =3D dicPos;=0D p->processedPos =3D processedPos;=0D p->reps[0] =3D rep0;=0D p->reps[1] =3D rep1;=0D p->reps[2] =3D rep2;=0D p->reps[3] =3D rep3;=0D - p->state =3D state;=0D + p->state =3D (UInt32)state;=0D =0D return SZ_OK;=0D }=0D @@ -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)=0D p->checkDicSize =3D p->prop.dicSize;=0D =0D - p->processedPos +=3D len;=0D - p->remainLen -=3D len;=0D + p->processedPos +=3D (UInt32)len;=0D + p->remainLen -=3D (UInt32)len;=0D while (len !=3D 0)=0D {=0D len--;=0D @@ -850,7 +850,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, c= onst Byte *buf, SizeT inS }=0D =0D =0D -void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)=0D +void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initSta= te)=0D {=0D p->remainLen =3D kMatchSpecLenStart + 1;=0D p->tempBufSize =3D 0;=0D @@ -979,10 +979,10 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,= const Byte *src, SizeT *sr p->tempBufSize =3D rem;=0D if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)=0D {=0D - int dummyRes =3D LzmaDec_TryDummy(p, p->tempBuf, rem);=0D + int dummyRes =3D LzmaDec_TryDummy(p, p->tempBuf, (SizeT)rem);=0D if (dummyRes =3D=3D DUMMY_ERROR)=0D {=0D - (*srcLen) +=3D lookAhead;=0D + (*srcLen) +=3D (SizeT)lookAhead;=0D *status =3D LZMA_STATUS_NEEDS_MORE_INPUT;=0D return SZ_OK;=0D }=0D @@ -1005,9 +1005,9 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,= const Byte *src, SizeT *sr return SZ_ERROR_FAIL; /* some internal error */=0D lookAhead -=3D rem;=0D }=0D - (*srcLen) +=3D lookAhead;=0D + (*srcLen) +=3D (SizeT)lookAhead;=0D src +=3D lookAhead;=0D - inSize -=3D lookAhead;=0D + inSize -=3D (SizeT)lookAhead;=0D p->tempBufSize =3D 0;=0D }=0D }=0D diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c b/BaseTools/So= urce/C/LzmaCompress/Sdk/C/LzmaEnc.c index e281716fee..4e9b499f8d 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=0D -2018-04-29 : Igor Pavlov : Public domain */=0D +2019-01-10: Igor Pavlov : Public domain */=0D =0D #include "Precomp.h"=0D =0D @@ -38,6 +38,8 @@ static unsigned g_STAT_OFFSET =3D 0; #define kNumBitPriceShiftBits 4=0D #define kBitPrice (1 << kNumBitPriceShiftBits)=0D =0D +#define REP_LEN_COUNT 64=0D +=0D void LzmaEncProps_Init(CLzmaEncProps *p)=0D {=0D p->level =3D 5;=0D @@ -52,7 +54,7 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p) int level =3D p->level;=0D if (level < 0) level =3D 5;=0D p->level =3D level;=0D - =0D +=0D if (p->dictSize =3D=3D 0) p->dictSize =3D (level <=3D 5 ? (1 << (level *= 2 + 14)) : (level <=3D 7 ? (1 << 25) : (1 << 26)));=0D if (p->dictSize > p->reduceSize)=0D {=0D @@ -74,7 +76,7 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p) if (p->btMode < 0) p->btMode =3D (p->algo =3D=3D 0 ? 0 : 1);=0D if (p->numHashBytes < 0) p->numHashBytes =3D 4;=0D if (p->mc =3D=3D 0) p->mc =3D (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1)= ;=0D - =0D +=0D if (p->numThreads < 0)=0D p->numThreads =3D=0D #ifndef _7ZIP_ST=0D @@ -124,7 +126,7 @@ static void LzmaEnc_FastPosInit(Byte *g_FastPos) g_FastPos[0] =3D 0;=0D g_FastPos[1] =3D 1;=0D g_FastPos +=3D 2;=0D - =0D +=0D for (slot =3D 2; slot < kNumLogBits * 2; slot++)=0D {=0D size_t k =3D ((size_t)1 << ((slot >> 1) - 1));=0D @@ -183,8 +185,11 @@ typedef struct } COptimal;=0D =0D =0D -#define kNumOpts (1 << 12)=0D -#define kPackReserve (1 + kNumOpts * 2)=0D +// 18.06=0D +#define kNumOpts (1 << 11)=0D +#define kPackReserve (kNumOpts * 8)=0D +// #define kNumOpts (1 << 12)=0D +// #define kPackReserve (1 + kNumOpts * 2)=0D =0D #define kNumLenToPosStates 4=0D #define kNumPosSlotBits 6=0D @@ -236,10 +241,18 @@ typedef struct typedef struct=0D {=0D unsigned tableSize;=0D - unsigned counters[LZMA_NUM_PB_STATES_MAX];=0D UInt32 prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal];=0D + // UInt32 prices1[LZMA_NUM_PB_STATES_MAX][kLenNumLowSymbols * 2];=0D + // UInt32 prices2[kLenNumSymbolsTotal];=0D } CLenPriceEnc;=0D =0D +#define GET_PRICE_LEN(p, posState, len) \=0D + ((p)->prices[posState][(size_t)(len) - LZMA_MATCH_LEN_MIN])=0D +=0D +/*=0D +#define GET_PRICE_LEN(p, posState, len) \=0D + ((p)->prices2[(size_t)(len) - 2] + ((p)->prices1[posState][((len) - 2)= & (kLenNumLowSymbols * 2 - 1)] & (((len) - 2 - kLenNumLowSymbols * 2) >> 9= )))=0D +*/=0D =0D typedef struct=0D {=0D @@ -273,7 +286,7 @@ typedef struct =0D CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];=0D CLzmaProb posEncoders[kNumFullDistances];=0D - =0D +=0D CLenEnc lenProbs;=0D CLenEnc repLenProbs;=0D =0D @@ -308,16 +321,18 @@ typedef struct unsigned lc, lp, pb;=0D unsigned lclp;=0D =0D - Bool fastMode;=0D - Bool writeEndMark;=0D - Bool finished;=0D - Bool multiThread;=0D - Bool needInit;=0D + BoolInt fastMode;=0D + BoolInt writeEndMark;=0D + BoolInt finished;=0D + BoolInt multiThread;=0D + BoolInt needInit;=0D + // BoolInt _maxMode;=0D =0D UInt64 nowPos64;=0D - =0D +=0D unsigned matchPriceCount;=0D - unsigned alignPriceCount;=0D + // unsigned alignPriceCount;=0D + int repLenEncCounter;=0D =0D unsigned distTableSize;=0D =0D @@ -325,7 +340,7 @@ typedef struct SRes result;=0D =0D #ifndef _7ZIP_ST=0D - Bool mtMode;=0D + BoolInt mtMode;=0D // begin of CMatchFinderMt is used in LZ thread=0D CMatchFinderMt matchFinderMt;=0D // end of CMatchFinderMt is used in BT and HASH threads=0D @@ -336,7 +351,7 @@ typedef struct #ifndef _7ZIP_ST=0D Byte pad[128];=0D #endif=0D - =0D +=0D // LZ thread=0D CProbPrice ProbPrices[kBitModelTotal >> kNumMoveReducingBits];=0D =0D @@ -355,7 +370,7 @@ typedef struct CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX];=0D CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];=0D CLzmaProb posEncoders[kNumFullDistances];=0D - =0D +=0D CLenEnc lenProbs;=0D CLenEnc repLenProbs;=0D =0D @@ -383,9 +398,9 @@ void LzmaEnc_SaveState(CLzmaEncHandle pp) {=0D CLzmaEnc *p =3D (CLzmaEnc *)pp;=0D CSaveState *dest =3D &p->saveState;=0D - =0D +=0D dest->state =3D p->state;=0D - =0D +=0D dest->lenProbs =3D p->lenProbs;=0D dest->repLenProbs =3D p->repLenProbs;=0D =0D @@ -414,9 +429,9 @@ void LzmaEnc_RestoreState(CLzmaEncHandle pp) =0D dest->lenProbs =3D p->lenProbs;=0D dest->repLenProbs =3D p->repLenProbs;=0D - =0D +=0D COPY_ARR(dest, p, reps);=0D - =0D +=0D COPY_ARR(dest, p, posAlignEncoder);=0D COPY_ARR(dest, p, isRep);=0D COPY_ARR(dest, p, isRepG0);=0D @@ -458,6 +473,7 @@ SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEnc= Props *props2) p->lp =3D props.lp;=0D p->pb =3D props.pb;=0D p->fastMode =3D (props.algo =3D=3D 0);=0D + // p->_maxMode =3D True;=0D p->matchFinderBase.btMode =3D (Byte)(props.btMode ? 1 : 0);=0D {=0D unsigned numHashBytes =3D 4;=0D @@ -618,9 +634,9 @@ static void RangeEnc_FlushData(CRangeEnc *p) =0D #ifdef _LZMA_ENC_USE_BRANCH=0D =0D -#define RC_BIT(p, prob, symbol) { \=0D +#define RC_BIT(p, prob, bit) { \=0D RC_BIT_PRE(p, prob) \=0D - if (symbol =3D=3D 0) { range =3D newBound; ttt +=3D (kBitModelTotal - tt= t) >> kNumMoveBits; } \=0D + if (bit =3D=3D 0) { range =3D newBound; ttt +=3D (kBitModelTotal - ttt) = >> kNumMoveBits; } \=0D else { (p)->low +=3D newBound; range -=3D newBound; ttt -=3D ttt >> kNum= MoveBits; } \=0D *(prob) =3D (CLzmaProb)ttt; \=0D RC_NORM(p) \=0D @@ -628,15 +644,15 @@ static void RangeEnc_FlushData(CRangeEnc *p) =0D #else=0D =0D -#define RC_BIT(p, prob, symbol) { \=0D +#define RC_BIT(p, prob, bit) { \=0D UInt32 mask; \=0D RC_BIT_PRE(p, prob) \=0D - mask =3D 0 - (UInt32)symbol; \=0D + mask =3D 0 - (UInt32)bit; \=0D range &=3D mask; \=0D mask &=3D newBound; \=0D range -=3D mask; \=0D (p)->low +=3D mask; \=0D - mask =3D (UInt32)symbol - 1; \=0D + mask =3D (UInt32)bit - 1; \=0D range +=3D newBound & mask; \=0D mask &=3D (kBitModelTotal - ((1 << kNumMoveBits) - 1)); \=0D mask +=3D ((1 << kNumMoveBits) - 1); \=0D @@ -673,42 +689,42 @@ static void RangeEnc_EncodeBit_0(CRangeEnc *p, CLzmaP= rob *prob) p->range =3D range;=0D }=0D =0D -static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol)=0D +static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 sym)=0D {=0D UInt32 range =3D p->range;=0D - symbol |=3D 0x100;=0D + sym |=3D 0x100;=0D do=0D {=0D UInt32 ttt, newBound;=0D - // RangeEnc_EncodeBit(p, probs + (symbol >> 8), (symbol >> 7) & 1);=0D - CLzmaProb *prob =3D probs + (symbol >> 8);=0D - UInt32 bit =3D (symbol >> 7) & 1;=0D - symbol <<=3D 1;=0D + // RangeEnc_EncodeBit(p, probs + (sym >> 8), (sym >> 7) & 1);=0D + CLzmaProb *prob =3D probs + (sym >> 8);=0D + UInt32 bit =3D (sym >> 7) & 1;=0D + sym <<=3D 1;=0D RC_BIT(p, prob, bit);=0D }=0D - while (symbol < 0x10000);=0D + while (sym < 0x10000);=0D p->range =3D range;=0D }=0D =0D -static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 sy= mbol, UInt32 matchByte)=0D +static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 sy= m, UInt32 matchByte)=0D {=0D UInt32 range =3D p->range;=0D UInt32 offs =3D 0x100;=0D - symbol |=3D 0x100;=0D + sym |=3D 0x100;=0D do=0D {=0D UInt32 ttt, newBound;=0D CLzmaProb *prob;=0D UInt32 bit;=0D matchByte <<=3D 1;=0D - // RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (symbol = >> 8)), (symbol >> 7) & 1);=0D - prob =3D probs + (offs + (matchByte & offs) + (symbol >> 8));=0D - bit =3D (symbol >> 7) & 1;=0D - symbol <<=3D 1;=0D - offs &=3D ~(matchByte ^ symbol);=0D + // RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (sym >> = 8)), (sym >> 7) & 1);=0D + prob =3D probs + (offs + (matchByte & offs) + (sym >> 8));=0D + bit =3D (sym >> 7) & 1;=0D + sym <<=3D 1;=0D + offs &=3D ~(matchByte ^ sym);=0D RC_BIT(p, prob, bit);=0D }=0D - while (symbol < 0x10000);=0D + while (sym < 0x10000);=0D p->range =3D range;=0D }=0D =0D @@ -739,11 +755,11 @@ static void LzmaEnc_InitPriceTables(CProbPrice *ProbP= rices) }=0D =0D =0D -#define GET_PRICE(prob, symbol) \=0D - p->ProbPrices[((prob) ^ (unsigned)(((-(int)(symbol))) & (kBitModelTotal = - 1))) >> kNumMoveReducingBits];=0D +#define GET_PRICE(prob, bit) \=0D + p->ProbPrices[((prob) ^ (unsigned)(((-(int)(bit))) & (kBitModelTotal - 1= ))) >> kNumMoveReducingBits];=0D =0D -#define GET_PRICEa(prob, symbol) \=0D - ProbPrices[((prob) ^ (unsigned)((-((int)(symbol))) & (kBitModelTotal = - 1))) >> kNumMoveReducingBits];=0D +#define GET_PRICEa(prob, bit) \=0D + ProbPrices[((prob) ^ (unsigned)((-((int)(bit))) & (kBitModelTotal - 1= ))) >> kNumMoveReducingBits];=0D =0D #define GET_PRICE_0(prob) p->ProbPrices[(prob) >> kNumMoveReducingBits]=0D #define GET_PRICE_1(prob) p->ProbPrices[((prob) ^ (kBitModelTotal - 1)) >>= kNumMoveReducingBits]=0D @@ -752,48 +768,48 @@ static void LzmaEnc_InitPriceTables(CProbPrice *ProbP= rices) #define GET_PRICEa_1(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> k= NumMoveReducingBits]=0D =0D =0D -static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 symbol, const= CProbPrice *ProbPrices)=0D +static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 sym, const CP= robPrice *ProbPrices)=0D {=0D UInt32 price =3D 0;=0D - symbol |=3D 0x100;=0D + sym |=3D 0x100;=0D do=0D {=0D - unsigned bit =3D symbol & 1;=0D - symbol >>=3D 1;=0D - price +=3D GET_PRICEa(probs[symbol], bit);=0D + unsigned bit =3D sym & 1;=0D + sym >>=3D 1;=0D + price +=3D GET_PRICEa(probs[sym], bit);=0D }=0D - while (symbol >=3D 2);=0D + while (sym >=3D 2);=0D return price;=0D }=0D =0D =0D -static UInt32 LitEnc_Matched_GetPrice(const CLzmaProb *probs, UInt32 symbo= l, UInt32 matchByte, const CProbPrice *ProbPrices)=0D +static UInt32 LitEnc_Matched_GetPrice(const CLzmaProb *probs, UInt32 sym, = UInt32 matchByte, const CProbPrice *ProbPrices)=0D {=0D UInt32 price =3D 0;=0D UInt32 offs =3D 0x100;=0D - symbol |=3D 0x100;=0D + sym |=3D 0x100;=0D do=0D {=0D matchByte <<=3D 1;=0D - price +=3D GET_PRICEa(probs[offs + (matchByte & offs) + (symbol >> 8)]= , (symbol >> 7) & 1);=0D - symbol <<=3D 1;=0D - offs &=3D ~(matchByte ^ symbol);=0D + price +=3D GET_PRICEa(probs[offs + (matchByte & offs) + (sym >> 8)], (= sym >> 7) & 1);=0D + sym <<=3D 1;=0D + offs &=3D ~(matchByte ^ sym);=0D }=0D - while (symbol < 0x10000);=0D + while (sym < 0x10000);=0D return price;=0D }=0D =0D =0D -static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, unsigned= numBits, UInt32 symbol)=0D +static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, unsigned= numBits, unsigned sym)=0D {=0D UInt32 range =3D rc->range;=0D unsigned m =3D 1;=0D do=0D {=0D UInt32 ttt, newBound;=0D - unsigned bit =3D symbol & 1;=0D + unsigned bit =3D sym & 1;=0D // RangeEnc_EncodeBit(rc, probs + m, bit);=0D - symbol >>=3D 1;=0D + sym >>=3D 1;=0D RC_BIT(rc, probs + m, bit);=0D m =3D (m << 1) | bit;=0D }=0D @@ -812,37 +828,37 @@ static void LenEnc_Init(CLenEnc *p) p->high[i] =3D kProbInitValue;=0D }=0D =0D -static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, unsigned symbol, unsi= gned posState)=0D +static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, unsigned sym, unsigne= d posState)=0D {=0D UInt32 range, ttt, newBound;=0D CLzmaProb *probs =3D p->low;=0D range =3D rc->range;=0D RC_BIT_PRE(rc, probs);=0D - if (symbol >=3D kLenNumLowSymbols)=0D + if (sym >=3D kLenNumLowSymbols)=0D {=0D RC_BIT_1(rc, probs);=0D probs +=3D kLenNumLowSymbols;=0D RC_BIT_PRE(rc, probs);=0D - if (symbol >=3D kLenNumLowSymbols * 2)=0D + if (sym >=3D kLenNumLowSymbols * 2)=0D {=0D RC_BIT_1(rc, probs);=0D rc->range =3D range;=0D - // RcTree_Encode(rc, p->high, kLenNumHighBits, symbol - kLenNumLowSy= mbols * 2);=0D - LitEnc_Encode(rc, p->high, symbol - kLenNumLowSymbols * 2);=0D + // RcTree_Encode(rc, p->high, kLenNumHighBits, sym - kLenNumLowSymbo= ls * 2);=0D + LitEnc_Encode(rc, p->high, sym - kLenNumLowSymbols * 2);=0D return;=0D }=0D - symbol -=3D kLenNumLowSymbols;=0D + sym -=3D kLenNumLowSymbols;=0D }=0D =0D - // RcTree_Encode(rc, probs + (posState << kLenNumLowBits), kLenNumLowBit= s, symbol);=0D + // RcTree_Encode(rc, probs + (posState << kLenNumLowBits), kLenNumLowBit= s, sym);=0D {=0D unsigned m;=0D unsigned bit;=0D RC_BIT_0(rc, probs);=0D probs +=3D (posState << (1 + kLenNumLowBits));=0D - bit =3D (symbol >> 2) ; RC_BIT(rc, probs + 1, bit); m =3D (1 << 1) = + bit;=0D - bit =3D (symbol >> 1) & 1; RC_BIT(rc, probs + m, bit); m =3D (m << 1) = + bit;=0D - bit =3D symbol & 1; RC_BIT(rc, probs + m, bit);=0D + bit =3D (sym >> 2) ; RC_BIT(rc, probs + 1, bit); m =3D (1 << 1) + b= it;=0D + bit =3D (sym >> 1) & 1; RC_BIT(rc, probs + m, bit); m =3D (m << 1) + b= it;=0D + bit =3D sym & 1; RC_BIT(rc, probs + m, bit);=0D rc->range =3D range;=0D }=0D }=0D @@ -863,50 +879,93 @@ static void SetPrices_3(const CLzmaProb *probs, UInt3= 2 startPrice, UInt32 *price }=0D =0D =0D -MY_NO_INLINE static void MY_FAST_CALL LenPriceEnc_UpdateTable(=0D - CLenPriceEnc *p, unsigned posState,=0D +MY_NO_INLINE static void MY_FAST_CALL LenPriceEnc_UpdateTables(=0D + CLenPriceEnc *p,=0D + unsigned numPosStates,=0D const CLenEnc *enc,=0D const CProbPrice *ProbPrices)=0D {=0D - // int y; for (y =3D 0; y < 100; y++) {=0D - UInt32 a;=0D - unsigned i, numSymbols;=0D + UInt32 b;=0D +=0D + {=0D + unsigned prob =3D enc->low[0];=0D + UInt32 a, c;=0D + unsigned posState;=0D + b =3D GET_PRICEa_1(prob);=0D + a =3D GET_PRICEa_0(prob);=0D + c =3D b + GET_PRICEa_0(enc->low[kLenNumLowSymbols]);=0D + for (posState =3D 0; posState < numPosStates; posState++)=0D + {=0D + UInt32 *prices =3D p->prices[posState];=0D + const CLzmaProb *probs =3D enc->low + (posState << (1 + kLenNumLowBi= ts));=0D + SetPrices_3(probs, a, prices, ProbPrices);=0D + SetPrices_3(probs + kLenNumLowSymbols, c, prices + kLenNumLowSymbols= , ProbPrices);=0D + }=0D + }=0D =0D - UInt32 *prices =3D p->prices[posState];=0D + /*=0D {=0D - const CLzmaProb *probs =3D enc->low + (posState << (1 + kLenNumLowBits= ));=0D - SetPrices_3(probs, GET_PRICEa_0(enc->low[0]), prices, ProbPrices);=0D + unsigned i;=0D + UInt32 b;=0D + a =3D GET_PRICEa_0(enc->low[0]);=0D + for (i =3D 0; i < kLenNumLowSymbols; i++)=0D + p->prices2[i] =3D a;=0D a =3D GET_PRICEa_1(enc->low[0]);=0D - SetPrices_3(probs + kLenNumLowSymbols, a + GET_PRICEa_0(enc->low[kLenN= umLowSymbols]), prices + kLenNumLowSymbols, ProbPrices);=0D + b =3D a + GET_PRICEa_0(enc->low[kLenNumLowSymbols]);=0D + for (i =3D kLenNumLowSymbols; i < kLenNumLowSymbols * 2; i++)=0D + p->prices2[i] =3D b;=0D a +=3D GET_PRICEa_1(enc->low[kLenNumLowSymbols]);=0D }=0D - numSymbols =3D p->tableSize;=0D - p->counters[posState] =3D numSymbols;=0D - for (i =3D kLenNumLowSymbols * 2; i < numSymbols; i +=3D 1)=0D + */=0D +=0D + // p->counter =3D numSymbols;=0D + // p->counter =3D 64;=0D +=0D {=0D - prices[i] =3D a +=0D - // RcTree_GetPrice(enc->high, kLenNumHighBits, i - kLenNumLowSymbol= s * 2, ProbPrices);=0D - LitEnc_GetPrice(enc->high, i - kLenNumLowSymbols * 2, ProbPrices);= =0D - /*=0D - unsigned sym =3D (i - kLenNumLowSymbols * 2) >> 1;=0D - UInt32 price =3D a + RcTree_GetPrice(enc->high, kLenNumHighBits - 1, s= ym, ProbPrices);=0D - UInt32 prob =3D enc->high[(1 << 7) + sym];=0D - prices[i ] =3D price + GET_PRICEa_0(prob);=0D - prices[i + 1] =3D price + GET_PRICEa_1(prob);=0D - */=0D - }=0D - // }=0D -}=0D + unsigned i =3D p->tableSize;=0D =0D -static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, unsigned numPosState= s,=0D - const CLenEnc *enc,=0D - const CProbPrice *ProbPrices)=0D -{=0D - unsigned posState;=0D - for (posState =3D 0; posState < numPosStates; posState++)=0D - LenPriceEnc_UpdateTable(p, posState, enc, ProbPrices);=0D -}=0D + if (i > kLenNumLowSymbols * 2)=0D + {=0D + const CLzmaProb *probs =3D enc->high;=0D + UInt32 *prices =3D p->prices[0] + kLenNumLowSymbols * 2;=0D + i -=3D kLenNumLowSymbols * 2 - 1;=0D + i >>=3D 1;=0D + b +=3D GET_PRICEa_1(enc->low[kLenNumLowSymbols]);=0D + do=0D + {=0D + /*=0D + p->prices2[i] =3D a +=0D + // RcTree_GetPrice(enc->high, kLenNumHighBits, i - kLenNumLowSymbo= ls * 2, ProbPrices);=0D + LitEnc_GetPrice(probs, i - kLenNumLowSymbols * 2, ProbPrices);=0D + */=0D + // UInt32 price =3D a + RcTree_GetPrice(probs, kLenNumHighBits - 1= , sym, ProbPrices);=0D + unsigned sym =3D --i + (1 << (kLenNumHighBits - 1));=0D + UInt32 price =3D b;=0D + do=0D + {=0D + unsigned bit =3D sym & 1;=0D + sym >>=3D 1;=0D + price +=3D GET_PRICEa(probs[sym], bit);=0D + }=0D + while (sym >=3D 2);=0D +=0D + {=0D + unsigned prob =3D probs[(size_t)i + (1 << (kLenNumHighBits - 1))= ];=0D + prices[(size_t)i * 2 ] =3D price + GET_PRICEa_0(prob);=0D + prices[(size_t)i * 2 + 1] =3D price + GET_PRICEa_1(prob);=0D + }=0D + }=0D + while (i);=0D =0D + {=0D + unsigned posState;=0D + size_t num =3D (p->tableSize - kLenNumLowSymbols * 2) * sizeof(p->= prices[0][0]);=0D + for (posState =3D 1; posState < numPosStates; posState++)=0D + memcpy(p->prices[posState] + kLenNumLowSymbols * 2, p->prices[0]= + kLenNumLowSymbols * 2, num);=0D + }=0D + }=0D + }=0D +}=0D =0D /*=0D #ifdef SHOW_STAT=0D @@ -914,21 +973,21 @@ static void LenPriceEnc_UpdateTables(CLenPriceEnc *p,= unsigned numPosStates, printf("\n MovePos %u", num);=0D #endif=0D */=0D - =0D +=0D #define MOVE_POS(p, num) { \=0D p->additionalOffset +=3D (num); \=0D - p->matchFinder.Skip(p->matchFinderObj, (num)); }=0D + p->matchFinder.Skip(p->matchFinderObj, (UInt32)(num)); }=0D =0D =0D static unsigned ReadMatchDistances(CLzmaEnc *p, unsigned *numPairsRes)=0D {=0D unsigned numPairs;=0D - =0D +=0D p->additionalOffset++;=0D p->numAvail =3D p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);= =0D numPairs =3D p->matchFinder.GetMatches(p->matchFinderObj, p->matches);=0D *numPairsRes =3D numPairs;=0D - =0D +=0D #ifdef SHOW_STAT=0D printf("\n i =3D %u numPairs =3D %u ", g_STAT_OFFSET, numPairs / 2);= =0D g_STAT_OFFSET++;=0D @@ -938,7 +997,7 @@ static unsigned ReadMatchDistances(CLzmaEnc *p, unsigne= d *numPairsRes) printf("%2u %6u | ", p->matches[i], p->matches[i + 1]);=0D }=0D #endif=0D - =0D +=0D if (numPairs =3D=3D 0)=0D return 0;=0D {=0D @@ -954,7 +1013,8 @@ static unsigned ReadMatchDistances(CLzmaEnc *p, unsign= ed *numPairsRes) const Byte *p2 =3D p1 + len;=0D ptrdiff_t dif =3D (ptrdiff_t)-1 - p->matches[(size_t)numPairs - 1]= ;=0D const Byte *lim =3D p1 + numAvail;=0D - for (; p2 !=3D lim && *p2 =3D=3D p2[dif]; p2++);=0D + for (; p2 !=3D lim && *p2 =3D=3D p2[dif]; p2++)=0D + {}=0D return (unsigned)(p2 - p1);=0D }=0D }=0D @@ -976,8 +1036,8 @@ static unsigned ReadMatchDistances(CLzmaEnc *p, unsign= ed *numPairsRes) + GET_PRICE_1(p->isRep0Long[state][posState])) \=0D + GET_PRICE_1(p->isRep[state]) \=0D + GET_PRICE_0(p->isRepG0[state])=0D - =0D =0D +MY_FORCE_INLINE=0D static UInt32 GetPrice_PureRep(const CLzmaEnc *p, unsigned repIndex, size_= t state, size_t posState)=0D {=0D UInt32 price;=0D @@ -1011,14 +1071,14 @@ static unsigned Backward(CLzmaEnc *p, unsigned cur) for (;;)=0D {=0D UInt32 dist =3D p->opt[cur].dist;=0D - UInt32 len =3D p->opt[cur].len;=0D - UInt32 extra =3D p->opt[cur].extra;=0D + unsigned len =3D (unsigned)p->opt[cur].len;=0D + unsigned extra =3D (unsigned)p->opt[cur].extra;=0D cur -=3D len;=0D =0D if (extra)=0D {=0D wr--;=0D - p->opt[wr].len =3D len;=0D + p->opt[wr].len =3D (UInt32)len;=0D cur -=3D extra;=0D len =3D extra;=0D if (extra =3D=3D 1)=0D @@ -1042,10 +1102,10 @@ static unsigned Backward(CLzmaEnc *p, unsigned cur) p->optCur =3D wr;=0D return len;=0D }=0D - =0D +=0D wr--;=0D p->opt[wr].dist =3D dist;=0D - p->opt[wr].len =3D len;=0D + p->opt[wr].len =3D (UInt32)len;=0D }=0D }=0D =0D @@ -1068,9 +1128,9 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 positi= on) UInt32 matchPrice, repMatchPrice;=0D const Byte *data;=0D Byte curByte, matchByte;=0D - =0D +=0D p->optCur =3D p->optEnd =3D 0;=0D - =0D +=0D if (p->additionalOffset =3D=3D 0)=0D mainLen =3D ReadMatchDistances(p, &numPairs);=0D else=0D @@ -1078,7 +1138,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 positi= on) mainLen =3D p->longestMatchLen;=0D numPairs =3D p->numPairs;=0D }=0D - =0D +=0D numAvail =3D p->numAvail;=0D if (numAvail < 2)=0D {=0D @@ -1087,10 +1147,10 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posi= tion) }=0D if (numAvail > LZMA_MATCH_LEN_MAX)=0D numAvail =3D LZMA_MATCH_LEN_MAX;=0D - =0D +=0D data =3D p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;= =0D repMaxIndex =3D 0;=0D - =0D +=0D for (i =3D 0; i < LZMA_NUM_REPS; i++)=0D {=0D unsigned len;=0D @@ -1102,43 +1162,48 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posi= tion) repLens[i] =3D 0;=0D continue;=0D }=0D - for (len =3D 2; len < numAvail && data[len] =3D=3D data2[len]; len++= );=0D + for (len =3D 2; len < numAvail && data[len] =3D=3D data2[len]; len++= )=0D + {}=0D repLens[i] =3D len;=0D if (len > repLens[repMaxIndex])=0D repMaxIndex =3D i;=0D }=0D - =0D +=0D if (repLens[repMaxIndex] >=3D p->numFastBytes)=0D {=0D unsigned len;=0D - p->backRes =3D repMaxIndex;=0D + p->backRes =3D (UInt32)repMaxIndex;=0D len =3D repLens[repMaxIndex];=0D MOVE_POS(p, len - 1)=0D return len;=0D }=0D - =0D +=0D matches =3D p->matches;=0D - =0D +=0D if (mainLen >=3D p->numFastBytes)=0D {=0D p->backRes =3D matches[(size_t)numPairs - 1] + LZMA_NUM_REPS;=0D MOVE_POS(p, mainLen - 1)=0D return mainLen;=0D }=0D - =0D +=0D curByte =3D *data;=0D matchByte =3D *(data - reps[0]);=0D - =0D - if (mainLen < 2 && curByte !=3D matchByte && repLens[repMaxIndex] < 2)= =0D +=0D + last =3D repLens[repMaxIndex];=0D + if (last <=3D mainLen)=0D + last =3D mainLen;=0D +=0D + if (last < 2 && curByte !=3D matchByte)=0D {=0D p->backRes =3D MARK_LIT;=0D return 1;=0D }=0D - =0D +=0D p->opt[0].state =3D (CState)p->state;=0D - =0D +=0D posState =3D (position & p->pbMask);=0D - =0D +=0D {=0D const CLzmaProb *probs =3D LIT_PROBS(position, *(data - 1));=0D p->opt[1].price =3D GET_PRICE_0(p->isMatch[p->state][posState]) +=0D @@ -1146,13 +1211,14 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posi= tion) LitEnc_Matched_GetPrice(probs, curByte, matchByte, p->ProbPrices= ) :=0D LitEnc_GetPrice(probs, curByte, p->ProbPrices));=0D }=0D - =0D +=0D MakeAs_Lit(&p->opt[1]);=0D - =0D +=0D matchPrice =3D GET_PRICE_1(p->isMatch[p->state][posState]);=0D repMatchPrice =3D matchPrice + GET_PRICE_1(p->isRep[p->state]);=0D - =0D - if (matchByte =3D=3D curByte)=0D +=0D + // 18.06=0D + if (matchByte =3D=3D curByte && repLens[0] =3D=3D 0)=0D {=0D UInt32 shortRepPrice =3D repMatchPrice + GetPrice_ShortRep(p, p->sta= te, posState);=0D if (shortRepPrice < p->opt[1].price)=0D @@ -1160,32 +1226,22 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posi= tion) p->opt[1].price =3D shortRepPrice;=0D MakeAs_ShortRep(&p->opt[1]);=0D }=0D + if (last < 2)=0D + {=0D + p->backRes =3D p->opt[1].dist;=0D + return 1;=0D + }=0D }=0D - =0D - last =3D (mainLen >=3D repLens[repMaxIndex] ? mainLen : repLens[repMax= Index]);=0D - =0D - if (last < 2)=0D - {=0D - p->backRes =3D p->opt[1].dist;=0D - return 1;=0D - }=0D - =0D +=0D p->opt[1].len =3D 1;=0D - =0D +=0D p->opt[0].reps[0] =3D reps[0];=0D p->opt[0].reps[1] =3D reps[1];=0D p->opt[0].reps[2] =3D reps[2];=0D p->opt[0].reps[3] =3D reps[3];=0D - =0D - {=0D - unsigned len =3D last;=0D - do=0D - p->opt[len--].price =3D kInfinityPrice;=0D - while (len >=3D 2);=0D - }=0D =0D // ---------- REP ----------=0D - =0D +=0D for (i =3D 0; i < LZMA_NUM_REPS; i++)=0D {=0D unsigned repLen =3D repLens[i];=0D @@ -1195,58 +1251,61 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posi= tion) price =3D repMatchPrice + GetPrice_PureRep(p, i, p->state, posState)= ;=0D do=0D {=0D - UInt32 price2 =3D price + p->repLenEnc.prices[posState][(size_t)re= pLen - 2];=0D + UInt32 price2 =3D price + GET_PRICE_LEN(&p->repLenEnc, posState, r= epLen);=0D COptimal *opt =3D &p->opt[repLen];=0D if (price2 < opt->price)=0D {=0D opt->price =3D price2;=0D - opt->len =3D repLen;=0D - opt->dist =3D i;=0D + opt->len =3D (UInt32)repLen;=0D + opt->dist =3D (UInt32)i;=0D opt->extra =3D 0;=0D }=0D }=0D while (--repLen >=3D 2);=0D }=0D - =0D - =0D +=0D +=0D // ---------- MATCH ----------=0D {=0D - unsigned len =3D ((repLens[0] >=3D 2) ? repLens[0] + 1 : 2);=0D + unsigned len =3D repLens[0] + 1;=0D if (len <=3D mainLen)=0D {=0D unsigned offs =3D 0;=0D UInt32 normalMatchPrice =3D matchPrice + GET_PRICE_0(p->isRep[p->s= tate]);=0D =0D - while (len > matches[offs])=0D - offs +=3D 2;=0D - =0D + if (len < 2)=0D + len =3D 2;=0D + else=0D + while (len > matches[offs])=0D + offs +=3D 2;=0D +=0D for (; ; len++)=0D {=0D COptimal *opt;=0D UInt32 dist =3D matches[(size_t)offs + 1];=0D - UInt32 price2 =3D normalMatchPrice + p->lenEnc.prices[posState][= (size_t)len - LZMA_MATCH_LEN_MIN];=0D + UInt32 price =3D normalMatchPrice + GET_PRICE_LEN(&p->lenEnc, po= sState, len);=0D unsigned lenToPosState =3D GetLenToPosState(len);=0D - =0D +=0D if (dist < kNumFullDistances)=0D - price2 +=3D p->distancesPrices[lenToPosState][dist & (kNumFull= Distances - 1)];=0D + price +=3D p->distancesPrices[lenToPosState][dist & (kNumFullD= istances - 1)];=0D else=0D {=0D unsigned slot;=0D GetPosSlot2(dist, slot);=0D - price2 +=3D p->alignPrices[dist & kAlignMask];=0D - price2 +=3D p->posSlotPrices[lenToPosState][slot];=0D + price +=3D p->alignPrices[dist & kAlignMask];=0D + price +=3D p->posSlotPrices[lenToPosState][slot];=0D }=0D - =0D +=0D opt =3D &p->opt[len];=0D - =0D - if (price2 < opt->price)=0D +=0D + if (price < opt->price)=0D {=0D - opt->price =3D price2;=0D - opt->len =3D len;=0D + opt->price =3D price;=0D + opt->len =3D (UInt32)len;=0D opt->dist =3D dist + LZMA_NUM_REPS;=0D opt->extra =3D 0;=0D }=0D - =0D +=0D if (len =3D=3D matches[offs])=0D {=0D offs +=3D 2;=0D @@ -1256,7 +1315,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 positi= on) }=0D }=0D }=0D - =0D +=0D =0D cur =3D 0;=0D =0D @@ -1272,37 +1331,73 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posi= tion) }=0D =0D =0D - =0D +=0D // ---------- Optimal Parsing ----------=0D =0D for (;;)=0D {=0D - UInt32 numAvail, numAvailFull;=0D + unsigned numAvail;=0D + UInt32 numAvailFull;=0D unsigned newLen, numPairs, prev, state, posState, startLen;=0D - UInt32 curPrice, litPrice, matchPrice, repMatchPrice;=0D - Bool nextIsLit;=0D + UInt32 litPrice, matchPrice, repMatchPrice;=0D + BoolInt nextIsLit;=0D Byte curByte, matchByte;=0D const Byte *data;=0D COptimal *curOpt, *nextOpt;=0D =0D if (++cur =3D=3D last)=0D - return Backward(p, cur);=0D + break;=0D +=0D + // 18.06=0D + if (cur >=3D kNumOpts - 64)=0D + {=0D + unsigned j, best;=0D + UInt32 price =3D p->opt[cur].price;=0D + best =3D cur;=0D + for (j =3D cur + 1; j <=3D last; j++)=0D + {=0D + UInt32 price2 =3D p->opt[j].price;=0D + if (price >=3D price2)=0D + {=0D + price =3D price2;=0D + best =3D j;=0D + }=0D + }=0D + {=0D + unsigned delta =3D best - cur;=0D + if (delta !=3D 0)=0D + {=0D + MOVE_POS(p, delta);=0D + }=0D + }=0D + cur =3D best;=0D + break;=0D + }=0D =0D newLen =3D ReadMatchDistances(p, &numPairs);=0D - =0D +=0D if (newLen >=3D p->numFastBytes)=0D {=0D p->numPairs =3D numPairs;=0D p->longestMatchLen =3D newLen;=0D - return Backward(p, cur);=0D + break;=0D }=0D - =0D +=0D curOpt =3D &p->opt[cur];=0D +=0D + position++;=0D +=0D + // we need that check here, if skip_items in p->opt are possible=0D + /*=0D + if (curOpt->price >=3D kInfinityPrice)=0D + continue;=0D + */=0D +=0D prev =3D cur - curOpt->len;=0D - =0D +=0D if (curOpt->len =3D=3D 1)=0D {=0D - state =3D p->opt[prev].state;=0D + state =3D (unsigned)p->opt[prev].state;=0D if (IsShortRep(curOpt))=0D state =3D kShortRepNextStates[state];=0D else=0D @@ -1316,14 +1411,14 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posi= tion) =0D if (curOpt->extra)=0D {=0D - prev -=3D curOpt->extra;=0D + prev -=3D (unsigned)curOpt->extra;=0D state =3D kState_RepAfterLit;=0D if (curOpt->extra =3D=3D 1)=0D - state =3D (dist < LZMA_NUM_REPS) ? kState_RepAfterLit : kState_M= atchAfterLit;=0D + state =3D (dist < LZMA_NUM_REPS ? kState_RepAfterLit : kState_Ma= tchAfterLit);=0D }=0D else=0D {=0D - state =3D p->opt[prev].state;=0D + state =3D (unsigned)p->opt[prev].state;=0D if (dist < LZMA_NUM_REPS)=0D state =3D kRepNextStates[state];=0D else=0D @@ -1368,7 +1463,7 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 positi= on) reps[3] =3D prevOpt->reps[2];=0D }=0D }=0D - =0D +=0D curOpt->state =3D (CState)state;=0D curOpt->reps[0] =3D reps[0];=0D curOpt->reps[1] =3D reps[1];=0D @@ -1379,7 +1474,6 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 positi= on) curByte =3D *data;=0D matchByte =3D *(data - reps[0]);=0D =0D - position++;=0D posState =3D (position & p->pbMask);=0D =0D /*=0D @@ -1391,19 +1485,31 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posi= tion) < MATCH [ : LIT : REP_0 ]=0D */=0D =0D - curPrice =3D curOpt->price;=0D - litPrice =3D curPrice + GET_PRICE_0(p->isMatch[state][posState]);=0D + {=0D + UInt32 curPrice =3D curOpt->price;=0D + unsigned prob =3D p->isMatch[state][posState];=0D + matchPrice =3D curPrice + GET_PRICE_1(prob);=0D + litPrice =3D curPrice + GET_PRICE_0(prob);=0D + }=0D =0D nextOpt =3D &p->opt[(size_t)cur + 1];=0D nextIsLit =3D False;=0D =0D - // if (litPrice >=3D nextOpt->price) litPrice =3D 0; else // 18.new=0D + // here we can allow skip_items in p->opt, if we don't check (nextOpt-= >price < kInfinityPrice)=0D + // 18.new.06=0D + if ((nextOpt->price < kInfinityPrice=0D + // && !IsLitState(state)=0D + && matchByte =3D=3D curByte)=0D + || litPrice > nextOpt->price=0D + )=0D + litPrice =3D 0;=0D + else=0D {=0D const CLzmaProb *probs =3D LIT_PROBS(position, *(data - 1));=0D litPrice +=3D (!IsLitState(state) ?=0D LitEnc_Matched_GetPrice(probs, curByte, matchByte, p->ProbPrices= ) :=0D LitEnc_GetPrice(probs, curByte, p->ProbPrices));=0D - =0D +=0D if (litPrice < nextOpt->price)=0D {=0D nextOpt->price =3D litPrice;=0D @@ -1413,21 +1519,32 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posi= tion) }=0D }=0D =0D - matchPrice =3D curPrice + GET_PRICE_1(p->isMatch[state][posState]);=0D repMatchPrice =3D matchPrice + GET_PRICE_1(p->isRep[state]);=0D - =0D +=0D + numAvailFull =3D p->numAvail;=0D + {=0D + unsigned temp =3D kNumOpts - 1 - cur;=0D + if (numAvailFull > temp)=0D + numAvailFull =3D (UInt32)temp;=0D + }=0D +=0D + // 18.06=0D // ---------- SHORT_REP ----------=0D - // if (IsLitState(state)) // 18.new=0D + if (IsLitState(state)) // 18.new=0D if (matchByte =3D=3D curByte)=0D - // if (repMatchPrice < nextOpt->price) // 18.new=0D - if (nextOpt->len < 2=0D + if (repMatchPrice < nextOpt->price) // 18.new=0D + // if (numAvailFull < 2 || data[1] !=3D *(data - reps[0] + 1))=0D + if (=0D + // nextOpt->price >=3D kInfinityPrice ||=0D + nextOpt->len < 2 // we can check nextOpt->len, if skip items are= not allowed in p->opt=0D || (nextOpt->dist !=3D 0=0D - && nextOpt->extra <=3D 1 // 17.old=0D - ))=0D + // && nextOpt->extra <=3D 1 // 17.old=0D + )=0D + )=0D {=0D UInt32 shortRepPrice =3D repMatchPrice + GetPrice_ShortRep(p, state,= posState);=0D - if (shortRepPrice <=3D nextOpt->price) // 17.old=0D - // if (shortRepPrice < nextOpt->price) // 18.new=0D + // if (shortRepPrice <=3D nextOpt->price) // 17.old=0D + if (shortRepPrice < nextOpt->price) // 18.new=0D {=0D nextOpt->price =3D shortRepPrice;=0D nextOpt->len =3D 1;=0D @@ -1435,13 +1552,6 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posit= ion) nextIsLit =3D False;=0D }=0D }=0D - =0D - numAvailFull =3D p->numAvail;=0D - {=0D - UInt32 temp =3D kNumOpts - 1 - cur;=0D - if (numAvailFull > temp)=0D - numAvailFull =3D temp;=0D - }=0D =0D if (numAvailFull < 2)=0D continue;=0D @@ -1451,9 +1561,8 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 positi= on) =0D // ---------- LIT : REP_0 ----------=0D =0D - if (=0D - // litPrice !=3D 0 && // 18.new=0D - !nextIsLit=0D + if (!nextIsLit=0D + && litPrice !=3D 0 // 18.new=0D && matchByte !=3D curByte=0D && numAvailFull > 2)=0D {=0D @@ -1465,32 +1574,32 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posi= tion) if (limit > numAvailFull)=0D limit =3D numAvailFull;=0D for (len =3D 3; len < limit && data[len] =3D=3D data2[len]; len++)= =0D - {=0D - }=0D - =0D + {}=0D +=0D {=0D unsigned state2 =3D kLiteralNextStates[state];=0D unsigned posState2 =3D (position + 1) & p->pbMask;=0D UInt32 price =3D litPrice + GetPrice_Rep_0(p, state2, posState2)= ;=0D {=0D unsigned offset =3D cur + len;=0D - while (last < offset)=0D - p->opt[++last].price =3D kInfinityPrice;=0D - =0D +=0D + if (last < offset)=0D + last =3D offset;=0D +=0D // do=0D {=0D UInt32 price2;=0D COptimal *opt;=0D len--;=0D // price2 =3D price + GetPrice_Len_Rep_0(p, len, state2, pos= State2);=0D - price2 =3D price + p->repLenEnc.prices[posState2][len - LZMA= _MATCH_LEN_MIN];=0D + price2 =3D price + GET_PRICE_LEN(&p->repLenEnc, posState2, l= en);=0D =0D opt =3D &p->opt[offset];=0D // offset--;=0D if (price2 < opt->price)=0D {=0D opt->price =3D price2;=0D - opt->len =3D len;=0D + opt->len =3D (UInt32)len;=0D opt->dist =3D 0;=0D opt->extra =3D 1;=0D }=0D @@ -1500,8 +1609,9 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 positi= on) }=0D }=0D }=0D - =0D +=0D startLen =3D 2; /* speed optimization */=0D +=0D {=0D // ---------- REP ----------=0D unsigned repIndex =3D 0; // 17.old=0D @@ -1513,31 +1623,35 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posi= tion) const Byte *data2 =3D data - reps[repIndex];=0D if (data[0] !=3D data2[0] || data[1] !=3D data2[1])=0D continue;=0D - =0D - for (len =3D 2; len < numAvail && data[len] =3D=3D data2[len]; len= ++);=0D - =0D +=0D + for (len =3D 2; len < numAvail && data[len] =3D=3D data2[len]; len= ++)=0D + {}=0D +=0D // if (len < startLen) continue; // 18.new: speed optimization=0D =0D - while (last < cur + len)=0D - p->opt[++last].price =3D kInfinityPrice;=0D + {=0D + unsigned offset =3D cur + len;=0D + if (last < offset)=0D + last =3D offset;=0D + }=0D {=0D unsigned len2 =3D len;=0D price =3D repMatchPrice + GetPrice_PureRep(p, repIndex, state, p= osState);=0D do=0D {=0D - UInt32 price2 =3D price + p->repLenEnc.prices[posState][(size_= t)len2 - 2];=0D + UInt32 price2 =3D price + GET_PRICE_LEN(&p->repLenEnc, posStat= e, len2);=0D COptimal *opt =3D &p->opt[cur + len2];=0D if (price2 < opt->price)=0D {=0D opt->price =3D price2;=0D - opt->len =3D len2;=0D - opt->dist =3D repIndex;=0D + opt->len =3D (UInt32)len2;=0D + opt->dist =3D (UInt32)repIndex;=0D opt->extra =3D 0;=0D }=0D }=0D while (--len2 >=3D 2);=0D }=0D - =0D +=0D if (repIndex =3D=3D 0) startLen =3D len + 1; // 17.old=0D // startLen =3D len + 1; // 18.new=0D =0D @@ -1550,51 +1664,59 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posi= tion) unsigned limit =3D len2 + p->numFastBytes;=0D if (limit > numAvailFull)=0D limit =3D numAvailFull;=0D - =0D - for (; len2 < limit && data[len2] =3D=3D data2[len2]; len2++);=0D - =0D - len2 -=3D len;=0D - if (len2 >=3D 3)=0D +=0D + len2 +=3D 2;=0D + if (len2 <=3D limit)=0D + if (data[len2 - 2] =3D=3D data2[len2 - 2])=0D + if (data[len2 - 1] =3D=3D data2[len2 - 1])=0D {=0D unsigned state2 =3D kRepNextStates[state];=0D unsigned posState2 =3D (position + len) & p->pbMask;=0D - price +=3D=0D - p->repLenEnc.prices[posState][(size_t)len - 2]=0D + price +=3D GET_PRICE_LEN(&p->repLenEnc, posState, len)=0D + GET_PRICE_0(p->isMatch[state2][posState2])=0D + LitEnc_Matched_GetPrice(LIT_PROBS(position + len, data[(= size_t)len - 1]),=0D data[len], data2[len], p->ProbPrices);=0D - =0D +=0D // state2 =3D kLiteralNextStates[state2];=0D state2 =3D kState_LitAfterRep;=0D posState2 =3D (posState2 + 1) & p->pbMask;=0D =0D =0D price +=3D GetPrice_Rep_0(p, state2, posState2);=0D +=0D + for (; len2 < limit && data[len2] =3D=3D data2[len2]; len2++)=0D + {}=0D +=0D + len2 -=3D len;=0D + // if (len2 >=3D 3)=0D + {=0D {=0D unsigned offset =3D cur + len + len2;=0D - while (last < offset)=0D - p->opt[++last].price =3D kInfinityPrice;=0D +=0D + if (last < offset)=0D + last =3D offset;=0D // do=0D {=0D - unsigned price2;=0D + UInt32 price2;=0D COptimal *opt;=0D len2--;=0D // price2 =3D price + GetPrice_Len_Rep_0(p, len2, state2, = posState2);=0D - price2 =3D price + p->repLenEnc.prices[posState2][len2 - L= ZMA_MATCH_LEN_MIN];=0D + price2 =3D price + GET_PRICE_LEN(&p->repLenEnc, posState2,= len2);=0D =0D opt =3D &p->opt[offset];=0D // offset--;=0D if (price2 < opt->price)=0D {=0D opt->price =3D price2;=0D - opt->len =3D len2;=0D + opt->len =3D (UInt32)len2;=0D opt->extra =3D (CExtra)(len + 1);=0D - opt->dist =3D repIndex;=0D + opt->dist =3D (UInt32)repIndex;=0D }=0D }=0D // while (len2 >=3D 3);=0D }=0D }=0D + }=0D }=0D }=0D }=0D @@ -1606,49 +1728,57 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posi= tion) {=0D newLen =3D numAvail;=0D for (numPairs =3D 0; newLen > matches[numPairs]; numPairs +=3D 2);=0D - matches[numPairs] =3D newLen;=0D + matches[numPairs] =3D (UInt32)newLen;=0D numPairs +=3D 2;=0D }=0D - =0D +=0D + // startLen =3D 2; /* speed optimization */=0D +=0D if (newLen >=3D startLen)=0D {=0D UInt32 normalMatchPrice =3D matchPrice + GET_PRICE_0(p->isRep[state]= );=0D UInt32 dist;=0D unsigned offs, posSlot, len;=0D - while (last < cur + newLen)=0D - p->opt[++last].price =3D kInfinityPrice;=0D +=0D + {=0D + unsigned offset =3D cur + newLen;=0D + if (last < offset)=0D + last =3D offset;=0D + }=0D =0D offs =3D 0;=0D while (startLen > matches[offs])=0D offs +=3D 2;=0D dist =3D matches[(size_t)offs + 1];=0D - =0D +=0D // if (dist >=3D kNumFullDistances)=0D GetPosSlot2(dist, posSlot);=0D - =0D +=0D for (len =3D /*2*/ startLen; ; len++)=0D {=0D - UInt32 price =3D normalMatchPrice + p->lenEnc.prices[posState][(si= ze_t)len - LZMA_MATCH_LEN_MIN];=0D + UInt32 price =3D normalMatchPrice + GET_PRICE_LEN(&p->lenEnc, posS= tate, len);=0D {=0D COptimal *opt;=0D - unsigned lenToPosState =3D len - 2; lenToPosState =3D GetLenToPo= sState2(lenToPosState);=0D + unsigned lenNorm =3D len - 2;=0D + lenNorm =3D GetLenToPosState2(lenNorm);=0D if (dist < kNumFullDistances)=0D - price +=3D p->distancesPrices[lenToPosState][dist & (kNumFullD= istances - 1)];=0D + price +=3D p->distancesPrices[lenNorm][dist & (kNumFullDistanc= es - 1)];=0D else=0D - price +=3D p->posSlotPrices[lenToPosState][posSlot] + p->align= Prices[dist & kAlignMask];=0D - =0D + price +=3D p->posSlotPrices[lenNorm][posSlot] + p->alignPrices= [dist & kAlignMask];=0D +=0D opt =3D &p->opt[cur + len];=0D if (price < opt->price)=0D {=0D opt->price =3D price;=0D - opt->len =3D len;=0D + opt->len =3D (UInt32)len;=0D opt->dist =3D dist + LZMA_NUM_REPS;=0D opt->extra =3D 0;=0D }=0D }=0D =0D - if (/*_maxMode && */ len =3D=3D matches[offs])=0D + if (len =3D=3D matches[offs])=0D {=0D + // if (p->_maxMode) {=0D // MATCH : LIT : REP_0=0D =0D const Byte *data2 =3D data - dist - 1;=0D @@ -1656,12 +1786,18 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posi= tion) unsigned limit =3D len2 + p->numFastBytes;=0D if (limit > numAvailFull)=0D limit =3D numAvailFull;=0D - =0D - for (; len2 < limit && data[len2] =3D=3D data2[len2]; len2++);=0D - =0D +=0D + len2 +=3D 2;=0D + if (len2 <=3D limit)=0D + if (data[len2 - 2] =3D=3D data2[len2 - 2])=0D + if (data[len2 - 1] =3D=3D data2[len2 - 1])=0D + {=0D + for (; len2 < limit && data[len2] =3D=3D data2[len2]; len2++)=0D + {}=0D +=0D len2 -=3D len;=0D - =0D - if (len2 >=3D 3)=0D +=0D + // if (len2 >=3D 3)=0D {=0D unsigned state2 =3D kMatchNextStates[state];=0D unsigned posState2 =3D (position + len) & p->pbMask;=0D @@ -1677,28 +1813,31 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posi= tion) price +=3D GetPrice_Rep_0(p, state2, posState2);=0D =0D offset =3D cur + len + len2;=0D - while (last < offset)=0D - p->opt[++last].price =3D kInfinityPrice;=0D +=0D + if (last < offset)=0D + last =3D offset;=0D // do=0D {=0D UInt32 price2;=0D COptimal *opt;=0D len2--;=0D // price2 =3D price + GetPrice_Len_Rep_0(p, len2, state2, po= sState2);=0D - price2 =3D price + p->repLenEnc.prices[posState2][len2 - LZM= A_MATCH_LEN_MIN];=0D + price2 =3D price + GET_PRICE_LEN(&p->repLenEnc, posState2, l= en2);=0D opt =3D &p->opt[offset];=0D // offset--;=0D if (price2 < opt->price)=0D {=0D opt->price =3D price2;=0D - opt->len =3D len2;=0D + opt->len =3D (UInt32)len2;=0D opt->extra =3D (CExtra)(len + 1);=0D opt->dist =3D dist + LZMA_NUM_REPS;=0D }=0D }=0D // while (len2 >=3D 3);=0D }=0D - =0D +=0D + }=0D +=0D offs +=3D 2;=0D if (offs =3D=3D numPairs)=0D break;=0D @@ -1709,6 +1848,12 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 posit= ion) }=0D }=0D }=0D +=0D + do=0D + p->opt[last].price =3D kInfinityPrice;=0D + while (--last);=0D +=0D + return Backward(p, cur);=0D }=0D =0D =0D @@ -1735,21 +1880,23 @@ static unsigned GetOptimumFast(CLzmaEnc *p) p->backRes =3D MARK_LIT;=0D if (numAvail < 2)=0D return 1;=0D + // if (mainLen < 2 && p->state =3D=3D 0) return 1; // 18.06.notused=0D if (numAvail > LZMA_MATCH_LEN_MAX)=0D numAvail =3D LZMA_MATCH_LEN_MAX;=0D data =3D p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;=0D repLen =3D repIndex =3D 0;=0D - =0D +=0D for (i =3D 0; i < LZMA_NUM_REPS; i++)=0D {=0D unsigned len;=0D const Byte *data2 =3D data - p->reps[i];=0D if (data[0] !=3D data2[0] || data[1] !=3D data2[1])=0D continue;=0D - for (len =3D 2; len < numAvail && data[len] =3D=3D data2[len]; len++);= =0D + for (len =3D 2; len < numAvail && data[len] =3D=3D data2[len]; len++)= =0D + {}=0D if (len >=3D p->numFastBytes)=0D {=0D - p->backRes =3D i;=0D + p->backRes =3D (UInt32)i;=0D MOVE_POS(p, len - 1)=0D return len;=0D }=0D @@ -1768,7 +1915,7 @@ static unsigned GetOptimumFast(CLzmaEnc *p) }=0D =0D mainDist =3D 0; /* for GCC */=0D - =0D +=0D if (mainLen >=3D 2)=0D {=0D mainDist =3D p->matches[(size_t)numPairs - 1];=0D @@ -1793,18 +1940,18 @@ static unsigned GetOptimumFast(CLzmaEnc *p) || (repLen + 2 >=3D mainLen && mainDist >=3D (1 << 9))=0D || (repLen + 3 >=3D mainLen && mainDist >=3D (1 << 15)))=0D {=0D - p->backRes =3D repIndex;=0D + p->backRes =3D (UInt32)repIndex;=0D MOVE_POS(p, repLen - 1)=0D return repLen;=0D }=0D - =0D +=0D if (mainLen < 2 || numAvail <=3D 2)=0D return 1;=0D =0D {=0D unsigned len1 =3D ReadMatchDistances(p, &p->numPairs);=0D p->longestMatchLen =3D len1;=0D - =0D +=0D if (len1 >=3D 2)=0D {=0D UInt32 newDist =3D p->matches[(size_t)p->numPairs - 1];=0D @@ -1815,9 +1962,9 @@ static unsigned GetOptimumFast(CLzmaEnc *p) return 1;=0D }=0D }=0D - =0D +=0D data =3D p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;=0D - =0D +=0D for (i =3D 0; i < LZMA_NUM_REPS; i++)=0D {=0D unsigned len, limit;=0D @@ -1833,7 +1980,7 @@ static unsigned GetOptimumFast(CLzmaEnc *p) break;=0D }=0D }=0D - =0D +=0D p->backRes =3D mainDist + LZMA_NUM_REPS;=0D if (mainLen !=3D 2)=0D {=0D @@ -1859,7 +2006,7 @@ static void WriteEndMarker(CLzmaEnc *p, unsigned posS= tate) RC_BIT_0(&p->rc, prob)=0D }=0D p->state =3D kMatchNextStates[p->state];=0D - =0D +=0D p->rc.range =3D range;=0D LenEnc_Encode(&p->lenProbs, &p->rc, 0, posState);=0D range =3D p->rc.range;=0D @@ -1888,7 +2035,7 @@ static void WriteEndMarker(CLzmaEnc *p, unsigned posS= tate) }=0D while (--numBits);=0D }=0D - =0D +=0D {=0D // RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAl= ignMask);=0D CLzmaProb *probs =3D p->posAlignEncoder;=0D @@ -1932,23 +2079,22 @@ MY_NO_INLINE static SRes Flush(CLzmaEnc *p, UInt32 = nowPos) }=0D =0D =0D -=0D -static void FillAlignPrices(CLzmaEnc *p)=0D +MY_NO_INLINE static void FillAlignPrices(CLzmaEnc *p)=0D {=0D unsigned i;=0D const CProbPrice *ProbPrices =3D p->ProbPrices;=0D const CLzmaProb *probs =3D p->posAlignEncoder;=0D - p->alignPriceCount =3D 0;=0D + // p->alignPriceCount =3D 0;=0D for (i =3D 0; i < kAlignTableSize / 2; i++)=0D {=0D UInt32 price =3D 0;=0D - unsigned symbol =3D i;=0D + unsigned sym =3D i;=0D unsigned m =3D 1;=0D unsigned bit;=0D UInt32 prob;=0D - bit =3D symbol & 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[m], bi= t); m =3D (m << 1) + bit;=0D - bit =3D symbol & 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[m], bi= t); m =3D (m << 1) + bit;=0D - bit =3D symbol & 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[m], bi= t); m =3D (m << 1) + bit;=0D + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[m], bit); m = =3D (m << 1) + bit;=0D + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[m], bit); m = =3D (m << 1) + bit;=0D + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[m], bit); m = =3D (m << 1) + bit;=0D prob =3D probs[m];=0D p->alignPrices[i ] =3D price + GET_PRICEa_0(prob);=0D p->alignPrices[i + 8] =3D price + GET_PRICEa_1(prob);=0D @@ -1957,78 +2103,97 @@ static void FillAlignPrices(CLzmaEnc *p) }=0D =0D =0D -static void FillDistancesPrices(CLzmaEnc *p)=0D +MY_NO_INLINE static void FillDistancesPrices(CLzmaEnc *p)=0D {=0D + // int y; for (y =3D 0; y < 100; y++) {=0D +=0D UInt32 tempPrices[kNumFullDistances];=0D - unsigned i, lenToPosState;=0D + unsigned i, lps;=0D =0D const CProbPrice *ProbPrices =3D p->ProbPrices;=0D p->matchPriceCount =3D 0;=0D =0D - for (i =3D kStartPosModelIndex; i < kNumFullDistances; i++)=0D + for (i =3D kStartPosModelIndex / 2; i < kNumFullDistances / 2; i++)=0D {=0D unsigned posSlot =3D GetPosSlot1(i);=0D - unsigned footerBits =3D ((posSlot >> 1) - 1);=0D + unsigned footerBits =3D (posSlot >> 1) - 1;=0D unsigned base =3D ((2 | (posSlot & 1)) << footerBits);=0D + const CLzmaProb *probs =3D p->posEncoders + (size_t)base * 2;=0D // tempPrices[i] =3D RcTree_ReverseGetPrice(p->posEncoders + base, foo= terBits, i - base, p->ProbPrices);=0D -=0D - const CLzmaProb *probs =3D p->posEncoders + base;=0D UInt32 price =3D 0;=0D unsigned m =3D 1;=0D - unsigned symbol =3D i - base;=0D + unsigned sym =3D i;=0D + unsigned offset =3D (unsigned)1 << footerBits;=0D + base +=3D i;=0D +=0D + if (footerBits)=0D do=0D {=0D - unsigned bit =3D symbol & 1;=0D - symbol >>=3D 1;=0D + unsigned bit =3D sym & 1;=0D + sym >>=3D 1;=0D price +=3D GET_PRICEa(probs[m], bit);=0D m =3D (m << 1) + bit;=0D }=0D while (--footerBits);=0D - tempPrices[i] =3D price;=0D +=0D + {=0D + unsigned prob =3D probs[m];=0D + tempPrices[base ] =3D price + GET_PRICEa_0(prob);=0D + tempPrices[base + offset] =3D price + GET_PRICEa_1(prob);=0D + }=0D }=0D =0D - for (lenToPosState =3D 0; lenToPosState < kNumLenToPosStates; lenToPosSt= ate++)=0D + for (lps =3D 0; lps < kNumLenToPosStates; lps++)=0D {=0D - unsigned posSlot;=0D - const CLzmaProb *encoder =3D p->posSlotEncoder[lenToPosState];=0D - UInt32 *posSlotPrices =3D p->posSlotPrices[lenToPosState];=0D - unsigned distTableSize =3D p->distTableSize;=0D - const CLzmaProb *probs =3D encoder;=0D - for (posSlot =3D 0; posSlot < distTableSize; posSlot +=3D 2)=0D + unsigned slot;=0D + unsigned distTableSize2 =3D (p->distTableSize + 1) >> 1;=0D + UInt32 *posSlotPrices =3D p->posSlotPrices[lps];=0D + const CLzmaProb *probs =3D p->posSlotEncoder[lps];=0D +=0D + for (slot =3D 0; slot < distTableSize2; slot++)=0D {=0D - // posSlotPrices[posSlot] =3D RcTree_GetPrice(encoder, kNumPosSlotBi= ts, posSlot, p->ProbPrices);=0D - UInt32 price =3D 0;=0D + // posSlotPrices[slot] =3D RcTree_GetPrice(encoder, kNumPosSlotBits,= slot, p->ProbPrices);=0D + UInt32 price;=0D unsigned bit;=0D - unsigned symbol =3D (posSlot >> 1) + (1 << (kNumPosSlotBits - 1));=0D - UInt32 prob;=0D - bit =3D symbol & 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[symb= ol], bit);=0D - bit =3D symbol & 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[symb= ol], bit);=0D - bit =3D symbol & 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[symb= ol], bit);=0D - bit =3D symbol & 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[symb= ol], bit);=0D - bit =3D symbol & 1; symbol >>=3D 1; price +=3D GET_PRICEa(probs[symb= ol], bit);=0D - prob =3D probs[(posSlot >> 1) + (1 << (kNumPosSlotBits - 1))];=0D - posSlotPrices[posSlot ] =3D price + GET_PRICEa_0(prob);=0D - posSlotPrices[posSlot + 1] =3D price + GET_PRICEa_1(prob);=0D + unsigned sym =3D slot + (1 << (kNumPosSlotBits - 1));=0D + unsigned prob;=0D + bit =3D sym & 1; sym >>=3D 1; price =3D GET_PRICEa(probs[sym], bit)= ;=0D + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[sym], bit)= ;=0D + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[sym], bit)= ;=0D + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[sym], bit)= ;=0D + bit =3D sym & 1; sym >>=3D 1; price +=3D GET_PRICEa(probs[sym], bit)= ;=0D + prob =3D probs[(size_t)slot + (1 << (kNumPosSlotBits - 1))];=0D + posSlotPrices[(size_t)slot * 2 ] =3D price + GET_PRICEa_0(prob);= =0D + posSlotPrices[(size_t)slot * 2 + 1] =3D price + GET_PRICEa_1(prob);= =0D }=0D - for (posSlot =3D kEndPosModelIndex; posSlot < distTableSize; posSlot++= )=0D - posSlotPrices[posSlot] +=3D ((UInt32)(((posSlot >> 1) - 1) - kNumAli= gnBits) << kNumBitPriceShiftBits);=0D =0D {=0D - UInt32 *distancesPrices =3D p->distancesPrices[lenToPosState];=0D + UInt32 delta =3D ((UInt32)((kEndPosModelIndex / 2 - 1) - kNumAlignBi= ts) << kNumBitPriceShiftBits);=0D + for (slot =3D kEndPosModelIndex / 2; slot < distTableSize2; slot++)= =0D {=0D - distancesPrices[0] =3D posSlotPrices[0];=0D - distancesPrices[1] =3D posSlotPrices[1];=0D - distancesPrices[2] =3D posSlotPrices[2];=0D - distancesPrices[3] =3D posSlotPrices[3];=0D + posSlotPrices[(size_t)slot * 2 ] +=3D delta;=0D + posSlotPrices[(size_t)slot * 2 + 1] +=3D delta;=0D + delta +=3D ((UInt32)1 << kNumBitPriceShiftBits);=0D }=0D + }=0D +=0D + {=0D + UInt32 *dp =3D p->distancesPrices[lps];=0D +=0D + dp[0] =3D posSlotPrices[0];=0D + dp[1] =3D posSlotPrices[1];=0D + dp[2] =3D posSlotPrices[2];=0D + dp[3] =3D posSlotPrices[3];=0D +=0D for (i =3D 4; i < kNumFullDistances; i +=3D 2)=0D {=0D UInt32 slotPrice =3D posSlotPrices[GetPosSlot1(i)];=0D - distancesPrices[i ] =3D slotPrice + tempPrices[i];=0D - distancesPrices[i + 1] =3D slotPrice + tempPrices[i + 1];=0D + dp[i ] =3D slotPrice + tempPrices[i];=0D + dp[i + 1] =3D slotPrice + tempPrices[i + 1];=0D }=0D }=0D }=0D + // }=0D }=0D =0D =0D @@ -2037,7 +2202,7 @@ void LzmaEnc_Construct(CLzmaEnc *p) {=0D RangeEnc_Construct(&p->rc);=0D MatchFinder_Construct(&p->matchFinderBase);=0D - =0D +=0D #ifndef _7ZIP_ST=0D MatchFinderMt_Construct(&p->matchFinderMt);=0D p->matchFinderMt.MatchFinder =3D &p->matchFinderBase;=0D @@ -2081,7 +2246,7 @@ void LzmaEnc_Destruct(CLzmaEnc *p, ISzAllocPtr alloc,= ISzAllocPtr allocBig) #ifndef _7ZIP_ST=0D MatchFinderMt_Destruct(&p->matchFinderMt, allocBig);=0D #endif=0D - =0D +=0D MatchFinder_Free(&p->matchFinderBase, allocBig);=0D LzmaEnc_FreeLits(p, alloc);=0D RangeEnc_Free(&p->rc, alloc);=0D @@ -2126,14 +2291,14 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt3= 2 maxPackSize, UInt32 maxUnpa }=0D =0D if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) !=3D 0)=0D - =0D +=0D for (;;)=0D {=0D UInt32 dist;=0D unsigned len, posState;=0D UInt32 range, ttt, newBound;=0D CLzmaProb *probs;=0D - =0D +=0D if (p->fastMode)=0D len =3D GetOptimumFast(p);=0D else=0D @@ -2153,9 +2318,9 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 = maxPackSize, UInt32 maxUnpa posState =3D (unsigned)nowPos32 & p->pbMask;=0D range =3D p->rc.range;=0D probs =3D &p->isMatch[p->state][posState];=0D - =0D +=0D RC_BIT_PRE(&p->rc, probs)=0D - =0D +=0D dist =3D p->backRes;=0D =0D #ifdef SHOW_STAT2=0D @@ -2185,7 +2350,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 = maxPackSize, UInt32 maxUnpa RC_BIT_1(&p->rc, probs);=0D probs =3D &p->isRep[p->state];=0D RC_BIT_PRE(&p->rc, probs)=0D - =0D +=0D if (dist < LZMA_NUM_REPS)=0D {=0D RC_BIT_1(&p->rc, probs);=0D @@ -2245,10 +2410,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32= maxPackSize, UInt32 maxUnpa if (len !=3D 1)=0D {=0D LenEnc_Encode(&p->repLenProbs, &p->rc, len - LZMA_MATCH_LEN_MIN,= posState);=0D - if (!p->fastMode)=0D - if (--p->repLenEnc.counters[posState] =3D=3D 0)=0D - LenPriceEnc_UpdateTable(&p->repLenEnc, posState, &p->repLenP= robs, p->ProbPrices);=0D -=0D + --p->repLenEncCounter;=0D p->state =3D kRepNextStates[p->state];=0D }=0D }=0D @@ -2260,34 +2422,32 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt3= 2 maxPackSize, UInt32 maxUnpa p->state =3D kMatchNextStates[p->state];=0D =0D LenEnc_Encode(&p->lenProbs, &p->rc, len - LZMA_MATCH_LEN_MIN, posS= tate);=0D - if (!p->fastMode)=0D - if (--p->lenEnc.counters[posState] =3D=3D 0)=0D - LenPriceEnc_UpdateTable(&p->lenEnc, posState, &p->lenProbs, p-= >ProbPrices);=0D + // --p->lenEnc.counter;=0D =0D dist -=3D LZMA_NUM_REPS;=0D p->reps[3] =3D p->reps[2];=0D p->reps[2] =3D p->reps[1];=0D p->reps[1] =3D p->reps[0];=0D p->reps[0] =3D dist + 1;=0D - =0D +=0D p->matchPriceCount++;=0D GetPosSlot(dist, posSlot);=0D // RcTree_Encode_PosSlot(&p->rc, p->posSlotEncoder[GetLenToPosStat= e(len)], posSlot);=0D {=0D - UInt32 symbol =3D posSlot + (1 << kNumPosSlotBits);=0D + UInt32 sym =3D (UInt32)posSlot + (1 << kNumPosSlotBits);=0D range =3D p->rc.range;=0D probs =3D p->posSlotEncoder[GetLenToPosState(len)];=0D do=0D {=0D - CLzmaProb *prob =3D probs + (symbol >> kNumPosSlotBits);=0D - UInt32 bit =3D (symbol >> (kNumPosSlotBits - 1)) & 1;=0D - symbol <<=3D 1;=0D + CLzmaProb *prob =3D probs + (sym >> kNumPosSlotBits);=0D + UInt32 bit =3D (sym >> (kNumPosSlotBits - 1)) & 1;=0D + sym <<=3D 1;=0D RC_BIT(&p->rc, prob, bit);=0D }=0D - while (symbol < (1 << kNumPosSlotBits * 2));=0D + while (sym < (1 << kNumPosSlotBits * 2));=0D p->rc.range =3D range;=0D }=0D - =0D +=0D if (dist >=3D kStartPosModelIndex)=0D {=0D unsigned footerBits =3D ((posSlot >> 1) - 1);=0D @@ -2295,7 +2455,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 = maxPackSize, UInt32 maxUnpa if (dist < kNumFullDistances)=0D {=0D unsigned base =3D ((2 | (posSlot & 1)) << footerBits);=0D - RcTree_ReverseEncode(&p->rc, p->posEncoders + base, footerBits= , dist - base);=0D + RcTree_ReverseEncode(&p->rc, p->posEncoders + base, footerBits= , (unsigned)(dist /* - base */));=0D }=0D else=0D {=0D @@ -2331,32 +2491,49 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt3= 2 maxPackSize, UInt32 maxUnpa bit =3D dist & 1; dist >>=3D 1; RC_BIT(&p->rc, p->posAlignEn= coder + m, bit); m =3D (m << 1) + bit;=0D bit =3D dist & 1; RC_BIT(&p->rc, p->posAlignEnco= der + m, bit);=0D p->rc.range =3D range;=0D - p->alignPriceCount++;=0D + // p->alignPriceCount++;=0D }=0D }=0D }=0D }=0D }=0D =0D - nowPos32 +=3D len;=0D + nowPos32 +=3D (UInt32)len;=0D p->additionalOffset -=3D len;=0D - =0D +=0D if (p->additionalOffset =3D=3D 0)=0D {=0D UInt32 processed;=0D =0D if (!p->fastMode)=0D {=0D - if (p->matchPriceCount >=3D (1 << 7))=0D + /*=0D + if (p->alignPriceCount >=3D 16) // kAlignTableSize=0D + FillAlignPrices(p);=0D + if (p->matchPriceCount >=3D 128)=0D FillDistancesPrices(p);=0D - if (p->alignPriceCount >=3D kAlignTableSize)=0D + if (p->lenEnc.counter <=3D 0)=0D + LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, &p->lenProbs, p= ->ProbPrices);=0D + */=0D + if (p->matchPriceCount >=3D 64)=0D + {=0D FillAlignPrices(p);=0D + // { int y; for (y =3D 0; y < 100; y++) {=0D + FillDistancesPrices(p);=0D + // }}=0D + LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, &p->lenProbs, p= ->ProbPrices);=0D + }=0D + if (p->repLenEncCounter <=3D 0)=0D + {=0D + p->repLenEncCounter =3D REP_LEN_COUNT;=0D + LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, &p->repLenPr= obs, p->ProbPrices);=0D + }=0D }=0D - =0D +=0D if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) =3D=3D 0)= =0D break;=0D processed =3D nowPos32 - startPos32;=0D - =0D +=0D if (maxPackSize)=0D {=0D if (processed + kNumOpts + 300 >=3D maxUnpackSize=0D @@ -2430,7 +2607,7 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWin= dowSize, ISzAllocPtr alloc, p->matchFinderObj =3D &p->matchFinderBase;=0D MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder);=0D }=0D - =0D +=0D return SZ_OK;=0D }=0D =0D @@ -2490,12 +2667,19 @@ void LzmaEnc_Init(CLzmaEnc *p) =0D p->optEnd =3D 0;=0D p->optCur =3D 0;=0D +=0D + {=0D + for (i =3D 0; i < kNumOpts; i++)=0D + p->opt[i].price =3D kInfinityPrice;=0D + }=0D +=0D p->additionalOffset =3D 0;=0D =0D p->pbMask =3D (1 << p->pb) - 1;=0D p->lpMask =3D ((UInt32)0x100 << p->lp) - ((unsigned)0x100 >> p->lc);=0D }=0D =0D +=0D void LzmaEnc_InitPrices(CLzmaEnc *p)=0D {=0D if (!p->fastMode)=0D @@ -2507,6 +2691,9 @@ void LzmaEnc_InitPrices(CLzmaEnc *p) p->lenEnc.tableSize =3D=0D p->repLenEnc.tableSize =3D=0D p->numFastBytes + 1 - LZMA_MATCH_LEN_MIN;=0D +=0D + p->repLenEncCounter =3D REP_LEN_COUNT;=0D +=0D LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, &p->lenProbs, p->ProbPr= ices);=0D LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, &p->repLenProbs, p->= ProbPrices);=0D }=0D @@ -2583,7 +2770,7 @@ typedef struct ISeqOutStream vt;=0D Byte *data;=0D SizeT rem;=0D - Bool overflow;=0D + BoolInt overflow;=0D } CLzmaEnc_SeqOutStreamBuf;=0D =0D static size_t SeqOutStreamBuf_Write(const ISeqOutStream *pp, const void *d= ata, size_t size)=0D @@ -2615,7 +2802,7 @@ const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp) }=0D =0D =0D -SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,=0D +SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit,=0D Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSiz= e)=0D {=0D CLzmaEnc *p =3D (CLzmaEnc *)pp;=0D @@ -2644,7 +2831,7 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool = reInit, return SZ_ERROR_OUTPUT_EOF;=0D =0D res =3D LzmaEnc_CodeOneBlock(p, desiredPackSize, *unpackSize);=0D - =0D +=0D *unpackSize =3D (UInt32)(p->nowPos64 - nowPos64);=0D *destLen -=3D outStream.rem;=0D if (outStream.overflow)=0D @@ -2679,7 +2866,7 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressPro= gress *progress) }=0D }=0D }=0D - =0D +=0D LzmaEnc_Finish(p);=0D =0D /*=0D @@ -2751,7 +2938,7 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest,= SizeT *destLen, const Byte p->rc.outStream =3D &outStream.vt;=0D =0D res =3D LzmaEnc_MemPrepare(pp, src, srcLen, 0, alloc, allocBig);=0D - =0D +=0D if (res =3D=3D SZ_OK)=0D {=0D res =3D LzmaEnc_Encode2(p, progress);=0D diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt b/Bas= eTools/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt index d7426d38a4..0f9560c7a6 100644 --- a/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt +++ b/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-history.txt @@ -1,13 +1,35 @@ HISTORY of the LZMA SDK=0D -----------------------=0D =0D +19.00 2019-02-21=0D +-------------------------=0D +- Encryption strength for 7z archives was increased:=0D + the size of random initialization vector was increased from 64-bit to 12= 8-bit,=0D + and the pseudo-random number generator was improved.=0D +- The bug in 7zIn.c code was fixed.=0D +=0D +=0D +18.06 2018-12-30=0D +-------------------------=0D +- The speed for LZMA/LZMA2 compressing was increased by 3-10%,=0D + and there are minor changes in compression ratio.=0D +- Some bugs were fixed.=0D +- The bug in 7-Zip 18.02-18.05 was fixed:=0D + There was memory leak in multithreading xz decoder - XzDecMt_Decode(),=0D + if xz stream contains only one block.=0D +- The changes for MSVS compiler makefiles:=0D + - the makefiles now use "PLATFORM" macroname with values (x64, x86, arm= 64)=0D + instead of "CPU" macroname with values (AMD64, ARM64).=0D + - the makefiles by default now use static version of the run-time libra= ry.=0D +=0D +=0D 18.05 2018-04-30=0D -------------------------=0D -- The speed for LZMA/LZMA2 compressing was increased =0D - by 8% for fastest/fast compression levels and =0D +- The speed for LZMA/LZMA2 compressing was increased=0D + by 8% for fastest/fast compression levels and=0D by 3% for normal/maximum compression levels.=0D - Previous versions of 7-Zip could work incorrectly in "Large memory pages= " mode in=0D - Windows 10 because of some BUG with "Large Pages" in Windows 10. =0D + Windows 10 because of some BUG with "Large Pages" in Windows 10.=0D Now 7-Zip doesn't use "Large Pages" on Windows 10 up to revision 1709 (1= 6299).=0D - The BUG was fixed in Lzma2Enc.c=0D Lzma2Enc_Encode2() function worked incorretly,=0D @@ -16,7 +38,7 @@ HISTORY of the LZMA SDK =0D 18.03 beta 2018-03-04=0D -------------------------=0D -- Asm\x86\LzmaDecOpt.asm: new optimized LZMA decoder written in asm =0D +- Asm\x86\LzmaDecOpt.asm: new optimized LZMA decoder written in asm=0D for x64 with about 30% higher speed than main version of LZMA decoder wr= itten in C.=0D - The speed for single-thread LZMA/LZMA2 decoder written in C was increase= d by 3%.=0D - 7-Zip now can use multi-threading for 7z/LZMA2 decoding,=0D @@ -35,7 +57,7 @@ HISTORY of the LZMA SDK 18.00 beta 2019-01-10=0D -------------------------=0D - The BUG in xz encoder was fixed:=0D - There was memory leak of 16 KB for each file compressed with =0D + There was memory leak of 16 KB for each file compressed with=0D xz compression method, if additional filter was used.=0D =0D =0D @@ -44,7 +66,7 @@ HISTORY of the LZMA SDK - Minor speed optimization for LZMA2 (xz and 7z) multi-threading compressi= on.=0D 7-Zip now uses additional memory buffers for multi-block LZMA2 compressi= on.=0D CPU utilization was slightly improved.=0D -- 7-zip now creates multi-block xz archives by default. Block size can be = =0D +- 7-zip now creates multi-block xz archives by default. Block size can be= =0D specified with -ms[Size]{m|g} switch.=0D - xz decoder now can unpack random block from multi-block xz archives.=0D - 7-Zip command line: @listfile now doesn't work after -- switch.=0D @@ -55,7 +77,7 @@ HISTORY of the LZMA SDK =0D 17.00 beta 2017-04-29=0D -------------------------=0D -- NewHandler.h / NewHandler.cpp: =0D +- NewHandler.h / NewHandler.cpp:=0D now it redefines operator new() only for old MSVC compilers (_MSC_VER = < 1900).=0D - C/7zTypes.h : the names of variables in interface structures were change= d (vt).=0D - Some bugs were fixed. 7-Zip could crash in some cases.=0D @@ -76,51 +98,51 @@ HISTORY of the LZMA SDK 16.02 2016-05-21=0D -------------------------=0D - The BUG in 16.00 - 16.01 was fixed:=0D - Split Handler (SplitHandler.cpp) returned incorrect =0D + Split Handler (SplitHandler.cpp) returned incorrect=0D total size value (kpidSize) for split archives.=0D =0D =0D 16.01 2016-05-19=0D -------------------------- =0D +-------------------------=0D - Some internal changes to reduce the number of compiler warnings.=0D =0D =0D 16.00 2016-05-10=0D -------------------------- =0D +-------------------------=0D - Some bugs were fixed.=0D =0D =0D 15.12 2015-11-19=0D -------------------------- =0D +-------------------------=0D - The BUG in C version of 7z decoder was fixed:=0D 7zDec.c : SzDecodeLzma2()=0D 7z decoder could mistakenly report about decoding error for some 7z arch= ives=0D that use LZMA2 compression method.=0D - The probability to get that mistaken decoding error report was about =0D - one error per 16384 solid blocks for solid blocks larger than 16 KB (com= pressed size). =0D + The probability to get that mistaken decoding error report was about=0D + one error per 16384 solid blocks for solid blocks larger than 16 KB (com= pressed size).=0D - The BUG (in 9.26-15.11) in C version of 7z decoder was fixed:=0D 7zArcIn.c : SzReadHeader2()=0D - 7z decoder worked incorrectly for 7z archives that contain =0D - empty solid blocks, that can be placed to 7z archive, if some file is =0D + 7z decoder worked incorrectly for 7z archives that contain=0D + empty solid blocks, that can be placed to 7z archive, if some file is=0D unavailable for reading during archive creation.=0D =0D =0D 15.09 beta 2015-10-16=0D -------------------------- =0D +-------------------------=0D - The BUG in LZMA / LZMA2 encoding code was fixed.=0D The BUG in LzFind.c::MatchFinder_ReadBlock() function.=0D If input data size is larger than (4 GiB - dictionary_size),=0D the following code worked incorrectly:=0D - - LZMA : LzmaEnc_MemEncode(), LzmaEncode() : LZMA encoding functions =0D - for compressing from memory to memory. =0D + - LZMA : LzmaEnc_MemEncode(), LzmaEncode() : LZMA encoding functions=0D + for compressing from memory to memory.=0D That BUG is not related to LZMA encoder version that works via stream= s.=0D - - LZMA2 : multi-threaded version of LZMA2 encoder worked incorrectly, i= f =0D - default value of chunk size (CLzma2EncProps::blockSize) is changed =0D + - LZMA2 : multi-threaded version of LZMA2 encoder worked incorrectly, i= f=0D + default value of chunk size (CLzma2EncProps::blockSize) is changed=0D to value larger than (4 GiB - dictionary_size).=0D =0D =0D 9.38 beta 2015-01-03=0D -------------------------- =0D +-------------------------=0D - The BUG in 9.31-9.37 was fixed:=0D IArchiveGetRawProps interface was disabled for 7z archives.=0D - The BUG in 9.26-9.36 was fixed:=0D @@ -128,10 +150,10 @@ HISTORY of the LZMA SDK =0D =0D 9.36 beta 2014-12-26=0D -------------------------- =0D +-------------------------=0D - The BUG in command line version was fixed:=0D 7-Zip created temporary archive in current folder during update archive= =0D - operation, if -w{Path} switch was not specified. =0D + operation, if -w{Path} switch was not specified.=0D The fixed 7-Zip creates temporary archive in folder that contains update= d archive.=0D - The BUG in 9.33-9.35 was fixed:=0D 7-Zip silently ignored file reading errors during 7z or gz archive creat= ion,=0D @@ -140,14 +162,14 @@ HISTORY of the LZMA SDK =0D =0D 9.35 beta 2014-12-07=0D -------------------------- =0D +-------------------------=0D - 7zr.exe now support AES encryption.=0D - SFX modules were added to LZMA SDK=0D - Some bugs were fixed.=0D =0D =0D 9.21 beta 2011-04-11=0D -------------------------- =0D +-------------------------=0D - New class FString for file names at file systems.=0D - Speed optimization in CRC code for big-endian CPUs.=0D - The BUG in Lzma2Dec.c was fixed:=0D @@ -155,7 +177,7 @@ HISTORY of the LZMA SDK =0D =0D 9.18 beta 2010-11-02=0D -------------------------- =0D +-------------------------=0D - New small SFX module for installers (SfxSetup).=0D =0D =0D @@ -168,7 +190,7 @@ HISTORY of the LZMA SDK 9.11 beta 2010-03-15=0D -------------------------=0D - PPMd compression method support=0D - =0D +=0D =0D 9.09 2009-12-12=0D -------------------------=0D @@ -202,7 +224,7 @@ HISTORY of the LZMA SDK 4.61 beta 2008-11-23=0D -------------------------=0D - The bug in ANSI-C LZMA Decoder was fixed:=0D - If encoded stream was corrupted, decoder could access memory =0D + If encoded stream was corrupted, decoder could access memory=0D outside of allocated range.=0D - Some changes in ANSI-C 7z Decoder interfaces.=0D - LZMA SDK is placed in the public domain.=0D @@ -216,7 +238,7 @@ HISTORY of the LZMA SDK 4.59 beta 2008-08-13=0D -------------------------=0D - The bug was fixed:=0D - LZMA Encoder in fast compression mode could access memory outside of = =0D + LZMA Encoder in fast compression mode could access memory outside of=0D allocated range in some rare cases.=0D =0D =0D @@ -229,7 +251,7 @@ HISTORY of the LZMA SDK =0D 4.57 2007-12-12=0D -------------------------=0D -- Speed optimizations in ?++ LZMA Decoder. =0D +- Speed optimizations in ?++ LZMA Decoder.=0D - Small changes for more compatibility with some C/C++ compilers.=0D =0D =0D @@ -239,36 +261,36 @@ HISTORY of the LZMA SDK - now it supports BCJ and BCJ2 filters=0D - now it supports files larger than 4 GB.=0D - now it supports "Last Write Time" field for files.=0D -- C++ code for .7z archives compressing/decompressing from 7-zip =0D +- C++ code for .7z archives compressing/decompressing from 7-zip=0D was included to LZMA SDK.=0D - =0D +=0D =0D 4.43 2006-06-04=0D -------------------------=0D - Small changes for more compatibility with some C/C++ compilers.=0D - =0D +=0D =0D 4.42 2006-05-15=0D -------------------------=0D - Small changes in .h files in ANSI-C version.=0D - =0D +=0D =0D 4.39 beta 2006-04-14=0D -------------------------=0D - The bug in versions 4.33b:4.38b was fixed:=0D - C++ version of LZMA encoder could not correctly compress =0D + C++ version of LZMA encoder could not correctly compress=0D files larger than 2 GB with HC4 match finder (-mfhc4).=0D - =0D +=0D =0D 4.37 beta 2005-04-06=0D -------------------------=0D -- Fixes in C++ code: code could no be compiled if _NO_EXCEPTIONS was defin= ed. =0D +- Fixes in C++ code: code could no be compiled if _NO_EXCEPTIONS was defin= ed.=0D =0D =0D 4.35 beta 2005-03-02=0D -------------------------=0D - The bug was fixed in C++ version of LZMA Decoder:=0D - If encoded stream was corrupted, decoder could access memory =0D + If encoded stream was corrupted, decoder could access memory=0D outside of allocated range.=0D =0D =0D @@ -339,7 +361,7 @@ HISTORY of the LZMA SDK =0D 4.17 2005-04-18=0D -------------------------=0D -- New example for RAM->RAM compressing/decompressing: =0D +- New example for RAM->RAM compressing/decompressing:=0D LZMA + BCJ (filter for x86 code):=0D - LzmaRam.h=0D - LzmaRam.cpp=0D @@ -350,11 +372,11 @@ HISTORY of the LZMA SDK =0D 4.16 2005-03-29=0D -------------------------=0D -- The bug was fixed in LzmaDecode.c (ANSI-C LZMA Decoder): =0D +- The bug was fixed in LzmaDecode.c (ANSI-C LZMA Decoder):=0D If _LZMA_OUT_READ was defined, and if encoded stream was corrupted,=0D decoder could access memory outside of allocated range.=0D - Speed optimization of ANSI-C LZMA Decoder (now it's about 20% faster).=0D - Old version of LZMA Decoder now is in file LzmaDecodeSize.c. =0D + Old version of LZMA Decoder now is in file LzmaDecodeSize.c.=0D LzmaDecodeSize.c can provide slightly smaller code than LzmaDecode.c=0D - Small speed optimization in LZMA C++ code=0D - filter for SPARC's code was added=0D @@ -369,7 +391,7 @@ HISTORY of the LZMA SDK =0D 4.05 2004-08-25=0D -------------------------=0D -- Source code of filters for x86, IA-64, ARM, ARM-Thumb =0D +- Source code of filters for x86, IA-64, ARM, ARM-Thumb=0D and PowerPC code was included to SDK=0D - Some internal minor changes=0D =0D @@ -381,8 +403,8 @@ HISTORY of the LZMA SDK =0D 4.03 2004-06-18=0D -------------------------=0D -- "Benchmark" command was added. It measures compressing =0D - and decompressing speed and shows rating values. =0D +- "Benchmark" command was added. It measures compressing=0D + and decompressing speed and shows rating values.=0D Also it checks hardware errors.=0D =0D =0D @@ -411,7 +433,7 @@ HISTORY of the LZMA SDK =0D HISTORY of the LZMA=0D -------------------=0D - 2001-2008: Improvements to LZMA compressing/decompressing code, =0D + 2001-2008: Improvements to LZMA compressing/decompressing code,=0D keeping compatibility with original LZMA format=0D 1996-2001: Development of LZMA compression format=0D =0D @@ -419,6 +441,6 @@ HISTORY of the LZMA =0D 2001-08-30: LZMA compression was added to 7-Zip=0D 1999-01-02: First version of 7-Zip was released=0D - =0D +=0D =0D End of document=0D diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/DOC/lzma-sdk.txt b/BaseToo= ls/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=0D +LZMA SDK 19.00=0D --------------=0D =0D LZMA SDK provides the documentation, samples, header files,=0D --=20 2.29.2.windows.3