diff options
| author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2026-09-04 00:00:00 +0000 |
|---|---|---|
| committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2026-09-04 12:17:40 +0500 |
| commit | 0766b733fe3e06dd2a7f9a3cfbf2108ac73abd17 (patch) | |
| tree | 3a8ca8ef8e855c41476499484ae3f3596e842ac2 /C | |
| parent | f9d78aff31a5f2521ae7ddbdc97c4a8855808959 (diff) | |
| download | 7zip-0766b733fe3e06dd2a7f9a3cfbf2108ac73abd17.tar.gz 7zip-0766b733fe3e06dd2a7f9a3cfbf2108ac73abd17.tar.bz2 7zip-0766b733fe3e06dd2a7f9a3cfbf2108ac73abd17.zip | |
Diffstat (limited to 'C')
| -rw-r--r-- | C/7zDec.c | 73 | ||||
| -rw-r--r-- | C/7zTypes.h | 1 | ||||
| -rw-r--r-- | C/7zVersion.h | 6 | ||||
| -rw-r--r-- | C/Bcj2Enc.c | 7 | ||||
| -rw-r--r-- | C/BwtSort.c | 6 | ||||
| -rw-r--r-- | C/Compiler.h | 30 | ||||
| -rw-r--r-- | C/CpuArch.h | 11 | ||||
| -rw-r--r-- | C/Lzma2Enc.c | 22 | ||||
| -rw-r--r-- | C/LzmaDec.c | 18 | ||||
| -rw-r--r-- | C/LzmaEnc.c | 13 | ||||
| -rw-r--r-- | C/Ppmd7Enc.c | 7 | ||||
| -rw-r--r-- | C/Ppmd8.c | 4 | ||||
| -rw-r--r-- | C/Util/7z/7zMain.c | 2 |
13 files changed, 125 insertions, 75 deletions
| @@ -99,62 +99,61 @@ static Byte ReadByte(IByteInPtr pp) | |||
| 99 | static SRes SzDecodePpmd(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStreamPtr inStream, | 99 | static SRes SzDecodePpmd(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStreamPtr inStream, |
| 100 | Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain) | 100 | Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain) |
| 101 | { | 101 | { |
| 102 | CPpmd7 ppmd; | 102 | CPpmd7 *ppmd; |
| 103 | CByteInToLook s; | 103 | SRes res; |
| 104 | SRes res = SZ_OK; | 104 | unsigned order; |
| 105 | 105 | UInt32 memSize; | |
| 106 | s.vt.Read = ReadByte; | ||
| 107 | s.inStream = inStream; | ||
| 108 | s.begin = s.end = s.cur = NULL; | ||
| 109 | s.extra = False; | ||
| 110 | s.res = SZ_OK; | ||
| 111 | s.processed = 0; | ||
| 112 | 106 | ||
| 113 | if (propsSize != 5) | 107 | if (propsSize != 5) |
| 114 | return SZ_ERROR_UNSUPPORTED; | 108 | return SZ_ERROR_UNSUPPORTED; |
| 115 | 109 | order = props[0]; | |
| 116 | { | 110 | memSize = GetUi32(props + 1); |
| 117 | unsigned order = props[0]; | 111 | if (order < PPMD7_MIN_ORDER || |
| 118 | UInt32 memSize = GetUi32(props + 1); | 112 | order > PPMD7_MAX_ORDER || |
| 119 | if (order < PPMD7_MIN_ORDER || | 113 | memSize < PPMD7_MIN_MEM_SIZE || |
| 120 | order > PPMD7_MAX_ORDER || | 114 | memSize > PPMD7_MAX_MEM_SIZE) |
| 121 | memSize < PPMD7_MIN_MEM_SIZE || | 115 | return SZ_ERROR_UNSUPPORTED; |
| 122 | memSize > PPMD7_MAX_MEM_SIZE) | 116 | if ((ppmd = (CPpmd7 *)ISzAlloc_Alloc(allocMain, sizeof(CPpmd7))) == NULL) |
| 123 | return SZ_ERROR_UNSUPPORTED; | 117 | return SZ_ERROR_MEM; |
| 124 | Ppmd7_Construct(&ppmd); | 118 | Ppmd7_Construct(ppmd); |
| 125 | if (!Ppmd7_Alloc(&ppmd, memSize, allocMain)) | 119 | res = SZ_ERROR_MEM; |
| 126 | return SZ_ERROR_MEM; | 120 | if (Ppmd7_Alloc(ppmd, memSize, allocMain)) |
| 127 | Ppmd7_Init(&ppmd, order); | ||
| 128 | } | ||
| 129 | { | 121 | { |
| 130 | ppmd.rc.dec.Stream = &s.vt; | 122 | CByteInToLook s; |
| 131 | if (!Ppmd7z_RangeDec_Init(&ppmd.rc.dec)) | 123 | s.vt.Read = ReadByte; |
| 132 | res = SZ_ERROR_DATA; | 124 | s.inStream = inStream; |
| 133 | else if (!s.extra) | 125 | s.begin = s.end = s.cur = NULL; |
| 126 | s.extra = False; | ||
| 127 | s.res = SZ_OK; | ||
| 128 | s.processed = 0; | ||
| 129 | |||
| 130 | Ppmd7_Init(ppmd, order); | ||
| 131 | ppmd->rc.dec.Stream = &s.vt; | ||
| 132 | res = SZ_ERROR_DATA; | ||
| 133 | if (Ppmd7z_RangeDec_Init(&ppmd->rc.dec) && !s.extra) | ||
| 134 | { | 134 | { |
| 135 | Byte *buf = outBuffer; | 135 | Byte *buf = outBuffer; |
| 136 | const Byte *lim = buf + outSize; | 136 | const Byte *lim = buf + outSize; |
| 137 | for (; buf != lim; buf++) | 137 | for (; buf != lim; buf++) |
| 138 | { | 138 | { |
| 139 | int sym = Ppmd7z_DecodeSymbol(&ppmd); | 139 | int sym = Ppmd7z_DecodeSymbol(ppmd); |
| 140 | if (s.extra || sym < 0) | 140 | if (s.extra || sym < 0) |
| 141 | break; | 141 | break; |
| 142 | *buf = (Byte)sym; | 142 | *buf = (Byte)sym; |
| 143 | } | 143 | } |
| 144 | if (buf != lim) | 144 | if (buf == lim) |
| 145 | res = SZ_ERROR_DATA; | 145 | if (Ppmd7z_RangeDec_IsFinishedOK(&ppmd->rc.dec) |
| 146 | else if (!Ppmd7z_RangeDec_IsFinishedOK(&ppmd.rc.dec)) | 146 | // || (Ppmd7z_DecodeSymbol(&ppmd) == PPMD7_SYM_END && Ppmd7z_RangeDec_IsFinishedOK(&ppmd.rc.dec)) |
| 147 | { | 147 | ) |
| 148 | /* if (Ppmd7z_DecodeSymbol(&ppmd) != PPMD7_SYM_END || !Ppmd7z_RangeDec_IsFinishedOK(&ppmd.rc.dec)) */ | 148 | res = SZ_OK; |
| 149 | res = SZ_ERROR_DATA; | ||
| 150 | } | ||
| 151 | } | 149 | } |
| 152 | if (s.extra) | 150 | if (s.extra) |
| 153 | res = (s.res != SZ_OK ? s.res : SZ_ERROR_DATA); | 151 | res = (s.res != SZ_OK ? s.res : SZ_ERROR_DATA); |
| 154 | else if (s.processed + (size_t)(s.cur - s.begin) != inSize) | 152 | else if (s.processed + (size_t)(s.cur - s.begin) != inSize) |
| 155 | res = SZ_ERROR_DATA; | 153 | res = SZ_ERROR_DATA; |
| 154 | Ppmd7_Free(ppmd, allocMain); | ||
| 156 | } | 155 | } |
| 157 | Ppmd7_Free(&ppmd, allocMain); | 156 | ISzAlloc_Free(allocMain, ppmd); |
| 158 | return res; | 157 | return res; |
| 159 | } | 158 | } |
| 160 | 159 | ||
diff --git a/C/7zTypes.h b/C/7zTypes.h index 8aaabc8..af47668 100644 --- a/C/7zTypes.h +++ b/C/7zTypes.h | |||
| @@ -556,6 +556,7 @@ struct ISzAlloc | |||
| 556 | 556 | ||
| 557 | 557 | ||
| 558 | #define Z7_memset_0_ARRAY(a) memset((a), 0, sizeof(a)) | 558 | #define Z7_memset_0_ARRAY(a) memset((a), 0, sizeof(a)) |
| 559 | #define Z7_memset_0_VAR(a) memset(&(a), 0, sizeof(a)) | ||
| 559 | 560 | ||
| 560 | #ifndef Z7_ARRAY_SIZE | 561 | #ifndef Z7_ARRAY_SIZE |
| 561 | #define Z7_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) | 562 | #define Z7_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) |
diff --git a/C/7zVersion.h b/C/7zVersion.h index 50ccebb..de7efb8 100644 --- a/C/7zVersion.h +++ b/C/7zVersion.h | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #define MY_VER_MAJOR 26 | 1 | #define MY_VER_MAJOR 26 |
| 2 | #define MY_VER_MINOR 2 | 2 | #define MY_VER_MINOR 3 |
| 3 | #define MY_VER_BUILD 0 | 3 | #define MY_VER_BUILD 0 |
| 4 | #define MY_VERSION_NUMBERS "26.02" | 4 | #define MY_VERSION_NUMBERS "26.03" |
| 5 | #define MY_VERSION MY_VERSION_NUMBERS | 5 | #define MY_VERSION MY_VERSION_NUMBERS |
| 6 | 6 | ||
| 7 | #ifdef MY_CPU_NAME | 7 | #ifdef MY_CPU_NAME |
| @@ -10,7 +10,7 @@ | |||
| 10 | #define MY_VERSION_CPU MY_VERSION | 10 | #define MY_VERSION_CPU MY_VERSION |
| 11 | #endif | 11 | #endif |
| 12 | 12 | ||
| 13 | #define MY_DATE "2026-06-25" | 13 | #define MY_DATE "2026-09-03" |
| 14 | #undef MY_COPYRIGHT | 14 | #undef MY_COPYRIGHT |
| 15 | #undef MY_VERSION_COPYRIGHT_DATE | 15 | #undef MY_VERSION_COPYRIGHT_DATE |
| 16 | #define MY_AUTHOR_NAME "Igor Pavlov" | 16 | #define MY_AUTHOR_NAME "Igor Pavlov" |
diff --git a/C/Bcj2Enc.c b/C/Bcj2Enc.c index 79460bb..5727cbb 100644 --- a/C/Bcj2Enc.c +++ b/C/Bcj2Enc.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Bcj2Enc.c -- BCJ2 Encoder converter for x86 code (Branch CALL/JUMP variant2) | 1 | /* Bcj2Enc.c -- BCJ2 Encoder converter for x86 code (Branch CALL/JUMP variant2) |
| 2 | 2023-04-02 : Igor Pavlov : Public domain */ | 2 | : Igor Pavlov : Public domain */ |
| 3 | 3 | ||
| 4 | #include "Precomp.h" | 4 | #include "Precomp.h" |
| 5 | 5 | ||
| @@ -75,7 +75,10 @@ static BoolInt Bcj2_RangeEnc_ShiftLow(CBcj2Enc *p) | |||
| 75 | p->cache = (Byte)(low >> 24); | 75 | p->cache = (Byte)(low >> 24); |
| 76 | } | 76 | } |
| 77 | p->cacheSize++; | 77 | p->cacheSize++; |
| 78 | p->low = low << 8; | 78 | { |
| 79 | const UInt32 low2 = low << 8; | ||
| 80 | p->low = low2; | ||
| 81 | } | ||
| 79 | return False; | 82 | return False; |
| 80 | } | 83 | } |
| 81 | 84 | ||
diff --git a/C/BwtSort.c b/C/BwtSort.c index 8f64f9d..c8f9135 100644 --- a/C/BwtSort.c +++ b/C/BwtSort.c | |||
| @@ -564,7 +564,8 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, size_t blockSize) | |||
| 564 | const BoolInt finishedGroup = ((Indices[i] & 0x80000000) == 0); | 564 | const BoolInt finishedGroup = ((Indices[i] & 0x80000000) == 0); |
| 565 | if (Indices[i] & 0x40000000) | 565 | if (Indices[i] & 0x40000000) |
| 566 | { | 566 | { |
| 567 | groupSize += ((Indices[(size_t)i + 1] >> kNumBitsMax) << kNumExtra0Bits); | 567 | const UInt32 temp = ((Indices[(size_t)i + 1] >> kNumBitsMax) << kNumExtra0Bits); |
| 568 | groupSize += temp; | ||
| 568 | Indices[(size_t)i + 1] &= kIndexMask; | 569 | Indices[(size_t)i + 1] &= kIndexMask; |
| 569 | } | 570 | } |
| 570 | Indices[i] &= kIndexMask; | 571 | Indices[i] &= kIndexMask; |
| @@ -616,7 +617,8 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, size_t blockSize) | |||
| 616 | size_t groupSize = (Indices[i] & ~0xC0000000) >> kNumBitsMax; | 617 | size_t groupSize = (Indices[i] & ~0xC0000000) >> kNumBitsMax; |
| 617 | if (Indices[i] & 0x40000000) | 618 | if (Indices[i] & 0x40000000) |
| 618 | { | 619 | { |
| 619 | groupSize += (Indices[(size_t)i + 1] >> kNumBitsMax) << kNumExtra0Bits; | 620 | const UInt32 temp = (Indices[(size_t)i + 1] >> kNumBitsMax) << kNumExtra0Bits; |
| 621 | groupSize += temp; | ||
| 620 | Indices[(size_t)i + 1] &= kIndexMask; | 622 | Indices[(size_t)i + 1] &= kIndexMask; |
| 621 | } | 623 | } |
| 622 | Indices[i] &= kIndexMask; | 624 | Indices[i] &= kIndexMask; |
diff --git a/C/Compiler.h b/C/Compiler.h index c06b883..707e46d 100644 --- a/C/Compiler.h +++ b/C/Compiler.h | |||
| @@ -125,6 +125,36 @@ typedef void (*Z7_void_Function)(void); | |||
| 125 | #pragma warning(disable : 4464) // relative include path contains '..' | 125 | #pragma warning(disable : 4464) // relative include path contains '..' |
| 126 | #endif | 126 | #endif |
| 127 | 127 | ||
| 128 | // #define Z7_ANALYZE_MODE | ||
| 129 | #if defined(Z7_ANALYZE_MODE) // && defined(Z7_MSC_VER_ORIGINAL) | ||
| 130 | // for -analyze switch: | ||
| 131 | #if _MSC_VER >= 1900 | ||
| 132 | #pragma warning(disable : 6001) // Using uninitialized memory 'ps'. | ||
| 133 | #pragma warning(disable : 6031) // Return value ignored: 'CoInitialize' | ||
| 134 | #pragma warning(disable : 6553) // The annotation for function 'RegOpenKeyExW' on _Param_(3) does not apply to a value type. | ||
| 135 | #pragma warning(disable : 28159) // Random.cpp(21) : Consider using 'GetTickCount64' instead of 'GetTickCount' | ||
| 136 | #pragma warning(disable : 28160) // ProcessUtils.h(92) : Error annotation: Passing MEM_RELEASE and a non-zero dwSize parameter to VirtualFree is not allowed. This results in the failure of this call | ||
| 137 | #pragma warning(disable : 28251) // Inconsistent annotation for 'WinMain': this instance has no annotations. See c:\program files (x86)\windows kits\10\include\10.0.26100.0\um\winbase.h(1062). | ||
| 138 | #pragma warning(disable : 28286) // um\consoleapi.h(236) : For function 'ReadConsoleW', error near the end of 'SAL_readableTo(byteCount(*__formal(3,lpNumberOfCharsRead) * sizeof(TCHAR%)))'. | ||
| 139 | #pragma warning(disable : 28301) // No annotations for first declaration of 'PNTSTATUS'. See c:\program files (x86)\windows kits\10\include\10.0.26100.0\shared\bcrypt.h(40). | ||
| 140 | #endif | ||
| 141 | #if _MSC_VER >= 1600 | ||
| 142 | #pragma warning(disable : 6011) // Dereferencing NULL pointer 'p->IsDirs' | ||
| 143 | #pragma warning(disable : 6255) // `_alloca` indicates failure by raising a stack overflow exception. Consider using _malloca instead. | ||
| 144 | #pragma warning(disable : 6258) // Using TerminateThread does not allow proper thread clean up. | ||
| 145 | // #pragma warning(disable : 6262) // SfxSetup.c : Function uses '32808' bytes of stack. | ||
| 146 | #pragma warning(disable : 6320) // Threads.c : Exception-filter expression is the constant EXCEPTION_EXECUTE_HANDLER. This might mask exceptions that were not intended to be handled. | ||
| 147 | #pragma warning(disable : 6385) // createcoder.cpp : Invalid data: accessing 'struct CCodecInfo const * * g_Codecs', the readable size is '256' bytes, but '4194244' bytes might be read: Lines: 338, 339, 340, 342, 344 | ||
| 148 | #pragma warning(disable : 6387) // MyString.cpp : 's' could be '0': this does not adhere to the specification for the function 'wmemcpy' | ||
| 149 | #endif | ||
| 150 | #if _MSC_VER == 1600 | ||
| 151 | #pragma warning(disable : 6200) // compressdialog.cpp : Index '31' is out of valid index range '0' to '9' for non-stack buffer 'g_Levels' | ||
| 152 | #pragma warning(disable : 6204) // Possible buffer overrun in call to 'memset': use of unchecked parameter 'size' | ||
| 153 | #pragma warning(disable : 6309) // Argument '1' is null: this does not adhere to function specification of 'GetProcAddress' | ||
| 154 | #pragma warning(disable : 6386) // myvector.h : Buffer overrun: accessing 'argument 1', the writable size is 'newCapacity*4' bytes, but '8' bytes might be written | ||
| 155 | #endif | ||
| 156 | #endif // Z7_ANALYZE_MODE | ||
| 157 | |||
| 128 | // == 1200 : -O1 : for __forceinline | 158 | // == 1200 : -O1 : for __forceinline |
| 129 | // >= 1900 : -O1 : for printf | 159 | // >= 1900 : -O1 : for printf |
| 130 | #pragma warning(disable : 4710) // function not inlined | 160 | #pragma warning(disable : 4710) // function not inlined |
diff --git a/C/CpuArch.h b/C/CpuArch.h index 348db0a..e6698d8 100644 --- a/C/CpuArch.h +++ b/C/CpuArch.h | |||
| @@ -209,6 +209,17 @@ MY_CPU_64BIT means that processor can work with 64-bit registers. | |||
| 209 | #endif | 209 | #endif |
| 210 | 210 | ||
| 211 | 211 | ||
| 212 | #if defined(__s390__) | ||
| 213 | #if defined(__s390x__) || defined(__LP64__) || (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 8) | ||
| 214 | #define MY_CPU_NAME "s390x" | ||
| 215 | #define MY_CPU_SIZEOF_POINTER 8 | ||
| 216 | #else | ||
| 217 | #define MY_CPU_NAME "s390" | ||
| 218 | #define MY_CPU_SIZEOF_POINTER 4 | ||
| 219 | #endif | ||
| 220 | #endif | ||
| 221 | |||
| 222 | |||
| 212 | // #undef MY_CPU_NAME | 223 | // #undef MY_CPU_NAME |
| 213 | // #undef MY_CPU_SIZEOF_POINTER | 224 | // #undef MY_CPU_SIZEOF_POINTER |
| 214 | // #define __e2k__ | 225 | // #define __e2k__ |
diff --git a/C/Lzma2Enc.c b/C/Lzma2Enc.c index 72aec69..5d64828 100644 --- a/C/Lzma2Enc.c +++ b/C/Lzma2Enc.c | |||
| @@ -129,11 +129,10 @@ UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle p); | |||
| 129 | static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf, | 129 | static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf, |
| 130 | size_t *packSizeRes, ISeqOutStreamPtr outStream) | 130 | size_t *packSizeRes, ISeqOutStreamPtr outStream) |
| 131 | { | 131 | { |
| 132 | size_t packSizeLimit = *packSizeRes; | 132 | const size_t packSizeLimit = *packSizeRes; |
| 133 | size_t packSize = packSizeLimit; | 133 | size_t packSize = packSizeLimit; |
| 134 | UInt32 unpackSize = LZMA2_UNPACK_SIZE_MAX; | 134 | UInt32 unpackSize = LZMA2_UNPACK_SIZE_MAX; |
| 135 | unsigned lzHeaderSize = 5 + (p->needInitProp ? 1 : 0); | 135 | const unsigned lzHeaderSize = 5 + (p->needInitProp ? 1 : 0); |
| 136 | BoolInt useCopyBlock; | ||
| 137 | SRes res; | 136 | SRes res; |
| 138 | 137 | ||
| 139 | *packSizeRes = 0; | 138 | *packSizeRes = 0; |
| @@ -150,22 +149,13 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf, | |||
| 150 | if (unpackSize == 0) | 149 | if (unpackSize == 0) |
| 151 | return res; | 150 | return res; |
| 152 | 151 | ||
| 153 | if (res == SZ_OK) | 152 | if (res == SZ_ERROR_OUTPUT_EOF |
| 154 | useCopyBlock = (packSize + 2 >= unpackSize || packSize > (1 << 16)); | 153 | || (res == SZ_OK && (packSize + 2 >= unpackSize || packSize > (1 << 16)))) |
| 155 | else | ||
| 156 | { | ||
| 157 | if (res != SZ_ERROR_OUTPUT_EOF) | ||
| 158 | return res; | ||
| 159 | res = SZ_OK; | ||
| 160 | useCopyBlock = True; | ||
| 161 | } | ||
| 162 | |||
| 163 | if (useCopyBlock) | ||
| 164 | { | 154 | { |
| 165 | size_t destPos = 0; | 155 | size_t destPos = 0; |
| 166 | PRF(printf("################# COPY ")); | 156 | PRF(printf("################# COPY ")); |
| 167 | 157 | ||
| 168 | while (unpackSize > 0) | 158 | while (unpackSize) |
| 169 | { | 159 | { |
| 170 | const UInt32 u = (unpackSize < LZMA2_COPY_CHUNK_SIZE) ? unpackSize : LZMA2_COPY_CHUNK_SIZE; | 160 | const UInt32 u = (unpackSize < LZMA2_COPY_CHUNK_SIZE) ? unpackSize : LZMA2_COPY_CHUNK_SIZE; |
| 171 | if (packSizeLimit - destPos < u + 3) | 161 | if (packSizeLimit - destPos < u + 3) |
| @@ -194,6 +184,8 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf, | |||
| 194 | return SZ_OK; | 184 | return SZ_OK; |
| 195 | } | 185 | } |
| 196 | 186 | ||
| 187 | if (res != SZ_OK) | ||
| 188 | return res; | ||
| 197 | { | 189 | { |
| 198 | size_t destPos = 0; | 190 | size_t destPos = 0; |
| 199 | const UInt32 u = unpackSize - 1; | 191 | const UInt32 u = unpackSize - 1; |
diff --git a/C/LzmaDec.c b/C/LzmaDec.c index 69bb8bb..5bc5094 100644 --- a/C/LzmaDec.c +++ b/C/LzmaDec.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* LzmaDec.c -- LZMA Decoder | 1 | /* LzmaDec.c -- LZMA Decoder |
| 2 | 2023-04-07 : Igor Pavlov : Public domain */ | 2 | : Igor Pavlov : Public domain */ |
| 3 | 3 | ||
| 4 | #include "Precomp.h" | 4 | #include "Precomp.h" |
| 5 | 5 | ||
| @@ -462,8 +462,10 @@ int Z7_FASTCALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit) | |||
| 462 | if (state >= kNumStates) | 462 | if (state >= kNumStates) |
| 463 | { | 463 | { |
| 464 | UInt32 distance; | 464 | UInt32 distance; |
| 465 | prob = probs + PosSlot + | 465 | { |
| 466 | ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); | 466 | const unsigned temp = (len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits; |
| 467 | prob = probs + PosSlot + temp; | ||
| 468 | } | ||
| 467 | TREE_6_DECODE(prob, distance) | 469 | TREE_6_DECODE(prob, distance) |
| 468 | if (distance >= kStartPosModelIndex) | 470 | if (distance >= kStartPosModelIndex) |
| 469 | { | 471 | { |
| @@ -857,9 +859,10 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, const Byt | |||
| 857 | if (state < 4) | 859 | if (state < 4) |
| 858 | { | 860 | { |
| 859 | unsigned posSlot; | 861 | unsigned posSlot; |
| 860 | prob = probs + PosSlot + | 862 | { |
| 861 | ((len < kNumLenToPosStates - 1 ? len : kNumLenToPosStates - 1) << | 863 | const unsigned temp = (len < kNumLenToPosStates - 1 ? len : kNumLenToPosStates - 1) << kNumPosSlotBits; |
| 862 | kNumPosSlotBits); | 864 | prob = probs + PosSlot + temp; |
| 865 | } | ||
| 863 | TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot) | 866 | TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot) |
| 864 | if (posSlot >= kStartPosModelIndex) | 867 | if (posSlot >= kStartPosModelIndex) |
| 865 | { | 868 | { |
| @@ -867,7 +870,8 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, const Byt | |||
| 867 | 870 | ||
| 868 | if (posSlot < kEndPosModelIndex) | 871 | if (posSlot < kEndPosModelIndex) |
| 869 | { | 872 | { |
| 870 | prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits); | 873 | const unsigned temp = (2 | (posSlot & 1)) << numDirectBits; |
| 874 | prob = probs + SpecPos + temp; | ||
| 871 | } | 875 | } |
| 872 | else | 876 | else |
| 873 | { | 877 | { |
diff --git a/C/LzmaEnc.c b/C/LzmaEnc.c index 60f1d21..f54e670 100644 --- a/C/LzmaEnc.c +++ b/C/LzmaEnc.c | |||
| @@ -692,7 +692,10 @@ Z7_NO_INLINE static void Z7_FASTCALL RangeEnc_ShiftLow(CRangeEnc *p) | |||
| 692 | { | 692 | { |
| 693 | UInt32 low = (UInt32)p->low; | 693 | UInt32 low = (UInt32)p->low; |
| 694 | unsigned high = (unsigned)(p->low >> 32); | 694 | unsigned high = (unsigned)(p->low >> 32); |
| 695 | p->low = (UInt32)(low << 8); | 695 | { |
| 696 | const UInt32 low2 = low << 8; | ||
| 697 | p->low = low2; | ||
| 698 | } | ||
| 696 | if (low < (UInt32)0xFF000000 || high != 0) | 699 | if (low < (UInt32)0xFF000000 || high != 0) |
| 697 | { | 700 | { |
| 698 | { | 701 | { |
| @@ -958,7 +961,8 @@ static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, unsigned sym, unsigned posS | |||
| 958 | unsigned m; | 961 | unsigned m; |
| 959 | unsigned bit; | 962 | unsigned bit; |
| 960 | RC_BIT_0(rc, probs) | 963 | RC_BIT_0(rc, probs) |
| 961 | probs += (posState << (1 + kLenNumLowBits)); | 964 | posState <<= (1 + kLenNumLowBits); |
| 965 | probs += posState; | ||
| 962 | bit = (sym >> 2) ; RC_BIT(rc, probs + 1, bit) m = (1 << 1) + bit; | 966 | bit = (sym >> 2) ; RC_BIT(rc, probs + 1, bit) m = (1 << 1) + bit; |
| 963 | bit = (sym >> 1) & 1; RC_BIT(rc, probs + m, bit) m = (m << 1) + bit; | 967 | bit = (sym >> 1) & 1; RC_BIT(rc, probs + m, bit) m = (m << 1) + bit; |
| 964 | bit = sym & 1; RC_BIT(rc, probs + m, bit) | 968 | bit = sym & 1; RC_BIT(rc, probs + m, bit) |
| @@ -1000,7 +1004,8 @@ Z7_NO_INLINE static void Z7_FASTCALL LenPriceEnc_UpdateTables( | |||
| 1000 | for (posState = 0; posState < numPosStates; posState++) | 1004 | for (posState = 0; posState < numPosStates; posState++) |
| 1001 | { | 1005 | { |
| 1002 | UInt32 *prices = p->prices[posState]; | 1006 | UInt32 *prices = p->prices[posState]; |
| 1003 | const CLzmaProb *probs = enc->low + (posState << (1 + kLenNumLowBits)); | 1007 | const unsigned posState2 = posState << (1 + kLenNumLowBits); |
| 1008 | const CLzmaProb *probs = enc->low + posState2; | ||
| 1004 | SetPrices_3(probs, a, prices, ProbPrices); | 1009 | SetPrices_3(probs, a, prices, ProbPrices); |
| 1005 | SetPrices_3(probs + kLenNumLowSymbols, c, prices + kLenNumLowSymbols, ProbPrices); | 1010 | SetPrices_3(probs + kLenNumLowSymbols, c, prices + kLenNumLowSymbols, ProbPrices); |
| 1006 | } | 1011 | } |
| @@ -2220,7 +2225,7 @@ Z7_NO_INLINE static void FillAlignPrices(CLzmaEnc *p) | |||
| 2220 | UInt32 prob; | 2225 | UInt32 prob; |
| 2221 | bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; | 2226 | bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; |
| 2222 | bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; | 2227 | bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; |
| 2223 | bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; | 2228 | bit = sym & 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; |
| 2224 | prob = probs[m]; | 2229 | prob = probs[m]; |
| 2225 | p->alignPrices[i ] = price + GET_PRICEa_0(prob); | 2230 | p->alignPrices[i ] = price + GET_PRICEa_0(prob); |
| 2226 | p->alignPrices[i + 8] = price + GET_PRICEa_1(prob); | 2231 | p->alignPrices[i + 8] = price + GET_PRICEa_1(prob); |
diff --git a/C/Ppmd7Enc.c b/C/Ppmd7Enc.c index 49cbbe6..975157c 100644 --- a/C/Ppmd7Enc.c +++ b/C/Ppmd7Enc.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Ppmd7Enc.c -- Ppmd7z (PPMdH with 7z Range Coder) Encoder | 1 | /* Ppmd7Enc.c -- Ppmd7z (PPMdH with 7z Range Coder) Encoder |
| 2 | 2023-09-07 : Igor Pavlov : Public domain | 2 | : Igor Pavlov : Public domain |
| 3 | This code is based on: | 3 | This code is based on: |
| 4 | PPMd var.H (2001): Dmitry Shkarin : Public domain */ | 4 | PPMd var.H (2001): Dmitry Shkarin : Public domain */ |
| 5 | 5 | ||
| @@ -35,7 +35,10 @@ static void Ppmd7z_RangeEnc_ShiftLow(CPpmd7 *p) | |||
| 35 | R->Cache = (Byte)((UInt32)R->Low >> 24); | 35 | R->Cache = (Byte)((UInt32)R->Low >> 24); |
| 36 | } | 36 | } |
| 37 | R->CacheSize++; | 37 | R->CacheSize++; |
| 38 | R->Low = (UInt32)((UInt32)R->Low << 8); | 38 | { |
| 39 | const UInt32 low2 = (UInt32)R->Low << 8; | ||
| 40 | R->Low = low2; | ||
| 41 | } | ||
| 39 | } | 42 | } |
| 40 | 43 | ||
| 41 | #define RC_NORM_BASE(p) if (R->Range < kTopValue) { R->Range <<= 8; Ppmd7z_RangeEnc_ShiftLow(p); | 44 | #define RC_NORM_BASE(p) if (R->Range < kTopValue) { R->Range <<= 8; Ppmd7z_RangeEnc_ShiftLow(p); |
| @@ -885,9 +885,9 @@ static PPMD8_CTX_PTR Ppmd8_CreateSuccessors(CPpmd8 *p, BoolInt skip, CPpmd_State | |||
| 885 | if (s->Freq < MAX_FREQ - 9) { s->Freq++; c->Union2.SummFreq++; } | 885 | if (s->Freq < MAX_FREQ - 9) { s->Freq++; c->Union2.SummFreq++; } |
| 886 | } | 886 | } |
| 887 | else | 887 | else |
| 888 | { | 888 | { const unsigned temp = !SUFFIX(c)->NumStats; |
| 889 | s = ONE_STATE(c); | 889 | s = ONE_STATE(c); |
| 890 | s->Freq = (Byte)(s->Freq + (!SUFFIX(c)->NumStats & (s->Freq < 24))); | 890 | s->Freq = (Byte)(s->Freq + (temp & (s->Freq < 24))); |
| 891 | } | 891 | } |
| 892 | successor = SUCCESSOR(s); | 892 | successor = SUCCESSOR(s); |
| 893 | if (successor != upBranch) | 893 | if (successor != upBranch) |
diff --git a/C/Util/7z/7zMain.c b/C/Util/7z/7zMain.c index 300c363..e49c230 100644 --- a/C/Util/7z/7zMain.c +++ b/C/Util/7z/7zMain.c | |||
| @@ -967,7 +967,7 @@ int Z7_CDECL main(int numargs, char *args[]) | |||
| 967 | break; | 967 | break; |
| 968 | } | 968 | } |
| 969 | 969 | ||
| 970 | if (len > tempSize) | 970 | if (len > tempSize || !temp) |
| 971 | { | 971 | { |
| 972 | SzFree(NULL, temp); | 972 | SzFree(NULL, temp); |
| 973 | tempSize = len; | 973 | tempSize = len; |
