summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/lzma/CPP/7zip/Common/CreateCoder.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2023-12-06 07:58:49 +1100
committer Vas Crabb <vas@vastheman.com>2023-12-06 07:58:49 +1100
commit79bef1e23049fdac25f1fefd132e0b6c7d2cc3a1 (patch)
tree643e9313fe86f583c4022c338677cbc12b761df7 /3rdparty/lzma/CPP/7zip/Common/CreateCoder.cpp
parent512ccf0c7c9b4f08e41038b2ed2de220e140385b (diff)
3rdparty/lzma: Updated to version 23.01.
Diffstat (limited to '3rdparty/lzma/CPP/7zip/Common/CreateCoder.cpp')
-rw-r--r--3rdparty/lzma/CPP/7zip/Common/CreateCoder.cpp113
1 files changed, 58 insertions, 55 deletions
diff --git a/3rdparty/lzma/CPP/7zip/Common/CreateCoder.cpp b/3rdparty/lzma/CPP/7zip/Common/CreateCoder.cpp
index 872f17fca31..bf7b04e441c 100644
--- a/3rdparty/lzma/CPP/7zip/Common/CreateCoder.cpp
+++ b/3rdparty/lzma/CPP/7zip/Common/CreateCoder.cpp
@@ -19,11 +19,11 @@ const CCodecInfo *g_Codecs[];
const CCodecInfo *g_Codecs[kNumCodecsMax];
// We use g_ExternalCodecs in other stages.
-#ifdef EXTERNAL_CODECS
+#ifdef Z7_EXTERNAL_CODECS
/*
extern CExternalCodecs g_ExternalCodecs;
#define CHECK_GLOBAL_CODECS \
- if (!__externalCodecs || !__externalCodecs->IsSet()) __externalCodecs = &g_ExternalCodecs;
+ if (!_externalCodecs || !_externalCodecs->IsSet()) _externalCodecs = &g_ExternalCodecs;
*/
#define CHECK_GLOBAL_CODECS
#endif
@@ -50,12 +50,12 @@ void RegisterHasher(const CHasherInfo *hashInfo) throw()
}
-#ifdef EXTERNAL_CODECS
+#ifdef Z7_EXTERNAL_CODECS
static HRESULT ReadNumberOfStreams(ICompressCodecsInfo *codecsInfo, UInt32 index, PROPID propID, UInt32 &res)
{
NWindows::NCOM::CPropVariant prop;
- RINOK(codecsInfo->GetProperty(index, propID, &prop));
+ RINOK(codecsInfo->GetProperty(index, propID, &prop))
if (prop.vt == VT_EMPTY)
res = 1;
else if (prop.vt == VT_UI4)
@@ -68,7 +68,7 @@ static HRESULT ReadNumberOfStreams(ICompressCodecsInfo *codecsInfo, UInt32 index
static HRESULT ReadIsAssignedProp(ICompressCodecsInfo *codecsInfo, UInt32 index, PROPID propID, bool &res)
{
NWindows::NCOM::CPropVariant prop;
- RINOK(codecsInfo->GetProperty(index, propID, &prop));
+ RINOK(codecsInfo->GetProperty(index, propID, &prop))
if (prop.vt == VT_EMPTY)
res = true;
else if (prop.vt == VT_BOOL)
@@ -89,13 +89,13 @@ HRESULT CExternalCodecs::Load()
UString s;
UInt32 num;
- RINOK(GetCodecs->GetNumMethods(&num));
+ RINOK(GetCodecs->GetNumMethods(&num))
for (UInt32 i = 0; i < num; i++)
{
NWindows::NCOM::CPropVariant prop;
- RINOK(GetCodecs->GetProperty(i, NMethodPropID::kID, &prop));
+ RINOK(GetCodecs->GetProperty(i, NMethodPropID::kID, &prop))
if (prop.vt != VT_UI8)
continue; // old Interface
info.Id = prop.uhVal.QuadPart;
@@ -103,22 +103,22 @@ HRESULT CExternalCodecs::Load()
prop.Clear();
info.Name.Empty();
- RINOK(GetCodecs->GetProperty(i, NMethodPropID::kName, &prop));
+ RINOK(GetCodecs->GetProperty(i, NMethodPropID::kName, &prop))
if (prop.vt == VT_BSTR)
info.Name.SetFromWStr_if_Ascii(prop.bstrVal);
else if (prop.vt != VT_EMPTY)
continue;
- RINOK(ReadNumberOfStreams(GetCodecs, i, NMethodPropID::kPackStreams, info.NumStreams));
+ RINOK(ReadNumberOfStreams(GetCodecs, i, NMethodPropID::kPackStreams, info.NumStreams))
{
UInt32 numUnpackStreams = 1;
- RINOK(ReadNumberOfStreams(GetCodecs, i, NMethodPropID::kUnpackStreams, numUnpackStreams));
+ RINOK(ReadNumberOfStreams(GetCodecs, i, NMethodPropID::kUnpackStreams, numUnpackStreams))
if (numUnpackStreams != 1)
continue;
}
- RINOK(ReadIsAssignedProp(GetCodecs, i, NMethodPropID::kEncoderIsAssigned, info.EncoderIsAssigned));
- RINOK(ReadIsAssignedProp(GetCodecs, i, NMethodPropID::kDecoderIsAssigned, info.DecoderIsAssigned));
- RINOK(ReadIsAssignedProp(GetCodecs, i, NMethodPropID::kIsFilter, info.IsFilter));
+ RINOK(ReadIsAssignedProp(GetCodecs, i, NMethodPropID::kEncoderIsAssigned, info.EncoderIsAssigned))
+ RINOK(ReadIsAssignedProp(GetCodecs, i, NMethodPropID::kDecoderIsAssigned, info.DecoderIsAssigned))
+ RINOK(ReadIsAssignedProp(GetCodecs, i, NMethodPropID::kIsFilter, info.IsFilter))
Codecs.Add(info);
}
@@ -133,7 +133,7 @@ HRESULT CExternalCodecs::Load()
{
NWindows::NCOM::CPropVariant prop;
- RINOK(GetHashers->GetHasherProp(i, NMethodPropID::kID, &prop));
+ RINOK(GetHashers->GetHasherProp(i, NMethodPropID::kID, &prop))
if (prop.vt != VT_UI8)
continue;
info.Id = prop.uhVal.QuadPart;
@@ -141,7 +141,7 @@ HRESULT CExternalCodecs::Load()
prop.Clear();
info.Name.Empty();
- RINOK(GetHashers->GetHasherProp(i, NMethodPropID::kName, &prop));
+ RINOK(GetHashers->GetHasherProp(i, NMethodPropID::kName, &prop))
if (prop.vt == VT_BSTR)
info.Name.SetFromWStr_if_Ascii(prop.bstrVal);
else if (prop.vt != VT_EMPTY)
@@ -162,7 +162,8 @@ int FindMethod_Index(
const AString &name,
bool encode,
CMethodId &methodId,
- UInt32 &numStreams)
+ UInt32 &numStreams,
+ bool &isFilter)
{
unsigned i;
for (i = 0; i < g_NumCodecs; i++)
@@ -173,23 +174,25 @@ int FindMethod_Index(
{
methodId = codec.Id;
numStreams = codec.NumStreams;
+ isFilter = codec.IsFilter;
return (int)i;
}
}
- #ifdef EXTERNAL_CODECS
+ #ifdef Z7_EXTERNAL_CODECS
CHECK_GLOBAL_CODECS
- if (__externalCodecs)
- for (i = 0; i < __externalCodecs->Codecs.Size(); i++)
+ if (_externalCodecs)
+ for (i = 0; i < _externalCodecs->Codecs.Size(); i++)
{
- const CCodecInfoEx &codec = __externalCodecs->Codecs[i];
+ const CCodecInfoEx &codec = _externalCodecs->Codecs[i];
if ((encode ? codec.EncoderIsAssigned : codec.DecoderIsAssigned)
&& StringsAreEqualNoCase_Ascii(name, codec.Name))
{
methodId = codec.Id;
numStreams = codec.NumStreams;
+ isFilter = codec.IsFilter;
return (int)(g_NumCodecs + i);
}
}
@@ -212,14 +215,14 @@ static int FindMethod_Index(
return (int)i;
}
- #ifdef EXTERNAL_CODECS
+ #ifdef Z7_EXTERNAL_CODECS
CHECK_GLOBAL_CODECS
- if (__externalCodecs)
- for (i = 0; i < __externalCodecs->Codecs.Size(); i++)
+ if (_externalCodecs)
+ for (i = 0; i < _externalCodecs->Codecs.Size(); i++)
{
- const CCodecInfoEx &codec = __externalCodecs->Codecs[i];
+ const CCodecInfoEx &codec = _externalCodecs->Codecs[i];
if (codec.Id == methodId && (encode ? codec.EncoderIsAssigned : codec.DecoderIsAssigned))
return (int)(g_NumCodecs + i);
}
@@ -248,14 +251,14 @@ bool FindMethod(
}
}
- #ifdef EXTERNAL_CODECS
+ #ifdef Z7_EXTERNAL_CODECS
CHECK_GLOBAL_CODECS
- if (__externalCodecs)
- for (i = 0; i < __externalCodecs->Codecs.Size(); i++)
+ if (_externalCodecs)
+ for (i = 0; i < _externalCodecs->Codecs.Size(); i++)
{
- const CCodecInfoEx &codec = __externalCodecs->Codecs[i];
+ const CCodecInfoEx &codec = _externalCodecs->Codecs[i];
if (methodId == codec.Id)
{
name = codec.Name;
@@ -284,14 +287,14 @@ bool FindHashMethod(
}
}
- #ifdef EXTERNAL_CODECS
+ #ifdef Z7_EXTERNAL_CODECS
CHECK_GLOBAL_CODECS
- if (__externalCodecs)
- for (i = 0; i < __externalCodecs->Hashers.Size(); i++)
+ if (_externalCodecs)
+ for (i = 0; i < _externalCodecs->Hashers.Size(); i++)
{
- const CHasherInfoEx &codec = __externalCodecs->Hashers[i];
+ const CHasherInfoEx &codec = _externalCodecs->Hashers[i];
if (StringsAreEqualNoCase_Ascii(name, codec.Name))
{
methodId = codec.Id;
@@ -313,13 +316,13 @@ void GetHashMethods(
for (i = 0; i < g_NumHashers; i++)
methods[i] = (*g_Hashers[i]).Id;
- #ifdef EXTERNAL_CODECS
+ #ifdef Z7_EXTERNAL_CODECS
CHECK_GLOBAL_CODECS
- if (__externalCodecs)
- for (i = 0; i < __externalCodecs->Hashers.Size(); i++)
- methods.Add(__externalCodecs->Hashers[i].Id);
+ if (_externalCodecs)
+ for (i = 0; i < _externalCodecs->Hashers.Size(); i++)
+ methods.Add(_externalCodecs->Hashers[i].Id);
#endif
}
@@ -364,17 +367,17 @@ HRESULT CreateCoder_Index(
}
}
- #ifdef EXTERNAL_CODECS
+ #ifdef Z7_EXTERNAL_CODECS
CHECK_GLOBAL_CODECS
- if (__externalCodecs)
+ if (_externalCodecs)
{
i -= g_NumCodecs;
cod.IsExternal = true;
- if (i < __externalCodecs->Codecs.Size())
+ if (i < _externalCodecs->Codecs.Size())
{
- const CCodecInfoEx &codec = __externalCodecs->Codecs[i];
+ const CCodecInfoEx &codec = _externalCodecs->Codecs[i];
// if (codec.Id == methodId)
{
if (encode)
@@ -383,15 +386,15 @@ HRESULT CreateCoder_Index(
{
if (codec.NumStreams == 1)
{
- HRESULT res = __externalCodecs->GetCodecs->CreateEncoder(i, &IID_ICompressCoder, (void **)&cod.Coder);
+ const HRESULT res = _externalCodecs->GetCodecs->CreateEncoder(i, &IID_ICompressCoder, (void **)&cod.Coder);
if (res != S_OK && res != E_NOINTERFACE && res != CLASS_E_CLASSNOTAVAILABLE)
return res;
if (cod.Coder)
return res;
- return __externalCodecs->GetCodecs->CreateEncoder(i, &IID_ICompressFilter, (void **)&filter);
+ return _externalCodecs->GetCodecs->CreateEncoder(i, &IID_ICompressFilter, (void **)&filter);
}
cod.NumStreams = codec.NumStreams;
- return __externalCodecs->GetCodecs->CreateEncoder(i, &IID_ICompressCoder2, (void **)&cod.Coder2);
+ return _externalCodecs->GetCodecs->CreateEncoder(i, &IID_ICompressCoder2, (void **)&cod.Coder2);
}
}
else
@@ -399,15 +402,15 @@ HRESULT CreateCoder_Index(
{
if (codec.NumStreams == 1)
{
- HRESULT res = __externalCodecs->GetCodecs->CreateDecoder(i, &IID_ICompressCoder, (void **)&cod.Coder);
+ const HRESULT res = _externalCodecs->GetCodecs->CreateDecoder(i, &IID_ICompressCoder, (void **)&cod.Coder);
if (res != S_OK && res != E_NOINTERFACE && res != CLASS_E_CLASSNOTAVAILABLE)
return res;
if (cod.Coder)
return res;
- return __externalCodecs->GetCodecs->CreateDecoder(i, &IID_ICompressFilter, (void **)&filter);
+ return _externalCodecs->GetCodecs->CreateDecoder(i, &IID_ICompressFilter, (void **)&filter);
}
cod.NumStreams = codec.NumStreams;
- return __externalCodecs->GetCodecs->CreateDecoder(i, &IID_ICompressCoder2, (void **)&cod.Coder2);
+ return _externalCodecs->GetCodecs->CreateDecoder(i, &IID_ICompressCoder2, (void **)&cod.Coder2);
}
}
}
@@ -424,7 +427,7 @@ HRESULT CreateCoder_Index(
CCreatedCoder &cod)
{
CMyComPtr<ICompressFilter> filter;
- HRESULT res = CreateCoder_Index(
+ const HRESULT res = CreateCoder_Index(
EXTERNAL_CODECS_LOC_VARS
index, encode,
filter, cod);
@@ -447,7 +450,7 @@ HRESULT CreateCoder_Id(
CMyComPtr<ICompressFilter> &filter,
CCreatedCoder &cod)
{
- int index = FindMethod_Index(EXTERNAL_CODECS_LOC_VARS methodId, encode);
+ const int index = FindMethod_Index(EXTERNAL_CODECS_LOC_VARS methodId, encode);
if (index < 0)
return S_OK;
return CreateCoder_Index(EXTERNAL_CODECS_LOC_VARS (unsigned)index, encode, filter, cod);
@@ -460,7 +463,7 @@ HRESULT CreateCoder_Id(
CCreatedCoder &cod)
{
CMyComPtr<ICompressFilter> filter;
- HRESULT res = CreateCoder_Id(
+ const HRESULT res = CreateCoder_Id(
EXTERNAL_CODECS_LOC_VARS
methodId, encode,
filter, cod);
@@ -483,7 +486,7 @@ HRESULT CreateCoder_Id(
CMyComPtr<ICompressCoder> &coder)
{
CCreatedCoder cod;
- HRESULT res = CreateCoder_Id(
+ const HRESULT res = CreateCoder_Id(
EXTERNAL_CODECS_LOC_VARS
methodId, encode,
cod);
@@ -524,18 +527,18 @@ HRESULT CreateHasher(
}
}
- #ifdef EXTERNAL_CODECS
+ #ifdef Z7_EXTERNAL_CODECS
CHECK_GLOBAL_CODECS
- if (!hasher && __externalCodecs)
- for (i = 0; i < __externalCodecs->Hashers.Size(); i++)
+ if (!hasher && _externalCodecs)
+ for (i = 0; i < _externalCodecs->Hashers.Size(); i++)
{
- const CHasherInfoEx &codec = __externalCodecs->Hashers[i];
+ const CHasherInfoEx &codec = _externalCodecs->Hashers[i];
if (codec.Id == methodId)
{
name = codec.Name;
- return __externalCodecs->GetHashers->CreateHasher((UInt32)i, &hasher);
+ return _externalCodecs->GetHashers->CreateHasher((UInt32)i, &hasher);
}
}