This commit is contained in:
Igor Pavlov
2018-03-12 11:19:17 +00:00
committed by Kornel
parent 866a06f5a0
commit f19b649c73
81 changed files with 8243 additions and 1296 deletions

View File

@@ -148,20 +148,23 @@ HRESULT CExternalCodecs::Load()
#endif
bool FindMethod(
int FindMethod_Index(
DECL_EXTERNAL_CODECS_LOC_VARS
const AString &name,
CMethodId &methodId, UInt32 &numStreams)
bool encode,
CMethodId &methodId,
UInt32 &numStreams)
{
unsigned i;
for (i = 0; i < g_NumCodecs; i++)
{
const CCodecInfo &codec = *g_Codecs[i];
if (StringsAreEqualNoCase_Ascii(name, codec.Name))
if ((encode ? codec.CreateEncoder : codec.CreateDecoder)
&& StringsAreEqualNoCase_Ascii(name, codec.Name))
{
methodId = codec.Id;
numStreams = codec.NumStreams;
return true;
return i;
}
}
@@ -173,19 +176,51 @@ bool FindMethod(
for (i = 0; i < __externalCodecs->Codecs.Size(); i++)
{
const CCodecInfoEx &codec = __externalCodecs->Codecs[i];
if (StringsAreEqualNoCase_Ascii(name, codec.Name))
if ((encode ? codec.EncoderIsAssigned : codec.DecoderIsAssigned)
&& StringsAreEqualNoCase_Ascii(name, codec.Name))
{
methodId = codec.Id;
numStreams = codec.NumStreams;
return true;
return g_NumCodecs + i;
}
}
#endif
return false;
return -1;
}
static int FindMethod_Index(
DECL_EXTERNAL_CODECS_LOC_VARS
CMethodId methodId, bool encode)
{
unsigned i;
for (i = 0; i < g_NumCodecs; i++)
{
const CCodecInfo &codec = *g_Codecs[i];
if (codec.Id == methodId && (encode ? codec.CreateEncoder : codec.CreateDecoder))
return i;
}
#ifdef EXTERNAL_CODECS
CHECK_GLOBAL_CODECS
if (__externalCodecs)
for (i = 0; i < __externalCodecs->Codecs.Size(); i++)
{
const CCodecInfoEx &codec = __externalCodecs->Codecs[i];
if (codec.Id == methodId && (encode ? codec.EncoderIsAssigned : codec.DecoderIsAssigned))
return g_NumCodecs + i;
}
#endif
return -1;
}
bool FindMethod(
DECL_EXTERNAL_CODECS_LOC_VARS
CMethodId methodId,
@@ -280,9 +315,11 @@ void GetHashMethods(
#endif
}
HRESULT CreateCoder(
HRESULT CreateCoder_Index(
DECL_EXTERNAL_CODECS_LOC_VARS
CMethodId methodId, bool encode,
unsigned i, bool encode,
CMyComPtr<ICompressFilter> &filter,
CCreatedCoder &cod)
{
@@ -290,11 +327,10 @@ HRESULT CreateCoder(
cod.IsFilter = false;
cod.NumStreams = 1;
unsigned i;
for (i = 0; i < g_NumCodecs; i++)
if (i < g_NumCodecs)
{
const CCodecInfo &codec = *g_Codecs[i];
if (codec.Id == methodId)
// if (codec.Id == methodId)
{
if (encode)
{
@@ -325,11 +361,12 @@ HRESULT CreateCoder(
if (__externalCodecs)
{
i -= g_NumCodecs;
cod.IsExternal = true;
for (i = 0; i < __externalCodecs->Codecs.Size(); i++)
if (i < __externalCodecs->Codecs.Size())
{
const CCodecInfoEx &codec = __externalCodecs->Codecs[i];
if (codec.Id == methodId)
// if (codec.Id == methodId)
{
if (encode)
{
@@ -371,13 +408,50 @@ HRESULT CreateCoder(
return S_OK;
}
HRESULT CreateCoder(
HRESULT CreateCoder_Index(
DECL_EXTERNAL_CODECS_LOC_VARS
unsigned index, bool encode,
CCreatedCoder &cod)
{
CMyComPtr<ICompressFilter> filter;
HRESULT res = CreateCoder_Index(
EXTERNAL_CODECS_LOC_VARS
index, encode,
filter, cod);
if (filter)
{
cod.IsFilter = true;
CFilterCoder *coderSpec = new CFilterCoder(encode);
cod.Coder = coderSpec;
coderSpec->Filter = filter;
}
return res;
}
HRESULT CreateCoder_Id(
DECL_EXTERNAL_CODECS_LOC_VARS
CMethodId methodId, bool encode,
CMyComPtr<ICompressFilter> &filter,
CCreatedCoder &cod)
{
int index = FindMethod_Index(EXTERNAL_CODECS_LOC_VARS methodId, encode);
if (index < 0)
return S_OK;
return CreateCoder_Index(EXTERNAL_CODECS_LOC_VARS index, encode, filter, cod);
}
HRESULT CreateCoder_Id(
DECL_EXTERNAL_CODECS_LOC_VARS
CMethodId methodId, bool encode,
CCreatedCoder &cod)
{
CMyComPtr<ICompressFilter> filter;
HRESULT res = CreateCoder(
HRESULT res = CreateCoder_Id(
EXTERNAL_CODECS_LOC_VARS
methodId, encode,
filter, cod);
@@ -393,13 +467,14 @@ HRESULT CreateCoder(
return res;
}
HRESULT CreateCoder(
HRESULT CreateCoder_Id(
DECL_EXTERNAL_CODECS_LOC_VARS
CMethodId methodId, bool encode,
CMyComPtr<ICompressCoder> &coder)
{
CCreatedCoder cod;
HRESULT res = CreateCoder(
HRESULT res = CreateCoder_Id(
EXTERNAL_CODECS_LOC_VARS
methodId, encode,
cod);
@@ -413,7 +488,7 @@ HRESULT CreateFilter(
CMyComPtr<ICompressFilter> &filter)
{
CCreatedCoder cod;
return CreateCoder(
return CreateCoder_Id(
EXTERNAL_CODECS_LOC_VARS
methodId, encode,
filter, cod);

View File

@@ -116,13 +116,12 @@ extern CExternalCodecs g_ExternalCodecs;
#endif
bool FindMethod(
int FindMethod_Index(
DECL_EXTERNAL_CODECS_LOC_VARS
const AString &name,
CMethodId &methodId, UInt32 &numStreams);
bool encode,
CMethodId &methodId,
UInt32 &numStreams);
bool FindMethod(
DECL_EXTERNAL_CODECS_LOC_VARS
@@ -152,18 +151,29 @@ struct CCreatedCoder
};
HRESULT CreateCoder(
HRESULT CreateCoder_Index(
DECL_EXTERNAL_CODECS_LOC_VARS
unsigned codecIndex, bool encode,
CMyComPtr<ICompressFilter> &filter,
CCreatedCoder &cod);
HRESULT CreateCoder_Index(
DECL_EXTERNAL_CODECS_LOC_VARS
unsigned index, bool encode,
CCreatedCoder &cod);
HRESULT CreateCoder_Id(
DECL_EXTERNAL_CODECS_LOC_VARS
CMethodId methodId, bool encode,
CMyComPtr<ICompressFilter> &filter,
CCreatedCoder &cod);
HRESULT CreateCoder(
HRESULT CreateCoder_Id(
DECL_EXTERNAL_CODECS_LOC_VARS
CMethodId methodId, bool encode,
CCreatedCoder &cod);
HRESULT CreateCoder(
HRESULT CreateCoder_Id(
DECL_EXTERNAL_CODECS_LOC_VARS
CMethodId methodId, bool encode,
CMyComPtr<ICompressCoder> &coder);

View File

@@ -253,6 +253,9 @@ struct CNameToPropID
const char *Name;
};
// the following are related to NCoderPropID::EEnum values
static const CNameToPropID g_NameToPropID[] =
{
{ VT_UI4, "" },
@@ -275,7 +278,8 @@ static const CNameToPropID g_NameToPropID[] =
{ VT_UI8, "expect" },
{ VT_UI4, "b" },
{ VT_UI4, "check" },
{ VT_BSTR, "filter" }
{ VT_BSTR, "filter" },
{ VT_UI8, "memuse" }
};
static int FindPropIdExact(const UString &name)
@@ -293,6 +297,13 @@ static bool ConvertProperty(const PROPVARIANT &srcProp, VARTYPE varType, NCOM::C
destProp = srcProp;
return true;
}
if (varType == VT_UI8 && srcProp.vt == VT_UI4)
{
destProp = (UInt64)srcProp.ulVal;
return true;
}
if (varType == VT_BOOL)
{
bool res;