Commit 99909485 authored by Steve Lhomme's avatar Steve Lhomme

libebml2: introduce an ebml_master class to handle its CRC32 value

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/foundation_src@487 a6f86f6d-0131-4f8e-9e7b-e335508773d5
parent 0c4e7ce2
......@@ -152,6 +152,12 @@ typedef struct ebml_element_vmt
#define EBML_ElementCmp(p,e) VMT_FUNC(p,ebml_element_vmt)->Cmp(p,e)
#define EBML_ElementCopy(p,c) VMT_FUNC(p,ebml_element_vmt)->Copy(p,c)
typedef struct ebml_master
{
ebml_element Base;
} ebml_master;
typedef struct ebml_string
{
ebml_element Base;
......@@ -235,19 +241,19 @@ EBML_DLL err_t EBML_ElementRenderHead(ebml_element *Element, stream *Output, boo
#endif
// type specific routines
EBML_DLL ebml_element *EBML_MasterFindFirstElt(ebml_element *Element, const ebml_context *Context, bool_t bCreateIfNull, bool_t SetDefault);
EBML_DLL err_t EBML_MasterAppend(ebml_element *Element, ebml_element *Append);
EBML_DLL err_t EBML_MasterRemove(ebml_element *Element, ebml_element *Remove);
EBML_DLL ebml_element *EBML_MasterFindNextElt(ebml_element *Element, const ebml_element *Current, bool_t bCreateIfNull, bool_t SetDefault);
EBML_DLL ebml_element *EBML_MasterAddElt(ebml_element *Element, const ebml_context *Context, bool_t SetDefault);
EBML_DLL size_t EBML_MasterCount(const ebml_element *Element);
EBML_DLL void EBML_MasterClear(ebml_element *Element); // clear the list (the children and not freed)
EBML_DLL void EBML_MasterErase(ebml_element *Element);
EBML_DLL void EBML_MasterMandatory(ebml_element *Element, bool_t SetDefault); // add the mandatory elements
EBML_DLL bool_t EBML_MasterCheckMandatory(const ebml_element *Element, bool_t SetDefault);
EBML_DLL void EBML_MasterSort(ebml_element *Element, arraycmp Cmp, const void* CmpParam);
EBML_DLL ebml_element *EBML_MasterFindFirstElt(ebml_master *Element, const ebml_context *Context, bool_t bCreateIfNull, bool_t SetDefault);
EBML_DLL err_t EBML_MasterAppend(ebml_master *Element, ebml_element *Append);
EBML_DLL err_t EBML_MasterRemove(ebml_master *Element, ebml_element *Remove);
EBML_DLL ebml_element *EBML_MasterFindNextElt(ebml_master *Element, const ebml_element *Current, bool_t bCreateIfNull, bool_t SetDefault);
EBML_DLL ebml_element *EBML_MasterAddElt(ebml_master *Element, const ebml_context *Context, bool_t SetDefault);
EBML_DLL size_t EBML_MasterCount(const ebml_master *Element);
EBML_DLL void EBML_MasterClear(ebml_master *Element); // clear the list (the children and not freed)
EBML_DLL void EBML_MasterErase(ebml_master *Element);
EBML_DLL void EBML_MasterMandatory(ebml_master *Element, bool_t SetDefault); // add the mandatory elements
EBML_DLL bool_t EBML_MasterCheckMandatory(const ebml_master *Element, bool_t SetDefault);
EBML_DLL void EBML_MasterSort(ebml_master *Element, arraycmp Cmp, const void* CmpParam);
#define EBML_MasterGetChild(e,c) EBML_MasterFindFirstElt(e,c,1,1)
#define EBML_MasterFindChild(e,c) EBML_MasterFindFirstElt((ebml_element*)e,c,0,0)
#define EBML_MasterFindChild(e,c) EBML_MasterFindFirstElt((ebml_master*)e,c,0,0)
#define EBML_MasterChildren(p) ((ebml_element*)NodeTree_Children(p))
#define EBML_MasterNext(p) ((ebml_element*)NodeTree_Next(p))
#define EBML_ElementParent(p) ((ebml_element*)NodeTree_Parent(p))
......
......@@ -226,7 +226,7 @@ ebml_element *EBML_ElementCreate(anynode *Any, const ebml_context *Context, bool
return Result;
}
static ebml_element *CreateElement(anynode *Any, const uint8_t *PossibleId, int8_t IdLength, const ebml_context *Context, ebml_element *Parent)
static ebml_element *CreateElement(anynode *Any, const uint8_t *PossibleId, int8_t IdLength, const ebml_context *Context, ebml_master *Parent)
{
ebml_element *Result;
assert(Context!=NULL);
......
This diff is collapsed.
......@@ -88,22 +88,22 @@ typedef struct matroska_frame
EBML_DLL err_t MATROSKA_LinkMetaSeekElement(matroska_seekpoint *MetaSeek, ebml_element *Link);
EBML_DLL err_t MATROSKA_MetaSeekUpdate(matroska_seekpoint *MetaSeek);
EBML_DLL err_t MATROSKA_LinkClusterReadSegmentInfo(matroska_cluster *Cluster, ebml_element *SegmentInfo, bool_t UseForWriteToo);
EBML_DLL err_t MATROSKA_LinkBlockWithReadTracks(matroska_block *Block, ebml_element *Tracks, bool_t UseForWriteToo);
EBML_DLL err_t MATROSKA_LinkBlockReadTrack(matroska_block *Block, ebml_element *Track, bool_t UseForWriteToo);
EBML_DLL err_t MATROSKA_LinkBlockReadSegmentInfo(matroska_block *Block, ebml_element *SegmentInfo, bool_t UseForWriteToo);
EBML_DLL err_t MATROSKA_LinkClusterReadSegmentInfo(matroska_cluster *Cluster, ebml_master *SegmentInfo, bool_t UseForWriteToo);
EBML_DLL err_t MATROSKA_LinkBlockWithReadTracks(matroska_block *Block, ebml_master *Tracks, bool_t UseForWriteToo);
EBML_DLL err_t MATROSKA_LinkBlockReadTrack(matroska_block *Block, ebml_master *Track, bool_t UseForWriteToo);
EBML_DLL err_t MATROSKA_LinkBlockReadSegmentInfo(matroska_block *Block, ebml_master *SegmentInfo, bool_t UseForWriteToo);
#if defined(CONFIG_EBML_WRITING)
EBML_DLL err_t MATROSKA_LinkClusterWriteSegmentInfo(matroska_cluster *Cluster, ebml_element *SegmentInfo);
EBML_DLL err_t MATROSKA_LinkBlockWithWriteTracks(matroska_block *Block, ebml_element *Tracks);
EBML_DLL err_t MATROSKA_LinkBlockWriteTrack(matroska_block *Block, ebml_element *Track);
EBML_DLL err_t MATROSKA_LinkBlockWriteSegmentInfo(matroska_block *Block, ebml_element *SegmentInfo);
EBML_DLL err_t MATROSKA_LinkClusterWriteSegmentInfo(matroska_cluster *Cluster, ebml_master *SegmentInfo);
EBML_DLL err_t MATROSKA_LinkBlockWithWriteTracks(matroska_block *Block, ebml_master *Tracks);
EBML_DLL err_t MATROSKA_LinkBlockWriteTrack(matroska_block *Block, ebml_master *Track);
EBML_DLL err_t MATROSKA_LinkBlockWriteSegmentInfo(matroska_block *Block, ebml_master *SegmentInfo);
#endif
//EBML_DLL err_t MATROSKA_LinkCueTrack(const ebml_element *Cue, ebml_element *Tracks);
EBML_DLL err_t MATROSKA_LinkCueSegmentInfo(matroska_cuepoint *Cue, ebml_element *SegmentInfo);
EBML_DLL err_t MATROSKA_LinkCueSegmentInfo(matroska_cuepoint *Cue, ebml_master *SegmentInfo);
EBML_DLL err_t MATROSKA_LinkCuePointBlock(matroska_cuepoint *Cue, matroska_block *Block);
EBML_DLL err_t MATROSKA_CuePointUpdate(matroska_cuepoint *Cue, ebml_element *Segment);
EBML_DLL double MATROSKA_TrackTimecodeScale(const ebml_element *Track);
EBML_DLL timecode_t MATROSKA_SegmentInfoTimecodeScale(const ebml_element *SegmentInfo);
EBML_DLL double MATROSKA_TrackTimecodeScale(const ebml_master *Track);
EBML_DLL timecode_t MATROSKA_SegmentInfoTimecodeScale(const ebml_master *SegmentInfo);
EBML_DLL void MATROSKA_ClusterSetTimecode(matroska_cluster *Cluster, timecode_t Timecode);
EBML_DLL err_t MATROSKA_BlockSetTimecode(matroska_block *Block, timecode_t Timecode, timecode_t Relative);
EBML_DLL timecode_t MATROSKA_ClusterTimecode(matroska_cluster *Cluster);
......@@ -117,7 +117,7 @@ EBML_DLL bool_t MATROSKA_BlockLaced(const matroska_block *Block);
EBML_DLL err_t MATROSKA_BlockReadData(matroska_block *Block, stream *Input);
EBML_DLL err_t MATROSKA_BlockReleaseData(matroska_block *Block);
EBML_DLL int16_t MATROSKA_CueTrackNum(const matroska_cuepoint *Cue);
EBML_DLL void MATROSKA_CuesSort(ebml_element *Cues);
EBML_DLL void MATROSKA_CuesSort(ebml_master *Cues);
EBML_DLL fourcc_t MATROSKA_MetaSeekID(const matroska_seekpoint *MetaSeek);
EBML_DLL filepos_t MATROSKA_MetaSeekPosInSegment(const matroska_seekpoint *MetaSeek);
EBML_DLL filepos_t MATROSKA_MetaSeekAbsolutePos(const matroska_seekpoint *MetaSeek);
......@@ -148,7 +148,7 @@ EBML_DLL err_t MATROSKA_BlockAppendFrame(matroska_block *Block, const matroska_f
EBML_DLL matroska_block *MATROSKA_GetBlockForTimecode(matroska_cluster *Cluster, timecode_t Timecode, int16_t Track);
EBML_DLL void MATROSKA_LinkClusterBlocks(matroska_cluster *Cluster, ebml_element *RSegmentInfo, ebml_element *Tracks, bool_t KeepUnmatched);
EBML_DLL void MATROSKA_LinkClusterBlocks(matroska_cluster *Cluster, ebml_master *RSegmentInfo, ebml_master *Tracks, bool_t KeepUnmatched);
// EBML contexts
extern const ebml_context MATROSKA_ContextStream;
......
......@@ -49,10 +49,10 @@ struct matroska_block
array SizeListIn; // int32_t
array Data; // uint8_t
array Durations; // timecode_t
ebml_element *ReadTrack;
ebml_element *ReadSegInfo;
ebml_master *ReadTrack;
ebml_master *ReadSegInfo;
#if defined(CONFIG_EBML_WRITING)
ebml_element *WriteTrack;
ebml_element *WriteSegInfo;
ebml_master *WriteTrack;
ebml_master *WriteSegInfo;
#endif
};
......@@ -68,7 +68,8 @@ static const int A_DTS_freq[16] = {
err_t MATROSKA_BlockProcessFrameDurations(matroska_block *Block, stream *Input)
{
ebml_element *Track=NULL, *Elt;
ebml_master *Track=NULL;
ebml_element *Elt;
tchar_t CodecID[MAXPATH];
err_t Err;
bool_t ReadData;
......@@ -203,7 +204,7 @@ err_t MATROSKA_BlockProcessFrameDurations(matroska_block *Block, stream *Input)
Elt = EBML_MasterFindFirstElt(Track,&MATROSKA_ContextTrackAudio,0,0);
if (Elt)
{
Elt = EBML_MasterFindFirstElt(Elt,&MATROSKA_ContextTrackAudioSamplingFreq,0,0);
Elt = EBML_MasterFindFirstElt((ebml_master*)Elt,&MATROSKA_ContextTrackAudioSamplingFreq,0,0);
if (Elt)
{
ArrayResize(&Block->Durations,sizeof(timecode_t)*ARRAYCOUNT(Block->SizeList,int32_t),0);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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