CHD: Enable support for LZMA (CDLZ) compression
This commit is contained in:
parent
1d7ecda2af
commit
b4155b0c23
14
core/core.mk
14
core/core.mk
|
@ -1,15 +1,19 @@
|
||||||
#LOCAL_PATH:=
|
#LOCAL_PATH:=
|
||||||
|
|
||||||
#MFLAGS := -marm -march=armv7-a -mtune=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp
|
#MFLAGS := -marm -march=armv7-a -mtune=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp
|
||||||
#ASFLAGS := -march=armv7-a -mfpu=vfp-d16 -mfloat-abi=softfp
|
#ASFLAGS := -march=armv7-a -mfpu=vfp-d16 -mfloat-abi=softfp
|
||||||
#LDFLAGS := -Wl,-Map,$(notdir $@).map,--gc-sections -Wl,-O3 -Wl,--sort-common
|
#LDFLAGS := -Wl,-Map,$(notdir $@).map,--gc-sections -Wl,-O3 -Wl,--sort-common
|
||||||
|
|
||||||
RZDCY_SRC_DIR ?= $(call my-dir)
|
RZDCY_SRC_DIR ?= $(call my-dir)
|
||||||
|
|
||||||
RZDCY_MODULES := cfg/ hw/arm7/ hw/aica/ hw/holly/ hw/ hw/gdrom/ hw/maple/ \
|
RZDCY_MODULES := cfg/ hw/arm7/ hw/aica/ hw/holly/ hw/ hw/gdrom/ hw/maple/ \
|
||||||
hw/mem/ hw/pvr/ hw/sh4/ hw/sh4/interpr/ hw/sh4/modules/ plugins/ profiler/ oslib/ \
|
hw/mem/ hw/pvr/ hw/sh4/ hw/sh4/interpr/ hw/sh4/modules/ plugins/ profiler/ oslib/ \
|
||||||
hw/extdev/ hw/arm/ hw/naomi/ imgread/ linux/ ./ deps/coreio/ deps/zlib/ deps/chdr/ deps/crypto/ \
|
hw/extdev/ hw/arm/ hw/naomi/ imgread/ linux/ ./ deps/coreio/ deps/zlib/ deps/chdr/ deps/crypto/ \
|
||||||
deps/libelf/ deps/chdpsr/ arm_emitter/ rend/ reios/ deps/libpng/
|
deps/libelf/ deps/chdpsr/ arm_emitter/ rend/ reios/ deps/libpng/
|
||||||
|
|
||||||
|
ifdef CHD5_LZMA
|
||||||
|
RZDCY_MODULES += deps/lzma/
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
ifdef WEBUI
|
ifdef WEBUI
|
||||||
|
@ -70,7 +74,7 @@ endif
|
||||||
RZDCY_FILES := $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.cpp))
|
RZDCY_FILES := $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.cpp))
|
||||||
RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.c))
|
RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.c))
|
||||||
RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.S))
|
RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.S))
|
||||||
|
|
||||||
ifdef FOR_PANDORA
|
ifdef FOR_PANDORA
|
||||||
RZDCY_CFLAGS := \
|
RZDCY_CFLAGS := \
|
||||||
$(CFLAGS) -c -O3 -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/deps \
|
$(CFLAGS) -c -O3 -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/deps \
|
||||||
|
@ -86,7 +90,7 @@ RZDCY_CFLAGS := \
|
||||||
-D_ANDROID -DRELEASE\
|
-D_ANDROID -DRELEASE\
|
||||||
-frename-registers -fsingle-precision-constant -ffast-math \
|
-frename-registers -fsingle-precision-constant -ffast-math \
|
||||||
-ftree-vectorize -fomit-frame-pointer
|
-ftree-vectorize -fomit-frame-pointer
|
||||||
|
|
||||||
ifndef NOT_ARM
|
ifndef NOT_ARM
|
||||||
RZDCY_CFLAGS += -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16
|
RZDCY_CFLAGS += -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16
|
||||||
RZDCY_CFLAGS += -DTARGET_LINUX_ARMELv7
|
RZDCY_CFLAGS += -DTARGET_LINUX_ARMELv7
|
||||||
|
|
|
@ -49,8 +49,8 @@
|
||||||
#endif // CHD5_FLAC
|
#endif // CHD5_FLAC
|
||||||
#include "huffman.h"
|
#include "huffman.h"
|
||||||
#if defined(CHD5_LZMA)
|
#if defined(CHD5_LZMA)
|
||||||
#include "LzmaEnc.h"
|
#include "deps/lzma/LzmaEnc.h"
|
||||||
#include "LzmaDec.h"
|
#include "deps/lzma/LzmaDec.h"
|
||||||
#endif // CHD5_LZMA
|
#endif // CHD5_LZMA
|
||||||
#include "crypto/md5.h"
|
#include "crypto/md5.h"
|
||||||
#include "crypto/sha1.h"
|
#include "crypto/sha1.h"
|
||||||
|
|
|
@ -0,0 +1,256 @@
|
||||||
|
/* 7zTypes.h -- Basic types
|
||||||
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __7Z_TYPES_H
|
||||||
|
#define __7Z_TYPES_H
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
/* #include <windows.h> */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#ifndef EXTERN_C_BEGIN
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN_C_BEGIN extern "C" {
|
||||||
|
#define EXTERN_C_END }
|
||||||
|
#else
|
||||||
|
#define EXTERN_C_BEGIN
|
||||||
|
#define EXTERN_C_END
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
#define SZ_OK 0
|
||||||
|
|
||||||
|
#define SZ_ERROR_DATA 1
|
||||||
|
#define SZ_ERROR_MEM 2
|
||||||
|
#define SZ_ERROR_CRC 3
|
||||||
|
#define SZ_ERROR_UNSUPPORTED 4
|
||||||
|
#define SZ_ERROR_PARAM 5
|
||||||
|
#define SZ_ERROR_INPUT_EOF 6
|
||||||
|
#define SZ_ERROR_OUTPUT_EOF 7
|
||||||
|
#define SZ_ERROR_READ 8
|
||||||
|
#define SZ_ERROR_WRITE 9
|
||||||
|
#define SZ_ERROR_PROGRESS 10
|
||||||
|
#define SZ_ERROR_FAIL 11
|
||||||
|
#define SZ_ERROR_THREAD 12
|
||||||
|
|
||||||
|
#define SZ_ERROR_ARCHIVE 16
|
||||||
|
#define SZ_ERROR_NO_ARCHIVE 17
|
||||||
|
|
||||||
|
typedef int SRes;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
/* typedef DWORD WRes; */
|
||||||
|
typedef unsigned WRes;
|
||||||
|
#else
|
||||||
|
typedef int WRes;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef RINOK
|
||||||
|
#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef unsigned char Byte;
|
||||||
|
typedef short Int16;
|
||||||
|
typedef unsigned short UInt16;
|
||||||
|
|
||||||
|
#ifdef _LZMA_UINT32_IS_ULONG
|
||||||
|
typedef long Int32;
|
||||||
|
typedef unsigned long UInt32;
|
||||||
|
#else
|
||||||
|
typedef int Int32;
|
||||||
|
typedef unsigned int UInt32;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _SZ_NO_INT_64
|
||||||
|
|
||||||
|
/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
|
||||||
|
NOTES: Some code will work incorrectly in that case! */
|
||||||
|
|
||||||
|
typedef long Int64;
|
||||||
|
typedef unsigned long UInt64;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||||
|
typedef __int64 Int64;
|
||||||
|
typedef unsigned __int64 UInt64;
|
||||||
|
#define UINT64_CONST(n) n
|
||||||
|
#else
|
||||||
|
typedef long long int Int64;
|
||||||
|
typedef unsigned long long int UInt64;
|
||||||
|
#define UINT64_CONST(n) n ## ULL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _LZMA_NO_SYSTEM_SIZE_T
|
||||||
|
typedef UInt32 SizeT;
|
||||||
|
#else
|
||||||
|
typedef size_t SizeT;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef int Bool;
|
||||||
|
#define True 1
|
||||||
|
#define False 0
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define MY_STD_CALL __stdcall
|
||||||
|
#else
|
||||||
|
#define MY_STD_CALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
#if _MSC_VER >= 1300
|
||||||
|
#define MY_NO_INLINE __declspec(noinline)
|
||||||
|
#else
|
||||||
|
#define MY_NO_INLINE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MY_CDECL __cdecl
|
||||||
|
#define MY_FAST_CALL __fastcall
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define MY_NO_INLINE
|
||||||
|
#define MY_CDECL
|
||||||
|
#define MY_FAST_CALL
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* The following interfaces use first parameter as pointer to structure */
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Byte (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */
|
||||||
|
} IByteIn;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
void (*Write)(void *p, Byte b);
|
||||||
|
} IByteOut;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
SRes (*Read)(void *p, void *buf, size_t *size);
|
||||||
|
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
|
||||||
|
(output(*size) < input(*size)) is allowed */
|
||||||
|
} ISeqInStream;
|
||||||
|
|
||||||
|
/* it can return SZ_ERROR_INPUT_EOF */
|
||||||
|
SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size);
|
||||||
|
SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType);
|
||||||
|
SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf);
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
size_t (*Write)(void *p, const void *buf, size_t size);
|
||||||
|
/* Returns: result - the number of actually written bytes.
|
||||||
|
(result < size) means error */
|
||||||
|
} ISeqOutStream;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SZ_SEEK_SET = 0,
|
||||||
|
SZ_SEEK_CUR = 1,
|
||||||
|
SZ_SEEK_END = 2
|
||||||
|
} ESzSeek;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */
|
||||||
|
SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
|
||||||
|
} ISeekInStream;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
SRes (*Look)(void *p, const void **buf, size_t *size);
|
||||||
|
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
|
||||||
|
(output(*size) > input(*size)) is not allowed
|
||||||
|
(output(*size) < input(*size)) is allowed */
|
||||||
|
SRes (*Skip)(void *p, size_t offset);
|
||||||
|
/* offset must be <= output(*size) of Look */
|
||||||
|
|
||||||
|
SRes (*Read)(void *p, void *buf, size_t *size);
|
||||||
|
/* reads directly (without buffer). It's same as ISeqInStream::Read */
|
||||||
|
SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
|
||||||
|
} ILookInStream;
|
||||||
|
|
||||||
|
SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size);
|
||||||
|
SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset);
|
||||||
|
|
||||||
|
/* reads via ILookInStream::Read */
|
||||||
|
SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType);
|
||||||
|
SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size);
|
||||||
|
|
||||||
|
#define LookToRead_BUF_SIZE (1 << 14)
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ILookInStream s;
|
||||||
|
ISeekInStream *realStream;
|
||||||
|
size_t pos;
|
||||||
|
size_t size;
|
||||||
|
Byte buf[LookToRead_BUF_SIZE];
|
||||||
|
} CLookToRead;
|
||||||
|
|
||||||
|
void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
|
||||||
|
void LookToRead_Init(CLookToRead *p);
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ISeqInStream s;
|
||||||
|
ILookInStream *realStream;
|
||||||
|
} CSecToLook;
|
||||||
|
|
||||||
|
void SecToLook_CreateVTable(CSecToLook *p);
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ISeqInStream s;
|
||||||
|
ILookInStream *realStream;
|
||||||
|
} CSecToRead;
|
||||||
|
|
||||||
|
void SecToRead_CreateVTable(CSecToRead *p);
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);
|
||||||
|
/* Returns: result. (result != SZ_OK) means break.
|
||||||
|
Value (UInt64)(Int64)-1 for size means unknown value. */
|
||||||
|
} ICompressProgress;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
void *(*Alloc)(void *p, size_t size);
|
||||||
|
void (*Free)(void *p, void *address); /* address can be 0 */
|
||||||
|
} ISzAlloc;
|
||||||
|
|
||||||
|
#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
|
||||||
|
#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
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,136 @@
|
||||||
|
/* Alloc.c -- Memory allocation functions
|
||||||
|
2015-02-21 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
|
|
||||||
|
/* #define _SZ_ALLOC_DEBUG */
|
||||||
|
|
||||||
|
/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
|
||||||
|
#ifdef _SZ_ALLOC_DEBUG
|
||||||
|
#include <stdio.h>
|
||||||
|
int g_allocCount = 0;
|
||||||
|
int g_allocCountMid = 0;
|
||||||
|
int g_allocCountBig = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void *MyAlloc(size_t size)
|
||||||
|
{
|
||||||
|
if (size == 0)
|
||||||
|
return 0;
|
||||||
|
#ifdef _SZ_ALLOC_DEBUG
|
||||||
|
{
|
||||||
|
void *p = malloc(size);
|
||||||
|
fprintf(stderr, "\nAlloc %10d bytes, count = %10d, addr = %8X", size, g_allocCount++, (unsigned)p);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
return malloc(size);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFree(void *address)
|
||||||
|
{
|
||||||
|
#ifdef _SZ_ALLOC_DEBUG
|
||||||
|
if (address != 0)
|
||||||
|
fprintf(stderr, "\nFree; count = %10d, addr = %8X", --g_allocCount, (unsigned)address);
|
||||||
|
#endif
|
||||||
|
free(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
void *MidAlloc(size_t size)
|
||||||
|
{
|
||||||
|
if (size == 0)
|
||||||
|
return 0;
|
||||||
|
#ifdef _SZ_ALLOC_DEBUG
|
||||||
|
fprintf(stderr, "\nAlloc_Mid %10d bytes; count = %10d", size, g_allocCountMid++);
|
||||||
|
#endif
|
||||||
|
return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MidFree(void *address)
|
||||||
|
{
|
||||||
|
#ifdef _SZ_ALLOC_DEBUG
|
||||||
|
if (address != 0)
|
||||||
|
fprintf(stderr, "\nFree_Mid; count = %10d", --g_allocCountMid);
|
||||||
|
#endif
|
||||||
|
if (address == 0)
|
||||||
|
return;
|
||||||
|
VirtualFree(address, 0, MEM_RELEASE);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef MEM_LARGE_PAGES
|
||||||
|
#undef _7ZIP_LARGE_PAGES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _7ZIP_LARGE_PAGES
|
||||||
|
SIZE_T g_LargePageSize = 0;
|
||||||
|
typedef SIZE_T (WINAPI *GetLargePageMinimumP)();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void SetLargePageSize()
|
||||||
|
{
|
||||||
|
#ifdef _7ZIP_LARGE_PAGES
|
||||||
|
SIZE_T size = 0;
|
||||||
|
GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP)
|
||||||
|
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");
|
||||||
|
if (largePageMinimum == 0)
|
||||||
|
return;
|
||||||
|
size = largePageMinimum();
|
||||||
|
if (size == 0 || (size & (size - 1)) != 0)
|
||||||
|
return;
|
||||||
|
g_LargePageSize = size;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void *BigAlloc(size_t size)
|
||||||
|
{
|
||||||
|
if (size == 0)
|
||||||
|
return 0;
|
||||||
|
#ifdef _SZ_ALLOC_DEBUG
|
||||||
|
fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _7ZIP_LARGE_PAGES
|
||||||
|
if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18))
|
||||||
|
{
|
||||||
|
void *res = VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)),
|
||||||
|
MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);
|
||||||
|
if (res != 0)
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BigFree(void *address)
|
||||||
|
{
|
||||||
|
#ifdef _SZ_ALLOC_DEBUG
|
||||||
|
if (address != 0)
|
||||||
|
fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (address == 0)
|
||||||
|
return;
|
||||||
|
VirtualFree(address, 0, MEM_RELEASE);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static void *SzAlloc(void *p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }
|
||||||
|
static void SzFree(void *p, void *address) { UNUSED_VAR(p); MyFree(address); }
|
||||||
|
ISzAlloc g_Alloc = { SzAlloc, SzFree };
|
||||||
|
|
||||||
|
static void *SzBigAlloc(void *p, size_t size) { UNUSED_VAR(p); return BigAlloc(size); }
|
||||||
|
static void SzBigFree(void *p, void *address) { UNUSED_VAR(p); BigFree(address); }
|
||||||
|
ISzAlloc g_BigAlloc = { SzBigAlloc, SzBigFree };
|
|
@ -0,0 +1,37 @@
|
||||||
|
/* Alloc.h -- Memory allocation functions
|
||||||
|
2015-02-21 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __COMMON_ALLOC_H
|
||||||
|
#define __COMMON_ALLOC_H
|
||||||
|
|
||||||
|
#include "7zTypes.h"
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
void *MyAlloc(size_t size);
|
||||||
|
void MyFree(void *address);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
void SetLargePageSize();
|
||||||
|
|
||||||
|
void *MidAlloc(size_t size);
|
||||||
|
void MidFree(void *address);
|
||||||
|
void *BigAlloc(size_t size);
|
||||||
|
void BigFree(void *address);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define MidAlloc(size) MyAlloc(size)
|
||||||
|
#define MidFree(address) MyFree(address)
|
||||||
|
#define BigAlloc(size) MyAlloc(size)
|
||||||
|
#define BigFree(address) MyFree(address)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern ISzAlloc g_Alloc;
|
||||||
|
extern ISzAlloc g_BigAlloc;
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,135 @@
|
||||||
|
/* Bra.c -- Converters for RISC code
|
||||||
|
2010-04-16 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
|
#include "Bra.h"
|
||||||
|
|
||||||
|
SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
|
||||||
|
{
|
||||||
|
SizeT i;
|
||||||
|
if (size < 4)
|
||||||
|
return 0;
|
||||||
|
size -= 4;
|
||||||
|
ip += 8;
|
||||||
|
for (i = 0; i <= size; i += 4)
|
||||||
|
{
|
||||||
|
if (data[i + 3] == 0xEB)
|
||||||
|
{
|
||||||
|
UInt32 dest;
|
||||||
|
UInt32 src = ((UInt32)data[i + 2] << 16) | ((UInt32)data[i + 1] << 8) | (data[i + 0]);
|
||||||
|
src <<= 2;
|
||||||
|
if (encoding)
|
||||||
|
dest = ip + (UInt32)i + src;
|
||||||
|
else
|
||||||
|
dest = src - (ip + (UInt32)i);
|
||||||
|
dest >>= 2;
|
||||||
|
data[i + 2] = (Byte)(dest >> 16);
|
||||||
|
data[i + 1] = (Byte)(dest >> 8);
|
||||||
|
data[i + 0] = (Byte)dest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
|
||||||
|
{
|
||||||
|
SizeT i;
|
||||||
|
if (size < 4)
|
||||||
|
return 0;
|
||||||
|
size -= 4;
|
||||||
|
ip += 4;
|
||||||
|
for (i = 0; i <= size; i += 2)
|
||||||
|
{
|
||||||
|
if ((data[i + 1] & 0xF8) == 0xF0 &&
|
||||||
|
(data[i + 3] & 0xF8) == 0xF8)
|
||||||
|
{
|
||||||
|
UInt32 dest;
|
||||||
|
UInt32 src =
|
||||||
|
(((UInt32)data[i + 1] & 0x7) << 19) |
|
||||||
|
((UInt32)data[i + 0] << 11) |
|
||||||
|
(((UInt32)data[i + 3] & 0x7) << 8) |
|
||||||
|
(data[i + 2]);
|
||||||
|
|
||||||
|
src <<= 1;
|
||||||
|
if (encoding)
|
||||||
|
dest = ip + (UInt32)i + src;
|
||||||
|
else
|
||||||
|
dest = src - (ip + (UInt32)i);
|
||||||
|
dest >>= 1;
|
||||||
|
|
||||||
|
data[i + 1] = (Byte)(0xF0 | ((dest >> 19) & 0x7));
|
||||||
|
data[i + 0] = (Byte)(dest >> 11);
|
||||||
|
data[i + 3] = (Byte)(0xF8 | ((dest >> 8) & 0x7));
|
||||||
|
data[i + 2] = (Byte)dest;
|
||||||
|
i += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
|
||||||
|
{
|
||||||
|
SizeT i;
|
||||||
|
if (size < 4)
|
||||||
|
return 0;
|
||||||
|
size -= 4;
|
||||||
|
for (i = 0; i <= size; i += 4)
|
||||||
|
{
|
||||||
|
if ((data[i] >> 2) == 0x12 && (data[i + 3] & 3) == 1)
|
||||||
|
{
|
||||||
|
UInt32 src = ((UInt32)(data[i + 0] & 3) << 24) |
|
||||||
|
((UInt32)data[i + 1] << 16) |
|
||||||
|
((UInt32)data[i + 2] << 8) |
|
||||||
|
((UInt32)data[i + 3] & (~3));
|
||||||
|
|
||||||
|
UInt32 dest;
|
||||||
|
if (encoding)
|
||||||
|
dest = ip + (UInt32)i + src;
|
||||||
|
else
|
||||||
|
dest = src - (ip + (UInt32)i);
|
||||||
|
data[i + 0] = (Byte)(0x48 | ((dest >> 24) & 0x3));
|
||||||
|
data[i + 1] = (Byte)(dest >> 16);
|
||||||
|
data[i + 2] = (Byte)(dest >> 8);
|
||||||
|
data[i + 3] &= 0x3;
|
||||||
|
data[i + 3] |= dest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
|
||||||
|
{
|
||||||
|
UInt32 i;
|
||||||
|
if (size < 4)
|
||||||
|
return 0;
|
||||||
|
size -= 4;
|
||||||
|
for (i = 0; i <= size; i += 4)
|
||||||
|
{
|
||||||
|
if ((data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00) ||
|
||||||
|
(data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0))
|
||||||
|
{
|
||||||
|
UInt32 src =
|
||||||
|
((UInt32)data[i + 0] << 24) |
|
||||||
|
((UInt32)data[i + 1] << 16) |
|
||||||
|
((UInt32)data[i + 2] << 8) |
|
||||||
|
((UInt32)data[i + 3]);
|
||||||
|
UInt32 dest;
|
||||||
|
|
||||||
|
src <<= 2;
|
||||||
|
if (encoding)
|
||||||
|
dest = ip + i + src;
|
||||||
|
else
|
||||||
|
dest = src - (ip + i);
|
||||||
|
dest >>= 2;
|
||||||
|
|
||||||
|
dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000;
|
||||||
|
|
||||||
|
data[i + 0] = (Byte)(dest >> 24);
|
||||||
|
data[i + 1] = (Byte)(dest >> 16);
|
||||||
|
data[i + 2] = (Byte)(dest >> 8);
|
||||||
|
data[i + 3] = (Byte)dest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/* Bra.h -- Branch converters for executables
|
||||||
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __BRA_H
|
||||||
|
#define __BRA_H
|
||||||
|
|
||||||
|
#include "7zTypes.h"
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
/*
|
||||||
|
These functions convert relative addresses to absolute addresses
|
||||||
|
in CALL instructions to increase the compression ratio.
|
||||||
|
|
||||||
|
In:
|
||||||
|
data - data buffer
|
||||||
|
size - size of data
|
||||||
|
ip - current virtual Instruction Pinter (IP) value
|
||||||
|
state - state variable for x86 converter
|
||||||
|
encoding - 0 (for decoding), 1 (for encoding)
|
||||||
|
|
||||||
|
Out:
|
||||||
|
state - state variable for x86 converter
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The number of processed bytes. If you call these functions with multiple calls,
|
||||||
|
you must start next call with first byte after block of processed bytes.
|
||||||
|
|
||||||
|
Type Endian Alignment LookAhead
|
||||||
|
|
||||||
|
x86 little 1 4
|
||||||
|
ARMT little 2 2
|
||||||
|
ARM little 4 0
|
||||||
|
PPC big 4 0
|
||||||
|
SPARC big 4 0
|
||||||
|
IA64 little 16 0
|
||||||
|
|
||||||
|
size must be >= Alignment + LookAhead, if it's not last block.
|
||||||
|
If (size < Alignment + LookAhead), converter returns 0.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
UInt32 ip = 0;
|
||||||
|
for ()
|
||||||
|
{
|
||||||
|
; size must be >= Alignment + LookAhead, if it's not last block
|
||||||
|
SizeT processed = Convert(data, size, ip, 1);
|
||||||
|
data += processed;
|
||||||
|
size -= processed;
|
||||||
|
ip += processed;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define x86_Convert_Init(state) { state = 0; }
|
||||||
|
SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding);
|
||||||
|
SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
|
||||||
|
SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
|
||||||
|
SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
|
||||||
|
SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
|
||||||
|
SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,82 @@
|
||||||
|
/* Bra86.c -- Converter for x86 code (BCJ)
|
||||||
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
|
#include "Bra.h"
|
||||||
|
|
||||||
|
#define Test86MSByte(b) ((((b) + 1) & 0xFE) == 0)
|
||||||
|
|
||||||
|
SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding)
|
||||||
|
{
|
||||||
|
SizeT pos = 0;
|
||||||
|
UInt32 mask = *state & 7;
|
||||||
|
if (size < 5)
|
||||||
|
return 0;
|
||||||
|
size -= 4;
|
||||||
|
ip += 5;
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
Byte *p = data + pos;
|
||||||
|
const Byte *limit = data + size;
|
||||||
|
for (; p < limit; p++)
|
||||||
|
if ((*p & 0xFE) == 0xE8)
|
||||||
|
break;
|
||||||
|
|
||||||
|
{
|
||||||
|
SizeT d = (SizeT)(p - data - pos);
|
||||||
|
pos = (SizeT)(p - data);
|
||||||
|
if (p >= limit)
|
||||||
|
{
|
||||||
|
*state = (d > 2 ? 0 : mask >> (unsigned)d);
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
if (d > 2)
|
||||||
|
mask = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mask >>= (unsigned)d;
|
||||||
|
if (mask != 0 && (mask > 4 || mask == 3 || Test86MSByte(p[(mask >> 1) + 1])))
|
||||||
|
{
|
||||||
|
mask = (mask >> 1) | 4;
|
||||||
|
pos++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Test86MSByte(p[4]))
|
||||||
|
{
|
||||||
|
UInt32 v = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]);
|
||||||
|
UInt32 cur = ip + (UInt32)pos;
|
||||||
|
pos += 5;
|
||||||
|
if (encoding)
|
||||||
|
v += cur;
|
||||||
|
else
|
||||||
|
v -= cur;
|
||||||
|
if (mask != 0)
|
||||||
|
{
|
||||||
|
unsigned sh = (mask & 6) << 2;
|
||||||
|
if (Test86MSByte((Byte)(v >> sh)))
|
||||||
|
{
|
||||||
|
v ^= (((UInt32)0x100 << sh) - 1);
|
||||||
|
if (encoding)
|
||||||
|
v += cur;
|
||||||
|
else
|
||||||
|
v -= cur;
|
||||||
|
}
|
||||||
|
mask = 0;
|
||||||
|
}
|
||||||
|
p[1] = (Byte)v;
|
||||||
|
p[2] = (Byte)(v >> 8);
|
||||||
|
p[3] = (Byte)(v >> 16);
|
||||||
|
p[4] = (Byte)(0 - ((v >> 24) & 1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mask = (mask >> 1) | 4;
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
/* BraIA64.c -- Converter for IA-64 code
|
||||||
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
|
#include "Bra.h"
|
||||||
|
|
||||||
|
static const Byte kBranchTable[32] =
|
||||||
|
{
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
4, 4, 6, 6, 0, 0, 7, 7,
|
||||||
|
4, 4, 0, 0, 4, 4, 0, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
|
||||||
|
{
|
||||||
|
SizeT i;
|
||||||
|
if (size < 16)
|
||||||
|
return 0;
|
||||||
|
size -= 16;
|
||||||
|
for (i = 0; i <= size; i += 16)
|
||||||
|
{
|
||||||
|
UInt32 instrTemplate = data[i] & 0x1F;
|
||||||
|
UInt32 mask = kBranchTable[instrTemplate];
|
||||||
|
UInt32 bitPos = 5;
|
||||||
|
int slot;
|
||||||
|
for (slot = 0; slot < 3; slot++, bitPos += 41)
|
||||||
|
{
|
||||||
|
UInt32 bytePos, bitRes;
|
||||||
|
UInt64 instruction, instNorm;
|
||||||
|
int j;
|
||||||
|
if (((mask >> slot) & 1) == 0)
|
||||||
|
continue;
|
||||||
|
bytePos = (bitPos >> 3);
|
||||||
|
bitRes = bitPos & 0x7;
|
||||||
|
instruction = 0;
|
||||||
|
for (j = 0; j < 6; j++)
|
||||||
|
instruction += (UInt64)data[i + j + bytePos] << (8 * j);
|
||||||
|
|
||||||
|
instNorm = instruction >> bitRes;
|
||||||
|
if (((instNorm >> 37) & 0xF) == 0x5 && ((instNorm >> 9) & 0x7) == 0)
|
||||||
|
{
|
||||||
|
UInt32 src = (UInt32)((instNorm >> 13) & 0xFFFFF);
|
||||||
|
UInt32 dest;
|
||||||
|
src |= ((UInt32)(instNorm >> 36) & 1) << 20;
|
||||||
|
|
||||||
|
src <<= 4;
|
||||||
|
|
||||||
|
if (encoding)
|
||||||
|
dest = ip + (UInt32)i + src;
|
||||||
|
else
|
||||||
|
dest = src - (ip + (UInt32)i);
|
||||||
|
|
||||||
|
dest >>= 4;
|
||||||
|
|
||||||
|
instNorm &= ~((UInt64)(0x8FFFFF) << 13);
|
||||||
|
instNorm |= ((UInt64)(dest & 0xFFFFF) << 13);
|
||||||
|
instNorm |= ((UInt64)(dest & 0x100000) << (36 - 20));
|
||||||
|
|
||||||
|
instruction &= (1 << bitRes) - 1;
|
||||||
|
instruction |= (instNorm << bitRes);
|
||||||
|
for (j = 0; j < 6; j++)
|
||||||
|
data[i + j + bytePos] = (Byte)(instruction >> (8 * j));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
/* Compiler.h
|
||||||
|
2015-08-02 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __7Z_COMPILER_H
|
||||||
|
#define __7Z_COMPILER_H
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
#ifdef UNDER_CE
|
||||||
|
#define RPC_NO_WINDOWS_H
|
||||||
|
/* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */
|
||||||
|
#pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union
|
||||||
|
#pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _MSC_VER >= 1300
|
||||||
|
#pragma warning(disable : 4996) // This function or variable may be unsafe
|
||||||
|
#else
|
||||||
|
#pragma warning(disable : 4511) // copy constructor could not be generated
|
||||||
|
#pragma warning(disable : 4512) // assignment operator could not be generated
|
||||||
|
#pragma warning(disable : 4514) // unreferenced inline function has been removed
|
||||||
|
#pragma warning(disable : 4702) // unreachable code
|
||||||
|
#pragma warning(disable : 4710) // not inlined
|
||||||
|
#pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define UNUSED_VAR(x) (void)x;
|
||||||
|
/* #define UNUSED_VAR(x) x=x; */
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,200 @@
|
||||||
|
/* CpuArch.c -- CPU specific code
|
||||||
|
2016-02-25: Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
|
#include "CpuArch.h"
|
||||||
|
|
||||||
|
#ifdef MY_CPU_X86_OR_AMD64
|
||||||
|
|
||||||
|
#if (defined(_MSC_VER) && !defined(MY_CPU_AMD64)) || defined(__GNUC__)
|
||||||
|
#define USE_ASM
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(USE_ASM) && _MSC_VER >= 1500
|
||||||
|
#include <intrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(USE_ASM) && !defined(MY_CPU_AMD64)
|
||||||
|
static UInt32 CheckFlag(UInt32 flag)
|
||||||
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
__asm pushfd;
|
||||||
|
__asm pop EAX;
|
||||||
|
__asm mov EDX, EAX;
|
||||||
|
__asm xor EAX, flag;
|
||||||
|
__asm push EAX;
|
||||||
|
__asm popfd;
|
||||||
|
__asm pushfd;
|
||||||
|
__asm pop EAX;
|
||||||
|
__asm xor EAX, EDX;
|
||||||
|
__asm push EDX;
|
||||||
|
__asm popfd;
|
||||||
|
__asm and flag, EAX;
|
||||||
|
#else
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
"pushf\n\t"
|
||||||
|
"pop %%EAX\n\t"
|
||||||
|
"movl %%EAX,%%EDX\n\t"
|
||||||
|
"xorl %0,%%EAX\n\t"
|
||||||
|
"push %%EAX\n\t"
|
||||||
|
"popf\n\t"
|
||||||
|
"pushf\n\t"
|
||||||
|
"pop %%EAX\n\t"
|
||||||
|
"xorl %%EDX,%%EAX\n\t"
|
||||||
|
"push %%EDX\n\t"
|
||||||
|
"popf\n\t"
|
||||||
|
"andl %%EAX, %0\n\t":
|
||||||
|
"=c" (flag) : "c" (flag) :
|
||||||
|
"%eax", "%edx");
|
||||||
|
#endif
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
#define CHECK_CPUID_IS_SUPPORTED if (CheckFlag(1 << 18) == 0 || CheckFlag(1 << 21) == 0) return False;
|
||||||
|
#else
|
||||||
|
#define CHECK_CPUID_IS_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d)
|
||||||
|
{
|
||||||
|
#ifdef USE_ASM
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
UInt32 a2, b2, c2, d2;
|
||||||
|
__asm xor EBX, EBX;
|
||||||
|
__asm xor ECX, ECX;
|
||||||
|
__asm xor EDX, EDX;
|
||||||
|
__asm mov EAX, function;
|
||||||
|
__asm cpuid;
|
||||||
|
__asm mov a2, EAX;
|
||||||
|
__asm mov b2, EBX;
|
||||||
|
__asm mov c2, ECX;
|
||||||
|
__asm mov d2, EDX;
|
||||||
|
|
||||||
|
*a = a2;
|
||||||
|
*b = b2;
|
||||||
|
*c = c2;
|
||||||
|
*d = d2;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
#if defined(MY_CPU_AMD64) && defined(__PIC__)
|
||||||
|
"mov %%rbx, %%rdi;"
|
||||||
|
"cpuid;"
|
||||||
|
"xchg %%rbx, %%rdi;"
|
||||||
|
: "=a" (*a) ,
|
||||||
|
"=D" (*b) ,
|
||||||
|
#elif defined(MY_CPU_X86) && defined(__PIC__)
|
||||||
|
"mov %%ebx, %%edi;"
|
||||||
|
"cpuid;"
|
||||||
|
"xchgl %%ebx, %%edi;"
|
||||||
|
: "=a" (*a) ,
|
||||||
|
"=D" (*b) ,
|
||||||
|
#else
|
||||||
|
"cpuid"
|
||||||
|
: "=a" (*a) ,
|
||||||
|
"=b" (*b) ,
|
||||||
|
#endif
|
||||||
|
"=c" (*c) ,
|
||||||
|
"=d" (*d)
|
||||||
|
: "0" (function)) ;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
int CPUInfo[4];
|
||||||
|
__cpuid(CPUInfo, function);
|
||||||
|
*a = CPUInfo[0];
|
||||||
|
*b = CPUInfo[1];
|
||||||
|
*c = CPUInfo[2];
|
||||||
|
*d = CPUInfo[3];
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
Bool x86cpuid_CheckAndRead(Cx86cpuid *p)
|
||||||
|
{
|
||||||
|
CHECK_CPUID_IS_SUPPORTED
|
||||||
|
MyCPUID(0, &p->maxFunc, &p->vendor[0], &p->vendor[2], &p->vendor[1]);
|
||||||
|
MyCPUID(1, &p->ver, &p->b, &p->c, &p->d);
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const UInt32 kVendors[][3] =
|
||||||
|
{
|
||||||
|
{ 0x756E6547, 0x49656E69, 0x6C65746E},
|
||||||
|
{ 0x68747541, 0x69746E65, 0x444D4163},
|
||||||
|
{ 0x746E6543, 0x48727561, 0x736C7561}
|
||||||
|
};
|
||||||
|
|
||||||
|
int x86cpuid_GetFirm(const Cx86cpuid *p)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
for (i = 0; i < sizeof(kVendors) / sizeof(kVendors[i]); i++)
|
||||||
|
{
|
||||||
|
const UInt32 *v = kVendors[i];
|
||||||
|
if (v[0] == p->vendor[0] &&
|
||||||
|
v[1] == p->vendor[1] &&
|
||||||
|
v[2] == p->vendor[2])
|
||||||
|
return (int)i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bool CPU_Is_InOrder()
|
||||||
|
{
|
||||||
|
Cx86cpuid p;
|
||||||
|
int firm;
|
||||||
|
UInt32 family, model;
|
||||||
|
if (!x86cpuid_CheckAndRead(&p))
|
||||||
|
return True;
|
||||||
|
|
||||||
|
family = x86cpuid_GetFamily(p.ver);
|
||||||
|
model = x86cpuid_GetModel(p.ver);
|
||||||
|
|
||||||
|
firm = x86cpuid_GetFirm(&p);
|
||||||
|
|
||||||
|
switch (firm)
|
||||||
|
{
|
||||||
|
case CPU_FIRM_INTEL: return (family < 6 || (family == 6 && (
|
||||||
|
/* In-Order Atom CPU */
|
||||||
|
model == 0x1C /* 45 nm, N4xx, D4xx, N5xx, D5xx, 230, 330 */
|
||||||
|
|| model == 0x26 /* 45 nm, Z6xx */
|
||||||
|
|| model == 0x27 /* 32 nm, Z2460 */
|
||||||
|
|| model == 0x35 /* 32 nm, Z2760 */
|
||||||
|
|| model == 0x36 /* 32 nm, N2xxx, D2xxx */
|
||||||
|
)));
|
||||||
|
case CPU_FIRM_AMD: return (family < 5 || (family == 5 && (model < 6 || model == 0xA)));
|
||||||
|
case CPU_FIRM_VIA: return (family < 6 || (family == 6 && model < 0xF));
|
||||||
|
}
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(MY_CPU_AMD64) && defined(_WIN32)
|
||||||
|
#include <windows.h>
|
||||||
|
static Bool CPU_Sys_Is_SSE_Supported()
|
||||||
|
{
|
||||||
|
OSVERSIONINFO vi;
|
||||||
|
vi.dwOSVersionInfoSize = sizeof(vi);
|
||||||
|
if (!GetVersionEx(&vi))
|
||||||
|
return False;
|
||||||
|
return (vi.dwMajorVersion >= 5);
|
||||||
|
}
|
||||||
|
#define CHECK_SYS_SSE_SUPPORT if (!CPU_Sys_Is_SSE_Supported()) return False;
|
||||||
|
#else
|
||||||
|
#define CHECK_SYS_SSE_SUPPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Bool CPU_Is_Aes_Supported()
|
||||||
|
{
|
||||||
|
Cx86cpuid p;
|
||||||
|
CHECK_SYS_SSE_SUPPORT
|
||||||
|
if (!x86cpuid_CheckAndRead(&p))
|
||||||
|
return False;
|
||||||
|
return (p.c >> 25) & 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,223 @@
|
||||||
|
/* CpuArch.h -- CPU specific code
|
||||||
|
2016-06-09: Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __CPU_ARCH_H
|
||||||
|
#define __CPU_ARCH_H
|
||||||
|
|
||||||
|
#include "7zTypes.h"
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
/*
|
||||||
|
MY_CPU_LE means that CPU is LITTLE ENDIAN.
|
||||||
|
MY_CPU_BE means that CPU is BIG ENDIAN.
|
||||||
|
If MY_CPU_LE and MY_CPU_BE are not defined, we don't know about ENDIANNESS of platform.
|
||||||
|
|
||||||
|
MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(_M_X64) \
|
||||||
|
|| defined(_M_AMD64) \
|
||||||
|
|| defined(__x86_64__) \
|
||||||
|
|| defined(__AMD64__) \
|
||||||
|
|| defined(__amd64__)
|
||||||
|
#define MY_CPU_AMD64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MY_CPU_AMD64) \
|
||||||
|
|| defined(_M_IA64) \
|
||||||
|
|| defined(__AARCH64EL__) \
|
||||||
|
|| defined(__AARCH64EB__)
|
||||||
|
#define MY_CPU_64BIT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_M_IX86) || defined(__i386__)
|
||||||
|
#define MY_CPU_X86
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MY_CPU_X86) || defined(MY_CPU_AMD64)
|
||||||
|
#define MY_CPU_X86_OR_AMD64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MY_CPU_X86) \
|
||||||
|
|| defined(_M_ARM) \
|
||||||
|
|| defined(__ARMEL__) \
|
||||||
|
|| defined(__THUMBEL__) \
|
||||||
|
|| defined(__ARMEB__) \
|
||||||
|
|| defined(__THUMBEB__)
|
||||||
|
#define MY_CPU_32BIT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32) && defined(_M_ARM)
|
||||||
|
#define MY_CPU_ARM_LE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32) && defined(_M_IA64)
|
||||||
|
#define MY_CPU_IA64_LE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MY_CPU_X86_OR_AMD64) \
|
||||||
|
|| defined(MY_CPU_ARM_LE) \
|
||||||
|
|| defined(MY_CPU_IA64_LE) \
|
||||||
|
|| defined(__LITTLE_ENDIAN__) \
|
||||||
|
|| defined(__ARMEL__) \
|
||||||
|
|| defined(__THUMBEL__) \
|
||||||
|
|| defined(__AARCH64EL__) \
|
||||||
|
|| defined(__MIPSEL__) \
|
||||||
|
|| defined(__MIPSEL) \
|
||||||
|
|| defined(_MIPSEL) \
|
||||||
|
|| defined(__BFIN__) \
|
||||||
|
|| (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
|
||||||
|
#define MY_CPU_LE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__BIG_ENDIAN__) \
|
||||||
|
|| defined(__ARMEB__) \
|
||||||
|
|| defined(__THUMBEB__) \
|
||||||
|
|| defined(__AARCH64EB__) \
|
||||||
|
|| defined(__MIPSEB__) \
|
||||||
|
|| defined(__MIPSEB) \
|
||||||
|
|| defined(_MIPSEB) \
|
||||||
|
|| defined(__m68k__) \
|
||||||
|
|| defined(__s390__) \
|
||||||
|
|| defined(__s390x__) \
|
||||||
|
|| defined(__zarch__) \
|
||||||
|
|| (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
|
||||||
|
#define MY_CPU_BE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MY_CPU_LE) && defined(MY_CPU_BE)
|
||||||
|
Stop_Compiling_Bad_Endian
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef MY_CPU_LE
|
||||||
|
#if defined(MY_CPU_X86_OR_AMD64) \
|
||||||
|
/* || defined(__AARCH64EL__) */
|
||||||
|
#define MY_CPU_LE_UNALIGN
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef MY_CPU_LE_UNALIGN
|
||||||
|
|
||||||
|
#define GetUi16(p) (*(const UInt16 *)(const void *)(p))
|
||||||
|
#define GetUi32(p) (*(const UInt32 *)(const void *)(p))
|
||||||
|
#define GetUi64(p) (*(const UInt64 *)(const void *)(p))
|
||||||
|
|
||||||
|
#define SetUi16(p, v) { *(UInt16 *)(p) = (v); }
|
||||||
|
#define SetUi32(p, v) { *(UInt32 *)(p) = (v); }
|
||||||
|
#define SetUi64(p, v) { *(UInt64 *)(p) = (v); }
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define GetUi16(p) ( (UInt16) ( \
|
||||||
|
((const Byte *)(p))[0] | \
|
||||||
|
((UInt16)((const Byte *)(p))[1] << 8) ))
|
||||||
|
|
||||||
|
#define GetUi32(p) ( \
|
||||||
|
((const Byte *)(p))[0] | \
|
||||||
|
((UInt32)((const Byte *)(p))[1] << 8) | \
|
||||||
|
((UInt32)((const Byte *)(p))[2] << 16) | \
|
||||||
|
((UInt32)((const Byte *)(p))[3] << 24))
|
||||||
|
|
||||||
|
#define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32))
|
||||||
|
|
||||||
|
#define SetUi16(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \
|
||||||
|
_ppp_[0] = (Byte)_vvv_; \
|
||||||
|
_ppp_[1] = (Byte)(_vvv_ >> 8); }
|
||||||
|
|
||||||
|
#define SetUi32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \
|
||||||
|
_ppp_[0] = (Byte)_vvv_; \
|
||||||
|
_ppp_[1] = (Byte)(_vvv_ >> 8); \
|
||||||
|
_ppp_[2] = (Byte)(_vvv_ >> 16); \
|
||||||
|
_ppp_[3] = (Byte)(_vvv_ >> 24); }
|
||||||
|
|
||||||
|
#define SetUi64(p, v) { Byte *_ppp2_ = (Byte *)(p); UInt64 _vvv2_ = (v); \
|
||||||
|
SetUi32(_ppp2_ , (UInt32)_vvv2_); \
|
||||||
|
SetUi32(_ppp2_ + 4, (UInt32)(_vvv2_ >> 32)); }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(MY_CPU_LE_UNALIGN) && /* defined(_WIN64) && */ (_MSC_VER >= 1300)
|
||||||
|
|
||||||
|
/* Note: we use bswap instruction, that is unsupported in 386 cpu */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#pragma intrinsic(_byteswap_ulong)
|
||||||
|
#pragma intrinsic(_byteswap_uint64)
|
||||||
|
#define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p))
|
||||||
|
#define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const Byte *)(p))
|
||||||
|
|
||||||
|
#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = _byteswap_ulong(v)
|
||||||
|
|
||||||
|
#elif defined(MY_CPU_LE_UNALIGN) && defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
|
||||||
|
|
||||||
|
#define GetBe32(p) __builtin_bswap32(*(const UInt32 *)(const Byte *)(p))
|
||||||
|
#define GetBe64(p) __builtin_bswap64(*(const UInt64 *)(const Byte *)(p))
|
||||||
|
|
||||||
|
#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = __builtin_bswap32(v)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define GetBe32(p) ( \
|
||||||
|
((UInt32)((const Byte *)(p))[0] << 24) | \
|
||||||
|
((UInt32)((const Byte *)(p))[1] << 16) | \
|
||||||
|
((UInt32)((const Byte *)(p))[2] << 8) | \
|
||||||
|
((const Byte *)(p))[3] )
|
||||||
|
|
||||||
|
#define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4))
|
||||||
|
|
||||||
|
#define SetBe32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \
|
||||||
|
_ppp_[0] = (Byte)(_vvv_ >> 24); \
|
||||||
|
_ppp_[1] = (Byte)(_vvv_ >> 16); \
|
||||||
|
_ppp_[2] = (Byte)(_vvv_ >> 8); \
|
||||||
|
_ppp_[3] = (Byte)_vvv_; }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define GetBe16(p) ( (UInt16) ( \
|
||||||
|
((UInt16)((const Byte *)(p))[0] << 8) | \
|
||||||
|
((const Byte *)(p))[1] ))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef MY_CPU_X86_OR_AMD64
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt32 maxFunc;
|
||||||
|
UInt32 vendor[3];
|
||||||
|
UInt32 ver;
|
||||||
|
UInt32 b;
|
||||||
|
UInt32 c;
|
||||||
|
UInt32 d;
|
||||||
|
} Cx86cpuid;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
CPU_FIRM_INTEL,
|
||||||
|
CPU_FIRM_AMD,
|
||||||
|
CPU_FIRM_VIA
|
||||||
|
};
|
||||||
|
|
||||||
|
void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d);
|
||||||
|
|
||||||
|
Bool x86cpuid_CheckAndRead(Cx86cpuid *p);
|
||||||
|
int x86cpuid_GetFirm(const Cx86cpuid *p);
|
||||||
|
|
||||||
|
#define x86cpuid_GetFamily(ver) (((ver >> 16) & 0xFF0) | ((ver >> 8) & 0xF))
|
||||||
|
#define x86cpuid_GetModel(ver) (((ver >> 12) & 0xF0) | ((ver >> 4) & 0xF))
|
||||||
|
#define x86cpuid_GetStepping(ver) (ver & 0xF)
|
||||||
|
|
||||||
|
Bool CPU_Is_InOrder();
|
||||||
|
Bool CPU_Is_Aes_Supported();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,64 @@
|
||||||
|
/* Delta.c -- Delta converter
|
||||||
|
2009-05-26 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
|
#include "Delta.h"
|
||||||
|
|
||||||
|
void Delta_Init(Byte *state)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
for (i = 0; i < DELTA_STATE_SIZE; i++)
|
||||||
|
state[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MyMemCpy(Byte *dest, const Byte *src, unsigned size)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
dest[i] = src[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size)
|
||||||
|
{
|
||||||
|
Byte buf[DELTA_STATE_SIZE];
|
||||||
|
unsigned j = 0;
|
||||||
|
MyMemCpy(buf, state, delta);
|
||||||
|
{
|
||||||
|
SizeT i;
|
||||||
|
for (i = 0; i < size;)
|
||||||
|
{
|
||||||
|
for (j = 0; j < delta && i < size; i++, j++)
|
||||||
|
{
|
||||||
|
Byte b = data[i];
|
||||||
|
data[i] = (Byte)(b - buf[j]);
|
||||||
|
buf[j] = b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (j == delta)
|
||||||
|
j = 0;
|
||||||
|
MyMemCpy(state, buf + j, delta - j);
|
||||||
|
MyMemCpy(state + delta - j, buf, j);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size)
|
||||||
|
{
|
||||||
|
Byte buf[DELTA_STATE_SIZE];
|
||||||
|
unsigned j = 0;
|
||||||
|
MyMemCpy(buf, state, delta);
|
||||||
|
{
|
||||||
|
SizeT i;
|
||||||
|
for (i = 0; i < size;)
|
||||||
|
{
|
||||||
|
for (j = 0; j < delta && i < size; i++, j++)
|
||||||
|
{
|
||||||
|
buf[j] = data[i] = (Byte)(buf[j] + data[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (j == delta)
|
||||||
|
j = 0;
|
||||||
|
MyMemCpy(state, buf + j, delta - j);
|
||||||
|
MyMemCpy(state + delta - j, buf, j);
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
/* Delta.h -- Delta converter
|
||||||
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __DELTA_H
|
||||||
|
#define __DELTA_H
|
||||||
|
|
||||||
|
#include "7zTypes.h"
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
#define DELTA_STATE_SIZE 256
|
||||||
|
|
||||||
|
void Delta_Init(Byte *state);
|
||||||
|
void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size);
|
||||||
|
void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size);
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,117 @@
|
||||||
|
/* LzFind.h -- Match finder for LZ algorithms
|
||||||
|
2015-10-15 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __LZ_FIND_H
|
||||||
|
#define __LZ_FIND_H
|
||||||
|
|
||||||
|
#include "7zTypes.h"
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
typedef UInt32 CLzRef;
|
||||||
|
|
||||||
|
typedef struct _CMatchFinder
|
||||||
|
{
|
||||||
|
Byte *buffer;
|
||||||
|
UInt32 pos;
|
||||||
|
UInt32 posLimit;
|
||||||
|
UInt32 streamPos;
|
||||||
|
UInt32 lenLimit;
|
||||||
|
|
||||||
|
UInt32 cyclicBufferPos;
|
||||||
|
UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
|
||||||
|
|
||||||
|
Byte streamEndWasReached;
|
||||||
|
Byte btMode;
|
||||||
|
Byte bigHash;
|
||||||
|
Byte directInput;
|
||||||
|
|
||||||
|
UInt32 matchMaxLen;
|
||||||
|
CLzRef *hash;
|
||||||
|
CLzRef *son;
|
||||||
|
UInt32 hashMask;
|
||||||
|
UInt32 cutValue;
|
||||||
|
|
||||||
|
Byte *bufferBase;
|
||||||
|
ISeqInStream *stream;
|
||||||
|
|
||||||
|
UInt32 blockSize;
|
||||||
|
UInt32 keepSizeBefore;
|
||||||
|
UInt32 keepSizeAfter;
|
||||||
|
|
||||||
|
UInt32 numHashBytes;
|
||||||
|
size_t directInputRem;
|
||||||
|
UInt32 historySize;
|
||||||
|
UInt32 fixedHashSize;
|
||||||
|
UInt32 hashSizeSum;
|
||||||
|
SRes result;
|
||||||
|
UInt32 crc[256];
|
||||||
|
size_t numRefs;
|
||||||
|
} CMatchFinder;
|
||||||
|
|
||||||
|
#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
|
||||||
|
|
||||||
|
#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
|
||||||
|
|
||||||
|
#define Inline_MatchFinder_IsFinishedOK(p) \
|
||||||
|
((p)->streamEndWasReached \
|
||||||
|
&& (p)->streamPos == (p)->pos \
|
||||||
|
&& (!(p)->directInput || (p)->directInputRem == 0))
|
||||||
|
|
||||||
|
int MatchFinder_NeedMove(CMatchFinder *p);
|
||||||
|
Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
|
||||||
|
void MatchFinder_MoveBlock(CMatchFinder *p);
|
||||||
|
void MatchFinder_ReadIfRequired(CMatchFinder *p);
|
||||||
|
|
||||||
|
void MatchFinder_Construct(CMatchFinder *p);
|
||||||
|
|
||||||
|
/* Conditions:
|
||||||
|
historySize <= 3 GB
|
||||||
|
keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
|
||||||
|
*/
|
||||||
|
int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
|
||||||
|
UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
|
||||||
|
ISzAlloc *alloc);
|
||||||
|
void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
|
||||||
|
void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems);
|
||||||
|
void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
|
||||||
|
|
||||||
|
UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
|
||||||
|
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
|
||||||
|
UInt32 *distances, UInt32 maxLen);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Conditions:
|
||||||
|
Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
|
||||||
|
Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef void (*Mf_Init_Func)(void *object);
|
||||||
|
typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);
|
||||||
|
typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);
|
||||||
|
typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);
|
||||||
|
typedef void (*Mf_Skip_Func)(void *object, UInt32);
|
||||||
|
|
||||||
|
typedef struct _IMatchFinder
|
||||||
|
{
|
||||||
|
Mf_Init_Func Init;
|
||||||
|
Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;
|
||||||
|
Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;
|
||||||
|
Mf_GetMatches_Func GetMatches;
|
||||||
|
Mf_Skip_Func Skip;
|
||||||
|
} IMatchFinder;
|
||||||
|
|
||||||
|
void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
|
||||||
|
|
||||||
|
void MatchFinder_Init_2(CMatchFinder *p, int readData);
|
||||||
|
void MatchFinder_Init(CMatchFinder *p);
|
||||||
|
|
||||||
|
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
|
||||||
|
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
|
||||||
|
|
||||||
|
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
|
||||||
|
void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,57 @@
|
||||||
|
/* LzHash.h -- HASH functions for LZ algorithms
|
||||||
|
2015-04-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __LZ_HASH_H
|
||||||
|
#define __LZ_HASH_H
|
||||||
|
|
||||||
|
#define kHash2Size (1 << 10)
|
||||||
|
#define kHash3Size (1 << 16)
|
||||||
|
#define kHash4Size (1 << 20)
|
||||||
|
|
||||||
|
#define kFix3HashSize (kHash2Size)
|
||||||
|
#define kFix4HashSize (kHash2Size + kHash3Size)
|
||||||
|
#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)
|
||||||
|
|
||||||
|
#define HASH2_CALC hv = cur[0] | ((UInt32)cur[1] << 8);
|
||||||
|
|
||||||
|
#define HASH3_CALC { \
|
||||||
|
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
|
||||||
|
h2 = temp & (kHash2Size - 1); \
|
||||||
|
hv = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; }
|
||||||
|
|
||||||
|
#define HASH4_CALC { \
|
||||||
|
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
|
||||||
|
h2 = temp & (kHash2Size - 1); \
|
||||||
|
temp ^= ((UInt32)cur[2] << 8); \
|
||||||
|
h3 = temp & (kHash3Size - 1); \
|
||||||
|
hv = (temp ^ (p->crc[cur[3]] << 5)) & p->hashMask; }
|
||||||
|
|
||||||
|
#define HASH5_CALC { \
|
||||||
|
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
|
||||||
|
h2 = temp & (kHash2Size - 1); \
|
||||||
|
temp ^= ((UInt32)cur[2] << 8); \
|
||||||
|
h3 = temp & (kHash3Size - 1); \
|
||||||
|
temp ^= (p->crc[cur[3]] << 5); \
|
||||||
|
h4 = temp & (kHash4Size - 1); \
|
||||||
|
hv = (temp ^ (p->crc[cur[4]] << 3)) & p->hashMask; }
|
||||||
|
|
||||||
|
/* #define HASH_ZIP_CALC hv = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */
|
||||||
|
#define HASH_ZIP_CALC hv = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;
|
||||||
|
|
||||||
|
|
||||||
|
#define MT_HASH2_CALC \
|
||||||
|
h2 = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1);
|
||||||
|
|
||||||
|
#define MT_HASH3_CALC { \
|
||||||
|
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
|
||||||
|
h2 = temp & (kHash2Size - 1); \
|
||||||
|
h3 = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); }
|
||||||
|
|
||||||
|
#define MT_HASH4_CALC { \
|
||||||
|
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
|
||||||
|
h2 = temp & (kHash2Size - 1); \
|
||||||
|
temp ^= ((UInt32)cur[2] << 8); \
|
||||||
|
h3 = temp & (kHash3Size - 1); \
|
||||||
|
h4 = (temp ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); }
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,111 @@
|
||||||
|
/* Lzma86.h -- LZMA + x86 (BCJ) Filter
|
||||||
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __LZMA86_H
|
||||||
|
#define __LZMA86_H
|
||||||
|
|
||||||
|
#include "7zTypes.h"
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
#define LZMA86_SIZE_OFFSET (1 + 5)
|
||||||
|
#define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8)
|
||||||
|
|
||||||
|
/*
|
||||||
|
It's an example for LZMA + x86 Filter use.
|
||||||
|
You can use .lzma86 extension, if you write that stream to file.
|
||||||
|
.lzma86 header adds one additional byte to standard .lzma header.
|
||||||
|
.lzma86 header (14 bytes):
|
||||||
|
Offset Size Description
|
||||||
|
0 1 = 0 - no filter, pure LZMA
|
||||||
|
= 1 - x86 filter + LZMA
|
||||||
|
1 1 lc, lp and pb in encoded form
|
||||||
|
2 4 dictSize (little endian)
|
||||||
|
6 8 uncompressed size (little endian)
|
||||||
|
|
||||||
|
|
||||||
|
Lzma86_Encode
|
||||||
|
-------------
|
||||||
|
level - compression level: 0 <= level <= 9, the default value for "level" is 5.
|
||||||
|
|
||||||
|
dictSize - The dictionary size in bytes. The maximum value is
|
||||||
|
128 MB = (1 << 27) bytes for 32-bit version
|
||||||
|
1 GB = (1 << 30) bytes for 64-bit version
|
||||||
|
The default value is 16 MB = (1 << 24) bytes, for level = 5.
|
||||||
|
It's recommended to use the dictionary that is larger than 4 KB and
|
||||||
|
that can be calculated as (1 << N) or (3 << N) sizes.
|
||||||
|
For better compression ratio dictSize must be >= inSize.
|
||||||
|
|
||||||
|
filterMode:
|
||||||
|
SZ_FILTER_NO - no Filter
|
||||||
|
SZ_FILTER_YES - x86 Filter
|
||||||
|
SZ_FILTER_AUTO - it tries both alternatives to select best.
|
||||||
|
Encoder will use 2 or 3 passes:
|
||||||
|
2 passes when FILTER_NO provides better compression.
|
||||||
|
3 passes when FILTER_YES provides better compression.
|
||||||
|
|
||||||
|
Lzma86Encode allocates Data with MyAlloc functions.
|
||||||
|
RAM Requirements for compressing:
|
||||||
|
RamSize = dictionarySize * 11.5 + 6MB + FilterBlockSize
|
||||||
|
filterMode FilterBlockSize
|
||||||
|
SZ_FILTER_NO 0
|
||||||
|
SZ_FILTER_YES inSize
|
||||||
|
SZ_FILTER_AUTO inSize
|
||||||
|
|
||||||
|
|
||||||
|
Return code:
|
||||||
|
SZ_OK - OK
|
||||||
|
SZ_ERROR_MEM - Memory allocation error
|
||||||
|
SZ_ERROR_PARAM - Incorrect paramater
|
||||||
|
SZ_ERROR_OUTPUT_EOF - output buffer overflow
|
||||||
|
SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum ESzFilterMode
|
||||||
|
{
|
||||||
|
SZ_FILTER_NO,
|
||||||
|
SZ_FILTER_YES,
|
||||||
|
SZ_FILTER_AUTO
|
||||||
|
};
|
||||||
|
|
||||||
|
SRes Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
|
||||||
|
int level, UInt32 dictSize, int filterMode);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Lzma86_GetUnpackSize:
|
||||||
|
In:
|
||||||
|
src - input data
|
||||||
|
srcLen - input data size
|
||||||
|
Out:
|
||||||
|
unpackSize - size of uncompressed stream
|
||||||
|
Return code:
|
||||||
|
SZ_OK - OK
|
||||||
|
SZ_ERROR_INPUT_EOF - Error in headers
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Lzma86_Decode:
|
||||||
|
In:
|
||||||
|
dest - output data
|
||||||
|
destLen - output data size
|
||||||
|
src - input data
|
||||||
|
srcLen - input data size
|
||||||
|
Out:
|
||||||
|
destLen - processed output size
|
||||||
|
srcLen - processed input size
|
||||||
|
Return code:
|
||||||
|
SZ_OK - OK
|
||||||
|
SZ_ERROR_DATA - Data error
|
||||||
|
SZ_ERROR_MEM - Memory allocation error
|
||||||
|
SZ_ERROR_UNSUPPORTED - unsupported file
|
||||||
|
SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen);
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,54 @@
|
||||||
|
/* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder
|
||||||
|
2016-05-16 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
|
#include "Lzma86.h"
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
|
#include "Bra.h"
|
||||||
|
#include "LzmaDec.h"
|
||||||
|
|
||||||
|
SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
if (srcLen < LZMA86_HEADER_SIZE)
|
||||||
|
return SZ_ERROR_INPUT_EOF;
|
||||||
|
*unpackSize = 0;
|
||||||
|
for (i = 0; i < sizeof(UInt64); i++)
|
||||||
|
*unpackSize += ((UInt64)src[LZMA86_SIZE_OFFSET + i]) << (8 * i);
|
||||||
|
return SZ_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen)
|
||||||
|
{
|
||||||
|
SRes res;
|
||||||
|
int useFilter;
|
||||||
|
SizeT inSizePure;
|
||||||
|
ELzmaStatus status;
|
||||||
|
|
||||||
|
if (*srcLen < LZMA86_HEADER_SIZE)
|
||||||
|
return SZ_ERROR_INPUT_EOF;
|
||||||
|
|
||||||
|
useFilter = src[0];
|
||||||
|
|
||||||
|
if (useFilter > 1)
|
||||||
|
{
|
||||||
|
*destLen = 0;
|
||||||
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
inSizePure = *srcLen - LZMA86_HEADER_SIZE;
|
||||||
|
res = LzmaDecode(dest, destLen, src + LZMA86_HEADER_SIZE, &inSizePure,
|
||||||
|
src + 1, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &status, &g_Alloc);
|
||||||
|
*srcLen = inSizePure + LZMA86_HEADER_SIZE;
|
||||||
|
if (res != SZ_OK)
|
||||||
|
return res;
|
||||||
|
if (useFilter == 1)
|
||||||
|
{
|
||||||
|
UInt32 x86State;
|
||||||
|
x86_Convert_Init(x86State);
|
||||||
|
x86_Convert(dest, *destLen, 0, &x86State, 0);
|
||||||
|
}
|
||||||
|
return SZ_OK;
|
||||||
|
}
|
|
@ -0,0 +1,106 @@
|
||||||
|
/* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder
|
||||||
|
2016-05-16 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "Lzma86.h"
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
|
#include "Bra.h"
|
||||||
|
#include "LzmaEnc.h"
|
||||||
|
|
||||||
|
#define SZE_OUT_OVERFLOW SZE_DATA_ERROR
|
||||||
|
|
||||||
|
int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
|
||||||
|
int level, UInt32 dictSize, int filterMode)
|
||||||
|
{
|
||||||
|
size_t outSize2 = *destLen;
|
||||||
|
Byte *filteredStream;
|
||||||
|
Bool useFilter;
|
||||||
|
int mainResult = SZ_ERROR_OUTPUT_EOF;
|
||||||
|
CLzmaEncProps props;
|
||||||
|
LzmaEncProps_Init(&props);
|
||||||
|
props.level = level;
|
||||||
|
props.dictSize = dictSize;
|
||||||
|
|
||||||
|
*destLen = 0;
|
||||||
|
if (outSize2 < LZMA86_HEADER_SIZE)
|
||||||
|
return SZ_ERROR_OUTPUT_EOF;
|
||||||
|
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
UInt64 t = srcLen;
|
||||||
|
for (i = 0; i < 8; i++, t >>= 8)
|
||||||
|
dest[LZMA86_SIZE_OFFSET + i] = (Byte)t;
|
||||||
|
}
|
||||||
|
|
||||||
|
filteredStream = 0;
|
||||||
|
useFilter = (filterMode != SZ_FILTER_NO);
|
||||||
|
if (useFilter)
|
||||||
|
{
|
||||||
|
if (srcLen != 0)
|
||||||
|
{
|
||||||
|
filteredStream = (Byte *)MyAlloc(srcLen);
|
||||||
|
if (filteredStream == 0)
|
||||||
|
return SZ_ERROR_MEM;
|
||||||
|
memcpy(filteredStream, src, srcLen);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
UInt32 x86State;
|
||||||
|
x86_Convert_Init(x86State);
|
||||||
|
x86_Convert(filteredStream, srcLen, 0, &x86State, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
size_t minSize = 0;
|
||||||
|
Bool bestIsFiltered = False;
|
||||||
|
|
||||||
|
/* passes for SZ_FILTER_AUTO:
|
||||||
|
0 - BCJ + LZMA
|
||||||
|
1 - LZMA
|
||||||
|
2 - BCJ + LZMA agaian, if pass 0 (BCJ + LZMA) is better.
|
||||||
|
*/
|
||||||
|
int numPasses = (filterMode == SZ_FILTER_AUTO) ? 3 : 1;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < numPasses; i++)
|
||||||
|
{
|
||||||
|
size_t outSizeProcessed = outSize2 - LZMA86_HEADER_SIZE;
|
||||||
|
size_t outPropsSize = 5;
|
||||||
|
SRes curRes;
|
||||||
|
Bool curModeIsFiltered = (numPasses > 1 && i == numPasses - 1);
|
||||||
|
if (curModeIsFiltered && !bestIsFiltered)
|
||||||
|
break;
|
||||||
|
if (useFilter && i == 0)
|
||||||
|
curModeIsFiltered = True;
|
||||||
|
|
||||||
|
curRes = LzmaEncode(dest + LZMA86_HEADER_SIZE, &outSizeProcessed,
|
||||||
|
curModeIsFiltered ? filteredStream : src, srcLen,
|
||||||
|
&props, dest + 1, &outPropsSize, 0,
|
||||||
|
NULL, &g_Alloc, &g_Alloc);
|
||||||
|
|
||||||
|
if (curRes != SZ_ERROR_OUTPUT_EOF)
|
||||||
|
{
|
||||||
|
if (curRes != SZ_OK)
|
||||||
|
{
|
||||||
|
mainResult = curRes;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (outSizeProcessed <= minSize || mainResult != SZ_OK)
|
||||||
|
{
|
||||||
|
minSize = outSizeProcessed;
|
||||||
|
bestIsFiltered = curModeIsFiltered;
|
||||||
|
mainResult = SZ_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dest[0] = (Byte)(bestIsFiltered ? 1 : 0);
|
||||||
|
*destLen = LZMA86_HEADER_SIZE + minSize;
|
||||||
|
}
|
||||||
|
if (useFilter)
|
||||||
|
MyFree(filteredStream);
|
||||||
|
return mainResult;
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,227 @@
|
||||||
|
/* LzmaDec.h -- LZMA Decoder
|
||||||
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __LZMA_DEC_H
|
||||||
|
#define __LZMA_DEC_H
|
||||||
|
|
||||||
|
#include "7zTypes.h"
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
/* #define _LZMA_PROB32 */
|
||||||
|
/* _LZMA_PROB32 can increase the speed on some CPUs,
|
||||||
|
but memory usage for CLzmaDec::probs will be doubled in that case */
|
||||||
|
|
||||||
|
#ifdef _LZMA_PROB32
|
||||||
|
#define CLzmaProb UInt32
|
||||||
|
#else
|
||||||
|
#define CLzmaProb UInt16
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- LZMA Properties ---------- */
|
||||||
|
|
||||||
|
#define LZMA_PROPS_SIZE 5
|
||||||
|
|
||||||
|
typedef struct _CLzmaProps
|
||||||
|
{
|
||||||
|
unsigned lc, lp, pb;
|
||||||
|
UInt32 dicSize;
|
||||||
|
} CLzmaProps;
|
||||||
|
|
||||||
|
/* LzmaProps_Decode - decodes properties
|
||||||
|
Returns:
|
||||||
|
SZ_OK
|
||||||
|
SZ_ERROR_UNSUPPORTED - Unsupported properties
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- LZMA Decoder state ---------- */
|
||||||
|
|
||||||
|
/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case.
|
||||||
|
Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */
|
||||||
|
|
||||||
|
#define LZMA_REQUIRED_INPUT_MAX 20
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
CLzmaProps prop;
|
||||||
|
CLzmaProb *probs;
|
||||||
|
Byte *dic;
|
||||||
|
const Byte *buf;
|
||||||
|
UInt32 range, code;
|
||||||
|
SizeT dicPos;
|
||||||
|
SizeT dicBufSize;
|
||||||
|
UInt32 processedPos;
|
||||||
|
UInt32 checkDicSize;
|
||||||
|
unsigned state;
|
||||||
|
UInt32 reps[4];
|
||||||
|
unsigned remainLen;
|
||||||
|
int needFlush;
|
||||||
|
int needInitState;
|
||||||
|
UInt32 numProbs;
|
||||||
|
unsigned tempBufSize;
|
||||||
|
Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];
|
||||||
|
} CLzmaDec;
|
||||||
|
|
||||||
|
#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; }
|
||||||
|
|
||||||
|
void LzmaDec_Init(CLzmaDec *p);
|
||||||
|
|
||||||
|
/* There are two types of LZMA streams:
|
||||||
|
0) Stream with end mark. That end mark adds about 6 bytes to compressed size.
|
||||||
|
1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
LZMA_FINISH_ANY, /* finish at any point */
|
||||||
|
LZMA_FINISH_END /* block must be finished at the end */
|
||||||
|
} ELzmaFinishMode;
|
||||||
|
|
||||||
|
/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!!
|
||||||
|
|
||||||
|
You must use LZMA_FINISH_END, when you know that current output buffer
|
||||||
|
covers last bytes of block. In other cases you must use LZMA_FINISH_ANY.
|
||||||
|
|
||||||
|
If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK,
|
||||||
|
and output value of destLen will be less than output buffer size limit.
|
||||||
|
You can check status result also.
|
||||||
|
|
||||||
|
You can use multiple checks to test data integrity after full decompression:
|
||||||
|
1) Check Result and "status" variable.
|
||||||
|
2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.
|
||||||
|
3) Check that output(srcLen) = compressedSize, if you know real compressedSize.
|
||||||
|
You must use correct finish mode in that case. */
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */
|
||||||
|
LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */
|
||||||
|
LZMA_STATUS_NOT_FINISHED, /* stream was not finished */
|
||||||
|
LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */
|
||||||
|
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */
|
||||||
|
} ELzmaStatus;
|
||||||
|
|
||||||
|
/* ELzmaStatus is used only as output value for function call */
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- Interfaces ---------- */
|
||||||
|
|
||||||
|
/* There are 3 levels of interfaces:
|
||||||
|
1) Dictionary Interface
|
||||||
|
2) Buffer Interface
|
||||||
|
3) One Call Interface
|
||||||
|
You can select any of these interfaces, but don't mix functions from different
|
||||||
|
groups for same object. */
|
||||||
|
|
||||||
|
|
||||||
|
/* There are two variants to allocate state for Dictionary Interface:
|
||||||
|
1) LzmaDec_Allocate / LzmaDec_Free
|
||||||
|
2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs
|
||||||
|
You can use variant 2, if you set dictionary buffer manually.
|
||||||
|
For Buffer Interface you must always use variant 1.
|
||||||
|
|
||||||
|
LzmaDec_Allocate* can return:
|
||||||
|
SZ_OK
|
||||||
|
SZ_ERROR_MEM - Memory allocation error
|
||||||
|
SZ_ERROR_UNSUPPORTED - Unsupported properties
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc);
|
||||||
|
void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc);
|
||||||
|
|
||||||
|
SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc);
|
||||||
|
void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc);
|
||||||
|
|
||||||
|
/* ---------- Dictionary Interface ---------- */
|
||||||
|
|
||||||
|
/* You can use it, if you want to eliminate the overhead for data copying from
|
||||||
|
dictionary to some other external buffer.
|
||||||
|
You must work with CLzmaDec variables directly in this interface.
|
||||||
|
|
||||||
|
STEPS:
|
||||||
|
LzmaDec_Constr()
|
||||||
|
LzmaDec_Allocate()
|
||||||
|
for (each new stream)
|
||||||
|
{
|
||||||
|
LzmaDec_Init()
|
||||||
|
while (it needs more decompression)
|
||||||
|
{
|
||||||
|
LzmaDec_DecodeToDic()
|
||||||
|
use data from CLzmaDec::dic and update CLzmaDec::dicPos
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LzmaDec_Free()
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* LzmaDec_DecodeToDic
|
||||||
|
|
||||||
|
The decoding to internal dictionary buffer (CLzmaDec::dic).
|
||||||
|
You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!
|
||||||
|
|
||||||
|
finishMode:
|
||||||
|
It has meaning only if the decoding reaches output limit (dicLimit).
|
||||||
|
LZMA_FINISH_ANY - Decode just dicLimit bytes.
|
||||||
|
LZMA_FINISH_END - Stream must be finished after dicLimit.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
SZ_OK
|
||||||
|
status:
|
||||||
|
LZMA_STATUS_FINISHED_WITH_MARK
|
||||||
|
LZMA_STATUS_NOT_FINISHED
|
||||||
|
LZMA_STATUS_NEEDS_MORE_INPUT
|
||||||
|
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
|
||||||
|
SZ_ERROR_DATA - Data error
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,
|
||||||
|
const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- Buffer Interface ---------- */
|
||||||
|
|
||||||
|
/* It's zlib-like interface.
|
||||||
|
See LzmaDec_DecodeToDic description for information about STEPS and return results,
|
||||||
|
but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need
|
||||||
|
to work with CLzmaDec variables manually.
|
||||||
|
|
||||||
|
finishMode:
|
||||||
|
It has meaning only if the decoding reaches output limit (*destLen).
|
||||||
|
LZMA_FINISH_ANY - Decode just destLen bytes.
|
||||||
|
LZMA_FINISH_END - Stream must be finished after (*destLen).
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,
|
||||||
|
const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- One Call Interface ---------- */
|
||||||
|
|
||||||
|
/* LzmaDecode
|
||||||
|
|
||||||
|
finishMode:
|
||||||
|
It has meaning only if the decoding reaches output limit (*destLen).
|
||||||
|
LZMA_FINISH_ANY - Decode just destLen bytes.
|
||||||
|
LZMA_FINISH_END - Stream must be finished after (*destLen).
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
SZ_OK
|
||||||
|
status:
|
||||||
|
LZMA_STATUS_FINISHED_WITH_MARK
|
||||||
|
LZMA_STATUS_NOT_FINISHED
|
||||||
|
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
|
||||||
|
SZ_ERROR_DATA - Data error
|
||||||
|
SZ_ERROR_MEM - Memory allocation error
|
||||||
|
SZ_ERROR_UNSUPPORTED - Unsupported properties
|
||||||
|
SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
||||||
|
const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
|
||||||
|
ELzmaStatus *status, ISzAlloc *alloc);
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,78 @@
|
||||||
|
/* LzmaEnc.h -- LZMA Encoder
|
||||||
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __LZMA_ENC_H
|
||||||
|
#define __LZMA_ENC_H
|
||||||
|
|
||||||
|
#include "7zTypes.h"
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
#define LZMA_PROPS_SIZE 5
|
||||||
|
|
||||||
|
typedef struct _CLzmaEncProps
|
||||||
|
{
|
||||||
|
int level; /* 0 <= level <= 9 */
|
||||||
|
UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
|
||||||
|
(1 << 12) <= dictSize <= (1 << 30) for 64-bit version
|
||||||
|
default = (1 << 24) */
|
||||||
|
UInt64 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 lp; /* 0 <= lp <= 4, default = 0 */
|
||||||
|
int pb; /* 0 <= pb <= 4, default = 2 */
|
||||||
|
int algo; /* 0 - fast, 1 - normal, default = 1 */
|
||||||
|
int fb; /* 5 <= fb <= 273, default = 32 */
|
||||||
|
int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
|
||||||
|
int numHashBytes; /* 2, 3 or 4, default = 4 */
|
||||||
|
UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */
|
||||||
|
unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
|
||||||
|
int numThreads; /* 1 or 2, default = 2 */
|
||||||
|
} CLzmaEncProps;
|
||||||
|
|
||||||
|
void LzmaEncProps_Init(CLzmaEncProps *p);
|
||||||
|
void LzmaEncProps_Normalize(CLzmaEncProps *p);
|
||||||
|
UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- CLzmaEncHandle Interface ---------- */
|
||||||
|
|
||||||
|
/* LzmaEnc_* functions can return the following exit codes:
|
||||||
|
Returns:
|
||||||
|
SZ_OK - OK
|
||||||
|
SZ_ERROR_MEM - Memory allocation error
|
||||||
|
SZ_ERROR_PARAM - Incorrect paramater in props
|
||||||
|
SZ_ERROR_WRITE - Write callback error.
|
||||||
|
SZ_ERROR_PROGRESS - some break from progress callback
|
||||||
|
SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef void * CLzmaEncHandle;
|
||||||
|
|
||||||
|
CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc);
|
||||||
|
void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
|
||||||
|
SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
|
||||||
|
SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
|
||||||
|
SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
|
||||||
|
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
|
||||||
|
SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
||||||
|
int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
|
||||||
|
|
||||||
|
/* ---------- One Call Interface ---------- */
|
||||||
|
|
||||||
|
/* LzmaEncode
|
||||||
|
Return code:
|
||||||
|
SZ_OK - OK
|
||||||
|
SZ_ERROR_MEM - Memory allocation error
|
||||||
|
SZ_ERROR_PARAM - Incorrect paramater
|
||||||
|
SZ_ERROR_OUTPUT_EOF - output buffer overflow
|
||||||
|
SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
||||||
|
const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
|
||||||
|
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,40 @@
|
||||||
|
/* LzmaLib.c -- LZMA library wrapper
|
||||||
|
2015-06-13 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
|
#include "LzmaDec.h"
|
||||||
|
#include "LzmaEnc.h"
|
||||||
|
#include "LzmaLib.h"
|
||||||
|
|
||||||
|
MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen,
|
||||||
|
unsigned char *outProps, size_t *outPropsSize,
|
||||||
|
int level, /* 0 <= level <= 9, default = 5 */
|
||||||
|
unsigned dictSize, /* use (1 << N) or (3 << N). 4 KB < dictSize <= 128 MB */
|
||||||
|
int lc, /* 0 <= lc <= 8, default = 3 */
|
||||||
|
int lp, /* 0 <= lp <= 4, default = 0 */
|
||||||
|
int pb, /* 0 <= pb <= 4, default = 2 */
|
||||||
|
int fb, /* 5 <= fb <= 273, default = 32 */
|
||||||
|
int numThreads /* 1 or 2, default = 2 */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
CLzmaEncProps props;
|
||||||
|
LzmaEncProps_Init(&props);
|
||||||
|
props.level = level;
|
||||||
|
props.dictSize = dictSize;
|
||||||
|
props.lc = lc;
|
||||||
|
props.lp = lp;
|
||||||
|
props.pb = pb;
|
||||||
|
props.fb = fb;
|
||||||
|
props.numThreads = numThreads;
|
||||||
|
|
||||||
|
return LzmaEncode(dest, destLen, src, srcLen, &props, outProps, outPropsSize, 0,
|
||||||
|
NULL, &g_Alloc, &g_Alloc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t *srcLen,
|
||||||
|
const unsigned char *props, size_t propsSize)
|
||||||
|
{
|
||||||
|
ELzmaStatus status;
|
||||||
|
return LzmaDecode(dest, destLen, src, srcLen, props, (unsigned)propsSize, LZMA_FINISH_ANY, &status, &g_Alloc);
|
||||||
|
}
|
|
@ -0,0 +1,131 @@
|
||||||
|
/* LzmaLib.h -- LZMA library interface
|
||||||
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __LZMA_LIB_H
|
||||||
|
#define __LZMA_LIB_H
|
||||||
|
|
||||||
|
#include "7zTypes.h"
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
#define MY_STDAPI int MY_STD_CALL
|
||||||
|
|
||||||
|
#define LZMA_PROPS_SIZE 5
|
||||||
|
|
||||||
|
/*
|
||||||
|
RAM requirements for LZMA:
|
||||||
|
for compression: (dictSize * 11.5 + 6 MB) + state_size
|
||||||
|
for decompression: dictSize + state_size
|
||||||
|
state_size = (4 + (1.5 << (lc + lp))) KB
|
||||||
|
by default (lc=3, lp=0), state_size = 16 KB.
|
||||||
|
|
||||||
|
LZMA properties (5 bytes) format
|
||||||
|
Offset Size Description
|
||||||
|
0 1 lc, lp and pb in encoded form.
|
||||||
|
1 4 dictSize (little endian).
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
LzmaCompress
|
||||||
|
------------
|
||||||
|
|
||||||
|
outPropsSize -
|
||||||
|
In: the pointer to the size of outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5.
|
||||||
|
Out: the pointer to the size of written properties in outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5.
|
||||||
|
|
||||||
|
LZMA Encoder will use defult values for any parameter, if it is
|
||||||
|
-1 for any from: level, loc, lp, pb, fb, numThreads
|
||||||
|
0 for dictSize
|
||||||
|
|
||||||
|
level - compression level: 0 <= level <= 9;
|
||||||
|
|
||||||
|
level dictSize algo fb
|
||||||
|
0: 16 KB 0 32
|
||||||
|
1: 64 KB 0 32
|
||||||
|
2: 256 KB 0 32
|
||||||
|
3: 1 MB 0 32
|
||||||
|
4: 4 MB 0 32
|
||||||
|
5: 16 MB 1 32
|
||||||
|
6: 32 MB 1 32
|
||||||
|
7+: 64 MB 1 64
|
||||||
|
|
||||||
|
The default value for "level" is 5.
|
||||||
|
|
||||||
|
algo = 0 means fast method
|
||||||
|
algo = 1 means normal method
|
||||||
|
|
||||||
|
dictSize - The dictionary size in bytes. The maximum value is
|
||||||
|
128 MB = (1 << 27) bytes for 32-bit version
|
||||||
|
1 GB = (1 << 30) bytes for 64-bit version
|
||||||
|
The default value is 16 MB = (1 << 24) bytes.
|
||||||
|
It's recommended to use the dictionary that is larger than 4 KB and
|
||||||
|
that can be calculated as (1 << N) or (3 << N) sizes.
|
||||||
|
|
||||||
|
lc - The number of literal context bits (high bits of previous literal).
|
||||||
|
It can be in the range from 0 to 8. The default value is 3.
|
||||||
|
Sometimes lc=4 gives the gain for big files.
|
||||||
|
|
||||||
|
lp - The number of literal pos bits (low bits of current position for literals).
|
||||||
|
It can be in the range from 0 to 4. The default value is 0.
|
||||||
|
The lp switch is intended for periodical data when the period is equal to 2^lp.
|
||||||
|
For example, for 32-bit (4 bytes) periodical data you can use lp=2. Often it's
|
||||||
|
better to set lc=0, if you change lp switch.
|
||||||
|
|
||||||
|
pb - The number of pos bits (low bits of current position).
|
||||||
|
It can be in the range from 0 to 4. The default value is 2.
|
||||||
|
The pb switch is intended for periodical data when the period is equal 2^pb.
|
||||||
|
|
||||||
|
fb - Word size (the number of fast bytes).
|
||||||
|
It can be in the range from 5 to 273. The default value is 32.
|
||||||
|
Usually, a big number gives a little bit better compression ratio and
|
||||||
|
slower compression process.
|
||||||
|
|
||||||
|
numThreads - The number of thereads. 1 or 2. The default value is 2.
|
||||||
|
Fast mode (algo = 0) can use only 1 thread.
|
||||||
|
|
||||||
|
Out:
|
||||||
|
destLen - processed output size
|
||||||
|
Returns:
|
||||||
|
SZ_OK - OK
|
||||||
|
SZ_ERROR_MEM - Memory allocation error
|
||||||
|
SZ_ERROR_PARAM - Incorrect paramater
|
||||||
|
SZ_ERROR_OUTPUT_EOF - output buffer overflow
|
||||||
|
SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
|
||||||
|
*/
|
||||||
|
|
||||||
|
MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen,
|
||||||
|
unsigned char *outProps, size_t *outPropsSize, /* *outPropsSize must be = 5 */
|
||||||
|
int level, /* 0 <= level <= 9, default = 5 */
|
||||||
|
unsigned dictSize, /* default = (1 << 24) */
|
||||||
|
int lc, /* 0 <= lc <= 8, default = 3 */
|
||||||
|
int lp, /* 0 <= lp <= 4, default = 0 */
|
||||||
|
int pb, /* 0 <= pb <= 4, default = 2 */
|
||||||
|
int fb, /* 5 <= fb <= 273, default = 32 */
|
||||||
|
int numThreads /* 1 or 2, default = 2 */
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
LzmaUncompress
|
||||||
|
--------------
|
||||||
|
In:
|
||||||
|
dest - output data
|
||||||
|
destLen - output data size
|
||||||
|
src - input data
|
||||||
|
srcLen - input data size
|
||||||
|
Out:
|
||||||
|
destLen - processed output size
|
||||||
|
srcLen - processed input size
|
||||||
|
Returns:
|
||||||
|
SZ_OK - OK
|
||||||
|
SZ_ERROR_DATA - Data error
|
||||||
|
SZ_ERROR_MEM - Memory allocation arror
|
||||||
|
SZ_ERROR_UNSUPPORTED - Unsupported properties
|
||||||
|
SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer (src)
|
||||||
|
*/
|
||||||
|
|
||||||
|
MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, SizeT *srcLen,
|
||||||
|
const unsigned char *props, size_t propsSize);
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,10 @@
|
||||||
|
/* Precomp.h -- StdAfx
|
||||||
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __7Z_PRECOMP_H
|
||||||
|
#define __7Z_PRECOMP_H
|
||||||
|
|
||||||
|
#include "Compiler.h"
|
||||||
|
/* #include "7zTypes.h" */
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,141 @@
|
||||||
|
/* Sort.c -- Sort functions
|
||||||
|
2014-04-05 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
|
#include "Sort.h"
|
||||||
|
|
||||||
|
#define HeapSortDown(p, k, size, temp) \
|
||||||
|
{ for (;;) { \
|
||||||
|
size_t s = (k << 1); \
|
||||||
|
if (s > size) break; \
|
||||||
|
if (s < size && p[s + 1] > p[s]) s++; \
|
||||||
|
if (temp >= p[s]) break; \
|
||||||
|
p[k] = p[s]; k = s; \
|
||||||
|
} p[k] = temp; }
|
||||||
|
|
||||||
|
void HeapSort(UInt32 *p, size_t size)
|
||||||
|
{
|
||||||
|
if (size <= 1)
|
||||||
|
return;
|
||||||
|
p--;
|
||||||
|
{
|
||||||
|
size_t i = size / 2;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
UInt32 temp = p[i];
|
||||||
|
size_t k = i;
|
||||||
|
HeapSortDown(p, k, size, temp)
|
||||||
|
}
|
||||||
|
while (--i != 0);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
do
|
||||||
|
{
|
||||||
|
size_t k = 1;
|
||||||
|
UInt32 temp = p[size];
|
||||||
|
p[size--] = p[1];
|
||||||
|
HeapSortDown(p, k, size, temp)
|
||||||
|
}
|
||||||
|
while (size > 1);
|
||||||
|
*/
|
||||||
|
while (size > 3)
|
||||||
|
{
|
||||||
|
UInt32 temp = p[size];
|
||||||
|
size_t k = (p[3] > p[2]) ? 3 : 2;
|
||||||
|
p[size--] = p[1];
|
||||||
|
p[1] = p[k];
|
||||||
|
HeapSortDown(p, k, size, temp)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
UInt32 temp = p[size];
|
||||||
|
p[size] = p[1];
|
||||||
|
if (size > 2 && p[2] < temp)
|
||||||
|
{
|
||||||
|
p[1] = p[2];
|
||||||
|
p[2] = temp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
p[1] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HeapSort64(UInt64 *p, size_t size)
|
||||||
|
{
|
||||||
|
if (size <= 1)
|
||||||
|
return;
|
||||||
|
p--;
|
||||||
|
{
|
||||||
|
size_t i = size / 2;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
UInt64 temp = p[i];
|
||||||
|
size_t k = i;
|
||||||
|
HeapSortDown(p, k, size, temp)
|
||||||
|
}
|
||||||
|
while (--i != 0);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
do
|
||||||
|
{
|
||||||
|
size_t k = 1;
|
||||||
|
UInt64 temp = p[size];
|
||||||
|
p[size--] = p[1];
|
||||||
|
HeapSortDown(p, k, size, temp)
|
||||||
|
}
|
||||||
|
while (size > 1);
|
||||||
|
*/
|
||||||
|
while (size > 3)
|
||||||
|
{
|
||||||
|
UInt64 temp = p[size];
|
||||||
|
size_t k = (p[3] > p[2]) ? 3 : 2;
|
||||||
|
p[size--] = p[1];
|
||||||
|
p[1] = p[k];
|
||||||
|
HeapSortDown(p, k, size, temp)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
UInt64 temp = p[size];
|
||||||
|
p[size] = p[1];
|
||||||
|
if (size > 2 && p[2] < temp)
|
||||||
|
{
|
||||||
|
p[1] = p[2];
|
||||||
|
p[2] = temp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
p[1] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define HeapSortRefDown(p, vals, n, size, temp) \
|
||||||
|
{ size_t k = n; UInt32 val = vals[temp]; for (;;) { \
|
||||||
|
size_t s = (k << 1); \
|
||||||
|
if (s > size) break; \
|
||||||
|
if (s < size && vals[p[s + 1]] > vals[p[s]]) s++; \
|
||||||
|
if (val >= vals[p[s]]) break; \
|
||||||
|
p[k] = p[s]; k = s; \
|
||||||
|
} p[k] = temp; }
|
||||||
|
|
||||||
|
void HeapSortRef(UInt32 *p, UInt32 *vals, size_t size)
|
||||||
|
{
|
||||||
|
if (size <= 1)
|
||||||
|
return;
|
||||||
|
p--;
|
||||||
|
{
|
||||||
|
size_t i = size / 2;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
UInt32 temp = p[i];
|
||||||
|
HeapSortRefDown(p, vals, i, size, temp);
|
||||||
|
}
|
||||||
|
while (--i != 0);
|
||||||
|
}
|
||||||
|
do
|
||||||
|
{
|
||||||
|
UInt32 temp = p[size];
|
||||||
|
p[size--] = p[1];
|
||||||
|
HeapSortRefDown(p, vals, 1, size, temp);
|
||||||
|
}
|
||||||
|
while (size > 1);
|
||||||
|
}
|
||||||
|
*/
|
|
@ -0,0 +1,18 @@
|
||||||
|
/* Sort.h -- Sort functions
|
||||||
|
2014-04-05 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __7Z_SORT_H
|
||||||
|
#define __7Z_SORT_H
|
||||||
|
|
||||||
|
#include "7zTypes.h"
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
void HeapSort(UInt32 *p, size_t size);
|
||||||
|
void HeapSort64(UInt64 *p, size_t size);
|
||||||
|
|
||||||
|
/* void HeapSortRef(UInt32 *p, UInt32 *vals, size_t size); */
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
|
@ -22,6 +22,7 @@ include $(CLEAR_VARS)
|
||||||
FOR_ANDROID := 1
|
FOR_ANDROID := 1
|
||||||
WEBUI := 1
|
WEBUI := 1
|
||||||
USE_GLES := 1
|
USE_GLES := 1
|
||||||
|
CHD5_LZMA := 1
|
||||||
|
|
||||||
ifneq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
ifneq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||||
NOT_ARM := 1
|
NOT_ARM := 1
|
||||||
|
@ -43,6 +44,11 @@ else
|
||||||
NO_REC :=
|
NO_REC :=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# 7-Zip/LZMA settings (CHDv5)
|
||||||
|
ifdef USE_LZMA
|
||||||
|
LOCAL_CFLAGS += -D_7ZIP_ST -DCHD5_LZMA
|
||||||
|
endif
|
||||||
|
|
||||||
$(info $$TARGET_ARCH_ABI is [${TARGET_ARCH_ABI}])
|
$(info $$TARGET_ARCH_ABI is [${TARGET_ARCH_ABI}])
|
||||||
|
|
||||||
include $(LOCAL_PATH)/../../../../../core/core.mk
|
include $(LOCAL_PATH)/../../../../../core/core.mk
|
||||||
|
|
|
@ -14,6 +14,8 @@ AS=${CC_PREFIX}as
|
||||||
STRIP=${CC_PREFIX}strip
|
STRIP=${CC_PREFIX}strip
|
||||||
LD=${CC}
|
LD=${CC}
|
||||||
|
|
||||||
|
CHD5_LZMA := 1
|
||||||
|
|
||||||
MFLAGS :=
|
MFLAGS :=
|
||||||
ASFLAGS :=
|
ASFLAGS :=
|
||||||
LDFLAGS :=
|
LDFLAGS :=
|
||||||
|
@ -234,6 +236,11 @@ else
|
||||||
$(error Unknown platform)
|
$(error Unknown platform)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# 7-Zip/LZMA settings (CHDv5)
|
||||||
|
ifdef CHD5_LZMA
|
||||||
|
CFLAGS += -D_7ZIP_ST -DCHD5_LZMA
|
||||||
|
endif
|
||||||
|
|
||||||
RZDCY_SRC_DIR = $(LOCAL_PATH)/../../core
|
RZDCY_SRC_DIR = $(LOCAL_PATH)/../../core
|
||||||
include $(RZDCY_SRC_DIR)/core.mk
|
include $(RZDCY_SRC_DIR)/core.mk
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,11 @@
|
||||||
<ClCompile Include="..\core\cfg\cfg.cpp" />
|
<ClCompile Include="..\core\cfg\cfg.cpp" />
|
||||||
<ClCompile Include="..\core\cfg\ini.cpp" />
|
<ClCompile Include="..\core\cfg\ini.cpp" />
|
||||||
<ClCompile Include="..\core\deps\chdpsr\cdipsr.cpp" />
|
<ClCompile Include="..\core\deps\chdpsr\cdipsr.cpp" />
|
||||||
<ClCompile Include="..\core\deps\chdr\chdr.cpp" />
|
<ClCompile Include="..\core\deps\chdr\bitstream.c" />
|
||||||
|
<ClCompile Include="..\core\deps\chdr\cdrom.c" />
|
||||||
|
<ClCompile Include="..\core\deps\chdr\chd.c" />
|
||||||
|
<ClCompile Include="..\core\deps\chdr\flac.c" />
|
||||||
|
<ClCompile Include="..\core\deps\chdr\huffman.c" />
|
||||||
<ClCompile Include="..\core\deps\coreio\coreio.cpp" />
|
<ClCompile Include="..\core\deps\coreio\coreio.cpp" />
|
||||||
<ClCompile Include="..\core\deps\crypto\md5.cpp" />
|
<ClCompile Include="..\core\deps\crypto\md5.cpp" />
|
||||||
<ClCompile Include="..\core\deps\crypto\sha1.cpp" />
|
<ClCompile Include="..\core\deps\crypto\sha1.cpp" />
|
||||||
|
@ -96,6 +100,19 @@
|
||||||
<ClCompile Include="..\core\deps\libwebsocket\server.c" />
|
<ClCompile Include="..\core\deps\libwebsocket\server.c" />
|
||||||
<ClCompile Include="..\core\deps\libwebsocket\service.c" />
|
<ClCompile Include="..\core\deps\libwebsocket\service.c" />
|
||||||
<ClCompile Include="..\core\deps\libwebsocket\sha-1.c" />
|
<ClCompile Include="..\core\deps\libwebsocket\sha-1.c" />
|
||||||
|
<ClCompile Include="..\core\deps\lzma\Alloc.c" />
|
||||||
|
<ClCompile Include="..\core\deps\lzma\Bra.c" />
|
||||||
|
<ClCompile Include="..\core\deps\lzma\Bra86.c" />
|
||||||
|
<ClCompile Include="..\core\deps\lzma\BraIA64.c" />
|
||||||
|
<ClCompile Include="..\core\deps\lzma\CpuArch.c" />
|
||||||
|
<ClCompile Include="..\core\deps\lzma\Delta.c" />
|
||||||
|
<ClCompile Include="..\core\deps\lzma\LzFind.c" />
|
||||||
|
<ClCompile Include="..\core\deps\lzma\Lzma86Dec.c" />
|
||||||
|
<ClCompile Include="..\core\deps\lzma\Lzma86Enc.c" />
|
||||||
|
<ClCompile Include="..\core\deps\lzma\LzmaDec.c" />
|
||||||
|
<ClCompile Include="..\core\deps\lzma\LzmaEnc.c" />
|
||||||
|
<ClCompile Include="..\core\deps\lzma\LzmaLib.c" />
|
||||||
|
<ClCompile Include="..\core\deps\lzma\Sort.c" />
|
||||||
<ClCompile Include="..\core\deps\zlib\adler32.c" />
|
<ClCompile Include="..\core\deps\zlib\adler32.c" />
|
||||||
<ClCompile Include="..\core\deps\zlib\compress.c" />
|
<ClCompile Include="..\core\deps\zlib\compress.c" />
|
||||||
<ClCompile Include="..\core\deps\zlib\crc32.c" />
|
<ClCompile Include="..\core\deps\zlib\crc32.c" />
|
||||||
|
@ -281,8 +298,12 @@
|
||||||
<ClInclude Include="..\core\cfg\cfg.h" />
|
<ClInclude Include="..\core\cfg\cfg.h" />
|
||||||
<ClInclude Include="..\core\cfg\ini.h" />
|
<ClInclude Include="..\core\cfg\ini.h" />
|
||||||
<ClInclude Include="..\core\deps\chdpsr\cdipsr.h" />
|
<ClInclude Include="..\core\deps\chdpsr\cdipsr.h" />
|
||||||
|
<ClInclude Include="..\core\deps\chdr\bitstream.h" />
|
||||||
|
<ClInclude Include="..\core\deps\chdr\cdrom.h" />
|
||||||
<ClInclude Include="..\core\deps\chdr\chd.h" />
|
<ClInclude Include="..\core\deps\chdr\chd.h" />
|
||||||
<ClInclude Include="..\core\deps\chdr\coretypes.h" />
|
<ClInclude Include="..\core\deps\chdr\coretypes.h" />
|
||||||
|
<ClInclude Include="..\core\deps\chdr\flac.h" />
|
||||||
|
<ClInclude Include="..\core\deps\chdr\huffman.h" />
|
||||||
<ClInclude Include="..\core\deps\coreio\coreio.h" />
|
<ClInclude Include="..\core\deps\coreio\coreio.h" />
|
||||||
<ClInclude Include="..\core\deps\crypto\md5.h" />
|
<ClInclude Include="..\core\deps\crypto\md5.h" />
|
||||||
<ClInclude Include="..\core\deps\crypto\sha1.h" />
|
<ClInclude Include="..\core\deps\crypto\sha1.h" />
|
||||||
|
@ -676,7 +697,7 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Full</Optimization>
|
<Optimization>Full</Optimization>
|
||||||
<PreprocessorDefinitions>TARGET_NO_WEBUI;WIN32;NDEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>TARGET_NO_WEBUI;WIN32;_7ZIP_ST;CHD5_LZMA;NDEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||||
|
@ -718,7 +739,7 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Full</Optimization>
|
<Optimization>Full</Optimization>
|
||||||
<PreprocessorDefinitions>TARGET_NO_WEBUI;WIN32;NDEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>TARGET_NO_WEBUI;WIN32;_7ZIP_ST;CHD5_LZMA;NDEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||||
|
@ -760,7 +781,7 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Full</Optimization>
|
<Optimization>Full</Optimization>
|
||||||
<PreprocessorDefinitions>TARGET_NO_WEBUI;WIN32;NDEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>TARGET_NO_WEBUI;WIN32;_7ZIP_ST;CHD5_LZMA;NDEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||||
|
@ -802,7 +823,7 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Full</Optimization>
|
<Optimization>Full</Optimization>
|
||||||
<PreprocessorDefinitions>TARGET_NO_WEBUI;WIN32;NDEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>TARGET_NO_WEBUI;WIN32;_7ZIP_ST;CHD5_LZMA;NDEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||||
|
@ -846,7 +867,7 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Full</Optimization>
|
<Optimization>Full</Optimization>
|
||||||
<PreprocessorDefinitions>TARGET_NO_WEBUI;WIN32;NDEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>TARGET_NO_WEBUI;WIN32;_7ZIP_ST;CHD5_LZMA;NDEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||||
|
@ -890,7 +911,7 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Full</Optimization>
|
<Optimization>Full</Optimization>
|
||||||
<PreprocessorDefinitions>TARGET_NO_WEBUI;WIN32;NDEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>TARGET_NO_WEBUI;WIN32;_7ZIP_ST;CHD5_LZMA;NDEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
|
||||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||||
|
@ -934,7 +955,7 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>DEF_CONSOLE;TARGET_NO_WEBUI;WIN32;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>DEF_CONSOLE;TARGET_NO_WEBUI;WIN32;_7ZIP_ST;CHD5_LZMA;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
|
@ -965,7 +986,7 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>DEF_CONSOLE;TARGET_NO_WEBUI;WIN32;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>DEF_CONSOLE;TARGET_NO_WEBUI;WIN32;_7ZIP_ST;CHD5_LZMA;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
|
@ -996,7 +1017,7 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>DEF_CONSOLE;TARGET_NO_WEBUI;WIN32;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>DEF_CONSOLE;TARGET_NO_WEBUI;WIN32;_7ZIP_ST;CHD5_LZMA;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
|
@ -1027,7 +1048,7 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>DEF_CONSOLE;TARGET_NO_WEBUI;WIN32;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>DEF_CONSOLE;TARGET_NO_WEBUI;WIN32;_7ZIP_ST;CHD5_LZMA;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
|
@ -1063,7 +1084,7 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>DEF_CONSOLE;TARGET_NO_WEBUI;WIN32;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>DEF_CONSOLE;TARGET_NO_WEBUI;WIN32;_7ZIP_ST;CHD5_LZMA;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
|
@ -1099,7 +1120,7 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>DEF_CONSOLE;TARGET_NO_WEBUI;WIN32;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>DEF_CONSOLE;TARGET_NO_WEBUI;WIN32;_7ZIP_ST;CHD5_LZMA;_DEBUG;_CONSOLE;X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\core\;$(ProjectDir)..\core\khronos;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
|
|
|
@ -97,9 +97,6 @@
|
||||||
<ClCompile Include="..\core\deps\crypto\sha1.cpp">
|
<ClCompile Include="..\core\deps\crypto\sha1.cpp">
|
||||||
<Filter>deps\crypto</Filter>
|
<Filter>deps\crypto</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\core\deps\chdr\chdr.cpp">
|
|
||||||
<Filter>deps\chdr</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\core\imgread\cdi.cpp">
|
<ClCompile Include="..\core\imgread\cdi.cpp">
|
||||||
<Filter>imgread</Filter>
|
<Filter>imgread</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -429,6 +426,60 @@
|
||||||
<ClCompile Include="..\core\cfg\ini.cpp">
|
<ClCompile Include="..\core\cfg\ini.cpp">
|
||||||
<Filter>cfg</Filter>
|
<Filter>cfg</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\chdr\chd.c">
|
||||||
|
<Filter>deps\chdr</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\chdr\cdrom.c">
|
||||||
|
<Filter>deps\chdr</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\chdr\flac.c">
|
||||||
|
<Filter>deps\chdr</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\chdr\huffman.c">
|
||||||
|
<Filter>deps\chdr</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\chdr\bitstream.c">
|
||||||
|
<Filter>deps\chdr</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\lzma\Alloc.c">
|
||||||
|
<Filter>deps\lzma</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\lzma\Bra.c">
|
||||||
|
<Filter>deps\lzma</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\lzma\Bra86.c">
|
||||||
|
<Filter>deps\lzma</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\lzma\BraIA64.c">
|
||||||
|
<Filter>deps\lzma</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\lzma\CpuArch.c">
|
||||||
|
<Filter>deps\lzma</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\lzma\Delta.c">
|
||||||
|
<Filter>deps\lzma</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\lzma\LzFind.c">
|
||||||
|
<Filter>deps\lzma</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\lzma\Lzma86Dec.c">
|
||||||
|
<Filter>deps\lzma</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\lzma\Lzma86Enc.c">
|
||||||
|
<Filter>deps\lzma</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\lzma\LzmaDec.c">
|
||||||
|
<Filter>deps\lzma</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\lzma\LzmaEnc.c">
|
||||||
|
<Filter>deps\lzma</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\lzma\LzmaLib.c">
|
||||||
|
<Filter>deps\lzma</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\core\deps\lzma\Sort.c">
|
||||||
|
<Filter>deps\lzma</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="hw">
|
<Filter Include="hw">
|
||||||
|
@ -566,6 +617,9 @@
|
||||||
<Filter Include="hw\naomi">
|
<Filter Include="hw\naomi">
|
||||||
<UniqueIdentifier>{1752487d-0739-47bf-8c6b-1d38e6f389f7}</UniqueIdentifier>
|
<UniqueIdentifier>{1752487d-0739-47bf-8c6b-1d38e6f389f7}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="deps\lzma">
|
||||||
|
<UniqueIdentifier>{9198fe3c-8215-431d-9adf-d36e81eda98d}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\core\hw\aica\aica.h">
|
<ClInclude Include="..\core\hw\aica\aica.h">
|
||||||
|
@ -947,6 +1001,18 @@
|
||||||
<Filter>hw\sh4\modules</Filter>
|
<Filter>hw\sh4\modules</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\core\version.h" />
|
<ClInclude Include="..\core\version.h" />
|
||||||
|
<ClInclude Include="..\core\deps\chdr\cdrom.h">
|
||||||
|
<Filter>deps\chdr</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\core\deps\chdr\flac.h">
|
||||||
|
<Filter>deps\chdr</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\core\deps\chdr\huffman.h">
|
||||||
|
<Filter>deps\chdr</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\core\deps\chdr\bitstream.h">
|
||||||
|
<Filter>deps\chdr</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\core\deps\zlib\Makefile">
|
<None Include="..\core\deps\zlib\Makefile">
|
||||||
|
|
Loading…
Reference in New Issue