Skip to content

Commit

Permalink
16.01
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Pavlov authored and kornelski committed May 27, 2016
1 parent 66ac98b commit bec3b47
Show file tree
Hide file tree
Showing 88 changed files with 967 additions and 748 deletions.
25 changes: 15 additions & 10 deletions C/7zArcIn.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* 7zArcIn.c -- 7z Input functions
2016-03-31 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand Down Expand Up @@ -1100,13 +1100,11 @@ static SRes SzReadHeader2(
ISzAlloc *allocTemp
)
{
UInt64 type;
UInt32 numFiles = 0;
UInt32 numEmptyStreams = 0;
CSubStreamInfo ssi;
const Byte *emptyStreams = NULL;
const Byte *emptyFiles = NULL;

{
UInt64 type;

SzData_Clear(&ssi.sdSizes);
SzData_Clear(&ssi.sdCRCs);
SzData_Clear(&ssi.sdNumSubStreams);
Expand All @@ -1120,9 +1118,9 @@ static SRes SzReadHeader2(
{
for (;;)
{
UInt64 type;
RINOK(ReadID(sd, &type));
if (type == k7zIdEnd)
UInt64 type2;
RINOK(ReadID(sd, &type2));
if (type2 == k7zIdEnd)
break;
RINOK(SkipData(sd));
}
Expand Down Expand Up @@ -1160,6 +1158,13 @@ static SRes SzReadHeader2(

if (type != k7zIdFilesInfo)
return SZ_ERROR_ARCHIVE;
}

{
UInt32 numFiles = 0;
UInt32 numEmptyStreams = 0;
const Byte *emptyStreams = NULL;
const Byte *emptyFiles = NULL;

RINOK(SzReadNumber32(sd, &numFiles));
p->NumFiles = numFiles;
Expand Down Expand Up @@ -1458,7 +1463,7 @@ static SRes SzReadHeader2(
if (ssi.sdNumSubStreams.Data && ssi.sdNumSubStreams.Size != 0)
return SZ_ERROR_ARCHIVE;
}
}
return SZ_OK;
}

Expand Down
8 changes: 4 additions & 4 deletions C/7zVersion.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#define MY_VER_MAJOR 16
#define MY_VER_MINOR 00
#define MY_VER_MINOR 01
#define MY_VER_BUILD 0
#define MY_VERSION_NUMBERS "16.00"
#define MY_VERSION "16.00"
#define MY_DATE "2016-05-10"
#define MY_VERSION_NUMBERS "16.01"
#define MY_VERSION "16.01"
#define MY_DATE "2016-05-19"
#undef MY_COPYRIGHT
#undef MY_VERSION_COPYRIGHT_DATE
#define MY_AUTHOR_NAME "Igor Pavlov"
Expand Down
12 changes: 6 additions & 6 deletions C/HuffEnc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* HuffEnc.c -- functions for Huffman encoding
2009-09-02 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand Down Expand Up @@ -121,8 +121,8 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
i = 0;
for (len = maxLen; len != 0; len--)
{
UInt32 num;
for (num = lenCounters[len]; num != 0; num--)
UInt32 k;
for (k = lenCounters[len]; k != 0; k--)
lens[p[i++] & MASK] = (Byte)len;
}
}
Expand All @@ -138,9 +138,9 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb
/* if (code + lenCounters[kMaxLen] - 1 != (1 << kMaxLen) - 1) throw 1; */

{
UInt32 i;
for (i = 0; i < numSymbols; i++)
p[i] = nextCodes[lens[i]]++;
UInt32 k;
for (k = 0; k < numSymbols; k++)
p[k] = nextCodes[lens[k]]++;
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions C/Lzma86Dec.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder
2015-11-08 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand All @@ -9,9 +9,6 @@
#include "Bra.h"
#include "LzmaDec.h"

static void *SzAlloc(void *p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }
static void SzFree(void *p, void *address) { UNUSED_VAR(p); MyFree(address); }

SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)
{
unsigned i;
Expand All @@ -25,7 +22,6 @@ SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)

SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen)
{
ISzAlloc g_Alloc = { SzAlloc, SzFree };
SRes res;
int useFilter;
SizeT inSizePure;
Expand Down
6 changes: 1 addition & 5 deletions C/Lzma86Enc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder
2015-11-08 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand All @@ -13,13 +13,9 @@

#define SZE_OUT_OVERFLOW SZE_DATA_ERROR

static void *SzAlloc(void *p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }
static void SzFree(void *p, void *address) { UNUSED_VAR(p); MyFree(address); }

int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
int level, UInt32 dictSize, int filterMode)
{
ISzAlloc g_Alloc = { SzAlloc, SzFree };
size_t outSize2 = *destLen;
Byte *filteredStream;
Bool useFilter;
Expand Down
12 changes: 6 additions & 6 deletions C/LzmaDec.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* LzmaDec.c -- LZMA Decoder
2015-06-23 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand Down Expand Up @@ -294,14 +294,14 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte

#ifdef _LZMA_SIZE_OPT
{
unsigned limit, offset;
unsigned lim, offset;
CLzmaProb *probLen = prob + LenChoice;
IF_BIT_0(probLen)
{
UPDATE_0(probLen);
probLen = prob + LenLow + (posState << kLenNumLowBits);
offset = 0;
limit = (1 << kLenNumLowBits);
lim = (1 << kLenNumLowBits);
}
else
{
Expand All @@ -312,17 +312,17 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
UPDATE_0(probLen);
probLen = prob + LenMid + (posState << kLenNumMidBits);
offset = kLenNumLowSymbols;
limit = (1 << kLenNumMidBits);
lim = (1 << kLenNumMidBits);
}
else
{
UPDATE_1(probLen);
probLen = prob + LenHigh;
offset = kLenNumLowSymbols + kLenNumMidSymbols;
limit = (1 << kLenNumHighBits);
lim = (1 << kLenNumHighBits);
}
}
TREE_DECODE(probLen, limit, len);
TREE_DECODE(probLen, lim, len);
len += offset;
}
#else
Expand Down
39 changes: 24 additions & 15 deletions C/LzmaEnc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* LzmaEnc.c -- LZMA Encoder
2015-11-08 : Igor Pavlov : Public domain */
2016-05-16 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand Down Expand Up @@ -108,7 +108,7 @@ UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)

