summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>2014-01-26 22:55:01 -0600
committerAlexandru Gagniuc <mr.nuke.me@gmail.com>2014-01-29 20:04:53 +0100
commit91e9f27973aba1988b32e694add144ab852dfece (patch)
tree0f5cc2a057ca50d668a89a7fdcae44e5bbb4bef6 /util
parentaa2f739ae87386b8a29068ecfdc2b25bcf4a19ca (diff)
cbfstool/lzma: Use stdint and stdbool types
This is the first patch on a long road to refactor and fix the lzma code in cbfstool. I want to submit it in small atomic patches, so that any potential errors are easy to spot before it's too late. Change-Id: Ib557f8c83f49f18488639f38bf98d3ce849e61af Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-on: http://review.coreboot.org/4834 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'util')
-rw-r--r--util/cbfstool/lzma/C/LzFind.c160
-rw-r--r--util/cbfstool/lzma/C/LzFind.h78
-rw-r--r--util/cbfstool/lzma/C/LzHash.h32
-rw-r--r--util/cbfstool/lzma/C/LzmaDec.c144
-rw-r--r--util/cbfstool/lzma/C/LzmaDec.h44
-rw-r--r--util/cbfstool/lzma/C/LzmaEnc.c660
-rw-r--r--util/cbfstool/lzma/C/LzmaEnc.h14
-rw-r--r--util/cbfstool/lzma/C/Types.h62
-rw-r--r--util/cbfstool/lzma/lzma.c6
9 files changed, 580 insertions, 620 deletions
diff --git a/util/cbfstool/lzma/C/LzFind.c b/util/cbfstool/lzma/C/LzFind.c
index 8f204afb13..a0d01bfff2 100644
--- a/util/cbfstool/lzma/C/LzFind.c
+++ b/util/cbfstool/lzma/C/LzFind.c
@@ -7,10 +7,10 @@
#include "LzHash.h"
#define kEmptyHashValue 0
-#define kMaxValForNormalize ((UInt32)0xFFFFFFFF)
+#define kMaxValForNormalize ((uint32_t)0xFFFFFFFF)
#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */
#define kNormalizeMask (~(kNormalizeStepMin - 1))
-#define kMaxHistorySize ((UInt32)3 << 30)
+#define kMaxHistorySize ((uint32_t)3 << 30)
#define kStartMaxLen 3
@@ -25,9 +25,9 @@ static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc)
/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */
-static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc)
+static int LzInWindow_Create(CMatchFinder *p, uint32_t keepSizeReserv, ISzAlloc *alloc)
{
- UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
+ uint32_t blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
if (p->directInput)
{
p->blockSize = blockSize;
@@ -37,17 +37,17 @@ static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *a
{
LzInWindow_Free(p, alloc);
p->blockSize = blockSize;
- p->bufferBase = (Byte *)alloc->Alloc(alloc, (size_t)blockSize);
+ p->bufferBase = (uint8_t *)alloc->Alloc(alloc, (size_t)blockSize);
}
return (p->bufferBase != 0);
}
-Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
-static Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 bindex) { return p->buffer[bindex]; }
+uint8_t *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
+static uint8_t MatchFinder_GetIndexByte(CMatchFinder *p, int32_t bindex) { return p->buffer[bindex]; }
-static UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
+static uint32_t MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
-void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
+void MatchFinder_ReduceOffsets(CMatchFinder *p, uint32_t subValue)
{
p->posLimit -= subValue;
p->pos -= subValue;
@@ -60,9 +60,9 @@ static void MatchFinder_ReadBlock(CMatchFinder *p)
return;
if (p->directInput)
{
- UInt32 curSize = 0xFFFFFFFF - p->streamPos;
+ uint32_t curSize = 0xFFFFFFFF - p->streamPos;
if (curSize > p->directInputRem)
- curSize = (UInt32)p->directInputRem;
+ curSize = (uint32_t)p->directInputRem;
p->directInputRem -= curSize;
p->streamPos += curSize;
if (p->directInputRem == 0)
@@ -71,7 +71,7 @@ static void MatchFinder_ReadBlock(CMatchFinder *p)
}
for (;;)
{
- Byte *dest = p->buffer + (p->streamPos - p->pos);
+ uint8_t *dest = p->buffer + (p->streamPos - p->pos);
size_t size = (p->bufferBase + p->blockSize - dest);
if (size == 0)
return;
@@ -83,7 +83,7 @@ static void MatchFinder_ReadBlock(CMatchFinder *p)
p->streamEndWasReached = 1;
return;
}
- p->streamPos += (UInt32)size;
+ p->streamPos += (uint32_t)size;
if (p->streamPos - p->pos > p->keepSizeAfter)
return;
}
@@ -132,7 +132,7 @@ static void MatchFinder_SetDefaultSettings(CMatchFinder *p)
void MatchFinder_Construct(CMatchFinder *p)
{
- UInt32 i;
+ uint32_t i;
p->bufferBase = 0;
p->directInput = 0;
p->hash = 0;
@@ -140,7 +140,7 @@ void MatchFinder_Construct(CMatchFinder *p)
for (i = 0; i < 256; i++)
{
- UInt32 r = i;
+ uint32_t r = i;
int j;
for (j = 0; j < 8; j++)
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
@@ -160,26 +160,26 @@ void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc)
LzInWindow_Free(p, alloc);
}
-static CLzRef* AllocRefs(UInt32 num, ISzAlloc *alloc)
+static CLzRef* AllocRefs(uint32_t num, ISzAlloc *alloc)
{
- size_t sizeInBytes = (size_t)num * sizeof(CLzRef);
- if (sizeInBytes / sizeof(CLzRef) != num)
+ size_t sizeInuint8_ts = (size_t)num * sizeof(CLzRef);
+ if (sizeInuint8_ts / sizeof(CLzRef) != num)
return 0;
- return (CLzRef *)alloc->Alloc(alloc, sizeInBytes);
+ return (CLzRef *)alloc->Alloc(alloc, sizeInuint8_ts);
}
-int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
- UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
+int MatchFinder_Create(CMatchFinder *p, uint32_t historySize,
+ uint32_t keepAddBufferBefore, uint32_t matchMaxLen, uint32_t keepAddBufferAfter,
ISzAlloc *alloc)
{
- UInt32 sizeReserv;
+ uint32_t sizeReserv;
if (historySize > kMaxHistorySize)
{
MatchFinder_Free(p, alloc);
return 0;
}
sizeReserv = historySize >> 1;
- if (historySize > ((UInt32)2 << 30))
+ if (historySize > ((uint32_t)2 << 30))
sizeReserv = historySize >> 2;
sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19);
@@ -188,8 +188,8 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
/* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */
if (LzInWindow_Create(p, sizeReserv, alloc))
{
- UInt32 newCyclicBufferSize = historySize + 1;
- UInt32 hs;
+ uint32_t newCyclicBufferSize = historySize + 1;
+ uint32_t hs;
p->matchMaxLen = matchMaxLen;
{
p->fixedHashSize = 0;
@@ -221,8 +221,8 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
}
{
- UInt32 prevSize = p->hashSizeSum + p->numSons;
- UInt32 newSize;
+ uint32_t prevSize = p->hashSizeSum + p->numSons;
+ uint32_t newSize;
p->historySize = historySize;
p->hashSizeSum = hs;
p->cyclicBufferSize = newCyclicBufferSize;
@@ -245,8 +245,8 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
static void MatchFinder_SetLimits(CMatchFinder *p)
{
- UInt32 limit = kMaxValForNormalize - p->pos;
- UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos;
+ uint32_t limit = kMaxValForNormalize - p->pos;
+ uint32_t limit2 = p->cyclicBufferSize - p->cyclicBufferPos;
if (limit2 < limit)
limit = limit2;
limit2 = p->streamPos - p->pos;
@@ -260,7 +260,7 @@ static void MatchFinder_SetLimits(CMatchFinder *p)
if (limit2 < limit)
limit = limit2;
{
- UInt32 lenLimit = p->streamPos - p->pos;
+ uint32_t lenLimit = p->streamPos - p->pos;
if (lenLimit > p->matchMaxLen)
lenLimit = p->matchMaxLen;
p->lenLimit = lenLimit;
@@ -270,7 +270,7 @@ static void MatchFinder_SetLimits(CMatchFinder *p)
void MatchFinder_Init(CMatchFinder *p)
{
- UInt32 i;
+ uint32_t i;
for (i = 0; i < p->hashSizeSum; i++)
p->hash[i] = kEmptyHashValue;
p->cyclicBufferPos = 0;
@@ -282,17 +282,17 @@ void MatchFinder_Init(CMatchFinder *p)
MatchFinder_SetLimits(p);
}
-static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)
+static uint32_t MatchFinder_GetSubValue(CMatchFinder *p)
{
return (p->pos - p->historySize - 1) & kNormalizeMask;
}
-void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
+void MatchFinder_Normalize3(uint32_t subValue, CLzRef *items, uint32_t numItems)
{
- UInt32 i;
+ uint32_t i;
for (i = 0; i < numItems; i++)
{
- UInt32 value = items[i];
+ uint32_t value = items[i];
if (value <= subValue)
value = kEmptyHashValue;
else
@@ -303,7 +303,7 @@ void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
static void MatchFinder_Normalize(CMatchFinder *p)
{
- UInt32 subValue = MatchFinder_GetSubValue(p);
+ uint32_t subValue = MatchFinder_GetSubValue(p);
MatchFinder_Normalize3(subValue, p->hash, p->hashSizeSum + p->numSons);
MatchFinder_ReduceOffsets(p, subValue);
}
@@ -319,22 +319,22 @@ static void MatchFinder_CheckLimits(CMatchFinder *p)
MatchFinder_SetLimits(p);
}
-static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
- UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
- UInt32 *distances, UInt32 maxLen)
+static uint32_t * Hc_GetMatchesSpec(uint32_t lenLimit, uint32_t curMatch, uint32_t pos, const uint8_t *cur, CLzRef *son,
+ uint32_t _cyclicBufferPos, uint32_t _cyclicBufferSize, uint32_t cutValue,
+ uint32_t *distances, uint32_t maxLen)
{
son[_cyclicBufferPos] = curMatch;
for (;;)
{
- UInt32 delta = pos - curMatch;
+ uint32_t delta = pos - curMatch;
if (cutValue-- == 0 || delta >= _cyclicBufferSize)
return distances;
{
- const Byte *pb = cur - delta;
+ const uint8_t *pb = cur - delta;
curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];
if (pb[maxLen] == cur[maxLen] && *pb == *cur)
{
- UInt32 len = 0;
+ uint32_t len = 0;
while (++len != lenLimit)
if (pb[len] != cur[len])
break;
@@ -350,16 +350,16 @@ static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos,
}
}
-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
- UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
- UInt32 *distances, UInt32 maxLen)
+uint32_t * GetMatchesSpec1(uint32_t lenLimit, uint32_t curMatch, uint32_t pos, const uint8_t *cur, CLzRef *son,
+ uint32_t _cyclicBufferPos, uint32_t _cyclicBufferSize, uint32_t cutValue,
+ uint32_t *distances, uint32_t maxLen)
{
CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
- UInt32 len0 = 0, len1 = 0;
+ uint32_t len0 = 0, len1 = 0;
for (;;)
{
- UInt32 delta = pos - curMatch;
+ uint32_t delta = pos - curMatch;
if (cutValue-- == 0 || delta >= _cyclicBufferSize)
{
*ptr0 = *ptr1 = kEmptyHashValue;
@@ -367,8 +367,8 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt
}
{
CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
- const Byte *pb = cur - delta;
- UInt32 len = (len0 < len1 ? len0 : len1);
+ const uint8_t *pb = cur - delta;
+ uint32_t len = (len0 < len1 ? len0 : len1);
if (pb[len] == cur[len])
{
if (++len != lenLimit && pb[len] == cur[len])
@@ -405,15 +405,15 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt
}
}
-static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
- UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)
+static void SkipMatchesSpec(uint32_t lenLimit, uint32_t curMatch, uint32_t pos, const uint8_t *cur, CLzRef *son,
+ uint32_t _cyclicBufferPos, uint32_t _cyclicBufferSize, uint32_t cutValue)
{
CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
- UInt32 len0 = 0, len1 = 0;
+ uint32_t len0 = 0, len1 = 0;
for (;;)
{
- UInt32 delta = pos - curMatch;
+ uint32_t delta = pos - curMatch;
if (cutValue-- == 0 || delta >= _cyclicBufferSize)
{
*ptr0 = *ptr1 = kEmptyHashValue;
@@ -421,8 +421,8 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const
}
{
CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
- const Byte *pb = cur - delta;
- UInt32 len = (len0 < len1 ? len0 : len1);
+ const uint8_t *pb = cur - delta;
+ uint32_t len = (len0 < len1 ? len0 : len1);
if (pb[len] == cur[len])
{
while (++len != lenLimit)
@@ -465,7 +465,7 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const
static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
#define GET_MATCHES_HEADER2(minLen, ret_op) \
- UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \
+ uint32_t lenLimit; uint32_t hashValue; const uint8_t *cur; uint32_t curMatch; \
lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
cur = p->buffer;
@@ -475,15 +475,15 @@ 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 GET_MATCHES_FOOTER(offset, maxLen) \
- offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \
+ offset = (uint32_t)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \
distances + offset, maxLen) - distances); MOVE_POS_RET;
#define SKIP_FOOTER \
SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
-static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+static uint32_t Bt2_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
{
- UInt32 offset;
+ uint32_t offset;
GET_MATCHES_HEADER(2)
HASH2_CALC;
curMatch = p->hash[hashValue];
@@ -492,9 +492,9 @@ static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
GET_MATCHES_FOOTER(offset, 1)
}
-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+uint32_t Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
{
- UInt32 offset;
+ uint32_t offset;
GET_MATCHES_HEADER(3)
HASH_ZIP_CALC;
curMatch = p->hash[hashValue];
@@ -503,9 +503,9 @@ UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
GET_MATCHES_FOOTER(offset, 2)
}
-static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+static uint32_t Bt3_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
{
- UInt32 hash2Value, delta2, maxLen, offset;
+ uint32_t hash2Value, delta2, maxLen, offset;
GET_MATCHES_HEADER(3)
HASH3_CALC;
@@ -536,9 +536,9 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
GET_MATCHES_FOOTER(offset, maxLen)
}
-static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+static uint32_t Bt4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
{
- UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset;
+ uint32_t hash2Value, hash3Value, delta2, delta3, maxLen, offset;
GET_MATCHES_HEADER(4)
HASH4_CALC;
@@ -583,9 +583,9 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
GET_MATCHES_FOOTER(offset, maxLen)
}
-static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+static uint32_t Hc4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
{
- UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset;
+ uint32_t hash2Value, hash3Value, delta2, delta3, maxLen, offset;
GET_MATCHES_HEADER(4)
HASH4_CALC;
@@ -627,24 +627,24 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
}
if (maxLen < 3)
maxLen = 3;
- offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
+ offset = (uint32_t)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
distances + offset, maxLen) - (distances));
MOVE_POS_RET
}
-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+uint32_t Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
{
- UInt32 offset;
+ uint32_t offset;
GET_MATCHES_HEADER(3)
HASH_ZIP_CALC;
curMatch = p->hash[hashValue];
p->hash[hashValue] = p->pos;
- offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
+ offset = (uint32_t)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
distances, 2) - (distances));
MOVE_POS_RET
}
-static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+static void Bt2_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
{
do
{
@@ -657,7 +657,7 @@ static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
while (--num != 0);
}
-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
{
do
{
@@ -670,11 +670,11 @@ void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
while (--num != 0);
}
-static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+static void Bt3_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
{
do
{
- UInt32 hash2Value;
+ uint32_t hash2Value;
SKIP_HEADER(3)
HASH3_CALC;
curMatch = p->hash[kFix3HashSize + hashValue];
@@ -685,11 +685,11 @@ static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
while (--num != 0);
}
-static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+static void Bt4_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
{
do
{
- UInt32 hash2Value, hash3Value;
+ uint32_t hash2Value, hash3Value;
SKIP_HEADER(4)
HASH4_CALC;
curMatch = p->hash[kFix4HashSize + hashValue];
@@ -701,11 +701,11 @@ static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
while (--num != 0);
}
-static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+static void Hc4_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
{
do
{
- UInt32 hash2Value, hash3Value;
+ uint32_t hash2Value, hash3Value;
SKIP_HEADER(4)
HASH4_CALC;
curMatch = p->hash[kFix4HashSize + hashValue];
@@ -718,7 +718,7 @@ static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
while (--num != 0);
}
-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
{
do
{
diff --git a/util/cbfstool/lzma/C/LzFind.h b/util/cbfstool/lzma/C/LzFind.h
index 010c4b92ba..1e5b49189c 100644
--- a/util/cbfstool/lzma/C/LzFind.h
+++ b/util/cbfstool/lzma/C/LzFind.h
@@ -10,53 +10,53 @@
extern "C" {
#endif
-typedef UInt32 CLzRef;
+typedef uint32_t CLzRef;
typedef struct _CMatchFinder
{
- Byte *buffer;
- UInt32 pos;
- UInt32 posLimit;
- UInt32 streamPos;
- UInt32 lenLimit;
+ uint8_t *buffer;
+ uint32_t pos;
+ uint32_t posLimit;
+ uint32_t streamPos;
+ uint32_t lenLimit;
- UInt32 cyclicBufferPos;
- UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
+ uint32_t cyclicBufferPos;
+ uint32_t cyclicBufferSize; /* it must be = (historySize + 1) */
- UInt32 matchMaxLen;
+ uint32_t matchMaxLen;
CLzRef *hash;
CLzRef *son;
- UInt32 hashMask;
- UInt32 cutValue;
+ uint32_t hashMask;
+ uint32_t cutValue;
- Byte *bufferBase;
+ uint8_t *bufferBase;
ISeqInStream *stream;
int streamEndWasReached;
- UInt32 blockSize;
- UInt32 keepSizeBefore;
- UInt32 keepSizeAfter;
+ uint32_t blockSize;
+ uint32_t keepSizeBefore;
+ uint32_t keepSizeAfter;
- UInt32 numHashBytes;
+ uint32_t numHashBytes;
int directInput;
size_t directInputRem;
int btMode;
int bigHash;
- UInt32 historySize;
- UInt32 fixedHashSize;
- UInt32 hashSizeSum;
- UInt32 numSons;
+ uint32_t historySize;
+ uint32_t fixedHashSize;
+ uint32_t hashSizeSum;
+ uint32_t numSons;
SRes result;
- UInt32 crc[256];
+ uint32_t crc[256];
} CMatchFinder;
#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
-#define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)])
+#define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(int32_t)(index)])
#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
int MatchFinder_NeedMove(CMatchFinder *p);
-Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
+uint8_t *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
void MatchFinder_MoveBlock(CMatchFinder *p);
void MatchFinder_ReadIfRequired(CMatchFinder *p);
@@ -66,16 +66,16 @@ void MatchFinder_Construct(CMatchFinder *p);
historySize <= 3 GB
keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
*/
-int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
- UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
+int MatchFinder_Create(CMatchFinder *p, uint32_t historySize,
+ uint32_t keepAddBufferBefore, uint32_t matchMaxLen, uint32_t keepAddBufferAfter,
ISzAlloc *alloc);
void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
-void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems);
-void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
+void MatchFinder_Normalize3(uint32_t subValue, CLzRef *items, uint32_t numItems);
+void MatchFinder_ReduceOffsets(CMatchFinder *p, uint32_t subValue);
-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
- UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
- UInt32 *distances, UInt32 maxLen);
+uint32_t * GetMatchesSpec1(uint32_t lenLimit, uint32_t curMatch, uint32_t pos, const uint8_t *buffer, CLzRef *son,
+ uint32_t _cyclicBufferPos, uint32_t _cyclicBufferSize, uint32_t _cutValue,
+ uint32_t *distances, uint32_t maxLen);
/*
Conditions:
@@ -84,11 +84,11 @@ Conditions:
*/
typedef void (*Mf_Init_Func)(void *object);
-typedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index);
-typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);
-typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);
-typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);
-typedef void (*Mf_Skip_Func)(void *object, UInt32);
+typedef uint8_t (*Mf_GetIndexByte_Func)(void *object, int32_t index);
+typedef uint32_t (*Mf_GetNumAvailableBytes_Func)(void *object);
+typedef const uint8_t * (*Mf_GetPointerToCurrentPos_Func)(void *object);
+typedef uint32_t (*Mf_GetMatches_Func)(void *object, uint32_t *distances);
+typedef void (*Mf_Skip_Func)(void *object, uint32_t);
typedef struct _IMatchFinder
{
@@ -103,10 +103,10 @@ typedef struct _IMatchFinder
void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
void MatchFinder_Init(CMatchFinder *p);
-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
+uint32_t Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances);
+uint32_t Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances);
+void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num);
+void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num);
#ifdef __cplusplus
}
diff --git a/util/cbfstool/lzma/C/LzHash.h b/util/cbfstool/lzma/C/LzHash.h
index f3e89966cc..cc01a3f937 100644
--- a/util/cbfstool/lzma/C/LzHash.h
+++ b/util/cbfstool/lzma/C/LzHash.h
@@ -12,43 +12,43 @@
#define kFix4HashSize (kHash2Size + kHash3Size)
#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)
-#define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8);
+#define HASH2_CALC hashValue = cur[0] | ((uint32_t)cur[1] << 8);
#define HASH3_CALC { \
- UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
+ uint32_t temp = p->crc[cur[0]] ^ cur[1]; \
hash2Value = temp & (kHash2Size - 1); \
- hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; }
+ hashValue = (temp ^ ((uint32_t)cur[2] << 8)) & p->hashMask; }
#define HASH4_CALC { \
- UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
+ uint32_t temp = p->crc[cur[0]] ^ cur[1]; \
hash2Value = temp & (kHash2Size - 1); \
- hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
- hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & p->hashMask; }
+ hash3Value = (temp ^ ((uint32_t)cur[2] << 8)) & (kHash3Size - 1); \
+ hashValue = (temp ^ ((uint32_t)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & p->hashMask; }
#define HASH5_CALC { \
- UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
+ uint32_t temp = p->crc[cur[0]] ^ cur[1]; \
hash2Value = temp & (kHash2Size - 1); \
- hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
- hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)); \
+ hash3Value = (temp ^ ((uint32_t)cur[2] << 8)) & (kHash3Size - 1); \
+ hash4Value = (temp ^ ((uint32_t)cur[2] << 8) ^ (p->crc[cur[3]] << 5)); \
hashValue = (hash4Value ^ (p->crc[cur[4]] << 3)) & p->hashMask; \
hash4Value &= (kHash4Size - 1); }
-/* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */
-#define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;
+/* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((uint32_t)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */
+#define HASH_ZIP_CALC hashValue = ((cur[2] | ((uint32_t)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;
#define MT_HASH2_CALC \
hash2Value = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1);
#define MT_HASH3_CALC { \
- UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
+ uint32_t temp = p->crc[cur[0]] ^ cur[1]; \
hash2Value = temp & (kHash2Size - 1); \
- hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); }
+ hash3Value = (temp ^ ((uint32_t)cur[2] << 8)) & (kHash3Size - 1); }
#define MT_HASH4_CALC { \
- UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
+ uint32_t temp = p->crc[cur[0]] ^ cur[1]; \
hash2Value = temp & (kHash2Size - 1); \
- hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
- hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); }
+ hash3Value = (temp ^ ((uint32_t)cur[2] << 8)) & (kHash3Size - 1); \
+ hash4Value = (temp ^ ((uint32_t)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); }
#endif
diff --git a/util/cbfstool/lzma/C/LzmaDec.c b/util/cbfstool/lzma/C/LzmaDec.c
index fd88cec818..7ba32b9b27 100644
--- a/util/cbfstool/lzma/C/LzmaDec.c
+++ b/util/cbfstool/lzma/C/LzmaDec.c
@@ -6,7 +6,7 @@
#include <string.h>
#define kNumTopBits 24
-#define kTopValue ((UInt32)1 << kNumTopBits)
+#define kTopValue ((uint32_t)1 << kNumTopBits)
#define kNumBitModelTotalBits 11
#define kBitModelTotal (1 << kNumBitModelTotalBits)
@@ -107,7 +107,7 @@
#define LZMA_BASE_SIZE 1846
#define LZMA_LIT_SIZE 768
-#define LzmaProps_GetNumProbs(p) ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))
+#define LzmaProps_GetNumProbs(p) ((uint32_t)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))
#if Literal != LZMA_BASE_SIZE
StopCompilingDueBUG
@@ -128,32 +128,32 @@ Out:
= kMatchSpecLenStart + 2 : State Init Marker
*/
-static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit_parm, const Byte *bufLimit)
+static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, size_t limit_parm, const uint8_t *bufLimit)
{
CLzmaProb *probs = p->probs;
unsigned state = p->state;
- UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];
+ uint32_t rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];
unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1;
unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1;
unsigned lc = p->prop.lc;
- Byte *dic = p->dic;
- SizeT dicBufSize = p->dicBufSize;
- SizeT dicPos = p->dicPos;
+ uint8_t *dic = p->dic;
+ size_t dicBufSize = p->dicBufSize;
+ size_t dicPos = p->dicPos;
- UInt32 processedPos = p->processedPos;
- UInt32 checkDicSize = p->checkDicSize;
+ uint32_t processedPos = p->processedPos;
+ uint32_t checkDicSize = p->checkDicSize;
unsigned len = 0;
- const Byte *buf = p->buf;
- UInt32 range = p->range;
- UInt32 code = p->code;
+ const uint8_t *buf = p->buf;
+ uint32_t range = p->range;
+ uint32_t code = p->code;
do
{
CLzmaProb *prob;
- UInt32 bound;
+ uint32_t bound;
unsigned ttt;
unsigned posState = processedPos & pbMask;
@@ -175,7 +175,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit_parm, const
}
else
{
- unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
+ unsigned matchuint8_t = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
unsigned offs = 0x100;
state -= (state < 10) ? 3 : 6;
symbol = 1;
@@ -183,14 +183,14 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit_parm, const
{
unsigned bit;
CLzmaProb *probLit;
- matchByte <<= 1;
- bit = (matchByte & offs);
+ matchuint8_t <<= 1;
+ bit = (matchuint8_t & offs);
probLit = prob + offs + bit + symbol;
GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit)
}
while (symbol < 0x100);
}
- dic[dicPos++] = (Byte)symbol;
+ dic[dicPos++] = (uint8_t)symbol;
processedPos++;
continue;
}
@@ -227,7 +227,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit_parm, const
}
else
{
- UInt32 distance;
+ uint32_t distance;
UPDATE_1(prob);
prob = probs + IsRepG1 + state;
IF_BIT_0(prob)
@@ -293,7 +293,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit_parm, const
if (state >= kNumStates)
{
- UInt32 distance;
+ uint32_t distance;
prob = probs + PosSlot +
((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits);
TREE_6_DECODE(prob, distance);
@@ -307,7 +307,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit_parm, const
distance <<= numDirectBits;
prob = probs + SpecPos + distance - posSlot - 1;
{
- UInt32 mask = 1;
+ uint32_t mask = 1;
unsigned i = 1;
do
{
@@ -326,9 +326,9 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit_parm, const
range >>= 1;
{
- UInt32 t;
+ uint32_t t;
code -= range;
- t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */
+ t = (0 - ((uint32_t)code >> 31)); /* (uint32_t)((int32_t)code >> 31) */
distance = (distance << 1) + (t + 1);
code += range & t;
}
@@ -351,7 +351,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit_parm, const
GET_BIT2(prob + i, i, ; , distance |= 4);
GET_BIT2(prob + i, i, ; , distance |= 8);
}
- if (distance == (UInt32)0xFFFFFFFF)
+ if (distance == (uint32_t)0xFFFFFFFF)
{
len += kMatchSpecLenStart;
state -= kNumStates;
@@ -378,21 +378,21 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit_parm, const
if (limit_parm == dicPos)
return SZ_ERROR_DATA;
{
- SizeT rem = limit_parm - dicPos;
+ size_t rem = limit_parm - dicPos;
unsigned curLen = ((rem < len) ? (unsigned)rem : len);
- SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0);
+ size_t pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0);
processedPos += curLen;
len -= curLen;
if (pos + curLen <= dicBufSize)
{
- Byte *dest = dic + dicPos;
+ uint8_t *dest = dic + dicPos;
ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;
- const Byte *lim = dest + curLen;
+ const uint8_t *lim = dest + curLen;
dicPos += curLen;
do
- *(dest) = (Byte)*(dest + src);
+ *(dest) = (uint8_t)*(dest + src);
while (++dest != lim);
}
else
@@ -425,15 +425,15 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit_parm, const
return SZ_OK;
}
-static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
+static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, size_t limit)
{
if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart)
{
- Byte *dic = p->dic;
- SizeT dicPos = p->dicPos;
- SizeT dicBufSize = p->dicBufSize;
+ uint8_t *dic = p->dic;
+ size_t dicPos = p->dicPos;
+ size_t dicBufSize = p->dicBufSize;
unsigned len = p->remainLen;
- UInt32 rep0 = p->reps[0];
+ uint32_t rep0 = p->reps[0];
if (limit - dicPos < len)
len = (unsigned)(limit - dicPos);
@@ -451,14 +451,14 @@ static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
}
}
-static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
+static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, size_t limit, const uint8_t *bufLimit)
{
do
{
- SizeT limit2 = limit;
+ size_t limit2 = limit;
if (p->checkDicSize == 0)
{
- UInt32 rem = p->prop.dicSize - p->processedPos;
+ uint32_t rem = p->prop.dicSize - p->processedPos;
if (limit - p->dicPos > rem)
limit2 = p->dicPos + rem;
}
@@ -484,18 +484,18 @@ typedef enum
DUMMY_REP
} ELzmaDummy;
-static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize)
+static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const uint8_t *buf, size_t inSize)
{
- UInt32 range = p->range;
- UInt32 code = p->code;
- const Byte *bufLimit = buf + inSize;
+ uint32_t range = p->range;
+ uint32_t code = p->code;
+ const uint8_t *bufLimit = buf + inSize;
CLzmaProb *probs = p->probs;
unsigned state = p->state;
ELzmaDummy res;
{
CLzmaProb *prob;
- UInt32 bound;
+ uint32_t bound;
unsigned ttt;
unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1);
@@ -519,7 +519,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
}
else
{
- unsigned matchByte = p->dic[p->dicPos - p->reps[0] +
+ unsigned matchuint8_t = p->dic[p->dicPos - p->reps[0] +
((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)];
unsigned offs = 0x100;
unsigned symbol = 1;
@@ -527,8 +527,8 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
{
unsigned bit;
CLzmaProb *probLit;
- matchByte <<= 1;
- bit = (matchByte & offs);
+ matchuint8_t <<= 1;
+ bit = (matchuint8_t & offs);
probLit = prob + offs + bit + symbol;
GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit)
}
@@ -675,14 +675,14 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
}
-static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data)
+static void LzmaDec_InitRc(CLzmaDec *p, const uint8_t *data)
{
- p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]);
+ p->code = ((uint32_t)data[1] << 24) | ((uint32_t)data[2] << 16) | ((uint32_t)data[3] << 8) | ((uint32_t)data[4]);
p->range = 0xFFFFFFFF;
p->needFlush = 0;
}
-static void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
+static void LzmaDec_InitDicAndState(CLzmaDec *p, bool initDic, bool initState)
{
p->needFlush = 1;
p->remainLen = 0;
@@ -701,13 +701,13 @@ static void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
void LzmaDec_Init(CLzmaDec *p)
{
p->dicPos = 0;
- LzmaDec_InitDicAndState(p, True, True);
+ LzmaDec_InitDicAndState(p, true, true);
}
static void LzmaDec_InitStateReal(CLzmaDec *p)
{
- UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp));
- UInt32 i;
+ uint32_t numProbs = Literal + ((uint32_t)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp));
+ uint32_t i;
CLzmaProb *probs = p->probs;
for (i = 0; i < numProbs; i++)
probs[i] = kBitModelTotal >> 1;
@@ -716,10 +716,10 @@ static void LzmaDec_InitStateReal(CLzmaDec *p)
p->needInitState = 0;
}
-SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
+SRes LzmaDec_DecodeToDic(CLzmaDec *p, size_t dicLimit, const uint8_t *src, size_t *srcLen,
ELzmaFinishMode finishMode, ELzmaStatus *status)
{
- SizeT inSize = *srcLen;
+ size_t inSize = *srcLen;
(*srcLen) = 0;
LzmaDec_WriteRem(p, dicLimit);
@@ -771,8 +771,8 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
if (p->tempBufSize == 0)
{
- SizeT processed;
- const Byte *bufLimit;
+ size_t processed;
+ const uint8_t *bufLimit;
if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
{
int dummyRes = LzmaDec_TryDummy(p, src, inSize);
@@ -796,7 +796,7 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
p->buf = src;
if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0)
return SZ_ERROR_DATA;
- processed = (SizeT)(p->buf - src);
+ processed = (size_t)(p->buf - src);
(*srcLen) += processed;
src += processed;
inSize -= processed;
@@ -837,14 +837,14 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA;
}
-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
+SRes LzmaDec_DecodeToBuf(CLzmaDec *p, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
{
- SizeT outSize = *destLen;
- SizeT inSize = *srcLen;
+ size_t outSize = *destLen;
+ size_t inSize = *srcLen;
*srcLen = *destLen = 0;
for (;;)
{
- SizeT inSizeCur = inSize, outSizeCur, dicPos;
+ size_t inSizeCur = inSize, outSizeCur, dicPos;
ELzmaFinishMode curFinishMode;
SRes res;
if (p->dicPos == p->dicBufSize)
@@ -895,15 +895,15 @@ void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc)
LzmaDec_FreeDict(p, alloc);
}
-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
+SRes LzmaProps_Decode(CLzmaProps *p, const uint8_t *data, unsigned size)
{
- UInt32 dicSize;
- Byte d;
+ uint32_t dicSize;
+ uint8_t d;
if (size < LZMA_PROPS_SIZE)
return SZ_ERROR_UNSUPPORTED;
else
- dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24);
+ dicSize = data[1] | ((uint32_t)data[2] << 8) | ((uint32_t)data[3] << 16) | ((uint32_t)data[4] << 24);
if (dicSize < LZMA_DIC_MIN)
dicSize = LZMA_DIC_MIN;
@@ -923,7 +923,7 @@ SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc)
{
- UInt32 numProbs = LzmaProps_GetNumProbs(propNew);
+ uint32_t numProbs = LzmaProps_GetNumProbs(propNew);
if (p->probs == 0 || numProbs != p->numProbs)
{
LzmaDec_FreeProbs(p, alloc);
@@ -935,7 +935,7 @@ static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAl
return SZ_OK;
}
-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
+SRes LzmaDec_AllocateProbs(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc)
{
CLzmaProps propNew;
RINOK(LzmaProps_Decode(&propNew, props, propsSize));
@@ -944,17 +944,17 @@ SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, I
return SZ_OK;
}
-SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
+SRes LzmaDec_Allocate(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc)
{
CLzmaProps propNew;
- SizeT dicBufSize;
+ size_t dicBufSize;
RINOK(LzmaProps_Decode(&propNew, props, propsSize));
RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
dicBufSize = propNew.dicSize;
if (p->dic == 0 || dicBufSize != p->dicBufSize)
{
LzmaDec_FreeDict(p, alloc);
- p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize);
+ p->dic = (uint8_t *)alloc->Alloc(alloc, dicBufSize);
if (p->dic == 0)
{
LzmaDec_FreeProbs(p, alloc);
@@ -966,14 +966,14 @@ SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAll
return SZ_OK;
}
-SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
- const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
+SRes LzmaDecode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen,
+ const uint8_t *propData, unsigned propSize, ELzmaFinishMode finishMode,
ELzmaStatus *status, ISzAlloc *alloc)
{
CLzmaDec p;
SRes res;
- SizeT inSize = *srcLen;
- SizeT outSize = *destLen;
+ size_t inSize = *srcLen;
+ size_t outSize = *destLen;
*srcLen = *destLen = 0;
if (inSize < RC_INIT_SIZE)
return SZ_ERROR_INPUT_EOF;
diff --git a/util/cbfstool/lzma/C/LzmaDec.h b/util/cbfstool/lzma/C/LzmaDec.h
index 7927acd0d4..3d06b584a5 100644
--- a/util/cbfstool/lzma/C/LzmaDec.h
+++ b/util/cbfstool/lzma/C/LzmaDec.h
@@ -15,9 +15,9 @@ extern "C" {
but memory usage for CLzmaDec::probs will be doubled in that case */
#ifdef _LZMA_PROB32
-#define CLzmaProb UInt32
+#define CLzmaProb uint32_t
#else
-#define CLzmaProb UInt16
+#define CLzmaProb uint16_t
#endif
@@ -28,7 +28,7 @@ extern "C" {
typedef struct _CLzmaProps
{
unsigned lc, lp, pb;
- UInt32 dicSize;
+ uint32_t dicSize;
} CLzmaProps;
/* LzmaProps_Decode - decodes properties
@@ -37,7 +37,7 @@ Returns:
SZ_ERROR_UNSUPPORTED - Unsupported properties
*/
-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);
+SRes LzmaProps_Decode(CLzmaProps *p, const uint8_t *data, unsigned size);
/* ---------- LZMA Decoder state ---------- */
@@ -51,21 +51,21 @@ typedef struct
{
CLzmaProps prop;
CLzmaProb *probs;
- Byte *dic;
- const Byte *buf;
- UInt32 range, code;
- SizeT dicPos;
- SizeT dicBufSize;
- UInt32 processedPos;
- UInt32 checkDicSize;
+ uint8_t *dic;
+ const uint8_t *buf;
+ uint32_t range, code;
+ size_t dicPos;
+ size_t dicBufSize;
+ uint32_t processedPos;
+ uint32_t checkDicSize;
unsigned state;
- UInt32 reps[4];
+ uint32_t reps[4];
unsigned remainLen;
int needFlush;
int needInitState;
- UInt32 numProbs;
+ uint32_t numProbs;
unsigned tempBufSize;
- Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];
+ uint8_t tempBuf[LZMA_REQUIRED_INPUT_MAX];
} CLzmaDec;
#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; }
@@ -131,10 +131,10 @@ LzmaDec_Allocate* can return:
SZ_ERROR_UNSUPPORTED - Unsupported properties
*/
-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc);
+SRes LzmaDec_AllocateProbs(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc);
void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc);
-SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc);
+SRes LzmaDec_Allocate(CLzmaDec *state, const uint8_t *prop, unsigned propsSize, ISzAlloc *alloc);
void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc);
/* ---------- Dictionary Interface ---------- */
@@ -178,8 +178,8 @@ Returns:
SZ_ERROR_DATA - Data error
*/
-SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,
- const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
+SRes LzmaDec_DecodeToDic(CLzmaDec *p, size_t dicLimit,
+ const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
/* ---------- Buffer Interface ---------- */
@@ -195,8 +195,8 @@ finishMode:
LZMA_FINISH_END - Stream must be finished after (*destLen).
*/
-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,
- const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
+SRes LzmaDec_DecodeToBuf(CLzmaDec *p, uint8_t *dest, size_t *destLen,
+ const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
/* ---------- One Call Interface ---------- */
@@ -220,8 +220,8 @@ Returns:
SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
*/
-SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
- const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
+SRes LzmaDecode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen,
+ const uint8_t *propData, unsigned propSize, ELzmaFinishMode finishMode,
ELzmaStatus *status, ISzAlloc *alloc);
#ifdef __cplusplus
diff --git a/util/cbfstool/lzma/C/LzmaEnc.c b/util/cbfstool/lzma/C/LzmaEnc.c
index a9a6813961..318b0abcf2 100644
--- a/util/cbfstool/lzma/C/LzmaEnc.c
+++ b/util/cbfstool/lzma/C/LzmaEnc.c
@@ -31,7 +31,7 @@ static int ttt = 0;
#define kNumMaxDirectBits (31)
#define kNumTopBits 24
-#define kTopValue ((UInt32)1 << kNumTopBits)
+#define kTopValue ((uint32_t)1 << kNumTopBits)
#define kNumBitModelTotalBits 11
#define kBitModelTotal (1 << kNumBitModelTotalBits)
@@ -73,7 +73,7 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p)
#endif
}
-UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
+uint32_t LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
{
CLzmaEncProps props = *props2;
LzmaEncProps_Normalize(&props);
@@ -90,9 +90,9 @@ UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
#define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); }
-UInt32 GetPosSlot1(UInt32 pos)
+uint32_t GetPosSlot1(uint32_t pos)
{
- UInt32 res;
+ uint32_t res;
BSR2_RET(pos, res);
return res;
}
@@ -104,7 +104,7 @@ UInt32 GetPosSlot1(UInt32 pos)
#define kNumLogBits (9 + (int)sizeof(size_t) / 2)
#define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7)
-static void LzmaEnc_FastPosInit(Byte *g_FastPos)
+static void LzmaEnc_FastPosInit(uint8_t *g_FastPos)
{
int c = 2, slotFast;
g_FastPos[0] = 0;
@@ -112,15 +112,15 @@ static void LzmaEnc_FastPosInit(Byte *g_FastPos)
for (slotFast = 2; slotFast < kNumLogBits * 2; slotFast++)
{
- UInt32 k = (1 << ((slotFast >> 1) - 1));
- UInt32 j;
+ uint32_t k = (1 << ((slotFast >> 1) - 1));
+ uint32_t j;
for (j = 0; j < k; j++, c++)
- g_FastPos[c] = (Byte)slotFast;
+ g_FastPos[c] = (uint8_t)slotFast;
}
}
-#define BSR2_RET(pos, res) { UInt32 i = 6 + ((kNumLogBits - 1) & \
- (0 - (((((UInt32)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \
+#define BSR2_RET(pos, res) { uint32_t i = 6 + ((kNumLogBits - 1) & \
+ (0 - (((((uint32_t)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \
res = p->g_FastPos[pos >> i] + (i * 2); }
/*
#define BSR2_RET(pos, res) { res = (pos < (1 << (kNumLogBits + 6))) ? \
@@ -141,18 +141,18 @@ typedef unsigned CState;
typedef struct
{
- UInt32 price;
+ uint32_t price;
CState state;
int prev1IsChar;
int prev2;
- UInt32 posPrev2;
- UInt32 backPrev2;
+ uint32_t posPrev2;
+ uint32_t backPrev2;
- UInt32 posPrev;
- UInt32 backPrev;
- UInt32 backs[LZMA_NUM_REPS];
+ uint32_t posPrev;
+ uint32_t backPrev;
+ uint32_t backs[LZMA_NUM_REPS];
} COptimal;
#define kNumOpts (1 << 12)
@@ -175,9 +175,9 @@ typedef struct
#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
#ifdef _LZMA_PROB32
-#define CLzmaProb UInt32
+#define CLzmaProb uint32_t
#else
-#define CLzmaProb UInt16
+#define CLzmaProb uint16_t
#endif
#define LZMA_PB_MAX 4
@@ -213,22 +213,22 @@ typedef struct
typedef struct
{
CLenEnc p;
- UInt32 prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal];
- UInt32 tableSize;
- UInt32 counters[LZMA_NUM_PB_STATES_MAX];
+ uint32_t prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal];
+ uint32_t tableSize;
+ uint32_t counters[LZMA_NUM_PB_STATES_MAX];
} CLenPriceEnc;
typedef struct
{
- UInt32 range;
- Byte cache;
- UInt64 low;
- UInt64 cacheSize;
- Byte *buf;
- Byte *bufLim;
- Byte *bufBase;
+ uint32_t range;
+ uint8_t cache;
+ uint64_t low;
+ uint64_t cacheSize;
+ uint8_t *buf;
+ uint8_t *bufLim;
+ uint8_t *bufBase;
ISeqOutStream *outStream;
- UInt64 processed;
+ uint64_t processed;
SRes res;
} CRangeEnc;
@@ -250,8 +250,8 @@ typedef struct
CLenPriceEnc lenEnc;
CLenPriceEnc repLenEnc;
- UInt32 reps[LZMA_NUM_REPS];
- UInt32 state;
+ uint32_t reps[LZMA_NUM_REPS];
+ uint32_t state;
} CSaveState;
typedef struct
@@ -260,41 +260,41 @@ typedef struct
void *matchFinderObj;
#ifndef _7ZIP_ST
- Bool mtMode;
+ bool mtMode;
CMatchFinderMt matchFinderMt;
#endif
CMatchFinder matchFinderBase;
#ifndef _7ZIP_ST
- Byte pad[128];
+ uint8_t pad[128];
#endif
- UInt32 optimumEndIndex;
- UInt32 optimumCurrentIndex;
+ uint32_t optimumEndIndex;
+ uint32_t optimumCurrentIndex;
- UInt32 longestMatchLength;
- UInt32 numPairs;
- UInt32 numAvail;
+ uint32_t longestMatchLength;
+ uint32_t numPairs;
+ uint32_t numAvail;
COptimal opt[kNumOpts];
#ifndef LZMA_LOG_BSR
- Byte g_FastPos[1 << kNumLogBits];
+ uint8_t g_FastPos[1 << kNumLogBits];
#endif
- UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
- UInt32 matches[LZMA_MATCH_LEN_MAX * 2 + 2 + 1];
- UInt32 numFastBytes;
- UInt32 additionalOffset;
- UInt32 reps[LZMA_NUM_REPS];
- UInt32 state;
+ uint32_t ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
+ uint32_t matches[LZMA_MATCH_LEN_MAX * 2 + 2 + 1];
+ uint32_t numFastuint8_ts;
+ uint32_t additionalOffset;
+ uint32_t reps[LZMA_NUM_REPS];
+ uint32_t state;
- UInt32 posSlotPrices[kNumLenToPosStates][kDistTableSizeMax];
- UInt32 distancesPrices[kNumLenToPosStates][kNumFullDistances];
- UInt32 alignPrices[kAlignTableSize];
- UInt32 alignPriceCount;
+ uint32_t posSlotPrices[kNumLenToPosStates][kDistTableSizeMax];
+ uint32_t distancesPrices[kNumLenToPosStates][kNumFullDistances];
+ uint32_t alignPrices[kAlignTableSize];
+ uint32_t alignPriceCount;
- UInt32 distTableSize;
+ uint32_t distTableSize;
unsigned lc, lp, pb;
unsigned lpMask, pbMask;
@@ -317,19 +317,19 @@ typedef struct
unsigned lclp;
- Bool fastMode;
+ bool fastMode;
CRangeEnc rc;
- Bool writeEndMark;
- UInt64 nowPos64;
- UInt32 matchPriceCount;
- Bool finished;
- Bool multiThread;
+ bool writeEndMark;
+ uint64_t nowPos64;
+ uint32_t matchPriceCount;
+ bool finished;
+ bool multiThread;
SRes result;
- UInt32 dictSize;
- UInt32 matchFinderCycles;
+ uint32_t dictSize;
+ uint32_t matchFinderCycles;
int needInit;
@@ -405,7 +405,7 @@ SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2)
fb = 5;
if (fb > LZMA_MATCH_LEN_MAX)
fb = LZMA_MATCH_LEN_MAX;
- p->numFastBytes = fb;
+ p->numFastuint8_ts = fb;
}
p->lc = props.lc;
p->lp = props.lp;
@@ -413,7 +413,7 @@ SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2)
p->fastMode = (props.algo == 0);
p->matchFinderBase.btMode = props.btMode;
{
- UInt32 numHashBytes = 4;
+ uint32_t numHashBytes = 4;
if (props.btMode)
{
if (props.numHashBytes < 2)
@@ -466,7 +466,7 @@ static int RangeEnc_Alloc(CRangeEnc *p, ISzAlloc *alloc)
{
if (p->bufBase == 0)
{
- p->bufBase = (Byte *)alloc->Alloc(alloc, RC_BUF_SIZE);
+ p->bufBase = (uint8_t *)alloc->Alloc(alloc, RC_BUF_SIZE);
if (p->bufBase == 0)
return 0;
p->bufLim = p->bufBase + RC_BUF_SIZE;
@@ -508,23 +508,23 @@ static void RangeEnc_FlushStream(CRangeEnc *p)
static void MY_FAST_CALL RangeEnc_ShiftLow(CRangeEnc *p)
{
- if ((UInt32)p->low < (UInt32)0xFF000000 || (int)(p->low >> 32) != 0)
+ if ((uint32_t)p->low < (uint32_t)0xFF000000 || (int)(p->low >> 32) != 0)
{
- Byte temp = p->cache;
+ uint8_t temp = p->cache;
do
{
- Byte *buf = p->buf;
- *buf++ = (Byte)(temp + (Byte)(p->low >> 32));
+ uint8_t *buf = p->buf;
+ *buf++ = (uint8_t)(temp + (uint8_t)(p->low >> 32));
p->buf = buf;
if (buf == p->bufLim)
RangeEnc_FlushStream(p);
temp = 0xFF;
}
while (--p->cacheSize != 0);
- p->cache = (Byte)((UInt32)p->low >> 24);
+ p->cache = (uint8_t)((uint32_t)p->low >> 24);
}
p->cacheSize++;
- p->low = (UInt32)p->low << 8;
+ p->low = (uint32_t)p->low << 8;
}
static void RangeEnc_FlushData(CRangeEnc *p)
@@ -534,7 +534,7 @@ static void RangeEnc_FlushData(CRangeEnc *p)
RangeEnc_ShiftLow(p);
}
-static void RangeEnc_EncodeDirectBits(CRangeEnc *p, UInt32 value, int numBits)
+static void RangeEnc_EncodeDirectBits(CRangeEnc *p, uint32_t value, int numBits)
{
do
{
@@ -549,10 +549,10 @@ static void RangeEnc_EncodeDirectBits(CRangeEnc *p, UInt32 value, int numBits)
while (numBits != 0);
}
-static void RangeEnc_EncodeBit(CRangeEnc *p, CLzmaProb *prob, UInt32 symbol)
+static void RangeEnc_EncodeBit(CRangeEnc *p, CLzmaProb *prob, uint32_t symbol)
{
- UInt32 ttt = *prob;
- UInt32 newBound = (p->range >> kNumBitModelTotalBits) * ttt;
+ uint32_t ttt = *prob;
+ uint32_t newBound = (p->range >> kNumBitModelTotalBits) * ttt;
if (symbol == 0)
{
p->range = newBound;
@@ -572,7 +572,7 @@ static void RangeEnc_EncodeBit(CRangeEnc *p, CLzmaProb *prob, UInt32 symbol)
}
}
-static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol)
+static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, uint32_t symbol)
{
symbol |= 0x100;
do
@@ -583,34 +583,34 @@ static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol)
while (symbol < 0x10000);
}
-static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol, UInt32 matchByte)
+static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, uint32_t symbol, uint32_t matchuint8_t)
{
- UInt32 offs = 0x100;
+ uint32_t offs = 0x100;
symbol |= 0x100;
do
{
- matchByte <<= 1;
- RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (symbol >> 8)), (symbol >> 7) & 1);
+ matchuint8_t <<= 1;
+ RangeEnc_EncodeBit(p, probs + (offs + (matchuint8_t & offs) + (symbol >> 8)), (symbol >> 7) & 1);
symbol <<= 1;
- offs &= ~(matchByte ^ symbol);
+ offs &= ~(matchuint8_t ^ symbol);
}
while (symbol < 0x10000);
}
-static void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
+static void LzmaEnc_InitPriceTables(uint32_t *ProbPrices)
{
- UInt32 i;
+ uint32_t i;
for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits))
{
const int kCyclesBits = kNumBitPriceShiftBits;
- UInt32 w = i;
- UInt32 bitCount = 0;
+ uint32_t w = i;
+ uint32_t bitCount = 0;
int j;
for (j = 0; j < kCyclesBits; j++)
{
w = w * w;
bitCount <<= 1;
- while (w >= ((UInt32)1 << 16))
+ while (w >= ((uint32_t)1 << 16))
{
w >>= 1;
bitCount++;
@@ -633,9 +633,9 @@ static void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
#define GET_PRICE_0a(prob) ProbPrices[(prob) >> kNumMoveReducingBits]
#define GET_PRICE_1a(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]
-static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 symbol, UInt32 *ProbPrices)
+static uint32_t LitEnc_GetPrice(const CLzmaProb *probs, uint32_t symbol, uint32_t *ProbPrices)
{
- UInt32 price = 0;
+ uint32_t price = 0;
symbol |= 0x100;
do
{
@@ -646,30 +646,30 @@ static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 symbol, UInt32 *Pro
return price;
}
-static UInt32 LitEnc_GetPriceMatched(const CLzmaProb *probs, UInt32 symbol, UInt32 matchByte, UInt32 *ProbPrices)
+static uint32_t LitEnc_GetPriceMatched(const CLzmaProb *probs, uint32_t symbol, uint32_t matchuint8_t, uint32_t *ProbPrices)
{
- UInt32 price = 0;
- UInt32 offs = 0x100;
+ uint32_t price = 0;
+ uint32_t offs = 0x100;
symbol |= 0x100;
do
{
- matchByte <<= 1;
- price += GET_PRICEa(probs[offs + (matchByte & offs) + (symbol >> 8)], (symbol >> 7) & 1);
+ matchuint8_t <<= 1;
+ price += GET_PRICEa(probs[offs + (matchuint8_t & offs) + (symbol >> 8)], (symbol >> 7) & 1);
symbol <<= 1;
- offs &= ~(matchByte ^ symbol);
+ offs &= ~(matchuint8_t ^ symbol);
}
while (symbol < 0x10000);
return price;
}
-static void RcTree_Encode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol)
+static void RcTree_Encode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, uint32_t symbol)
{
- UInt32 m = 1;
+ uint32_t m = 1;
int i;
for (i = numBitLevels; i != 0;)
{
- UInt32 bit;
+ uint32_t bit;
i--;
bit = (symbol >> i) & 1;
RangeEnc_EncodeBit(rc, probs + m, bit);
@@ -677,22 +677,22 @@ static void RcTree_Encode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UIn
}
}
-static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol)
+static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, uint32_t symbol)
{
- UInt32 m = 1;
+ uint32_t m = 1;
int i;
for (i = 0; i < numBitLevels; i++)
{
- UInt32 bit = symbol & 1;
+ uint32_t bit = symbol & 1;
RangeEnc_EncodeBit(rc, probs + m, bit);
m = (m << 1) | bit;
symbol >>= 1;
}
}
-static UInt32 RcTree_GetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices)
+static uint32_t RcTree_GetPrice(const CLzmaProb *probs, int numBitLevels, uint32_t symbol, uint32_t *ProbPrices)
{
- UInt32 price = 0;
+ uint32_t price = 0;
symbol |= (1 << numBitLevels);
while (symbol != 1)
{
@@ -702,14 +702,14 @@ static UInt32 RcTree_GetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 s
return price;
}
-static UInt32 RcTree_ReverseGetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices)
+static uint32_t RcTree_ReverseGetPrice(const CLzmaProb *probs, int numBitLevels, uint32_t symbol, uint32_t *ProbPrices)
{
- UInt32 price = 0;
- UInt32 m = 1;
+ uint32_t price = 0;
+ uint32_t m = 1;
int i;
for (i = numBitLevels; i != 0; i--)
{
- UInt32 bit = symbol & 1;
+ uint32_t bit = symbol & 1;
symbol >>= 1;
price += GET_PRICEa(probs[m], bit);
m = (m << 1) | bit;
@@ -730,7 +730,7 @@ static void LenEnc_Init(CLenEnc *p)
p->high[i] = kProbInitValue;
}
-static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState)
+static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, uint32_t symbol, uint32_t posState)
{
if (symbol < kLenNumLowSymbols)
{
@@ -753,13 +753,13 @@ static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posSt
}
}
-static void LenEnc_SetPrices(CLenEnc *p, UInt32 posState, UInt32 numSymbols, UInt32 *prices, UInt32 *ProbPrices)
+static void LenEnc_SetPrices(CLenEnc *p, uint32_t posState, uint32_t numSymbols, uint32_t *prices, uint32_t *ProbPrices)
{
- UInt32 a0 = GET_PRICE_0a(p->choice);
- UInt32 a1 = GET_PRICE_1a(p->choice);
- UInt32 b0 = a1 + GET_PRICE_0a(p->choice2);
- UInt32 b1 = a1 + GET_PRICE_1a(p->choice2);
- UInt32 i = 0;
+ uint32_t a0 = GET_PRICE_0a(p->choice);
+ uint32_t a1 = GET_PRICE_1a(p->choice);
+ uint32_t b0 = a1 + GET_PRICE_0a(p->choice2);
+ uint32_t b1 = a1 + GET_PRICE_1a(p->choice2);
+ uint32_t i = 0;
for (i = 0; i < kLenNumLowSymbols; i++)
{
if (i >= numSymbols)
@@ -776,20 +776,20 @@ static void LenEnc_SetPrices(CLenEnc *p, UInt32 posState, UInt32 numSymbols, UIn
prices[i] = b1 + RcTree_GetPrice(p->high, kLenNumHighBits, i - kLenNumLowSymbols - kLenNumMidSymbols, ProbPrices);
}
-static void MY_FAST_CALL LenPriceEnc_UpdateTable(CLenPriceEnc *p, UInt32 posState, UInt32 *ProbPrices)
+static void MY_FAST_CALL LenPriceEnc_UpdateTable(CLenPriceEnc *p, uint32_t posState, uint32_t *ProbPrices)
{
LenEnc_SetPrices(&p->p, posState, p->tableSize, p->prices[posState], ProbPrices);
p->counters[posState] = p->tableSize;
}
-static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, UInt32 numPosStates, UInt32 *ProbPrices)
+static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, uint32_t numPosStates, uint32_t *ProbPrices)
{
- UInt32 posState;
+ uint32_t posState;
for (posState = 0; posState < numPosStates; posState++)
LenPriceEnc_UpdateTable(p, posState, ProbPrices);
}
-static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState, Bool updatePrice, UInt32 *ProbPrices)
+static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, uint32_t symbol, uint32_t posState, bool updatePrice, uint32_t *ProbPrices)
{
LenEnc_Encode(&p->p, rc, symbol, posState);
if (updatePrice)
@@ -800,7 +800,7 @@ static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32
-static void MovePos(CLzmaEnc *p, UInt32 num)
+static void MovePos(CLzmaEnc *p, uint32_t num)
{
#ifdef SHOW_STAT
ttt += num;
@@ -813,16 +813,16 @@ static void MovePos(CLzmaEnc *p, UInt32 num)
}
}
-static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes)
+static uint32_t ReadMatchDistances(CLzmaEnc *p, uint32_t *numDistancePairsRes)
{
- UInt32 lenRes = 0, numPairs;
+ uint32_t lenRes = 0, numPairs;
p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches);
#ifdef SHOW_STAT
printf("\n i = %d numPairs = %d ", ttt, numPairs / 2);
ttt++;
{
- UInt32 i;
+ uint32_t i;
for (i = 0; i < numPairs; i += 2)
printf("%2d %6d | ", p->matches[i], p->matches[i + 1]);
}
@@ -830,15 +830,15 @@ static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes)
if (numPairs > 0)
{
lenRes = p->matches[numPairs - 2];
- if (lenRes == p->numFastBytes)
+ if (lenRes == p->numFastuint8_ts)
{
- const Byte *pby = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
- UInt32 distance = p->matches[numPairs - 1] + 1;
- UInt32 numAvail = p->numAvail;
+ const uint8_t *pby = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
+ uint32_t distance = p->matches[numPairs - 1] + 1;
+ uint32_t numAvail = p->numAvail;
if (numAvail > LZMA_MATCH_LEN_MAX)
numAvail = LZMA_MATCH_LEN_MAX;
{
- const Byte *pby2 = pby - distance;
+ const uint8_t *pby2 = pby - distance;
for (; lenRes < numAvail && pby[lenRes] == pby2[lenRes]; lenRes++);
}
}
@@ -849,20 +849,20 @@ static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes)
}
-#define MakeAsChar(p) (p)->backPrev = (UInt32)(-1); (p)->prev1IsChar = False;
-#define MakeAsShortRep(p) (p)->backPrev = 0; (p)->prev1IsChar = False;
+#define MakeAsChar(p) (p)->backPrev = (uint32_t)(-1); (p)->prev1IsChar = false;
+#define MakeAsShortRep(p) (p)->backPrev = 0; (p)->prev1IsChar = false;
#define IsShortRep(p) ((p)->backPrev == 0)
-static UInt32 GetRepLen1Price(CLzmaEnc *p, UInt32 state, UInt32 posState)
+static uint32_t GetRepLen1Price(CLzmaEnc *p, uint32_t state, uint32_t posState)
{
return
GET_PRICE_0(p->isRepG0[state]) +
GET_PRICE_0(p->isRep0Long[state][posState]);
}
-static UInt32 GetPureRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 state, UInt32 posState)
+static uint32_t GetPureRepPrice(CLzmaEnc *p, uint32_t repIndex, uint32_t state, uint32_t posState)
{
- UInt32 price;
+ uint32_t price;
if (repIndex == 0)
{
price = GET_PRICE_0(p->isRepG0[state]);
@@ -882,16 +882,16 @@ static UInt32 GetPureRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 state, UInt32
return price;
}
-static UInt32 GetRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 len, UInt32 state, UInt32 posState)
+static uint32_t GetRepPrice(CLzmaEnc *p, uint32_t repIndex, uint32_t len, uint32_t state, uint32_t posState)
{
return p->repLenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN] +
GetPureRepPrice(p, repIndex, state, posState);
}
-static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur)
+static uint32_t Backward(CLzmaEnc *p, uint32_t *backRes, uint32_t cur)
{
- UInt32 posMem = p->opt[cur].posPrev;
- UInt32 backMem = p->opt[cur].backPrev;
+ uint32_t posMem = p->opt[cur].posPrev;
+ uint32_t backMem = p->opt[cur].backPrev;
p->optimumEndIndex = cur;
do
{
@@ -901,14 +901,14 @@ static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur)
p->opt[posMem].posPrev = posMem - 1;
if (p->opt[cur].prev2)
{
- p->opt[posMem - 1].prev1IsChar = False;
+ p->opt[posMem - 1].prev1IsChar = false;
p->opt[posMem - 1].posPrev = p->opt[cur].posPrev2;
p->opt[posMem - 1].backPrev = p->opt[cur].backPrev2;
}
}
{
- UInt32 posPrev = posMem;
- UInt32 backCur = backMem;
+ uint32_t posPrev = posMem;
+ uint32_t backCur = backMem;
backMem = p->opt[posPrev].backPrev;
posMem = p->opt[posPrev].posPrev;
@@ -924,20 +924,20 @@ static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur)
return p->optimumCurrentIndex;
}
-#define LIT_PROBS(pos, prevByte) (p->litProbs + ((((pos) & p->lpMask) << p->lc) + ((prevByte) >> (8 - p->lc))) * 0x300)
+#define LIT_PROBS(pos, prevuint8_t) (p->litProbs + ((((pos) & p->lpMask) << p->lc) + ((prevuint8_t) >> (8 - p->lc))) * 0x300)
-static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
+static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes)
{
- UInt32 numAvail, mainLen, numPairs, repMaxIndex, i, posState, lenEnd, len, cur;
- UInt32 matchPrice, repMatchPrice, normalMatchPrice;
- UInt32 reps[LZMA_NUM_REPS], repLens[LZMA_NUM_REPS];
- UInt32 *matches;
- const Byte *data;
- Byte curByte, matchByte;
+ uint32_t numAvail, mainLen, numPairs, repMaxIndex, i, posState, lenEnd, len, cur;
+ uint32_t matchPrice, repMatchPrice, normalMatchPrice;
+ uint32_t reps[LZMA_NUM_REPS], repLens[LZMA_NUM_REPS];
+ uint32_t *matches;
+ const uint8_t *data;
+ uint8_t curuint8_t, matchuint8_t;
if (p->optimumEndIndex != p->optimumCurrentIndex)
{
const COptimal *opt = &p->opt[p->optimumCurrentIndex];
- UInt32 lenRes = opt->posPrev - p->optimumCurrentIndex;
+ uint32_t lenRes = opt->posPrev - p->optimumCurrentIndex;
*backRes = opt->backPrev;
p->optimumCurrentIndex = opt->posPrev;
return lenRes;
@@ -955,7 +955,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
numAvail = p->numAvail;
if (numAvail < 2)
{
- *backRes = (UInt32)(-1);
+ *backRes = (uint32_t)(-1);
return 1;
}
if (numAvail > LZMA_MATCH_LEN_MAX)
@@ -965,8 +965,8 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
repMaxIndex = 0;
for (i = 0; i < LZMA_NUM_REPS; i++)
{
- UInt32 lenTest;
- const Byte *data2;
+ uint32_t lenTest;
+ const uint8_t *data2;
reps[i] = p->reps[i];
data2 = data - (reps[i] + 1);
if (data[0] != data2[0] || data[1] != data2[1])
@@ -979,9 +979,9 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
if (lenTest > repLens[repMaxIndex])
repMaxIndex = i;
}
- if (repLens[repMaxIndex] >= p->numFastBytes)
+ if (repLens[repMaxIndex] >= p->numFastuint8_ts)
{
- UInt32 lenRes;
+ uint32_t lenRes;
*backRes = repMaxIndex;
lenRes = repLens[repMaxIndex];
MovePos(p, lenRes - 1);
@@ -989,18 +989,18 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
}
matches = p->matches;
- if (mainLen >= p->numFastBytes)
+ if (mainLen >= p->numFastuint8_ts)
{
*backRes = matches[numPairs - 1] + LZMA_NUM_REPS;
MovePos(p, mainLen - 1);
return mainLen;
}
- curByte = *data;
- matchByte = *(data - (reps[0] + 1));
+ curuint8_t = *data;
+ matchuint8_t = *(data - (reps[0] + 1));
- if (mainLen < 2 && curByte != matchByte && repLens[repMaxIndex] < 2)
+ if (mainLen < 2 && curuint8_t != matchuint8_t && repLens[repMaxIndex] < 2)
{
- *backRes = (UInt32)-1;
+ *backRes = (uint32_t)-1;
return 1;
}
@@ -1012,8 +1012,8 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
const CLzmaProb *probs = LIT_PROBS(position, *(data - 1));
p->opt[1].price = GET_PRICE_0(p->isMatch[p->state][posState]) +
(!IsCharState(p->state) ?
- LitEnc_GetPriceMatched(probs, curByte, matchByte, p->ProbPrices) :
- LitEnc_GetPrice(probs, curByte, p->ProbPrices));
+ LitEnc_GetPriceMatched(probs, curuint8_t, matchuint8_t, p->ProbPrices) :
+ LitEnc_GetPrice(probs, curuint8_t, p->ProbPrices));
}
MakeAsChar(&p->opt[1]);
@@ -1021,9 +1021,9 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
matchPrice = GET_PRICE_1(p->isMatch[p->state][posState]);
repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[p->state]);
- if (matchByte == curByte)
+ if (matchuint8_t == curuint8_t)
{
- UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, p->state, posState);
+ uint32_t shortRepPrice = repMatchPrice + GetRepLen1Price(p, p->state, posState);
if (shortRepPrice < p->opt[1].price)
{
p->opt[1].price = shortRepPrice;
@@ -1049,21 +1049,21 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
for (i = 0; i < LZMA_NUM_REPS; i++)
{
- UInt32 repLen = repLens[i];
- UInt32 price;
+ uint32_t repLen = repLens[i];
+ uint32_t price;
if (repLen < 2)
continue;
price = repMatchPrice + GetPureRepPrice(p, i, p->state, posState);
do
{
- UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][repLen - 2];
+ uint32_t curAndLenPrice = price + p->repLenEnc.prices[posState][repLen - 2];
COptimal *opt = &p->opt[repLen];
if (curAndLenPrice < opt->price)
{
opt->price = curAndLenPrice;
opt->posPrev = 0;
opt->backPrev = i;
- opt->prev1IsChar = False;
+ opt->prev1IsChar = false;
}
}
while (--repLen >= 2);
@@ -1074,21 +1074,21 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2);
if (len <= mainLen)
{
- UInt32 offs = 0;
+ uint32_t offs = 0;
while (len > matches[offs])
offs += 2;
for (; ; len++)
{
COptimal *opt;
- UInt32 distance = matches[offs + 1];
+ uint32_t distance = matches[offs + 1];
- UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN];
- UInt32 lenToPosState = GetLenToPosState(len);
+ uint32_t curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN];
+ uint32_t lenToPosState = GetLenToPosState(len);
if (distance < kNumFullDistances)
curAndLenPrice += p->distancesPrices[lenToPosState][distance];
else
{
- UInt32 slot;
+ uint32_t slot;
GetPosSlot2(distance, slot);
curAndLenPrice += p->alignPrices[distance & kAlignMask] + p->posSlotPrices[lenToPosState][slot];
}
@@ -1098,7 +1098,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
opt->price = curAndLenPrice;
opt->posPrev = 0;
opt->backPrev = distance + LZMA_NUM_REPS;
- opt->prev1IsChar = False;
+ opt->prev1IsChar = false;
}
if (len == matches[offs])
{
@@ -1123,11 +1123,11 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
for (;;)
{
- UInt32 numAvailFull, newLen, numPairs, posPrev, state, posState, startLen;
- UInt32 curPrice, curAnd1Price, matchPrice, repMatchPrice;
- Bool nextIsChar;
- Byte curByte, matchByte;
- const Byte *data;
+ uint32_t numAvailFull, newLen, numPairs, posPrev, state, posState, startLen;
+ uint32_t curPrice, curAnd1Price, matchPrice, repMatchPrice;
+ bool nextIsChar;
+ uint8_t curuint8_t, matchuint8_t;
+ const uint8_t *data;
COptimal *curOpt;
COptimal *nextOpt;
@@ -1136,7 +1136,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
return Backward(p, backRes, cur);
newLen = ReadMatchDistances(p, &numPairs);
- if (newLen >= p->numFastBytes)
+ if (newLen >= p->numFastuint8_ts)
{
p->numPairs = numPairs;
p->longestMatchLength = newLen;
@@ -1171,7 +1171,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
}
else
{
- UInt32 pos;
+ uint32_t pos;
const COptimal *prevOpt;
if (curOpt->prev1IsChar && curOpt->prev2)
{
@@ -1190,7 +1190,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
prevOpt = &p->opt[posPrev];
if (pos < LZMA_NUM_REPS)
{
- UInt32 i;
+ uint32_t i;
reps[0] = prevOpt->backs[pos];
for (i = 1; i <= pos; i++)
reps[i] = prevOpt->backs[i - 1];
@@ -1199,7 +1199,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
}
else
{
- UInt32 i;
+ uint32_t i;
reps[0] = (pos - LZMA_NUM_REPS);
for (i = 1; i < LZMA_NUM_REPS; i++)
reps[i] = prevOpt->backs[i - 1];
@@ -1213,10 +1213,10 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
curOpt->backs[3] = reps[3];
curPrice = curOpt->price;
- nextIsChar = False;
+ nextIsChar = false;
data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
- curByte = *data;
- matchByte = *(data - (reps[0] + 1));
+ curuint8_t = *data;
+ matchuint8_t = *(data - (reps[0] + 1));
posState = (position & p->pbMask);
@@ -1225,8 +1225,8 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
const CLzmaProb *probs = LIT_PROBS(position, *(data - 1));
curAnd1Price +=
(!IsCharState(state) ?
- LitEnc_GetPriceMatched(probs, curByte, matchByte, p->ProbPrices) :
- LitEnc_GetPrice(probs, curByte, p->ProbPrices));
+ LitEnc_GetPriceMatched(probs, curuint8_t, matchuint8_t, p->ProbPrices) :
+ LitEnc_GetPrice(probs, curuint8_t, p->ProbPrices));
}
nextOpt = &p->opt[cur + 1];
@@ -1236,41 +1236,41 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
nextOpt->price = curAnd1Price;
nextOpt->posPrev = cur;
MakeAsChar(nextOpt);
- nextIsChar = True;
+ nextIsChar = true;
}
matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]);
repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]);
- if (matchByte == curByte && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0))
+ if (matchuint8_t == curuint8_t && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0))
{
- UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState);
+ uint32_t shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState);
if (shortRepPrice <= nextOpt->price)
{
nextOpt->price = shortRepPrice;
nextOpt->posPrev = cur;
MakeAsShortRep(nextOpt);
- nextIsChar = True;
+ nextIsChar = true;
}
}
numAvailFull = p->numAvail;
{
- UInt32 temp = kNumOpts - 1 - cur;
+ uint32_t temp = kNumOpts - 1 - cur;
if (temp < numAvailFull)
numAvailFull = temp;
}
if (numAvailFull < 2)
continue;
- numAvail = (numAvailFull <= p->numFastBytes ? numAvailFull : p->numFastBytes);
+ numAvail = (numAvailFull <= p->numFastuint8_ts ? numAvailFull : p->numFastuint8_ts);
- if (!nextIsChar && matchByte != curByte) /* speed optimization */
+ if (!nextIsChar && matchuint8_t != curuint8_t) /* speed optimization */
{
/* try Literal + rep0 */
- UInt32 temp;
- UInt32 lenTest2;
- const Byte *data2 = data - (reps[0] + 1);
- UInt32 limit = p->numFastBytes + 1;
+ uint32_t temp;
+ uint32_t lenTest2;
+ const uint8_t *data2 = data - (reps[0] + 1);
+ uint32_t limit = p->numFastuint8_ts + 1;
if (limit > numAvailFull)
limit = numAvailFull;
@@ -1278,16 +1278,16 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
lenTest2 = temp - 1;
if (lenTest2 >= 2)
{
- UInt32 state2 = kLiteralNextStates[state];
- UInt32 posStateNext = (position + 1) & p->pbMask;
- UInt32 nextRepMatchPrice = curAnd1Price +
+ uint32_t state2 = kLiteralNextStates[state];
+ uint32_t posStateNext = (position + 1) & p->pbMask;
+ uint32_t nextRepMatchPrice = curAnd1Price +
GET_PRICE_1(p->isMatch[state2][posStateNext]) +
GET_PRICE_1(p->isRep[state2]);
/* for (; lenTest2 >= 2; lenTest2--) */
{
- UInt32 curAndLenPrice;
+ uint32_t curAndLenPrice;
COptimal *opt;
- UInt32 offset = cur + 1 + lenTest2;
+ uint32_t offset = cur + 1 + lenTest2;
while (lenEnd < offset)
p->opt[++lenEnd].price = kInfinityPrice;
curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
@@ -1297,8 +1297,8 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
opt->price = curAndLenPrice;
opt->posPrev = cur + 1;
opt->backPrev = 0;
- opt->prev1IsChar = True;
- opt->prev2 = False;
+ opt->prev1IsChar = true;
+ opt->prev2 = false;
}
}
}
@@ -1306,13 +1306,13 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
startLen = 2; /* speed optimization */
{
- UInt32 repIndex;
+ uint32_t repIndex;
for (repIndex = 0; repIndex < LZMA_NUM_REPS; repIndex++)
{
- UInt32 lenTest;
- UInt32 lenTestTemp;
- UInt32 price;
- const Byte *data2 = data - (reps[repIndex] + 1);
+ uint32_t lenTest;
+ uint32_t lenTestTemp;
+ uint32_t price;
+ const uint8_t *data2 = data - (reps[repIndex] + 1);
if (data[0] != data2[0] || data[1] != data2[1])
continue;
for (lenTest = 2; lenTest < numAvail && data[lenTest] == data2[lenTest]; lenTest++);
@@ -1322,14 +1322,14 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
price = repMatchPrice + GetPureRepPrice(p, repIndex, state, posState);
do
{
- UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][lenTest - 2];
+ uint32_t curAndLenPrice = price + p->repLenEnc.prices[posState][lenTest - 2];
COptimal *opt = &p->opt[cur + lenTest];
if (curAndLenPrice < opt->price)
{
opt->price = curAndLenPrice;
opt->posPrev = cur;
opt->backPrev = repIndex;
- opt->prev1IsChar = False;
+ opt->prev1IsChar = false;
}
}
while (--lenTest >= 2);
@@ -1340,18 +1340,18 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
/* if (_maxMode) */
{
- UInt32 lenTest2 = lenTest + 1;
- UInt32 limit = lenTest2 + p->numFastBytes;
- UInt32 nextRepMatchPrice;
+ uint32_t lenTest2 = lenTest + 1;
+ uint32_t limit = lenTest2 + p->numFastuint8_ts;
+ uint32_t nextRepMatchPrice;
if (limit > numAvailFull)
limit = numAvailFull;
for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
lenTest2 -= lenTest + 1;
if (lenTest2 >= 2)
{
- UInt32 state2 = kRepNextStates[state];
- UInt32 posStateNext = (position + lenTest) & p->pbMask;
- UInt32 curAndLenCharPrice =
+ uint32_t state2 = kRepNextStates[state];
+ uint32_t posStateNext = (position + lenTest) & p->pbMask;
+ uint32_t curAndLenCharPrice =
price + p->repLenEnc.prices[posState][lenTest - 2] +
GET_PRICE_0(p->isMatch[state2][posStateNext]) +
LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]),
@@ -1364,9 +1364,9 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
/* for (; lenTest2 >= 2; lenTest2--) */
{
- UInt32 curAndLenPrice;
+ uint32_t curAndLenPrice;
COptimal *opt;
- UInt32 offset = cur + lenTest + 1 + lenTest2;
+ uint32_t offset = cur + lenTest + 1 + lenTest2;
while (lenEnd < offset)
p->opt[++lenEnd].price = kInfinityPrice;
curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
@@ -1376,8 +1376,8 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
opt->price = curAndLenPrice;
opt->posPrev = cur + lenTest + 1;
opt->backPrev = 0;
- opt->prev1IsChar = True;
- opt->prev2 = True;
+ opt->prev1IsChar = true;
+ opt->prev2 = true;
opt->posPrev2 = cur;
opt->backPrev2 = repIndex;
}
@@ -1386,7 +1386,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
}
}
}
- /* for (UInt32 lenTest = 2; lenTest <= newLen; lenTest++) */
+ /* for (uint32_t lenTest = 2; lenTest <= newLen; lenTest++) */
if (newLen > numAvail)
{
newLen = numAvail;
@@ -1396,9 +1396,9 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
}
if (newLen >= startLen)
{
- UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[state]);
- UInt32 offs, curBack, posSlot;
- UInt32 lenTest;
+ uint32_t normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[state]);
+ uint32_t offs, curBack, posSlot;
+ uint32_t lenTest;
while (lenEnd < cur + newLen)
p->opt[++lenEnd].price = kInfinityPrice;
@@ -1409,8 +1409,8 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
GetPosSlot2(curBack, posSlot);
for (lenTest = /*2*/ startLen; ; lenTest++)
{
- UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][lenTest - LZMA_MATCH_LEN_MIN];
- UInt32 lenToPosState = GetLenToPosState(lenTest);
+ uint32_t curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][lenTest - LZMA_MATCH_LEN_MIN];
+ uint32_t lenToPosState = GetLenToPosState(lenTest);
COptimal *opt;
if (curBack < kNumFullDistances)
curAndLenPrice += p->distancesPrices[lenToPosState][curBack];
@@ -1423,25 +1423,25 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
opt->price = curAndLenPrice;
opt->posPrev = cur;
opt->backPrev = curBack + LZMA_NUM_REPS;
- opt->prev1IsChar = False;
+ opt->prev1IsChar = false;
}
if (/*_maxMode && */lenTest == matches[offs])
{
/* Try Match + Literal + Rep0 */
- const Byte *data2 = data - (curBack + 1);
- UInt32 lenTest2 = lenTest + 1;
- UInt32 limit = lenTest2 + p->numFastBytes;
- UInt32 nextRepMatchPrice;
+ const uint8_t *data2 = data - (curBack + 1);
+ uint32_t lenTest2 = lenTest + 1;
+ uint32_t limit = lenTest2 + p->numFastuint8_ts;
+ uint32_t nextRepMatchPrice;
if (limit > numAvailFull)
limit = numAvailFull;
for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
lenTest2 -= lenTest + 1;
if (lenTest2 >= 2)
{
- UInt32 state2 = kMatchNextStates[state];
- UInt32 posStateNext = (position + lenTest) & p->pbMask;
- UInt32 curAndLenCharPrice = curAndLenPrice +
+ uint32_t state2 = kMatchNextStates[state];
+ uint32_t posStateNext = (position + lenTest) & p->pbMask;
+ uint32_t curAndLenCharPrice = curAndLenPrice +
GET_PRICE_0(p->isMatch[state2][posStateNext]) +
LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]),
data[lenTest], data2[lenTest], p->ProbPrices);
@@ -1453,8 +1453,8 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
/* for (; lenTest2 >= 2; lenTest2--) */
{
- UInt32 offset = cur + lenTest + 1 + lenTest2;
- UInt32 curAndLenPrice;
+ uint32_t offset = cur + lenTest + 1 + lenTest2;
+ uint32_t curAndLenPrice;
COptimal *opt;
while (lenEnd < offset)
p->opt[++lenEnd].price = kInfinityPrice;
@@ -1465,8 +1465,8 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
opt->price = curAndLenPrice;
opt->posPrev = cur + lenTest + 1;
opt->backPrev = 0;
- opt->prev1IsChar = True;
- opt->prev2 = True;
+ opt->prev1IsChar = true;
+ opt->prev2 = true;
opt->posPrev2 = cur;
opt->backPrev2 = curBack + LZMA_NUM_REPS;
}
@@ -1486,11 +1486,11 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
#define ChangePair(smallDist, bigDist) (((bigDist) >> 7) > (smallDist))
-static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes)
+static uint32_t GetOptimumFast(CLzmaEnc *p, uint32_t *backRes)
{
- UInt32 numAvail, mainLen, mainDist, numPairs, repIndex, repLen, i;
- const Byte *data;
- const UInt32 *matches;
+ uint32_t numAvail, mainLen, mainDist, numPairs, repIndex, repLen, i;
+ const uint8_t *data;
+ const uint32_t *matches;
if (p->additionalOffset == 0)
mainLen = ReadMatchDistances(p, &numPairs);
@@ -1501,7 +1501,7 @@ static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes)
}
numAvail = p->numAvail;
- *backRes = (UInt32)-1;
+ *backRes = (uint32_t)-1;
if (numAvail < 2)
return 1;
if (numAvail > LZMA_MATCH_LEN_MAX)
@@ -1511,12 +1511,12 @@ static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes)
repLen = repIndex = 0;
for (i = 0; i < LZMA_NUM_REPS; i++)
{
- UInt32 len;
- const Byte *data2 = data - (p->reps[i] + 1);
+ uint32_t len;
+ const uint8_t *data2 = data - (p->reps[i] + 1);
if (data[0] != data2[0] || data[1] != data2[1])
continue;
for (len = 2; len < numAvail && data[len] == data2[len]; len++);
- if (len >= p->numFastBytes)
+ if (len >= p->numFastuint8_ts)
{
*backRes = i;
MovePos(p, len - 1);
@@ -1530,7 +1530,7 @@ static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes)
}
matches = p->matches;
- if (mainLen >= p->numFastBytes)
+ if (mainLen >= p->numFastuint8_ts)
{
*backRes = matches[numPairs - 1] + LZMA_NUM_REPS;
MovePos(p, mainLen - 1);
@@ -1569,7 +1569,7 @@ static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes)
p->longestMatchLength = ReadMatchDistances(p, &p->numPairs);
if (p->longestMatchLength >= 2)
{
- UInt32 newDistance = matches[p->numPairs - 1];
+ uint32_t newDistance = matches[p->numPairs - 1];
if ((p->longestMatchLength >= mainLen && newDistance < mainDist) ||
(p->longestMatchLength == mainLen + 1 && !ChangePair(mainDist, newDistance)) ||
(p->longestMatchLength > mainLen + 1) ||
@@ -1580,8 +1580,8 @@ static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes)
data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;
for (i = 0; i < LZMA_NUM_REPS; i++)
{
- UInt32 len, limit;
- const Byte *data2 = data - (p->reps[i] + 1);
+ uint32_t len, limit;
+ const uint8_t *data2 = data - (p->reps[i] + 1);
if (data[0] != data2[0] || data[1] != data2[1])
continue;
limit = mainLen - 1;
@@ -1594,16 +1594,16 @@ static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes)
return mainLen;
}
-static void WriteEndMarker(CLzmaEnc *p, UInt32 posState)
+static void WriteEndMarker(CLzmaEnc *p, uint32_t posState)
{
- UInt32 len;
+ uint32_t len;
RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1);
RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0);
p->state = kMatchNextStates[p->state];
len = LZMA_MATCH_LEN_MIN;
LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);
RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, (1 << kNumPosSlotBits) - 1);
- RangeEnc_EncodeDirectBits(&p->rc, (((UInt32)1 << 30) - 1) >> kNumAlignBits, 30 - kNumAlignBits);
+ RangeEnc_EncodeDirectBits(&p->rc, (((uint32_t)1 << 30) - 1) >> kNumAlignBits, 30 - kNumAlignBits);
RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask);
}
@@ -1616,14 +1616,14 @@ static SRes CheckErrors(CLzmaEnc *p)
if (p->matchFinderBase.result != SZ_OK)
p->result = SZ_ERROR_READ;
if (p->result != SZ_OK)
- p->finished = True;
+ p->finished = true;
return p->result;
}
-static SRes Flush(CLzmaEnc *p, UInt32 nowPos)
+static SRes Flush(CLzmaEnc *p, uint32_t nowPos)
{
/* ReleaseMFStream(); */
- p->finished = True;
+ p->finished = true;
if (p->writeEndMark)
WriteEndMarker(p, nowPos & p->pbMask);
RangeEnc_FlushData(&p->rc);
@@ -1633,7 +1633,7 @@ static SRes Flush(CLzmaEnc *p, UInt32 nowPos)
static void FillAlignPrices(CLzmaEnc *p)
{
- UInt32 i;
+ uint32_t i;
for (i = 0; i < kAlignTableSize; i++)
p->alignPrices[i] = RcTree_ReverseGetPrice(p->posAlignEncoder, kNumAlignBits, i, p->ProbPrices);
p->alignPriceCount = 0;
@@ -1641,29 +1641,29 @@ static void FillAlignPrices(CLzmaEnc *p)
static void FillDistancesPrices(CLzmaEnc *p)
{
- UInt32 tempPrices[kNumFullDistances];
- UInt32 i, lenToPosState;
+ uint32_t tempPrices[kNumFullDistances];
+ uint32_t i, lenToPosState;
for (i = kStartPosModelIndex; i < kNumFullDistances; i++)
{
- UInt32 posSlot = GetPosSlot1(i);
- UInt32 footerBits = ((posSlot >> 1) - 1);
- UInt32 base = ((2 | (posSlot & 1)) << footerBits);
+ uint32_t posSlot = GetPosSlot1(i);
+ uint32_t footerBits = ((posSlot >> 1) - 1);
+ uint32_t base = ((2 | (posSlot & 1)) << footerBits);
tempPrices[i] = RcTree_ReverseGetPrice(p->posEncoders + base - posSlot - 1, footerBits, i - base, p->ProbPrices);
}
for (lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++)
{
- UInt32 posSlot;
+ uint32_t posSlot;
const CLzmaProb *encoder = p->posSlotEncoder[lenToPosState];
- UInt32 *posSlotPrices = p->posSlotPrices[lenToPosState];
+ uint32_t *posSlotPrices = p->posSlotPrices[lenToPosState];
for (posSlot = 0; posSlot < p->distTableSize; posSlot++)
posSlotPrices[posSlot] = RcTree_GetPrice(encoder, kNumPosSlotBits, posSlot, p->ProbPrices);
for (posSlot = kEndPosModelIndex; posSlot < p->distTableSize; posSlot++)
posSlotPrices[posSlot] += ((((posSlot >> 1) - 1) - kNumAlignBits) << kNumBitPriceShiftBits);
{
- UInt32 *distancesPrices = p->distancesPrices[lenToPosState];
- UInt32 i;
+ uint32_t *distancesPrices = p->distancesPrices[lenToPosState];
+ uint32_t i;
for (i = 0; i < kStartPosModelIndex; i++)
distancesPrices[i] = posSlotPrices[i];
for (; i < kNumFullDistances; i++)
@@ -1730,9 +1730,9 @@ void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig)
alloc->Free(alloc, p);
}
-static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize, UInt32 maxUnpackSize)
+static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, bool useLimits, uint32_t maxPackSize, uint32_t maxUnpackSize)
{
- UInt32 nowPos32, startPos32;
+ uint32_t nowPos32, startPos32;
if (p->needInit)
{
p->matchFinder.Init(p->matchFinderObj);
@@ -1743,20 +1743,20 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
return p->result;
RINOK(CheckErrors(p));
- nowPos32 = (UInt32)p->nowPos64;
+ nowPos32 = (uint32_t)p->nowPos64;
startPos32 = nowPos32;
if (p->nowPos64 == 0)
{
- UInt32 numPairs;
- Byte curByte;
+ uint32_t numPairs;
+ uint8_t curuint8_t;
if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0)
return Flush(p, nowPos32);
ReadMatchDistances(p, &numPairs);
RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][0], 0);
p->state = kLiteralNextStates[p->state];
- curByte = p->matchFinder.GetIndexByte(p->matchFinderObj, 0 - p->additionalOffset);
- LitEnc_Encode(&p->rc, p->litProbs, curByte);
+ curuint8_t = p->matchFinder.GetIndexByte(p->matchFinderObj, 0 - p->additionalOffset);
+ LitEnc_Encode(&p->rc, p->litProbs, curuint8_t);
p->additionalOffset--;
nowPos32++;
}
@@ -1764,7 +1764,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) != 0)
for (;;)
{
- UInt32 pos, len, posState;
+ uint32_t pos, len, posState;
if (p->fastMode)
len = GetOptimumFast(p, &pos);
@@ -1776,20 +1776,20 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
#endif
posState = nowPos32 & p->pbMask;
- if (len == 1 && pos == (UInt32)-1)
+ if (len == 1 && pos == (uint32_t)-1)
{
- Byte curByte;
+ uint8_t curuint8_t;
CLzmaProb *probs;
- const Byte *data;
+ const uint8_t *data;
RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 0);
data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
- curByte = *data;
+ curuint8_t = *data;
probs = LIT_PROBS(nowPos32, *(data - 1));
if (IsCharState(p->state))
- LitEnc_Encode(&p->rc, probs, curByte);
+ LitEnc_Encode(&p->rc, probs, curuint8_t);
else
- LitEnc_EncodeMatched(&p->rc, probs, curByte, *(data - p->reps[0] - 1));
+ LitEnc_EncodeMatched(&p->rc, probs, curuint8_t, *(data - p->reps[0] - 1));
p->state = kLiteralNextStates[p->state];
}
else
@@ -1805,7 +1805,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
}
else
{
- UInt32 distance = p->reps[pos];
+ uint32_t distance = p->reps[pos];
RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 1);
if (pos == 1)
RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 0);
@@ -1830,7 +1830,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
}
else
{
- UInt32 posSlot;
+ uint32_t posSlot;
RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0);
p->state = kMatchNextStates[p->state];
LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);
@@ -1840,9 +1840,9 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
if (posSlot >= kStartPosModelIndex)
{
- UInt32 footerBits = ((posSlot >> 1) - 1);
- UInt32 base = ((2 | (posSlot & 1)) << footerBits);
- UInt32 posReduced = pos - base;
+ uint32_t footerBits = ((posSlot >> 1) - 1);
+ uint32_t base = ((2 | (posSlot & 1)) << footerBits);
+ uint32_t posReduced = pos - base;
if (posSlot < kEndPosModelIndex)
RcTree_ReverseEncode(&p->rc, p->posEncoders + base - posSlot - 1, footerBits, posReduced);
@@ -1864,7 +1864,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
nowPos32 += len;
if (p->additionalOffset == 0)
{
- UInt32 processed;
+ uint32_t processed;
if (!p->fastMode)
{
if (p->matchPriceCount >= (1 << 7))
@@ -1892,13 +1892,13 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
return Flush(p, nowPos32);
}
-#define kBigHashDicLimit ((UInt32)1 << 24)
+#define kBigHashDicLimit ((uint32_t)1 << 24)
-static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
+static SRes LzmaEnc_Alloc(CLzmaEnc *p, uint32_t keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
{
- UInt32 beforeSize = kNumOpts;
+ uint32_t beforeSize = kNumOpts;
#ifndef _7ZIP_ST
- Bool btMode;
+ bool btMode;
#endif
if (!RangeEnc_Alloc(&p->rc, alloc))
return SZ_ERROR_MEM;
@@ -1931,14 +1931,14 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, I
#ifndef _7ZIP_ST
if (p->mtMode)
{
- RINOK(MatchFinderMt_Create(&p->matchFinderMt, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig));
+ RINOK(MatchFinderMt_Create(&p->matchFinderMt, p->dictSize, beforeSize, p->numFastuint8_ts, LZMA_MATCH_LEN_MAX, allocBig));
p->matchFinderObj = &p->matchFinderMt;
MatchFinderMt_CreateVTable(&p->matchFinderMt, &p->matchFinder);
}
else
#endif
{
- if (!MatchFinder_Create(&p->matchFinderBase, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig))
+ if (!MatchFinder_Create(&p->matchFinderBase, p->dictSize, beforeSize, p->numFastuint8_ts, LZMA_MATCH_LEN_MAX, allocBig))
return SZ_ERROR_MEM;
p->matchFinderObj = &p->matchFinderBase;
MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder);
@@ -1948,7 +1948,7 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, I
static void LzmaEnc_Init(CLzmaEnc *p)
{
- UInt32 i;
+ uint32_t i;
p->state = 0;
for (i = 0 ; i < LZMA_NUM_REPS; i++)
p->reps[i] = 0;
@@ -1958,7 +1958,7 @@ static void LzmaEnc_Init(CLzmaEnc *p)
for (i = 0; i < kNumStates; i++)
{
- UInt32 j;
+ uint32_t j;
for (j = 0; j < LZMA_NUM_PB_STATES_MAX; j++)
{
p->isMatch[i][j] = kProbInitValue;
@@ -1971,7 +1971,7 @@ static void LzmaEnc_Init(CLzmaEnc *p)
}
{
- UInt32 num = 0x300 << (p->lp + p->lc);
+ uint32_t num = 0x300 << (p->lp + p->lc);
for (i = 0; i < num; i++)
p->litProbs[i] = kProbInitValue;
}
@@ -1980,7 +1980,7 @@ static void LzmaEnc_Init(CLzmaEnc *p)
for (i = 0; i < kNumLenToPosStates; i++)
{
CLzmaProb *probs = p->posSlotEncoder[i];
- UInt32 j;
+ uint32_t j;
for (j = 0; j < (1 << kNumPosSlotBits); j++)
probs[j] = kProbInitValue;
}
@@ -2014,20 +2014,20 @@ static void LzmaEnc_InitPrices(CLzmaEnc *p)
p->lenEnc.tableSize =
p->repLenEnc.tableSize =
- p->numFastBytes + 1 - LZMA_MATCH_LEN_MIN;
+ p->numFastuint8_ts + 1 - LZMA_MATCH_LEN_MIN;
LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, p->ProbPrices);
LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, p->ProbPrices);
}
-static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
+static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, uint32_t keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
{
- UInt32 i;
- for (i = 0; i < (UInt32)kDicLogSizeMaxCompress; i++)
- if (p->dictSize <= ((UInt32)1 << i))
+ uint32_t i;
+ for (i = 0; i < (uint32_t)kDicLogSizeMaxCompress; i++)
+ if (p->dictSize <= ((uint32_t)1 << i))
break;
p->distTableSize = i * 2;
- p->finished = False;
+ p->finished = false;
p->result = SZ_OK;
RINOK(LzmaEnc_Alloc(p, keepWindowSize, alloc, allocBig));
LzmaEnc_Init(p);
@@ -2047,7 +2047,7 @@ static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInS
}
/*static SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp,
- ISeqInStream *inStream, UInt32 keepWindowSize,
+ ISeqInStream *inStream, uint32_t keepWindowSize,
ISzAlloc *alloc, ISzAlloc *allocBig)
{
CLzmaEnc *p = (CLzmaEnc *)pp;
@@ -2056,15 +2056,15 @@ static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInS
return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
}*/
-static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen)
+static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const uint8_t *src, size_t srcLen)
{
p->matchFinderBase.directInput = 1;
- p->matchFinderBase.bufferBase = (Byte *)src;
+ p->matchFinderBase.bufferBase = (uint8_t *)src;
p->matchFinderBase.directInputRem = srcLen;
}
-static SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
- UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
+static SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const uint8_t *src, size_t srcLen,
+ uint32_t keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
{
CLzmaEnc *p = (CLzmaEnc *)pp;
LzmaEnc_SetInputBuf(p, src, srcLen);
@@ -2087,9 +2087,9 @@ static void LzmaEnc_Finish(CLzmaEncHandle pp)
typedef struct
{
ISeqOutStream funcTable;
- Byte *data;
- SizeT rem;
- Bool overflow;
+ uint8_t *data;
+ size_t rem;
+ bool overflow;
} CSeqOutStreamBuf;
static size_t MyWrite(void *pp, const void *data, size_t size)
@@ -2098,7 +2098,7 @@ static size_t MyWrite(void *pp, const void *data, size_t size)
if (p->rem < size)
{
size = p->rem;
- p->overflow = True;
+ p->overflow = true;
}
memcpy(p->data, data, size);
p->rem -= size;
@@ -2107,33 +2107,33 @@ static size_t MyWrite(void *pp, const void *data, size_t size)
}
-/*static UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
+/*static uint32_t LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
{
const CLzmaEnc *p = (CLzmaEnc *)pp;
return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
}*/
-/*static const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
+/*static const uint8_t *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
{
const CLzmaEnc *p = (CLzmaEnc *)pp;
return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
}*/
-/*static SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
- Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)
+/*static SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, bool reInit,
+ uint8_t *dest, size_t *destLen, uint32_t desiredPackSize, uint32_t *unpackSize)
{
CLzmaEnc *p = (CLzmaEnc *)pp;
- UInt64 nowPos64;
+ uint64_t nowPos64;
SRes res;
CSeqOutStreamBuf outStream;
outStream.funcTable.Write = MyWrite;
outStream.data = dest;
outStream.rem = *destLen;
- outStream.overflow = False;
+ outStream.overflow = false;
- p->writeEndMark = False;
- p->finished = False;
+ p->writeEndMark = false;
+ p->finished = false;
p->result = SZ_OK;
if (reInit)
@@ -2143,9 +2143,9 @@ static size_t MyWrite(void *pp, const void *data, size_t size)
RangeEnc_Init(&p->rc);
p->rc.outStream = &outStream.funcTable;
- res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize);
+ res = LzmaEnc_CodeOneBlock(p, true, desiredPackSize, *unpackSize);
- *unpackSize = (UInt32)(p->nowPos64 - nowPos64);
+ *unpackSize = (uint32_t)(p->nowPos64 - nowPos64);
*destLen -= outStream.rem;
if (outStream.overflow)
return SZ_ERROR_OUTPUT_EOF;
@@ -2158,15 +2158,15 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
SRes res = SZ_OK;
#ifndef _7ZIP_ST
- Byte allocaDummy[0x300];
+ uint8_t allocaDummy[0x300];
int i = 0;
for (i = 0; i < 16; i++)
- allocaDummy[i] = (Byte)i;
+ allocaDummy[i] = (uint8_t)i;
#endif
for (;;)
{
- res = LzmaEnc_CodeOneBlock(p, False, 0, 0);
+ res = LzmaEnc_CodeOneBlock(p, false, 0, 0);
if (res != SZ_OK || p->finished != 0)
break;
if (progress != 0)
@@ -2190,24 +2190,24 @@ SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *i
return LzmaEnc_Encode2((CLzmaEnc *)pp, progress);
}
-SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size)
+SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, uint8_t *props, size_t *size)
{
CLzmaEnc *p = (CLzmaEnc *)pp;
int i;
- UInt32 dictSize = p->dictSize;
+ uint32_t dictSize = p->dictSize;
if (*size < LZMA_PROPS_SIZE)
return SZ_ERROR_PARAM;
*size = LZMA_PROPS_SIZE;
- props[0] = (Byte)((p->pb * 5 + p->lp) * 9 + p->lc);
+ props[0] = (uint8_t)((p->pb * 5 + p->lp) * 9 + p->lc);
for (i = 11; i <= 30; i++)
{
- if (dictSize <= ((UInt32)2 << i))
+ if (dictSize <= ((uint32_t)2 << i))
{
dictSize = (2 << i);
break;
}
- if (dictSize <= ((UInt32)3 << i))
+ if (dictSize <= ((uint32_t)3 << i))
{
dictSize = (3 << i);
break;
@@ -2215,11 +2215,11 @@ SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size)
}
for (i = 0; i < 4; i++)
- props[1 + i] = (Byte)(dictSize >> (8 * i));
+ props[1 + i] = (uint8_t)(dictSize >> (8 * i));
return SZ_OK;
}
-SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
+SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t srcLen,
int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
{
SRes res;
@@ -2232,7 +2232,7 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte
outStream.funcTable.Write = MyWrite;
outStream.data = dest;
outStream.rem = *destLen;
- outStream.overflow = False;
+ outStream.overflow = false;
p->writeEndMark = writeEndMark;
@@ -2247,8 +2247,8 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte
return res;
}
-SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
- const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
+SRes LzmaEncode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t srcLen,
+ const CLzmaEncProps *props, uint8_t *propsEncoded, size_t *propsSize, int writeEndMark,
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
{
CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc);
diff --git a/util/cbfstool/lzma/C/LzmaEnc.h b/util/cbfstool/lzma/C/LzmaEnc.h
index 200d60eb83..7a6cb59a73 100644
--- a/util/cbfstool/lzma/C/LzmaEnc.h
+++ b/util/cbfstool/lzma/C/LzmaEnc.h
@@ -15,7 +15,7 @@ extern "C" {
typedef struct _CLzmaEncProps
{
int level; /* 0 <= level <= 9 */
- UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
+ uint32_t dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
(1 << 12) <= dictSize <= (1 << 30) for 64-bit version
default = (1 << 24) */
int lc; /* 0 <= lc <= 8, default = 3 */
@@ -25,14 +25,14 @@ typedef struct _CLzmaEncProps
int fb; /* 5 <= fb <= 273, default = 32 */
int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
int numHashBytes; /* 2, 3 or 4, default = 4 */
- UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */
+ uint32_t mc; /* 1 <= mc <= (1 << 30), default = 32 */
unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
int numThreads; /* 1 or 2, default = 2 */
} CLzmaEncProps;
void LzmaEncProps_Init(CLzmaEncProps *p);
void LzmaEncProps_Normalize(CLzmaEncProps *p);
-UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
+uint32_t LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
/* ---------- CLzmaEncHandle Interface ---------- */
@@ -52,10 +52,10 @@ typedef void * CLzmaEncHandle;
CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc);
void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
-SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
+SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, uint8_t *properties, size_t *size);
SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
-SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
+SRes LzmaEnc_MemEncode(CLzmaEncHandle p, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t srcLen,
int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
/* ---------- One Call Interface ---------- */
@@ -69,8 +69,8 @@ Return code:
SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
*/
-SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
- const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
+SRes LzmaEncode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t srcLen,
+ const CLzmaEncProps *props, uint8_t *propsEncoded, size_t *propsSize, int writeEndMark,
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
#ifdef __cplusplus
diff --git a/util/cbfstool/lzma/C/Types.h b/util/cbfstool/lzma/C/Types.h
index d7bc78de1d..b761133014 100644
--- a/util/cbfstool/lzma/C/Types.h
+++ b/util/cbfstool/lzma/C/Types.h
@@ -5,6 +5,8 @@
#define __7Z_TYPES_H
#include <stddef.h>
+#include <stdint.h>
+#include <stdbool.h>
#ifdef _WIN32
#include <windows.h>
@@ -52,48 +54,6 @@ typedef int WRes;
#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
#endif
-typedef unsigned char Byte;
-typedef short Int16;
-typedef unsigned short UInt16;
-
-#ifdef _LZMA_UINT32_IS_ULONG
-typedef long Int32;
-typedef unsigned long UInt32;
-#else
-typedef int Int32;
-typedef unsigned int UInt32;
-#endif
-
-#ifdef _SZ_NO_INT_64
-
-/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
- NOTES: Some code will work incorrectly in that case! */
-
-typedef long Int64;
-typedef unsigned long UInt64;
-
-#else
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-typedef __int64 Int64;
-typedef unsigned __int64 UInt64;
-#else
-typedef long long int Int64;
-typedef unsigned long long int UInt64;
-#endif
-
-#endif
-
-#ifdef _LZMA_NO_SYSTEM_SIZE_T
-typedef UInt32 SizeT;
-#else
-typedef size_t SizeT;
-#endif
-
-typedef int Bool;
-#define True 1
-#define False 0
-
#ifdef _WIN32
#define MY_STD_CALL __stdcall
@@ -124,12 +84,12 @@ typedef int Bool;
typedef struct
{
- Byte (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */
+ uint8_t (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */
} IByteIn;
typedef struct
{
- void (*Write)(void *p, Byte b);
+ void (*Write)(void *p, uint8_t b);
} IByteOut;
typedef struct ISeqInStream
@@ -145,7 +105,7 @@ typedef struct ISeqInStream
/* it can return SZ_ERROR_INPUT_EOF */
SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size);
SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType);
-SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf);
+SRes SeqInStream_ReadByte(ISeqInStream *stream, uint8_t *buf);
typedef struct ISeqOutStream
{
@@ -167,7 +127,7 @@ typedef enum
typedef struct
{
SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */
- SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
+ SRes (*Seek)(void *p, int64_t *pos, ESzSeek origin);
} ISeekInStream;
typedef struct
@@ -181,11 +141,11 @@ typedef struct
SRes (*Read)(void *p, void *buf, size_t *size);
/* reads directly (without buffer). It's same as ISeqInStream::Read */
- SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
+ SRes (*Seek)(void *p, int64_t *pos, ESzSeek origin);
} ILookInStream;
SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size);
-SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset);
+SRes LookInStream_SeekTo(ILookInStream *stream, uint64_t offset);
/* reads via ILookInStream::Read */
SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType);
@@ -199,7 +159,7 @@ typedef struct
ISeekInStream *realStream;
size_t pos;
size_t size;
- Byte buf[LookToRead_BUF_SIZE];
+ uint8_t buf[LookToRead_BUF_SIZE];
} CLookToRead;
void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
@@ -223,9 +183,9 @@ void SecToRead_CreateVTable(CSecToRead *p);
typedef struct
{
- SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);
+ SRes (*Progress)(void *p, uint64_t inSize, uint64_t outSize);
/* Returns: result. (result != SZ_OK) means break.
- Value (UInt64)(Int64)-1 for size means unknown value. */
+ Value (uint64_t)(int64_t)-1 for size means unknown value. */
} ICompressProgress;
typedef struct
diff --git a/util/cbfstool/lzma/lzma.c b/util/cbfstool/lzma/lzma.c
index 579784eae0..f889946690 100644
--- a/util/cbfstool/lzma/lzma.c
+++ b/util/cbfstool/lzma/lzma.c
@@ -186,9 +186,9 @@ void do_lzma_uncompress(char *dst, int dst_len, char *src, int src_len)
size_t destlen = out_sizemax;
size_t srclen = src_len - (LZMA_PROPS_SIZE + 8);
- int res = LzmaDecode((Byte *) dst, &destlen,
- (Byte *) &src[LZMA_PROPS_SIZE + 8], &srclen,
- (Byte *) &src[0], LZMA_PROPS_SIZE,
+ int res = LzmaDecode((uint8_t *) dst, &destlen,
+ (uint8_t *) &src[LZMA_PROPS_SIZE + 8], &srclen,
+ (uint8_t *) &src[0], LZMA_PROPS_SIZE,
LZMA_FINISH_END,
&status,
&LZMAalloc);