[matroska] r1221 - in trunk/libmatroska: matroska src
[email protected] Thu, 13 Oct 2005 01:21:03 +0400 (MSD)
| Newsgroups | gmane.comp.multimedia.matroska.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: robux4
Date: 2005-10-13 01:21:00 +0400 (Thu, 13 Oct 2005)
New Revision: 1221
Modified:
trunk/libmatroska/matroska/KaxCluster.h
trunk/libmatroska/src/KaxCluster.cpp
Log:
libmatroska: prepare the cluster to render from KaxBlockBlob
Modified: trunk/libmatroska/matroska/KaxCluster.h
===================================================================
--- trunk/libmatroska/matroska/KaxCluster.h 2005-10-10 20:48:59 UTC (rev 1220)
+++ trunk/libmatroska/matroska/KaxCluster.h 2005-10-12 21:21:00 UTC (rev 1221)
@@ -138,7 +138,11 @@
return FindFirstElt(KaxClusterSilentTracks::ClassInfos, true) != NULL;
}
+ bool AddBlockBlob(KaxBlockBlob * NewBlob);
+
protected:
+ KaxBlockBlob * currentNewBlob;
+ std::vector<KaxBlockBlob*> Blobs;
KaxBlockGroup * currentNewBlock;
const KaxSegment * ParentSegment;
Modified: trunk/libmatroska/src/KaxCluster.cpp
===================================================================
--- trunk/libmatroska/src/KaxCluster.cpp 2005-10-10 20:48:59 UTC (rev 1220)
+++ trunk/libmatroska/src/KaxCluster.cpp 2005-10-12 21:21:00 UTC (rev 1221)
@@ -90,6 +90,12 @@
}
}
+bool KaxCluster::AddBlockBlob(KaxBlockBlob * NewBlob)
+{
+ Blobs.push_back(NewBlob);
+ return true;
+}
+
bool KaxCluster::AddFrameInternal(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, KaxBlockGroup * & MyNewBlock, const KaxBlockGroup * PastBlock, const KaxBlockGroup * ForwBlock, LacingType lacing)
{
if (!bFirstFrameInside) {
@@ -146,16 +152,19 @@
bool KaxCluster::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, KaxBlockGroup * & MyNewBlock, LacingType lacing)
{
+ assert(Blobs.size() == 0); // mutually exclusive for the moment
return AddFrameInternal(track, timecode, buffer, MyNewBlock, NULL, NULL, lacing);
}
bool KaxCluster::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, KaxBlockGroup * & MyNewBlock, const KaxBlockGroup & PastBlock, LacingType lacing)
{
+ assert(Blobs.size() == 0); // mutually exclusive for the moment
return AddFrameInternal(track, timecode, buffer, MyNewBlock, &PastBlock, NULL, lacing);
}
bool KaxCluster::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, KaxBlockGroup * & MyNewBlock, const KaxBlockGroup & PastBlock, const KaxBlockGroup & ForwBlock, LacingType lacing)
{
+ assert(Blobs.size() == 0); // mutually exclusive for the moment
return AddFrameInternal(track, timecode, buffer, MyNewBlock, &PastBlock, &ForwBlock, lacing);
}
@@ -164,49 +173,58 @@
*/
uint32 KaxCluster::Render(IOCallback & output, KaxCues & CueToUpdate, bool bSaveDefault)
{
+ uint32 Result = 0;
+
// update the Timecode of the Cluster before writing
KaxClusterTimecode * Timecode = static_cast<KaxClusterTimecode *>(this->FindElt(KaxClusterTimecode::ClassInfos));
*static_cast<EbmlUInteger *>(Timecode) = GlobalTimecode() / GlobalTimecodeScale();
- size_t TrkIndex, Index;
+ if (Blobs.size() == 0) {
+ // old-school direct KaxBlockGroup
+ size_t TrkIndex, Index;
- // SilentTracks handling
- // check the parent cluster for existing tracks and see if they are contained in this cluster or not
- if (bSilentTracksUsed)
- {
- KaxTracks & MyTracks = *static_cast<KaxTracks *>(ParentSegment->FindElt(KaxTracks::ClassInfos));
- for (TrkIndex = 0; TrkIndex < MyTracks.ListSize(); TrkIndex++) {
- if (EbmlId(*MyTracks[TrkIndex]) == KaxTrackEntry::ClassInfos.GlobalId)
- {
- KaxTrackEntry & entry = *static_cast<KaxTrackEntry *>(MyTracks[TrkIndex]);
- uint32 tracknum = entry.TrackNumber();
- for (Index = 0; Index < ElementList.size(); Index++) {
- if (EbmlId(*ElementList[Index]) == KaxBlockGroup::ClassInfos.GlobalId) {
- KaxBlockGroup & group = *static_cast<KaxBlockGroup *>(ElementList[Index]);
- if (group.TrackNumber() == tracknum)
- break; // this track is used
+ // SilentTracks handling
+ // check the parent cluster for existing tracks and see if they are contained in this cluster or not
+ if (bSilentTracksUsed)
+ {
+ KaxTracks & MyTracks = *static_cast<KaxTracks *>(ParentSegment->FindElt(KaxTracks::ClassInfos));
+ for (TrkIndex = 0; TrkIndex < MyTracks.ListSize(); TrkIndex++) {
+ if (EbmlId(*MyTracks[TrkIndex]) == KaxTrackEntry::ClassInfos.GlobalId)
+ {
+ KaxTrackEntry & entry = *static_cast<KaxTrackEntry *>(MyTracks[TrkIndex]);
+ uint32 tracknum = entry.TrackNumber();
+ for (Index = 0; Index < ElementList.size(); Index++) {
+ if (EbmlId(*ElementList[Index]) == KaxBlockGroup::ClassInfos.GlobalId) {
+ KaxBlockGroup & group = *static_cast<KaxBlockGroup *>(ElementList[Index]);
+ if (group.TrackNumber() == tracknum)
+ break; // this track is used
+ }
}
+ // the track wasn't found in this cluster
+ if (Index == ElementList.size())
+ {
+ KaxClusterSilentTracks * SilentTracks = static_cast<KaxClusterSilentTracks *>(this->FindFirstElt(KaxClusterSilentTracks::ClassInfos));
+ assert(SilentTracks != NULL); // the flag bSilentTracksUsed should be set when creating the Cluster
+ KaxClusterSilentTrackNumber * trackelt = static_cast<KaxClusterSilentTrackNumber *>(SilentTracks->AddNewElt(KaxClusterSilentTrackNumber::ClassInfos));
+ *static_cast<EbmlUInteger *>(trackelt) = tracknum;
+ }
}
- // the track wasn't found in this cluster
- if (Index == ElementList.size())
- {
- KaxClusterSilentTracks * SilentTracks = static_cast<KaxClusterSilentTracks *>(this->FindFirstElt(KaxClusterSilentTracks::ClassInfos));
- assert(SilentTracks != NULL); // the flag bSilentTracksUsed should be set when creating the Cluster
- KaxClusterSilentTrackNumber * trackelt = static_cast<KaxClusterSilentTrackNumber *>(SilentTracks->AddNewElt(KaxClusterSilentTrackNumber::ClassInfos));
- *static_cast<EbmlUInteger *>(trackelt) = tracknum;
- }
}
}
- }
- uint32 Result = EbmlMaster::Render(output, bSaveDefault);
- // For all Blocks add their position on the CueEntry
-
- for (Index = 0; Index < ElementList.size(); Index++) {
- if (EbmlId(*ElementList[Index]) == KaxBlockGroup::ClassInfos.GlobalId) {
- CueToUpdate.PositionSet(*static_cast<const KaxBlockGroup *>(ElementList[Index]));
+ Result = EbmlMaster::Render(output, bSaveDefault);
+ // For all Blocks add their position on the CueEntry
+
+ for (Index = 0; Index < ElementList.size(); Index++) {
+ if (EbmlId(*ElementList[Index]) == KaxBlockGroup::ClassInfos.GlobalId) {
+ CueToUpdate.PositionSet(*static_cast<const KaxBlockGroup *>(ElementList[Index]));
+ }
}
+ } else {
+ // new school, using KaxBlockBlob
+ Blobs.clear();
}
+
return Result;
}