Commit 2c881c32 authored by Steve Lhomme's avatar Steve Lhomme

libmatroska2: partially implement the Block copy (no internal data)

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/foundation_src@389 a6f86f6d-0131-4f8e-9e7b-e335508773d5
parent 4e847327
......@@ -48,8 +48,8 @@ struct matroska_block
array SizeList; // int32_t
array Data; // uint8_t
array Durations; // timecode_t
ebml_element *ReadSegInfo;
ebml_element *ReadTrack;
ebml_element *ReadSegInfo;
#if defined(CONFIG_EBML_WRITING)
ebml_element *WriteTrack;
ebml_element *WriteSegInfo;
......
......@@ -1809,10 +1809,33 @@ failed:
}
#endif
static ebml_element *CopyBlockData(const matroska_block *Element, const void *Cookie)
static matroska_block *CopyBlockData(const matroska_block *Element, const void *Cookie)
{
assert(Element!=NULL); // not supported yet
return NULL;
matroska_block *Result = (matroska_block*)INHERITED(Element,ebml_element_vmt,Node_ClassId(Element))->Copy(Element,Cookie);
if (Result)
{
Result->TrackNumber = Element->TrackNumber;
Result->IsKeyframe = Element->IsKeyframe;
Result->IsDiscardable = Element->IsDiscardable;
Result->Invisible = Element->Invisible;
#if 0
Result->LocalTimecode = Element->LocalTimecode;
Result->LocalTimecodeUsed = Element->LocalTimecodeUsed;
Result->GlobalTimecode = Element->GlobalTimecode;
Result->Lacing = Element->Lacing;
Result->FirstFrameLocation = Element->FirstFrameLocation;
array SizeList = Element->; // int32_t
array Data = Element->; // uint8_t
array Durations = Element->; // timecode_t
#endif
Node_SET(Result,MATROSKA_BLOCK_READ_TRACK,&Element->ReadTrack);
Node_SET(Result,MATROSKA_BLOCK_READ_SEGMENTINFO,&Element->ReadSegInfo);
#if defined(CONFIG_EBML_WRITING)
Node_SET(Result,MATROSKA_BLOCK_WRITE_TRACK,&Element->WriteTrack);
Node_SET(Result,MATROSKA_BLOCK_WRITE_SEGMENTINFO,&Element->WriteSegInfo);
#endif
}
return Result;
}
static filepos_t UpdateBlockSize(matroska_block *Element, bool_t bWithDefault, bool_t bForceRender)
......
......@@ -1593,14 +1593,8 @@ int main(int argc, const char *argv[])
{
if (((ebml_element*)pBlockInfo->Block)->Context->Id == MATROSKA_ContextClusterSimpleBlock.Id)
{
/// \todo use EBML_ElementCopy()
Block1 = (matroska_block*)EBML_ElementCreate(pBlockInfo->Block, &MATROSKA_ContextClusterSimpleBlock, 1, NULL);
MATROSKA_LinkBlockReadTrack(Block1,MATROSKA_BlockReadTrack(pBlockInfo->Block),0);
MATROSKA_LinkBlockWriteTrack(Block1,MATROSKA_BlockWriteTrack(pBlockInfo->Block));
MATROSKA_LinkBlockReadSegmentInfo(Block1,RSegmentInfo,0);
Block1 = (matroska_block*)EBML_ElementCopy(pBlockInfo->Block, NULL);
MATROSKA_LinkBlockWriteSegmentInfo(Block1,WSegmentInfo);
MATROSKA_BlockSetKeyframe(Block1,MATROSKA_BlockKeyframe(pBlockInfo->Block));
MATROSKA_BlockSetDiscardable(Block1,MATROSKA_BlockDiscardable(pBlockInfo->Block));
for (; pBlockInfo->FrameStart < MATROSKA_BlockGetFrameCount(pBlockInfo->Block); ++pBlockInfo->FrameStart)
{
......@@ -1625,15 +1619,9 @@ int main(int argc, const char *argv[])
}
else if (((ebml_element*)pBlockInfo->Block)->Context->Id == MATROSKA_ContextClusterBlock.Id)
{
/// \todo use EBML_ElementCopy()
Elt = EBML_ElementCreate(pBlockInfo->Block, &MATROSKA_ContextClusterBlockGroup, 1, NULL);
Elt = EBML_ElementCopy(pBlockInfo->Block, NULL);
Block1 = (matroska_block*)EBML_MasterFindFirstElt(Elt, &MATROSKA_ContextClusterBlock, 0, 0);
MATROSKA_LinkBlockReadTrack(Block1,MATROSKA_BlockReadTrack(pBlockInfo->Block),0);
MATROSKA_LinkBlockWriteTrack(Block1,MATROSKA_BlockWriteTrack(pBlockInfo->Block));
MATROSKA_LinkBlockReadSegmentInfo(Block1,RSegmentInfo,0);
MATROSKA_LinkBlockWriteSegmentInfo(Block1,WSegmentInfo);
MATROSKA_BlockSetKeyframe(Block1,MATROSKA_BlockKeyframe(pBlockInfo->Block));
MATROSKA_BlockSetDiscardable(Block1,MATROSKA_BlockDiscardable(pBlockInfo->Block));
for (; pBlockInfo->FrameStart < MATROSKA_BlockGetFrameCount(pBlockInfo->Block); ++pBlockInfo->FrameStart)
{
......@@ -1668,14 +1656,8 @@ int main(int argc, const char *argv[])
{
// This block needs to be split
MATROSKA_BlockReadData(pBlockInfo->Block,Input);
/// \todo use EBML_ElementCopy()
Block1 = (matroska_block*)EBML_ElementCreate(pBlockInfo->Block, &MATROSKA_ContextClusterSimpleBlock, 1, NULL);
MATROSKA_LinkBlockReadTrack(Block1,MATROSKA_BlockReadTrack(pBlockInfo->Block),0);
MATROSKA_LinkBlockWriteTrack(Block1,MATROSKA_BlockWriteTrack(pBlockInfo->Block));
MATROSKA_LinkBlockReadSegmentInfo(Block1,RSegmentInfo,0);
Block1 = (matroska_block*)EBML_ElementCopy(pBlockInfo->Block, NULL);
MATROSKA_LinkBlockWriteSegmentInfo(Block1,WSegmentInfo);
MATROSKA_BlockSetKeyframe(Block1,MATROSKA_BlockKeyframe(pBlockInfo->Block));
MATROSKA_BlockSetDiscardable(Block1,MATROSKA_BlockDiscardable(pBlockInfo->Block));
for (; pBlockInfo->FrameStart < MATROSKA_BlockGetFrameCount(pBlockInfo->Block); ++pBlockInfo->FrameStart)
{
......@@ -1704,15 +1686,9 @@ int main(int argc, const char *argv[])
assert(((ebml_element*)pBlockInfo->Block)->Context->Id == MATROSKA_ContextClusterBlock.Id);
// This block needs to be split
MATROSKA_BlockReadData(pBlockInfo->Block,Input);
/// \todo use EBML_ElementCopy()
Elt = EBML_ElementCreate(pBlockInfo->Block, &MATROSKA_ContextClusterBlockGroup, 1, NULL);
Elt = EBML_ElementCopy(pBlockInfo->Block, NULL);
Block1 = (matroska_block*)EBML_MasterFindFirstElt(Elt, &MATROSKA_ContextClusterBlock, 0, 0);
MATROSKA_LinkBlockReadTrack(Block1,MATROSKA_BlockReadTrack(pBlockInfo->Block),0);
MATROSKA_LinkBlockWriteTrack(Block1,MATROSKA_BlockWriteTrack(pBlockInfo->Block));
MATROSKA_LinkBlockReadSegmentInfo(Block1,RSegmentInfo,0);
MATROSKA_LinkBlockWriteSegmentInfo(Block1,WSegmentInfo);
MATROSKA_BlockSetKeyframe(Block1,MATROSKA_BlockKeyframe(pBlockInfo->Block));
MATROSKA_BlockSetDiscardable(Block1,MATROSKA_BlockDiscardable(pBlockInfo->Block));
for (; pBlockInfo->FrameStart < MATROSKA_BlockGetFrameCount(pBlockInfo->Block); ++pBlockInfo->FrameStart)
{
......
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