#define kDicLogSizeMaxCompress 32

#define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); }
#define BSR2_RET(pos, res) { unsigned long zz; _BitScanReverse(&zz, (pos)); res = (zz + zz) + ((pos >> (zz - 1)) & 1); }

static UInt32 GetPosSlot1(UInt32 pos)
{
Expand Down Expand Up @@ -145,19 +145,19 @@ static void LzmaEnc_FastPosInit(Byte *g_FastPos)

/* we can use ((limit - pos) >> 31) only if (pos < ((UInt32)1 << 31)) */
/*
#define BSR2_RET(pos, res) { UInt32 i = 6 + ((kNumLogBits - 1) & \
#define BSR2_RET(pos, res) { UInt32 zz = 6 + ((kNumLogBits - 1) & \
(0 - (((((UInt32)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \
res = p->g_FastPos[pos >> i] + (i * 2); }
res = p->g_FastPos[pos >> zz] + (zz * 2); }
*/

/*
#define BSR2_RET(pos, res) { UInt32 i = 6 + ((kNumLogBits - 1) & \
#define BSR2_RET(pos, res) { UInt32 zz = 6 + ((kNumLogBits - 1) & \
(0 - (((((UInt32)1 << (kNumLogBits)) - 1) - (pos >> 6)) >> 31))); \
res = p->g_FastPos[pos >> i] + (i * 2); }
res = p->g_FastPos[pos >> zz] + (zz * 2); }
*/

#define BSR2_RET(pos, res) { UInt32 i = (pos < (1 << (kNumLogBits + 6))) ? 6 : 6 + kNumLogBits - 1; \
res = p->g_FastPos[pos >> i] + (i * 2); }
#define BSR2_RET(pos, res) { UInt32 zz = (pos < (1 << (kNumLogBits + 6))) ? 6 : 6 + kNumLogBits - 1; \
res = p->g_FastPos[pos >> zz] + (zz * 2); }

