mirror of
https://github.com/1dot13/source.git
synced 2026-09-02 14:36:06 +02:00
7z-Library Update to version 7z 9.22 (by Buggler)
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6568 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -595,22 +595,6 @@
|
|||||||
RelativePath="..\ext\7z\src\Ppmd7Enc.c"
|
RelativePath="..\ext\7z\src\Ppmd7Enc.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\ext\7z\src\Ppmd8.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\ext\7z\src\Ppmd8.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\ext\7z\src\Ppmd8Dec.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\ext\7z\src\Ppmd8Enc.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\ext\7z\src\RotateDefs.h"
|
RelativePath="..\ext\7z\src\RotateDefs.h"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9,00"
|
Version="9.00"
|
||||||
Name="7z"
|
Name="7z"
|
||||||
ProjectGUID="{9AD14886-DB5C-4EFF-AE17-35F9BD684692}"
|
ProjectGUID="{9AD14886-DB5C-4EFF-AE17-35F9BD684692}"
|
||||||
RootNamespace="7z"
|
RootNamespace="7z"
|
||||||
@@ -597,22 +597,6 @@
|
|||||||
RelativePath="..\ext\7z\src\Ppmd7Enc.c"
|
RelativePath="..\ext\7z\src\Ppmd7Enc.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\ext\7z\src\Ppmd8.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\ext\7z\src\Ppmd8.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\ext\7z\src\Ppmd8Dec.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\ext\7z\src\Ppmd8Enc.c"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\ext\7z\src\RotateDefs.h"
|
RelativePath="..\ext\7z\src\RotateDefs.h"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -46,7 +46,6 @@
|
|||||||
<ClInclude Include="..\ext\7z\src\MtCoder.h" />
|
<ClInclude Include="..\ext\7z\src\MtCoder.h" />
|
||||||
<ClInclude Include="..\ext\7z\src\Ppmd.h" />
|
<ClInclude Include="..\ext\7z\src\Ppmd.h" />
|
||||||
<ClInclude Include="..\ext\7z\src\Ppmd7.h" />
|
<ClInclude Include="..\ext\7z\src\Ppmd7.h" />
|
||||||
<ClInclude Include="..\ext\7z\src\Ppmd8.h" />
|
|
||||||
<ClInclude Include="..\ext\7z\src\RotateDefs.h" />
|
<ClInclude Include="..\ext\7z\src\RotateDefs.h" />
|
||||||
<ClInclude Include="..\ext\7z\src\Sha256.h" />
|
<ClInclude Include="..\ext\7z\src\Sha256.h" />
|
||||||
<ClInclude Include="..\ext\7z\src\Threads.h" />
|
<ClInclude Include="..\ext\7z\src\Threads.h" />
|
||||||
@@ -85,9 +84,6 @@
|
|||||||
<ClCompile Include="..\ext\7z\src\Ppmd7.c" />
|
<ClCompile Include="..\ext\7z\src\Ppmd7.c" />
|
||||||
<ClCompile Include="..\ext\7z\src\Ppmd7Dec.c" />
|
<ClCompile Include="..\ext\7z\src\Ppmd7Dec.c" />
|
||||||
<ClCompile Include="..\ext\7z\src\Ppmd7Enc.c" />
|
<ClCompile Include="..\ext\7z\src\Ppmd7Enc.c" />
|
||||||
<ClCompile Include="..\ext\7z\src\Ppmd8.c" />
|
|
||||||
<ClCompile Include="..\ext\7z\src\Ppmd8Dec.c" />
|
|
||||||
<ClCompile Include="..\ext\7z\src\Ppmd8Enc.c" />
|
|
||||||
<ClCompile Include="..\ext\7z\src\Sha256.c" />
|
<ClCompile Include="..\ext\7z\src\Sha256.c" />
|
||||||
<ClCompile Include="..\ext\7z\src\Threads.c" />
|
<ClCompile Include="..\ext\7z\src\Threads.c" />
|
||||||
<ClCompile Include="..\ext\7z\src\Xz.c" />
|
<ClCompile Include="..\ext\7z\src\Xz.c" />
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
<ClInclude Include="..\ext\7z\src\MtCoder.h" />
|
<ClInclude Include="..\ext\7z\src\MtCoder.h" />
|
||||||
<ClInclude Include="..\ext\7z\src\Ppmd.h" />
|
<ClInclude Include="..\ext\7z\src\Ppmd.h" />
|
||||||
<ClInclude Include="..\ext\7z\src\Ppmd7.h" />
|
<ClInclude Include="..\ext\7z\src\Ppmd7.h" />
|
||||||
<ClInclude Include="..\ext\7z\src\Ppmd8.h" />
|
|
||||||
<ClInclude Include="..\ext\7z\src\RotateDefs.h" />
|
<ClInclude Include="..\ext\7z\src\RotateDefs.h" />
|
||||||
<ClInclude Include="..\ext\7z\src\Sha256.h" />
|
<ClInclude Include="..\ext\7z\src\Sha256.h" />
|
||||||
<ClInclude Include="..\ext\7z\src\Threads.h" />
|
<ClInclude Include="..\ext\7z\src\Threads.h" />
|
||||||
@@ -63,9 +62,6 @@
|
|||||||
<ClCompile Include="..\ext\7z\src\Ppmd7.c" />
|
<ClCompile Include="..\ext\7z\src\Ppmd7.c" />
|
||||||
<ClCompile Include="..\ext\7z\src\Ppmd7Dec.c" />
|
<ClCompile Include="..\ext\7z\src\Ppmd7Dec.c" />
|
||||||
<ClCompile Include="..\ext\7z\src\Ppmd7Enc.c" />
|
<ClCompile Include="..\ext\7z\src\Ppmd7Enc.c" />
|
||||||
<ClCompile Include="..\ext\7z\src\Ppmd8.c" />
|
|
||||||
<ClCompile Include="..\ext\7z\src\Ppmd8Dec.c" />
|
|
||||||
<ClCompile Include="..\ext\7z\src\Ppmd8Enc.c" />
|
|
||||||
<ClCompile Include="..\ext\7z\src\Sha256.c" />
|
<ClCompile Include="..\ext\7z\src\Sha256.c" />
|
||||||
<ClCompile Include="..\ext\7z\src\Threads.c" />
|
<ClCompile Include="..\ext\7z\src\Threads.c" />
|
||||||
<ClCompile Include="..\ext\7z\src\Xz.c" />
|
<ClCompile Include="..\ext\7z\src\Xz.c" />
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
7-Zip method IDs (9.04)
|
7-Zip method IDs (9.18)
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
Each compression or crypto method in 7z has unique binary value (ID).
|
Each compression or crypto method in 7z has unique binary value (ID).
|
||||||
@@ -77,7 +77,13 @@ List of defined IDs
|
|||||||
06 - Implode
|
06 - Implode
|
||||||
08 - Deflate
|
08 - Deflate
|
||||||
09 - Deflate64
|
09 - Deflate64
|
||||||
|
10 - Imploding
|
||||||
12 - BZip2 (not used). Use {04 02 02} instead
|
12 - BZip2 (not used). Use {04 02 02} instead
|
||||||
|
14 - LZMA
|
||||||
|
60 - Jpeg
|
||||||
|
61 - WavPack
|
||||||
|
62 - PPMd
|
||||||
|
63 - wzAES
|
||||||
02 - BZip
|
02 - BZip
|
||||||
02 - BZip2
|
02 - BZip2
|
||||||
03 - Rar
|
03 - Rar
|
||||||
|
|||||||
@@ -1,6 +1,19 @@
|
|||||||
HISTORY of the LZMA SDK
|
HISTORY of the LZMA SDK
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
9.21 beta 2011-04-11
|
||||||
|
-------------------------
|
||||||
|
- New class FString for file names at file systems.
|
||||||
|
- Speed optimization in CRC code for big-endian CPUs.
|
||||||
|
- The BUG in Lzma2Dec.c was fixed:
|
||||||
|
Lzma2Decode function didn't work.
|
||||||
|
|
||||||
|
|
||||||
|
9.18 beta 2010-11-02
|
||||||
|
-------------------------
|
||||||
|
- New small SFX module for installers (SfxSetup).
|
||||||
|
|
||||||
|
|
||||||
9.12 beta 2010-03-24
|
9.12 beta 2010-03-24
|
||||||
-------------------------
|
-------------------------
|
||||||
- The BUG in LZMA SDK 9.* was fixed: LZMA2 codec didn't work,
|
- The BUG in LZMA SDK 9.* was fixed: LZMA2 codec didn't work,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
LZMA SDK 9.12
|
LZMA SDK 9.22
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
LZMA SDK provides the documentation, samples, header files, libraries,
|
LZMA SDK provides the documentation, samples, header files, libraries,
|
||||||
@@ -20,10 +20,16 @@ LICENSE
|
|||||||
|
|
||||||
LZMA SDK is written and placed in the public domain by Igor Pavlov.
|
LZMA SDK is written and placed in the public domain by Igor Pavlov.
|
||||||
|
|
||||||
Some code in LZMA is based on public domain code from another developers:
|
Some code in LZMA SDK is based on public domain code from another developers:
|
||||||
1) PPMd var.H (2001): Dmitry Shkarin
|
1) PPMd var.H (2001): Dmitry Shkarin
|
||||||
2) SHA-256: Wei Dai (Crypto++ library)
|
2) SHA-256: Wei Dai (Crypto++ library)
|
||||||
|
|
||||||
|
You can copy, modify, distribute and perform LZMA SDK code, even for commercial purposes,
|
||||||
|
all without asking permission.
|
||||||
|
|
||||||
|
LZMA SDK code is compatible with open source licenses, for example, you can
|
||||||
|
include it to GNU GPL or GNU LGPL code.
|
||||||
|
|
||||||
|
|
||||||
LZMA SDK Contents
|
LZMA SDK Contents
|
||||||
-----------------
|
-----------------
|
||||||
@@ -37,7 +43,7 @@ LZMA SDK includes:
|
|||||||
UNIX/Linux version
|
UNIX/Linux version
|
||||||
------------------
|
------------------
|
||||||
To compile C++ version of file->file LZMA encoding, go to directory
|
To compile C++ version of file->file LZMA encoding, go to directory
|
||||||
C++/7zip/Compress/LZMA_Alone
|
CPP/7zip/Bundles/LzmaCon
|
||||||
and call make to recompile it:
|
and call make to recompile it:
|
||||||
make -f makefile.gcc clean all
|
make -f makefile.gcc clean all
|
||||||
|
|
||||||
@@ -91,8 +97,6 @@ CPP/ -- CPP files
|
|||||||
|
|
||||||
Compress - files related to compression/decompression
|
Compress - files related to compression/decompression
|
||||||
|
|
||||||
LZMA_Alone - file->file LZMA compression/decompression
|
|
||||||
|
|
||||||
Archive - files related to archiving
|
Archive - files related to archiving
|
||||||
|
|
||||||
Common - common files for archive handling
|
Common - common files for archive handling
|
||||||
@@ -101,6 +105,7 @@ CPP/ -- CPP files
|
|||||||
Bundles - Modules that are bundles of other modules
|
Bundles - Modules that are bundles of other modules
|
||||||
|
|
||||||
Alone7z - 7zr.exe: Standalone version of 7z.exe that supports only 7z/LZMA/BCJ/BCJ2
|
Alone7z - 7zr.exe: Standalone version of 7z.exe that supports only 7z/LZMA/BCJ/BCJ2
|
||||||
|
LzmaCon - lzma.exe: LZMA compression/decompression
|
||||||
Format7zR - 7zr.dll: Reduced version of 7za.dll: extracting/compressing to 7z/LZMA/BCJ/BCJ2
|
Format7zR - 7zr.dll: Reduced version of 7za.dll: extracting/compressing to 7z/LZMA/BCJ/BCJ2
|
||||||
Format7zExtractR - 7zxr.dll: Reduced version of 7zxa.dll: extracting from 7z/LZMA/BCJ/BCJ2.
|
Format7zExtractR - 7zxr.dll: Reduced version of 7zxa.dll: extracting from 7z/LZMA/BCJ/BCJ2.
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ EXTERN_C_BEGIN
|
|||||||
|
|
||||||
#define k7zStartHeaderSize 0x20
|
#define k7zStartHeaderSize 0x20
|
||||||
#define k7zSignatureSize 6
|
#define k7zSignatureSize 6
|
||||||
SZIP_API extern Byte k7zSignature[k7zSignatureSize];
|
extern Byte k7zSignature[k7zSignatureSize];
|
||||||
#define k7zMajorVersion 0
|
#define k7zMajorVersion 0
|
||||||
|
|
||||||
enum EIdEnum
|
enum EIdEnum
|
||||||
@@ -76,10 +76,10 @@ typedef struct
|
|||||||
} CSzFolder;
|
} CSzFolder;
|
||||||
|
|
||||||
void SzFolder_Init(CSzFolder *p);
|
void SzFolder_Init(CSzFolder *p);
|
||||||
SZIP_API UInt64 SzFolder_GetUnpackSize(CSzFolder *p);
|
UInt64 SzFolder_GetUnpackSize(CSzFolder *p);
|
||||||
int SzFolder_FindBindPairForInStream(CSzFolder *p, UInt32 inStreamIndex);
|
int SzFolder_FindBindPairForInStream(CSzFolder *p, UInt32 inStreamIndex);
|
||||||
SZIP_API UInt32 SzFolder_GetNumOutStreams(CSzFolder *p);
|
UInt32 SzFolder_GetNumOutStreams(CSzFolder *p);
|
||||||
SZIP_API UInt64 SzFolder_GetUnpackSize(CSzFolder *p);
|
UInt64 SzFolder_GetUnpackSize(CSzFolder *p);
|
||||||
|
|
||||||
SRes SzFolder_Decode(const CSzFolder *folder, const UInt64 *packSizes,
|
SRes SzFolder_Decode(const CSzFolder *folder, const UInt64 *packSizes,
|
||||||
ILookInStream *stream, UInt64 startPos,
|
ILookInStream *stream, UInt64 startPos,
|
||||||
@@ -159,9 +159,9 @@ typedef struct
|
|||||||
CBuf FileNames; /* UTF-16-LE */
|
CBuf FileNames; /* UTF-16-LE */
|
||||||
} CSzArEx;
|
} CSzArEx;
|
||||||
|
|
||||||
SZIP_API void SzArEx_Init(CSzArEx *p);
|
void SzArEx_Init(CSzArEx *p);
|
||||||
void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc);
|
void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc);
|
||||||
SZIP_API UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder);
|
UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder);
|
||||||
int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize);
|
int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -170,7 +170,7 @@ if dest == NULL, the return value specifies the required size of the buffer,
|
|||||||
if dest != NULL, the return value specifies the number of 16-bit characters that
|
if dest != NULL, the return value specifies the number of 16-bit characters that
|
||||||
are written to the dest, including the null-terminating character. */
|
are written to the dest, including the null-terminating character. */
|
||||||
|
|
||||||
SZIP_API size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
|
size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
|
||||||
|
|
||||||
SRes SzArEx_Extract(
|
SRes SzArEx_Extract(
|
||||||
const CSzArEx *db,
|
const CSzArEx *db,
|
||||||
@@ -196,7 +196,7 @@ SZ_ERROR_INPUT_EOF
|
|||||||
SZ_ERROR_FAIL
|
SZ_ERROR_FAIL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SZIP_API SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAlloc *allocTemp);
|
SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAlloc *allocTemp);
|
||||||
|
|
||||||
EXTERN_C_END
|
EXTERN_C_END
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/* 7zAlloc.c -- Allocation functions
|
/* 7zAlloc.c -- Allocation functions
|
||||||
2008-10-04 : Igor Pavlov : Public domain */
|
2010-10-29 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "7zAlloc.h"
|
#include "7zAlloc.h"
|
||||||
|
|
||||||
/* #define _SZ_ALLOC_DEBUG */
|
/* #define _SZ_ALLOC_DEBUG */
|
||||||
|
|||||||
@@ -1,24 +1,15 @@
|
|||||||
/* 7zAlloc.h -- Allocation functions
|
/* 7zAlloc.h -- Allocation functions
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2010-10-29 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __7Z_ALLOC_H
|
#ifndef __7Z_ALLOC_H
|
||||||
#define __7Z_ALLOC_H
|
#define __7Z_ALLOC_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stdlib.h>
|
||||||
#include "Types.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
void *SzAlloc(void *p, size_t size);
|
||||||
extern "C" {
|
void SzFree(void *p, void *address);
|
||||||
#endif
|
|
||||||
|
|
||||||
SZIP_API void *SzAlloc(void *p, size_t size);
|
void *SzAllocTemp(void *p, size_t size);
|
||||||
SZIP_API void SzFree(void *p, void *address);
|
void SzFreeTemp(void *p, void *address);
|
||||||
|
|
||||||
SZIP_API void *SzAllocTemp(void *p, size_t size);
|
|
||||||
SZIP_API void SzFreeTemp(void *p, void *address);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+37
-28
@@ -1,15 +1,24 @@
|
|||||||
/* 7zCrc.c -- CRC32 calculation
|
/* 7zCrc.c -- CRC32 init
|
||||||
2009-11-23 : Igor Pavlov : Public domain */
|
2010-12-01 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "7zCrc.h"
|
#include "7zCrc.h"
|
||||||
#include "CpuArch.h"
|
#include "CpuArch.h"
|
||||||
|
|
||||||
#define kCrcPoly 0xEDB88320
|
#define kCrcPoly 0xEDB88320
|
||||||
|
|
||||||
#ifdef MY_CPU_LE
|
#ifdef MY_CPU_X86_OR_AMD64
|
||||||
#define CRC_NUM_TABLES 8
|
#define CRC_NUM_TABLES 8
|
||||||
|
UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table);
|
||||||
|
#elif defined(MY_CPU_LE)
|
||||||
|
#define CRC_NUM_TABLES 4
|
||||||
#else
|
#else
|
||||||
#define CRC_NUM_TABLES 1
|
#define CRC_NUM_TABLES 5
|
||||||
|
#define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24))
|
||||||
|
UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MY_CPU_BE
|
||||||
|
UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef UInt32 (MY_FAST_CALL *CRC_FUNC)(UInt32 v, const void *data, size_t size, const UInt32 *table);
|
typedef UInt32 (MY_FAST_CALL *CRC_FUNC)(UInt32 v, const void *data, size_t size, const UInt32 *table);
|
||||||
@@ -17,25 +26,6 @@ typedef UInt32 (MY_FAST_CALL *CRC_FUNC)(UInt32 v, const void *data, size_t size,
|
|||||||
static CRC_FUNC g_CrcUpdate;
|
static CRC_FUNC g_CrcUpdate;
|
||||||
UInt32 g_CrcTable[256 * CRC_NUM_TABLES];
|
UInt32 g_CrcTable[256 * CRC_NUM_TABLES];
|
||||||
|
|
||||||
#if CRC_NUM_TABLES == 1
|
|
||||||
|
|
||||||
#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
|
|
||||||
|
|
||||||
static UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const UInt32 *table)
|
|
||||||
{
|
|
||||||
const Byte *p = (const Byte *)data;
|
|
||||||
for (; size > 0; size--, p++)
|
|
||||||
v = CRC_UPDATE_BYTE_2(v, *p);
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table);
|
|
||||||
UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)
|
UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)
|
||||||
{
|
{
|
||||||
return g_CrcUpdate(v, data, size, g_CrcTable);
|
return g_CrcUpdate(v, data, size, g_CrcTable);
|
||||||
@@ -57,18 +47,37 @@ void MY_FAST_CALL CrcGenerateTable()
|
|||||||
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
|
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
|
||||||
g_CrcTable[i] = r;
|
g_CrcTable[i] = r;
|
||||||
}
|
}
|
||||||
#if CRC_NUM_TABLES == 1
|
|
||||||
g_CrcUpdate = CrcUpdateT1;
|
|
||||||
#else
|
|
||||||
for (; i < 256 * CRC_NUM_TABLES; i++)
|
for (; i < 256 * CRC_NUM_TABLES; i++)
|
||||||
{
|
{
|
||||||
UInt32 r = g_CrcTable[i - 256];
|
UInt32 r = g_CrcTable[i - 256];
|
||||||
g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8);
|
g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MY_CPU_LE
|
||||||
|
|
||||||
g_CrcUpdate = CrcUpdateT4;
|
g_CrcUpdate = CrcUpdateT4;
|
||||||
#ifdef MY_CPU_X86_OR_AMD64
|
|
||||||
|
#if CRC_NUM_TABLES == 8
|
||||||
if (!CPU_Is_InOrder())
|
if (!CPU_Is_InOrder())
|
||||||
g_CrcUpdate = CrcUpdateT8;
|
g_CrcUpdate = CrcUpdateT8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
#ifndef MY_CPU_BE
|
||||||
|
UInt32 k = 1;
|
||||||
|
if (*(const Byte *)&k == 1)
|
||||||
|
g_CrcUpdate = CrcUpdateT4;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
for (i = 256 * CRC_NUM_TABLES - 1; i >= 256; i--)
|
||||||
|
{
|
||||||
|
UInt32 x = g_CrcTable[i - 256];
|
||||||
|
g_CrcTable[i] = CRC_UINT32_SWAP(x);
|
||||||
|
}
|
||||||
|
g_CrcUpdate = CrcUpdateT1_BeT4;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,14 @@ EXTERN_C_BEGIN
|
|||||||
extern UInt32 g_CrcTable[];
|
extern UInt32 g_CrcTable[];
|
||||||
|
|
||||||
/* Call CrcGenerateTable one time before other CRC functions */
|
/* Call CrcGenerateTable one time before other CRC functions */
|
||||||
SZIP_API void MY_FAST_CALL CrcGenerateTable(void);
|
void MY_FAST_CALL CrcGenerateTable(void);
|
||||||
|
|
||||||
#define CRC_INIT_VAL 0xFFFFFFFF
|
#define CRC_INIT_VAL 0xFFFFFFFF
|
||||||
#define CRC_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL)
|
#define CRC_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL)
|
||||||
#define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
|
#define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
|
||||||
|
|
||||||
UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void *data, size_t size);
|
UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void *data, size_t size);
|
||||||
SZIP_API UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size);
|
UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size);
|
||||||
|
|
||||||
EXTERN_C_END
|
EXTERN_C_END
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/* 7zCrcOpt.c -- CRC32 calculation : optimized version
|
/* 7zCrcOpt.c -- CRC32 calculation
|
||||||
2009-11-23 : Igor Pavlov : Public domain */
|
2010-12-01 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "CpuArch.h"
|
#include "CpuArch.h"
|
||||||
|
|
||||||
#ifdef MY_CPU_LE
|
|
||||||
|
|
||||||
#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
|
#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
|
||||||
|
|
||||||
|
#ifndef MY_CPU_BE
|
||||||
|
|
||||||
UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table)
|
UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table)
|
||||||
{
|
{
|
||||||
const Byte *p = (const Byte *)data;
|
const Byte *p = (const Byte *)data;
|
||||||
@@ -32,3 +32,33 @@ UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const U
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef MY_CPU_LE
|
||||||
|
|
||||||
|
#define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24))
|
||||||
|
|
||||||
|
UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table)
|
||||||
|
{
|
||||||
|
const Byte *p = (const Byte *)data;
|
||||||
|
for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++)
|
||||||
|
v = CRC_UPDATE_BYTE_2(v, *p);
|
||||||
|
v = CRC_UINT32_SWAP(v);
|
||||||
|
table += 0x100;
|
||||||
|
for (; size >= 4; size -= 4, p += 4)
|
||||||
|
{
|
||||||
|
v ^= *(const UInt32 *)p;
|
||||||
|
v =
|
||||||
|
table[0x000 + (v & 0xFF)] ^
|
||||||
|
table[0x100 + ((v >> 8) & 0xFF)] ^
|
||||||
|
table[0x200 + ((v >> 16) & 0xFF)] ^
|
||||||
|
table[0x300 + ((v >> 24))];
|
||||||
|
}
|
||||||
|
table -= 0x100;
|
||||||
|
v = CRC_UINT32_SWAP(v);
|
||||||
|
for (; size > 0; size--, p++)
|
||||||
|
v = CRC_UPDATE_BYTE_2(v, *p);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
+43
-17
@@ -1,5 +1,5 @@
|
|||||||
/* 7zDec.c -- Decoding from 7z folder
|
/* 7zDec.c -- Decoding from 7z folder
|
||||||
2010-03-15 : Igor Pavlov : Public domain */
|
2010-11-02 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -18,9 +18,13 @@
|
|||||||
|
|
||||||
#define k_Copy 0
|
#define k_Copy 0
|
||||||
#define k_LZMA2 0x21
|
#define k_LZMA2 0x21
|
||||||
#define k_LZMA 0x30101
|
#define k_LZMA 0x30101
|
||||||
#define k_BCJ 0x03030103
|
#define k_BCJ 0x03030103
|
||||||
#define k_BCJ2 0x0303011B
|
#define k_PPC 0x03030205
|
||||||
|
#define k_ARM 0x03030501
|
||||||
|
#define k_ARMT 0x03030701
|
||||||
|
#define k_SPARC 0x03030805
|
||||||
|
#define k_BCJ2 0x0303011B
|
||||||
|
|
||||||
#ifdef _7ZIP_PPMD_SUPPPORT
|
#ifdef _7ZIP_PPMD_SUPPPORT
|
||||||
|
|
||||||
@@ -260,7 +264,6 @@ static Bool IS_SUPPORTED_CODER(const CSzCoderInfo *c)
|
|||||||
IS_MAIN_METHOD((UInt32)c->MethodID);
|
IS_MAIN_METHOD((UInt32)c->MethodID);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IS_BCJ(c) ((c)->MethodID == k_BCJ && (c)->NumInStreams == 1 && (c)->NumOutStreams == 1)
|
|
||||||
#define IS_BCJ2(c) ((c)->MethodID == k_BCJ2 && (c)->NumInStreams == 4 && (c)->NumOutStreams == 1)
|
#define IS_BCJ2(c) ((c)->MethodID == k_BCJ2 && (c)->NumInStreams == 4 && (c)->NumOutStreams == 1)
|
||||||
|
|
||||||
static SRes CheckSupportedFolder(const CSzFolder *f)
|
static SRes CheckSupportedFolder(const CSzFolder *f)
|
||||||
@@ -277,11 +280,24 @@ static SRes CheckSupportedFolder(const CSzFolder *f)
|
|||||||
}
|
}
|
||||||
if (f->NumCoders == 2)
|
if (f->NumCoders == 2)
|
||||||
{
|
{
|
||||||
if (!IS_BCJ(&f->Coders[1]) ||
|
CSzCoderInfo *c = &f->Coders[1];
|
||||||
f->NumPackStreams != 1 || f->PackStreams[0] != 0 ||
|
if (c->MethodID > (UInt32)0xFFFFFFFF ||
|
||||||
|
c->NumInStreams != 1 ||
|
||||||
|
c->NumOutStreams != 1 ||
|
||||||
|
f->NumPackStreams != 1 ||
|
||||||
|
f->PackStreams[0] != 0 ||
|
||||||
f->NumBindPairs != 1 ||
|
f->NumBindPairs != 1 ||
|
||||||
f->BindPairs[0].InIndex != 1 || f->BindPairs[0].OutIndex != 0)
|
f->BindPairs[0].InIndex != 1 ||
|
||||||
|
f->BindPairs[0].OutIndex != 0)
|
||||||
return SZ_ERROR_UNSUPPORTED;
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
|
switch ((UInt32)c->MethodID)
|
||||||
|
{
|
||||||
|
case k_BCJ:
|
||||||
|
case k_ARM:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
|
}
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
if (f->NumCoders == 4)
|
if (f->NumCoders == 4)
|
||||||
@@ -314,6 +330,8 @@ static UInt64 GetSum(const UInt64 *values, UInt32 index)
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CASE_BRA_CONV(isa) case k_ ## isa: isa ## _Convert(outBuffer, outSize, 0, 0); break;
|
||||||
|
|
||||||
static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes,
|
static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes,
|
||||||
ILookInStream *inStream, UInt64 startPos,
|
ILookInStream *inStream, UInt64 startPos,
|
||||||
Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain,
|
Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain,
|
||||||
@@ -391,14 +409,6 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (coder->MethodID == k_BCJ)
|
|
||||||
{
|
|
||||||
UInt32 state;
|
|
||||||
if (ci != 1)
|
|
||||||
return SZ_ERROR_UNSUPPORTED;
|
|
||||||
x86_Convert_Init(state);
|
|
||||||
x86_Convert(outBuffer, outSize, 0, &state, 0);
|
|
||||||
}
|
|
||||||
else if (coder->MethodID == k_BCJ2)
|
else if (coder->MethodID == k_BCJ2)
|
||||||
{
|
{
|
||||||
UInt64 offset = GetSum(packSizes, 1);
|
UInt64 offset = GetSum(packSizes, 1);
|
||||||
@@ -425,7 +435,23 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes,
|
|||||||
RINOK(res)
|
RINOK(res)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return SZ_ERROR_UNSUPPORTED;
|
{
|
||||||
|
if (ci != 1)
|
||||||
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
|
switch(coder->MethodID)
|
||||||
|
{
|
||||||
|
case k_BCJ:
|
||||||
|
{
|
||||||
|
UInt32 state;
|
||||||
|
x86_Convert_Init(state);
|
||||||
|
x86_Convert(outBuffer, outSize, 0, &state, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
CASE_BRA_CONV(ARM)
|
||||||
|
default:
|
||||||
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* 7zIn.c -- 7z Input functions
|
/* 7zIn.c -- 7z Input functions
|
||||||
2010-03-11 : Igor Pavlov : Public domain */
|
2010-10-29 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -1218,12 +1218,16 @@ static SRes SzArEx_Open2(
|
|||||||
ISzAlloc *allocTemp)
|
ISzAlloc *allocTemp)
|
||||||
{
|
{
|
||||||
Byte header[k7zStartHeaderSize];
|
Byte header[k7zStartHeaderSize];
|
||||||
|
Int64 startArcPos;
|
||||||
UInt64 nextHeaderOffset, nextHeaderSize;
|
UInt64 nextHeaderOffset, nextHeaderSize;
|
||||||
size_t nextHeaderSizeT;
|
size_t nextHeaderSizeT;
|
||||||
UInt32 nextHeaderCRC;
|
UInt32 nextHeaderCRC;
|
||||||
CBuf buffer;
|
CBuf buffer;
|
||||||
SRes res;
|
SRes res;
|
||||||
|
|
||||||
|
startArcPos = 0;
|
||||||
|
RINOK(inStream->Seek(inStream, &startArcPos, SZ_SEEK_CUR));
|
||||||
|
|
||||||
RINOK(LookInStream_Read2(inStream, header, k7zStartHeaderSize, SZ_ERROR_NO_ARCHIVE));
|
RINOK(LookInStream_Read2(inStream, header, k7zStartHeaderSize, SZ_ERROR_NO_ARCHIVE));
|
||||||
|
|
||||||
if (!TestSignatureCandidate(header))
|
if (!TestSignatureCandidate(header))
|
||||||
@@ -1235,7 +1239,7 @@ static SRes SzArEx_Open2(
|
|||||||
nextHeaderSize = GetUi64(header + 20);
|
nextHeaderSize = GetUi64(header + 20);
|
||||||
nextHeaderCRC = GetUi32(header + 28);
|
nextHeaderCRC = GetUi32(header + 28);
|
||||||
|
|
||||||
p->startPosAfterHeader = k7zStartHeaderSize;
|
p->startPosAfterHeader = startArcPos + k7zStartHeaderSize;
|
||||||
|
|
||||||
if (CrcCalc(header + 12, 20) != GetUi32(header + 8))
|
if (CrcCalc(header + 12, 20) != GetUi32(header + 8))
|
||||||
return SZ_ERROR_CRC;
|
return SZ_ERROR_CRC;
|
||||||
@@ -1252,13 +1256,13 @@ static SRes SzArEx_Open2(
|
|||||||
{
|
{
|
||||||
Int64 pos = 0;
|
Int64 pos = 0;
|
||||||
RINOK(inStream->Seek(inStream, &pos, SZ_SEEK_END));
|
RINOK(inStream->Seek(inStream, &pos, SZ_SEEK_END));
|
||||||
if ((UInt64)pos < nextHeaderOffset ||
|
if ((UInt64)pos < startArcPos + nextHeaderOffset ||
|
||||||
(UInt64)pos < k7zStartHeaderSize + nextHeaderOffset ||
|
(UInt64)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset ||
|
||||||
(UInt64)pos < k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize)
|
(UInt64)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize)
|
||||||
return SZ_ERROR_INPUT_EOF;
|
return SZ_ERROR_INPUT_EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
RINOK(LookInStream_SeekTo(inStream, k7zStartHeaderSize + nextHeaderOffset));
|
RINOK(LookInStream_SeekTo(inStream, startArcPos + k7zStartHeaderSize + nextHeaderOffset));
|
||||||
|
|
||||||
if (!Buf_Create(&buffer, nextHeaderSizeT, allocTemp))
|
if (!Buf_Create(&buffer, nextHeaderSizeT, allocTemp))
|
||||||
return SZ_ERROR_MEM;
|
return SZ_ERROR_MEM;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#define MY_VER_MAJOR 9
|
#define MY_VER_MAJOR 9
|
||||||
#define MY_VER_MINOR 12
|
#define MY_VER_MINOR 22
|
||||||
#define MY_VER_BUILD 0
|
#define MY_VER_BUILD 00
|
||||||
#define MY_VERSION "9.12 beta"
|
#define MY_VERSION "9.22 beta"
|
||||||
#define MY_DATE "2010-03-24"
|
#define MY_7ZIP_VERSION "9.22 beta"
|
||||||
|
#define MY_DATE "2011-04-18"
|
||||||
#define MY_COPYRIGHT ": Igor Pavlov : Public domain"
|
#define MY_COPYRIGHT ": Igor Pavlov : Public domain"
|
||||||
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE
|
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Bra.c -- Converters for RISC code
|
/* Bra.c -- Converters for RISC code
|
||||||
2008-10-04 : Igor Pavlov : Public domain */
|
2010-04-16 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Bra.h"
|
#include "Bra.h"
|
||||||
|
|
||||||
@@ -104,8 +104,8 @@ SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
|
|||||||
size -= 4;
|
size -= 4;
|
||||||
for (i = 0; i <= size; i += 4)
|
for (i = 0; i <= size; i += 4)
|
||||||
{
|
{
|
||||||
if (data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00 ||
|
if ((data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00) ||
|
||||||
data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0)
|
(data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0))
|
||||||
{
|
{
|
||||||
UInt32 src =
|
UInt32 src =
|
||||||
((UInt32)data[i + 0] << 24) |
|
((UInt32)data[i + 0] << 24) |
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* CpuArch.c -- CPU specific code
|
/* CpuArch.c -- CPU specific code
|
||||||
2009-12-12: Igor Pavlov : Public domain */
|
2010-10-26: Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "CpuArch.h"
|
#include "CpuArch.h"
|
||||||
|
|
||||||
@@ -71,28 +71,14 @@ static void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d)
|
|||||||
*d = d2;
|
*d = d2;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#ifdef ORIGINAL_7ZIP
|
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"cpuid"
|
"cpuid"
|
||||||
: "=a" (*a) ,
|
: "=a" (*a) ,
|
||||||
"=b" (*b) ,
|
"=b" (*b) ,
|
||||||
"=c" (*c) ,
|
"=c" (*c) ,
|
||||||
"=d" (*d)
|
"=d" (*d)
|
||||||
: "0" (function)) ;
|
: "0" (function)) ;
|
||||||
#else
|
|
||||||
//
|
|
||||||
// Original code doesn't compile on linux for a shared library build
|
|
||||||
// Use proposed fix from the 7-Zip forum on SourceForge
|
|
||||||
// http://sourceforge.net/projects/sevenzip/forums/forum/45797/topic/3768042
|
|
||||||
//
|
|
||||||
__asm__ __volatile__("pushl %%ebx \n\t" /* save %ebx */
|
|
||||||
"cpuid \n\t"
|
|
||||||
"movl %%ebx, %1 \n\t" /* save what cpuid just put in %ebx */
|
|
||||||
"popl %%ebx \n\t" /* restore the old %ebx */
|
|
||||||
: "=a"(*a), "=r"(*b), "=c"(*c), "=d"(*d)
|
|
||||||
: "a"(function)
|
|
||||||
: "cc");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* CpuArch.h -- CPU specific code
|
/* CpuArch.h -- CPU specific code
|
||||||
2010-03-11: Igor Pavlov : Public domain */
|
2010-12-01: Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __CPU_ARCH_H
|
#ifndef __CPU_ARCH_H
|
||||||
#define __CPU_ARCH_H
|
#define __CPU_ARCH_H
|
||||||
@@ -40,14 +40,26 @@ If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of pla
|
|||||||
#define MY_CPU_ARM_LE
|
#define MY_CPU_ARM_LE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32) && defined(_M_IA64)
|
||||||
|
#define MY_CPU_IA64_LE
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MY_CPU_X86_OR_AMD64)
|
#if defined(MY_CPU_X86_OR_AMD64)
|
||||||
#define MY_CPU_LE_UNALIGN
|
#define MY_CPU_LE_UNALIGN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MY_CPU_X86_OR_AMD64) || defined(MY_CPU_ARM_LE)
|
#if defined(MY_CPU_X86_OR_AMD64) || defined(MY_CPU_ARM_LE) || defined(MY_CPU_IA64_LE) || defined(__ARMEL__) || defined(__MIPSEL__) || defined(__LITTLE_ENDIAN__)
|
||||||
#define MY_CPU_LE
|
#define MY_CPU_LE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__BIG_ENDIAN__) || defined(__m68k__) || defined(__ARMEB__) || defined(__MIPSEB__)
|
||||||
|
#define MY_CPU_BE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MY_CPU_LE) && defined(MY_CPU_BE)
|
||||||
|
Stop_Compiling_Bad_Endian
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MY_CPU_LE_UNALIGN
|
#ifdef MY_CPU_LE_UNALIGN
|
||||||
|
|
||||||
#define GetUi16(p) (*(const UInt16 *)(p))
|
#define GetUi16(p) (*(const UInt16 *)(p))
|
||||||
@@ -55,6 +67,7 @@ If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of pla
|
|||||||
#define GetUi64(p) (*(const UInt64 *)(p))
|
#define GetUi64(p) (*(const UInt64 *)(p))
|
||||||
#define SetUi16(p, d) *(UInt16 *)(p) = (d);
|
#define SetUi16(p, d) *(UInt16 *)(p) = (d);
|
||||||
#define SetUi32(p, d) *(UInt32 *)(p) = (d);
|
#define SetUi32(p, d) *(UInt32 *)(p) = (d);
|
||||||
|
#define SetUi64(p, d) *(UInt64 *)(p) = (d);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -78,6 +91,10 @@ If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of pla
|
|||||||
((Byte *)(p))[2] = (Byte)(_x_ >> 16); \
|
((Byte *)(p))[2] = (Byte)(_x_ >> 16); \
|
||||||
((Byte *)(p))[3] = (Byte)(_x_ >> 24); }
|
((Byte *)(p))[3] = (Byte)(_x_ >> 24); }
|
||||||
|
|
||||||
|
#define SetUi64(p, d) { UInt64 _x64_ = (d); \
|
||||||
|
SetUi32(p, (UInt32)_x64_); \
|
||||||
|
SetUi32(((Byte *)(p)) + 4, (UInt32)(_x64_ >> 32)); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MY_CPU_LE_UNALIGN) && defined(_WIN64) && (_MSC_VER >= 1300)
|
#if defined(MY_CPU_LE_UNALIGN) && defined(_WIN64) && (_MSC_VER >= 1300)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Lzma2Dec.c -- LZMA2 Decoder
|
/* Lzma2Dec.c -- LZMA2 Decoder
|
||||||
2009-05-03 : Igor Pavlov : Public domain */
|
2010-12-15 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
/* #define SHOW_DEBUG_INFO */
|
/* #define SHOW_DEBUG_INFO */
|
||||||
|
|
||||||
@@ -330,27 +330,21 @@ SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, const Byte *
|
|||||||
SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
||||||
Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc)
|
Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc)
|
||||||
{
|
{
|
||||||
CLzma2Dec decoder;
|
CLzma2Dec p;
|
||||||
SRes res;
|
SRes res;
|
||||||
SizeT outSize = *destLen, inSize = *srcLen;
|
SizeT outSize = *destLen, inSize = *srcLen;
|
||||||
Byte props[LZMA_PROPS_SIZE];
|
|
||||||
|
|
||||||
Lzma2Dec_Construct(&decoder);
|
|
||||||
|
|
||||||
*destLen = *srcLen = 0;
|
*destLen = *srcLen = 0;
|
||||||
*status = LZMA_STATUS_NOT_SPECIFIED;
|
*status = LZMA_STATUS_NOT_SPECIFIED;
|
||||||
decoder.decoder.dic = dest;
|
Lzma2Dec_Construct(&p);
|
||||||
decoder.decoder.dicBufSize = outSize;
|
RINOK(Lzma2Dec_AllocateProbs(&p, prop, alloc));
|
||||||
|
p.decoder.dic = dest;
|
||||||
RINOK(Lzma2Dec_GetOldProps(prop, props));
|
p.decoder.dicBufSize = outSize;
|
||||||
RINOK(LzmaDec_AllocateProbs(&decoder.decoder, props, LZMA_PROPS_SIZE, alloc));
|
Lzma2Dec_Init(&p);
|
||||||
|
|
||||||
*srcLen = inSize;
|
*srcLen = inSize;
|
||||||
res = Lzma2Dec_DecodeToDic(&decoder, outSize, src, srcLen, finishMode, status);
|
res = Lzma2Dec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);
|
||||||
*destLen = decoder.decoder.dicPos;
|
*destLen = p.decoder.dicPos;
|
||||||
if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
|
if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
|
||||||
res = SZ_ERROR_INPUT_EOF;
|
res = SZ_ERROR_INPUT_EOF;
|
||||||
|
Lzma2Dec_FreeProbs(&p, alloc);
|
||||||
LzmaDec_FreeProbs(&decoder.decoder, alloc);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Lzma2Enc.c -- LZMA2 Encoder
|
/* Lzma2Enc.c -- LZMA2 Encoder
|
||||||
2010-03-24 : Igor Pavlov : Public domain */
|
2010-09-24 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
/* #include <stdio.h> */
|
/* #include <stdio.h> */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -141,7 +141,7 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,
|
|||||||
|
|
||||||
PRF(printf(" "));
|
PRF(printf(" "));
|
||||||
|
|
||||||
outBuf[destPos++] = (Byte)(LZMA2_CONTROL_LZMA | (mode << 5) | (u >> 16) & 0x1F);
|
outBuf[destPos++] = (Byte)(LZMA2_CONTROL_LZMA | (mode << 5) | ((u >> 16) & 0x1F));
|
||||||
outBuf[destPos++] = (Byte)(u >> 8);
|
outBuf[destPos++] = (Byte)(u >> 8);
|
||||||
outBuf[destPos++] = (Byte)u;
|
outBuf[destPos++] = (Byte)u;
|
||||||
outBuf[destPos++] = (Byte)(pm >> 8);
|
outBuf[destPos++] = (Byte)(pm >> 8);
|
||||||
@@ -240,9 +240,7 @@ static SRes Progress(ICompressProgress *p, UInt64 inSize, UInt64 outSize)
|
|||||||
|
|
||||||
/* ---------- Lzma2 ---------- */
|
/* ---------- Lzma2 ---------- */
|
||||||
|
|
||||||
extern struct _CLzma2Enc;
|
typedef struct
|
||||||
|
|
||||||
typedef struct _CLzma2Enc
|
|
||||||
{
|
{
|
||||||
Byte propEncoded;
|
Byte propEncoded;
|
||||||
CLzma2EncProps props;
|
CLzma2EncProps props;
|
||||||
@@ -271,7 +269,7 @@ static SRes Lzma2Enc_EncodeMt1(CLzma2EncInt *p, CLzma2Enc *mainEncoder,
|
|||||||
|
|
||||||
if (mainEncoder->outBuf == 0)
|
if (mainEncoder->outBuf == 0)
|
||||||
{
|
{
|
||||||
mainEncoder->outBuf = IAlloc_Alloc(mainEncoder->alloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX);
|
mainEncoder->outBuf = (Byte *)IAlloc_Alloc(mainEncoder->alloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX);
|
||||||
if (mainEncoder->outBuf == 0)
|
if (mainEncoder->outBuf == 0)
|
||||||
return SZ_ERROR_MEM;
|
return SZ_ERROR_MEM;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* LzmaDec.c -- LZMA Decoder
|
/* LzmaDec.c -- LZMA Decoder
|
||||||
2009-09-20 : Igor Pavlov : Public domain */
|
2010-12-15 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "LzmaDec.h"
|
#include "LzmaDec.h"
|
||||||
|
|
||||||
@@ -442,8 +442,9 @@ static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
|
|||||||
|
|
||||||
p->processedPos += len;
|
p->processedPos += len;
|
||||||
p->remainLen -= len;
|
p->remainLen -= len;
|
||||||
while (len-- != 0)
|
while (len != 0)
|
||||||
{
|
{
|
||||||
|
len--;
|
||||||
dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
|
dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
|
||||||
dicPos++;
|
dicPos++;
|
||||||
}
|
}
|
||||||
@@ -972,28 +973,21 @@ SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
|||||||
{
|
{
|
||||||
CLzmaDec p;
|
CLzmaDec p;
|
||||||
SRes res;
|
SRes res;
|
||||||
SizeT inSize = *srcLen;
|
SizeT outSize = *destLen, inSize = *srcLen;
|
||||||
SizeT outSize = *destLen;
|
*destLen = *srcLen = 0;
|
||||||
*srcLen = *destLen = 0;
|
*status = LZMA_STATUS_NOT_SPECIFIED;
|
||||||
if (inSize < RC_INIT_SIZE)
|
if (inSize < RC_INIT_SIZE)
|
||||||
return SZ_ERROR_INPUT_EOF;
|
return SZ_ERROR_INPUT_EOF;
|
||||||
|
|
||||||
LzmaDec_Construct(&p);
|
LzmaDec_Construct(&p);
|
||||||
res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc);
|
RINOK(LzmaDec_AllocateProbs(&p, propData, propSize, alloc));
|
||||||
if (res != 0)
|
|
||||||
return res;
|
|
||||||
p.dic = dest;
|
p.dic = dest;
|
||||||
p.dicBufSize = outSize;
|
p.dicBufSize = outSize;
|
||||||
|
|
||||||
LzmaDec_Init(&p);
|
LzmaDec_Init(&p);
|
||||||
|
|
||||||
*srcLen = inSize;
|
*srcLen = inSize;
|
||||||
res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);
|
res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);
|
||||||
|
*destLen = p.dicPos;
|
||||||
if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
|
if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
|
||||||
res = SZ_ERROR_INPUT_EOF;
|
res = SZ_ERROR_INPUT_EOF;
|
||||||
|
|
||||||
(*destLen) = p.dicPos;
|
|
||||||
LzmaDec_FreeProbs(&p, alloc);
|
LzmaDec_FreeProbs(&p, alloc);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* LzmaEnc.c -- LZMA Encoder
|
/* LzmaEnc.c -- LZMA Encoder
|
||||||
2009-11-24 : Igor Pavlov : Public domain */
|
2011-01-27 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -46,6 +46,7 @@ void LzmaEncProps_Init(CLzmaEncProps *p)
|
|||||||
{
|
{
|
||||||
p->level = 5;
|
p->level = 5;
|
||||||
p->dictSize = p->mc = 0;
|
p->dictSize = p->mc = 0;
|
||||||
|
p->reduceSize = (UInt32)(Int32)-1;
|
||||||
p->lc = p->lp = p->pb = p->algo = p->fb = p->btMode = p->numHashBytes = p->numThreads = -1;
|
p->lc = p->lp = p->pb = p->algo = p->fb = p->btMode = p->numHashBytes = p->numThreads = -1;
|
||||||
p->writeEndMark = 0;
|
p->writeEndMark = 0;
|
||||||
}
|
}
|
||||||
@@ -56,6 +57,15 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p)
|
|||||||
if (level < 0) level = 5;
|
if (level < 0) level = 5;
|
||||||
p->level = level;
|
p->level = level;
|
||||||
if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26)));
|
if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26)));
|
||||||
|
if (p->dictSize > p->reduceSize)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
for (i = 15; i <= 30; i++)
|
||||||
|
{
|
||||||
|
if (p->reduceSize <= ((UInt32)2 << i)) { p->dictSize = ((UInt32)2 << i); break; }
|
||||||
|
if (p->reduceSize <= ((UInt32)3 << i)) { p->dictSize = ((UInt32)3 << i); break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
if (p->lc < 0) p->lc = 3;
|
if (p->lc < 0) p->lc = 3;
|
||||||
if (p->lp < 0) p->lp = 0;
|
if (p->lp < 0) p->lp = 0;
|
||||||
if (p->pb < 0) p->pb = 2;
|
if (p->pb < 0) p->pb = 2;
|
||||||
@@ -329,7 +339,6 @@ typedef struct
|
|||||||
|
|
||||||
SRes result;
|
SRes result;
|
||||||
UInt32 dictSize;
|
UInt32 dictSize;
|
||||||
UInt32 matchFinderCycles;
|
|
||||||
|
|
||||||
int needInit;
|
int needInit;
|
||||||
|
|
||||||
@@ -395,10 +404,9 @@ SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2)
|
|||||||
LzmaEncProps_Normalize(&props);
|
LzmaEncProps_Normalize(&props);
|
||||||
|
|
||||||
if (props.lc > LZMA_LC_MAX || props.lp > LZMA_LP_MAX || props.pb > LZMA_PB_MAX ||
|
if (props.lc > LZMA_LC_MAX || props.lp > LZMA_LP_MAX || props.pb > LZMA_PB_MAX ||
|
||||||
props.dictSize > (1 << kDicLogSizeMaxCompress) || props.dictSize > (1 << 30))
|
props.dictSize > ((UInt32)1 << kDicLogSizeMaxCompress) || props.dictSize > ((UInt32)1 << 30))
|
||||||
return SZ_ERROR_PARAM;
|
return SZ_ERROR_PARAM;
|
||||||
p->dictSize = props.dictSize;
|
p->dictSize = props.dictSize;
|
||||||
p->matchFinderCycles = props.mc;
|
|
||||||
{
|
{
|
||||||
unsigned fb = props.fb;
|
unsigned fb = props.fb;
|
||||||
if (fb < 5)
|
if (fb < 5)
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
/* LzmaEnc.h -- LZMA Encoder
|
/* LzmaEnc.h -- LZMA Encoder
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2011-01-27 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZMA_ENC_H
|
#ifndef __LZMA_ENC_H
|
||||||
#define __LZMA_ENC_H
|
#define __LZMA_ENC_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LZMA_PROPS_SIZE 5
|
#define LZMA_PROPS_SIZE 5
|
||||||
|
|
||||||
@@ -18,6 +16,8 @@ typedef struct _CLzmaEncProps
|
|||||||
UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
|
UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
|
||||||
(1 << 12) <= dictSize <= (1 << 30) for 64-bit version
|
(1 << 12) <= dictSize <= (1 << 30) for 64-bit version
|
||||||
default = (1 << 24) */
|
default = (1 << 24) */
|
||||||
|
UInt32 reduceSize; /* estimated size of data that will be compressed. default = 0xFFFFFFFF.
|
||||||
|
Encoder uses this value to reduce dictionary size */
|
||||||
int lc; /* 0 <= lc <= 8, default = 3 */
|
int lc; /* 0 <= lc <= 8, default = 3 */
|
||||||
int lp; /* 0 <= lp <= 4, default = 0 */
|
int lp; /* 0 <= lp <= 4, default = 0 */
|
||||||
int pb; /* 0 <= pb <= 4, default = 2 */
|
int pb; /* 0 <= pb <= 4, default = 2 */
|
||||||
@@ -73,8 +73,6 @@ SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
|||||||
const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
|
const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
|
||||||
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
|
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* MtCoder.c -- Multi-thread Coder
|
/* MtCoder.c -- Multi-thread Coder
|
||||||
2010-03-24 : Igor Pavlov : Public domain */
|
2010-09-24 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ static void CMtThread_Destruct(CMtThread *p)
|
|||||||
#define MY_BUF_ALLOC(buf, size, newSize) \
|
#define MY_BUF_ALLOC(buf, size, newSize) \
|
||||||
if (buf == 0 || size != newSize) \
|
if (buf == 0 || size != newSize) \
|
||||||
{ IAlloc_Free(p->mtCoder->alloc, buf); \
|
{ IAlloc_Free(p->mtCoder->alloc, buf); \
|
||||||
size = newSize; buf = IAlloc_Alloc(p->mtCoder->alloc, size); \
|
size = newSize; buf = (Byte *)IAlloc_Alloc(p->mtCoder->alloc, size); \
|
||||||
if (buf == 0) return SZ_ERROR_MEM; }
|
if (buf == 0) return SZ_ERROR_MEM; }
|
||||||
|
|
||||||
static SRes CMtThread_Prepare(CMtThread *p)
|
static SRes CMtThread_Prepare(CMtThread *p)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Ppmd.h -- PPMD codec common code
|
/* Ppmd.h -- PPMD codec common code
|
||||||
2010-03-12 : Igor Pavlov : Public domain
|
2011-01-27 : Igor Pavlov : Public domain
|
||||||
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
||||||
|
|
||||||
#ifndef __PPMD_H
|
#ifndef __PPMD_H
|
||||||
@@ -29,6 +29,9 @@ EXTERN_C_BEGIN
|
|||||||
#define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4)
|
#define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4)
|
||||||
#define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4)
|
#define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4)
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
/* Most compilers works OK here even without #pragma pack(push, 1), but some GCC compilers need it. */
|
||||||
|
|
||||||
/* SEE-contexts for PPM-contexts with masked symbols */
|
/* SEE-contexts for PPM-contexts with masked symbols */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -48,6 +51,8 @@ typedef struct
|
|||||||
UInt16 SuccessorHigh;
|
UInt16 SuccessorHigh;
|
||||||
} CPpmd_State;
|
} CPpmd_State;
|
||||||
|
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
typedef
|
typedef
|
||||||
#ifdef PPMD_32BIT
|
#ifdef PPMD_32BIT
|
||||||
CPpmd_State *
|
CPpmd_State *
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,133 +0,0 @@
|
|||||||
/* Ppmd8.h -- PPMdI codec
|
|
||||||
2010-03-24 : Igor Pavlov : Public domain
|
|
||||||
This code is based on:
|
|
||||||
PPMd var.I (2002): Dmitry Shkarin : Public domain
|
|
||||||
Carryless rangecoder (1999): Dmitry Subbotin : Public domain */
|
|
||||||
|
|
||||||
#ifndef __PPMD8_H
|
|
||||||
#define __PPMD8_H
|
|
||||||
|
|
||||||
#include "Ppmd.h"
|
|
||||||
|
|
||||||
EXTERN_C_BEGIN
|
|
||||||
|
|
||||||
#define PPMD8_MIN_ORDER 2
|
|
||||||
#define PPMD8_MAX_ORDER 16
|
|
||||||
|
|
||||||
struct CPpmd8_Context_;
|
|
||||||
|
|
||||||
typedef
|
|
||||||
#ifdef PPMD_32BIT
|
|
||||||
struct CPpmd8_Context_ *
|
|
||||||
#else
|
|
||||||
UInt32
|
|
||||||
#endif
|
|
||||||
CPpmd8_Context_Ref;
|
|
||||||
|
|
||||||
typedef struct CPpmd8_Context_
|
|
||||||
{
|
|
||||||
Byte NumStats;
|
|
||||||
Byte Flags;
|
|
||||||
UInt16 SummFreq;
|
|
||||||
CPpmd_State_Ref Stats;
|
|
||||||
CPpmd8_Context_Ref Suffix;
|
|
||||||
} CPpmd8_Context;
|
|
||||||
|
|
||||||
#define Ppmd8Context_OneState(p) ((CPpmd_State *)&(p)->SummFreq)
|
|
||||||
|
|
||||||
/* The BUG in Shkarin's code for FREEZE mode was fixed, but that fixed
|
|
||||||
code is not compatible with original code for some files compressed
|
|
||||||
in FREEZE mode. So we disable FREEZE mode support. */
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
PPMD8_RESTORE_METHOD_RESTART,
|
|
||||||
PPMD8_RESTORE_METHOD_CUT_OFF
|
|
||||||
#ifdef PPMD8_FREEZE_SUPPORT
|
|
||||||
, PPMD8_RESTORE_METHOD_FREEZE
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
CPpmd8_Context *MinContext, *MaxContext;
|
|
||||||
CPpmd_State *FoundState;
|
|
||||||
unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder;
|
|
||||||
Int32 RunLength, InitRL; /* must be 32-bit at least */
|
|
||||||
|
|
||||||
UInt32 Size;
|
|
||||||
UInt32 GlueCount;
|
|
||||||
Byte *Base, *LoUnit, *HiUnit, *Text, *UnitsStart;
|
|
||||||
UInt32 AlignOffset;
|
|
||||||
unsigned RestoreMethod;
|
|
||||||
|
|
||||||
/* Range Coder */
|
|
||||||
UInt32 Range;
|
|
||||||
UInt32 Code;
|
|
||||||
UInt32 Low;
|
|
||||||
union
|
|
||||||
{
|
|
||||||
IByteIn *In;
|
|
||||||
IByteOut *Out;
|
|
||||||
} Stream;
|
|
||||||
|
|
||||||
Byte Indx2Units[PPMD_NUM_INDEXES];
|
|
||||||
Byte Units2Indx[128];
|
|
||||||
CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES];
|
|
||||||
UInt32 Stamps[PPMD_NUM_INDEXES];
|
|
||||||
|
|
||||||
Byte NS2BSIndx[256], NS2Indx[260];
|
|
||||||
CPpmd_See DummySee, See[24][32];
|
|
||||||
UInt16 BinSumm[25][64];
|
|
||||||
} CPpmd8;
|
|
||||||
|
|
||||||
void Ppmd8_Construct(CPpmd8 *p);
|
|
||||||
Bool Ppmd8_Alloc(CPpmd8 *p, UInt32 size, ISzAlloc *alloc);
|
|
||||||
void Ppmd8_Free(CPpmd8 *p, ISzAlloc *alloc);
|
|
||||||
void Ppmd8_Init(CPpmd8 *p, unsigned maxOrder, unsigned restoreMethod);
|
|
||||||
#define Ppmd8_WasAllocated(p) ((p)->Base != NULL)
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------- Internal Functions ---------- */
|
|
||||||
|
|
||||||
extern const Byte PPMD8_kExpEscape[16];
|
|
||||||
|
|
||||||
#ifdef PPMD_32BIT
|
|
||||||
#define Ppmd8_GetPtr(p, ptr) (ptr)
|
|
||||||
#define Ppmd8_GetContext(p, ptr) (ptr)
|
|
||||||
#define Ppmd8_GetStats(p, ctx) ((ctx)->Stats)
|
|
||||||
#else
|
|
||||||
#define Ppmd8_GetPtr(p, offs) ((void *)((p)->Base + (offs)))
|
|
||||||
#define Ppmd8_GetContext(p, offs) ((CPpmd8_Context *)Ppmd8_GetPtr((p), (offs)))
|
|
||||||
#define Ppmd8_GetStats(p, ctx) ((CPpmd_State *)Ppmd8_GetPtr((p), ((ctx)->Stats)))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void Ppmd8_Update1(CPpmd8 *p);
|
|
||||||
void Ppmd8_Update1_0(CPpmd8 *p);
|
|
||||||
void Ppmd8_Update2(CPpmd8 *p);
|
|
||||||
void Ppmd8_UpdateBin(CPpmd8 *p);
|
|
||||||
|
|
||||||
#define Ppmd8_GetBinSumm(p) \
|
|
||||||
&p->BinSumm[p->NS2Indx[Ppmd8Context_OneState(p->MinContext)->Freq - 1]][ \
|
|
||||||
p->NS2BSIndx[Ppmd8_GetContext(p, p->MinContext->Suffix)->NumStats] + \
|
|
||||||
p->PrevSuccess + p->MinContext->Flags + ((p->RunLength >> 26) & 0x20)]
|
|
||||||
|
|
||||||
CPpmd_See *Ppmd8_MakeEscFreq(CPpmd8 *p, unsigned numMasked, UInt32 *scale);
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------- Decode ---------- */
|
|
||||||
|
|
||||||
Bool Ppmd8_RangeDec_Init(CPpmd8 *p);
|
|
||||||
#define Ppmd8_RangeDec_IsFinishedOK(p) ((p)->Code == 0)
|
|
||||||
int Ppmd8_DecodeSymbol(CPpmd8 *p); /* returns: -1 as EndMarker, -2 as DataError */
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------- Encode ---------- */
|
|
||||||
|
|
||||||
#define Ppmd8_RangeEnc_Init(p) { (p)->Low = 0; (p)->Range = 0xFFFFFFFF; }
|
|
||||||
void Ppmd8_RangeEnc_FlushData(CPpmd8 *p);
|
|
||||||
void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol); /* symbol = -1 means EndMarker */
|
|
||||||
|
|
||||||
EXTERN_C_END
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
/* Ppmd8Dec.c -- PPMdI Decoder
|
|
||||||
2010-03-12 : Igor Pavlov : Public domain
|
|
||||||
This code is based on:
|
|
||||||
PPMd var.I (2002): Dmitry Shkarin : Public domain
|
|
||||||
Carryless rangecoder (1999): Dmitry Subbotin : Public domain */
|
|
||||||
|
|
||||||
#include "Ppmd8.h"
|
|
||||||
|
|
||||||
#define kTop (1 << 24)
|
|
||||||
#define kBot (1 << 15)
|
|
||||||
|
|
||||||
Bool Ppmd8_RangeDec_Init(CPpmd8 *p)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
p->Low = 0;
|
|
||||||
p->Range = 0xFFFFFFFF;
|
|
||||||
p->Code = 0;
|
|
||||||
for (i = 0; i < 4; i++)
|
|
||||||
p->Code = (p->Code << 8) | p->Stream.In->Read(p->Stream.In);
|
|
||||||
return (p->Code < 0xFFFFFFFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
static UInt32 RangeDec_GetThreshold(CPpmd8 *p, UInt32 total)
|
|
||||||
{
|
|
||||||
return p->Code / (p->Range /= total);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void RangeDec_Decode(CPpmd8 *p, UInt32 start, UInt32 size)
|
|
||||||
{
|
|
||||||
start *= p->Range;
|
|
||||||
p->Low += start;
|
|
||||||
p->Code -= start;
|
|
||||||
p->Range *= size;
|
|
||||||
|
|
||||||
while ((p->Low ^ (p->Low + p->Range)) < kTop ||
|
|
||||||
p->Range < kBot && ((p->Range = (0 - p->Low) & (kBot - 1)), 1))
|
|
||||||
{
|
|
||||||
p->Code = (p->Code << 8) | p->Stream.In->Read(p->Stream.In);
|
|
||||||
p->Range <<= 8;
|
|
||||||
p->Low <<= 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MASK(sym) ((signed char *)charMask)[sym]
|
|
||||||
|
|
||||||
int Ppmd8_DecodeSymbol(CPpmd8 *p)
|
|
||||||
{
|
|
||||||
size_t charMask[256 / sizeof(size_t)];
|
|
||||||
if (p->MinContext->NumStats != 0)
|
|
||||||
{
|
|
||||||
CPpmd_State *s = Ppmd8_GetStats(p, p->MinContext);
|
|
||||||
unsigned i;
|
|
||||||
UInt32 count, hiCnt;
|
|
||||||
if ((count = RangeDec_GetThreshold(p, p->MinContext->SummFreq)) < (hiCnt = s->Freq))
|
|
||||||
{
|
|
||||||
Byte symbol;
|
|
||||||
RangeDec_Decode(p, 0, s->Freq);
|
|
||||||
p->FoundState = s;
|
|
||||||
symbol = s->Symbol;
|
|
||||||
Ppmd8_Update1_0(p);
|
|
||||||
return symbol;
|
|
||||||
}
|
|
||||||
p->PrevSuccess = 0;
|
|
||||||
i = p->MinContext->NumStats;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if ((hiCnt += (++s)->Freq) > count)
|
|
||||||
{
|
|
||||||
Byte symbol;
|
|
||||||
RangeDec_Decode(p, hiCnt - s->Freq, s->Freq);
|
|
||||||
p->FoundState = s;
|
|
||||||
symbol = s->Symbol;
|
|
||||||
Ppmd8_Update1(p);
|
|
||||||
return symbol;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (--i);
|
|
||||||
if (count >= p->MinContext->SummFreq)
|
|
||||||
return -2;
|
|
||||||
RangeDec_Decode(p, hiCnt, p->MinContext->SummFreq - hiCnt);
|
|
||||||
PPMD_SetAllBitsIn256Bytes(charMask);
|
|
||||||
MASK(s->Symbol) = 0;
|
|
||||||
i = p->MinContext->NumStats;
|
|
||||||
do { MASK((--s)->Symbol) = 0; } while (--i);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UInt16 *prob = Ppmd8_GetBinSumm(p);
|
|
||||||
if (((p->Code / (p->Range >>= 14)) < *prob))
|
|
||||||
{
|
|
||||||
Byte symbol;
|
|
||||||
RangeDec_Decode(p, 0, *prob);
|
|
||||||
*prob = (UInt16)PPMD_UPDATE_PROB_0(*prob);
|
|
||||||
symbol = (p->FoundState = Ppmd8Context_OneState(p->MinContext))->Symbol;
|
|
||||||
Ppmd8_UpdateBin(p);
|
|
||||||
return symbol;
|
|
||||||
}
|
|
||||||
RangeDec_Decode(p, *prob, (1 << 14) - *prob);
|
|
||||||
*prob = (UInt16)PPMD_UPDATE_PROB_1(*prob);
|
|
||||||
p->InitEsc = PPMD8_kExpEscape[*prob >> 10];
|
|
||||||
PPMD_SetAllBitsIn256Bytes(charMask);
|
|
||||||
MASK(Ppmd8Context_OneState(p->MinContext)->Symbol) = 0;
|
|
||||||
p->PrevSuccess = 0;
|
|
||||||
}
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
CPpmd_State *ps[256], *s;
|
|
||||||
UInt32 freqSum, count, hiCnt;
|
|
||||||
CPpmd_See *see;
|
|
||||||
unsigned i, num, numMasked = p->MinContext->NumStats;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
p->OrderFall++;
|
|
||||||
if (!p->MinContext->Suffix)
|
|
||||||
return -1;
|
|
||||||
p->MinContext = Ppmd8_GetContext(p, p->MinContext->Suffix);
|
|
||||||
}
|
|
||||||
while (p->MinContext->NumStats == numMasked);
|
|
||||||
hiCnt = 0;
|
|
||||||
s = Ppmd8_GetStats(p, p->MinContext);
|
|
||||||
i = 0;
|
|
||||||
num = p->MinContext->NumStats - numMasked;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
int k = (int)(MASK(s->Symbol));
|
|
||||||
hiCnt += (s->Freq & k);
|
|
||||||
ps[i] = s++;
|
|
||||||
i -= k;
|
|
||||||
}
|
|
||||||
while (i != num);
|
|
||||||
|
|
||||||
see = Ppmd8_MakeEscFreq(p, numMasked, &freqSum);
|
|
||||||
freqSum += hiCnt;
|
|
||||||
count = RangeDec_GetThreshold(p, freqSum);
|
|
||||||
|
|
||||||
if (count < hiCnt)
|
|
||||||
{
|
|
||||||
Byte symbol;
|
|
||||||
CPpmd_State **pps = ps;
|
|
||||||
for (hiCnt = 0; (hiCnt += (*pps)->Freq) <= count; pps++);
|
|
||||||
s = *pps;
|
|
||||||
RangeDec_Decode(p, hiCnt - s->Freq, s->Freq);
|
|
||||||
Ppmd_See_Update(see);
|
|
||||||
p->FoundState = s;
|
|
||||||
symbol = s->Symbol;
|
|
||||||
Ppmd8_Update2(p);
|
|
||||||
return symbol;
|
|
||||||
}
|
|
||||||
if (count >= freqSum)
|
|
||||||
return -2;
|
|
||||||
RangeDec_Decode(p, hiCnt, freqSum - hiCnt);
|
|
||||||
see->Summ = (UInt16)(see->Summ + freqSum);
|
|
||||||
do { MASK(ps[--i]->Symbol) = 0; } while (i != 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,161 +0,0 @@
|
|||||||
/* Ppmd8Enc.c -- PPMdI Encoder
|
|
||||||
2010-03-12 : Igor Pavlov : Public domain
|
|
||||||
This code is based on:
|
|
||||||
PPMd var.I (2002): Dmitry Shkarin : Public domain
|
|
||||||
Carryless rangecoder (1999): Dmitry Subbotin : Public domain */
|
|
||||||
|
|
||||||
#include "Ppmd8.h"
|
|
||||||
|
|
||||||
#define kTop (1 << 24)
|
|
||||||
#define kBot (1 << 15)
|
|
||||||
|
|
||||||
void Ppmd8_RangeEnc_FlushData(CPpmd8 *p)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
for (i = 0; i < 4; i++, p->Low <<= 8 )
|
|
||||||
p->Stream.Out->Write(p->Stream.Out, (Byte)(p->Low >> 24));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void RangeEnc_Normalize(CPpmd8 *p)
|
|
||||||
{
|
|
||||||
while ((p->Low ^ (p->Low + p->Range)) < kTop ||
|
|
||||||
p->Range < kBot && ((p->Range = (0 - p->Low) & (kBot - 1)), 1))
|
|
||||||
{
|
|
||||||
p->Stream.Out->Write(p->Stream.Out, (Byte)(p->Low >> 24));
|
|
||||||
p->Range <<= 8;
|
|
||||||
p->Low <<= 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void RangeEnc_Encode(CPpmd8 *p, UInt32 start, UInt32 size, UInt32 total)
|
|
||||||
{
|
|
||||||
p->Low += start * (p->Range /= total);
|
|
||||||
p->Range *= size;
|
|
||||||
RangeEnc_Normalize(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void RangeEnc_EncodeBit_0(CPpmd8 *p, UInt32 size0)
|
|
||||||
{
|
|
||||||
p->Range >>= 14;
|
|
||||||
p->Range *= size0;
|
|
||||||
RangeEnc_Normalize(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void RangeEnc_EncodeBit_1(CPpmd8 *p, UInt32 size0)
|
|
||||||
{
|
|
||||||
p->Low += size0 * (p->Range >>= 14);
|
|
||||||
p->Range *= ((1 << 14) - size0);
|
|
||||||
RangeEnc_Normalize(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define MASK(sym) ((signed char *)charMask)[sym]
|
|
||||||
|
|
||||||
void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol)
|
|
||||||
{
|
|
||||||
size_t charMask[256 / sizeof(size_t)];
|
|
||||||
if (p->MinContext->NumStats != 0)
|
|
||||||
{
|
|
||||||
CPpmd_State *s = Ppmd8_GetStats(p, p->MinContext);
|
|
||||||
UInt32 sum;
|
|
||||||
unsigned i;
|
|
||||||
if (s->Symbol == symbol)
|
|
||||||
{
|
|
||||||
RangeEnc_Encode(p, 0, s->Freq, p->MinContext->SummFreq);
|
|
||||||
p->FoundState = s;
|
|
||||||
Ppmd8_Update1_0(p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
p->PrevSuccess = 0;
|
|
||||||
sum = s->Freq;
|
|
||||||
i = p->MinContext->NumStats;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if ((++s)->Symbol == symbol)
|
|
||||||
{
|
|
||||||
RangeEnc_Encode(p, sum, s->Freq, p->MinContext->SummFreq);
|
|
||||||
p->FoundState = s;
|
|
||||||
Ppmd8_Update1(p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sum += s->Freq;
|
|
||||||
}
|
|
||||||
while (--i);
|
|
||||||
|
|
||||||
PPMD_SetAllBitsIn256Bytes(charMask);
|
|
||||||
MASK(s->Symbol) = 0;
|
|
||||||
i = p->MinContext->NumStats;
|
|
||||||
do { MASK((--s)->Symbol) = 0; } while (--i);
|
|
||||||
RangeEnc_Encode(p, sum, p->MinContext->SummFreq - sum, p->MinContext->SummFreq);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UInt16 *prob = Ppmd8_GetBinSumm(p);
|
|
||||||
CPpmd_State *s = Ppmd8Context_OneState(p->MinContext);
|
|
||||||
if (s->Symbol == symbol)
|
|
||||||
{
|
|
||||||
RangeEnc_EncodeBit_0(p, *prob);
|
|
||||||
*prob = (UInt16)PPMD_UPDATE_PROB_0(*prob);
|
|
||||||
p->FoundState = s;
|
|
||||||
Ppmd8_UpdateBin(p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RangeEnc_EncodeBit_1(p, *prob);
|
|
||||||
*prob = (UInt16)PPMD_UPDATE_PROB_1(*prob);
|
|
||||||
p->InitEsc = PPMD8_kExpEscape[*prob >> 10];
|
|
||||||
PPMD_SetAllBitsIn256Bytes(charMask);
|
|
||||||
MASK(s->Symbol) = 0;
|
|
||||||
p->PrevSuccess = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
UInt32 escFreq;
|
|
||||||
CPpmd_See *see;
|
|
||||||
CPpmd_State *s;
|
|
||||||
UInt32 sum;
|
|
||||||
unsigned i, numMasked = p->MinContext->NumStats;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
p->OrderFall++;
|
|
||||||
if (!p->MinContext->Suffix)
|
|
||||||
return; /* EndMarker (symbol = -1) */
|
|
||||||
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;
|
|
||||||
i = p->MinContext->NumStats + 1;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
int cur = s->Symbol;
|
|
||||||
if (cur == symbol)
|
|
||||||
{
|
|
||||||
UInt32 low = sum;
|
|
||||||
CPpmd_State *s1 = s;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
sum += (s->Freq & (int)(MASK(s->Symbol)));
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
while (--i);
|
|
||||||
RangeEnc_Encode(p, low, s1->Freq, sum + escFreq);
|
|
||||||
Ppmd_See_Update(see);
|
|
||||||
p->FoundState = s1;
|
|
||||||
Ppmd8_Update2(p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sum += (s->Freq & (int)(MASK(cur)));
|
|
||||||
MASK(cur) = 0;
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
while (--i);
|
|
||||||
|
|
||||||
RangeEnc_Encode(p, sum, escFreq, sum + escFreq);
|
|
||||||
see->Summ = (UInt16)(see->Summ + sum + escFreq);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
/* Crypto/Sha256.c -- SHA-256 Hash function
|
/* Crypto/Sha256.c -- SHA-256 Hash
|
||||||
2008-11-06 : Igor Pavlov : Public domain
|
2010-06-11 : Igor Pavlov : Public domain
|
||||||
This code is based on public domain code from Wei Dai's Crypto++ library. */
|
This code is based on public domain code from Wei Dai's Crypto++ library. */
|
||||||
|
|
||||||
#include "Sha256.h"
|
|
||||||
#include "RotateDefs.h"
|
#include "RotateDefs.h"
|
||||||
|
#include "Sha256.h"
|
||||||
|
|
||||||
/* define it for speed optimization */
|
/* define it for speed optimization */
|
||||||
/* #define _SHA256_UNROLL */
|
/* #define _SHA256_UNROLL */
|
||||||
@@ -71,7 +71,7 @@ void Sha256_Init(CSha256 *p)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const UInt32 K[64] = {
|
static const UInt32 K[64] = {
|
||||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
|
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
|
||||||
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
/* Sha256.h -- SHA-256 Hash
|
/* Sha256.h -- SHA-256 Hash
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2010-06-11 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __CRYPTO_SHA256_H
|
#ifndef __CRYPTO_SHA256_H
|
||||||
#define __CRYPTO_SHA256_H
|
#define __CRYPTO_SHA256_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SHA256_DIGEST_SIZE 32
|
#define SHA256_DIGEST_SIZE 32
|
||||||
|
|
||||||
@@ -23,8 +21,6 @@ void Sha256_Init(CSha256 *p);
|
|||||||
void Sha256_Update(CSha256 *p, const Byte *data, size_t size);
|
void Sha256_Update(CSha256 *p, const Byte *data, size_t size);
|
||||||
void Sha256_Final(CSha256 *p, Byte *digest);
|
void Sha256_Final(CSha256 *p, Byte *digest);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+21
-18
@@ -1,5 +1,5 @@
|
|||||||
/* Types.h -- Basic types
|
/* Types.h -- Basic types
|
||||||
2010-03-11 : Igor Pavlov : Public domain */
|
2010-10-09 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __7Z_TYPES_H
|
#ifndef __7Z_TYPES_H
|
||||||
#define __7Z_TYPES_H
|
#define __7Z_TYPES_H
|
||||||
@@ -20,21 +20,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#ifdef __cplusplus
|
|
||||||
#if defined(_WIN32) && defined(_MSC_VER)
|
|
||||||
# if !defined(SZIP_STATIC)
|
|
||||||
# if defined(SZIP_EXPORT)
|
|
||||||
# define SZIP_API __declspec(dllexport)
|
|
||||||
# else
|
|
||||||
# define SZIP_API __declspec(dllimport)
|
|
||||||
# endif
|
|
||||||
# else
|
|
||||||
# define SZIP_API
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# define SZIP_API
|
|
||||||
#endif
|
|
||||||
|
|
||||||
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
#define SZ_OK 0
|
#define SZ_OK 0
|
||||||
@@ -92,9 +77,11 @@ typedef unsigned long UInt64;
|
|||||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||||
typedef __int64 Int64;
|
typedef __int64 Int64;
|
||||||
typedef unsigned __int64 UInt64;
|
typedef unsigned __int64 UInt64;
|
||||||
|
#define UINT64_CONST(n) n
|
||||||
#else
|
#else
|
||||||
typedef long long int Int64;
|
typedef long long int Int64;
|
||||||
typedef unsigned long long int UInt64;
|
typedef unsigned long long int UInt64;
|
||||||
|
#define UINT64_CONST(n) n ## ULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -211,8 +198,8 @@ typedef struct
|
|||||||
Byte buf[LookToRead_BUF_SIZE];
|
Byte buf[LookToRead_BUF_SIZE];
|
||||||
} CLookToRead;
|
} CLookToRead;
|
||||||
|
|
||||||
SZIP_API void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
|
void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
|
||||||
SZIP_API void LookToRead_Init(CLookToRead *p);
|
void LookToRead_Init(CLookToRead *p);
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -246,6 +233,22 @@ typedef struct
|
|||||||
#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
|
#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
|
||||||
#define IAlloc_Free(p, a) (p)->Free((p), a)
|
#define IAlloc_Free(p, a) (p)->Free((p), a)
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
#define CHAR_PATH_SEPARATOR '\\'
|
||||||
|
#define WCHAR_PATH_SEPARATOR L'\\'
|
||||||
|
#define STRING_PATH_SEPARATOR "\\"
|
||||||
|
#define WSTRING_PATH_SEPARATOR L"\\"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define CHAR_PATH_SEPARATOR '/'
|
||||||
|
#define WCHAR_PATH_SEPARATOR L'/'
|
||||||
|
#define STRING_PATH_SEPARATOR "/"
|
||||||
|
#define WSTRING_PATH_SEPARATOR L"/"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
EXTERN_C_END
|
EXTERN_C_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+9
-11
@@ -1,14 +1,12 @@
|
|||||||
/* Xz.h - Xz interface
|
/* Xz.h - Xz interface
|
||||||
2009-04-15 : Igor Pavlov : Public domain */
|
2011-01-09 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __XZ_H
|
#ifndef __XZ_H
|
||||||
#define __XZ_H
|
#define __XZ_H
|
||||||
|
|
||||||
#include "Sha256.h"
|
#include "Sha256.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define XZ_ID_Subblock 1
|
#define XZ_ID_Subblock 1
|
||||||
#define XZ_ID_Delta 3
|
#define XZ_ID_Delta 3
|
||||||
@@ -140,7 +138,7 @@ typedef enum
|
|||||||
CODER_STATUS_NOT_SPECIFIED, /* use main error code instead */
|
CODER_STATUS_NOT_SPECIFIED, /* use main error code instead */
|
||||||
CODER_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */
|
CODER_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */
|
||||||
CODER_STATUS_NOT_FINISHED, /* stream was not finished */
|
CODER_STATUS_NOT_FINISHED, /* stream was not finished */
|
||||||
CODER_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */
|
CODER_STATUS_NEEDS_MORE_INPUT /* you must provide more input bytes */
|
||||||
} ECoderStatus;
|
} ECoderStatus;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
@@ -222,7 +220,8 @@ typedef struct
|
|||||||
Byte buf[XZ_BLOCK_HEADER_SIZE_MAX];
|
Byte buf[XZ_BLOCK_HEADER_SIZE_MAX];
|
||||||
} CXzUnpacker;
|
} CXzUnpacker;
|
||||||
|
|
||||||
SRes XzUnpacker_Create(CXzUnpacker *p, ISzAlloc *alloc);
|
void XzUnpacker_Construct(CXzUnpacker *p, ISzAlloc *alloc);
|
||||||
|
void XzUnpacker_Init(CXzUnpacker *p);
|
||||||
void XzUnpacker_Free(CXzUnpacker *p);
|
void XzUnpacker_Free(CXzUnpacker *p);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -234,8 +233,9 @@ finishMode:
|
|||||||
Returns:
|
Returns:
|
||||||
SZ_OK
|
SZ_OK
|
||||||
status:
|
status:
|
||||||
LZMA_STATUS_FINISHED_WITH_MARK
|
CODER_STATUS_NOT_FINISHED,
|
||||||
LZMA_STATUS_NOT_FINISHED
|
CODER_STATUS_NEEDS_MORE_INPUT - maybe there are more xz streams,
|
||||||
|
call XzUnpacker_IsStreamWasFinished to check that current stream was finished
|
||||||
SZ_ERROR_DATA - Data error
|
SZ_ERROR_DATA - Data error
|
||||||
SZ_ERROR_MEM - Memory allocation error
|
SZ_ERROR_MEM - Memory allocation error
|
||||||
SZ_ERROR_UNSUPPORTED - Unsupported properties
|
SZ_ERROR_UNSUPPORTED - Unsupported properties
|
||||||
@@ -249,8 +249,6 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
|
|||||||
|
|
||||||
Bool XzUnpacker_IsStreamWasFinished(CXzUnpacker *p);
|
Bool XzUnpacker_IsStreamWasFinished(CXzUnpacker *p);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
/* XzCrc64.c -- CRC64 calculation
|
/* XzCrc64.c -- CRC64 calculation
|
||||||
2009-04-15 : Igor Pavlov : Public domain */
|
2010-04-16 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "XzCrc64.h"
|
#include "XzCrc64.h"
|
||||||
|
|
||||||
#define kCrc64Poly 0xC96C5795D7870F42
|
#define kCrc64Poly UINT64_CONST(0xC96C5795D7870F42)
|
||||||
UInt64 g_Crc64Table[256];
|
UInt64 g_Crc64Table[256];
|
||||||
|
|
||||||
void MY_FAST_CALL Crc64GenerateTable(void)
|
void MY_FAST_CALL Crc64GenerateTable(void)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* XzCrc64.c -- CRC64 calculation
|
/* XzCrc64.h -- CRC64 calculation
|
||||||
2009-04-15 : Igor Pavlov : Public domain */
|
2010-04-16 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __XZ_CRC64_H
|
#ifndef __XZ_CRC64_H
|
||||||
#define __XZ_CRC64_H
|
#define __XZ_CRC64_H
|
||||||
@@ -8,23 +8,19 @@
|
|||||||
|
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern UInt64 g_Crc64Table[];
|
extern UInt64 g_Crc64Table[];
|
||||||
|
|
||||||
void MY_FAST_CALL Crc64GenerateTable(void);
|
void MY_FAST_CALL Crc64GenerateTable(void);
|
||||||
|
|
||||||
#define CRC64_INIT_VAL 0xFFFFFFFFFFFFFFFF
|
#define CRC64_INIT_VAL UINT64_CONST(0xFFFFFFFFFFFFFFFF)
|
||||||
#define CRC64_GET_DIGEST(crc) ((crc) ^ 0xFFFFFFFFFFFFFFFF)
|
#define CRC64_GET_DIGEST(crc) ((crc) ^ CRC64_INIT_VAL)
|
||||||
#define CRC64_UPDATE_BYTE(crc, b) (g_Crc64Table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
|
#define CRC64_UPDATE_BYTE(crc, b) (g_Crc64Table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
|
||||||
|
|
||||||
UInt64 MY_FAST_CALL Crc64Update(UInt64 crc, const void *data, size_t size);
|
UInt64 MY_FAST_CALL Crc64Update(UInt64 crc, const void *data, size_t size);
|
||||||
UInt64 MY_FAST_CALL Crc64Calc(const void *data, size_t size);
|
UInt64 MY_FAST_CALL Crc64Calc(const void *data, size_t size);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+33
-17
@@ -1,5 +1,5 @@
|
|||||||
/* XzDec.c -- Xz Decode
|
/* XzDec.c -- Xz Decode
|
||||||
2009-06-08 : Igor Pavlov : Public domain */
|
2011-02-07 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
/* #define XZ_DUMP */
|
/* #define XZ_DUMP */
|
||||||
|
|
||||||
@@ -18,7 +18,8 @@
|
|||||||
#include "Lzma2Dec.h"
|
#include "Lzma2Dec.h"
|
||||||
|
|
||||||
#ifdef USE_SUBBLOCK
|
#ifdef USE_SUBBLOCK
|
||||||
#include "SbDec.h"
|
#include "Bcj3Dec.c"
|
||||||
|
#include "SbDec.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Xz.h"
|
#include "Xz.h"
|
||||||
@@ -72,7 +73,6 @@ SRes BraState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *a
|
|||||||
{
|
{
|
||||||
CBraState *p = ((CBraState *)pp);
|
CBraState *p = ((CBraState *)pp);
|
||||||
alloc = alloc;
|
alloc = alloc;
|
||||||
p->encodeMode = 0;
|
|
||||||
p->ip = 0;
|
p->ip = 0;
|
||||||
if (p->methodId == XZ_ID_Delta)
|
if (p->methodId == XZ_ID_Delta)
|
||||||
{
|
{
|
||||||
@@ -195,7 +195,7 @@ static SRes BraState_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src,
|
|||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, ISzAlloc *alloc)
|
SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, int encodeMode, ISzAlloc *alloc)
|
||||||
{
|
{
|
||||||
CBraState *decoder;
|
CBraState *decoder;
|
||||||
if (id != XZ_ID_Delta &&
|
if (id != XZ_ID_Delta &&
|
||||||
@@ -211,6 +211,7 @@ SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, ISzAlloc *alloc)
|
|||||||
if (decoder == 0)
|
if (decoder == 0)
|
||||||
return SZ_ERROR_MEM;
|
return SZ_ERROR_MEM;
|
||||||
decoder->methodId = (UInt32)id;
|
decoder->methodId = (UInt32)id;
|
||||||
|
decoder->encodeMode = encodeMode;
|
||||||
p->p = decoder;
|
p->p = decoder;
|
||||||
p->Free = BraState_Free;
|
p->Free = BraState_Free;
|
||||||
p->SetProps = BraState_SetProps;
|
p->SetProps = BraState_SetProps;
|
||||||
@@ -225,8 +226,8 @@ SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, ISzAlloc *alloc)
|
|||||||
|
|
||||||
static void SbState_Free(void *pp, ISzAlloc *alloc)
|
static void SbState_Free(void *pp, ISzAlloc *alloc)
|
||||||
{
|
{
|
||||||
CSubblockDec *p = (CSubblockDec *)pp;
|
CSbDec *p = (CSbDec *)pp;
|
||||||
SubblockDec_Free(p, alloc);
|
SbDec_Free(p);
|
||||||
alloc->Free(alloc, pp);
|
alloc->Free(alloc, pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,24 +241,32 @@ static SRes SbState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAl
|
|||||||
|
|
||||||
static void SbState_Init(void *pp)
|
static void SbState_Init(void *pp)
|
||||||
{
|
{
|
||||||
SubblockDec_Init((CSubblockDec *)pp);
|
SbDec_Init((CSbDec *)pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SRes SbState_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
static SRes SbState_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
||||||
int srcWasFinished, ECoderFinishMode finishMode, int *wasFinished)
|
int srcWasFinished, ECoderFinishMode finishMode, int *wasFinished)
|
||||||
{
|
{
|
||||||
ECoderStatus status;
|
CSbDec *p = (CSbDec *)pp;
|
||||||
SRes res = SubblockDec_Decode((CSubblockDec *)pp, dest, destLen, src, srcLen, finishMode, &status);
|
SRes res;
|
||||||
srcWasFinished = srcWasFinished;
|
srcWasFinished = srcWasFinished;
|
||||||
*wasFinished = (status == LZMA_STATUS_FINISHED_WITH_MARK);
|
p->dest = dest;
|
||||||
|
p->destLen = *destLen;
|
||||||
|
p->src = src;
|
||||||
|
p->srcLen = *srcLen;
|
||||||
|
p->finish = finishMode; /* change it */
|
||||||
|
res = SbDec_Decode((CSbDec *)pp);
|
||||||
|
*destLen -= p->destLen;
|
||||||
|
*srcLen -= p->srcLen;
|
||||||
|
*wasFinished = (*destLen == 0 && *srcLen == 0); /* change it */
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRes SbState_SetFromMethod(IStateCoder *p, ISzAlloc *alloc)
|
SRes SbState_SetFromMethod(IStateCoder *p, ISzAlloc *alloc)
|
||||||
{
|
{
|
||||||
CSubblockDec *decoder;
|
CSbDec *decoder;
|
||||||
p->p = 0;
|
p->p = 0;
|
||||||
decoder = alloc->Alloc(alloc, sizeof(CSubblockDec));
|
decoder = alloc->Alloc(alloc, sizeof(CSbDec));
|
||||||
if (decoder == 0)
|
if (decoder == 0)
|
||||||
return SZ_ERROR_MEM;
|
return SZ_ERROR_MEM;
|
||||||
p->p = decoder;
|
p->p = decoder;
|
||||||
@@ -265,7 +274,8 @@ SRes SbState_SetFromMethod(IStateCoder *p, ISzAlloc *alloc)
|
|||||||
p->SetProps = SbState_SetProps;
|
p->SetProps = SbState_SetProps;
|
||||||
p->Init = SbState_Init;
|
p->Init = SbState_Init;
|
||||||
p->Code = SbState_Code;
|
p->Code = SbState_Code;
|
||||||
SubblockDec_Construct(decoder);
|
SbDec_Construct(decoder);
|
||||||
|
SbDec_SetAlloc(decoder, alloc);
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -369,7 +379,7 @@ SRes MixCoder_SetFromMethod(CMixCoder *p, int coderIndex, UInt64 methodId)
|
|||||||
}
|
}
|
||||||
if (coderIndex == 0)
|
if (coderIndex == 0)
|
||||||
return SZ_ERROR_UNSUPPORTED;
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
return BraState_SetFromMethod(sc, methodId, p->alloc);
|
return BraState_SetFromMethod(sc, methodId, 0, p->alloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,
|
SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,
|
||||||
@@ -587,13 +597,17 @@ SRes XzDec_Init(CMixCoder *p, const CXzBlock *block)
|
|||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRes XzUnpacker_Create(CXzUnpacker *p, ISzAlloc *alloc)
|
void XzUnpacker_Init(CXzUnpacker *p)
|
||||||
{
|
{
|
||||||
MixCoder_Construct(&p->decoder, alloc);
|
|
||||||
p->state = XZ_STATE_STREAM_HEADER;
|
p->state = XZ_STATE_STREAM_HEADER;
|
||||||
p->pos = 0;
|
p->pos = 0;
|
||||||
p->numStreams = 0;
|
p->numStreams = 0;
|
||||||
return SZ_OK;
|
}
|
||||||
|
|
||||||
|
void XzUnpacker_Construct(CXzUnpacker *p, ISzAlloc *alloc)
|
||||||
|
{
|
||||||
|
MixCoder_Construct(&p->decoder, alloc);
|
||||||
|
XzUnpacker_Init(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XzUnpacker_Free(CXzUnpacker *p)
|
void XzUnpacker_Free(CXzUnpacker *p)
|
||||||
@@ -858,6 +872,8 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case XZ_STATE_BLOCK: break; /* to disable GCC warning */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|||||||
+160
-137
@@ -1,5 +1,5 @@
|
|||||||
/* XzEnc.c -- Xz Encode
|
/* XzEnc.c -- Xz Encode
|
||||||
2009-06-04 : Igor Pavlov : Public domain */
|
2011-02-07 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -9,7 +9,9 @@
|
|||||||
#include "Bra.h"
|
#include "Bra.h"
|
||||||
#include "CpuArch.h"
|
#include "CpuArch.h"
|
||||||
#ifdef USE_SUBBLOCK
|
#ifdef USE_SUBBLOCK
|
||||||
#include "SbEnc.h"
|
#include "Bcj3Enc.c"
|
||||||
|
#include "SbFind.c"
|
||||||
|
#include "SbEnc.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "XzEnc.h"
|
#include "XzEnc.h"
|
||||||
@@ -198,158 +200,147 @@ static size_t MyWrite(void *pp, const void *data, size_t size)
|
|||||||
|
|
||||||
/* ---------- CSeqInFilter ---------- */
|
/* ---------- CSeqInFilter ---------- */
|
||||||
|
|
||||||
/*
|
#define FILTER_BUF_SIZE (1 << 20)
|
||||||
typedef struct _IFilter
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
void (*Free)(void *p, ISzAlloc *alloc);
|
|
||||||
SRes (*SetProps)(void *p, const Byte *props, size_t propSize, ISzAlloc *alloc);
|
|
||||||
void (*Init)(void *p);
|
|
||||||
size_t (*Filter)(void *p, Byte *data, SizeT destLen);
|
|
||||||
} IFilter;
|
|
||||||
|
|
||||||
#define FILT_BUF_SIZE (1 << 19)
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
ISeqInStream p;
|
ISeqInStream p;
|
||||||
ISeqInStream *realStream;
|
ISeqInStream *realStream;
|
||||||
UInt32 x86State;
|
IStateCoder StateCoder;
|
||||||
UInt32 ip;
|
Byte *buf;
|
||||||
UInt64 processed;
|
size_t curPos;
|
||||||
CXzCheck check;
|
size_t endPos;
|
||||||
Byte buf[FILT_BUF_SIZE];
|
int srcWasFinished;
|
||||||
UInt32 bufferPos;
|
|
||||||
UInt32 convertedPosBegin;
|
|
||||||
UInt32 convertedPosEnd;
|
|
||||||
IFilter *filter;
|
|
||||||
} CSeqInFilter;
|
} CSeqInFilter;
|
||||||
|
|
||||||
static SRes SeqInFilter_Read(void *pp, void *data, size_t *size)
|
static SRes SeqInFilter_Read(void *pp, void *data, size_t *size)
|
||||||
{
|
{
|
||||||
CSeqInFilter *p = (CSeqInFilter *)pp;
|
CSeqInFilter *p = (CSeqInFilter *)pp;
|
||||||
size_t remSize = *size;
|
size_t sizeOriginal = *size;
|
||||||
|
if (sizeOriginal == 0)
|
||||||
|
return S_OK;
|
||||||
*size = 0;
|
*size = 0;
|
||||||
|
for (;;)
|
||||||
while (remSize > 0)
|
|
||||||
{
|
{
|
||||||
int i;
|
if (!p->srcWasFinished && p->curPos == p->endPos)
|
||||||
if (p->convertedPosBegin != p->convertedPosEnd)
|
|
||||||
{
|
{
|
||||||
UInt32 sizeTemp = p->convertedPosEnd - p->convertedPosBegin;
|
p->curPos = 0;
|
||||||
if (remSize < sizeTemp)
|
p->endPos = FILTER_BUF_SIZE;
|
||||||
sizeTemp = (UInt32)remSize;
|
RINOK(p->realStream->Read(p->realStream, p->buf, &p->endPos));
|
||||||
memmove(data, p->buf + p->convertedPosBegin, sizeTemp);
|
if (p->endPos == 0)
|
||||||
p->convertedPosBegin += sizeTemp;
|
p->srcWasFinished = 1;
|
||||||
data = (void *)((Byte *)data + sizeTemp);
|
|
||||||
remSize -= sizeTemp;
|
|
||||||
*size += sizeTemp;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
for (i = 0; p->convertedPosEnd + i < p->bufferPos; i++)
|
|
||||||
p->buf[i] = p->buf[i + p->convertedPosEnd];
|
|
||||||
p->bufferPos = i;
|
|
||||||
p->convertedPosBegin = p->convertedPosEnd = 0;
|
|
||||||
{
|
{
|
||||||
size_t processedSizeTemp = FILT_BUF_SIZE - p->bufferPos;
|
SizeT srcLen = p->endPos - p->curPos;
|
||||||
RINOK(p->realStream->Read(p->realStream, p->buf + p->bufferPos, &processedSizeTemp));
|
int wasFinished;
|
||||||
p->bufferPos = p->bufferPos + (UInt32)processedSizeTemp;
|
SRes res;
|
||||||
}
|
*size = sizeOriginal;
|
||||||
p->convertedPosEnd = (UInt32)p->filter->Filter(p->filter->p, p->buf, p->bufferPos);
|
res = p->StateCoder.Code(p->StateCoder.p, data, size, p->buf + p->curPos, &srcLen,
|
||||||
if (p->convertedPosEnd == 0)
|
p->srcWasFinished, CODER_FINISH_ANY, &wasFinished);
|
||||||
{
|
p->curPos += srcLen;
|
||||||
if (p->bufferPos == 0)
|
if (*size != 0 || srcLen == 0 || res != 0)
|
||||||
break;
|
return res;
|
||||||
else
|
|
||||||
{
|
|
||||||
p->convertedPosEnd = p->bufferPos;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (p->convertedPosEnd > p->bufferPos)
|
|
||||||
{
|
|
||||||
for (; p->bufferPos < p->convertedPosEnd; p->bufferPos++)
|
|
||||||
p->buf[p->bufferPos] = 0;
|
|
||||||
p->convertedPosEnd = (UInt32)p->filter->Filter(p->filter->p, p->buf, p->bufferPos);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SZ_OK;
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
static void SeqInFilter_Construct(CSeqInFilter *p)
|
||||||
typedef struct
|
|
||||||
{
|
{
|
||||||
ISeqInStream p;
|
p->buf = NULL;
|
||||||
ISeqInStream *realStream;
|
p->p.Read = SeqInFilter_Read;
|
||||||
CMixCoder mixCoder;
|
}
|
||||||
Byte buf[FILT_BUF_SIZE];
|
|
||||||
UInt32 bufPos;
|
|
||||||
UInt32 bufSize;
|
|
||||||
} CMixCoderSeqInStream;
|
|
||||||
|
|
||||||
static SRes CMixCoderSeqInStream_Read(void *pp, void *data, size_t *size)
|
static void SeqInFilter_Free(CSeqInFilter *p)
|
||||||
{
|
{
|
||||||
CMixCoderSeqInStream *p = (CMixCoderSeqInStream *)pp;
|
if (p->buf)
|
||||||
SRes res = SZ_OK;
|
|
||||||
size_t remSize = *size;
|
|
||||||
*size = 0;
|
|
||||||
while (remSize > 0)
|
|
||||||
{
|
{
|
||||||
if (p->bufPos == p->bufSize)
|
g_Alloc.Free(&g_Alloc, p->buf);
|
||||||
{
|
p->buf = NULL;
|
||||||
size_t curSize;
|
|
||||||
p->bufPos = p->bufSize = 0;
|
|
||||||
if (*size != 0)
|
|
||||||
break;
|
|
||||||
curSize = FILT_BUF_SIZE;
|
|
||||||
RINOK(p->realStream->Read(p->realStream, p->buf, &curSize));
|
|
||||||
p->bufSize = (UInt32)curSize;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
SizeT destLen = remSize;
|
|
||||||
SizeT srcLen = p->bufSize - p->bufPos;
|
|
||||||
res = MixCoder_Code(&p->mixCoder, data, &destLen, p->buf + p->bufPos, &srcLen, 0);
|
|
||||||
data = (void *)((Byte *)data + destLen);
|
|
||||||
remSize -= destLen;
|
|
||||||
*size += destLen;
|
|
||||||
p->bufPos += srcLen;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, int encodeMode, ISzAlloc *alloc);
|
||||||
|
|
||||||
|
static SRes SeqInFilter_Init(CSeqInFilter *p, const CXzFilter *props)
|
||||||
|
{
|
||||||
|
if (!p->buf)
|
||||||
|
{
|
||||||
|
p->buf = g_Alloc.Alloc(&g_Alloc, FILTER_BUF_SIZE);
|
||||||
|
if (!p->buf)
|
||||||
|
return SZ_ERROR_MEM;
|
||||||
|
}
|
||||||
|
p->curPos = p->endPos = 0;
|
||||||
|
p->srcWasFinished = 0;
|
||||||
|
RINOK(BraState_SetFromMethod(&p->StateCoder, props->id, 1, &g_Alloc));
|
||||||
|
RINOK(p->StateCoder.SetProps(p->StateCoder.p, props->props, props->propsSize, &g_Alloc));
|
||||||
|
p->StateCoder.Init(p->StateCoder.p);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- CSbEncInStream ---------- */
|
||||||
|
|
||||||
#ifdef USE_SUBBLOCK
|
#ifdef USE_SUBBLOCK
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
ISeqInStream p;
|
ISeqInStream p;
|
||||||
CSubblockEnc sb;
|
ISeqInStream *inStream;
|
||||||
UInt64 processed;
|
CSbEnc enc;
|
||||||
} CSbEncInStream;
|
} CSbEncInStream;
|
||||||
|
|
||||||
void SbEncInStream_Init(CSbEncInStream *p)
|
|
||||||
{
|
|
||||||
p->processed = 0;
|
|
||||||
SubblockEnc_Init(&p->sb);
|
|
||||||
}
|
|
||||||
|
|
||||||
static SRes SbEncInStream_Read(void *pp, void *data, size_t *size)
|
static SRes SbEncInStream_Read(void *pp, void *data, size_t *size)
|
||||||
{
|
{
|
||||||
CSbEncInStream *p = (CSbEncInStream *)pp;
|
CSbEncInStream *p = (CSbEncInStream *)pp;
|
||||||
SRes res = SubblockEnc_Read(&p->sb, data, size);
|
size_t sizeOriginal = *size;
|
||||||
p->processed += *size;
|
if (sizeOriginal == 0)
|
||||||
return res;
|
return S_OK;
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if (p->enc.needRead && !p->enc.readWasFinished)
|
||||||
|
{
|
||||||
|
size_t processed = p->enc.needReadSizeMax;
|
||||||
|
RINOK(p->inStream->Read(p->inStream, p->enc.buf + p->enc.readPos, &processed));
|
||||||
|
p->enc.readPos += processed;
|
||||||
|
if (processed == 0)
|
||||||
|
{
|
||||||
|
p->enc.readWasFinished = True;
|
||||||
|
p->enc.isFinalFinished = True;
|
||||||
|
}
|
||||||
|
p->enc.needRead = False;
|
||||||
|
}
|
||||||
|
*size = sizeOriginal;
|
||||||
|
RINOK(SbEnc_Read(&p->enc, data, size));
|
||||||
|
if (*size != 0 || !p->enc.needRead)
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SbEncInStream_Construct(CSbEncInStream *p, ISzAlloc *alloc)
|
||||||
|
{
|
||||||
|
SbEnc_Construct(&p->enc, alloc);
|
||||||
|
p->p.Read = SbEncInStream_Read;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRes SbEncInStream_Init(CSbEncInStream *p)
|
||||||
|
{
|
||||||
|
return SbEnc_Init(&p->enc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SbEncInStream_Free(CSbEncInStream *p)
|
||||||
|
{
|
||||||
|
SbEnc_Free(&p->enc);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/* CMixCoderSeqInStream inStream; */
|
|
||||||
CLzma2EncHandle lzma2;
|
CLzma2EncHandle lzma2;
|
||||||
#ifdef USE_SUBBLOCK
|
#ifdef USE_SUBBLOCK
|
||||||
CSbEncInStream sb;
|
CSbEncInStream sb;
|
||||||
#endif
|
#endif
|
||||||
|
CSeqInFilter filter;
|
||||||
ISzAlloc *alloc;
|
ISzAlloc *alloc;
|
||||||
ISzAlloc *bigAlloc;
|
ISzAlloc *bigAlloc;
|
||||||
} CLzma2WithFilters;
|
} CLzma2WithFilters;
|
||||||
@@ -361,9 +352,9 @@ static void Lzma2WithFilters_Construct(CLzma2WithFilters *p, ISzAlloc *alloc, IS
|
|||||||
p->bigAlloc = bigAlloc;
|
p->bigAlloc = bigAlloc;
|
||||||
p->lzma2 = NULL;
|
p->lzma2 = NULL;
|
||||||
#ifdef USE_SUBBLOCK
|
#ifdef USE_SUBBLOCK
|
||||||
p->sb.p.Read = SbEncInStream_Read;
|
SbEncInStream_Construct(&p->sb, alloc);
|
||||||
SubblockEnc_Construct(&p->sb.sb, p->alloc);
|
|
||||||
#endif
|
#endif
|
||||||
|
SeqInFilter_Construct(&p->filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SRes Lzma2WithFilters_Create(CLzma2WithFilters *p)
|
static SRes Lzma2WithFilters_Create(CLzma2WithFilters *p)
|
||||||
@@ -376,8 +367,9 @@ static SRes Lzma2WithFilters_Create(CLzma2WithFilters *p)
|
|||||||
|
|
||||||
static void Lzma2WithFilters_Free(CLzma2WithFilters *p)
|
static void Lzma2WithFilters_Free(CLzma2WithFilters *p)
|
||||||
{
|
{
|
||||||
|
SeqInFilter_Free(&p->filter);
|
||||||
#ifdef USE_SUBBLOCK
|
#ifdef USE_SUBBLOCK
|
||||||
SubblockEnc_Free(&p->sb.sb);
|
SbEncInStream_Free(&p->sb);
|
||||||
#endif
|
#endif
|
||||||
if (p->lzma2)
|
if (p->lzma2)
|
||||||
{
|
{
|
||||||
@@ -386,17 +378,28 @@ static void Lzma2WithFilters_Free(CLzma2WithFilters *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SRes Xz_Compress(CXzStream *xz,
|
void XzProps_Init(CXzProps *p)
|
||||||
CLzma2WithFilters *lzmaf,
|
|
||||||
ISeqOutStream *outStream,
|
|
||||||
ISeqInStream *inStream,
|
|
||||||
const CLzma2EncProps *lzma2Props,
|
|
||||||
Bool useSubblock,
|
|
||||||
ICompressProgress *progress)
|
|
||||||
{
|
{
|
||||||
xz->flags = XZ_CHECK_CRC32;
|
p->lzma2Props = 0;
|
||||||
|
p->filterProps = 0;
|
||||||
|
p->checkId = XZ_CHECK_CRC32;
|
||||||
|
}
|
||||||
|
|
||||||
RINOK(Lzma2Enc_SetProps(lzmaf->lzma2, lzma2Props));
|
void XzFilterProps_Init(CXzFilterProps *p)
|
||||||
|
{
|
||||||
|
p->id = 0;
|
||||||
|
p->delta = 0;
|
||||||
|
p->ip= 0;
|
||||||
|
p->ipDefined = False;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SRes Xz_Compress(CXzStream *xz, CLzma2WithFilters *lzmaf,
|
||||||
|
ISeqOutStream *outStream, ISeqInStream *inStream,
|
||||||
|
const CXzProps *props, ICompressProgress *progress)
|
||||||
|
{
|
||||||
|
xz->flags = (Byte)props->checkId;
|
||||||
|
|
||||||
|
RINOK(Lzma2Enc_SetProps(lzmaf->lzma2, props->lzma2Props));
|
||||||
RINOK(Xz_WriteHeader(xz->flags, outStream));
|
RINOK(Xz_WriteHeader(xz->flags, outStream));
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -404,15 +407,27 @@ static SRes Xz_Compress(CXzStream *xz,
|
|||||||
CSeqSizeOutStream seqSizeOutStream;
|
CSeqSizeOutStream seqSizeOutStream;
|
||||||
CXzBlock block;
|
CXzBlock block;
|
||||||
int filterIndex = 0;
|
int filterIndex = 0;
|
||||||
|
CXzFilter *filter = NULL;
|
||||||
|
const CXzFilterProps *fp = props->filterProps;
|
||||||
|
|
||||||
XzBlock_ClearFlags(&block);
|
XzBlock_ClearFlags(&block);
|
||||||
XzBlock_SetNumFilters(&block, 1 + (useSubblock ? 1 : 0));
|
XzBlock_SetNumFilters(&block, 1 + (fp ? 1 : 0));
|
||||||
|
|
||||||
if (useSubblock)
|
if (fp)
|
||||||
{
|
{
|
||||||
CXzFilter *f = &block.filters[filterIndex++];
|
filter = &block.filters[filterIndex++];
|
||||||
f->id = XZ_ID_Subblock;
|
filter->id = fp->id;
|
||||||
f->propsSize = 0;
|
filter->propsSize = 0;
|
||||||
|
if (fp->id == XZ_ID_Delta)
|
||||||
|
{
|
||||||
|
filter->props[0] = (Byte)(fp->delta - 1);
|
||||||
|
filter->propsSize = 1;
|
||||||
|
}
|
||||||
|
else if (fp->ipDefined)
|
||||||
|
{
|
||||||
|
SetUi32(filter->props, fp->ip);
|
||||||
|
filter->propsSize = 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -432,20 +447,30 @@ static SRes Xz_Compress(CXzStream *xz,
|
|||||||
checkInStream.realStream = inStream;
|
checkInStream.realStream = inStream;
|
||||||
SeqCheckInStream_Init(&checkInStream, XzFlags_GetCheckType(xz->flags));
|
SeqCheckInStream_Init(&checkInStream, XzFlags_GetCheckType(xz->flags));
|
||||||
|
|
||||||
#ifdef USE_SUBBLOCK
|
if (fp)
|
||||||
if (useSubblock)
|
|
||||||
{
|
{
|
||||||
lzmaf->sb.sb.inStream = &checkInStream.p;
|
#ifdef USE_SUBBLOCK
|
||||||
SubblockEnc_Init(&lzmaf->sb.sb);
|
if (fp->id == XZ_ID_Subblock)
|
||||||
|
{
|
||||||
|
lzmaf->sb.inStream = &checkInStream.p;
|
||||||
|
RINOK(SbEncInStream_Init(&lzmaf->sb));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
lzmaf->filter.realStream = &checkInStream.p;
|
||||||
|
RINOK(SeqInFilter_Init(&lzmaf->filter, filter));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
{
|
{
|
||||||
UInt64 packPos = seqSizeOutStream.processed;
|
UInt64 packPos = seqSizeOutStream.processed;
|
||||||
SRes res = Lzma2Enc_Encode(lzmaf->lzma2, &seqSizeOutStream.p,
|
SRes res = Lzma2Enc_Encode(lzmaf->lzma2, &seqSizeOutStream.p,
|
||||||
|
fp ?
|
||||||
#ifdef USE_SUBBLOCK
|
#ifdef USE_SUBBLOCK
|
||||||
useSubblock ? &lzmaf->sb.p:
|
(fp->id == XZ_ID_Subblock) ? &lzmaf->sb.p:
|
||||||
#endif
|
#endif
|
||||||
|
&lzmaf->filter.p:
|
||||||
&checkInStream.p,
|
&checkInStream.p,
|
||||||
progress);
|
progress);
|
||||||
RINOK(res);
|
RINOK(res);
|
||||||
@@ -467,8 +492,7 @@ static SRes Xz_Compress(CXzStream *xz,
|
|||||||
}
|
}
|
||||||
|
|
||||||
SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream,
|
SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream,
|
||||||
const CLzma2EncProps *lzma2Props, Bool useSubblock,
|
const CXzProps *props, ICompressProgress *progress)
|
||||||
ICompressProgress *progress)
|
|
||||||
{
|
{
|
||||||
SRes res;
|
SRes res;
|
||||||
CXzStream xz;
|
CXzStream xz;
|
||||||
@@ -477,8 +501,7 @@ SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream,
|
|||||||
Lzma2WithFilters_Construct(&lzmaf, &g_Alloc, &g_BigAlloc);
|
Lzma2WithFilters_Construct(&lzmaf, &g_Alloc, &g_BigAlloc);
|
||||||
res = Lzma2WithFilters_Create(&lzmaf);
|
res = Lzma2WithFilters_Create(&lzmaf);
|
||||||
if (res == SZ_OK)
|
if (res == SZ_OK)
|
||||||
res = Xz_Compress(&xz, &lzmaf, outStream, inStream,
|
res = Xz_Compress(&xz, &lzmaf, outStream, inStream, props, progress);
|
||||||
lzma2Props, useSubblock, progress);
|
|
||||||
Lzma2WithFilters_Free(&lzmaf);
|
Lzma2WithFilters_Free(&lzmaf);
|
||||||
Xz_Free(&xz, &g_Alloc);
|
Xz_Free(&xz, &g_Alloc);
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* XzEnc.h -- Xz Encode
|
/* XzEnc.h -- Xz Encode
|
||||||
2009-04-15 : Igor Pavlov : Public domain */
|
2011-02-07 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __XZ_ENC_H
|
#ifndef __XZ_ENC_H
|
||||||
#define __XZ_ENC_H
|
#define __XZ_ENC_H
|
||||||
@@ -8,18 +8,32 @@
|
|||||||
|
|
||||||
#include "Xz.h"
|
#include "Xz.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt32 id;
|
||||||
|
UInt32 delta;
|
||||||
|
UInt32 ip;
|
||||||
|
int ipDefined;
|
||||||
|
} CXzFilterProps;
|
||||||
|
|
||||||
|
void XzFilterProps_Init(CXzFilterProps *p);
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
const CLzma2EncProps *lzma2Props;
|
||||||
|
const CXzFilterProps *filterProps;
|
||||||
|
unsigned checkId;
|
||||||
|
} CXzProps;
|
||||||
|
|
||||||
|
void XzProps_Init(CXzProps *p);
|
||||||
|
|
||||||
SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream,
|
SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream,
|
||||||
const CLzma2EncProps *lzma2Props, Bool useSubblock,
|
const CXzProps *props, ICompressProgress *progress);
|
||||||
ICompressProgress *progress);
|
|
||||||
|
|
||||||
SRes Xz_EncodeEmpty(ISeqOutStream *outStream);
|
SRes Xz_EncodeEmpty(ISeqOutStream *outStream);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+20
-21
@@ -1,5 +1,5 @@
|
|||||||
/* XzIn.c - Xz input
|
/* XzIn.c - Xz input
|
||||||
2009-06-19 : Igor Pavlov : Public domain */
|
2011-02-01 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -152,39 +152,38 @@ static SRes Xz_ReadBackward(CXzStream *p, ILookInStream *stream, Int64 *startOff
|
|||||||
|
|
||||||
if (memcmp(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) != 0)
|
if (memcmp(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) != 0)
|
||||||
{
|
{
|
||||||
Int64 i = 0;
|
UInt32 total = 0;
|
||||||
*startOffset += XZ_STREAM_FOOTER_SIZE;
|
*startOffset += XZ_STREAM_FOOTER_SIZE;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int j;
|
size_t i;
|
||||||
size_t processedSize;
|
|
||||||
#define TEMP_BUF_SIZE (1 << 10)
|
#define TEMP_BUF_SIZE (1 << 10)
|
||||||
Byte tempBuf[TEMP_BUF_SIZE];
|
Byte tempBuf[TEMP_BUF_SIZE];
|
||||||
if (*startOffset < XZ_STREAM_FOOTER_SIZE || i > (1 << 16))
|
if (*startOffset < XZ_STREAM_FOOTER_SIZE || total > (1 << 16))
|
||||||
return SZ_ERROR_NO_ARCHIVE;
|
return SZ_ERROR_NO_ARCHIVE;
|
||||||
processedSize = (*startOffset > TEMP_BUF_SIZE) ? TEMP_BUF_SIZE : (size_t)*startOffset;
|
i = (*startOffset > TEMP_BUF_SIZE) ? TEMP_BUF_SIZE : (size_t)*startOffset;
|
||||||
i += processedSize;
|
total += (UInt32)i;
|
||||||
*startOffset = -(Int64)processedSize;
|
*startOffset = -(Int64)i;
|
||||||
RINOK(SeekFromCur(stream, startOffset));
|
RINOK(SeekFromCur(stream, startOffset));
|
||||||
RINOK(LookInStream_Read2(stream, tempBuf, processedSize, SZ_ERROR_NO_ARCHIVE));
|
RINOK(LookInStream_Read2(stream, tempBuf, i, SZ_ERROR_NO_ARCHIVE));
|
||||||
for (j = (int)processedSize; j >= 0; j--)
|
for (; i != 0; i--)
|
||||||
if (tempBuf[j -1] != 0)
|
if (tempBuf[i - 1] != 0)
|
||||||
break;
|
break;
|
||||||
if (j != 0)
|
if (i != 0)
|
||||||
{
|
{
|
||||||
if ((j & 3) != 0)
|
if ((i & 3) != 0)
|
||||||
return SZ_ERROR_NO_ARCHIVE;
|
|
||||||
*startOffset += j;
|
|
||||||
if (*startOffset < XZ_STREAM_FOOTER_SIZE)
|
|
||||||
return SZ_ERROR_NO_ARCHIVE;
|
|
||||||
*startOffset -= XZ_STREAM_FOOTER_SIZE;
|
|
||||||
RINOK(stream->Seek(stream, startOffset, SZ_SEEK_SET));
|
|
||||||
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)
|
|
||||||
return SZ_ERROR_NO_ARCHIVE;
|
return SZ_ERROR_NO_ARCHIVE;
|
||||||
|
*startOffset += i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (*startOffset < XZ_STREAM_FOOTER_SIZE)
|
||||||
|
return SZ_ERROR_NO_ARCHIVE;
|
||||||
|
*startOffset -= XZ_STREAM_FOOTER_SIZE;
|
||||||
|
RINOK(stream->Seek(stream, startOffset, SZ_SEEK_SET));
|
||||||
|
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)
|
||||||
|
return SZ_ERROR_NO_ARCHIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
p->flags = (CXzStreamFlags)GetBe16(buf + 8);
|
p->flags = (CXzStreamFlags)GetBe16(buf + 8);
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
7z(lzma) : 4.65
|
7z(lzma) : 9.22
|
||||||
utfcpp : 2.3.4
|
utfcpp : 2.3.4
|
||||||
libpng : 1.2.50
|
libpng : 1.2.50
|
||||||
zlib : 1.2.8
|
zlib : 1.2.8
|
||||||
|
|||||||
Reference in New Issue
Block a user