Commit 853d39e8 authored by Steve Lhomme's avatar Steve Lhomme

libebml2: add a EBML_ElementDataSize() helper function

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/foundation_src@603 a6f86f6d-0131-4f8e-9e7b-e335508773d5
parent 87ffecd1
......@@ -230,6 +230,8 @@ EBML_DLL filepos_t EBML_ElementPosition(const ebml_element *Element);
EBML_DLL filepos_t EBML_ElementPositionData(const ebml_element *Element);
EBML_DLL filepos_t EBML_ElementPositionEnd(const ebml_element *Element);
EBML_DLL filepos_t EBML_ElementDataSize(const ebml_element *Element, bool_t bWithDefault);
#if defined(CONFIG_EBML_WRITING)
// TODO: replace the list of bools by flags ?
EBML_DLL err_t EBML_ElementRender(ebml_element *Element, stream *Output, bool_t bWithDefault, bool_t bKeepPosition, bool_t bForceRender, filepos_t *Rendered);
......
......@@ -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));
}
filepos_t EBML_ElementDataSize(const ebml_element *Element, bool_t bWithDefault)
{
return Element->DataSize;
}
fourcc_t EBML_ElementClassID(const ebml_element *Element)
{
return Element->Context->Id;
......
......@@ -296,7 +296,7 @@ static err_t ReadData(ebml_master *Element, stream *Input, const ebml_parser_con
Node_GET(Input,MEMSTREAM_OFFSET,&OffSet);
Node_GET(Input,MEMSTREAM_PTR,&CRCData);
CRCData += (DataPos - OffSet);
CRCDataSize = Element->Base.DataSize - EBML_ElementFullSize(SubElement,0);
CRCDataSize = (size_t)(EBML_ElementDataSize((ebml_element*)Element,1) - EBML_ElementFullSize(SubElement,1));
Stream_Read(Input, CRCData, CRCDataSize, NULL);
}
else
......
......@@ -117,12 +117,12 @@ static ebml_element *OutputElement(ebml_element *Element, const ebml_parser_cont
ebml_element *SubElement,*NewElement;
ebml_parser_context SubContext;
if (Element->DataSize == INVALID_FILEPOS_T)
if (EBML_ElementDataSize(Element, 1) == INVALID_FILEPOS_T)
fprintf(stdout,"(master)");
else if (!EBML_ElementIsFiniteSize(Element))
fprintf(stdout,"(master) [unknown size]",Element->DataSize);
fprintf(stdout,"(master) [unknown size]",EBML_ElementDataSize(Element, 1));
else
fprintf(stdout,"(master) [%"PRId64" bytes]",Element->DataSize);
fprintf(stdout,"(master) [%"PRId64" bytes]",EBML_ElementDataSize(Element, 1));
EndLine(Element);
SubContext.UpContext = Context;
SubContext.Context = Element->Context;
......@@ -194,7 +194,7 @@ static ebml_element *OutputElement(ebml_element *Element, const ebml_parser_cont
}
else if (EBML_ElementIsDummy(Element))
{
fprintf(stdout,"[%X] [%"PRId64" bytes]",EBML_ElementClassID(Element),Element->DataSize);
fprintf(stdout,"[%X] [%"PRId64" bytes]",EBML_ElementClassID(Element),EBML_ElementDataSize(Element, 1));
EBML_ElementSkipData(Element, Input, Context, NULL, 0);
EndLine(Element);
}
......@@ -203,18 +203,18 @@ static ebml_element *OutputElement(ebml_element *Element, const ebml_parser_cont
if (EBML_ElementReadData(Element,Input,NULL,0,SCOPE_PARTIAL_DATA,0)==ERR_NONE)
{
uint8_t *Data = ARRAYBEGIN(((ebml_binary*)Element)->Data,uint8_t);
if (Element->DataSize != 0)
if (EBML_ElementDataSize(Element, 1) != 0)
{
if (Element->DataSize == 1)
fprintf(stdout,"%02X (%"PRId64")",Data[0],Element->DataSize);
else if (Element->DataSize == 2)
fprintf(stdout,"%02X %02X (%"PRId64")",Data[0],Data[1],Element->DataSize);
else if (Element->DataSize == 3)
fprintf(stdout,"%02X %02X %02X (%"PRId64")",Data[0],Data[1],Data[2],Element->DataSize);
else if (Element->DataSize == 4)
fprintf(stdout,"%02X %02X %02X %02X (%"PRId64")",Data[0],Data[1],Data[2],Data[3],Element->DataSize);
if (EBML_ElementDataSize(Element, 1) == 1)
fprintf(stdout,"%02X (%"PRId64")",Data[0],EBML_ElementDataSize(Element, 1));
else if (EBML_ElementDataSize(Element, 1) == 2)
fprintf(stdout,"%02X %02X (%"PRId64")",Data[0],Data[1],EBML_ElementDataSize(Element, 1));
else if (EBML_ElementDataSize(Element, 1) == 3)
fprintf(stdout,"%02X %02X %02X (%"PRId64")",Data[0],Data[1],Data[2],EBML_ElementDataSize(Element, 1));
else if (EBML_ElementDataSize(Element, 1) == 4)
fprintf(stdout,"%02X %02X %02X %02X (%"PRId64")",Data[0],Data[1],Data[2],Data[3],EBML_ElementDataSize(Element, 1));
else
fprintf(stdout,"%02X %02X %02X %02X.. (%"PRId64")",Data[0],Data[1],Data[2],Data[3],Element->DataSize);
fprintf(stdout,"%02X %02X %02X %02X.. (%"PRId64")",Data[0],Data[1],Data[2],Data[3],EBML_ElementDataSize(Element, 1));
}
}
else
......@@ -224,7 +224,7 @@ static ebml_element *OutputElement(ebml_element *Element, const ebml_parser_cont
}
else if (Node_IsPartOf(Element,EBML_VOID_CLASS))
{
fprintf(stdout,"[%"PRId64" bytes]",Element->DataSize);
fprintf(stdout,"[%"PRId64" bytes]",EBML_ElementDataSize(Element, 1));
EBML_ElementSkipData(Element, Input, Context, NULL, 0);
EndLine(Element);
}
......
This diff is collapsed.
......@@ -57,7 +57,7 @@ static timecode_t ClusterTime = INVALID_TIMECODE_T;
#define EL_Pos(elt) EBML_ElementPosition((const ebml_element*)elt)
#define EL_Int(elt) EBML_IntegerValue((const ebml_integer*)elt)
#define EL_Type(elt, type) (((const ebml_element*)elt)->Context->Id == (type)->Id)
#define EL_DataSize(elt) ((const ebml_element*)elt)->DataSize
#define EL_DataSize(elt) EBML_ElementDataSize((const ebml_element*)elt, 1)
typedef struct track_info
{
......
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