mirror of
https://github.com/Xevion/easy7zip.git
synced 2026-02-01 00:24:14 -06:00
9.04 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
8874e4fbc9
commit
829409452d
@@ -2,10 +2,7 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../C/Alloc.h"
|
||||
}
|
||||
|
||||
#include "../../Common/Defs.h"
|
||||
|
||||
@@ -420,15 +417,19 @@ static UInt32 NO_INLINE DecodeBlock2Rand(const UInt32 *tt, UInt32 blockSize, UIn
|
||||
return crc.GetDigest();
|
||||
}
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
|
||||
CDecoder::CDecoder():
|
||||
m_States(0)
|
||||
CDecoder::CDecoder()
|
||||
{
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
m_States = 0;
|
||||
m_NumThreadsPrev = 0;
|
||||
NumThreads = 1;
|
||||
#endif;
|
||||
_needInStreamInit = true;
|
||||
}
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
|
||||
CDecoder::~CDecoder()
|
||||
{
|
||||
Free();
|
||||
@@ -611,43 +612,61 @@ HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress)
|
||||
}
|
||||
|
||||
HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
|
||||
const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
|
||||
bool &isBZ, ICompressProgressInfo *progress)
|
||||
{
|
||||
isBZ = false;
|
||||
try
|
||||
{
|
||||
|
||||
if (!m_InStream.Create(kBufferSize))
|
||||
return E_OUTOFMEMORY;
|
||||
if (!m_OutStream.Create(kBufferSize))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
m_InStream.SetStream(inStream);
|
||||
m_InStream.Init();
|
||||
if (inStream)
|
||||
m_InStream.SetStream(inStream);
|
||||
|
||||
CDecoderFlusher flusher(this, inStream != NULL);
|
||||
|
||||
if (_needInStreamInit)
|
||||
{
|
||||
m_InStream.Init();
|
||||
_needInStreamInit = false;
|
||||
}
|
||||
_inStart = m_InStream.GetProcessedSize();
|
||||
|
||||
m_InStream.AlignToByte();
|
||||
|
||||
m_OutStream.SetStream(outStream);
|
||||
m_OutStream.Init();
|
||||
|
||||
CDecoderFlusher flusher(this);
|
||||
|
||||
bool isBZ;
|
||||
RINOK(DecodeFile(isBZ, progress));
|
||||
return isBZ ? S_OK: S_FALSE;
|
||||
}
|
||||
flusher.NeedFlush = false;
|
||||
return Flush();
|
||||
|
||||
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
|
||||
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
|
||||
{
|
||||
try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
|
||||
}
|
||||
catch(const CInBufferException &e) { return e.ErrorCode; }
|
||||
catch(const COutBufferException &e) { return e.ErrorCode; }
|
||||
catch(...) { return E_FAIL; }
|
||||
}
|
||||
|
||||
STDMETHODIMP CDecoder::GetInStreamProcessedSize(UInt64 *value)
|
||||
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
|
||||
const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
|
||||
{
|
||||
if (value == NULL)
|
||||
return E_INVALIDARG;
|
||||
*value = m_InStream.GetProcessedSize();
|
||||
return S_OK;
|
||||
_needInStreamInit = true;
|
||||
bool isBZ;
|
||||
RINOK(CodeReal(inStream, outStream, isBZ, progress));
|
||||
return isBZ ? S_OK : S_FALSE;
|
||||
}
|
||||
|
||||
HRESULT CDecoder::CodeResume(ISequentialOutStream *outStream, bool &isBZ, ICompressProgressInfo *progress)
|
||||
{
|
||||
return CodeReal(NULL, outStream, isBZ, progress);
|
||||
}
|
||||
|
||||
STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream) { m_InStream.SetStream(inStream); return S_OK; }
|
||||
STDMETHODIMP CDecoder::ReleaseInStream() { m_InStream.ReleaseStream(); return S_OK; }
|
||||
|
||||
#ifdef COMPRESS_BZIP2_MT
|
||||
|
||||
static THREAD_FUNC_DECL MFThread(void *p) { ((CState *)p)->ThreadFunc(); return 0; }
|
||||
@@ -694,7 +713,7 @@ void CState::ThreadFunc()
|
||||
nextBlockIndex = 0;
|
||||
Decoder->NextBlockIndex = nextBlockIndex;
|
||||
UInt32 crc;
|
||||
UInt64 packSize;
|
||||
UInt64 packSize = 0;
|
||||
UInt32 blockSize = 0, origPtr = 0;
|
||||
bool randMode = false;
|
||||
|
||||
@@ -752,8 +771,9 @@ void CState::ThreadFunc()
|
||||
{
|
||||
if (Decoder->Progress)
|
||||
{
|
||||
UInt64 inSize = packSize - Decoder->_inStart;
|
||||
UInt64 unpackSize = Decoder->m_OutStream.GetProcessedSize();
|
||||
res = Decoder->Progress->SetRatioInfo(&packSize, &unpackSize);
|
||||
res = Decoder->Progress->SetRatioInfo(&inSize, &unpackSize);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user