Commit cb6ee4e8 authored by Steve Lhomme's avatar Steve Lhomme

libebml2: clean the integer/float read/write access

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/foundation_src@608 a6f86f6d-0131-4f8e-9e7b-e335508773d5
parent a8c357c6
......@@ -262,12 +262,11 @@ EBML_DLL bool_t EBML_MasterIsChecksumValid(const ebml_master *Element);
#define EBML_MasterNext(p) ((ebml_element*)NodeTree_Next(p))
#define EBML_ElementParent(p) ((ebml_element*)NodeTree_Parent(p))
#if !defined(NDEBUG)
#define EBML_IntegerValue(p) (assert(((ebml_element*)p)->bValueIsSet), ((ebml_integer*)p)->Value)
#else
#define EBML_IntegerValue(p) ((ebml_integer*)p)->Value
#endif
EBML_DLL err_t EBML_IntegerSetValue(ebml_integer *Element, int64_t Value);
EBML_DLL int64_t EBML_IntegerValue(const ebml_integer *Element);
EBML_DLL void EBML_IntegerSetValue(ebml_integer *Element, int64_t Value);
EBML_DLL double EBML_FloatValue(const ebml_float *Element);
EBML_DLL void EBML_FloatSetValue(ebml_float *Element, double Value);
EBML_DLL err_t EBML_StringSetValue(ebml_string *Element,const char *Value);
#if defined(CONFIG_EBML_UNICODE)
......
......@@ -419,10 +419,32 @@ META_VMT(TYPE_FUNC,ebml_element_vmt,RenderData,RenderDataFloat)
META_VMT(TYPE_FUNC,ebml_element_vmt,Copy,CopyFloat)
META_END(EBML_ELEMENT_CLASS)
err_t EBML_IntegerSetValue(ebml_integer *Element, int64_t Value)
void EBML_IntegerSetValue(ebml_integer *Element, int64_t Value)
{
Element->Value = Value;
Element->Base.bValueIsSet = 1;
Element->Base.bNeedDataSizeUpdate = 1;
return ERR_NONE;
}
\ No newline at end of file
}
int64_t EBML_IntegerValue(const ebml_integer *Element)
{
#if !defined(NDEBUG)
assert(Element->Base.bValueIsSet);
#endif
return Element->Value;
}
double EBML_FloatValue(const ebml_float *Element)
{
#if !defined(NDEBUG)
assert(Element->Base.bValueIsSet);
#endif
return Element->Value;
}
void EBML_FloatSetValue(ebml_float *Element, double Value)
{
Element->Value = Value;
Element->Base.bValueIsSet = 1;
Element->Base.bNeedDataSizeUpdate = 1;
}
......@@ -82,7 +82,7 @@ err_t MATROSKA_BlockProcessFrameDurations(matroska_block *Block, stream *Input)
{
assert(Track!=NULL);
Elt = EBML_MasterFindFirstElt(Track,&MATROSKA_ContextTrackType,0,0);
if (!Elt || EBML_IntegerValue(Elt)!=TRACK_TYPE_AUDIO) // other track types not supported for now
if (!Elt || EBML_IntegerValue((ebml_integer*)Elt)!=TRACK_TYPE_AUDIO) // other track types not supported for now
Err = ERR_INVALID_DATA;
else
{
......
This diff is collapsed.
......@@ -153,8 +153,13 @@ static ebml_element *OutputElement(ebml_element *Element, const ebml_parser_cont
//tchar_t UnicodeString[MAXDATA];
//EBML_StringRead((ebml_string*)Element,Input,UnicodeString,TSIZEOF(UnicodeString));
if (EBML_ElementReadData(Element,Input,NULL,0,SCOPE_ALL_DATA,0)==ERR_NONE)
fprintf(stdout,"'%s'",((ebml_string*)Element)->Buffer);
else
{
tchar_t String[MAXDATA];
char cString[MAXDATA];
EBML_StringGet((ebml_string*)Element, String, TSIZEOF(String));
Node_ToUTF8(Element, cString, sizeof(cString), String);
fprintf(stdout,"'%s'",cString);
} else
fprintf(stdout,"<error reading>");
EndLine(Element);
}
......@@ -176,9 +181,9 @@ static ebml_element *OutputElement(ebml_element *Element, const ebml_parser_cont
if (EBML_ElementReadData(Element,Input,NULL,0,SCOPE_ALL_DATA,0)==ERR_NONE)
{
if (Node_IsPartOf(Element,EBML_SINTEGER_CLASS))
fprintf(stdout,"%"PRId64,EBML_IntegerValue(Element));
fprintf(stdout,"%"PRId64,EBML_IntegerValue((ebml_integer*)Element));
else
fprintf(stdout,"%"PRIu64,EBML_IntegerValue(Element));
fprintf(stdout,"%"PRIu64,EBML_IntegerValue((ebml_integer*)Element));
}
else
fprintf(stdout,"<error reading>");
......@@ -187,7 +192,7 @@ static ebml_element *OutputElement(ebml_element *Element, const ebml_parser_cont
else if (Node_IsPartOf(Element,EBML_FLOAT_CLASS))
{
if (EBML_ElementReadData(Element,Input,NULL,0,SCOPE_ALL_DATA,0)==ERR_NONE)
fprintf(stdout,"%f",((ebml_float*)Element)->Value);
fprintf(stdout,"%f",EBML_FloatValue((ebml_float*)Element));
else
fprintf(stdout,"<error reading>");
EndLine(Element);
......@@ -202,7 +207,7 @@ 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);
const uint8_t *Data = EBML_BinaryGetData((ebml_binary*)Element);
if (EBML_ElementDataSize(Element, 1) != 0)
{
if (EBML_ElementDataSize(Element, 1) == 1)
......
......@@ -1053,7 +1053,7 @@ static int CleanTracks(ebml_master *Tracks, int Profile, ebml_master *Attachment
{
DisplayH = EBML_MasterFindChild((ebml_master*)Elt,&MATROSKA_ContextTrackAudioSamplingFreq);
assert(DisplayH!=NULL);
if (((ebml_float*)Elt2)->Value == ((ebml_float*)DisplayH)->Value)
if (EBML_FloatValue(Elt2) == EBML_FloatValue(DisplayH))
NodeDelete((node*)Elt2);
}
}
......
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