diff --git a/ebml/EbmlElement.h b/ebml/EbmlElement.h index 488bb783..645eeeed 100644 --- a/ebml/EbmlElement.h +++ b/ebml/EbmlElement.h @@ -632,7 +632,7 @@ class EBML_DLL_API EbmlElement { \return a DummyRawElement if the element is unknown or nullptr if the element dummy is not allowed */ static EbmlElement *CreateElementUsingContext(const EbmlId & aID, const EbmlSemanticContext & Context, int & LowLevel, bool IsGlobalContext, - bool AsInfiniteSize, + std::uint64_t WithSize, bool AsInfiniteSize, bool bAllowDummy = false, unsigned int MaxLowerLevel = 1); filepos_t RenderHead(IOCallback & output, bool bForceRender, const ShouldWrite& writeFilter = WriteSkipDefault, bool bKeepPosition = false); diff --git a/src/EbmlElement.cpp b/src/EbmlElement.cpp index b5c0172c..a0f096f0 100644 --- a/src/EbmlElement.cpp +++ b/src/EbmlElement.cpp @@ -317,7 +317,7 @@ EbmlElement * EbmlElement::FindNextElement(IOCallback & DataStream, const EbmlSe if (bFound) { // find the element in the context and use the correct creator const auto PossibleID = EbmlId(EbmlId::FromBuffer(PossibleIdNSize.data(), PossibleID_Length)); - EbmlElement * Result = CreateElementUsingContext(PossibleID, Context, UpperLevel, false, SizeFound == SizeUnknown, AllowDummyElt, MaxLowerLevel); + EbmlElement * Result = CreateElementUsingContext(PossibleID, Context, UpperLevel, false, SizeFound, SizeFound == SizeUnknown, AllowDummyElt, MaxLowerLevel); ///< \todo continue is misplaced if (Result != nullptr) { if (AllowDummyElt || !Result->IsDummy()) { @@ -413,7 +413,7 @@ EbmlElement * EbmlElement::SkipData(EbmlStream & DataStream, const EbmlSemanticC EbmlElement *EbmlElement::CreateElementUsingContext(const EbmlId & aID, const EbmlSemanticContext & Context, int & LowLevel, bool IsGlobalContext, - bool AsInfiniteSize, + std::uint64_t WithSize, bool AsInfiniteSize, bool bAllowDummy, unsigned int MaxLowerLevel) { EbmlElement *Result = nullptr; @@ -421,7 +421,7 @@ EbmlElement *EbmlElement::CreateElementUsingContext(const EbmlId & aID, const Eb // elements at the current level for (unsigned int ContextIndex = 0; ContextIndex < EBML_CTX_SIZE(Context); ContextIndex++) { if (aID == EBML_CTX_IDX_ID(Context,ContextIndex)) { - if (AsInfiniteSize && !EBML_CTX_IDX_INFO(Context,ContextIndex).CanHaveInfiniteSize()) + if (!EBML_CTX_IDX_INFO(Context,ContextIndex).IsSizeValid(WithSize, AsInfiniteSize)) return nullptr; Result = &EBML_SEM_CREATE(EBML_CTX_IDX(Context,ContextIndex)); Result->SetSizeInfinite(AsInfiniteSize); @@ -436,7 +436,7 @@ EbmlElement *EbmlElement::CreateElementUsingContext(const EbmlId & aID, const Eb LowLevel--; MaxLowerLevel--; // recursive is good, but be carefull... - Result = CreateElementUsingContext(aID, tstContext, LowLevel, true, AsInfiniteSize, bAllowDummy, MaxLowerLevel); + Result = CreateElementUsingContext(aID, tstContext, LowLevel, true, WithSize, AsInfiniteSize, bAllowDummy, MaxLowerLevel); if (Result != nullptr) { return Result; } @@ -449,7 +449,7 @@ EbmlElement *EbmlElement::CreateElementUsingContext(const EbmlId & aID, const Eb // parent elements if (EBML_CTX_MASTER(Context) != nullptr && aID == EBML_INFO_ID(*EBML_CTX_MASTER(Context))) { auto Callbacks = *EBML_CTX_MASTER(Context); - if (AsInfiniteSize && !Callbacks.CanHaveInfiniteSize()) + if (!Callbacks.IsSizeValid(WithSize, AsInfiniteSize)) return nullptr; LowLevel++; // already one level up (same as context) Result = &EBML_INFO_CREATE(Callbacks); @@ -461,7 +461,7 @@ EbmlElement *EbmlElement::CreateElementUsingContext(const EbmlId & aID, const Eb if (EBML_CTX_PARENT(Context) != nullptr) { LowLevel++; MaxLowerLevel++; - return CreateElementUsingContext(aID, *EBML_CTX_PARENT(Context), LowLevel, IsGlobalContext, AsInfiniteSize, bAllowDummy, MaxLowerLevel); + return CreateElementUsingContext(aID, *EBML_CTX_PARENT(Context), LowLevel, IsGlobalContext, WithSize, AsInfiniteSize, bAllowDummy, MaxLowerLevel); } if (!IsGlobalContext && bAllowDummy && !AsInfiniteSize) {