From: Steve Lhomme Date: Mon, 15 Mar 2010 16:03:51 +0000 (+0000) Subject: use the new accessors internally X-Git-Tag: release-0.9.0~51 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=55957a351e47061a745b6bea4e27cfe60065609e;p=libmatroska use the new accessors internally + make the new accessors inline git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libmatroska@13 a6f86f6d-0131-4f8e-9e7b-e335508773d5 --- diff --git a/matroska/KaxBlock.h b/matroska/KaxBlock.h index 1ca08e3..f114992 100644 --- a/matroska/KaxBlock.h +++ b/matroska/KaxBlock.h @@ -365,7 +365,7 @@ class MATROSKA_DLL_API KaxBlockDuration : public EbmlUInteger { #if MATROSKA_VERSION >= 2 class MATROSKA_DLL_API KaxBlockVirtual : public EbmlBinary { public: - KaxBlockVirtual() :ParentCluster(NULL) {Data = DataBlock; Size = countof(DataBlock);} + KaxBlockVirtual() :ParentCluster(NULL) {SetBuffer(DataBlock,sizeof(DataBlock)); SetValueIsSet(false);} KaxBlockVirtual(const KaxBlockVirtual & ElementToClone); static EbmlElement & Create() {return *(new KaxBlockVirtual);} const EbmlCallbacks & Generic() const {return ClassInfos;} diff --git a/matroska/KaxInfoData.h b/matroska/KaxInfoData.h index ee185a7..5325c1a 100644 --- a/matroska/KaxInfoData.h +++ b/matroska/KaxInfoData.h @@ -54,7 +54,7 @@ class MATROSKA_DLL_API KaxSegmentUID : public EbmlBinary { KaxSegmentUID() {} KaxSegmentUID(const KaxSegmentUID & ElementToClone) :EbmlBinary(ElementToClone){} static EbmlElement & Create() {return *(new KaxSegmentUID);} - bool ValidateSize() const { return (Size == 16);} + bool ValidateSize() const { return (GetSize() == 16);} const EbmlCallbacks & Generic() const {return ClassInfos;} static const EbmlCallbacks ClassInfos; operator const EbmlId &() const {return ClassInfos.GlobalId;} @@ -77,7 +77,7 @@ class MATROSKA_DLL_API KaxPrevUID : public KaxSegmentUID { KaxPrevUID() {} KaxPrevUID(const KaxPrevUID & ElementToClone) :KaxSegmentUID(ElementToClone){} static EbmlElement & Create() {return *(new KaxPrevUID);} - bool ValidateSize() const { return (Size == 16);} + bool ValidateSize() const { return (GetSize() == 16);} const EbmlCallbacks & Generic() const {return ClassInfos;} static const EbmlCallbacks ClassInfos; operator const EbmlId &() const {return ClassInfos.GlobalId;} @@ -100,7 +100,7 @@ class MATROSKA_DLL_API KaxNextUID : public KaxSegmentUID { KaxNextUID() {} KaxNextUID(const KaxNextUID & ElementToClone) :KaxSegmentUID(ElementToClone){} static EbmlElement & Create() {return *(new KaxNextUID);} - bool ValidateSize() const { return (Size == 16);} + bool ValidateSize() const { return (GetSize() == 16);} const EbmlCallbacks & Generic() const {return ClassInfos;} static const EbmlCallbacks ClassInfos; operator const EbmlId &() const {return ClassInfos.GlobalId;} @@ -123,7 +123,7 @@ class MATROSKA_DLL_API KaxSegmentFamily : public EbmlBinary { KaxSegmentFamily() {} KaxSegmentFamily(const KaxSegmentFamily & ElementToClone) :EbmlBinary(ElementToClone){} static EbmlElement & Create() {return *(new KaxSegmentFamily);} - bool ValidateSize() const { return (Size == 16);} + bool ValidateSize() const { return (GetSize() == 16);} const EbmlCallbacks & Generic() const {return ClassInfos;} static const EbmlCallbacks ClassInfos; operator const EbmlId &() const {return ClassInfos.GlobalId;} diff --git a/matroska/KaxSeekHead.h b/matroska/KaxSeekHead.h index 1b269fc..d3c2b4f 100644 --- a/matroska/KaxSeekHead.h +++ b/matroska/KaxSeekHead.h @@ -90,7 +90,7 @@ class MATROSKA_DLL_API KaxSeekID : public EbmlBinary { const EbmlCallbacks & Generic() const {return ClassInfos;} static const EbmlCallbacks ClassInfos; operator const EbmlId &() const {return ClassInfos.GlobalId;} - bool ValidateSize() const {return Size <= 4;} + bool ValidateSize() const {return GetSize() <= 4;} EbmlElement * Clone() const {return new KaxSeekID(*this);} }; diff --git a/matroska/KaxTag.h b/matroska/KaxTag.h index 8bf1325..98e64eb 100644 --- a/matroska/KaxTag.h +++ b/matroska/KaxTag.h @@ -687,7 +687,7 @@ class MATROSKA_DLL_API KaxTagBinary : public EbmlBinary { KaxTagBinary() {} KaxTagBinary(const KaxTagBinary & ElementToClone) :EbmlBinary(ElementToClone){} static EbmlElement & Create() {return *(new KaxTagBinary);} - bool ValidateSize() const {return (Size >= 0);} + bool ValidateSize() const {return true;} // {return (GetSize() >= 0);} const EbmlCallbacks & Generic() const {return ClassInfos;} static const EbmlCallbacks ClassInfos; operator const EbmlId &() const {return ClassInfos.GlobalId;} diff --git a/matroska/KaxTrackVideo.h b/matroska/KaxTrackVideo.h index 92c0cf3..9a2678c 100644 --- a/matroska/KaxTrackVideo.h +++ b/matroska/KaxTrackVideo.h @@ -199,7 +199,7 @@ class MATROSKA_DLL_API KaxVideoColourSpace : public EbmlBinary { static EbmlElement & Create() {return *(new KaxVideoColourSpace);} const EbmlCallbacks & Generic() const {return ClassInfos;} static const EbmlCallbacks ClassInfos; - bool ValidateSize(void) const {return (Size == 4);} + bool ValidateSize(void) const {return (GetSize() == 4);} operator const EbmlId &() const {return ClassInfos.GlobalId;} EbmlElement * Clone() const {return new KaxVideoColourSpace(*this);} }; diff --git a/src/KaxBlock.cpp b/src/KaxBlock.cpp index 9b121ab..2e95c72 100644 --- a/src/KaxBlock.cpp +++ b/src/KaxBlock.cpp @@ -134,7 +134,7 @@ SimpleDataBuffer::SimpleDataBuffer(const SimpleDataBuffer & ToClone) bool KaxInternalBlock::ValidateSize() const { - return (Size >= 4); /// for the moment + return (GetSize() >= 4); /// for the moment } KaxInternalBlock::~KaxInternalBlock() @@ -188,7 +188,7 @@ KaxBlockMore::KaxBlockMore() */ bool KaxInternalBlock::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, LacingType lacing, bool invisible) { - bValueIsSet = true; + SetValueIsSet(); if (myBuffers.size() == 0) { // first frame Timecode = timecode; @@ -228,7 +228,7 @@ LacingType KaxInternalBlock::GetBestLacingType() const { SameSize = false; XiphLacingSize += myBuffers[i]->Size() / 255 + 1; } - EbmlLacingSize += CodedSizeLength(myBuffers[0]->Size(), 0, bSizeIsFinite); + EbmlLacingSize += CodedSizeLength(myBuffers[0]->Size(), 0, IsFiniteSize()); for (i = 1; i < (int)myBuffers.size() - 1; i++) EbmlLacingSize += CodedSizeLengthSigned(int64(myBuffers[i]->Size()) - int64(myBuffers[i - 1]->Size()), 0); if (SameSize) @@ -242,20 +242,20 @@ LacingType KaxInternalBlock::GetBestLacingType() const { uint64 KaxInternalBlock::UpdateSize(bool bSaveDefault, bool bForceRender) { LacingType LacingHere; - assert(Data == NULL); // Data is not used for KaxInternalBlock + assert(GetData() == NULL); // Data is not used for KaxInternalBlock assert(TrackNumber < 0x4000); // no more allowed for the moment unsigned int i; // compute the final size of the data switch (myBuffers.size()) { case 0: - Size = 0; + SetSize_(0); break; case 1: - Size = 4 + myBuffers[0]->Size(); + SetSize_(4 + myBuffers[0]->Size()); break; default: - Size = 4 + 1; // 1 for the lacing head + SetSize_(4 + 1); // 1 for the lacing head if (mLacing == LACING_AUTO) LacingHere = GetBestLacingType(); else @@ -264,33 +264,32 @@ uint64 KaxInternalBlock::UpdateSize(bool bSaveDefault, bool bForceRender) { case LACING_XIPH: for (i=0; iSize() + (myBuffers[i]->Size() / 0xFF + 1); + SetSize_(GetSize() + myBuffers[i]->Size() + (myBuffers[i]->Size() / 0xFF + 1)); } break; case LACING_EBML: - Size += myBuffers[0]->Size() + CodedSizeLength(myBuffers[0]->Size(), 0, bSizeIsFinite); + SetSize_(GetSize() + myBuffers[0]->Size() + CodedSizeLength(myBuffers[0]->Size(), 0, IsFiniteSize())); for (i=1; iSize() - + CodedSizeLengthSigned(int64(myBuffers[i]->Size()) - int64(myBuffers[i-1]->Size()), 0);; + SetSize_(GetSize() + myBuffers[i]->Size() + CodedSizeLengthSigned(int64(myBuffers[i]->Size()) - int64(myBuffers[i-1]->Size()), 0)); } break; case LACING_FIXED: for (i=0; iSize(); + SetSize_(GetSize() + myBuffers[i]->Size()); } break; default: assert(0); } // Size of the last frame (not in lace) - Size += myBuffers[i]->Size(); + SetSize_(GetSize() + myBuffers[i]->Size()); break; } if (TrackNumber >= 0x80) - Size++; // the size will be coded with one more octet + SetSize_(GetSize() + 1); // the size will be coded with one more octet - return Size; + return GetSize(); } #if MATROSKA_VERSION >= 2 @@ -300,13 +299,14 @@ KaxBlockVirtual::KaxBlockVirtual(const KaxBlockVirtual & ElementToClone) ,TrackNumber(ElementToClone.TrackNumber) ,ParentCluster(ElementToClone.ParentCluster) ///< \todo not exactly { - Data = DataBlock; + SetBuffer(DataBlock,sizeof(DataBlock)); + SetValueIsSet(false); } uint64 KaxBlockVirtual::UpdateSize(bool bSaveDefault, bool bForceRender) { assert(TrackNumber < 0x4000); - binary *cursor = Data; + binary *cursor = GetData(); // fill data if (TrackNumber < 0x80) { *cursor++ = TrackNumber | 0x80; // set the first bit to 1 @@ -323,7 +323,7 @@ uint64 KaxBlockVirtual::UpdateSize(bool bSaveDefault, bool bForceRender) *cursor++ = 0; // flags - return Size; + return GetSize(); } #endif // MATROSKA_VERSION @@ -341,15 +341,15 @@ uint32 KaxInternalBlock::RenderData(IOCallback & output, bool bForceRender, bool unsigned int i; if (myBuffers.size() == 1) { - Size = 4; + SetSize_(4); mLacing = LACING_NONE; } else { if (mLacing == LACING_NONE) mLacing = LACING_EBML; // supposedly the best of all - Size = 4 + 1; // 1 for the lacing head (number of laced elements) + SetSize_(4 + 1); // 1 for the lacing head (number of laced elements) } if (TrackNumber > 0x80) - Size++; + SetSize_(GetSize() + 1); // write Block Head if (TrackNumber < 0x80) { @@ -416,12 +416,12 @@ uint32 KaxInternalBlock::RenderData(IOCallback & output, bool bForceRender, bool uint16 tmpSize = myBuffers[i]->Size(); while (tmpSize >= 0xFF) { output.writeFully(&tmpValue, 1); - Size++; + SetSize_(GetSize() + 1); tmpSize -= 0xFF; } tmpValue = binary(tmpSize); output.writeFully(&tmpValue, 1); - Size++; + SetSize_(GetSize() + 1); } break; case LACING_EBML: @@ -436,12 +436,12 @@ uint32 KaxInternalBlock::RenderData(IOCallback & output, bool bForceRender, bool _Size = myBuffers[0]->Size(); - _CodedSize = CodedSizeLength(_Size, 0, bSizeIsFinite); + _CodedSize = CodedSizeLength(_Size, 0, IsFiniteSize()); // first size in the lace is not a signed CodedValueLength(_Size, _CodedSize, _FinalHead); output.writeFully(_FinalHead, _CodedSize); - Size += _CodedSize; + SetSize_(GetSize() + _CodedSize); // set the size of each member in the lace for (i=1; iBuffer(), myBuffers[i]->Size()); - Size += myBuffers[i]->Size(); + SetSize_(GetSize() + myBuffers[i]->Size()); } } - return Size; + return GetSize(); } uint64 KaxInternalBlock::ReadInternalHead(IOCallback & input) @@ -519,7 +519,7 @@ uint64 KaxInternalBlock::ReadData(IOCallback & input, ScopeMode ReadFully) if (ReadFully == SCOPE_ALL_DATA) { Result = EbmlBinary::ReadData(input, ReadFully); - binary *cursor = Data; + binary *cursor = GetData(); uint8 BlockHeadSize = 4; // update internal values @@ -552,14 +552,14 @@ uint64 KaxInternalBlock::ReadData(IOCallback & input, ScopeMode ReadFully) // put all Frames in the list if (mLacing == LACING_NONE) { - FirstFrameLocation += cursor - Data; - DataBuffer * soloFrame = new DataBuffer(cursor, Size - BlockHeadSize); + FirstFrameLocation += cursor - GetData(); + DataBuffer * soloFrame = new DataBuffer(cursor, GetSize() - BlockHeadSize); myBuffers.push_back(soloFrame); SizeList.resize(1); - SizeList[0] = Size - BlockHeadSize; + SizeList[0] = GetSize() - BlockHeadSize; } else { // read the number of frames in the lace - uint32 LastBufferSize = Size - BlockHeadSize - 1; // 1 for number of frame + uint32 LastBufferSize = GetSize() - BlockHeadSize - 1; // 1 for number of frame uint8 FrameNum = *cursor++; // number of frames in the lace - 1 // read the list of frame sizes uint8 Index; @@ -611,7 +611,7 @@ uint64 KaxInternalBlock::ReadData(IOCallback & input, ScopeMode ReadFully) assert(0); } - FirstFrameLocation += cursor - Data; + FirstFrameLocation += cursor - GetData(); for (Index=0; Index<=FrameNum; Index++) { DataBuffer * lacedFrame = new DataBuffer(cursor, SizeList[Index]); @@ -619,7 +619,7 @@ uint64 KaxInternalBlock::ReadData(IOCallback & input, ScopeMode ReadFully) cursor += SizeList[Index]; } } - bValueIsSet = true; + SetValueIsSet(); } else if (ReadFully == SCOPE_PARTIAL_DATA) { @@ -668,7 +668,7 @@ uint64 KaxInternalBlock::ReadData(IOCallback & input, ScopeMode ReadFully) // put all Frames in the list if (mLacing != LACING_NONE) { // read the number of frames in the lace - uint32 LastBufferSize = Size - BlockHeadSize - 1; // 1 for number of frame + uint32 LastBufferSize = GetSize() - BlockHeadSize - 1; // 1 for number of frame uint8 FrameNum = _TempHead[0]; // number of frames in the lace - 1 // read the list of frame sizes uint8 Index; @@ -732,13 +732,13 @@ uint64 KaxInternalBlock::ReadData(IOCallback & input, ScopeMode ReadFully) } } else { SizeList.resize(1); - SizeList[0] = Size - BlockHeadSize; + SizeList[0] = GetSize() - BlockHeadSize; } - bValueIsSet = false; - Result = Size; + SetValueIsSet(false); + Result = GetSize(); } else { - bValueIsSet = false; - Result = Size; + SetValueIsSet(false); + Result = GetSize(); } return Result; @@ -937,7 +937,7 @@ int64 KaxInternalBlock::GetDataPosition(size_t FrameNumber) { int64 _Result = -1; - if (bValueIsSet && FrameNumber < SizeList.size()) + if (ValueIsSet() && FrameNumber < SizeList.size()) { _Result = FirstFrameLocation; diff --git a/src/KaxBlockData.cpp b/src/KaxBlockData.cpp index 1c5b979..216f409 100644 --- a/src/KaxBlockData.cpp +++ b/src/KaxBlockData.cpp @@ -124,7 +124,7 @@ void KaxReferenceBlock::SetReferencedBlock(const KaxBlockBlob * aRefdBlock) assert(RefdBlock == NULL); assert(aRefdBlock != NULL); RefdBlock = aRefdBlock; - bValueIsSet = true; + SetValueIsSet(); } void KaxReferenceBlock::SetReferencedBlock(const KaxBlockGroup & aRefdBlock) @@ -132,7 +132,7 @@ void KaxReferenceBlock::SetReferencedBlock(const KaxBlockGroup & aRefdBlock) KaxBlockBlob *block_blob = new KaxBlockBlob(BLOCK_BLOB_NO_SIMPLE); block_blob->SetBlockGroup(*const_cast(&aRefdBlock)); RefdBlock = block_blob; - bValueIsSet = true; + SetValueIsSet(); } END_LIBMATROSKA_NAMESPACE diff --git a/src/KaxCluster.cpp b/src/KaxCluster.cpp index d520e7a..807181a 100644 --- a/src/KaxCluster.cpp +++ b/src/KaxCluster.cpp @@ -75,8 +75,8 @@ KaxCluster::KaxCluster(const KaxCluster & ElementToClone) ,bSilentTracksUsed(ElementToClone.bSilentTracksUsed) { // update the parent of each children - std::vector::const_iterator Itr = ElementList.begin(); - while (Itr != ElementList.end()) + std::vector::const_iterator Itr = begin(); + while (Itr != end()) { if (EbmlId(**Itr) == KaxBlockGroup::ClassInfos.GlobalId) { static_cast(*Itr)->SetParent(*this); @@ -193,15 +193,15 @@ uint32 KaxCluster::Render(IOCallback & output, KaxCues & CueToUpdate, bool bSave { KaxTrackEntry & entry = *static_cast(MyTracks[TrkIndex]); uint32 tracknum = entry.TrackNumber(); - for (Index = 0; Index < ElementList.size(); Index++) { - if (EbmlId(*ElementList[Index]) == KaxBlockGroup::ClassInfos.GlobalId) { - KaxBlockGroup & group = *static_cast(ElementList[Index]); + for (Index = 0; Index < ListSize(); Index++) { + if (EbmlId(*(*this)[Index]) == KaxBlockGroup::ClassInfos.GlobalId) { + KaxBlockGroup & group = *static_cast((*this)[Index]); if (group.TrackNumber() == tracknum) break; // this track is used } } // the track wasn't found in this cluster - if (Index == ElementList.size()) + if (Index == ListSize()) { KaxClusterSilentTracks * SilentTracks = static_cast(this->FindFirstElt(KaxClusterSilentTracks::ClassInfos)); assert(SilentTracks != NULL); // the flag bSilentTracksUsed should be set when creating the Cluster @@ -215,9 +215,9 @@ uint32 KaxCluster::Render(IOCallback & output, KaxCues & CueToUpdate, bool bSave 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(ElementList[Index])); + for (Index = 0; Index < ListSize(); Index++) { + if (EbmlId(*(*this)[Index]) == KaxBlockGroup::ClassInfos.GlobalId) { + CueToUpdate.PositionSet(*static_cast((*this)[Index])); } } } else { @@ -226,10 +226,10 @@ uint32 KaxCluster::Render(IOCallback & output, KaxCues & CueToUpdate, bool bSave { #if MATROSKA_VERSION >= 2 if (Blobs[Index]->IsSimpleBlock()) - ElementList.push_back( &(KaxSimpleBlock&) *Blobs[Index] ); + PushElement( (KaxSimpleBlock&) *Blobs[Index] ); else #endif - ElementList.push_back( &(KaxBlockGroup&) *Blobs[Index] ); + PushElement( (KaxBlockGroup&) *Blobs[Index] ); } // SilentTracks handling @@ -247,7 +247,7 @@ uint32 KaxCluster::Render(IOCallback & output, KaxCues & CueToUpdate, bool bSave break; // this track is used } // the track wasn't found in this cluster - if (Index == ElementList.size()) + if (Index == ListSize()) { KaxClusterSilentTracks * SilentTracks = static_cast(this->FindFirstElt(KaxClusterSilentTracks::ClassInfos)); assert(SilentTracks != NULL); // the flag bSilentTracksUsed should be set when creating the Cluster @@ -319,9 +319,9 @@ void KaxCluster::ReleaseFrames() { size_t Index; - for (Index = 0; Index < ElementList.size(); Index++) { - if (EbmlId(*ElementList[Index]) == KaxBlockGroup::ClassInfos.GlobalId) { - static_cast(ElementList[Index])->ReleaseFrames(); + for (Index = 0; Index < ListSize(); Index++) { + if (EbmlId(*(*this)[Index]) == KaxBlockGroup::ClassInfos.GlobalId) { + static_cast((*this)[Index])->ReleaseFrames(); } } } diff --git a/src/KaxCuesData.cpp b/src/KaxCuesData.cpp index 17b688c..0140226 100644 --- a/src/KaxCuesData.cpp +++ b/src/KaxCuesData.cpp @@ -166,7 +166,7 @@ void KaxCuePoint::PositionSet(const KaxBlockGroup & BlockReference, uint64 Globa } #endif // MATROSKA_VERSION - bValueIsSet = true; + SetValueIsSet(); } void KaxCuePoint::PositionSet(const KaxBlockBlob & BlobReference, uint64 GlobalTimecodeScale) @@ -207,7 +207,7 @@ void KaxCuePoint::PositionSet(const KaxBlockBlob & BlobReference, uint64 GlobalT } #endif // MATROSKA_VERSION - bValueIsSet = true; + SetValueIsSet(); } #if MATROSKA_VERSION >= 2 diff --git a/src/KaxSeekHead.cpp b/src/KaxSeekHead.cpp index 63efdad..4dfceca 100644 --- a/src/KaxSeekHead.cpp +++ b/src/KaxSeekHead.cpp @@ -126,19 +126,19 @@ KaxSeek * KaxSeekHead::FindNextOf(const KaxSeek &aPrev) const KaxSeek *tmp; // look for the previous in the list - for (iIndex = 0; iIndex(&aPrev)) + if ((*this)[iIndex] == static_cast(&aPrev)) break; } - if (iIndex (ElementList[iIndex]); + tmp = (KaxSeek *)((*this)[iIndex]); if (tmp->IsEbmlId(aPrev)) return tmp; } diff --git a/src/KaxSegment.cpp b/src/KaxSegment.cpp index 4bafab1..34bcad9 100644 --- a/src/KaxSegment.cpp +++ b/src/KaxSegment.cpp @@ -83,8 +83,8 @@ KaxSegment::KaxSegment(const KaxSegment & ElementToClone) :EbmlMaster(ElementToClone) { // update the parent of each children - std::vector::const_iterator Itr = ElementList.begin(); - while (Itr != ElementList.end()) + std::vector::const_iterator Itr = begin(); + while (Itr != end()) { if (EbmlId(**Itr) == KaxCluster::ClassInfos.GlobalId) { static_cast(*Itr)->SetParent(*this);