Update to lzma 23.01.

This commit is contained in:
2023-09-24 03:13:03 +01:00
parent 5a6a32f513
commit dda9bcac54
530 changed files with 31937 additions and 14468 deletions

View File

@@ -25,14 +25,14 @@ namespace NCompress {
namespace NLzma {
CDecoder::CDecoder():
_inBuf(NULL),
_lzmaStatus(LZMA_STATUS_NOT_SPECIFIED),
FinishStream(false),
_propsWereSet(false),
_outSizeDefined(false),
_outStep(1 << 20),
_inBufSize(0),
_inBufSizeNew(1 << 20)
_inBufSizeNew(1 << 20),
_lzmaStatus(LZMA_STATUS_NOT_SPECIFIED),
_inBuf(NULL)
{
_inProcessed = 0;
_inPos = _inLim = 0;
@@ -42,7 +42,7 @@ CDecoder::CDecoder():
_alloc.numAlignBits = 7;
_alloc.offset = 0;
*/
LzmaDec_Construct(&_state);
LzmaDec_CONSTRUCT(&_state)
}
CDecoder::~CDecoder()
@@ -51,8 +51,10 @@ CDecoder::~CDecoder()
MyFree(_inBuf);
}
STDMETHODIMP CDecoder::SetInBufSize(UInt32 , UInt32 size) { _inBufSizeNew = size; return S_OK; }
STDMETHODIMP CDecoder::SetOutBufSize(UInt32 , UInt32 size) { _outStep = size; return S_OK; }
Z7_COM7F_IMF(CDecoder::SetInBufSize(UInt32 , UInt32 size))
{ _inBufSizeNew = size; return S_OK; }
Z7_COM7F_IMF(CDecoder::SetOutBufSize(UInt32 , UInt32 size))
{ _outStep = size; return S_OK; }
HRESULT CDecoder::CreateInputBuffer()
{
@@ -69,7 +71,7 @@ HRESULT CDecoder::CreateInputBuffer()
}
STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *prop, UInt32 size)
Z7_COM7F_IMF(CDecoder::SetDecoderProperties2(const Byte *prop, UInt32 size))
{
RINOK(SResToHRESULT(LzmaDec_Allocate(&_state, prop, size, &g_AlignedAlloc))) // &_alloc.vt
_propsWereSet = true;
@@ -90,7 +92,7 @@ void CDecoder::SetOutStreamSizeResume(const UInt64 *outSize)
}
STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
Z7_COM7F_IMF(CDecoder::SetOutStreamSize(const UInt64 *outSize))
{
_inProcessed = 0;
_inPos = _inLim = 0;
@@ -99,14 +101,14 @@ STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
}
STDMETHODIMP CDecoder::SetFinishMode(UInt32 finishMode)
Z7_COM7F_IMF(CDecoder::SetFinishMode(UInt32 finishMode))
{
FinishStream = (finishMode != 0);
return S_OK;
}
STDMETHODIMP CDecoder::GetInStreamProcessedSize(UInt64 *value)
Z7_COM7F_IMF(CDecoder::GetInStreamProcessedSize(UInt64 *value))
{
*value = _inProcessed;
return S_OK;
@@ -154,7 +156,7 @@ HRESULT CDecoder::CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *
SizeT inProcessed = _inLim - _inPos;
ELzmaStatus status;
SRes res = LzmaDec_DecodeToDic(&_state, dicPos + size, _inBuf + _inPos, &inProcessed, finishMode, &status);
const SRes res = LzmaDec_DecodeToDic(&_state, dicPos + size, _inBuf + _inPos, &inProcessed, finishMode, &status);
_lzmaStatus = status;
_inPos += (UInt32)inProcessed;
@@ -163,22 +165,22 @@ HRESULT CDecoder::CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *
_outProcessed += outProcessed;
// we check for LZMA_STATUS_NEEDS_MORE_INPUT to allow RangeCoder initialization, if (_outSizeDefined && _outSize == 0)
bool outFinished = (_outSizeDefined && _outProcessed >= _outSize);
const bool outFinished = (_outSizeDefined && _outProcessed >= _outSize);
bool needStop = (res != 0
const bool needStop = (res != 0
|| (inProcessed == 0 && outProcessed == 0)
|| status == LZMA_STATUS_FINISHED_WITH_MARK
|| (outFinished && status != LZMA_STATUS_NEEDS_MORE_INPUT));
if (needStop || outProcessed >= size)
{
HRESULT res2 = WriteStream(outStream, _state.dic + wrPos, _state.dicPos - wrPos);
const HRESULT res2 = WriteStream(outStream, _state.dic + wrPos, _state.dicPos - wrPos);
if (_state.dicPos == _state.dicBufSize)
_state.dicPos = 0;
wrPos = _state.dicPos;
RINOK(res2);
RINOK(res2)
if (needStop)
{
@@ -207,14 +209,14 @@ HRESULT CDecoder::CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *
if (progress)
{
const UInt64 inSize = _inProcessed - startInProgress;
RINOK(progress->SetRatioInfo(&inSize, &_outProcessed));
RINOK(progress->SetRatioInfo(&inSize, &_outProcessed))
}
}
}
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress)
Z7_COM7F_IMF(CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress))
{
if (!_inBuf)
return E_INVALIDARG;
@@ -227,13 +229,14 @@ STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream
}
#ifndef NO_READ_FROM_CODER
#ifndef Z7_NO_READ_FROM_CODER
STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream) { _inStream = inStream; return S_OK; }
STDMETHODIMP CDecoder::ReleaseInStream() { _inStream.Release(); return S_OK; }
Z7_COM7F_IMF(CDecoder::SetInStream(ISequentialInStream *inStream))
{ _inStream = inStream; return S_OK; }
Z7_COM7F_IMF(CDecoder::ReleaseInStream())
{ _inStream.Release(); return S_OK; }
STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
Z7_COM7F_IMF(CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize))
{
if (processedSize)
*processedSize = 0;
@@ -264,7 +267,7 @@ STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
SizeT outProcessed = size;
ELzmaStatus status;
SRes res = LzmaDec_DecodeToBuf(&_state, (Byte *)data, &outProcessed,
const SRes res = LzmaDec_DecodeToBuf(&_state, (Byte *)data, &outProcessed,
_inBuf + _inPos, &inProcessed, finishMode, &status);
_lzmaStatus = status;
@@ -308,7 +311,7 @@ HRESULT CDecoder::CodeResume(ISequentialOutStream *outStream, const UInt64 *outS
HRESULT CDecoder::ReadFromInputStream(void *data, UInt32 size, UInt32 *processedSize)
{
RINOK(CreateInputBuffer());
RINOK(CreateInputBuffer())
if (processedSize)
*processedSize = 0;