BaseTools LzmaCompress: Update LZMA to new 19.00 version
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3101 New formal release in https://www.7-zip.org/sdk.html is 19.00. Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Wei Liu <weix.c.liu@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
committed by
mergify[bot]
parent
1d3d5e3256
commit
4e38bb607a
@ -1,3 +1,3 @@
|
|||||||
LzmaCompress is based on the LZMA SDK 18.05. LZMA SDK 18.05
|
LzmaCompress is based on the LZMA SDK 19.00. LZMA SDK 19.00
|
||||||
was placed in the public domain on 2018-04-30. It was
|
was placed in the public domain on 2019-02-21. It was
|
||||||
released on the http://www.7-zip.org/sdk.html website.
|
released on the http://www.7-zip.org/sdk.html website.
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/** @file
|
/** @file
|
||||||
LZMA Compress/Decompress tool (LzmaCompress)
|
LZMA Compress/Decompress tool (LzmaCompress)
|
||||||
|
|
||||||
Based on LZMA SDK 18.05:
|
Based on LZMA SDK 19.00:
|
||||||
LzmaUtil.c -- Test application for LZMA compression
|
LzmaUtil.c -- Test application for LZMA compression
|
||||||
2018-04-30 : Igor Pavlov : Public domain
|
2019-02-21 : Igor Pavlov : Public domain
|
||||||
|
|
||||||
Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
@ -39,7 +39,7 @@ const char *kCantAllocateMessage = "Can not allocate memory";
|
|||||||
const char *kDataErrorMessage = "Data error";
|
const char *kDataErrorMessage = "Data error";
|
||||||
const char *kInvalidParamValMessage = "Invalid parameter value";
|
const char *kInvalidParamValMessage = "Invalid parameter value";
|
||||||
|
|
||||||
static Bool mQuietMode = False;
|
static BoolInt mQuietMode = False;
|
||||||
static CONVERTER_TYPE mConType = NoConverter;
|
static CONVERTER_TYPE mConType = NoConverter;
|
||||||
|
|
||||||
UINT64 mDictionarySize = 28;
|
UINT64 mDictionarySize = 28;
|
||||||
@ -244,7 +244,7 @@ int main2(int numArgs, const char *args[], char *rs)
|
|||||||
CFileOutStream outStream;
|
CFileOutStream outStream;
|
||||||
int res;
|
int res;
|
||||||
int encodeMode = 0;
|
int encodeMode = 0;
|
||||||
Bool modeWasSet = False;
|
BoolInt modeWasSet = False;
|
||||||
const char *inputFile = NULL;
|
const char *inputFile = NULL;
|
||||||
const char *outputFile = "file.tmp";
|
const char *outputFile = "file.tmp";
|
||||||
int param;
|
int param;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* 7zTypes.h -- Basic types
|
/* 7zTypes.h -- Basic types
|
||||||
2017-07-17 : Igor Pavlov : Public domain */
|
2018-08-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __7Z_TYPES_H
|
#ifndef __7Z_TYPES_H
|
||||||
#define __7Z_TYPES_H
|
#define __7Z_TYPES_H
|
||||||
@ -103,7 +103,8 @@ typedef UInt32 SizeT;
|
|||||||
typedef size_t SizeT;
|
typedef size_t SizeT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int Bool;
|
typedef int BoolInt;
|
||||||
|
/* typedef BoolInt Bool; */
|
||||||
#define True 1
|
#define True 1
|
||||||
#define False 0
|
#define False 0
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#define MY_VER_MAJOR 18
|
#define MY_VER_MAJOR 19
|
||||||
#define MY_VER_MINOR 05
|
#define MY_VER_MINOR 00
|
||||||
#define MY_VER_BUILD 0
|
#define MY_VER_BUILD 0
|
||||||
#define MY_VERSION_NUMBERS "18.05"
|
#define MY_VERSION_NUMBERS "19.00"
|
||||||
#define MY_VERSION MY_VERSION_NUMBERS
|
#define MY_VERSION MY_VERSION_NUMBERS
|
||||||
|
|
||||||
#ifdef MY_CPU_NAME
|
#ifdef MY_CPU_NAME
|
||||||
@ -10,7 +10,7 @@
|
|||||||
#define MY_VERSION_CPU MY_VERSION
|
#define MY_VERSION_CPU MY_VERSION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MY_DATE "2018-04-30"
|
#define MY_DATE "2019-02-21"
|
||||||
#undef MY_COPYRIGHT
|
#undef MY_COPYRIGHT
|
||||||
#undef MY_VERSION_COPYRIGHT_DATE
|
#undef MY_VERSION_COPYRIGHT_DATE
|
||||||
#define MY_AUTHOR_NAME "Igor Pavlov"
|
#define MY_AUTHOR_NAME "Igor Pavlov"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* CpuArch.h -- CPU specific code
|
/* CpuArch.h -- CPU specific code
|
||||||
2017-09-04 : Igor Pavlov : Public domain */
|
2018-02-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __CPU_ARCH_H
|
#ifndef __CPU_ARCH_H
|
||||||
#define __CPU_ARCH_H
|
#define __CPU_ARCH_H
|
||||||
@ -318,15 +318,16 @@ enum
|
|||||||
|
|
||||||
void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d);
|
void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d);
|
||||||
|
|
||||||
Bool x86cpuid_CheckAndRead(Cx86cpuid *p);
|
BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p);
|
||||||
int x86cpuid_GetFirm(const Cx86cpuid *p);
|
int x86cpuid_GetFirm(const Cx86cpuid *p);
|
||||||
|
|
||||||
#define x86cpuid_GetFamily(ver) (((ver >> 16) & 0xFF0) | ((ver >> 8) & 0xF))
|
#define x86cpuid_GetFamily(ver) (((ver >> 16) & 0xFF0) | ((ver >> 8) & 0xF))
|
||||||
#define x86cpuid_GetModel(ver) (((ver >> 12) & 0xF0) | ((ver >> 4) & 0xF))
|
#define x86cpuid_GetModel(ver) (((ver >> 12) & 0xF0) | ((ver >> 4) & 0xF))
|
||||||
#define x86cpuid_GetStepping(ver) (ver & 0xF)
|
#define x86cpuid_GetStepping(ver) (ver & 0xF)
|
||||||
|
|
||||||
Bool CPU_Is_InOrder();
|
BoolInt CPU_Is_InOrder();
|
||||||
Bool CPU_Is_Aes_Supported();
|
BoolInt CPU_Is_Aes_Supported();
|
||||||
|
BoolInt CPU_IsSupported_PageGB();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* LzFind.c -- Match finder for LZ algorithms
|
/* LzFind.c -- Match finder for LZ algorithms
|
||||||
2017-06-10 : Igor Pavlov : Public domain */
|
2018-07-08 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ static void MatchFinder_SetDefaultSettings(CMatchFinder *p)
|
|||||||
|
|
||||||
void MatchFinder_Construct(CMatchFinder *p)
|
void MatchFinder_Construct(CMatchFinder *p)
|
||||||
{
|
{
|
||||||
UInt32 i;
|
unsigned i;
|
||||||
p->bufferBase = NULL;
|
p->bufferBase = NULL;
|
||||||
p->directInput = 0;
|
p->directInput = 0;
|
||||||
p->hash = NULL;
|
p->hash = NULL;
|
||||||
@ -147,7 +147,7 @@ void MatchFinder_Construct(CMatchFinder *p)
|
|||||||
|
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
UInt32 r = i;
|
UInt32 r = (UInt32)i;
|
||||||
unsigned j;
|
unsigned j;
|
||||||
for (j = 0; j < 8; j++)
|
for (j = 0; j < 8; j++)
|
||||||
r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1)));
|
r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1)));
|
||||||
@ -368,6 +368,8 @@ static void MatchFinder_Normalize(CMatchFinder *p)
|
|||||||
MatchFinder_ReduceOffsets(p, subValue);
|
MatchFinder_ReduceOffsets(p, subValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MY_NO_INLINE
|
||||||
static void MatchFinder_CheckLimits(CMatchFinder *p)
|
static void MatchFinder_CheckLimits(CMatchFinder *p)
|
||||||
{
|
{
|
||||||
if (p->pos == kMaxValForNormalize)
|
if (p->pos == kMaxValForNormalize)
|
||||||
@ -379,10 +381,16 @@ static void MatchFinder_CheckLimits(CMatchFinder *p)
|
|||||||
MatchFinder_SetLimits(p);
|
MatchFinder_SetLimits(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
|
|
||||||
|
/*
|
||||||
|
(lenLimit > maxLen)
|
||||||
|
*/
|
||||||
|
MY_FORCE_INLINE
|
||||||
|
static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
|
||||||
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
|
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
|
||||||
UInt32 *distances, UInt32 maxLen)
|
UInt32 *distances, unsigned maxLen)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
son[_cyclicBufferPos] = curMatch;
|
son[_cyclicBufferPos] = curMatch;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@ -400,7 +408,8 @@ static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos,
|
|||||||
break;
|
break;
|
||||||
if (maxLen < len)
|
if (maxLen < len)
|
||||||
{
|
{
|
||||||
*distances++ = maxLen = len;
|
maxLen = len;
|
||||||
|
*distances++ = len;
|
||||||
*distances++ = delta - 1;
|
*distances++ = delta - 1;
|
||||||
if (len == lenLimit)
|
if (len == lenLimit)
|
||||||
return distances;
|
return distances;
|
||||||
@ -408,15 +417,58 @@ static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
const Byte *lim = cur + lenLimit;
|
||||||
|
son[_cyclicBufferPos] = curMatch;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
UInt32 delta = pos - curMatch;
|
||||||
|
if (delta >= _cyclicBufferSize)
|
||||||
|
break;
|
||||||
|
{
|
||||||
|
ptrdiff_t diff;
|
||||||
|
curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];
|
||||||
|
diff = (ptrdiff_t)0 - delta;
|
||||||
|
if (cur[maxLen] == cur[maxLen + diff])
|
||||||
|
{
|
||||||
|
const Byte *c = cur;
|
||||||
|
while (*c == c[diff])
|
||||||
|
{
|
||||||
|
if (++c == lim)
|
||||||
|
{
|
||||||
|
distances[0] = (UInt32)(lim - cur);
|
||||||
|
distances[1] = delta - 1;
|
||||||
|
return distances + 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
unsigned len = (unsigned)(c - cur);
|
||||||
|
if (maxLen < len)
|
||||||
|
{
|
||||||
|
maxLen = len;
|
||||||
|
distances[0] = (UInt32)len;
|
||||||
|
distances[1] = delta - 1;
|
||||||
|
distances += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (--cutValue);
|
||||||
|
|
||||||
|
return distances;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MY_FORCE_INLINE
|
||||||
UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
|
UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
|
||||||
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
|
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
|
||||||
UInt32 *distances, UInt32 maxLen)
|
UInt32 *distances, UInt32 maxLen)
|
||||||
{
|
{
|
||||||
CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
|
CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1;
|
||||||
CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
|
CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1);
|
||||||
UInt32 len0 = 0, len1 = 0;
|
unsigned len0 = 0, len1 = 0;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
UInt32 delta = pos - curMatch;
|
UInt32 delta = pos - curMatch;
|
||||||
@ -426,9 +478,10 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt
|
|||||||
return distances;
|
return distances;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
|
CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
|
||||||
const Byte *pb = cur - delta;
|
const Byte *pb = cur - delta;
|
||||||
UInt32 len = (len0 < len1 ? len0 : len1);
|
unsigned len = (len0 < len1 ? len0 : len1);
|
||||||
|
UInt32 pair0 = pair[0];
|
||||||
if (pb[len] == cur[len])
|
if (pb[len] == cur[len])
|
||||||
{
|
{
|
||||||
if (++len != lenLimit && pb[len] == cur[len])
|
if (++len != lenLimit && pb[len] == cur[len])
|
||||||
@ -437,11 +490,12 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt
|
|||||||
break;
|
break;
|
||||||
if (maxLen < len)
|
if (maxLen < len)
|
||||||
{
|
{
|
||||||
*distances++ = maxLen = len;
|
maxLen = (UInt32)len;
|
||||||
|
*distances++ = (UInt32)len;
|
||||||
*distances++ = delta - 1;
|
*distances++ = delta - 1;
|
||||||
if (len == lenLimit)
|
if (len == lenLimit)
|
||||||
{
|
{
|
||||||
*ptr1 = pair[0];
|
*ptr1 = pair0;
|
||||||
*ptr0 = pair[1];
|
*ptr0 = pair[1];
|
||||||
return distances;
|
return distances;
|
||||||
}
|
}
|
||||||
@ -468,9 +522,9 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt
|
|||||||
static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
|
static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
|
||||||
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)
|
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)
|
||||||
{
|
{
|
||||||
CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
|
CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1;
|
||||||
CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
|
CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1);
|
||||||
UInt32 len0 = 0, len1 = 0;
|
unsigned len0 = 0, len1 = 0;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
UInt32 delta = pos - curMatch;
|
UInt32 delta = pos - curMatch;
|
||||||
@ -480,9 +534,9 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
|
CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
|
||||||
const Byte *pb = cur - delta;
|
const Byte *pb = cur - delta;
|
||||||
UInt32 len = (len0 < len1 ? len0 : len1);
|
unsigned len = (len0 < len1 ? len0 : len1);
|
||||||
if (pb[len] == cur[len])
|
if (pb[len] == cur[len])
|
||||||
{
|
{
|
||||||
while (++len != lenLimit)
|
while (++len != lenLimit)
|
||||||
@ -520,13 +574,13 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const
|
|||||||
p->buffer++; \
|
p->buffer++; \
|
||||||
if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
|
if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
|
||||||
|
|
||||||
#define MOVE_POS_RET MOVE_POS return offset;
|
#define MOVE_POS_RET MOVE_POS return (UInt32)offset;
|
||||||
|
|
||||||
static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
|
static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
|
||||||
|
|
||||||
#define GET_MATCHES_HEADER2(minLen, ret_op) \
|
#define GET_MATCHES_HEADER2(minLen, ret_op) \
|
||||||
UInt32 lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \
|
unsigned lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \
|
||||||
lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
|
lenLimit = (unsigned)p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
|
||||||
cur = p->buffer;
|
cur = p->buffer;
|
||||||
|
|
||||||
#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0)
|
#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0)
|
||||||
@ -535,22 +589,22 @@ static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
|
|||||||
#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue
|
#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue
|
||||||
|
|
||||||
#define GET_MATCHES_FOOTER(offset, maxLen) \
|
#define GET_MATCHES_FOOTER(offset, maxLen) \
|
||||||
offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \
|
offset = (unsigned)(GetMatchesSpec1((UInt32)lenLimit, curMatch, MF_PARAMS(p), \
|
||||||
distances + offset, maxLen) - distances); MOVE_POS_RET;
|
distances + offset, (UInt32)maxLen) - distances); MOVE_POS_RET;
|
||||||
|
|
||||||
#define SKIP_FOOTER \
|
#define SKIP_FOOTER \
|
||||||
SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
|
SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
|
||||||
|
|
||||||
#define UPDATE_maxLen { \
|
#define UPDATE_maxLen { \
|
||||||
ptrdiff_t diff = (ptrdiff_t)0 - d2; \
|
ptrdiff_t diff = (ptrdiff_t)0 - d2; \
|
||||||
const Byte *c = cur + maxLen; \
|
const Byte *c = cur + maxLen; \
|
||||||
const Byte *lim = cur + lenLimit; \
|
const Byte *lim = cur + lenLimit; \
|
||||||
for (; c != lim; c++) if (*(c + diff) != *c) break; \
|
for (; c != lim; c++) if (*(c + diff) != *c) break; \
|
||||||
maxLen = (UInt32)(c - cur); }
|
maxLen = (unsigned)(c - cur); }
|
||||||
|
|
||||||
static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||||
{
|
{
|
||||||
UInt32 offset;
|
unsigned offset;
|
||||||
GET_MATCHES_HEADER(2)
|
GET_MATCHES_HEADER(2)
|
||||||
HASH2_CALC;
|
HASH2_CALC;
|
||||||
curMatch = p->hash[hv];
|
curMatch = p->hash[hv];
|
||||||
@ -561,7 +615,7 @@ static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
|
|
||||||
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||||
{
|
{
|
||||||
UInt32 offset;
|
unsigned offset;
|
||||||
GET_MATCHES_HEADER(3)
|
GET_MATCHES_HEADER(3)
|
||||||
HASH_ZIP_CALC;
|
HASH_ZIP_CALC;
|
||||||
curMatch = p->hash[hv];
|
curMatch = p->hash[hv];
|
||||||
@ -572,7 +626,8 @@ UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
|
|
||||||
static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||||
{
|
{
|
||||||
UInt32 h2, d2, maxLen, offset, pos;
|
UInt32 h2, d2, pos;
|
||||||
|
unsigned maxLen, offset;
|
||||||
UInt32 *hash;
|
UInt32 *hash;
|
||||||
GET_MATCHES_HEADER(3)
|
GET_MATCHES_HEADER(3)
|
||||||
|
|
||||||
@ -594,12 +649,12 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
|
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
|
||||||
{
|
{
|
||||||
UPDATE_maxLen
|
UPDATE_maxLen
|
||||||
distances[0] = maxLen;
|
distances[0] = (UInt32)maxLen;
|
||||||
distances[1] = d2 - 1;
|
distances[1] = d2 - 1;
|
||||||
offset = 2;
|
offset = 2;
|
||||||
if (maxLen == lenLimit)
|
if (maxLen == lenLimit)
|
||||||
{
|
{
|
||||||
SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
|
SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p));
|
||||||
MOVE_POS_RET;
|
MOVE_POS_RET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -609,7 +664,8 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
|
|
||||||
static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||||
{
|
{
|
||||||
UInt32 h2, h3, d2, d3, maxLen, offset, pos;
|
UInt32 h2, h3, d2, d3, pos;
|
||||||
|
unsigned maxLen, offset;
|
||||||
UInt32 *hash;
|
UInt32 *hash;
|
||||||
GET_MATCHES_HEADER(4)
|
GET_MATCHES_HEADER(4)
|
||||||
|
|
||||||
@ -618,12 +674,12 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
hash = p->hash;
|
hash = p->hash;
|
||||||
pos = p->pos;
|
pos = p->pos;
|
||||||
|
|
||||||
d2 = pos - hash[ h2];
|
d2 = pos - hash [h2];
|
||||||
d3 = pos - (hash + kFix3HashSize)[h3];
|
d3 = pos - (hash + kFix3HashSize)[h3];
|
||||||
|
|
||||||
curMatch = (hash + kFix4HashSize)[hv];
|
curMatch = (hash + kFix4HashSize)[hv];
|
||||||
|
|
||||||
hash[ h2] = pos;
|
hash [h2] = pos;
|
||||||
(hash + kFix3HashSize)[h3] = pos;
|
(hash + kFix3HashSize)[h3] = pos;
|
||||||
(hash + kFix4HashSize)[hv] = pos;
|
(hash + kFix4HashSize)[hv] = pos;
|
||||||
|
|
||||||
@ -632,7 +688,8 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
|
|
||||||
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
|
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
|
||||||
{
|
{
|
||||||
distances[0] = maxLen = 2;
|
maxLen = 2;
|
||||||
|
distances[0] = 2;
|
||||||
distances[1] = d2 - 1;
|
distances[1] = d2 - 1;
|
||||||
offset = 2;
|
offset = 2;
|
||||||
}
|
}
|
||||||
@ -648,10 +705,10 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
if (offset != 0)
|
if (offset != 0)
|
||||||
{
|
{
|
||||||
UPDATE_maxLen
|
UPDATE_maxLen
|
||||||
distances[(size_t)offset - 2] = maxLen;
|
distances[(size_t)offset - 2] = (UInt32)maxLen;
|
||||||
if (maxLen == lenLimit)
|
if (maxLen == lenLimit)
|
||||||
{
|
{
|
||||||
SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
|
SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p));
|
||||||
MOVE_POS_RET;
|
MOVE_POS_RET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -674,13 +731,13 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
hash = p->hash;
|
hash = p->hash;
|
||||||
pos = p->pos;
|
pos = p->pos;
|
||||||
|
|
||||||
d2 = pos - hash[ h2];
|
d2 = pos - hash [h2];
|
||||||
d3 = pos - (hash + kFix3HashSize)[h3];
|
d3 = pos - (hash + kFix3HashSize)[h3];
|
||||||
d4 = pos - (hash + kFix4HashSize)[h4];
|
d4 = pos - (hash + kFix4HashSize)[h4];
|
||||||
|
|
||||||
curMatch = (hash + kFix5HashSize)[hv];
|
curMatch = (hash + kFix5HashSize)[hv];
|
||||||
|
|
||||||
hash[ h2] = pos;
|
hash [h2] = pos;
|
||||||
(hash + kFix3HashSize)[h3] = pos;
|
(hash + kFix3HashSize)[h3] = pos;
|
||||||
(hash + kFix4HashSize)[h4] = pos;
|
(hash + kFix4HashSize)[h4] = pos;
|
||||||
(hash + kFix5HashSize)[hv] = pos;
|
(hash + kFix5HashSize)[hv] = pos;
|
||||||
@ -741,7 +798,8 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
|
|
||||||
static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||||
{
|
{
|
||||||
UInt32 h2, h3, d2, d3, maxLen, offset, pos;
|
UInt32 h2, h3, d2, d3, pos;
|
||||||
|
unsigned maxLen, offset;
|
||||||
UInt32 *hash;
|
UInt32 *hash;
|
||||||
GET_MATCHES_HEADER(4)
|
GET_MATCHES_HEADER(4)
|
||||||
|
|
||||||
@ -750,12 +808,11 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
hash = p->hash;
|
hash = p->hash;
|
||||||
pos = p->pos;
|
pos = p->pos;
|
||||||
|
|
||||||
d2 = pos - hash[ h2];
|
d2 = pos - hash [h2];
|
||||||
d3 = pos - (hash + kFix3HashSize)[h3];
|
d3 = pos - (hash + kFix3HashSize)[h3];
|
||||||
|
|
||||||
curMatch = (hash + kFix4HashSize)[hv];
|
curMatch = (hash + kFix4HashSize)[hv];
|
||||||
|
|
||||||
hash[ h2] = pos;
|
hash [h2] = pos;
|
||||||
(hash + kFix3HashSize)[h3] = pos;
|
(hash + kFix3HashSize)[h3] = pos;
|
||||||
(hash + kFix4HashSize)[hv] = pos;
|
(hash + kFix4HashSize)[hv] = pos;
|
||||||
|
|
||||||
@ -764,7 +821,8 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
|
|
||||||
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
|
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
|
||||||
{
|
{
|
||||||
distances[0] = maxLen = 2;
|
maxLen = 2;
|
||||||
|
distances[0] = 2;
|
||||||
distances[1] = d2 - 1;
|
distances[1] = d2 - 1;
|
||||||
offset = 2;
|
offset = 2;
|
||||||
}
|
}
|
||||||
@ -780,7 +838,7 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
if (offset != 0)
|
if (offset != 0)
|
||||||
{
|
{
|
||||||
UPDATE_maxLen
|
UPDATE_maxLen
|
||||||
distances[(size_t)offset - 2] = maxLen;
|
distances[(size_t)offset - 2] = (UInt32)maxLen;
|
||||||
if (maxLen == lenLimit)
|
if (maxLen == lenLimit)
|
||||||
{
|
{
|
||||||
p->son[p->cyclicBufferPos] = curMatch;
|
p->son[p->cyclicBufferPos] = curMatch;
|
||||||
@ -791,7 +849,7 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
if (maxLen < 3)
|
if (maxLen < 3)
|
||||||
maxLen = 3;
|
maxLen = 3;
|
||||||
|
|
||||||
offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
|
offset = (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
|
||||||
distances + offset, maxLen) - (distances));
|
distances + offset, maxLen) - (distances));
|
||||||
MOVE_POS_RET
|
MOVE_POS_RET
|
||||||
}
|
}
|
||||||
@ -808,13 +866,13 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
hash = p->hash;
|
hash = p->hash;
|
||||||
pos = p->pos;
|
pos = p->pos;
|
||||||
|
|
||||||
d2 = pos - hash[ h2];
|
d2 = pos - hash [h2];
|
||||||
d3 = pos - (hash + kFix3HashSize)[h3];
|
d3 = pos - (hash + kFix3HashSize)[h3];
|
||||||
d4 = pos - (hash + kFix4HashSize)[h4];
|
d4 = pos - (hash + kFix4HashSize)[h4];
|
||||||
|
|
||||||
curMatch = (hash + kFix5HashSize)[hv];
|
curMatch = (hash + kFix5HashSize)[hv];
|
||||||
|
|
||||||
hash[ h2] = pos;
|
hash [h2] = pos;
|
||||||
(hash + kFix3HashSize)[h3] = pos;
|
(hash + kFix3HashSize)[h3] = pos;
|
||||||
(hash + kFix4HashSize)[h4] = pos;
|
(hash + kFix4HashSize)[h4] = pos;
|
||||||
(hash + kFix5HashSize)[hv] = pos;
|
(hash + kFix5HashSize)[hv] = pos;
|
||||||
@ -877,12 +935,12 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
|
|
||||||
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||||
{
|
{
|
||||||
UInt32 offset;
|
unsigned offset;
|
||||||
GET_MATCHES_HEADER(3)
|
GET_MATCHES_HEADER(3)
|
||||||
HASH_ZIP_CALC;
|
HASH_ZIP_CALC;
|
||||||
curMatch = p->hash[hv];
|
curMatch = p->hash[hv];
|
||||||
p->hash[hv] = p->pos;
|
p->hash[hv] = p->pos;
|
||||||
offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
|
offset = (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
|
||||||
distances, 2) - (distances));
|
distances, 2) - (distances));
|
||||||
MOVE_POS_RET
|
MOVE_POS_RET
|
||||||
}
|
}
|
||||||
@ -940,7 +998,7 @@ static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
|
|||||||
HASH4_CALC;
|
HASH4_CALC;
|
||||||
hash = p->hash;
|
hash = p->hash;
|
||||||
curMatch = (hash + kFix4HashSize)[hv];
|
curMatch = (hash + kFix4HashSize)[hv];
|
||||||
hash[ h2] =
|
hash [h2] =
|
||||||
(hash + kFix3HashSize)[h3] =
|
(hash + kFix3HashSize)[h3] =
|
||||||
(hash + kFix4HashSize)[hv] = p->pos;
|
(hash + kFix4HashSize)[hv] = p->pos;
|
||||||
SKIP_FOOTER
|
SKIP_FOOTER
|
||||||
@ -959,7 +1017,7 @@ static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
|
|||||||
HASH5_CALC;
|
HASH5_CALC;
|
||||||
hash = p->hash;
|
hash = p->hash;
|
||||||
curMatch = (hash + kFix5HashSize)[hv];
|
curMatch = (hash + kFix5HashSize)[hv];
|
||||||
hash[ h2] =
|
hash [h2] =
|
||||||
(hash + kFix3HashSize)[h3] =
|
(hash + kFix3HashSize)[h3] =
|
||||||
(hash + kFix4HashSize)[h4] =
|
(hash + kFix4HashSize)[h4] =
|
||||||
(hash + kFix5HashSize)[hv] = p->pos;
|
(hash + kFix5HashSize)[hv] = p->pos;
|
||||||
@ -979,7 +1037,7 @@ static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
|
|||||||
HASH4_CALC;
|
HASH4_CALC;
|
||||||
hash = p->hash;
|
hash = p->hash;
|
||||||
curMatch = (hash + kFix4HashSize)[hv];
|
curMatch = (hash + kFix4HashSize)[hv];
|
||||||
hash[ h2] =
|
hash [h2] =
|
||||||
(hash + kFix3HashSize)[h3] =
|
(hash + kFix3HashSize)[h3] =
|
||||||
(hash + kFix4HashSize)[hv] = p->pos;
|
(hash + kFix4HashSize)[hv] = p->pos;
|
||||||
p->son[p->cyclicBufferPos] = curMatch;
|
p->son[p->cyclicBufferPos] = curMatch;
|
||||||
@ -999,7 +1057,7 @@ static void Hc5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
|
|||||||
HASH5_CALC;
|
HASH5_CALC;
|
||||||
hash = p->hash;
|
hash = p->hash;
|
||||||
curMatch = hash + kFix5HashSize)[hv];
|
curMatch = hash + kFix5HashSize)[hv];
|
||||||
hash[ h2] =
|
hash [h2] =
|
||||||
(hash + kFix3HashSize)[h3] =
|
(hash + kFix3HashSize)[h3] =
|
||||||
(hash + kFix4HashSize)[h4] =
|
(hash + kFix4HashSize)[h4] =
|
||||||
(hash + kFix5HashSize)[hv] = p->pos;
|
(hash + kFix5HashSize)[hv] = p->pos;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* LzFindMt.c -- multithreaded Match finder for LZ algorithms
|
/* LzFindMt.c -- multithreaded Match finder for LZ algorithms
|
||||||
2017-06-10 : Igor Pavlov : Public domain */
|
2018-12-29 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@ -232,38 +232,57 @@ static void MatchFinderMt_GetNextBlock_Hash(CMatchFinderMt *p)
|
|||||||
|
|
||||||
#define kEmptyHashValue 0
|
#define kEmptyHashValue 0
|
||||||
|
|
||||||
/* #define MFMT_GM_INLINE */
|
#define MFMT_GM_INLINE
|
||||||
|
|
||||||
#ifdef MFMT_GM_INLINE
|
#ifdef MFMT_GM_INLINE
|
||||||
|
|
||||||
#define NO_INLINE MY_FAST_CALL
|
/*
|
||||||
|
we use size_t for _cyclicBufferPos instead of UInt32
|
||||||
|
to eliminate "movsx" BUG in old MSVC x64 compiler.
|
||||||
|
*/
|
||||||
|
|
||||||
static Int32 NO_INLINE GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *cur, CLzRef *son,
|
MY_NO_INLINE
|
||||||
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
|
static UInt32 *GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *cur, CLzRef *son,
|
||||||
UInt32 *_distances, UInt32 _maxLen, const UInt32 *hash, Int32 limit, UInt32 size, UInt32 *posRes)
|
size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
|
||||||
|
UInt32 *distances, UInt32 _maxLen, const UInt32 *hash, const UInt32 *limit, UInt32 size, UInt32 *posRes)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
UInt32 *distances = _distances + 1;
|
UInt32 *_distances = ++distances;
|
||||||
UInt32 curMatch = pos - *hash++;
|
UInt32 delta = *hash++;
|
||||||
|
|
||||||
CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
|
CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1;
|
||||||
CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
|
CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1);
|
||||||
UInt32 len0 = 0, len1 = 0;
|
unsigned len0 = 0, len1 = 0;
|
||||||
UInt32 cutValue = _cutValue;
|
UInt32 cutValue = _cutValue;
|
||||||
UInt32 maxLen = _maxLen;
|
unsigned maxLen = (unsigned)_maxLen;
|
||||||
for (;;)
|
|
||||||
|
/*
|
||||||
|
if (size > 1)
|
||||||
{
|
{
|
||||||
UInt32 delta = pos - curMatch;
|
UInt32 delta = *hash;
|
||||||
if (cutValue-- == 0 || delta >= _cyclicBufferSize)
|
if (delta < _cyclicBufferSize)
|
||||||
|
{
|
||||||
|
UInt32 cyc1 = _cyclicBufferPos + 1;
|
||||||
|
CLzRef *pair = son + ((size_t)(cyc1 - delta + ((delta > cyc1) ? _cyclicBufferSize : 0)) << 1);
|
||||||
|
Byte b = *(cur + 1 - delta);
|
||||||
|
_distances[0] = pair[0];
|
||||||
|
_distances[1] = b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (cutValue == 0 || delta >= _cyclicBufferSize)
|
||||||
{
|
{
|
||||||
*ptr0 = *ptr1 = kEmptyHashValue;
|
*ptr0 = *ptr1 = kEmptyHashValue;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
for(;;)
|
||||||
{
|
{
|
||||||
CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
|
{
|
||||||
|
CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((_cyclicBufferPos < delta) ? _cyclicBufferSize : 0)) << 1);
|
||||||
const Byte *pb = cur - delta;
|
const Byte *pb = cur - delta;
|
||||||
UInt32 len = (len0 < len1 ? len0 : len1);
|
unsigned len = (len0 < len1 ? len0 : len1);
|
||||||
|
UInt32 pair0 = *pair;
|
||||||
if (pb[len] == cur[len])
|
if (pb[len] == cur[len])
|
||||||
{
|
{
|
||||||
if (++len != lenLimit && pb[len] == cur[len])
|
if (++len != lenLimit && pb[len] == cur[len])
|
||||||
@ -272,54 +291,66 @@ static Int32 NO_INLINE GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *
|
|||||||
break;
|
break;
|
||||||
if (maxLen < len)
|
if (maxLen < len)
|
||||||
{
|
{
|
||||||
*distances++ = maxLen = len;
|
maxLen = len;
|
||||||
|
*distances++ = (UInt32)len;
|
||||||
*distances++ = delta - 1;
|
*distances++ = delta - 1;
|
||||||
if (len == lenLimit)
|
if (len == lenLimit)
|
||||||
{
|
{
|
||||||
*ptr1 = pair[0];
|
UInt32 pair1 = pair[1];
|
||||||
*ptr0 = pair[1];
|
*ptr1 = pair0;
|
||||||
|
*ptr0 = pair1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
UInt32 curMatch = pos - delta;
|
||||||
|
// delta = pos - *pair;
|
||||||
|
// delta = pos - pair[((UInt32)pb[len] - (UInt32)cur[len]) >> 31];
|
||||||
if (pb[len] < cur[len])
|
if (pb[len] < cur[len])
|
||||||
{
|
{
|
||||||
|
delta = pos - pair[1];
|
||||||
*ptr1 = curMatch;
|
*ptr1 = curMatch;
|
||||||
ptr1 = pair + 1;
|
ptr1 = pair + 1;
|
||||||
curMatch = *ptr1;
|
|
||||||
len1 = len;
|
len1 = len;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
delta = pos - *pair;
|
||||||
*ptr0 = curMatch;
|
*ptr0 = curMatch;
|
||||||
ptr0 = pair;
|
ptr0 = pair;
|
||||||
curMatch = *ptr0;
|
|
||||||
len0 = len;
|
len0 = len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (--cutValue == 0 || delta >= _cyclicBufferSize)
|
||||||
|
{
|
||||||
|
*ptr0 = *ptr1 = kEmptyHashValue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
pos++;
|
pos++;
|
||||||
_cyclicBufferPos++;
|
_cyclicBufferPos++;
|
||||||
cur++;
|
cur++;
|
||||||
{
|
{
|
||||||
UInt32 num = (UInt32)(distances - _distances);
|
UInt32 num = (UInt32)(distances - _distances);
|
||||||
*_distances = num - 1;
|
_distances[-1] = num;
|
||||||
_distances += num;
|
|
||||||
limit -= num;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (limit > 0 && --size != 0);
|
while (distances < limit && --size != 0);
|
||||||
*posRes = pos;
|
*posRes = pos;
|
||||||
return limit;
|
return distances;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void BtGetMatches(CMatchFinderMt *p, UInt32 *distances)
|
static void BtGetMatches(CMatchFinderMt *p, UInt32 *distances)
|
||||||
{
|
{
|
||||||
UInt32 numProcessed = 0;
|
UInt32 numProcessed = 0;
|
||||||
UInt32 curPos = 2;
|
UInt32 curPos = 2;
|
||||||
UInt32 limit = kMtBtBlockSize - (p->matchMaxLen * 2);
|
UInt32 limit = kMtBtBlockSize - (p->matchMaxLen * 2); // * 2
|
||||||
|
|
||||||
distances[1] = p->hashNumAvail;
|
distances[1] = p->hashNumAvail;
|
||||||
|
|
||||||
@ -369,8 +400,10 @@ static void BtGetMatches(CMatchFinderMt *p, UInt32 *distances)
|
|||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
UInt32 posRes;
|
UInt32 posRes;
|
||||||
curPos = limit - GetMatchesSpecN(lenLimit, pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue,
|
curPos = (UInt32)(GetMatchesSpecN(lenLimit, pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue,
|
||||||
distances + curPos, p->numHashBytes - 1, p->hashBuf + p->hashBufPos, (Int32)(limit - curPos), size, &posRes);
|
distances + curPos, p->numHashBytes - 1, p->hashBuf + p->hashBufPos,
|
||||||
|
distances + limit,
|
||||||
|
size, &posRes) - distances);
|
||||||
p->hashBufPos += posRes - pos;
|
p->hashBufPos += posRes - pos;
|
||||||
cyclicBufferPos += posRes - pos;
|
cyclicBufferPos += posRes - pos;
|
||||||
p->buffer += posRes - pos;
|
p->buffer += posRes - pos;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* LzFindMt.h -- multithreaded Match finder for LZ algorithms
|
/* LzFindMt.h -- multithreaded Match finder for LZ algorithms
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-07-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZ_FIND_MT_H
|
#ifndef __LZ_FIND_MT_H
|
||||||
#define __LZ_FIND_MT_H
|
#define __LZ_FIND_MT_H
|
||||||
@ -19,10 +19,10 @@ EXTERN_C_BEGIN
|
|||||||
|
|
||||||
typedef struct _CMtSync
|
typedef struct _CMtSync
|
||||||
{
|
{
|
||||||
Bool wasCreated;
|
BoolInt wasCreated;
|
||||||
Bool needStart;
|
BoolInt needStart;
|
||||||
Bool exit;
|
BoolInt exit;
|
||||||
Bool stopWriting;
|
BoolInt stopWriting;
|
||||||
|
|
||||||
CThread thread;
|
CThread thread;
|
||||||
CAutoResetEvent canStart;
|
CAutoResetEvent canStart;
|
||||||
@ -30,8 +30,8 @@ typedef struct _CMtSync
|
|||||||
CAutoResetEvent wasStopped;
|
CAutoResetEvent wasStopped;
|
||||||
CSemaphore freeSemaphore;
|
CSemaphore freeSemaphore;
|
||||||
CSemaphore filledSemaphore;
|
CSemaphore filledSemaphore;
|
||||||
Bool csWasInitialized;
|
BoolInt csWasInitialized;
|
||||||
Bool csWasEntered;
|
BoolInt csWasEntered;
|
||||||
CCriticalSection cs;
|
CCriticalSection cs;
|
||||||
UInt32 numProcessedBlocks;
|
UInt32 numProcessedBlocks;
|
||||||
} CMtSync;
|
} CMtSync;
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
/* LzmaDec.c -- LZMA Decoder
|
/* LzmaDec.c -- LZMA Decoder
|
||||||
2018-02-28 : Igor Pavlov : Public domain */
|
2018-07-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/* #include "CpuArch.h" */
|
/* #include "CpuArch.h" */
|
||||||
#include "LzmaDec.h"
|
#include "LzmaDec.h"
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define kNumTopBits 24
|
#define kNumTopBits 24
|
||||||
#define kTopValue ((UInt32)1 << kNumTopBits)
|
#define kTopValue ((UInt32)1 << kNumTopBits)
|
||||||
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }
|
#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }
|
||||||
|
|
||||||
#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
|
#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound)
|
||||||
#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));
|
#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));
|
||||||
#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));
|
#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));
|
||||||
#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \
|
#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \
|
||||||
@ -66,7 +66,7 @@
|
|||||||
|
|
||||||
#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }
|
#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }
|
||||||
|
|
||||||
#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
|
#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound)
|
||||||
#define UPDATE_0_CHECK range = bound;
|
#define UPDATE_0_CHECK range = bound;
|
||||||
#define UPDATE_1_CHECK range -= bound; code -= bound;
|
#define UPDATE_1_CHECK range -= bound; code -= bound;
|
||||||
#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \
|
#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \
|
||||||
@ -539,7 +539,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit
|
|||||||
curLen = ((rem < len) ? (unsigned)rem : len);
|
curLen = ((rem < len) ? (unsigned)rem : len);
|
||||||
pos = dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0);
|
pos = dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0);
|
||||||
|
|
||||||
processedPos += curLen;
|
processedPos += (UInt32)curLen;
|
||||||
|
|
||||||
len -= curLen;
|
len -= curLen;
|
||||||
if (curLen <= dicBufSize - pos)
|
if (curLen <= dicBufSize - pos)
|
||||||
@ -547,7 +547,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit
|
|||||||
Byte *dest = dic + dicPos;
|
Byte *dest = dic + dicPos;
|
||||||
ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;
|
ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;
|
||||||
const Byte *lim = dest + curLen;
|
const Byte *lim = dest + curLen;
|
||||||
dicPos += curLen;
|
dicPos += (SizeT)curLen;
|
||||||
do
|
do
|
||||||
*(dest) = (Byte)*(dest + src);
|
*(dest) = (Byte)*(dest + src);
|
||||||
while (++dest != lim);
|
while (++dest != lim);
|
||||||
@ -572,14 +572,14 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit
|
|||||||
p->buf = buf;
|
p->buf = buf;
|
||||||
p->range = range;
|
p->range = range;
|
||||||
p->code = code;
|
p->code = code;
|
||||||
p->remainLen = len;
|
p->remainLen = (UInt32)len;
|
||||||
p->dicPos = dicPos;
|
p->dicPos = dicPos;
|
||||||
p->processedPos = processedPos;
|
p->processedPos = processedPos;
|
||||||
p->reps[0] = rep0;
|
p->reps[0] = rep0;
|
||||||
p->reps[1] = rep1;
|
p->reps[1] = rep1;
|
||||||
p->reps[2] = rep2;
|
p->reps[2] = rep2;
|
||||||
p->reps[3] = rep3;
|
p->reps[3] = rep3;
|
||||||
p->state = state;
|
p->state = (UInt32)state;
|
||||||
|
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
@ -601,8 +601,8 @@ static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
|
|||||||
if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len)
|
if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len)
|
||||||
p->checkDicSize = p->prop.dicSize;
|
p->checkDicSize = p->prop.dicSize;
|
||||||
|
|
||||||
p->processedPos += len;
|
p->processedPos += (UInt32)len;
|
||||||
p->remainLen -= len;
|
p->remainLen -= (UInt32)len;
|
||||||
while (len != 0)
|
while (len != 0)
|
||||||
{
|
{
|
||||||
len--;
|
len--;
|
||||||
@ -850,7 +850,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
|
void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState)
|
||||||
{
|
{
|
||||||
p->remainLen = kMatchSpecLenStart + 1;
|
p->remainLen = kMatchSpecLenStart + 1;
|
||||||
p->tempBufSize = 0;
|
p->tempBufSize = 0;
|
||||||
@ -979,10 +979,10 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
|
|||||||
p->tempBufSize = rem;
|
p->tempBufSize = rem;
|
||||||
if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
|
if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
|
||||||
{
|
{
|
||||||
int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem);
|
int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, (SizeT)rem);
|
||||||
if (dummyRes == DUMMY_ERROR)
|
if (dummyRes == DUMMY_ERROR)
|
||||||
{
|
{
|
||||||
(*srcLen) += lookAhead;
|
(*srcLen) += (SizeT)lookAhead;
|
||||||
*status = LZMA_STATUS_NEEDS_MORE_INPUT;
|
*status = LZMA_STATUS_NEEDS_MORE_INPUT;
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
@ -1005,9 +1005,9 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
|
|||||||
return SZ_ERROR_FAIL; /* some internal error */
|
return SZ_ERROR_FAIL; /* some internal error */
|
||||||
lookAhead -= rem;
|
lookAhead -= rem;
|
||||||
}
|
}
|
||||||
(*srcLen) += lookAhead;
|
(*srcLen) += (SizeT)lookAhead;
|
||||||
src += lookAhead;
|
src += lookAhead;
|
||||||
inSize -= lookAhead;
|
inSize -= (SizeT)lookAhead;
|
||||||
p->tempBufSize = 0;
|
p->tempBufSize = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,28 @@
|
|||||||
HISTORY of the LZMA SDK
|
HISTORY of the LZMA SDK
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
19.00 2019-02-21
|
||||||
|
-------------------------
|
||||||
|
- Encryption strength for 7z archives was increased:
|
||||||
|
the size of random initialization vector was increased from 64-bit to 128-bit,
|
||||||
|
and the pseudo-random number generator was improved.
|
||||||
|
- The bug in 7zIn.c code was fixed.
|
||||||
|
|
||||||
|
|
||||||
|
18.06 2018-12-30
|
||||||
|
-------------------------
|
||||||
|
- The speed for LZMA/LZMA2 compressing was increased by 3-10%,
|
||||||
|
and there are minor changes in compression ratio.
|
||||||
|
- Some bugs were fixed.
|
||||||
|
- The bug in 7-Zip 18.02-18.05 was fixed:
|
||||||
|
There was memory leak in multithreading xz decoder - XzDecMt_Decode(),
|
||||||
|
if xz stream contains only one block.
|
||||||
|
- The changes for MSVS compiler makefiles:
|
||||||
|
- the makefiles now use "PLATFORM" macroname with values (x64, x86, arm64)
|
||||||
|
instead of "CPU" macroname with values (AMD64, ARM64).
|
||||||
|
- the makefiles by default now use static version of the run-time library.
|
||||||
|
|
||||||
|
|
||||||
18.05 2018-04-30
|
18.05 2018-04-30
|
||||||
-------------------------
|
-------------------------
|
||||||
- The speed for LZMA/LZMA2 compressing was increased
|
- The speed for LZMA/LZMA2 compressing was increased
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
LZMA SDK 18.05
|
LZMA SDK 19.00
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
LZMA SDK provides the documentation, samples, header files,
|
LZMA SDK provides the documentation, samples, header files,
|
||||||
|
Reference in New Issue
Block a user