PhysicsFS 2.0.3 imported.
This commit is contained in:
parent
bcc0937726
commit
993311d151
459 changed files with 87785 additions and 0 deletions
19
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/ARM.cpp
Normal file
19
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/ARM.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
// ARM.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "ARM.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/Compress/Branch/BranchARM.h"
|
||||
}
|
||||
|
||||
UInt32 CBC_ARM_Encoder::SubFilter(Byte *data, UInt32 size)
|
||||
{
|
||||
return ::ARM_Convert(data, size, _bufferPos, 1);
|
||||
}
|
||||
|
||||
UInt32 CBC_ARM_Decoder::SubFilter(Byte *data, UInt32 size)
|
||||
{
|
||||
return ::ARM_Convert(data, size, _bufferPos, 0);
|
||||
}
|
10
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/ARM.h
Normal file
10
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/ARM.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
// ARM.h
|
||||
|
||||
#ifndef __ARM_H
|
||||
#define __ARM_H
|
||||
|
||||
#include "BranchCoder.h"
|
||||
|
||||
MyClassA(BC_ARM, 0x05, 1)
|
||||
|
||||
#endif
|
20
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/ARMThumb.cpp
Normal file
20
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/ARMThumb.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
// ARMThumb.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "ARMThumb.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/Compress/Branch/BranchARMThumb.h"
|
||||
}
|
||||
|
||||
UInt32 CBC_ARMThumb_Encoder::SubFilter(Byte *data, UInt32 size)
|
||||
{
|
||||
return ::ARMThumb_Convert(data, size, _bufferPos, 1);
|
||||
}
|
||||
|
||||
UInt32 CBC_ARMThumb_Decoder::SubFilter(Byte *data, UInt32 size)
|
||||
{
|
||||
return ::ARMThumb_Convert(data, size, _bufferPos, 0);
|
||||
}
|
10
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/ARMThumb.h
Normal file
10
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/ARMThumb.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
// ARMThumb.h
|
||||
|
||||
#ifndef __ARMTHUMB_H
|
||||
#define __ARMTHUMB_H
|
||||
|
||||
#include "BranchCoder.h"
|
||||
|
||||
MyClassA(BC_ARMThumb, 0x07, 1)
|
||||
|
||||
#endif
|
|
@ -0,0 +1,18 @@
|
|||
// BranchRegister.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../Common/RegisterCodec.h"
|
||||
|
||||
#include "x86_2.h"
|
||||
static void *CreateCodec() { return (void *)(ICompressCoder2 *)(new NCompress::NBcj2::CDecoder()); }
|
||||
#ifndef EXTRACT_ONLY
|
||||
static void *CreateCodecOut() { return (void *)(ICompressCoder2 *)(new NCompress::NBcj2::CEncoder()); }
|
||||
#else
|
||||
#define CreateCodecOut 0
|
||||
#endif
|
||||
|
||||
static CCodecInfo g_CodecInfo =
|
||||
{ CreateCodec, CreateCodecOut, 0x0303011B, L"BCJ2", 4, false };
|
||||
|
||||
REGISTER_CODEC(BCJ2)
|
|
@ -0,0 +1,18 @@
|
|||
// BranchRegister.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../Common/RegisterCodec.h"
|
||||
|
||||
#include "x86.h"
|
||||
static void *CreateCodec() { return (void *)(ICompressFilter *)(new CBCJ_x86_Decoder()); }
|
||||
#ifndef EXTRACT_ONLY
|
||||
static void *CreateCodecOut() { return (void *)(ICompressFilter *)(new CBCJ_x86_Encoder()); }
|
||||
#else
|
||||
#define CreateCodecOut 0
|
||||
#endif
|
||||
|
||||
static CCodecInfo g_CodecInfo =
|
||||
{ CreateCodec, CreateCodecOut, 0x03030103, L"BCJ", 1, true };
|
||||
|
||||
REGISTER_CODEC(BCJ)
|
|
@ -0,0 +1,18 @@
|
|||
// BranchCoder.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "BranchCoder.h"
|
||||
|
||||
STDMETHODIMP CBranchConverter::Init()
|
||||
{
|
||||
_bufferPos = 0;
|
||||
SubInit();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(UInt32) CBranchConverter::Filter(Byte *data, UInt32 size)
|
||||
{
|
||||
UInt32 processedSize = SubFilter(data, size);
|
||||
_bufferPos += processedSize;
|
||||
return processedSize;
|
||||
}
|
45
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/BranchCoder.h
Normal file
45
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/BranchCoder.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
// BranchCoder.h
|
||||
|
||||
#ifndef __BRANCH_CODER_H
|
||||
#define __BRANCH_CODER_H
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "Common/Types.h"
|
||||
|
||||
#include "../../ICoder.h"
|
||||
|
||||
class CBranchConverter:
|
||||
public ICompressFilter,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
protected:
|
||||
UInt32 _bufferPos;
|
||||
virtual void SubInit() {}
|
||||
virtual UInt32 SubFilter(Byte *data, UInt32 size) = 0;
|
||||
public:
|
||||
MY_UNKNOWN_IMP;
|
||||
STDMETHOD(Init)();
|
||||
STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
|
||||
};
|
||||
|
||||
#define MyClassEncoderA(Name) class C ## Name: public CBranchConverter \
|
||||
{ public: UInt32 SubFilter(Byte *data, UInt32 size); };
|
||||
|
||||
#define MyClassDecoderA(Name) class C ## Name: public CBranchConverter \
|
||||
{ public: UInt32 SubFilter(Byte *data, UInt32 size); };
|
||||
|
||||
#define MyClassEncoderB(Name, ADD_ITEMS, ADD_INIT) class C ## Name: public CBranchConverter, public ADD_ITEMS \
|
||||
{ public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT};
|
||||
|
||||
#define MyClassDecoderB(Name, ADD_ITEMS, ADD_INIT) class C ## Name: public CBranchConverter, public ADD_ITEMS \
|
||||
{ public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT};
|
||||
|
||||
#define MyClassA(Name, id, subId) \
|
||||
MyClassEncoderA(Name ## _Encoder) \
|
||||
MyClassDecoderA(Name ## _Decoder)
|
||||
|
||||
#define MyClassB(Name, id, subId, ADD_ITEMS, ADD_INIT) \
|
||||
MyClassEncoderB(Name ## _Encoder, ADD_ITEMS, ADD_INIT) \
|
||||
MyClassDecoderB(Name ## _Decoder, ADD_ITEMS, ADD_INIT)
|
||||
|
||||
#endif
|
|
@ -0,0 +1,34 @@
|
|||
// BranchRegister.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../Common/RegisterCodec.h"
|
||||
|
||||
#include "PPC.h"
|
||||
#include "IA64.h"
|
||||
#include "ARM.h"
|
||||
#include "ARMThumb.h"
|
||||
#include "SPARC.h"
|
||||
|
||||
#define CREATE_CODEC(x) \
|
||||
static void *CreateCodec ## x() { return (void *)(ICompressFilter *)(new C ## x ## _Decoder); } \
|
||||
static void *CreateCodec ## x ## Out() { return (void *)(ICompressFilter *)(new C ## x ## _Encoder); }
|
||||
|
||||
CREATE_CODEC(BC_PPC_B)
|
||||
CREATE_CODEC(BC_IA64)
|
||||
CREATE_CODEC(BC_ARM)
|
||||
CREATE_CODEC(BC_ARMThumb)
|
||||
CREATE_CODEC(BC_SPARC)
|
||||
|
||||
#define METHOD_ITEM(x, id1, id2, name) { CreateCodec ## x, CreateCodec ## x ## Out, 0x03030000 + (id1 * 256) + id2, name, 1, true }
|
||||
|
||||
static CCodecInfo g_CodecsInfo[] =
|
||||
{
|
||||
METHOD_ITEM(BC_PPC_B, 0x02, 0x05, L"BC_PPC_B"),
|
||||
METHOD_ITEM(BC_IA64, 0x04, 1, L"BC_IA64"),
|
||||
METHOD_ITEM(BC_ARM, 0x05, 1, L"BC_ARM"),
|
||||
METHOD_ITEM(BC_ARMThumb,0x07, 1, L"BC_ARMThumb"),
|
||||
METHOD_ITEM(BC_SPARC, 0x08, 0x05, L"BC_SPARC")
|
||||
};
|
||||
|
||||
REGISTER_CODECS(Branch)
|
19
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/IA64.cpp
Normal file
19
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/IA64.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
// IA64.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "IA64.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/Compress/Branch/BranchIA64.h"
|
||||
}
|
||||
|
||||
UInt32 CBC_IA64_Encoder::SubFilter(Byte *data, UInt32 size)
|
||||
{
|
||||
return ::IA64_Convert(data, size, _bufferPos, 1);
|
||||
}
|
||||
|
||||
UInt32 CBC_IA64_Decoder::SubFilter(Byte *data, UInt32 size)
|
||||
{
|
||||
return ::IA64_Convert(data, size, _bufferPos, 0);
|
||||
}
|
10
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/IA64.h
Normal file
10
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/IA64.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
// IA64.h
|
||||
|
||||
#ifndef __IA64_H
|
||||
#define __IA64_H
|
||||
|
||||
#include "BranchCoder.h"
|
||||
|
||||
MyClassA(BC_IA64, 0x04, 1)
|
||||
|
||||
#endif
|
19
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/PPC.cpp
Normal file
19
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/PPC.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
// PPC.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "PPC.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/Compress/Branch/BranchPPC.h"
|
||||
}
|
||||
|
||||
UInt32 CBC_PPC_B_Encoder::SubFilter(Byte *data, UInt32 size)
|
||||
{
|
||||
return ::PPC_B_Convert(data, size, _bufferPos, 1);
|
||||
}
|
||||
|
||||
UInt32 CBC_PPC_B_Decoder::SubFilter(Byte *data, UInt32 size)
|
||||
{
|
||||
return ::PPC_B_Convert(data, size, _bufferPos, 0);
|
||||
}
|
10
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/PPC.h
Normal file
10
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/PPC.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
// PPC.h
|
||||
|
||||
#ifndef __PPC_H
|
||||
#define __PPC_H
|
||||
|
||||
#include "BranchCoder.h"
|
||||
|
||||
MyClassA(BC_PPC_B, 0x02, 5)
|
||||
|
||||
#endif
|
19
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/SPARC.cpp
Normal file
19
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/SPARC.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
// SPARC.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "SPARC.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/Compress/Branch/BranchSPARC.h"
|
||||
}
|
||||
|
||||
UInt32 CBC_SPARC_Encoder::SubFilter(Byte *data, UInt32 size)
|
||||
{
|
||||
return ::SPARC_Convert(data, size, _bufferPos, 1);
|
||||
}
|
||||
|
||||
UInt32 CBC_SPARC_Decoder::SubFilter(Byte *data, UInt32 size)
|
||||
{
|
||||
return ::SPARC_Convert(data, size, _bufferPos, 0);
|
||||
}
|
10
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/SPARC.h
Normal file
10
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/SPARC.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
// SPARC.h
|
||||
|
||||
#ifndef __SPARC_H
|
||||
#define __SPARC_H
|
||||
|
||||
#include "BranchCoder.h"
|
||||
|
||||
MyClassA(BC_SPARC, 0x08, 5)
|
||||
|
||||
#endif
|
|
@ -0,0 +1,3 @@
|
|||
// StdAfx.cpp
|
||||
|
||||
#include "StdAfx.h"
|
8
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/StdAfx.h
Normal file
8
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/StdAfx.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
// StdAfx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#endif
|
14
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/x86.cpp
Normal file
14
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/x86.cpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
// x86.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "x86.h"
|
||||
|
||||
UInt32 CBCJ_x86_Encoder::SubFilter(Byte *data, UInt32 size)
|
||||
{
|
||||
return (UInt32)::x86_Convert(data, size, _bufferPos, &_prevMask, 1);
|
||||
}
|
||||
|
||||
UInt32 CBCJ_x86_Decoder::SubFilter(Byte *data, UInt32 size)
|
||||
{
|
||||
return (UInt32)::x86_Convert(data, size, _bufferPos, &_prevMask, 0);
|
||||
}
|
21
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/x86.h
Normal file
21
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/x86.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
// x86.h
|
||||
|
||||
#ifndef __X86_H
|
||||
#define __X86_H
|
||||
|
||||
#include "BranchCoder.h"
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/Compress/Branch/BranchX86.h"
|
||||
}
|
||||
|
||||
struct CBranch86
|
||||
{
|
||||
UInt32 _prevMask;
|
||||
void x86Init() { x86_Convert_Init(_prevMask); }
|
||||
};
|
||||
|
||||
MyClassB(BCJ_x86, 0x01, 3, CBranch86 ,
|
||||
virtual void SubInit() { x86Init(); })
|
||||
|
||||
#endif
|
392
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/x86_2.cpp
Normal file
392
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/x86_2.cpp
Normal file
|
@ -0,0 +1,392 @@
|
|||
// x86_2.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "x86_2.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/Alloc.h"
|
||||
}
|
||||
|
||||
namespace NCompress {
|
||||
namespace NBcj2 {
|
||||
|
||||
inline bool IsJcc(Byte b0, Byte b1) { return (b0 == 0x0F && (b1 & 0xF0) == 0x80); }
|
||||
inline bool IsJ(Byte b0, Byte b1) { return ((b1 & 0xFE) == 0xE8 || IsJcc(b0, b1)); }
|
||||
inline unsigned GetIndex(Byte b0, Byte b1) { return ((b1 == 0xE8) ? b0 : ((b1 == 0xE9) ? 256 : 257)); }
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
|
||||
static const int kBufferSize = 1 << 17;
|
||||
|
||||
static bool inline Test86MSByte(Byte b)
|
||||
{
|
||||
return (b == 0 || b == 0xFF);
|
||||
}
|
||||
|
||||
bool CEncoder::Create()
|
||||
{
|
||||
if (!_mainStream.Create(1 << 16))
|
||||
return false;
|
||||
if (!_callStream.Create(1 << 20))
|
||||
return false;
|
||||
if (!_jumpStream.Create(1 << 20))
|
||||
return false;
|
||||
if (!_rangeEncoder.Create(1 << 20))
|
||||
return false;
|
||||
if (_buffer == 0)
|
||||
{
|
||||
_buffer = (Byte *)MidAlloc(kBufferSize);
|
||||
if (_buffer == 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
CEncoder::~CEncoder()
|
||||
{
|
||||
::MidFree(_buffer);
|
||||
}
|
||||
|
||||
HRESULT CEncoder::Flush()
|
||||
{
|
||||
RINOK(_mainStream.Flush());
|
||||
RINOK(_callStream.Flush());
|
||||
RINOK(_jumpStream.Flush());
|
||||
_rangeEncoder.FlushData();
|
||||
return _rangeEncoder.FlushStream();
|
||||
}
|
||||
|
||||
const UInt32 kDefaultLimit = (1 << 24);
|
||||
|
||||
HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams,
|
||||
const UInt64 **inSizes,
|
||||
UInt32 numInStreams,
|
||||
ISequentialOutStream **outStreams,
|
||||
const UInt64 ** /* outSizes */,
|
||||
UInt32 numOutStreams,
|
||||
ICompressProgressInfo *progress)
|
||||
{
|
||||
if (numInStreams != 1 || numOutStreams != 4)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (!Create())
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
bool sizeIsDefined = false;
|
||||
UInt64 inSize = 0;
|
||||
if (inSizes != NULL)
|
||||
if (inSizes[0] != NULL)
|
||||
{
|
||||
inSize = *inSizes[0];
|
||||
if (inSize <= kDefaultLimit)
|
||||
sizeIsDefined = true;
|
||||
}
|
||||
|
||||
ISequentialInStream *inStream = inStreams[0];
|
||||
|
||||
_mainStream.SetStream(outStreams[0]);
|
||||
_mainStream.Init();
|
||||
_callStream.SetStream(outStreams[1]);
|
||||
_callStream.Init();
|
||||
_jumpStream.SetStream(outStreams[2]);
|
||||
_jumpStream.Init();
|
||||
_rangeEncoder.SetStream(outStreams[3]);
|
||||
_rangeEncoder.Init();
|
||||
for (int i = 0; i < 256 + 2; i++)
|
||||
_statusEncoder[i].Init();
|
||||
CCoderReleaser releaser(this);
|
||||
|
||||
CMyComPtr<ICompressGetSubStreamSize> getSubStreamSize;
|
||||
{
|
||||
inStream->QueryInterface(IID_ICompressGetSubStreamSize, (void **)&getSubStreamSize);
|
||||
}
|
||||
|
||||
UInt32 nowPos = 0;
|
||||
UInt64 nowPos64 = 0;
|
||||
UInt32 bufferPos = 0;
|
||||
|
||||
Byte prevByte = 0;
|
||||
|
||||
UInt64 subStreamIndex = 0;
|
||||
UInt64 subStreamStartPos = 0;
|
||||
UInt64 subStreamEndPos = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
UInt32 processedSize = 0;
|
||||
for (;;)
|
||||
{
|
||||
UInt32 size = kBufferSize - (bufferPos + processedSize);
|
||||
UInt32 processedSizeLoc;
|
||||
if (size == 0)
|
||||
break;
|
||||
RINOK(inStream->Read(_buffer + bufferPos + processedSize, size, &processedSizeLoc));
|
||||
if (processedSizeLoc == 0)
|
||||
break;
|
||||
processedSize += processedSizeLoc;
|
||||
}
|
||||
UInt32 endPos = bufferPos + processedSize;
|
||||
|
||||
if (endPos < 5)
|
||||
{
|
||||
// change it
|
||||
for (bufferPos = 0; bufferPos < endPos; bufferPos++)
|
||||
{
|
||||
Byte b = _buffer[bufferPos];
|
||||
_mainStream.WriteByte(b);
|
||||
UInt32 index;
|
||||
if (b == 0xE8)
|
||||
index = prevByte;
|
||||
else if (b == 0xE9)
|
||||
index = 256;
|
||||
else if (IsJcc(prevByte, b))
|
||||
index = 257;
|
||||
else
|
||||
{
|
||||
prevByte = b;
|
||||
continue;
|
||||
}
|
||||
_statusEncoder[index].Encode(&_rangeEncoder, 0);
|
||||
prevByte = b;
|
||||
}
|
||||
return Flush();
|
||||
}
|
||||
|
||||
bufferPos = 0;
|
||||
|
||||
UInt32 limit = endPos - 5;
|
||||
while(bufferPos <= limit)
|
||||
{
|
||||
Byte b = _buffer[bufferPos];
|
||||
_mainStream.WriteByte(b);
|
||||
if (!IsJ(prevByte, b))
|
||||
{
|
||||
bufferPos++;
|
||||
prevByte = b;
|
||||
continue;
|
||||
}
|
||||
Byte nextByte = _buffer[bufferPos + 4];
|
||||
UInt32 src =
|
||||
(UInt32(nextByte) << 24) |
|
||||
(UInt32(_buffer[bufferPos + 3]) << 16) |
|
||||
(UInt32(_buffer[bufferPos + 2]) << 8) |
|
||||
(_buffer[bufferPos + 1]);
|
||||
UInt32 dest = (nowPos + bufferPos + 5) + src;
|
||||
// if (Test86MSByte(nextByte))
|
||||
bool convert;
|
||||
if (getSubStreamSize != NULL)
|
||||
{
|
||||
UInt64 currentPos = (nowPos64 + bufferPos);
|
||||
while (subStreamEndPos < currentPos)
|
||||
{
|
||||
UInt64 subStreamSize;
|
||||
HRESULT result = getSubStreamSize->GetSubStreamSize(subStreamIndex, &subStreamSize);
|
||||
if (result == S_OK)
|
||||
{
|
||||
subStreamStartPos = subStreamEndPos;
|
||||
subStreamEndPos += subStreamSize;
|
||||
subStreamIndex++;
|
||||
}
|
||||
else if (result == S_FALSE || result == E_NOTIMPL)
|
||||
{
|
||||
getSubStreamSize.Release();
|
||||
subStreamStartPos = 0;
|
||||
subStreamEndPos = subStreamStartPos - 1;
|
||||
}
|
||||
else
|
||||
return result;
|
||||
}
|
||||
if (getSubStreamSize == NULL)
|
||||
{
|
||||
if (sizeIsDefined)
|
||||
convert = (dest < inSize);
|
||||
else
|
||||
convert = Test86MSByte(nextByte);
|
||||
}
|
||||
else if (subStreamEndPos - subStreamStartPos > kDefaultLimit)
|
||||
convert = Test86MSByte(nextByte);
|
||||
else
|
||||
{
|
||||
UInt64 dest64 = (currentPos + 5) + Int64(Int32(src));
|
||||
convert = (dest64 >= subStreamStartPos && dest64 < subStreamEndPos);
|
||||
}
|
||||
}
|
||||
else if (sizeIsDefined)
|
||||
convert = (dest < inSize);
|
||||
else
|
||||
convert = Test86MSByte(nextByte);
|
||||
unsigned index = GetIndex(prevByte, b);
|
||||
if (convert)
|
||||
{
|
||||
_statusEncoder[index].Encode(&_rangeEncoder, 1);
|
||||
bufferPos += 5;
|
||||
COutBuffer &s = (b == 0xE8) ? _callStream : _jumpStream;
|
||||
for (int i = 24; i >= 0; i -= 8)
|
||||
s.WriteByte((Byte)(dest >> i));
|
||||
prevByte = nextByte;
|
||||
}
|
||||
else
|
||||
{
|
||||
_statusEncoder[index].Encode(&_rangeEncoder, 0);
|
||||
bufferPos++;
|
||||
prevByte = b;
|
||||
}
|
||||
}
|
||||
nowPos += bufferPos;
|
||||
nowPos64 += bufferPos;
|
||||
|
||||
if (progress != NULL)
|
||||
{
|
||||
/*
|
||||
const UInt64 compressedSize =
|
||||
_mainStream.GetProcessedSize() +
|
||||
_callStream.GetProcessedSize() +
|
||||
_jumpStream.GetProcessedSize() +
|
||||
_rangeEncoder.GetProcessedSize();
|
||||
*/
|
||||
RINOK(progress->SetRatioInfo(&nowPos64, NULL));
|
||||
}
|
||||
|
||||
UInt32 i = 0;
|
||||
while(bufferPos < endPos)
|
||||
_buffer[i++] = _buffer[bufferPos++];
|
||||
bufferPos = i;
|
||||
}
|
||||
}
|
||||
|
||||
STDMETHODIMP CEncoder::Code(ISequentialInStream **inStreams,
|
||||
const UInt64 **inSizes,
|
||||
UInt32 numInStreams,
|
||||
ISequentialOutStream **outStreams,
|
||||
const UInt64 **outSizes,
|
||||
UInt32 numOutStreams,
|
||||
ICompressProgressInfo *progress)
|
||||
{
|
||||
try
|
||||
{
|
||||
return CodeReal(inStreams, inSizes, numInStreams,
|
||||
outStreams, outSizes,numOutStreams, progress);
|
||||
}
|
||||
catch(const COutBufferException &e) { return e.ErrorCode; }
|
||||
catch(...) { return S_FALSE; }
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
HRESULT CDecoder::CodeReal(ISequentialInStream **inStreams,
|
||||
const UInt64 ** /* inSizes */,
|
||||
UInt32 numInStreams,
|
||||
ISequentialOutStream **outStreams,
|
||||
const UInt64 ** /* outSizes */,
|
||||
UInt32 numOutStreams,
|
||||
ICompressProgressInfo *progress)
|
||||
{
|
||||
if (numInStreams != 4 || numOutStreams != 1)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (!_mainInStream.Create(1 << 16))
|
||||
return E_OUTOFMEMORY;
|
||||
if (!_callStream.Create(1 << 20))
|
||||
return E_OUTOFMEMORY;
|
||||
if (!_jumpStream.Create(1 << 16))
|
||||
return E_OUTOFMEMORY;
|
||||
if (!_rangeDecoder.Create(1 << 20))
|
||||
return E_OUTOFMEMORY;
|
||||
if (!_outStream.Create(1 << 16))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
_mainInStream.SetStream(inStreams[0]);
|
||||
_callStream.SetStream(inStreams[1]);
|
||||
_jumpStream.SetStream(inStreams[2]);
|
||||
_rangeDecoder.SetStream(inStreams[3]);
|
||||
_outStream.SetStream(outStreams[0]);
|
||||
|
||||
_mainInStream.Init();
|
||||
_callStream.Init();
|
||||
_jumpStream.Init();
|
||||
_rangeDecoder.Init();
|
||||
_outStream.Init();
|
||||
|
||||
for (int i = 0; i < 256 + 2; i++)
|
||||
_statusDecoder[i].Init();
|
||||
|
||||
CCoderReleaser releaser(this);
|
||||
|
||||
Byte prevByte = 0;
|
||||
UInt32 processedBytes = 0;
|
||||
for (;;)
|
||||
{
|
||||
if (processedBytes >= (1 << 20) && progress != NULL)
|
||||
{
|
||||
/*
|
||||
const UInt64 compressedSize =
|
||||
_mainInStream.GetProcessedSize() +
|
||||
_callStream.GetProcessedSize() +
|
||||
_jumpStream.GetProcessedSize() +
|
||||
_rangeDecoder.GetProcessedSize();
|
||||
*/
|
||||
const UInt64 nowPos64 = _outStream.GetProcessedSize();
|
||||
RINOK(progress->SetRatioInfo(NULL, &nowPos64));
|
||||
processedBytes = 0;
|
||||
}
|
||||
UInt32 i;
|
||||
Byte b = 0;
|
||||
const UInt32 kBurstSize = (1 << 18);
|
||||
for (i = 0; i < kBurstSize; i++)
|
||||
{
|
||||
if (!_mainInStream.ReadByte(b))
|
||||
return Flush();
|
||||
_outStream.WriteByte(b);
|
||||
if (IsJ(prevByte, b))
|
||||
break;
|
||||
prevByte = b;
|
||||
}
|
||||
processedBytes += i;
|
||||
if (i == kBurstSize)
|
||||
continue;
|
||||
unsigned index = GetIndex(prevByte, b);
|
||||
if (_statusDecoder[index].Decode(&_rangeDecoder) == 1)
|
||||
{
|
||||
UInt32 src = 0;
|
||||
CInBuffer &s = (b == 0xE8) ? _callStream : _jumpStream;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Byte b0;
|
||||
if(!s.ReadByte(b0))
|
||||
return S_FALSE;
|
||||
src <<= 8;
|
||||
src |= ((UInt32)b0);
|
||||
}
|
||||
UInt32 dest = src - (UInt32(_outStream.GetProcessedSize()) + 4) ;
|
||||
_outStream.WriteByte((Byte)(dest));
|
||||
_outStream.WriteByte((Byte)(dest >> 8));
|
||||
_outStream.WriteByte((Byte)(dest >> 16));
|
||||
_outStream.WriteByte((Byte)(dest >> 24));
|
||||
prevByte = (Byte)(dest >> 24);
|
||||
processedBytes += 4;
|
||||
}
|
||||
else
|
||||
prevByte = b;
|
||||
}
|
||||
}
|
||||
|
||||
STDMETHODIMP CDecoder::Code(ISequentialInStream **inStreams,
|
||||
const UInt64 **inSizes,
|
||||
UInt32 numInStreams,
|
||||
ISequentialOutStream **outStreams,
|
||||
const UInt64 **outSizes,
|
||||
UInt32 numOutStreams,
|
||||
ICompressProgressInfo *progress)
|
||||
{
|
||||
try
|
||||
{
|
||||
return CodeReal(inStreams, inSizes, numInStreams,
|
||||
outStreams, outSizes,numOutStreams, progress);
|
||||
}
|
||||
catch(const CInBufferException &e) { return e.ErrorCode; }
|
||||
catch(const COutBufferException &e) { return e.ErrorCode; }
|
||||
catch(...) { return S_FALSE; }
|
||||
}
|
||||
|
||||
}}
|
123
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/x86_2.h
Normal file
123
lib/physfs-2.0.3/lzma/CPP/7zip/Compress/Branch/x86_2.h
Normal file
|
@ -0,0 +1,123 @@
|
|||
// x86_2.h
|
||||
|
||||
#ifndef __BRANCH_X86_2_H
|
||||
#define __BRANCH_X86_2_H
|
||||
|
||||
#include "../../../Common/MyCom.h"
|
||||
#include "../RangeCoder/RangeCoderBit.h"
|
||||
#include "../../ICoder.h"
|
||||
|
||||
namespace NCompress {
|
||||
namespace NBcj2 {
|
||||
|
||||
const int kNumMoveBits = 5;
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
|
||||
class CEncoder:
|
||||
public ICompressCoder2,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Byte *_buffer;
|
||||
public:
|
||||
CEncoder(): _buffer(0) {};
|
||||
~CEncoder();
|
||||
bool Create();
|
||||
|
||||
COutBuffer _mainStream;
|
||||
COutBuffer _callStream;
|
||||
COutBuffer _jumpStream;
|
||||
NCompress::NRangeCoder::CEncoder _rangeEncoder;
|
||||
NCompress::NRangeCoder::CBitEncoder<kNumMoveBits> _statusEncoder[256 + 2];
|
||||
|
||||
HRESULT Flush();
|
||||
void ReleaseStreams()
|
||||
{
|
||||
_mainStream.ReleaseStream();
|
||||
_callStream.ReleaseStream();
|
||||
_jumpStream.ReleaseStream();
|
||||
_rangeEncoder.ReleaseStream();
|
||||
}
|
||||
|
||||
class CCoderReleaser
|
||||
{
|
||||
CEncoder *_coder;
|
||||
public:
|
||||
CCoderReleaser(CEncoder *coder): _coder(coder) {}
|
||||
~CCoderReleaser() { _coder->ReleaseStreams(); }
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
HRESULT CodeReal(ISequentialInStream **inStreams,
|
||||
const UInt64 **inSizes,
|
||||
UInt32 numInStreams,
|
||||
ISequentialOutStream **outStreams,
|
||||
const UInt64 **outSizes,
|
||||
UInt32 numOutStreams,
|
||||
ICompressProgressInfo *progress);
|
||||
STDMETHOD(Code)(ISequentialInStream **inStreams,
|
||||
const UInt64 **inSizes,
|
||||
UInt32 numInStreams,
|
||||
ISequentialOutStream **outStreams,
|
||||
const UInt64 **outSizes,
|
||||
UInt32 numOutStreams,
|
||||
ICompressProgressInfo *progress);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
class CDecoder:
|
||||
public ICompressCoder2,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
public:
|
||||
CInBuffer _mainInStream;
|
||||
CInBuffer _callStream;
|
||||
CInBuffer _jumpStream;
|
||||
NCompress::NRangeCoder::CDecoder _rangeDecoder;
|
||||
NCompress::NRangeCoder::CBitDecoder<kNumMoveBits> _statusDecoder[256 + 2];
|
||||
|
||||
COutBuffer _outStream;
|
||||
|
||||
void ReleaseStreams()
|
||||
{
|
||||
_mainInStream.ReleaseStream();
|
||||
_callStream.ReleaseStream();
|
||||
_jumpStream.ReleaseStream();
|
||||
_rangeDecoder.ReleaseStream();
|
||||
_outStream.ReleaseStream();
|
||||
}
|
||||
|
||||
HRESULT Flush() { return _outStream.Flush(); }
|
||||
class CCoderReleaser
|
||||
{
|
||||
CDecoder *_coder;
|
||||
public:
|
||||
CCoderReleaser(CDecoder *coder): _coder(coder) {}
|
||||
~CCoderReleaser() { _coder->ReleaseStreams(); }
|
||||
};
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP
|
||||
HRESULT CodeReal(ISequentialInStream **inStreams,
|
||||
const UInt64 **inSizes,
|
||||
UInt32 numInStreams,
|
||||
ISequentialOutStream **outStreams,
|
||||
const UInt64 **outSizes,
|
||||
UInt32 numOutStreams,
|
||||
ICompressProgressInfo *progress);
|
||||
STDMETHOD(Code)(ISequentialInStream **inStreams,
|
||||
const UInt64 **inSizes,
|
||||
UInt32 numInStreams,
|
||||
ISequentialOutStream **outStreams,
|
||||
const UInt64 **outSizes,
|
||||
UInt32 numOutStreams,
|
||||
ICompressProgressInfo *progress);
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue