mirror of
https://github.com/aaru-dps/Aaru.Compression.Native.git
synced 2025-12-16 19:24:31 +00:00
Update to lzma 23.01.
This commit is contained in:
48
3rdparty/lzma/CPP/7zip/Compress/LzmaEncoder.cpp
vendored
48
3rdparty/lzma/CPP/7zip/Compress/LzmaEncoder.cpp
vendored
@@ -9,14 +9,15 @@
|
||||
|
||||
#include "LzmaEncoder.h"
|
||||
|
||||
#include "../../Common/IntToString.h"
|
||||
#include "../../Windows/TimeUtils.h"
|
||||
|
||||
// #define LOG_LZMA_THREADS
|
||||
|
||||
#ifdef LOG_LZMA_THREADS
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../../Common/IntToString.h"
|
||||
#include "../../Windows/TimeUtils.h"
|
||||
|
||||
EXTERN_C_BEGIN
|
||||
void LzmaEnc_GetLzThreads(CLzmaEncHandle pp, HANDLE lz_threads[2]);
|
||||
EXTERN_C_END
|
||||
@@ -47,12 +48,12 @@ static inline wchar_t GetLowCharFast(wchar_t c)
|
||||
|
||||
static int ParseMatchFinder(const wchar_t *s, int *btMode, int *numHashBytes)
|
||||
{
|
||||
wchar_t c = GetLowCharFast(*s++);
|
||||
const wchar_t c = GetLowCharFast(*s++);
|
||||
if (c == 'h')
|
||||
{
|
||||
if (GetLowCharFast(*s++) != 'c')
|
||||
return 0;
|
||||
int num = (int)(*s++ - L'0');
|
||||
const int num = (int)(*s++ - L'0');
|
||||
if (num < 4 || num > 5)
|
||||
return 0;
|
||||
if (*s != 0)
|
||||
@@ -67,7 +68,7 @@ static int ParseMatchFinder(const wchar_t *s, int *btMode, int *numHashBytes)
|
||||
{
|
||||
if (GetLowCharFast(*s++) != 't')
|
||||
return 0;
|
||||
int num = (int)(*s++ - L'0');
|
||||
const int num = (int)(*s++ - L'0');
|
||||
if (num < 2 || num > 5)
|
||||
return 0;
|
||||
if (*s != 0)
|
||||
@@ -100,6 +101,15 @@ HRESULT SetLzmaProp(PROPID propID, const PROPVARIANT &prop, CLzmaEncProps &ep)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (propID == NCoderPropID::kHashBits)
|
||||
{
|
||||
if (prop.vt == VT_UI4)
|
||||
ep.numHashOutBits = prop.ulVal;
|
||||
else
|
||||
return E_INVALIDARG;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (propID > NCoderPropID::kReduceSize)
|
||||
return S_OK;
|
||||
|
||||
@@ -132,7 +142,7 @@ HRESULT SetLzmaProp(PROPID propID, const PROPVARIANT &prop, CLzmaEncProps &ep)
|
||||
|
||||
if (prop.vt != VT_UI4)
|
||||
return E_INVALIDARG;
|
||||
UInt32 v = prop.ulVal;
|
||||
const UInt32 v = prop.ulVal;
|
||||
switch (propID)
|
||||
{
|
||||
case NCoderPropID::kDefaultProp:
|
||||
@@ -154,8 +164,8 @@ HRESULT SetLzmaProp(PROPID propID, const PROPVARIANT &prop, CLzmaEncProps &ep)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
|
||||
const PROPVARIANT *coderProps, UInt32 numProps)
|
||||
Z7_COM7F_IMF(CEncoder::SetCoderProperties(const PROPID *propIDs,
|
||||
const PROPVARIANT *coderProps, UInt32 numProps))
|
||||
{
|
||||
CLzmaEncProps props;
|
||||
LzmaEncProps_Init(&props);
|
||||
@@ -163,7 +173,7 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
|
||||
for (UInt32 i = 0; i < numProps; i++)
|
||||
{
|
||||
const PROPVARIANT &prop = coderProps[i];
|
||||
PROPID propID = propIDs[i];
|
||||
const PROPID propID = propIDs[i];
|
||||
switch (propID)
|
||||
{
|
||||
case NCoderPropID::kEndMarker:
|
||||
@@ -172,20 +182,20 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
|
||||
props.writeEndMark = (prop.boolVal != VARIANT_FALSE);
|
||||
break;
|
||||
default:
|
||||
RINOK(SetLzmaProp(propID, prop, props));
|
||||
RINOK(SetLzmaProp(propID, prop, props))
|
||||
}
|
||||
}
|
||||
return SResToHRESULT(LzmaEnc_SetProps(_encoder, &props));
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CEncoder::SetCoderPropertiesOpt(const PROPID *propIDs,
|
||||
const PROPVARIANT *coderProps, UInt32 numProps)
|
||||
Z7_COM7F_IMF(CEncoder::SetCoderPropertiesOpt(const PROPID *propIDs,
|
||||
const PROPVARIANT *coderProps, UInt32 numProps))
|
||||
{
|
||||
for (UInt32 i = 0; i < numProps; i++)
|
||||
{
|
||||
const PROPVARIANT &prop = coderProps[i];
|
||||
PROPID propID = propIDs[i];
|
||||
const PROPID propID = propIDs[i];
|
||||
if (propID == NCoderPropID::kExpectedDataSize)
|
||||
if (prop.vt == VT_UI8)
|
||||
LzmaEnc_SetDataSize(_encoder, prop.uhVal.QuadPart);
|
||||
@@ -194,11 +204,11 @@ STDMETHODIMP CEncoder::SetCoderPropertiesOpt(const PROPID *propIDs,
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
|
||||
Z7_COM7F_IMF(CEncoder::WriteCoderProperties(ISequentialOutStream *outStream))
|
||||
{
|
||||
Byte props[LZMA_PROPS_SIZE];
|
||||
size_t size = LZMA_PROPS_SIZE;
|
||||
RINOK(LzmaEnc_WriteProperties(_encoder, props, &size));
|
||||
SizeT size = LZMA_PROPS_SIZE;
|
||||
RINOK(LzmaEnc_WriteProperties(_encoder, props, &size))
|
||||
return WriteStream(outStream, props, size);
|
||||
}
|
||||
|
||||
@@ -292,8 +302,8 @@ static void PrintStat(HANDLE thread, UInt64 totalTime, const CBaseStat *prevStat
|
||||
|
||||
|
||||
|
||||
STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
|
||||
const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress)
|
||||
Z7_COM7F_IMF(CEncoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream,
|
||||
const UInt64 * /* inSize */, const UInt64 * /* outSize */, ICompressProgressInfo *progress))
|
||||
{
|
||||
CSeqInStreamWrap inWrap;
|
||||
CSeqOutStreamWrap outWrap;
|
||||
|
||||
Reference in New Issue
Block a user