Commit 4204b59b authored by Steve Lhomme's avatar Steve Lhomme

libebml2: add EBML_ElementClassID() helper

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/foundation_src@596 a6f86f6d-0131-4f8e-9e7b-e335508773d5
parent d61a9519
...@@ -224,6 +224,8 @@ EBML_DLL bool_t EBML_ElementIsFiniteSize(const ebml_element *Element); ...@@ -224,6 +224,8 @@ EBML_DLL bool_t EBML_ElementIsFiniteSize(const ebml_element *Element);
EBML_DLL void EBML_ElementSetInfiniteSize(const ebml_element *Element, bool_t Set); EBML_DLL void EBML_ElementSetInfiniteSize(const ebml_element *Element, bool_t Set);
EBML_DLL bool_t EBML_ElementInfiniteForceSize(ebml_element *Element, filepos_t NewSize); EBML_DLL bool_t EBML_ElementInfiniteForceSize(ebml_element *Element, filepos_t NewSize);
EBML_DLL bool_t EBML_ElementIsDummy(const ebml_element *Element); EBML_DLL bool_t EBML_ElementIsDummy(const ebml_element *Element);
EBML_DLL fourcc_t EBML_ElementClassID(const ebml_element *Element);
static INLINE filepos_t EBML_ElementPositionData(const ebml_element *Element) static INLINE filepos_t EBML_ElementPositionData(const ebml_element *Element)
{ {
if (!EBML_ElementIsFiniteSize(Element)) if (!EBML_ElementIsFiniteSize(Element))
......
...@@ -132,6 +132,11 @@ filepos_t EBML_ElementFullSize(const ebml_element *Element, bool_t bWithDefault) ...@@ -132,6 +132,11 @@ filepos_t EBML_ElementFullSize(const ebml_element *Element, bool_t bWithDefault)
return Element->DataSize + GetIdLength(Element->Context->Id) + EBML_CodedSizeLength(Element->DataSize, Element->SizeLength, EBML_ElementIsFiniteSize(Element)); return Element->DataSize + GetIdLength(Element->Context->Id) + EBML_CodedSizeLength(Element->DataSize, Element->SizeLength, EBML_ElementIsFiniteSize(Element));
} }
fourcc_t EBML_ElementClassID(const ebml_element *Element)
{
return Element->Context->Id;
}
bool_t EBML_ElementInfiniteForceSize(ebml_element *Element, filepos_t NewSize) bool_t EBML_ElementInfiniteForceSize(ebml_element *Element, filepos_t NewSize)
{ {
int OldSizeLen; int OldSizeLen;
......
...@@ -194,7 +194,7 @@ static ebml_element *OutputElement(ebml_element *Element, const ebml_parser_cont ...@@ -194,7 +194,7 @@ static ebml_element *OutputElement(ebml_element *Element, const ebml_parser_cont
} }
else if (EBML_ElementIsDummy(Element)) else if (EBML_ElementIsDummy(Element))
{ {
fprintf(stdout,"[%X] [%"PRId64" bytes]",Element->Context->Id,Element->DataSize); fprintf(stdout,"[%X] [%"PRId64" bytes]",EBML_ElementClassID(Element),Element->DataSize);
EBML_ElementSkipData(Element, Input, Context, NULL, 0); EBML_ElementSkipData(Element, Input, Context, NULL, 0);
EndLine(Element); EndLine(Element);
} }
...@@ -234,14 +234,14 @@ static ebml_element *OutputElement(ebml_element *Element, const ebml_parser_cont ...@@ -234,14 +234,14 @@ static ebml_element *OutputElement(ebml_element *Element, const ebml_parser_cont
#ifdef IS_BIG_ENDIAN #ifdef IS_BIG_ENDIAN
fprintf(stdout,"<unsupported element %x>\r\n",Element->Context->Id); fprintf(stdout,"<unsupported element %x>\r\n",Element->Context->Id);
#else #else
fourcc_t Id = Element->Context->Id; fourcc_t Id = EBML_ElementClassID(Element);
fprintf(stdout,"<unsupported element "); fprintf(stdout,"<unsupported element ");
while (Id & 0xFF) while (Id & 0xFF)
{ {
fprintf(stdout,"[%x]",Id & 0xFF); fprintf(stdout,"[%x]",Id & 0xFF);
Id >>= 8; Id >>= 8;
} }
fprintf(stdout,">",Element->Context->Id); fprintf(stdout,">",EBML_ElementClassID(Element));
#endif #endif
EBML_ElementSkipData(Element, Input, Context, NULL, 0); EBML_ElementSkipData(Element, Input, Context, NULL, 0);
EndLine(Element); EndLine(Element);
......
...@@ -177,7 +177,7 @@ static filepos_t CheckUnknownElements(ebml_element *Elt) ...@@ -177,7 +177,7 @@ static filepos_t CheckUnknownElements(ebml_element *Elt)
if (Node_IsPartOf(SubElt,EBML_DUMMY_ID)) if (Node_IsPartOf(SubElt,EBML_DUMMY_ID))
{ {
EBML_ElementGetName(Elt,String,TSIZEOF(String)); EBML_ElementGetName(Elt,String,TSIZEOF(String));
EBML_IdToString(IdStr,TSIZEOF(IdStr),SubElt->Context->Id); EBML_IdToString(IdStr,TSIZEOF(IdStr),EBML_ElementClassID(SubElt));
OutputError(12,T("Unknown element in %s %s at %") TPRId64 T(" (size %") TPRId64 T(")"),String,IdStr,SubElt->ElementPosition,SubElt->DataSize); OutputError(12,T("Unknown element in %s %s at %") TPRId64 T(" (size %") TPRId64 T(")"),String,IdStr,SubElt->ElementPosition,SubElt->DataSize);
} }
else if (Node_IsPartOf(SubElt,EBML_VOID_CLASS)) else if (Node_IsPartOf(SubElt,EBML_VOID_CLASS))
...@@ -1246,7 +1246,7 @@ int main(int argc, const char *argv[]) ...@@ -1246,7 +1246,7 @@ int main(int argc, const char *argv[])
if (Node_IsPartOf(RLevel1,EBML_DUMMY_ID)) if (Node_IsPartOf(RLevel1,EBML_DUMMY_ID))
{ {
tchar_t Id[32]; tchar_t Id[32];
EBML_IdToString(Id,TSIZEOF(Id),RLevel1->Base.Context->Id); EBML_IdToString(Id,TSIZEOF(Id),EBML_ElementClassID((ebml_element*)RLevel1));
Result |= OutputError(0x80,T("Unknown element %s at %") TPRId64 T(" size %") TPRId64 T(""),Id,RLevel1->Base.ElementPosition,RLevel1->Base.DataSize); Result |= OutputError(0x80,T("Unknown element %s at %") TPRId64 T(" size %") TPRId64 T(""),Id,RLevel1->Base.ElementPosition,RLevel1->Base.DataSize);
} }
if (Node_IsPartOf(RLevel1,EBML_VOID_CLASS)) if (Node_IsPartOf(RLevel1,EBML_VOID_CLASS))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment