diff options
Diffstat (limited to 'src/lib/lib7z')
39 files changed, 210 insertions, 210 deletions
diff --git a/src/lib/lib7z/7z.h b/src/lib/lib7z/7z.h index 01c4cac6a7b..91c8b3ff021 100644 --- a/src/lib/lib7z/7z.h +++ b/src/lib/lib7z/7z.h @@ -136,17 +136,17 @@ void SzAr_Free(CSzAr *p, ISzAlloc *alloc); *outBufferSize You can consider "*outBuffer" as cache of solid block. If your archive is solid, it will increase decompression speed. - + If you use external function, you can declare these 3 cache variables (blockIndex, outBuffer, outBufferSize) as static in that external function. - + Free *outBuffer and set *outBuffer to 0, if you want to flush cache. */ typedef struct { CSzAr db; - + UInt64 startPosAfterHeader; UInt64 dataPos; diff --git a/src/lib/lib7z/7zCrc.c b/src/lib/lib7z/7zCrc.c index cd94201be97..d82bc7ec5af 100644 --- a/src/lib/lib7z/7zCrc.c +++ b/src/lib/lib7z/7zCrc.c @@ -52,11 +52,11 @@ void MY_FAST_CALL CrcGenerateTable() UInt32 r = g_CrcTable[i - 256]; g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8); } - + #ifdef MY_CPU_LE g_CrcUpdate = CrcUpdateT4; - + #if CRC_NUM_TABLES == 8 if (!CPU_Is_InOrder()) g_CrcUpdate = CrcUpdateT8; diff --git a/src/lib/lib7z/7zIn.c b/src/lib/lib7z/7zIn.c index ec93a43ffec..d7256dde718 100644 --- a/src/lib/lib7z/7zIn.c +++ b/src/lib/lib7z/7zIn.c @@ -537,12 +537,12 @@ static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) { UInt32 numCoders, numBindPairs, numPackStreams, i; UInt32 numInStreams = 0, numOutStreams = 0; - + RINOK(SzReadNumber32(sd, &numCoders)); if (numCoders > NUM_FOLDER_CODERS_MAX) return SZ_ERROR_UNSUPPORTED; folder->NumCoders = numCoders; - + MY_ALLOC(CSzCoderInfo, folder->Coders, (size_t)numCoders, alloc); for (i = 0; i < numCoders; i++) @@ -810,7 +810,7 @@ static SRes SzReadSubStreamsInfo( numDigests += numSubstreams; } - + si = 0; for (;;) { @@ -963,8 +963,8 @@ static SRes SzReadHeader2( RINOK(SzReadArchiveProperties(sd)); RINOK(SzReadID(sd, &type)); } - - + + if (type == k7zIdMainStreamsInfo) { RINOK(SzReadStreamsInfo(sd, @@ -982,7 +982,7 @@ static SRes SzReadHeader2( return SZ_OK; if (type != k7zIdFilesInfo) return SZ_ERROR_ARCHIVE; - + RINOK(SzReadNumber32(sd, &numFiles)); p->db.NumFiles = numFiles; @@ -1165,19 +1165,19 @@ static SRes SzReadAndDecodePackedStreams2( RINOK(SzReadStreamsInfo(sd, &dataStartPos, p, &numUnpackStreams, unpackSizes, digestsDefined, digests, allocTemp, allocTemp)); - + dataStartPos += baseOffset; if (p->NumFolders != 1) return SZ_ERROR_ARCHIVE; folder = p->Folders; unpackSize = SzFolder_GetUnpackSize(folder); - + RINOK(LookInStream_SeekTo(inStream, dataStartPos)); if (!Buf_Create(outBuffer, (size_t)unpackSize, allocTemp)) return SZ_ERROR_MEM; - + res = SzFolder_Decode(folder, p->PackSizes, inStream, dataStartPos, outBuffer->data, (size_t)unpackSize, allocTemp); @@ -1240,7 +1240,7 @@ static SRes SzArEx_Open2( nextHeaderCRC = GetUi32(header + 28); p->startPosAfterHeader = startArcPos + k7zStartHeaderSize; - + if (CrcCalc(header + 12, 20) != GetUi32(header + 8)) return SZ_ERROR_CRC; @@ -1356,9 +1356,9 @@ SRes SzArEx_Extract( *blockIndex = folderIndex; IAlloc_Free(allocMain, *outBuffer); *outBuffer = 0; - + RINOK(LookInStream_SeekTo(inStream, startOffset)); - + if (res == SZ_OK) { *outBufferSize = unpackSize; diff --git a/src/lib/lib7z/Aes.c b/src/lib/lib7z/Aes.c index e7221cd2b2e..2bdfc9b9af9 100644 --- a/src/lib/lib7z/Aes.c +++ b/src/lib/lib7z/Aes.c @@ -228,9 +228,9 @@ void MY_FAST_CALL AesCbc_Encode(UInt32 *p, Byte *data, size_t numBlocks) p[1] ^= GetUi32(data + 4); p[2] ^= GetUi32(data + 8); p[3] ^= GetUi32(data + 12); - + Aes_Encode(p + 4, p, p); - + SetUi32(data, p[0]); SetUi32(data + 4, p[1]); SetUi32(data + 8, p[2]); @@ -254,7 +254,7 @@ void MY_FAST_CALL AesCbc_Decode(UInt32 *p, Byte *data, size_t numBlocks) SetUi32(data + 4, p[1] ^ out[1]); SetUi32(data + 8, p[2] ^ out[2]); SetUi32(data + 12, p[3] ^ out[3]); - + p[0] = in[0]; p[1] = in[1]; p[2] = in[2]; diff --git a/src/lib/lib7z/Alloc.c b/src/lib/lib7z/Alloc.c index df7412afe79..651ada46961 100644 --- a/src/lib/lib7z/Alloc.c +++ b/src/lib/lib7z/Alloc.c @@ -99,7 +99,7 @@ void *BigAlloc(size_t size) #ifdef _SZ_ALLOC_DEBUG fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++); #endif - + #ifdef _7ZIP_LARGE_PAGES if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18)) { @@ -118,7 +118,7 @@ void BigFree(void *address) if (address != 0) fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig); #endif - + if (address == 0) return; VirtualFree(address, 0, MEM_RELEASE); diff --git a/src/lib/lib7z/Bra.c b/src/lib/lib7z/Bra.c index 2e47b1413c1..e78e6f97b37 100644 --- a/src/lib/lib7z/Bra.c +++ b/src/lib/lib7z/Bra.c @@ -48,14 +48,14 @@ SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) ((UInt32)data[i + 0] << 11) | (((UInt32)data[i + 3] & 0x7) << 8) | (data[i + 2]); - + src <<= 1; if (encoding) dest = ip + (UInt32)i + src; else dest = src - (ip + (UInt32)i); dest >>= 1; - + data[i + 1] = (Byte)(0xF0 | ((dest >> 19) & 0x7)); data[i + 0] = (Byte)(dest >> 11); data[i + 3] = (Byte)(0xF8 | ((dest >> 8) & 0x7)); @@ -80,7 +80,7 @@ SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) ((UInt32)data[i + 1] << 16) | ((UInt32)data[i + 2] << 8) | ((UInt32)data[i + 3] & (~3)); - + UInt32 dest; if (encoding) dest = ip + (UInt32)i + src; @@ -113,14 +113,14 @@ SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) ((UInt32)data[i + 2] << 8) | ((UInt32)data[i + 3]); UInt32 dest; - + src <<= 2; if (encoding) dest = ip + i + src; else dest = src - (ip + i); dest >>= 2; - + dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000; data[i + 0] = (Byte)(dest >> 24); diff --git a/src/lib/lib7z/Bra.h b/src/lib/lib7z/Bra.h index 5748c1c051d..aac20a6961d 100644 --- a/src/lib/lib7z/Bra.h +++ b/src/lib/lib7z/Bra.h @@ -13,23 +13,23 @@ extern "C" { /* These functions convert relative addresses to absolute addresses in CALL instructions to increase the compression ratio. - + In: data - data buffer size - size of data ip - current virtual Instruction Pinter (IP) value state - state variable for x86 converter encoding - 0 (for decoding), 1 (for encoding) - + Out: state - state variable for x86 converter Returns: The number of processed bytes. If you call these functions with multiple calls, you must start next call with first byte after block of processed bytes. - + Type Endian Alignment LookAhead - + x86 little 1 4 ARMT little 2 2 ARM little 4 0 diff --git a/src/lib/lib7z/BraIA64.c b/src/lib/lib7z/BraIA64.c index 0b4ee85bc76..07fa7ba40fa 100644 --- a/src/lib/lib7z/BraIA64.c +++ b/src/lib/lib7z/BraIA64.c @@ -42,20 +42,20 @@ SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) UInt32 src = (UInt32)((instNorm >> 13) & 0xFFFFF); UInt32 dest; src |= ((UInt32)(instNorm >> 36) & 1) << 20; - + src <<= 4; - + if (encoding) dest = ip + (UInt32)i + src; else dest = src - (ip + (UInt32)i); - + dest >>= 4; - + instNorm &= ~((UInt64)(0x8FFFFF) << 13); instNorm |= ((UInt64)(dest & 0xFFFFF) << 13); instNorm |= ((UInt64)(dest & 0x100000) << (36 - 20)); - + instruction &= (1 << bitRes) - 1; instruction |= (instNorm << bitRes); for (j = 0; j < 6; j++) diff --git a/src/lib/lib7z/BwtSort.c b/src/lib/lib7z/BwtSort.c index 207305072d7..482f41285f0 100644 --- a/src/lib/lib7z/BwtSort.c +++ b/src/lib/lib7z/BwtSort.c @@ -96,7 +96,7 @@ UInt32 NO_INLINE SortGroup(UInt32 BlockSize, UInt32 NumSortedBytes, UInt32 group gPrev = Groups[sp]; temp[0] = (gPrev << NumRefBits); } - + for (j = 1; j < groupSize; j++) { UInt32 sp = ind2[j] + NumSortedBytes; @@ -114,11 +114,11 @@ UInt32 NO_INLINE SortGroup(UInt32 BlockSize, UInt32 NumSortedBytes, UInt32 group return 1; } } - + HeapSort(temp, groupSize); mask = ((1 << NumRefBits) - 1); thereAreGroups = 0; - + group = groupOffset; cg = (temp[0] >> NumRefBits); temp[0] = ind2[temp[0] & mask]; @@ -129,12 +129,12 @@ UInt32 NO_INLINE SortGroup(UInt32 BlockSize, UInt32 NumSortedBytes, UInt32 group #else UInt32 prevGroupStart = 0; #endif - + for (j = 1; j < groupSize; j++) { UInt32 val = temp[j]; UInt32 cgCur = (val >> NumRefBits); - + if (cgCur != cg) { cg = cgCur; @@ -398,7 +398,7 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize) for (i = 0; i < blockSize - 1; i++) Indices[counters[((UInt32)data[i] << 8) | data[i + 1]]++] = i; Indices[counters[((UInt32)data[i] << 8) | data[0]]++] = i; - + #ifndef BLOCK_SORT_EXTERNAL_FLAGS { UInt32 prev = 0; @@ -441,7 +441,7 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize) for (groupSize = 1; (Flags[(i + groupSize) >> kNumFlagsBits] & (1 << ((i + groupSize) & kFlagsMask))) != 0; groupSize++); - + groupSize++; #else @@ -473,7 +473,7 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize) } #endif - + if (NumSortedBytes >= blockSize) { UInt32 j; diff --git a/src/lib/lib7z/CpuArch.c b/src/lib/lib7z/CpuArch.c index 787af6e62fc..2896300d235 100644 --- a/src/lib/lib7z/CpuArch.c +++ b/src/lib/lib7z/CpuArch.c @@ -81,7 +81,7 @@ static void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d) : "0" (function)) ; #endif - + #else int CPUInfo[4]; diff --git a/src/lib/lib7z/HuffEnc.c b/src/lib/lib7z/HuffEnc.c index 561c7e5da82..9e6a139506f 100644 --- a/src/lib/lib7z/HuffEnc.c +++ b/src/lib/lib7z/HuffEnc.c @@ -18,9 +18,9 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb /* if (maxLen > 10) maxLen = 10; */ { UInt32 i; - + #ifdef HUFFMAN_SPEED_OPT - + UInt32 counters[NUM_COUNTERS]; for (i = 0; i < NUM_COUNTERS; i++) counters[i] = 0; @@ -29,7 +29,7 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb UInt32 freq = freqs[i]; counters[(freq < NUM_COUNTERS - 1) ? freq : NUM_COUNTERS - 1]++; } - + for (i = 1; i < NUM_COUNTERS; i++) { UInt32 temp = counters[i]; @@ -47,7 +47,7 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb } counters[0] = 0; HeapSort(p + counters[NUM_COUNTERS - 2], counters[NUM_COUNTERS - 1] - counters[NUM_COUNTERS - 2]); - + #else for (i = 0; i < numSymbols; i++) @@ -78,10 +78,10 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb lens[minCode] = lens[maxCode] = 1; return; } - + { UInt32 b, e, i; - + i = b = e = 0; do { @@ -96,12 +96,12 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb e++; } while (num - e > 1); - + { UInt32 lenCounters[kMaxLen + 1]; for (i = 0; i <= kMaxLen; i++) lenCounters[i] = 0; - + p[--e] &= MASK; lenCounters[1] = 2; while (e > 0) @@ -113,7 +113,7 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb lenCounters[len]--; lenCounters[len + 1] += 2; } - + { UInt32 len; i = 0; @@ -124,7 +124,7 @@ void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 numSymb lens[p[i++] & MASK] = (Byte)len; } } - + { UInt32 nextCodes[kMaxLen + 1]; { diff --git a/src/lib/lib7z/HuffEnc.h b/src/lib/lib7z/HuffEnc.h index 9cf4bfde817..d0aa13cdc8d 100644 --- a/src/lib/lib7z/HuffEnc.h +++ b/src/lib/lib7z/HuffEnc.h @@ -17,7 +17,7 @@ Conditions: maxLen <= 16 = kMaxLen Num_Items(p) >= HUFFMAN_TEMP_SIZE(num) */ - + void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 num, UInt32 maxLen); #ifdef __cplusplus diff --git a/src/lib/lib7z/LzFind.c b/src/lib/lib7z/LzFind.c index e3ecb05420e..e753d04c692 100644 --- a/src/lib/lib7z/LzFind.c +++ b/src/lib/lib7z/LzFind.c @@ -512,7 +512,7 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) delta2 = p->pos - p->hash[hash2Value]; curMatch = p->hash[kFix3HashSize + hashValue]; - + p->hash[hash2Value] = p->hash[kFix3HashSize + hashValue] = p->pos; @@ -546,7 +546,7 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) delta2 = p->pos - p->hash[ hash2Value]; delta3 = p->pos - p->hash[kFix3HashSize + hash3Value]; curMatch = p->hash[kFix4HashSize + hashValue]; - + p->hash[ hash2Value] = p->hash[kFix3HashSize + hash3Value] = p->hash[kFix4HashSize + hashValue] = p->pos; diff --git a/src/lib/lib7z/LzFindMt.c b/src/lib/lib7z/LzFindMt.c index aa41ed98a57..0f7b314f4c5 100644 --- a/src/lib/lib7z/LzFindMt.c +++ b/src/lib/lib7z/LzFindMt.c @@ -58,7 +58,7 @@ void MtSync_StopWriting(CMtSync *p) p->csWasEntered = False; } Semaphore_Release1(&p->freeSemaphore); - + Event_Wait(&p->wasStopped); while (myNumBlocks++ != p->numProcessedBlocks) @@ -108,12 +108,12 @@ static SRes MtSync_Create2(CMtSync *p, unsigned (MY_STD_CALL *startAddress)(void RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->canStart)); RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStarted)); RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStopped)); - + RINOK_THREAD(Semaphore_Create(&p->freeSemaphore, numBlocks, numBlocks)); RINOK_THREAD(Semaphore_Create(&p->filledSemaphore, 0, numBlocks)); p->needStart = True; - + RINOK_THREAD(Thread_Create(&p->thread, startAddress, obj)); p->wasCreated = True; return SZ_OK; @@ -385,7 +385,7 @@ void BtFillBlock(CMatchFinderMt *p, UInt32 globalBlockIndex) CriticalSection_Enter(&sync->cs); sync->csWasEntered = True; } - + BtGetMatches(p, p->btBuf + (globalBlockIndex & kMtBtNumBlocksMask) * kMtBtBlockSize); if (p->pos > kMtMaxValForNormalize - kMtBtBlockSize) @@ -561,7 +561,7 @@ UInt32 * MixMatches2(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances) const Byte *cur = p->pointerToCurPos; UInt32 lzPos = p->lzPos; MT_HASH2_CALC - + curMatch2 = hash[hash2Value]; hash[hash2Value] = lzPos; @@ -584,7 +584,7 @@ UInt32 * MixMatches3(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances) curMatch2 = hash[ hash2Value]; curMatch3 = hash[kFix3HashSize + hash3Value]; - + hash[ hash2Value] = hash[kFix3HashSize + hash3Value] = lzPos; @@ -616,11 +616,11 @@ UInt32 *MixMatches4(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances) const Byte *cur = p->pointerToCurPos; UInt32 lzPos = p->lzPos; MT_HASH4_CALC - + curMatch2 = hash[ hash2Value]; curMatch3 = hash[kFix3HashSize + hash3Value]; curMatch4 = hash[kFix4HashSize + hash4Value]; - + hash[ hash2Value] = hash[kFix3HashSize + hash3Value] = hash[kFix4HashSize + hash4Value] = diff --git a/src/lib/lib7z/LzFindMt.h b/src/lib/lib7z/LzFindMt.h index b985af5fee2..63133b1b909 100644 --- a/src/lib/lib7z/LzFindMt.h +++ b/src/lib/lib7z/LzFindMt.h @@ -62,7 +62,7 @@ typedef struct _CMatchFinderMt const UInt32 *crc; Mf_Mix_Matches MixMatchesFunc; - + /* LZ + BT */ CMtSync btSync; Byte btDummy[kMtCacheLineDummy]; @@ -85,7 +85,7 @@ typedef struct _CMatchFinderMt /* BT + Hash */ CMtSync hashSync; /* Byte hashDummy[kMtCacheLineDummy]; */ - + /* Hash */ Mf_GetHeads GetHeadsFunc; CMatchFinder *MatchFinder; diff --git a/src/lib/lib7z/Lzma2Dec.c b/src/lib/lib7z/Lzma2Dec.c index f3a6b821daf..d2f8c8884c9 100644 --- a/src/lib/lib7z/Lzma2Dec.c +++ b/src/lib/lib7z/Lzma2Dec.c @@ -114,17 +114,17 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b) else p->unpackSize = (UInt32)(p->control & 0x1F) << 16; return LZMA2_STATE_UNPACK0; - + case LZMA2_STATE_UNPACK0: p->unpackSize |= (UInt32)b << 8; return LZMA2_STATE_UNPACK1; - + case LZMA2_STATE_UNPACK1: p->unpackSize |= (UInt32)b; p->unpackSize++; PRF(printf(" %8d", p->unpackSize)); return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0; - + case LZMA2_STATE_PACK0: p->packSize = (UInt32)b << 8; return LZMA2_STATE_PACK1; @@ -199,7 +199,7 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, SizeT destSizeCur = dicLimit - dicPos; SizeT srcSizeCur = inSize - *srcLen; ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY; - + if (p->unpackSize <= destSizeCur) { destSizeCur = (SizeT)p->unpackSize; @@ -250,7 +250,7 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, Bool initState = (mode > 0); if ((!initDic && p->needInitDic) || (!initState && p->needInitState)) return SZ_ERROR_DATA; - + LzmaDec_InitDicAndState(&p->decoder, initDic, initState); p->needInitDic = False; p->needInitState = False; @@ -258,9 +258,9 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, } if (srcSizeCur > p->packSize) srcSizeCur = (SizeT)p->packSize; - + res = LzmaDec_DecodeToDic(&p->decoder, dicPos + destSizeCur, src, &srcSizeCur, curFinishMode, status); - + src += srcSizeCur; *srcLen += srcSizeCur; p->packSize -= (UInt32)srcSizeCur; diff --git a/src/lib/lib7z/Lzma2Enc.c b/src/lib/lib7z/Lzma2Enc.c index e97597f63d5..86869551668 100644 --- a/src/lib/lib7z/Lzma2Enc.c +++ b/src/lib/lib7z/Lzma2Enc.c @@ -83,11 +83,11 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf, if (packSize < lzHeaderSize) return SZ_ERROR_OUTPUT_EOF; packSize -= lzHeaderSize; - + LzmaEnc_SaveState(p->enc); res = LzmaEnc_CodeOneMemBlock(p->enc, p->needInitState, outBuf + lzHeaderSize, &packSize, LZMA2_PACK_SIZE_MAX, &unpackSize); - + PRF(printf("\npackSize = %7d unpackSize = %7d ", packSize, unpackSize)); if (unpackSize == 0) @@ -146,10 +146,10 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf, outBuf[destPos++] = (Byte)u; outBuf[destPos++] = (Byte)(pm >> 8); outBuf[destPos++] = (Byte)pm; - + if (p->needInitProp) outBuf[destPos++] = p->props; - + p->needInitProp = False; p->needInitState = False; destPos += packSize; @@ -244,7 +244,7 @@ typedef struct { Byte propEncoded; CLzma2EncProps props; - + Byte *outBuf; ISzAlloc *alloc; @@ -322,10 +322,10 @@ static SRes MtCallbackImp_Code(void *pp, unsigned index, Byte *dest, size_t *des if (srcSize != 0) { RINOK(Lzma2EncInt_Init(p, &mainEncoder->props)); - + RINOK(LzmaEnc_MemPrepare(p->enc, src, srcSize, LZMA2_KEEP_WINDOW_SIZE, mainEncoder->alloc, mainEncoder->allocBig)); - + while (p->srcPos < srcSize) { size_t packSize = destLim - *destSize; @@ -460,7 +460,7 @@ SRes Lzma2Enc_Encode(CLzma2EncHandle pp, mtCallback.funcTable.Code = MtCallbackImp_Code; mtCallback.lzma2Enc = p; - + p->mtCoder.progress = progress; p->mtCoder.inStream = inStream; p->mtCoder.outStream = outStream; @@ -470,7 +470,7 @@ SRes Lzma2Enc_Encode(CLzma2EncHandle pp, p->mtCoder.blockSize = p->props.blockSize; p->mtCoder.destBlockSize = p->props.blockSize + (p->props.blockSize >> 10) + 16; p->mtCoder.numThreads = p->props.numBlockThreads; - + return MtCoder_Code(&p->mtCoder); } #endif diff --git a/src/lib/lib7z/Lzma86Enc.c b/src/lib/lib7z/Lzma86Enc.c index 2ea4ac2da45..45b96b68e43 100644 --- a/src/lib/lib7z/Lzma86Enc.c +++ b/src/lib/lib7z/Lzma86Enc.c @@ -26,7 +26,7 @@ int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen, LzmaEncProps_Init(&props); props.level = level; props.dictSize = dictSize; - + *destLen = 0; if (outSize2 < LZMA86_HEADER_SIZE) return SZ_ERROR_OUTPUT_EOF; @@ -78,12 +78,12 @@ int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen, break; if (useFilter && i == 0) curModeIsFiltered = True; - + curRes = LzmaEncode(dest + LZMA86_HEADER_SIZE, &outSizeProcessed, curModeIsFiltered ? filteredStream : src, srcLen, &props, dest + 1, &outPropsSize, 0, NULL, &g_Alloc, &g_Alloc); - + if (curRes != SZ_ERROR_OUTPUT_EOF) { if (curRes != SZ_OK) diff --git a/src/lib/lib7z/LzmaDec.c b/src/lib/lib7z/LzmaDec.c index a85edb7dfd0..14d0f2d3250 100644 --- a/src/lib/lib7z/LzmaDec.c +++ b/src/lib/lib7z/LzmaDec.c @@ -141,7 +141,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte Byte *dic = p->dic; SizeT dicBufSize = p->dicBufSize; SizeT dicPos = p->dicPos; - + UInt32 processedPos = p->processedPos; UInt32 checkDicSize = p->checkDicSize; unsigned len = 0; @@ -324,7 +324,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte { NORMALIZE range >>= 1; - + { UInt32 t; code -= range; @@ -723,7 +723,7 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr SizeT inSize = *srcLen; (*srcLen) = 0; LzmaDec_WriteRem(p, dicLimit); - + *status = LZMA_STATUS_NOT_SPECIFIED; while (p->remainLen != kMatchSpecLenStart) @@ -769,7 +769,7 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr if (p->needInitState) LzmaDec_InitStateReal(p); - + if (p->tempBufSize == 0) { SizeT processed; @@ -900,12 +900,12 @@ SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) { UInt32 dicSize; Byte 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); - + if (dicSize < LZMA_DIC_MIN) dicSize = LZMA_DIC_MIN; p->dicSize = dicSize; diff --git a/src/lib/lib7z/LzmaDec.h b/src/lib/lib7z/LzmaDec.h index bf7f084ba3d..7927acd0d4e 100644 --- a/src/lib/lib7z/LzmaDec.h +++ b/src/lib/lib7z/LzmaDec.h @@ -130,7 +130,7 @@ LzmaDec_Allocate* can return: SZ_ERROR_MEM - Memory allocation error SZ_ERROR_UNSUPPORTED - Unsupported properties */ - + SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc); void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc); @@ -159,7 +159,7 @@ void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc); */ /* LzmaDec_DecodeToDic - + The decoding to internal dictionary buffer (CLzmaDec::dic). You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!! diff --git a/src/lib/lib7z/LzmaEnc.c b/src/lib/lib7z/LzmaEnc.c index ef26e0cfdbd..17d63f38cd2 100644 --- a/src/lib/lib7z/LzmaEnc.c +++ b/src/lib/lib7z/LzmaEnc.c @@ -119,7 +119,7 @@ void LzmaEnc_FastPosInit(Byte *g_FastPos) int c = 2, slotFast; g_FastPos[0] = 0; g_FastPos[1] = 1; - + for (slotFast = 2; slotFast < kNumLogBits * 2; slotFast++) { UInt32 k = (1 << ((slotFast >> 1) - 1)); @@ -256,7 +256,7 @@ typedef struct CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; CLzmaProb posAlignEncoder[1 << kNumAlignBits]; - + CLenPriceEnc lenEnc; CLenPriceEnc repLenEnc; @@ -279,7 +279,7 @@ typedef struct #ifndef _7ZIP_ST Byte pad[128]; #endif - + UInt32 optimumEndIndex; UInt32 optimumCurrentIndex; @@ -287,7 +287,7 @@ typedef struct UInt32 numPairs; UInt32 numAvail; COptimal opt[kNumOpts]; - + #ifndef LZMA_LOG_BSR Byte g_FastPos[1 << kNumLogBits]; #endif @@ -321,14 +321,14 @@ typedef struct CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; CLzmaProb posAlignEncoder[1 << kNumAlignBits]; - + CLenPriceEnc lenEnc; CLenPriceEnc repLenEnc; unsigned lclp; Bool fastMode; - + CRangeEnc rc; Bool writeEndMark; @@ -917,10 +917,10 @@ static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur) { UInt32 posPrev = posMem; UInt32 backCur = backMem; - + backMem = p->opt[posPrev].backPrev; posMem = p->opt[posPrev].posPrev; - + p->opt[posPrev].backPrev = backCur; p->opt[posPrev].posPrev = cur; cur = posPrev; @@ -951,7 +951,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) return lenRes; } p->optimumCurrentIndex = p->optimumEndIndex = 0; - + if (p->additionalOffset == 0) mainLen = ReadMatchDistances(p, &numPairs); else @@ -1249,7 +1249,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) 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)) { UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState); @@ -1311,7 +1311,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) } } } - + startLen = 2; /* speed optimization */ { UInt32 repIndex; @@ -1342,10 +1342,10 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) } while (--lenTest >= 2); lenTest = lenTestTemp; - + if (repIndex == 0) startLen = lenTest + 1; - + /* if (_maxMode) */ { UInt32 lenTest2 = lenTest + 1; @@ -1369,7 +1369,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) nextRepMatchPrice = curAndLenCharPrice + GET_PRICE_1(p->isMatch[state2][posStateNext]) + GET_PRICE_1(p->isRep[state2]); - + /* for (; lenTest2 >= 2; lenTest2--) */ { UInt32 curAndLenPrice; @@ -1424,7 +1424,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) curAndLenPrice += p->distancesPrices[lenToPosState][curBack]; else curAndLenPrice += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[curBack & kAlignMask]; - + opt = &p->opt[cur + lenTest]; if (curAndLenPrice < opt->price) { @@ -1458,7 +1458,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) nextRepMatchPrice = curAndLenCharPrice + GET_PRICE_1(p->isMatch[state2][posStateNext]) + GET_PRICE_1(p->isRep[state2]); - + /* for (; lenTest2 >= 2; lenTest2--) */ { UInt32 offset = cur + lenTest + 1 + lenTest2; @@ -1570,7 +1570,7 @@ static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes) MovePos(p, repLen - 1); return repLen; } - + if (mainLen < 2 || numAvail <= 2) return 1; @@ -1584,7 +1584,7 @@ static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes) (p->longestMatchLength + 1 >= mainLen && mainLen >= 3 && ChangePair(newDistance, mainDist))) return 1; } - + data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; for (i = 0; i < LZMA_NUM_REPS; i++) { @@ -1845,7 +1845,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize pos -= LZMA_NUM_REPS; GetPosSlot(pos, posSlot); RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot); - + if (posSlot >= kStartPosModelIndex) { UInt32 footerBits = ((posSlot >> 1) - 1); @@ -2150,7 +2150,7 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, p->rc.outStream = &outStream.funcTable; res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize); - + *unpackSize = (UInt32)(p->nowPos64 - nowPos64); *destLen -= outStream.rem; if (outStream.overflow) diff --git a/src/lib/lib7z/LzmaLib.h b/src/lib/lib7z/LzmaLib.h index 76c99ce758d..2a3efe161c1 100644 --- a/src/lib/lib7z/LzmaLib.h +++ b/src/lib/lib7z/LzmaLib.h @@ -38,7 +38,7 @@ outPropsSize - LZMA Encoder will use defult values for any parameter, if it is -1 for any from: level, loc, lp, pb, fb, numThreads 0 for dictSize - + level - compression level: 0 <= level <= 9; level dictSize algo fb @@ -50,7 +50,7 @@ level - compression level: 0 <= level <= 9; 5: 16 MB 1 32 6: 32 MB 1 32 7+: 64 MB 1 64 - + The default value for "level" is 5. algo = 0 means fast method diff --git a/src/lib/lib7z/MtCoder.c b/src/lib/lib7z/MtCoder.c index 946fbbc7076..c6a992a64ba 100644 --- a/src/lib/lib7z/MtCoder.c +++ b/src/lib/lib7z/MtCoder.c @@ -190,9 +190,9 @@ static SRes MtThread_Process(CMtThread *p, Bool *stop) *stop = True; if (Event_Wait(&p->canRead) != 0) return SZ_ERROR_THREAD; - + next = GET_NEXT_THREAD(p); - + if (p->stopReading) { next->stopReading = True; diff --git a/src/lib/lib7z/MtCoder.h b/src/lib/lib7z/MtCoder.h index f0f06da281f..e2cbdc3ab2e 100644 --- a/src/lib/lib7z/MtCoder.h +++ b/src/lib/lib7z/MtCoder.h @@ -14,7 +14,7 @@ typedef struct CAutoResetEvent startEvent; CAutoResetEvent finishedEvent; int stop; - + THREAD_FUNC_TYPE func; LPVOID param; THREAD_FUNC_RET_TYPE res; @@ -75,7 +75,7 @@ typedef struct _CMtCoder size_t blockSize; size_t destBlockSize; unsigned numThreads; - + ISeqInStream *inStream; ISeqOutStream *outStream; ICompressProgress *progress; diff --git a/src/lib/lib7z/Ppmd.h b/src/lib/lib7z/Ppmd.h index 9cbc46647b8..db8a16d6371 100644 --- a/src/lib/lib7z/Ppmd.h +++ b/src/lib/lib7z/Ppmd.h @@ -82,5 +82,5 @@ typedef p[i+7] = p[i+6] = p[i+5] = p[i+4] = p[i+3] = p[i+2] = p[i+1] = p[i+0] = ~(size_t)0; }} EXTERN_C_END - + #endif diff --git a/src/lib/lib7z/Ppmd7.c b/src/lib/lib7z/Ppmd7.c index bba4d06f0ab..58244e13610 100644 --- a/src/lib/lib7z/Ppmd7.c +++ b/src/lib/lib7z/Ppmd7.c @@ -148,7 +148,7 @@ static void GlueFreeBlocks(CPpmd7 *p) #else CPpmd7_Node_Ref head = p->AlignOffset + p->Size; #endif - + CPpmd7_Node_Ref n = head; unsigned i; @@ -175,7 +175,7 @@ static void GlueFreeBlocks(CPpmd7 *p) NODE(n)->Prev = head; if (p->LoUnit != p->HiUnit) ((CPpmd7_Node *)p->LoUnit)->Stamp = 1; - + /* Glue free blocks */ while (n != head) { @@ -193,7 +193,7 @@ static void GlueFreeBlocks(CPpmd7 *p) } n = node->Next; } - + /* Fill lists of free blocks */ for (n = NODE(head)->Next; n != head;) { @@ -319,7 +319,7 @@ static void RestartModel(CPpmd7 *p) for (m = 0; m < 64; m += 8) dest[m] = val; } - + for (i = 0; i < 25; i++) for (k = 0; k < 16; k++) { @@ -345,10 +345,10 @@ static CTX_PTR CreateSuccessors(CPpmd7 *p, Bool skip) CPpmd_Byte_Ref upBranch = (CPpmd_Byte_Ref)SUCCESSOR(p->FoundState); CPpmd_State *ps[PPMD7_MAX_ORDER]; unsigned numPs = 0; - + if (!skip) ps[numPs++] = p->FoundState; - + while (c->Suffix) { CPpmd_Void_Ref successor; @@ -370,10 +370,10 @@ static CTX_PTR CreateSuccessors(CPpmd7 *p, Bool skip) } ps[numPs++] = s; } - + upState.Symbol = *(const Byte *)Ppmd7_GetPtr(p, upBranch); SetSuccessor(&upState, upBranch + 1); - + if (c->NumStats == 1) upState.Freq = ONE_STATE(c)->Freq; else @@ -407,7 +407,7 @@ static CTX_PTR CreateSuccessors(CPpmd7 *p, Bool skip) c = c1; } while (numPs != 0); - + return c; } @@ -423,11 +423,11 @@ static void UpdateModel(CPpmd7 *p) CPpmd_Void_Ref successor, fSuccessor = SUCCESSOR(p->FoundState); CTX_PTR c; unsigned s0, ns; - + if (p->FoundState->Freq < MAX_FREQ / 4 && p->MinContext->Suffix != 0) { c = SUFFIX(p->MinContext); - + if (c->NumStats == 1) { CPpmd_State *s = ONE_STATE(c); @@ -465,7 +465,7 @@ static void UpdateModel(CPpmd7 *p) SetSuccessor(p->FoundState, REF(p->MinContext)); return; } - + *p->Text++ = p->FoundState->Symbol; successor = REF(p->Text); if (p->Text >= p->UnitsStart) @@ -473,7 +473,7 @@ static void UpdateModel(CPpmd7 *p) RestartModel(p); return; } - + if (fSuccessor) { if (fSuccessor <= successor) @@ -497,9 +497,9 @@ static void UpdateModel(CPpmd7 *p) SetSuccessor(p->FoundState, successor); fSuccessor = REF(p->MinContext); } - + s0 = p->MinContext->SummFreq - (ns = p->MinContext->NumStats) - (p->FoundState->Freq - 1); - + for (c = p->MaxContext; c != p->MinContext; c = SUFFIX(c)) { unsigned ns1; @@ -566,7 +566,7 @@ static void UpdateModel(CPpmd7 *p) } p->MaxContext = p->MinContext = CTX(fSuccessor); } - + static void Rescale(CPpmd7 *p) { unsigned i, adder, sumFreq, escFreq; @@ -583,7 +583,7 @@ static void Rescale(CPpmd7 *p) adder = (p->OrderFall != 0); s->Freq = (Byte)((s->Freq + adder) >> 1); sumFreq = s->Freq; - + i = p->MinContext->NumStats - 1; do { @@ -601,7 +601,7 @@ static void Rescale(CPpmd7 *p) } } while (--i); - + if (s->Freq == 0) { unsigned numStats = p->MinContext->NumStats; diff --git a/src/lib/lib7z/Ppmd7.h b/src/lib/lib7z/Ppmd7.h index 96521c31f11..fa4225e2d35 100644 --- a/src/lib/lib7z/Ppmd7.h +++ b/src/lib/lib7z/Ppmd7.h @@ -136,5 +136,5 @@ void Ppmd7z_RangeEnc_FlushData(CPpmd7z_RangeEnc *p); void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol); EXTERN_C_END - + #endif diff --git a/src/lib/lib7z/Ppmd7Dec.c b/src/lib/lib7z/Ppmd7Dec.c index 68438d5ce4e..dc31b4f3a82 100644 --- a/src/lib/lib7z/Ppmd7Dec.c +++ b/src/lib/lib7z/Ppmd7Dec.c @@ -160,11 +160,11 @@ int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc) i -= k; } while (i != num); - + see = Ppmd7_MakeEscFreq(p, numMasked, &freqSum); freqSum += hiCnt; count = rc->GetThreshold(rc, freqSum); - + if (count < hiCnt) { Byte symbol; diff --git a/src/lib/lib7z/Ppmd7Enc.c b/src/lib/lib7z/Ppmd7Enc.c index 8247757d09d..51a36b0178d 100644 --- a/src/lib/lib7z/Ppmd7Enc.c +++ b/src/lib/lib7z/Ppmd7Enc.c @@ -104,7 +104,7 @@ void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol) sum += s->Freq; } while (--i); - + p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol]; PPMD_SetAllBitsIn256Bytes(charMask); MASK(s->Symbol) = 0; @@ -149,7 +149,7 @@ void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol) p->MinContext = Ppmd7_GetContext(p, p->MinContext->Suffix); } while (p->MinContext->NumStats == numMasked); - + see = Ppmd7_MakeEscFreq(p, numMasked, &escFreq); s = Ppmd7_GetStats(p, p->MinContext); sum = 0; @@ -178,7 +178,7 @@ void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol) s++; } while (--i); - + RangeEnc_Encode(rc, sum, escFreq, sum + escFreq); see->Summ = (UInt16)(see->Summ + sum + escFreq); } diff --git a/src/lib/lib7z/Ppmd8.c b/src/lib/lib7z/Ppmd8.c index 9187a88ef1e..8bec6f560f1 100644 --- a/src/lib/lib7z/Ppmd8.c +++ b/src/lib/lib7z/Ppmd8.c @@ -146,7 +146,7 @@ static void GlueFreeBlocks(CPpmd8 *p) p->GlueCount = 1 << 13; memset(p->Stamps, 0, sizeof(p->Stamps)); - + /* Order-0 context is always at top UNIT, so we don't need guard NODE at the end. All blocks up to p->LoUnit can be free, so we need guard NODE at LoUnit. */ if (p->LoUnit != p->HiUnit) @@ -175,7 +175,7 @@ static void GlueFreeBlocks(CPpmd8 *p) } } *prev = 0; - + /* Fill lists of free blocks */ while (head != 0) { @@ -298,7 +298,7 @@ static void ExpandTextArea(CPpmd8 *p) memset(count, 0, sizeof(count)); if (p->LoUnit != p->HiUnit) ((CPpmd8_Node *)p->LoUnit)->Stamp = 0; - + { CPpmd8_Node *node = (CPpmd8_Node *)p->UnitsStart; for (; node->Stamp == EMPTY_NODE; node += node->NU) @@ -308,7 +308,7 @@ static void ExpandTextArea(CPpmd8 *p) } p->UnitsStart = (Byte *)node; } - + for (i = 0; i < PPMD_NUM_INDEXES; i++) { CPpmd8_Node_Ref *next = (CPpmd8_Node_Ref *)&p->FreeList[i]; @@ -440,7 +440,7 @@ static CPpmd_Void_Ref CutOff(CPpmd8 *p, CTX_PTR ctx, unsigned order) int i; unsigned tmp; CPpmd_State *s; - + if (!ctx->NumStats) { s = ONE_STATE(ctx); @@ -470,7 +470,7 @@ static CPpmd_Void_Ref CutOff(CPpmd8 *p, CTX_PTR ctx, unsigned order) SetSuccessor(s, CutOff(p, CTX(SUCCESSOR(s)), order + 1)); else SetSuccessor(s, 0); - + if (i != ctx->NumStats && order) { ctx->NumStats = (Byte)i; @@ -521,7 +521,7 @@ static CPpmd_Void_Ref RemoveBinContexts(CPpmd8 *p, CTX_PTR ctx, unsigned order) SetSuccessor(s, RemoveBinContexts(p, CTX(SUCCESSOR(s)), order + 1)); else SetSuccessor(s, 0); - + return REF(ctx); } #endif @@ -561,7 +561,7 @@ static void RestoreModel(CPpmd8 *p, CTX_PTR c1 } else Refresh(p, c, (c->NumStats+3) >> 1, 0); - + for (; c != p->MinContext; c = SUFFIX(c)) if (!c->NumStats) ONE_STATE(c)->Freq -= ONE_STATE(c)->Freq >> 1; @@ -610,10 +610,10 @@ static CTX_PTR CreateSuccessors(CPpmd8 *p, Bool skip, CPpmd_State *s1, CTX_PTR c /* fixed over Shkarin's code. Maybe it could work without + 1 too. */ CPpmd_State *ps[PPMD8_MAX_ORDER + 1]; unsigned numPs = 0; - + if (!skip) ps[numPs++] = p->FoundState; - + while (c->Suffix) { CPpmd_Void_Ref successor; @@ -648,7 +648,7 @@ static CTX_PTR CreateSuccessors(CPpmd8 *p, Bool skip, CPpmd_State *s1, CTX_PTR c } ps[numPs++] = s; } - + upState.Symbol = *(const Byte *)Ppmd8_GetPtr(p, upBranch); SetSuccessor(&upState, upBranch + 1); flags = 0x10 * (p->FoundState->Symbol >= 0x40) + 0x08 * (upState.Symbol >= 0x40); @@ -687,7 +687,7 @@ static CTX_PTR CreateSuccessors(CPpmd8 *p, Bool skip, CPpmd_State *s1, CTX_PTR c c = c1; } while (numPs != 0); - + return c; } @@ -696,7 +696,7 @@ static CTX_PTR ReduceOrder(CPpmd8 *p, CPpmd_State *s1, CTX_PTR c) CPpmd_State *s = NULL; CTX_PTR c1 = c; CPpmd_Void_Ref upBranch = REF(p->Text); - + #ifdef PPMD8_FREEZE_SUPPORT /* The BUG in Shkarin's code was fixed: ps could overflow in CUT_OFF mode. */ CPpmd_State *ps[PPMD8_MAX_ORDER + 1]; @@ -754,7 +754,7 @@ static CTX_PTR ReduceOrder(CPpmd8 *p, CPpmd_State *s1, CTX_PTR c) SetSuccessor(s, upBranch); p->OrderFall++; } - + #ifdef PPMD8_FREEZE_SUPPORT if (p->RestoreMethod > PPMD8_RESTORE_METHOD_FREEZE) { @@ -779,7 +779,7 @@ static CTX_PTR ReduceOrder(CPpmd8 *p, CPpmd_State *s1, CTX_PTR c) SetSuccessor(s, REF(successor)); p->FoundState = s1; } - + if (p->OrderFall == 1 && c1 == p->MaxContext) { SetSuccessor(p->FoundState, SUCCESSOR(s)); @@ -797,11 +797,11 @@ static void UpdateModel(CPpmd8 *p) unsigned s0, ns, fFreq = p->FoundState->Freq; Byte flag, fSymbol = p->FoundState->Symbol; CPpmd_State *s = NULL; - + if (p->FoundState->Freq < MAX_FREQ / 4 && p->MinContext->Suffix != 0) { c = SUFFIX(p->MinContext); - + if (c->NumStats == 0) { s = ONE_STATE(c); @@ -827,7 +827,7 @@ static void UpdateModel(CPpmd8 *p) } } } - + c = p->MaxContext; if (p->OrderFall == 0 && fSuccessor) { @@ -844,7 +844,7 @@ static void UpdateModel(CPpmd8 *p) } return; } - + *p->Text++ = p->FoundState->Symbol; successor = REF(p->Text); if (p->Text >= p->UnitsStart) @@ -852,7 +852,7 @@ static void UpdateModel(CPpmd8 *p) RESTORE_MODEL(c, CTX(fSuccessor)); /* check it */ return; } - + if (!fSuccessor) { CTX_PTR cs = ReduceOrder(p, s, p->MinContext); @@ -873,7 +873,7 @@ static void UpdateModel(CPpmd8 *p) } fSuccessor = REF(cs); } - + if (--p->OrderFall == 0) { successor = fSuccessor; @@ -887,10 +887,10 @@ static void UpdateModel(CPpmd8 *p) p->OrderFall = 0; } #endif - + s0 = p->MinContext->SummFreq - (ns = p->MinContext->NumStats) - fFreq; flag = 0x08 * (fSymbol >= 0x40); - + for (; c != p->MinContext; c = SUFFIX(c)) { unsigned ns1; @@ -958,7 +958,7 @@ static void UpdateModel(CPpmd8 *p) } p->MaxContext = p->MinContext = CTX(fSuccessor); } - + static void Rescale(CPpmd8 *p) { unsigned i, adder, sumFreq, escFreq; @@ -979,7 +979,7 @@ static void Rescale(CPpmd8 *p) ); s->Freq = (Byte)((s->Freq + adder) >> 1); sumFreq = s->Freq; - + i = p->MinContext->NumStats; do { @@ -997,7 +997,7 @@ static void Rescale(CPpmd8 *p) } } while (--i); - + if (s->Freq == 0) { unsigned numStats = p->MinContext->NumStats; diff --git a/src/lib/lib7z/Ppmd8.h b/src/lib/lib7z/Ppmd8.h index 7dcfc91613b..813254cd462 100644 --- a/src/lib/lib7z/Ppmd8.h +++ b/src/lib/lib7z/Ppmd8.h @@ -133,5 +133,5 @@ void Ppmd8_RangeEnc_FlushData(CPpmd8 *p); void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol); /* symbol = -1 means EndMarker */ EXTERN_C_END - + #endif diff --git a/src/lib/lib7z/Ppmd8Dec.c b/src/lib/lib7z/Ppmd8Dec.c index c54e02ab205..12fd7ec0d79 100644 --- a/src/lib/lib7z/Ppmd8Dec.c +++ b/src/lib/lib7z/Ppmd8Dec.c @@ -128,11 +128,11 @@ int Ppmd8_DecodeSymbol(CPpmd8 *p) i -= k; } while (i != num); - + see = Ppmd8_MakeEscFreq(p, numMasked, &freqSum); freqSum += hiCnt; count = RangeDec_GetThreshold(p, freqSum); - + if (count < hiCnt) { Byte symbol; diff --git a/src/lib/lib7z/Ppmd8Enc.c b/src/lib/lib7z/Ppmd8Enc.c index 8da727eb25a..f433fe9ee0a 100644 --- a/src/lib/lib7z/Ppmd8Enc.c +++ b/src/lib/lib7z/Ppmd8Enc.c @@ -81,7 +81,7 @@ void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol) sum += s->Freq; } while (--i); - + PPMD_SetAllBitsIn256Bytes(charMask); MASK(s->Symbol) = 0; i = p->MinContext->NumStats; @@ -125,7 +125,7 @@ void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol) p->MinContext = Ppmd8_GetContext(p, p->MinContext->Suffix); } while (p->MinContext->NumStats == numMasked); - + see = Ppmd8_MakeEscFreq(p, numMasked, &escFreq); s = Ppmd8_GetStats(p, p->MinContext); sum = 0; @@ -154,7 +154,7 @@ void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol) s++; } while (--i); - + RangeEnc_Encode(p, sum, escFreq, sum + escFreq); see->Summ = (UInt16)(see->Summ + sum + escFreq); } diff --git a/src/lib/lib7z/Sha256.c b/src/lib/lib7z/Sha256.c index eb4fc61fc9d..8b824744ced 100644 --- a/src/lib/lib7z/Sha256.c +++ b/src/lib/lib7z/Sha256.c @@ -133,7 +133,7 @@ static void Sha256_Transform(UInt32 *state, const UInt32 *data) for (j = 0; j < 8; j++) state[j] += T[j]; #endif - + /* Wipe variables */ /* memset(W, 0, sizeof(W)); */ /* memset(T, 0, sizeof(T)); */ diff --git a/src/lib/lib7z/Xz.h b/src/lib/lib7z/Xz.h index 0f7a822c37e..45481cfdf6d 100644 --- a/src/lib/lib7z/Xz.h +++ b/src/lib/lib7z/Xz.h @@ -199,7 +199,7 @@ typedef struct unsigned indexPreSize; CXzStreamFlags streamFlags; - + UInt32 blockHeaderSize; UInt64 packSize; UInt64 unpackSize; diff --git a/src/lib/lib7z/XzDec.c b/src/lib/lib7z/XzDec.c index 113e2cdf0f0..5a4a9a1ca0e 100644 --- a/src/lib/lib7z/XzDec.c +++ b/src/lib/lib7z/XzDec.c @@ -421,7 +421,7 @@ SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen, const Byte *srcCur; int srcFinishedCur; int encodingWasFinished; - + if (i == 0) { srcCur = src; @@ -434,7 +434,7 @@ SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen, srcLenCur = p->size[i - 1] - p->pos[i - 1]; srcFinishedCur = p->finished[i - 1]; } - + if (i == p->numCoders - 1) { destCur = dest; @@ -447,7 +447,7 @@ SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen, destCur = p->buf + (CODER_BUF_SIZE * i); destLenCur = CODER_BUF_SIZE; } - + res = coder->Code(coder->p, destCur, &destLenCur, srcCur, &srcLenCur, srcFinishedCur, finishMode, &encodingWasFinished); if (!encodingWasFinished) @@ -474,7 +474,7 @@ SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen, p->pos[i] = 0; p->finished[i] = encodingWasFinished; } - + if (res != SZ_OK) return res; @@ -637,20 +637,20 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen, *status = CODER_STATUS_NOT_FINISHED; return SZ_OK; } - + res = MixCoder_Code(&p->decoder, dest, &destLen2, src, &srcLen2, False, finishMode, status); XzCheck_Update(&p->check, dest, destLen2); - + (*srcLen) += srcLen2; src += srcLen2; p->packSize += srcLen2; - + (*destLen) += destLen2; dest += destLen2; p->unpackSize += destLen2; - + RINOK(res); - + if (*status == CODER_STATUS_FINISHED_WITH_MARK) { Byte temp[32]; @@ -659,14 +659,14 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen, Sha256_Update(&p->sha, temp, num); p->indexSize += num; p->numBlocks++; - + p->state = XZ_STATE_BLOCK_FOOTER; p->pos = 0; p->alignPos = 0; } else if (srcLen2 == 0 && destLen2 == 0) return SZ_OK; - + continue; } @@ -872,7 +872,7 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen, } break; } - + case XZ_STATE_BLOCK: break; /* to disable GCC warning */ } } diff --git a/src/lib/lib7z/XzEnc.c b/src/lib/lib7z/XzEnc.c index 56cfd579c69..8a206f4b9af 100644 --- a/src/lib/lib7z/XzEnc.c +++ b/src/lib/lib7z/XzEnc.c @@ -409,10 +409,10 @@ static SRes Xz_Compress(CXzStream *xz, CLzma2WithFilters *lzmaf, int filterIndex = 0; CXzFilter *filter = NULL; const CXzFilterProps *fp = props->filterProps; - + XzBlock_ClearFlags(&block); XzBlock_SetNumFilters(&block, 1 + (fp ? 1 : 0)); - + if (fp) { filter = &block.filters[filterIndex++]; @@ -440,13 +440,13 @@ static SRes Xz_Compress(CXzStream *xz, CLzma2WithFilters *lzmaf, seqSizeOutStream.p.Write = MyWrite; seqSizeOutStream.realStream = outStream; seqSizeOutStream.processed = 0; - + RINOK(XzBlock_WriteHeader(&block, &seqSizeOutStream.p)); - + checkInStream.p.Read = SeqCheckInStream_Read; checkInStream.realStream = inStream; SeqCheckInStream_Init(&checkInStream, XzFlags_GetCheckType(xz->flags)); - + if (fp) { #ifdef USE_SUBBLOCK diff --git a/src/lib/lib7z/XzIn.c b/src/lib/lib7z/XzIn.c index 4ba87a2cfc6..adb24c0eaac 100644 --- a/src/lib/lib7z/XzIn.c +++ b/src/lib/lib7z/XzIn.c @@ -88,7 +88,7 @@ static SRes Xz_ReadIndex2(CXzStream *p, const Byte *buf, size_t size, ISzAlloc * if (numBlocks != numBlocks64 || numBlocks * 2 > size) return SZ_ERROR_ARCHIVE; } - + crcStartPos = pos; Xz_Free(p, alloc); if (numBlocks != 0) @@ -149,7 +149,7 @@ static SRes Xz_ReadBackward(CXzStream *p, ILookInStream *stream, Int64 *startOff RINOK(SeekFromCur(stream, startOffset)); RINOK(LookInStream_Read2(stream, buf, XZ_STREAM_FOOTER_SIZE, SZ_ERROR_NO_ARCHIVE)); - + if (memcmp(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) != 0) { UInt32 total = 0; @@ -185,7 +185,7 @@ static SRes Xz_ReadBackward(CXzStream *p, ILookInStream *stream, Int64 *startOff if (memcmp(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) != 0) return SZ_ERROR_NO_ARCHIVE; } - + p->flags = (CXzStreamFlags)GetBe16(buf + 8); if (!XzFlags_IsSupported(p->flags)) diff --git a/src/lib/lib7z/x7zFile.c b/src/lib/lib7z/x7zFile.c index a66c9e9d08e..8eb02b5020c 100644 --- a/src/lib/lib7z/x7zFile.c +++ b/src/lib/lib7z/x7zFile.c @@ -120,12 +120,12 @@ WRes File_Read(CSzFile *p, void *data, size_t *size) return 0; #else - + *size = fread(data, 1, originalSize, p->file); if (*size == originalSize) return 0; return ferror(p->file); - + #endif } @@ -134,7 +134,7 @@ WRes File_Write(CSzFile *p, const void *data, size_t *size) size_t originalSize = *size; if (originalSize == 0) return 0; - + #ifdef USE_WINDOWS_FILE *size = 0; @@ -160,7 +160,7 @@ WRes File_Write(CSzFile *p, const void *data, size_t *size) if (*size == originalSize) return 0; return ferror(p->file); - + #endif } @@ -190,7 +190,7 @@ WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin) return 0; #else - + int moveMethod; int res; switch (origin) @@ -203,14 +203,14 @@ WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin) res = fseek(p->file, (long)*pos, moveMethod); *pos = ftell(p->file); return res; - + #endif } WRes File_GetLength(CSzFile *p, UInt64 *length) { #ifdef USE_WINDOWS_FILE - + DWORD sizeHigh; DWORD sizeLow = GetFileSize(p->handle, &sizeHigh); if (sizeLow == 0xFFFFFFFF) @@ -221,15 +221,15 @@ WRes File_GetLength(CSzFile *p, UInt64 *length) } *length = (((UInt64)sizeHigh) << 32) + sizeLow; return 0; - + #else - + long pos = ftell(p->file); int res = fseek(p->file, 0, SEEK_END); *length = ftell(p->file); fseek(p->file, pos, SEEK_SET); return res; - + #endif } |