//typedef Track *TrackID;
FileMatroska::FileMatroska(IOCallback & output)
- :myFile(output)
+ :myFile(output)
#ifdef OLD
- ,myCurrReadBlock(NULL)
- ,myMinClusterSize(5*1024) // 5KB is the min size of a cluster
- ,myMaxClusterSize(2*1024*1024) // 2MB is the max size of a cluster
- ,myCurrReadBlockTrack(0)
- ,myCurrWriteCluster(2*1024*1024) // myMaxClusterSize
- ,myCurrReadCluster(NULL)
- ,myReadBlockNumber(0)
+ ,myCurrReadBlock(NULL)
+ ,myMinClusterSize(5*1024) // 5KB is the min size of a cluster
+ ,myMaxClusterSize(2*1024*1024) // 2MB is the max size of a cluster
+ ,myCurrReadBlockTrack(0)
+ ,myCurrWriteCluster(2*1024*1024) // myMaxClusterSize
+ ,myCurrReadCluster(NULL)
+ ,myReadBlockNumber(0)
#endif // OLD
{
#ifdef OLD
- myStreamInfo.MainHeaderSize = TypeHeader::default_size() +
+ myStreamInfo.MainHeaderSize = TypeHeader::default_size() +
ActualHeader::default_size() +
ExtendedInfo::default_size() +
ContentInfo::default_size();
- myStreamInfo.TrackEntrySize = Track::default_size();
- myStreamInfo.BlockHeadSize = BLOCK_HEADER_SIZE;
- myStreamInfo.ClusterHeadSize = CLUSTER_HEADER_SIZE;
- myStreamInfo.ClusterFootSize = CLUSTER_TRAILER_SIZE;
+ myStreamInfo.TrackEntrySize = Track::default_size();
+ myStreamInfo.BlockHeadSize = BLOCK_HEADER_SIZE;
+ myStreamInfo.ClusterHeadSize = CLUSTER_HEADER_SIZE;
+ myStreamInfo.ClusterFootSize = CLUSTER_TRAILER_SIZE;
#endif // OLD
}
FileMatroska::~FileMatroska()
{
-// if (myCurrCluster != NULL)
-// throw 0; // there are some data left to write
-// if (myCurrReadCluster != NULL || myCurrReadBlock != NULL)
-// throw 0; // there are some data left to write
+ // if (myCurrCluster != NULL)
+ // throw 0; // there are some data left to write
+ // if (myCurrReadCluster != NULL || myCurrReadBlock != NULL)
+ // throw 0; // there are some data left to write
}
#ifdef OLD
void FileMatroska::SetMaxClusterSize(const uint32 value)
{
- myMaxClusterSize = value;
- myCurrWriteCluster.setMaxSize(value);
+ myMaxClusterSize = value;
+ myCurrWriteCluster.setMaxSize(value);
}
void FileMatroska::Close(const uint32 aTimeLength)
{
- Flush();
+ Flush();
- // get the file size
- myFile.setFilePointer(0,seek_end);
- myMainHeader.type_SetSize(myFile.getFilePointer());
+ // get the file size
+ myFile.setFilePointer(0,seek_end);
+ myMainHeader.type_SetSize(myFile.getFilePointer());
- // rewrite the header at the beginning
- myFile.setFilePointer(0,seek_beginning);
+ // rewrite the header at the beginning
+ myFile.setFilePointer(0,seek_beginning);
- // get the Track-entry size
- uint32 track_entries_size = 0;
- for (size_t i=0; i<myTracks.size(); i++)
- {
- track_entries_size += myTracks[i]->default_size();
- }
+ // get the Track-entry size
+ uint32 track_entries_size = 0;
+ for (size_t i=0; i<myTracks.size(); i++) {
+ track_entries_size += myTracks[i]->default_size();
+ }
- myStreamInfo.TrackEntriesSize = track_entries_size;
- myStreamInfo.TimeLength = aTimeLength;
- myMainHeader.Render(myFile, myStreamInfo);
+ myStreamInfo.TrackEntriesSize = track_entries_size;
+ myStreamInfo.TimeLength = aTimeLength;
+ myMainHeader.Render(myFile, myStreamInfo);
- for (i=0; i<myTracks.size(); i++)
- {
- delete myTracks[i];
- }
+ for (i=0; i<myTracks.size(); i++) {
+ delete myTracks[i];
+ }
}
/*!
- \warning after rendering the head, some parameters are locked
+ \warning after rendering the head, some parameters are locked
*/
filepos_t FileMatroska::RenderHead(const std::string & aEncoderApp)
{
- try {
- uint32 track_entries_size = 0;
- for (size_t i=0; i<myTracks.size(); i++)
- {
+ try {
+ uint32 track_entries_size = 0;
+ for (size_t i=0; i<myTracks.size(); i++) {
track_entries_size += myTracks[i]->default_size();
- }
+ }
- std::string aStr = LIB_NAME;
- aStr += " ";
- aStr += VERSION;
- myStreamInfo.EncoderLib = aStr;
+ std::string aStr = LIB_NAME;
+ aStr += " ";
+ aStr += VERSION;
+ myStreamInfo.EncoderLib = aStr;
- myStreamInfo.EncoderApp = aEncoderApp;
+ myStreamInfo.EncoderApp = aEncoderApp;
- myStreamInfo.TrackEntryPosition = 0 + myStreamInfo.MainHeaderSize;
- myStreamInfo.TrackEntriesSize = myTracks.size() * myStreamInfo.TrackEntrySize;
+ myStreamInfo.TrackEntryPosition = 0 + myStreamInfo.MainHeaderSize;
+ myStreamInfo.TrackEntriesSize = myTracks.size() * myStreamInfo.TrackEntrySize;
- myStreamInfo.CodecEntryPosition = myStreamInfo.MainHeaderSize + myStreamInfo.TrackEntriesSize;
- myStreamInfo.CodecEntrySize = 4;
- for (i=0; i<myTracks.size(); i++)
- {
+ myStreamInfo.CodecEntryPosition = myStreamInfo.MainHeaderSize + myStreamInfo.TrackEntriesSize;
+ myStreamInfo.CodecEntrySize = 4;
+ for (i=0; i<myTracks.size(); i++) {
myStreamInfo.CodecEntrySize += myTracks[i]->CodecSize();
- }
+ }
- // Main Header
- filepos_t result = myMainHeader.Render(myFile, myStreamInfo);
+ // Main Header
+ filepos_t result = myMainHeader.Render(myFile, myStreamInfo);
- // Track Entries
- for (i=0; i<myTracks.size(); i++)
- {
+ // Track Entries
+ for (i=0; i<myTracks.size(); i++) {
myTracks[i]->RenderEntry(myFile, i+1);
- }
- myStreamInfo.ClusterPosition = myStreamInfo.CodecEntryPosition + myStreamInfo.CodecEntrySize;
+ }
+ myStreamInfo.ClusterPosition = myStreamInfo.CodecEntryPosition + myStreamInfo.CodecEntrySize;
- // Codec Header
- result = CodecHeader::Render(myFile, myTracks);
+ // Codec Header
+ result = CodecHeader::Render(myFile, myTracks);
- return result;
- }
- catch (exception & Ex)
- {
- throw Ex;
- }
+ return result;
+ }
+ catch (exception & Ex) {
+ throw Ex;
+ }
}
/*!
- \return 0 if the track was not created, or a valid track number
+ \return 0 if the track was not created, or a valid track number
*/
Track * FileMatroska::CreateTrack(const track_type aType)
{
- myTracks.push_back(new Track(aType));
- return myTracks.back();
+ myTracks.push_back(new Track(aType));
+ return myTracks.back();
}
-/*Track *FileMatroska::findTrack(Track * aTrack) const
-{
- for (size_t i=0; i<myTracks.size(); i++)
- {
+/*Track *FileMatroska::findTrack(Track * aTrack) const {
+ for (size_t i=0; i<myTracks.size(); i++) {
if (myTracks[i] == aTrack)
- return myTracks[i];
- }
+ return myTracks[i];
+ }
- return NULL;
-}*/
+ return NULL;
+ }*/
void FileMatroska::track_SetName(Track * aTrack, const std::string & aName)
{
- if (IsMyTrack(aTrack))
- {
- aTrack->SetName(aName);
- }
+ if (IsMyTrack(aTrack)) {
+ aTrack->SetName(aName);
+ }
}
void FileMatroska::track_SetLaced(Track * aTrack, bool bLaced)
{
- if (IsMyTrack(aTrack))
- {
- aTrack->SetLaced(bLaced);
- }
+ if (IsMyTrack(aTrack)) {
+ aTrack->SetLaced(bLaced);
+ }
}
bool FileMatroska::AddFrame(Track * aTrack, const uint32 aTimecode, const binary *aFrame, const uint32 aFrameSize,
- bool aKeyFrame, bool aBFrame)
+ bool aKeyFrame, bool aBFrame)
{
- try {
- // make sure we know that track
- if (IsMyTrack(aTrack))
- {
+ try {
+ // make sure we know that track
+ if (IsMyTrack(aTrack)) {
// pass the cluster to the track
// handle the creation of a new cluster if needed
- if (aTrack->AddFrame(aTimecode, aFrame, aFrameSize, aKeyFrame, aBFrame))
- {
- while (!aTrack->SerialiseBlock(myCurrWriteCluster))
- {
- /// \todo handle errors
- uint32 aNbBlock;
- myStreamInfo.ClusterSize += myCurrWriteCluster.Render(myFile, aNbBlock);
- myStreamInfo.NumberBlock += aNbBlock;
- myCurrWriteCluster.Flush();
- }
+ if (aTrack->AddFrame(aTimecode, aFrame, aFrameSize, aKeyFrame, aBFrame)) {
+ while (!aTrack->SerialiseBlock(myCurrWriteCluster)) {
+ /// \todo handle errors
+ uint32 aNbBlock;
+ myStreamInfo.ClusterSize += myCurrWriteCluster.Render(myFile, aNbBlock);
+ myStreamInfo.NumberBlock += aNbBlock;
+ myCurrWriteCluster.Flush();
+ }
}
- return true;
- }
- return false;
- }
- catch (exception & Ex)
- {
- throw Ex;
+ return true;
}
+ return false;
+ }
+ catch (exception & Ex) {
+ throw Ex;
+ }
}
void FileMatroska::Flush()
{
- uint32 aNbBlock;
- myStreamInfo.ClusterSize += myCurrWriteCluster.Render(myFile,aNbBlock);
- myStreamInfo.NumberBlock += aNbBlock;
+ uint32 aNbBlock;
+ myStreamInfo.ClusterSize += myCurrWriteCluster.Render(myFile,aNbBlock);
+ myStreamInfo.NumberBlock += aNbBlock;
}
uint32 FileMatroska::ReadHead()
{
- try {
- uint32 result = myMainHeader.Read(myFile, myStreamInfo);
+ try {
+ uint32 result = myMainHeader.Read(myFile, myStreamInfo);
- return result;
- }
- catch (exception & Ex)
- {
- throw Ex;
- }
+ return result;
+ }
+ catch (exception & Ex) {
+ throw Ex;
+ }
}
uint32 FileMatroska::ReadTracks()
{
- try {
- uint32 result = 0;
-
- // seek to the start of the Track Entries
- myFile.setFilePointer(myStreamInfo.TrackEntryPosition);
- // get the number of Track Entries
- uint8 TrackNumber = myStreamInfo.TrackEntriesSize / myStreamInfo.TrackEntrySize;
- // read all the Track Entries
- myTracks.clear();
- for (uint8 TrackIdx = 0; TrackIdx<TrackNumber; TrackIdx ++) {
+ try {
+ uint32 result = 0;
+
+ // seek to the start of the Track Entries
+ myFile.setFilePointer(myStreamInfo.TrackEntryPosition);
+ // get the number of Track Entries
+ uint8 TrackNumber = myStreamInfo.TrackEntriesSize / myStreamInfo.TrackEntrySize;
+ // read all the Track Entries
+ myTracks.clear();
+ for (uint8 TrackIdx = 0; TrackIdx<TrackNumber; TrackIdx ++) {
Track * tmpTrack = Track::ReadEntry(myFile, TrackIdx+1, myStreamInfo);
if (tmpTrack == NULL)
- throw 0;
+ throw 0;
myTracks.push_back(tmpTrack);
- }
-
- return result;
- }
- catch (exception & Ex)
- {
- throw Ex;
}
+
+ return result;
+ }
+ catch (exception & Ex) {
+ throw Ex;
+ }
}
uint32 FileMatroska::ReadCodec()
{
- try {
- // seek to the start of the Track Entries
- myFile.setFilePointer(myStreamInfo.CodecEntryPosition);
+ try {
+ // seek to the start of the Track Entries
+ myFile.setFilePointer(myStreamInfo.CodecEntryPosition);
- uint32 result = CodecHeader::Read(myFile, myTracks);
+ uint32 result = CodecHeader::Read(myFile, myTracks);
- return result;
- }
- catch (exception & Ex)
- {
- throw Ex;
- }
+ return result;
+ }
+ catch (exception & Ex) {
+ throw Ex;
+ }
}
inline bool FileMatroska::IsMyTrack(const Track * aTrack) const
{
- if (aTrack == 0)
- throw 0;
+ if (aTrack == 0)
+ throw 0;
- for (std::vector<Track*>::const_iterator i = myTracks.begin(); i != myTracks.end(); i ++)
- {
- if (*i == aTrack)
+ for (std::vector<Track*>::const_iterator i = myTracks.begin(); i != myTracks.end(); i ++) {
+ if (*i == aTrack)
break;
- }
+ }
- if (i != myTracks.end())
- return true;
- else
- return false;
+ if (i != myTracks.end())
+ return true;
+ else
+ return false;
}
void FileMatroska::SelectReadingTrack(Track * aTrack, bool select)
{
- if (IsMyTrack(aTrack))
- {
- // here we have the right track
- // check if it's not already selected
- for (std::vector<uint8>::iterator j = mySelectedTracks.begin();
- j != mySelectedTracks.end(); j ++)
- {
+ if (IsMyTrack(aTrack)) {
+ // here we have the right track
+ // check if it's not already selected
+ for (std::vector<uint8>::iterator j = mySelectedTracks.begin(); j != mySelectedTracks.end(); j ++) {
if (*j == aTrack->TrackNumber())
- break;
- }
+ break;
+ }
- if (select && j == mySelectedTracks.end())
+ if (select && j == mySelectedTracks.end())
mySelectedTracks.push_back(aTrack->TrackNumber());
- else if (!select && j != mySelectedTracks.end())
+ else if (!select && j != mySelectedTracks.end())
mySelectedTracks.erase(j);
- std::sort(mySelectedTracks.begin(), mySelectedTracks.end());
- }
+ std::sort(mySelectedTracks.begin(), mySelectedTracks.end());
+ }
}
inline bool FileMatroska::IsReadingTrack(const uint8 aTrackNumber) const
{
- for (std::vector<uint8>::const_iterator trackIdx = mySelectedTracks.begin();
- trackIdx != mySelectedTracks.end() && *trackIdx < aTrackNumber;
- trackIdx++)
- {}
-
- if (trackIdx == mySelectedTracks.end())
- return false;
- else
- return true;
+ for (std::vector<uint8>::const_iterator trackIdx = mySelectedTracks.begin();
+ trackIdx != mySelectedTracks.end() && *trackIdx < aTrackNumber;
+ trackIdx++) {}
+
+ if (trackIdx == mySelectedTracks.end())
+ return false;
+ else
+ return true;
}
//
void FileMatroska::Track_GetInfo(const Track * aTrack, TrackInfo & aTrackInfo) const
{
- if (IsMyTrack(aTrack))
- {
- aTrack->GetInfo(aTrackInfo);
- }
+ if (IsMyTrack(aTrack)) {
+ aTrack->GetInfo(aTrackInfo);
+ }
}
// Audio related getters/setters
void FileMatroska::Track_GetInfo_Audio(const Track * aTrack, TrackInfoAudio & aTrackInfo) const
{
- if (IsMyTrack(aTrack))
- {
- aTrack->GetInfoAudio(aTrackInfo);
- }
+ if (IsMyTrack(aTrack)) {
+ aTrack->GetInfoAudio(aTrackInfo);
+ }
}
void FileMatroska::Track_SetInfo_Audio(Track * aTrack, const TrackInfoAudio & aTrackInfo)
{
- if (IsMyTrack(aTrack))
- {
- aTrack->SetInfoAudio(aTrackInfo);
- }
+ if (IsMyTrack(aTrack)) {
+ aTrack->SetInfoAudio(aTrackInfo);
+ }
}
// Video related getters/setters
void FileMatroska::Track_GetInfo_Video(const Track * aTrack, TrackInfoVideo & aTrackInfo) const
{
- if (IsMyTrack(aTrack))
- {
- aTrack->GetInfoVideo(aTrackInfo);
- }
+ if (IsMyTrack(aTrack)) {
+ aTrack->GetInfoVideo(aTrackInfo);
+ }
}
void FileMatroska::Track_SetInfo_Video(Track * aTrack, const TrackInfoVideo & aTrackInfo)
{
- if (IsMyTrack(aTrack))
- {
- aTrack->SetInfoVideo(aTrackInfo);
- }
+ if (IsMyTrack(aTrack)) {
+ aTrack->SetInfoVideo(aTrackInfo);
+ }
}
/*!
- \todo exit when there is no Block left
+ \todo exit when there is no Block left
*/
bool FileMatroska::ReadFrame(Track * & aTrack, uint32 & aTimecode, const binary * & aFrame, uint32 & aFrameSize,
- bool & aKeyFrame, bool & aBFrame)
+ bool & aKeyFrame, bool & aBFrame)
{
- if (myCurrReadBlockTrack == 0)
- {
- do {
- if (myReadBlockNumber >= myStreamInfo.NumberBlock)
- {
-// myReadBlockNumber = myStreamInfo.NumberBlock;
- return false;
+ if (myCurrReadBlockTrack == 0) {
+ do {
+ if (myReadBlockNumber >= myStreamInfo.NumberBlock) {
+ // myReadBlockNumber = myStreamInfo.NumberBlock;
+ return false;
}
// get the next frame in the file
- if (!myCurrReadCluster.BlockLeft())
- {
- myCurrReadCluster.Flush();
- try {
- myCurrReadCluster.FindHead(myFile);
- }
- catch (exception & Ex)
- {
- return false;
- }
+ if (!myCurrReadCluster.BlockLeft()) {
+ myCurrReadCluster.Flush();
+ try {
+ myCurrReadCluster.FindHead(myFile);
+ }
+ catch (exception & Ex) {
+ return false;
+ }
}
myCurrReadCluster.GetBlock( myCurrReadBlock, myCurrReadBlockSize, myCurrReadBlockTrack );
myReadBlockNumber++;
- } while (!IsReadingTrack(myCurrReadBlockTrack));
-
- // get the track associated (normally from myTracks)
- aTrack = myTracks[myCurrReadBlockTrack-1];
- // get the next frame from the current block
- aTrack->HandleBlock(myCurrReadBlock, myCurrReadBlockSize);
- }
- else
- {
- // get the track associated (normally from myTracks)
- aTrack = myTracks[myCurrReadBlockTrack-1];
- }
+ } while (!IsReadingTrack(myCurrReadBlockTrack));
+
+ // get the track associated (normally from myTracks)
+ aTrack = myTracks[myCurrReadBlockTrack-1];
+ // get the next frame from the current block
+ aTrack->HandleBlock(myCurrReadBlock, myCurrReadBlockSize);
+ } else {
+ // get the track associated (normally from myTracks)
+ aTrack = myTracks[myCurrReadBlockTrack-1];
+ }
- Frame * myReadFrame;
- aTrack->GetNextFrame(aTimecode, myReadFrame, aKeyFrame, aBFrame);
- aFrame = myReadFrame->buf();
- aFrameSize = myReadFrame->length();
+ Frame * myReadFrame;
+ aTrack->GetNextFrame(aTimecode, myReadFrame, aKeyFrame, aBFrame);
+ aFrame = myReadFrame->buf();
+ aFrameSize = myReadFrame->length();
- if (aTrack->NoFrameLeft())
- {
- aTrack->FlushBlock();
- myCurrReadBlockTrack = 0;
- }
+ if (aTrack->NoFrameLeft()) {
+ aTrack->FlushBlock();
+ myCurrReadBlockTrack = 0;
+ }
- return true;
+ return true;
}
#endif // OLD
void matroska_init()
{
#if defined(HAVE_EBML2) || defined(HAS_EBML2)
- ebml_init();
+ ebml_init();
#endif
}
void matroska_done()
{
#if defined(HAVE_EBML2) || defined(HAS_EBML2)
- ebml_done();
+ ebml_done();
#endif
}
START_LIBMATROSKA_NAMESPACE
KaxAttached::KaxAttached(EBML_EXTRA_DEF)
- :EbmlMaster(EBML_CLASS_SEMCONTEXT(KaxAttached) EBML_DEF_SEP EBML_EXTRA_CALL)
+ :EbmlMaster(EBML_CLASS_SEMCONTEXT(KaxAttached) EBML_DEF_SEP EBML_EXTRA_CALL)
{
SetSizeLength(2); // mandatory min size support (for easier updating) (2^(7*2)-2 = 16Ko)
}
START_LIBMATROSKA_NAMESPACE
KaxAttachments::KaxAttachments(EBML_EXTRA_DEF)
- :EbmlMaster(EBML_CLASS_SEMCONTEXT(KaxAttachments) EBML_DEF_SEP EBML_EXTRA_CALL)
+ :EbmlMaster(EBML_CLASS_SEMCONTEXT(KaxAttachments) EBML_DEF_SEP EBML_EXTRA_CALL)
{
SetSizeLength(2); // mandatory min size support (for easier updating) (2^(7*2)-2 = 16Ko)
}
}
SimpleDataBuffer::SimpleDataBuffer(const SimpleDataBuffer & ToClone)
- :DataBuffer((binary *)malloc(ToClone.mySize * sizeof(binary)), ToClone.mySize, myFreeBuffer)
+ :DataBuffer((binary *)malloc(ToClone.mySize * sizeof(binary)), ToClone.mySize, myFreeBuffer)
{
assert(myBuffer != NULL);
memcpy(myBuffer, ToClone.myBuffer ,mySize );
}
KaxInternalBlock::KaxInternalBlock(const KaxInternalBlock & ElementToClone)
- :EbmlBinary(ElementToClone)
- ,myBuffers(ElementToClone.myBuffers.size())
- ,Timecode(ElementToClone.Timecode)
- ,LocalTimecode(ElementToClone.LocalTimecode)
- ,bLocalTimecodeUsed(ElementToClone.bLocalTimecodeUsed)
- ,TrackNumber(ElementToClone.TrackNumber)
- ,ParentCluster(ElementToClone.ParentCluster) ///< \todo not exactly
+ :EbmlBinary(ElementToClone)
+ ,myBuffers(ElementToClone.myBuffers.size())
+ ,Timecode(ElementToClone.Timecode)
+ ,LocalTimecode(ElementToClone.LocalTimecode)
+ ,bLocalTimecodeUsed(ElementToClone.bLocalTimecodeUsed)
+ ,TrackNumber(ElementToClone.TrackNumber)
+ ,ParentCluster(ElementToClone.ParentCluster) ///< \todo not exactly
{
// add a clone of the list
std::vector<DataBuffer *>::const_iterator Itr = ElementToClone.myBuffers.begin();
std::vector<DataBuffer *>::iterator myItr = myBuffers.begin();
- while (Itr != ElementToClone.myBuffers.end())
- {
+ while (Itr != ElementToClone.myBuffers.end()) {
*myItr = (*Itr)->Clone();
Itr++; myItr++;
}
KaxBlockGroup::~KaxBlockGroup()
{
-//NOTE("KaxBlockGroup::~KaxBlockGroup");
+ //NOTE("KaxBlockGroup::~KaxBlockGroup");
}
KaxBlockGroup::KaxBlockGroup(EBML_EXTRA_DEF)
- :EbmlMaster(EBML_CLASS_SEMCONTEXT(KaxBlockGroup) EBML_DEF_SEP EBML_EXTRA_CALL)
- ,ParentCluster(NULL)
- ,ParentTrack(NULL)
+ :EbmlMaster(EBML_CLASS_SEMCONTEXT(KaxBlockGroup) EBML_DEF_SEP EBML_EXTRA_CALL)
+ ,ParentCluster(NULL)
+ ,ParentTrack(NULL)
{}
/*!
}
/*!
- \return Returns the lacing type that produces the smallest footprint.
+ \return Returns the lacing type that produces the smallest footprint.
*/
LacingType KaxInternalBlock::GetBestLacingType() const {
int XiphLacingSize, EbmlLacingSize, i;
filepos_t KaxInternalBlock::UpdateSize(bool /* bSaveDefault */, bool /* bForceRender */)
{
LacingType LacingHere;
- assert(EbmlBinary::GetBuffer() == NULL); // Data is not used for KaxInternalBlock
+ assert(EbmlBinary::GetBuffer() == NULL); // Data is not used for KaxInternalBlock
assert(TrackNumber < 0x4000); // no more allowed for the moment
unsigned int i;
LacingHere = GetBestLacingType();
else
LacingHere = mLacing;
- switch (LacingHere)
- {
- case LACING_XIPH:
- for (i=0; i<myBuffers.size()-1; i++) {
- SetSize_(GetSize() + myBuffers[i]->Size() + (myBuffers[i]->Size() / 0xFF + 1));
- }
- break;
- case LACING_EBML:
- SetSize_(GetSize() + myBuffers[0]->Size() + CodedSizeLength(myBuffers[0]->Size(), 0, IsFiniteSize()));
- for (i=1; i<myBuffers.size()-1; i++) {
- SetSize_(GetSize() + myBuffers[i]->Size() + CodedSizeLengthSigned(int64(myBuffers[i]->Size()) - int64(myBuffers[i-1]->Size()), 0));
- }
- break;
- case LACING_FIXED:
- for (i=0; i<myBuffers.size()-1; i++) {
- SetSize_(GetSize() + myBuffers[i]->Size());
- }
- break;
- default:
- i = 0;
- assert(0);
+ switch (LacingHere) {
+ case LACING_XIPH:
+ for (i=0; i<myBuffers.size()-1; i++) {
+ SetSize_(GetSize() + myBuffers[i]->Size() + (myBuffers[i]->Size() / 0xFF + 1));
+ }
+ break;
+ case LACING_EBML:
+ SetSize_(GetSize() + myBuffers[0]->Size() + CodedSizeLength(myBuffers[0]->Size(), 0, IsFiniteSize()));
+ for (i=1; i<myBuffers.size()-1; i++) {
+ SetSize_(GetSize() + myBuffers[i]->Size() + CodedSizeLengthSigned(int64(myBuffers[i]->Size()) - int64(myBuffers[i-1]->Size()), 0));
+ }
+ break;
+ case LACING_FIXED:
+ for (i=0; i<myBuffers.size()-1; i++) {
+ SetSize_(GetSize() + myBuffers[i]->Size());
+ }
+ break;
+ default:
+ i = 0;
+ assert(0);
}
// Size of the last frame (not in lace)
SetSize_(GetSize() + myBuffers[i]->Size());
#if MATROSKA_VERSION >= 2
KaxBlockVirtual::KaxBlockVirtual(const KaxBlockVirtual & ElementToClone)
- :EbmlBinary(ElementToClone)
- ,Timecode(ElementToClone.Timecode)
- ,TrackNumber(ElementToClone.TrackNumber)
- ,ParentCluster(ElementToClone.ParentCluster) ///< \todo not exactly
+ :EbmlBinary(ElementToClone)
+ ,Timecode(ElementToClone.Timecode)
+ ,TrackNumber(ElementToClone.TrackNumber)
+ ,ParentCluster(ElementToClone.ParentCluster) ///< \todo not exactly
{
- SetBuffer(DataBlock,sizeof(DataBlock));
- SetValueIsSet(false);
+ SetBuffer(DataBlock,sizeof(DataBlock));
+ SetValueIsSet(false);
}
KaxBlockVirtual::KaxBlockVirtual(EBML_EXTRA_DEF)
-:EBML_DEF_BINARY(KaxBlockVirtual)EBML_DEF_SEP ParentCluster(NULL)
+ :EBML_DEF_BINARY(KaxBlockVirtual)EBML_DEF_SEP ParentCluster(NULL)
{
- SetBuffer(DataBlock,sizeof(DataBlock));
- SetValueIsSet(false);
+ SetBuffer(DataBlock,sizeof(DataBlock));
+ SetValueIsSet(false);
}
KaxBlockVirtual::~KaxBlockVirtual()
{
- if(GetBuffer() == DataBlock)
- SetBuffer( NULL, 0 );
+ if(GetBuffer() == DataBlock)
+ SetBuffer( NULL, 0 );
}
filepos_t KaxBlockVirtual::UpdateSize(bool /* bSaveDefault */, bool /* bForceRender */)
binary *cursor = EbmlBinary::GetBuffer();
// fill data
if (TrackNumber < 0x80) {
- assert(GetSize() >= 4);
+ assert(GetSize() >= 4);
*cursor++ = TrackNumber | 0x80; // set the first bit to 1
} else {
- assert(GetSize() >= 5);
+ assert(GetSize() >= 5);
*cursor++ = (TrackNumber >> 8) | 0x40; // set the second bit to 1
*cursor++ = TrackNumber & 0xFF;
}
}
// lacing flag
- switch (mLacing)
- {
- case LACING_XIPH:
- *cursor++ |= 0x02;
- break;
- case LACING_EBML:
- *cursor++ |= 0x06;
- break;
- case LACING_FIXED:
- *cursor++ |= 0x04;
- break;
- case LACING_NONE:
- break;
+ switch (mLacing) {
+ case LACING_XIPH:
+ *cursor++ |= 0x02;
+ break;
+ case LACING_EBML:
+ *cursor++ |= 0x06;
+ break;
+ case LACING_FIXED:
+ *cursor++ |= 0x04;
+ break;
+ case LACING_NONE:
+ break;
default:
- assert(0);
+ assert(0);
}
output.writeFully(BlockHead, 4 + ((TrackNumber > 0x80) ? 1 : 0));
binary tmpValue;
- switch (mLacing)
- {
- case LACING_XIPH:
- // number of laces
- tmpValue = myBuffers.size()-1;
- output.writeFully(&tmpValue, 1);
-
- // set the size of each member in the lace
- for (i=0; i<myBuffers.size()-1; i++) {
- tmpValue = 0xFF;
- uint16 tmpSize = myBuffers[i]->Size();
- while (tmpSize >= 0xFF) {
+ switch (mLacing) {
+ case LACING_XIPH:
+ // number of laces
+ tmpValue = myBuffers.size()-1;
+ output.writeFully(&tmpValue, 1);
+
+ // set the size of each member in the lace
+ for (i=0; i<myBuffers.size()-1; i++) {
+ tmpValue = 0xFF;
+ uint16 tmpSize = myBuffers[i]->Size();
+ while (tmpSize >= 0xFF) {
+ output.writeFully(&tmpValue, 1);
+ SetSize_(GetSize() + 1);
+ tmpSize -= 0xFF;
+ }
+ tmpValue = binary(tmpSize);
output.writeFully(&tmpValue, 1);
SetSize_(GetSize() + 1);
- tmpSize -= 0xFF;
}
- tmpValue = binary(tmpSize);
+ break;
+ case LACING_EBML:
+ // number of laces
+ tmpValue = myBuffers.size()-1;
output.writeFully(&tmpValue, 1);
- SetSize_(GetSize() + 1);
- }
- break;
- case LACING_EBML:
- // number of laces
- tmpValue = myBuffers.size()-1;
- output.writeFully(&tmpValue, 1);
+ {
+ int64 _Size;
+ int _CodedSize;
+ binary _FinalHead[8]; // 64 bits max coded size
- {
- int64 _Size;
- int _CodedSize;
- binary _FinalHead[8]; // 64 bits max coded size
+ _Size = myBuffers[0]->Size();
- _Size = myBuffers[0]->Size();
+ _CodedSize = CodedSizeLength(_Size, 0, IsFiniteSize());
- _CodedSize = CodedSizeLength(_Size, 0, IsFiniteSize());
-
- // first size in the lace is not a signed
- CodedValueLength(_Size, _CodedSize, _FinalHead);
- output.writeFully(_FinalHead, _CodedSize);
- SetSize_(GetSize() + _CodedSize);
-
- // set the size of each member in the lace
- for (i=1; i<myBuffers.size()-1; i++) {
- _Size = int64(myBuffers[i]->Size()) - int64(myBuffers[i-1]->Size());
- _CodedSize = CodedSizeLengthSigned(_Size, 0);
- CodedValueLengthSigned(_Size, _CodedSize, _FinalHead);
+ // first size in the lace is not a signed
+ CodedValueLength(_Size, _CodedSize, _FinalHead);
output.writeFully(_FinalHead, _CodedSize);
SetSize_(GetSize() + _CodedSize);
+
+ // set the size of each member in the lace
+ for (i=1; i<myBuffers.size()-1; i++) {
+ _Size = int64(myBuffers[i]->Size()) - int64(myBuffers[i-1]->Size());
+ _CodedSize = CodedSizeLengthSigned(_Size, 0);
+ CodedValueLengthSigned(_Size, _CodedSize, _FinalHead);
+ output.writeFully(_FinalHead, _CodedSize);
+ SetSize_(GetSize() + _CodedSize);
+ }
}
- }
- break;
- case LACING_FIXED:
- // number of laces
- tmpValue = myBuffers.size()-1;
- output.writeFully(&tmpValue, 1);
- break;
- case LACING_NONE:
- break;
+ break;
+ case LACING_FIXED:
+ // number of laces
+ tmpValue = myBuffers.size()-1;
+ output.writeFully(&tmpValue, 1);
+ break;
+ case LACING_NONE:
+ break;
default:
- assert(0);
+ assert(0);
}
// put the data of each frame
FirstFrameLocation = input.getFilePointer(); // will be updated accordingly below
- if (ReadFully == SCOPE_ALL_DATA)
- {
+ if (ReadFully == SCOPE_ALL_DATA) {
Result = EbmlBinary::ReadData(input, ReadFully);
- binary *cursor = EbmlBinary::GetBuffer();
+ binary *cursor = EbmlBinary::GetBuffer();
uint8 BlockHeadSize = 4;
// update internal values
SizeList.resize(FrameNum + 1);
- switch (mLacing)
- {
- case LACING_XIPH:
- for (Index=0; Index<FrameNum; Index++) {
- // get the size of the frame
- FrameSize = 0;
- do {
- FrameSize += uint8(*cursor);
- LastBufferSize--;
- } while (*cursor++ == 0xFF);
- SizeList[Index] = FrameSize;
- LastBufferSize -= FrameSize;
- }
- SizeList[Index] = LastBufferSize;
- break;
- case LACING_EBML:
- SizeRead = LastBufferSize;
- FrameSize = ReadCodedSizeValue(cursor, SizeRead, SizeUnknown);
- SizeList[0] = FrameSize;
- cursor += SizeRead;
- LastBufferSize -= FrameSize + SizeRead;
-
- for (Index=1; Index<FrameNum; Index++) {
- // get the size of the frame
+ switch (mLacing) {
+ case LACING_XIPH:
+ for (Index=0; Index<FrameNum; Index++) {
+ // get the size of the frame
+ FrameSize = 0;
+ do {
+ FrameSize += uint8(*cursor);
+ LastBufferSize--;
+ } while (*cursor++ == 0xFF);
+ SizeList[Index] = FrameSize;
+ LastBufferSize -= FrameSize;
+ }
+ SizeList[Index] = LastBufferSize;
+ break;
+ case LACING_EBML:
SizeRead = LastBufferSize;
- FrameSize += ReadCodedSizeSignedValue(cursor, SizeRead, SizeUnknown);
- SizeList[Index] = FrameSize;
+ FrameSize = ReadCodedSizeValue(cursor, SizeRead, SizeUnknown);
+ SizeList[0] = FrameSize;
cursor += SizeRead;
LastBufferSize -= FrameSize + SizeRead;
- }
- if (Index <= FrameNum) // Safety check if FrameNum == 0
- SizeList[Index] = LastBufferSize;
- break;
- case LACING_FIXED:
- for (Index=0; Index<=FrameNum; Index++) {
- // get the size of the frame
- SizeList[Index] = LastBufferSize / (FrameNum + 1);
- }
- break;
- default: // other lacing not supported
- assert(0);
+
+ for (Index=1; Index<FrameNum; Index++) {
+ // get the size of the frame
+ SizeRead = LastBufferSize;
+ FrameSize += ReadCodedSizeSignedValue(cursor, SizeRead, SizeUnknown);
+ SizeList[Index] = FrameSize;
+ cursor += SizeRead;
+ LastBufferSize -= FrameSize + SizeRead;
+ }
+ if (Index <= FrameNum) // Safety check if FrameNum == 0
+ SizeList[Index] = LastBufferSize;
+ break;
+ case LACING_FIXED:
+ for (Index=0; Index<=FrameNum; Index++) {
+ // get the size of the frame
+ SizeList[Index] = LastBufferSize / (FrameNum + 1);
+ }
+ break;
+ default: // other lacing not supported
+ assert(0);
}
FirstFrameLocation += cursor - EbmlBinary::GetBuffer();
}
SetValueIsSet();
}
- else if (ReadFully == SCOPE_PARTIAL_DATA)
- {
+ else if (ReadFully == SCOPE_PARTIAL_DATA) {
binary _TempHead[5];
Result = input.read(_TempHead, 5);
binary *cursor = _TempHead;
}
mInvisible = (*cursor & 0x08) >> 3;
mLacing = LacingType((*cursor++ & 0x06) >> 1);
- if (cursor == &_TempHead[4])
- {
+ if (cursor == &_TempHead[4]) {
_TempHead[0] = _TempHead[4];
} else {
Result += input.read(_TempHead, 1);
SizeList.resize(FrameNum + 1);
- switch (mLacing)
- {
- case LACING_XIPH:
- for (Index=0; Index<FrameNum; Index++) {
- // get the size of the frame
- FrameSize = 0;
- do {
- Result += input.read(_TempHead, 1);
- FrameSize += uint8(_TempHead[0]);
- LastBufferSize--;
+ switch (mLacing) {
+ case LACING_XIPH:
+ for (Index=0; Index<FrameNum; Index++) {
+ // get the size of the frame
+ FrameSize = 0;
+ do {
+ Result += input.read(_TempHead, 1);
+ FrameSize += uint8(_TempHead[0]);
+ LastBufferSize--;
- FirstFrameLocation++;
- } while (_TempHead[0] == 0xFF);
+ FirstFrameLocation++;
+ } while (_TempHead[0] == 0xFF);
- FirstFrameLocation++;
- SizeList[Index] = FrameSize;
- LastBufferSize -= FrameSize;
- }
- SizeList[Index] = LastBufferSize;
- break;
- case LACING_EBML:
- SizeRead = LastBufferSize;
- cursor = _tmpBuf = new binary[FrameNum*4]; /// \warning assume the mean size will be coded in less than 4 bytes
- Result += input.read(cursor, FrameNum*4);
- FrameSize = ReadCodedSizeValue(cursor, SizeRead, SizeUnknown);
- SizeList[0] = FrameSize;
- cursor += SizeRead;
- LastBufferSize -= FrameSize + SizeRead;
-
- for (Index=1; Index<FrameNum; Index++) {
- // get the size of the frame
+ FirstFrameLocation++;
+ SizeList[Index] = FrameSize;
+ LastBufferSize -= FrameSize;
+ }
+ SizeList[Index] = LastBufferSize;
+ break;
+ case LACING_EBML:
SizeRead = LastBufferSize;
- FrameSize += ReadCodedSizeSignedValue(cursor, SizeRead, SizeUnknown);
- SizeList[Index] = FrameSize;
+ cursor = _tmpBuf = new binary[FrameNum*4]; /// \warning assume the mean size will be coded in less than 4 bytes
+ Result += input.read(cursor, FrameNum*4);
+ FrameSize = ReadCodedSizeValue(cursor, SizeRead, SizeUnknown);
+ SizeList[0] = FrameSize;
cursor += SizeRead;
LastBufferSize -= FrameSize + SizeRead;
- }
- FirstFrameLocation += cursor - _tmpBuf;
+ for (Index=1; Index<FrameNum; Index++) {
+ // get the size of the frame
+ SizeRead = LastBufferSize;
+ FrameSize += ReadCodedSizeSignedValue(cursor, SizeRead, SizeUnknown);
+ SizeList[Index] = FrameSize;
+ cursor += SizeRead;
+ LastBufferSize -= FrameSize + SizeRead;
+ }
- SizeList[Index] = LastBufferSize;
- delete [] _tmpBuf;
- break;
- case LACING_FIXED:
- for (Index=0; Index<=FrameNum; Index++) {
- // get the size of the frame
- SizeList[Index] = LastBufferSize / (FrameNum + 1);
- }
- break;
- default: // other lacing not supported
- assert(0);
+ FirstFrameLocation += cursor - _tmpBuf;
+
+ SizeList[Index] = LastBufferSize;
+ delete [] _tmpBuf;
+ break;
+ case LACING_FIXED:
+ for (Index=0; Index<=FrameNum; Index++) {
+ // get the size of the frame
+ SizeList[Index] = LastBufferSize / (FrameNum + 1);
+ }
+ break;
+ default: // other lacing not supported
+ assert(0);
}
} else {
SizeList.resize(1);
bool KaxBlockGroup::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, const KaxBlockGroup & PastBlock, LacingType lacing)
{
-// assert(past_timecode < 0);
+ // assert(past_timecode < 0);
KaxBlock & theBlock = GetChild<KaxBlock>(*this);
assert(ParentCluster != NULL);
bool KaxBlockGroup::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, const KaxBlockGroup & PastBlock, const KaxBlockGroup & ForwBlock, LacingType lacing)
{
-// assert(past_timecode < 0);
+ // assert(past_timecode < 0);
-// assert(forw_timecode > 0);
+ // assert(forw_timecode > 0);
KaxBlock & theBlock = GetChild<KaxBlock>(*this);
assert(ParentCluster != NULL);
ParentTrack = &track;
bool bRes = theBlock.AddFrame(track, timecode, buffer, lacing);
- if (PastBlock != NULL)
- {
+ if (PastBlock != NULL) {
KaxReferenceBlock & thePastRef = GetChild<KaxReferenceBlock>(*this);
thePastRef.SetReferencedBlock(PastBlock);
thePastRef.SetParentBlock(*this);
}
- if (ForwBlock != NULL)
- {
+ if (ForwBlock != NULL) {
KaxReferenceBlock & theFutureRef = AddNewChild<KaxReferenceBlock>(*this);
theFutureRef.SetReferencedBlock(ForwBlock);
theFutureRef.SetParentBlock(*this);
KaxReferenceBlock * MyBlockAdds = static_cast<KaxReferenceBlock *>(FindFirstElt(EBML_INFO(KaxReferenceBlock)));
if (MyBlockAdds != NULL) {
Result++;
- while ((MyBlockAdds = static_cast<KaxReferenceBlock *>(FindNextElt(*MyBlockAdds))) != NULL)
- {
+ while ((MyBlockAdds = static_cast<KaxReferenceBlock *>(FindNextElt(*MyBlockAdds))) != NULL) {
Result++;
}
}
{
int64 _Result = -1;
- if (ValueIsSet() && FrameNumber < SizeList.size())
- {
+ if (ValueIsSet() && FrameNumber < SizeList.size()) {
_Result = FirstFrameLocation;
size_t _Idx = 0;
- while(FrameNumber--)
- {
+ while(FrameNumber--) {
_Result += SizeList[_Idx++];
}
}
{
int64 _Result = -1;
- if (/*bValueIsSet &&*/ FrameNumber < SizeList.size())
- {
+ if (/*bValueIsSet &&*/ FrameNumber < SizeList.size()) {
_Result = SizeList[FrameNumber];
}
} else {
Block.simpleblock->SetKeyframe(false);
if ((ForwBlock == NULL || ((const KaxInternalBlock &)*ForwBlock).GlobalTimecode() <= timecode) &&
- (PastBlock == NULL || ((const KaxInternalBlock &)*PastBlock).GlobalTimecode() <= timecode))
+ (PastBlock == NULL || ((const KaxInternalBlock &)*PastBlock).GlobalTimecode() <= timecode))
Block.simpleblock->SetDiscardable(false);
else
Block.simpleblock->SetDiscardable(true);
}
else
#endif
- {
- if (ReplaceSimpleByGroup()) {
+ if (ReplaceSimpleByGroup())
bResult = Block.group->AddFrame(track, timecode, buffer, PastBlock, ForwBlock, lacing);
- }
- }
return bResult;
}
}
}
#if MATROSKA_VERSION >= 2
- else
- {
+ else {
if (Block.simpleblock != NULL) {
KaxSimpleBlock *old_simpleblock = Block.simpleblock;
filepos_t KaxBlockVirtual::ReadData(IOCallback & input, ScopeMode /* ReadFully */)
{
- input.setFilePointer(SizePosition + CodedSizeLength(Size, SizeLength, bSizeIsFinite) + Size, seek_beginning);
- return GetSize();
+ input.setFilePointer(SizePosition + CodedSizeLength(Size, SizeLength, bSizeIsFinite) + Size, seek_beginning);
+ return GetSize();
}
END_LIBMATROSKA_NAMESPACE
}
KaxReferenceBlock::KaxReferenceBlock(EBML_EXTRA_DEF)
-:EBML_DEF_SINTEGER(KaxReferenceBlock)EBML_DEF_SEP
-RefdBlock(NULL)
-,ParentBlock(NULL)
-,bTimecodeSet(false)
-,bOurBlob(false)
+ :EBML_DEF_SINTEGER(KaxReferenceBlock)EBML_DEF_SEP
+ RefdBlock(NULL)
+ ,ParentBlock(NULL)
+ ,bTimecodeSet(false)
+ ,bOurBlob(false)
{
- bTimecodeSet = false;
+ bTimecodeSet = false;
}
KaxReferenceBlock::KaxReferenceBlock(const KaxReferenceBlock & ElementToClone)
-:EbmlSInteger(ElementToClone)
-,RefdBlock(NULL)
-,ParentBlock(NULL)
-,bTimecodeSet(ElementToClone.bTimecodeSet)
-,bOurBlob(false)
+ :EbmlSInteger(ElementToClone)
+ ,RefdBlock(NULL)
+ ,ParentBlock(NULL)
+ ,bTimecodeSet(ElementToClone.bTimecodeSet)
+ ,bOurBlob(false)
{
}
KaxReferenceBlock::~KaxReferenceBlock()
{
- FreeBlob();
+ FreeBlob();
}
void KaxReferenceBlock::FreeBlob()
{
- if (bOurBlob && RefdBlock!=NULL)
- delete RefdBlock;
- RefdBlock = NULL;
+ if (bOurBlob && RefdBlock!=NULL)
+ delete RefdBlock;
+ RefdBlock = NULL;
}
filepos_t KaxReferenceBlock::UpdateSize(bool bSaveDefault, bool bForceRender)
{
assert(RefdBlock == NULL);
assert(aRefdBlock != NULL);
- FreeBlob();
+ FreeBlob();
RefdBlock = aRefdBlock;
- bOurBlob = true;
+ bOurBlob = true;
SetValueIsSet();
}
void KaxReferenceBlock::SetReferencedBlock(const KaxBlockGroup & aRefdBlock)
{
- FreeBlob();
+ FreeBlob();
KaxBlockBlob *block_blob = new KaxBlockBlob(BLOCK_BLOB_NO_SIMPLE);
block_blob->SetBlockGroup(*const_cast<KaxBlockGroup*>(&aRefdBlock));
RefdBlock = block_blob;
- bOurBlob = true;
+ bOurBlob = true;
SetValueIsSet();
}
{}
KaxCluster::KaxCluster(const KaxCluster & ElementToClone)
- :EbmlMaster(ElementToClone)
- ,bSilentTracksUsed(ElementToClone.bSilentTracksUsed)
+ :EbmlMaster(ElementToClone)
+ ,bSilentTracksUsed(ElementToClone.bSilentTracksUsed)
{
// update the parent of each children
EBML_MASTER_ITERATOR Itr = begin();
- while (Itr != end())
- {
+ while (Itr != end()) {
if (EbmlId(**Itr) == EBML_ID(KaxBlockGroup)) {
static_cast<KaxBlockGroup *>(*Itr)->SetParent(*this);
} else if (EbmlId(**Itr) == EBML_ID(KaxBlock)) {
static_cast<KaxBlockVirtual *>(*Itr)->SetParent(*this);
#endif // MATROSKA_VERSION
}
- ++Itr;
+ ++Itr;
}
}
filepos_t KaxCluster::Render(IOCallback & output, KaxCues & CueToUpdate, bool bSaveDefault)
{
filepos_t Result = 0;
- size_t Index;
- EBML_MASTER_ITERATOR TrkItr, Itr;
+ size_t Index;
+ EBML_MASTER_ITERATOR TrkItr, Itr;
// update the Timecode of the Cluster before writing
KaxClusterTimecode * Timecode = static_cast<KaxClusterTimecode *>(this->FindElt(EBML_INFO(KaxClusterTimecode)));
// SilentTracks handling
// check the parent cluster for existing tracks and see if they are contained in this cluster or not
- if (bSilentTracksUsed)
- {
+ if (bSilentTracksUsed) {
KaxTracks & MyTracks = *static_cast<KaxTracks *>(ParentSegment->FindElt(EBML_INFO(KaxTracks)));
- for (TrkItr = MyTracks.begin(); TrkItr != MyTracks.end(); ++TrkItr)
- {
- if (EbmlId(*(*TrkItr)) == EBML_ID(KaxTrackEntry))
- {
+ for (TrkItr = MyTracks.begin(); TrkItr != MyTracks.end(); ++TrkItr) {
+ if (EbmlId(*(*TrkItr)) == EBML_ID(KaxTrackEntry)) {
KaxTrackEntry & entry = *static_cast<KaxTrackEntry *>(*TrkItr);
uint32 tracknum = entry.TrackNumber();
- for (Itr = begin(); Itr != end(); ++Itr)
- {
+ for (Itr = begin(); Itr != end(); ++Itr) {
if (EbmlId(*(*Itr)) == EBML_ID(KaxBlockGroup)) {
KaxBlockGroup & group = *static_cast<KaxBlockGroup *>(*Itr);
if (group.TrackNumber() == tracknum)
}
}
// the track wasn't found in this cluster
- if (Itr == end())
- {
+ if (Itr == end()) {
KaxClusterSilentTracks * SilentTracks = static_cast<KaxClusterSilentTracks *>(this->FindFirstElt(EBML_INFO(KaxClusterSilentTracks)));
assert(SilentTracks != NULL); // the flag bSilentTracksUsed should be set when creating the Cluster
KaxClusterSilentTrackNumber * trackelt = static_cast<KaxClusterSilentTrackNumber *>(SilentTracks->AddNewElt(EBML_INFO(KaxClusterSilentTrackNumber)));
Result = EbmlMaster::Render(output, bSaveDefault);
// For all Blocks add their position on the CueEntry
- for (Itr = begin(); Itr != end(); ++Itr)
- {
+ for (Itr = begin(); Itr != end(); ++Itr) {
if (EbmlId(*(*Itr)) == EBML_ID(KaxBlockGroup)) {
CueToUpdate.PositionSet(*static_cast<const KaxBlockGroup *>(*Itr));
}
}
} else {
// new school, using KaxBlockBlob
- for (Index = 0; Index<Blobs.size(); Index++)
- {
+ for (Index = 0; Index<Blobs.size(); Index++) {
#if MATROSKA_VERSION >= 2
if (Blobs[Index]->IsSimpleBlock())
PushElement( (KaxSimpleBlock&) *Blobs[Index] );
// SilentTracks handling
// check the parent cluster for existing tracks and see if they are contained in this cluster or not
- if (bSilentTracksUsed)
- {
+ if (bSilentTracksUsed) {
KaxTracks & MyTracks = *static_cast<KaxTracks *>(ParentSegment->FindElt(EBML_INFO(KaxTracks)));
- for (TrkItr = MyTracks.begin(); TrkItr != MyTracks.end(); ++TrkItr)
- {
- if (EbmlId(*(*TrkItr)) == EBML_ID(KaxTrackEntry))
- {
+ for (TrkItr = MyTracks.begin(); TrkItr != MyTracks.end(); ++TrkItr) {
+ if (EbmlId(*(*TrkItr)) == EBML_ID(KaxTrackEntry)) {
KaxTrackEntry & entry = *static_cast<KaxTrackEntry *>(*TrkItr);
uint32 tracknum = entry.TrackNumber();
for (Index = 0; Index<Blobs.size(); Index++) {
if (((KaxInternalBlock&)*Blobs[Index]).TrackNum() == tracknum)
- break; // this track is used
+ break; // this track is used
}
// the track wasn't found in this cluster
- if (Index == ListSize())
- {
+ if (Index == ListSize()) {
KaxClusterSilentTracks * SilentTracks = static_cast<KaxClusterSilentTracks *>(this->FindFirstElt(EBML_INFO(KaxClusterSilentTracks)));
assert(SilentTracks != NULL); // the flag bSilentTracksUsed should be set when creating the Cluster
KaxClusterSilentTrackNumber * trackelt = static_cast<KaxClusterSilentTrackNumber *>(SilentTracks->AddNewElt(EBML_INFO(KaxClusterSilentTrackNumber)));
void KaxCluster::ReleaseFrames()
{
- EBML_MASTER_ITERATOR Itr;
- for (Itr = begin(); Itr != end(); ++Itr)
- {
+ EBML_MASTER_ITERATOR Itr;
+ for (Itr = begin(); Itr != end(); ++Itr) {
if (EbmlId(*(*Itr)) == EBML_ID(KaxBlockGroup)) {
static_cast<KaxBlockGroup*>(*Itr)->ReleaseFrames();
}
BlockReference->SetBlockGroup(*const_cast<KaxBlockGroup*>(&BlockRef));
for (ListIdx = myTempReferences.begin(); ListIdx != myTempReferences.end(); ListIdx++)
- if (&(KaxBlockGroup&)*ListIdx == &BlockRef)
- {
- delete BlockReference;
+ if (&(KaxBlockGroup&)*ListIdx == &BlockRef) {
+ delete BlockReference;
return true;
- }
+ }
myTempReferences.push_back(BlockReference);
return true;
for (ListIdx = myTempReferences.begin(); ListIdx != myTempReferences.end(); ++ListIdx) {
const KaxInternalBlock &refTmp = **ListIdx;
if (refTmp.GlobalTimecode() == BlockRef.GlobalTimecode() &&
- refTmp.TrackNum() == BlockRef.TrackNumber()) {
+ refTmp.TrackNum() == BlockRef.TrackNumber()) {
// found, now add the element to the entry list
KaxCuePoint & NewPoint = AddNewChild<KaxCuePoint>(*this);
NewPoint.PositionSet(**ListIdx, GlobalTimecodeScale());
uint64 aPrevTime = 0;
uint64 aNextTime = EBML_PRETTYLONGINT(0xFFFFFFFFFFFF);
- EBML_MASTER_CONST_ITERATOR Itr;
- for (Itr = begin(); Itr != end(); ++Itr)
- {
+ EBML_MASTER_CONST_ITERATOR Itr;
+ for (Itr = begin(); Itr != end(); ++Itr) {
if (EbmlId(*(*Itr)) == EBML_ID(KaxCuePoint)) {
const KaxCuePoint *tmp = static_cast<const KaxCuePoint *>(*Itr);
// check the tile
const KaxCueTime *aTime = static_cast<const KaxCueTime *>(tmp->FindFirstElt(EBML_INFO(KaxCueTime)));
- if (aTime != NULL)
- {
+ if (aTime != NULL) {
uint64 _Time = uint64(*aTime);
if (_Time > aPrevTime && _Time < TimecodeToLocate) {
aPrevTime = _Time;
#if MATROSKA_VERSION >= 2
// handle reference use
- if (BlockReference.ReferenceCount() != 0)
- {
+ if (BlockReference.ReferenceCount() != 0) {
unsigned int i;
for (i=0; i<BlockReference.ReferenceCount(); i++) {
KaxCueReference & NewRefs = AddNewChild<KaxCueReference>(NewPositions);
#if 0 // MATROSKA_VERSION >= 2
// handle reference use
- if (BlockReference.ReferenceCount() != 0)
- {
+ if (BlockReference.ReferenceCount() != 0) {
unsigned int i;
for (i=0; i<BlockReference.ReferenceCount(); i++) {
KaxCueReference & NewRefs = AddNewChild<KaxCueReference>(NewPositions);
#ifdef OLD
// handle recursive reference use
- if (BlockReference.ReferenceCount() != 0)
- {
+ if (BlockReference.ReferenceCount() != 0) {
unsigned int i;
for (i=0; i<BlockReference.ReferenceCount(); i++) {
AddReference(BlockReference.Reference(i).RefBlock());
uint64 aPosition = EBML_PRETTYLONGINT(0xFFFFFFFFFFFFFFF);
// find the position of the "earlier" Cluster
const KaxCueTrackPositions *aPoss = static_cast<const KaxCueTrackPositions *>(FindFirstElt(EBML_INFO(KaxCueTrackPositions)));
- while (aPoss != NULL)
- {
+ while (aPoss != NULL) {
const KaxCueClusterPosition *aPos = static_cast<const KaxCueClusterPosition *>(aPoss->FindFirstElt(EBML_INFO(KaxCueClusterPosition)));
if (aPos != NULL && uint64(*aPos) < aPosition) {
aPosition = uint64(*aPos);
START_LIBMATROSKA_NAMESPACE
KaxPrevUID::KaxPrevUID(EBML_EXTRA_DEF)
-:KaxSegmentUID(EBML_DEF_BINARY_CTX(KaxPrevUID) EBML_DEF_SEP EBML_EXTRA_CALL)
+ :KaxSegmentUID(EBML_DEF_BINARY_CTX(KaxPrevUID) EBML_DEF_SEP EBML_EXTRA_CALL)
{
}
KaxNextUID::KaxNextUID(EBML_EXTRA_DEF)
-:KaxSegmentUID(EBML_DEF_BINARY_CTX(KaxNextUID) EBML_DEF_SEP EBML_EXTRA_CALL)
+ :KaxSegmentUID(EBML_DEF_BINARY_CTX(KaxNextUID) EBML_DEF_SEP EBML_EXTRA_CALL)
{
}
#if defined(HAVE_EBML2) || defined(HAS_EBML2)
KaxSegmentUID::KaxSegmentUID(EBML_DEF_CONS EBML_DEF_SEP EBML_EXTRA_DEF)
-:EbmlBinary(EBML_DEF_PARAM EBML_DEF_SEP EBML_EXTRA_CALL)
+ :EbmlBinary(EBML_DEF_PARAM EBML_DEF_SEP EBML_EXTRA_CALL)
{
}
#endif
KaxSeekID & aNewID = GetChild<KaxSeekID>(aNewPoint);
binary ID[4];
- ((const EbmlId&)aElt).Fill(ID);
+ ((const EbmlId&)aElt).Fill(ID);
aNewID.CopyBuffer(ID, EBML_ID_LENGTH((const EbmlId&)aElt));
}
{
// parse all the Entries and find the first to match the type
KaxSeek * aElt = static_cast<KaxSeek *>(FindFirstElt(EBML_INFO(KaxSeek)));
- while (aElt != NULL)
- {
+ while (aElt != NULL) {
KaxSeekID * aId = NULL;
- EBML_MASTER_ITERATOR Itr;
- for (Itr = aElt->begin(); Itr != aElt->end(); ++Itr)
- {
+ EBML_MASTER_ITERATOR Itr;
+ for (Itr = aElt->begin(); Itr != aElt->end(); ++Itr) {
if (EbmlId(*(*Itr)) == EBML_ID(KaxSeekID)) {
aId = static_cast<KaxSeekID*>(*Itr);
EbmlId aEbmlId(aId->GetBuffer(), aId->GetSize());
- if (aEbmlId == EBML_INFO_ID(Callbacks))
- {
+ if (aEbmlId == EBML_INFO_ID(Callbacks)) {
return aElt;
}
break;
KaxSeek * KaxSeekHead::FindNextOf(const KaxSeek &aPrev) const
{
- EBML_MASTER_CONST_ITERATOR Itr;
+ EBML_MASTER_CONST_ITERATOR Itr;
KaxSeek *tmp;
// look for the previous in the list
- for (Itr = begin(); Itr != end(); ++Itr)
- {
+ for (Itr = begin(); Itr != end(); ++Itr) {
if (*Itr == static_cast<const EbmlElement*>(&aPrev))
break;
}
- if (Itr != end())
- {
+ if (Itr != end()) {
++Itr;
- for (; Itr != end(); ++Itr)
- {
- if (EbmlId(*(*Itr)) == EBML_ID(KaxSeek))
- {
+ for (; Itr != end(); ++Itr) {
+ if (EbmlId(*(*Itr)) == EBML_ID(KaxSeek)) {
tmp = (KaxSeek *)(*Itr);
if (tmp->IsEbmlId(aPrev))
return tmp;
}
KaxSegment::KaxSegment(const KaxSegment & ElementToClone)
- :EbmlMaster(ElementToClone)
+ :EbmlMaster(ElementToClone)
{
// update the parent of each children
EBML_MASTER_ITERATOR Itr = begin();
- while (Itr != end())
- {
+ while (Itr != end()) {
if (EbmlId(**Itr) == EBML_ID(KaxCluster)) {
static_cast<KaxCluster *>(*Itr)->SetParent(*this);
}
- ++Itr;
+ ++Itr;
}
}