/*
#define BSR2_RET(pos, res) { res = (pos < (1 << (kNumLogBits + 6))) ? \
Expand Down Expand Up @@ -983,12 +983,17 @@ static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur)

static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
{
UInt32 numAvail, mainLen, numPairs, repMaxIndex, i, posState, lenEnd, len, cur;
UInt32 matchPrice, repMatchPrice, normalMatchPrice;
UInt32 lenEnd, cur;
UInt32 reps[LZMA_NUM_REPS], repLens[LZMA_NUM_REPS];
UInt32 *matches;

{

UInt32 numAvail, mainLen, numPairs, repMaxIndex, i, posState, len;
UInt32 matchPrice, repMatchPrice, normalMatchPrice;
const Byte *data;
Byte curByte, matchByte;

if (p->optimumEndIndex != p->optimumCurrentIndex)
{
const COptimal *opt = &p->opt[p->optimumCurrentIndex];
Expand Down Expand Up @@ -1176,8 +1181,11 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
}
#endif

}

for (;;)
{
UInt32 numAvail;
UInt32 numAvailFull, newLen, numPairs, posPrev, state, posState, startLen;
UInt32 curPrice, curAnd1Price, matchPrice, repMatchPrice;
Bool nextIsChar;
Expand Down Expand Up @@ -1465,6 +1473,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
for (lenTest = /*2*/ startLen; ; lenTest++)
{
UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][lenTest - LZMA_MATCH_LEN_MIN];
{
UInt32 lenToPosState = GetLenToPosState(lenTest);
COptimal *opt;
if (curBack < kNumFullDistances)
Expand All @@ -1480,6 +1489,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
opt->backPrev = curBack + LZMA_NUM_REPS;
opt->prev1IsChar = False;
}
}

if (/*_maxMode && */lenTest == matches[offs])
{
Expand Down Expand Up @@ -1509,15 +1519,15 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
/* for (; lenTest2 >= 2; lenTest2--) */
{
UInt32 offset = cur + lenTest + 1 + lenTest2;
UInt32 curAndLenPrice;
UInt32 curAndLenPrice2;
COptimal *opt;
while (lenEnd < offset)
p->opt[++lenEnd].price = kInfinityPrice;
curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
curAndLenPrice2 = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
opt = &p->opt[offset];
if (curAndLenPrice < opt->price)
if (curAndLenPrice2 < opt->price)
{
opt->price = curAndLenPrice;
opt->price = curAndLenPrice2;
opt->posPrev = cur + lenTest + 1;
opt->backPrev = 0;
opt->prev1IsChar = True;
Expand Down Expand Up @@ -1718,7 +1728,6 @@ static void FillDistancesPrices(CLzmaEnc *p)

{
UInt32 *distancesPrices = p->distancesPrices[lenToPosState];
UInt32 i;
for (i = 0; i < kStartPosModelIndex; i++)
distancesPrices[i] = posSlotPrices[i];
for (; i < kNumFullDistances; i++)
Expand Down
6 changes: 3 additions & 3 deletions C/Ppmd.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Ppmd.h -- PPMD codec common code
2013-01-18 : Igor Pavlov : Public domain
2016-05-16 : Igor Pavlov : Public domain
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */

#ifndef __PPMD_H
Expand Down Expand Up @@ -77,8 +77,8 @@ typedef
CPpmd_Byte_Ref;

#define PPMD_SetAllBitsIn256Bytes(p) \
{ unsigned i; for (i = 0; i < 256 / sizeof(p[0]); i += 8) { \
p[i+7] = p[i+6] = p[i+5] = p[i+4] = p[i+3] = p[i+2] = p[i+1] = p[i+0] = ~(size_t)0; }}
{ unsigned z; for (z = 0; z < 256 / sizeof(p[0]); z += 8) { \
p[z+7] = p[z+6] = p[z+5] = p[z+4] = p[z+3] = p[z+2] = p[z+1] = p[z+0] = ~(size_t)0; }}

EXTERN_C_END

Expand Down
Loading

0 comments on commit bec3b47

Please sign in to comment.