DataBuffer * DataBuffer::Clone()
{
auto ClonedData = static_cast<binary *>(malloc(mySize * sizeof(binary)));
- assert(ClonedData != nullptr);
+ assert(ClonedData);
memcpy(ClonedData, myBuffer ,mySize );
auto result = new SimpleDataBuffer(ClonedData, mySize, 0);
SimpleDataBuffer::SimpleDataBuffer(const SimpleDataBuffer & ToClone)
:DataBuffer(static_cast<binary *>(malloc(ToClone.mySize * sizeof(binary))), ToClone.mySize, myFreeBuffer)
{
- assert(myBuffer != nullptr);
+ assert(myBuffer);
memcpy(myBuffer, ToClone.myBuffer ,mySize );
bValidValue = ToClone.bValidValue;
}
filepos_t KaxInternalBlock::UpdateSize(bool /* bSaveDefault */, bool /* bForceRender */)
{
LacingType LacingHere;
- assert(EbmlBinary::GetBuffer() == nullptr); // Data is not used for KaxInternalBlock
+ assert(!EbmlBinary::GetBuffer()); // Data is not used for KaxInternalBlock
assert(TrackNumber < 0x4000); // no more allowed for the moment
unsigned int i;
*cursor++ = TrackNumber & 0xFF;
}
- assert(ParentCluster != nullptr);
+ assert(ParentCluster);
const int16 ActualTimecode = ParentCluster->GetBlockLocalTimecode(Timecode);
const auto b16 = big_int16(ActualTimecode);
b16.Fill(cursor);
*cursor++ = TrackNumber & 0xFF;
}
- assert(ParentCluster != nullptr);
+ assert(ParentCluster);
const int16 ActualTimecode = ParentCluster->GetBlockLocalTimecode(Timecode);
const auto b16 = big_int16(ActualTimecode);
b16.Fill(cursor);
big_int16 b16;
b16.Eval(cursor);
- assert(ParentCluster != nullptr);
+ assert(ParentCluster);
Timecode = ParentCluster->GetBlockGlobalTimecode(static_cast<int16>(b16));
bLocalTimecodeUsed = false;
cursor += 2;
bool KaxBlockGroup::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, LacingType lacing)
{
auto & theBlock = GetChild<KaxBlock>(*this);
- assert(ParentCluster != nullptr);
+ assert(ParentCluster);
theBlock.SetParent(*ParentCluster);
ParentTrack = &track;
return theBlock.AddFrame(track, timecode, buffer, lacing);
// assert(past_timecode < 0);
auto & theBlock = GetChild<KaxBlock>(*this);
- assert(ParentCluster != nullptr);
+ assert(ParentCluster);
theBlock.SetParent(*ParentCluster);
ParentTrack = &track;
const bool bRes = theBlock.AddFrame(track, timecode, buffer, lacing);
// assert(forw_timecode > 0);
auto & theBlock = GetChild<KaxBlock>(*this);
- assert(ParentCluster != nullptr);
+ assert(ParentCluster);
theBlock.SetParent(*ParentCluster);
ParentTrack = &track;
bool const bRes = theBlock.AddFrame(track, timecode, buffer, lacing);
bool KaxBlockGroup::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, const KaxBlockBlob * PastBlock, const KaxBlockBlob * ForwBlock, LacingType lacing)
{
auto & theBlock = GetChild<KaxBlock>(*this);
- assert(ParentCluster != nullptr);
+ assert(ParentCluster);
theBlock.SetParent(*ParentCluster);
ParentTrack = &track;
const bool bRes = theBlock.AddFrame(track, timecode, buffer, lacing);
- if (PastBlock != nullptr) {
+ if (PastBlock) {
auto & thePastRef = GetChild<KaxReferenceBlock>(*this);
thePastRef.SetReferencedBlock(PastBlock);
thePastRef.SetParentBlock(*this);
}
- if (ForwBlock != nullptr) {
+ if (ForwBlock) {
auto & theFutureRef = AddNewChild<KaxReferenceBlock>(*this);
theFutureRef.SetReferencedBlock(ForwBlock);
theFutureRef.SetParentBlock(*this);
*/
uint64 KaxBlockGroup::GlobalTimecode() const
{
- assert(ParentCluster != nullptr); // impossible otherwise
+ assert(ParentCluster); // impossible otherwise
auto MyBlock = static_cast<KaxBlock *>(this->FindElt(EBML_INFO(KaxBlock)));
return MyBlock->GlobalTimecode();
}
uint64 KaxBlockGroup::ClusterPosition() const
{
- assert(ParentCluster != nullptr); // impossible otherwise
+ assert(ParentCluster); // impossible otherwise
return ParentCluster->GetPosition();
}
uint64 KaxInternalBlock::ClusterPosition() const
{
- assert(ParentCluster != nullptr); // impossible otherwise
+ assert(ParentCluster); // impossible otherwise
return ParentCluster->GetPosition();
}
{
unsigned int Result = 0;
auto MyBlockAdds = static_cast<KaxReferenceBlock *>(FindFirstElt(EBML_INFO(KaxReferenceBlock)));
- if (MyBlockAdds != nullptr) {
+ if (MyBlockAdds) {
Result++;
- while ((MyBlockAdds = static_cast<KaxReferenceBlock *>(FindNextElt(*MyBlockAdds))) != nullptr) {
+ while ((MyBlockAdds = static_cast<KaxReferenceBlock *>(FindNextElt(*MyBlockAdds)))) {
Result++;
}
}
const KaxReferenceBlock & KaxBlockGroup::Reference(unsigned int Index) const
{
auto MyBlockAdds = static_cast<KaxReferenceBlock *>(FindFirstElt(EBML_INFO(KaxReferenceBlock)));
- assert(MyBlockAdds != nullptr); // call of a non existing reference
+ assert(MyBlockAdds); // call of a non existing reference
while (Index != 0) {
MyBlockAdds = static_cast<KaxReferenceBlock *>(FindNextElt(*MyBlockAdds));
- assert(MyBlockAdds != nullptr);
+ assert(MyBlockAdds);
Index--;
}
return *MyBlockAdds;
{
// free the allocated Frames
for (int i=myBuffers.size()-1; i>=0; i--) {
- if (myBuffers[i] != nullptr) {
+ if (myBuffers[i]) {
myBuffers[i]->FreeBuffer(*myBuffers[i]);
delete myBuffers[i];
myBuffers[i] = nullptr;
void KaxBlockGroup::SetBlockDuration(uint64 TimeLength)
{
- assert(ParentTrack != nullptr);
+ assert(ParentTrack);
const int64 scale = ParentTrack->GlobalTimecodeScale();
const auto& myDuration = static_cast<KaxBlockDuration *>(FindFirstElt(EBML_INFO(KaxBlockDuration), true));
*(static_cast<EbmlUInteger *>(myDuration)) = TimeLength / static_cast<uint64>(scale);
bool KaxBlockGroup::GetBlockDuration(uint64 &TheTimecode) const
{
- auto myDuration = static_cast<KaxBlockDuration *>(FindElt(EBML_INFO(KaxBlockDuration)));
- if (myDuration == nullptr) {
+ const auto myDuration = static_cast<KaxBlockDuration *>(FindElt(EBML_INFO(KaxBlockDuration)));
+ if (!myDuration) {
return false;
}
- assert(ParentTrack != nullptr);
+ assert(ParentTrack);
TheTimecode = static_cast<uint64>(*myDuration) * ParentTrack->GlobalTimecodeScale();
return true;
}
bool KaxBlockBlob::AddFrameAuto(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, LacingType lacing, const KaxBlockBlob * PastBlock, const KaxBlockBlob * ForwBlock)
{
bool bResult = false;
- if ((SimpleBlockMode == BLOCK_BLOB_ALWAYS_SIMPLE) || (SimpleBlockMode == BLOCK_BLOB_SIMPLE_AUTO && PastBlock == nullptr && ForwBlock == nullptr)) {
+ if ((SimpleBlockMode == BLOCK_BLOB_ALWAYS_SIMPLE) || (SimpleBlockMode == BLOCK_BLOB_SIMPLE_AUTO && !PastBlock && !ForwBlock)) {
assert(bUseSimpleBlock == true);
- if (Block.simpleblock == nullptr) {
+ if (!Block.simpleblock) {
Block.simpleblock = new KaxSimpleBlock();
Block.simpleblock->SetParent(*ParentCluster);
}
bResult = Block.simpleblock->AddFrame(track, timecode, buffer, lacing);
- if (PastBlock == nullptr && ForwBlock == nullptr) {
+ if (!PastBlock && !ForwBlock) {
Block.simpleblock->SetKeyframe(true);
Block.simpleblock->SetDiscardable(false);
} else {
Block.simpleblock->SetKeyframe(false);
- if ((ForwBlock == nullptr || static_cast<const KaxInternalBlock &>(*ForwBlock).GlobalTimecode() <= timecode) &&
- (PastBlock == nullptr || static_cast<const KaxInternalBlock &>(*PastBlock).GlobalTimecode() <= timecode))
+ if ((!ForwBlock || static_cast<const KaxInternalBlock &>(*ForwBlock).GlobalTimecode() <= timecode) &&
+ (!PastBlock || static_cast<const KaxInternalBlock &>(*PastBlock).GlobalTimecode() <= timecode))
Block.simpleblock->SetDiscardable(false);
else
Block.simpleblock->SetDiscardable(true);
return false;
if (!bUseSimpleBlock) {
- if (Block.group == nullptr) {
+ if (!Block.group) {
Block.group = new KaxBlockGroup();
}
}
else {
- if (Block.simpleblock != nullptr) {
- KaxSimpleBlock *const old_simpleblock = Block.simpleblock;
+ if (Block.simpleblock) {
+ auto old_simpleblock = Block.simpleblock;
Block.group = new KaxBlockGroup();
// _TODO_ : move all the data to the blockgroup
assert(false);
Block.group = new KaxBlockGroup();
}
}
- if (ParentCluster != nullptr)
+ if (ParentCluster)
Block.group->SetParent(*ParentCluster);
bUseSimpleBlock = false;
}
// force creation of a new block
- if (currentNewBlock == nullptr || static_cast<uint32>(track.TrackNumber()) != static_cast<uint32>(currentNewBlock->TrackNumber()) || PastBlock != nullptr || ForwBlock != nullptr) {
+ if (!currentNewBlock || static_cast<uint32>(track.TrackNumber()) != static_cast<uint32>(currentNewBlock->TrackNumber()) || PastBlock || ForwBlock) {
KaxBlockGroup & aNewBlock = GetNewBlock();
MyNewBlock = currentNewBlock = &aNewBlock;
}
- if (PastBlock != nullptr) {
- if (ForwBlock != nullptr) {
+ if (PastBlock) {
+ if (ForwBlock) {
if (currentNewBlock->AddFrame(track, timecode, buffer, *PastBlock, *ForwBlock, lacing)) {
// more data are allowed in this Block
return true;
// the track wasn't found in this cluster
if (track == ElementList.end()) {
auto SilentTracks = static_cast<KaxClusterSilentTracks *>(this->FindFirstElt(EBML_INFO(KaxClusterSilentTracks)));
- assert(SilentTracks != nullptr); // the flag bSilentTracksUsed should be set when creating the Cluster
+ assert(SilentTracks); // the flag bSilentTracksUsed should be set when creating the Cluster
auto trackelt = static_cast<KaxClusterSilentTrackNumber *>(SilentTracks->AddNewElt(EBML_INFO(KaxClusterSilentTrackNumber)));
*static_cast<EbmlUInteger *>(trackelt) = tracknum;
}
// the track wasn't found in this cluster
if (Index == ListSize()) {
auto SilentTracks = static_cast<KaxClusterSilentTracks *>(this->FindFirstElt(EBML_INFO(KaxClusterSilentTracks)));
- assert(SilentTracks != nullptr); // the flag bSilentTracksUsed should be set when creating the Cluster
+ assert(SilentTracks); // the flag bSilentTracksUsed should be set when creating the Cluster
auto trackelt = static_cast<KaxClusterSilentTrackNumber *>(SilentTracks->AddNewElt(EBML_INFO(KaxClusterSilentTrackNumber)));
*static_cast<EbmlUInteger *>(trackelt) = tracknum;
}
uint64 KaxCluster::GetPosition() const
{
- assert(ParentSegment != nullptr);
+ assert(ParentSegment);
return ParentSegment->GetRelativePosition(*this);
}
}
auto CodecState = static_cast<KaxCodecState *>(BlockReference.FindFirstElt(EBML_INFO(KaxCodecState)));
- if (CodecState != nullptr) {
+ if (CodecState) {
auto &CueCodecState = AddNewChild<KaxCueCodecState>(NewPositions);
*static_cast<EbmlUInteger*>(&CueCodecState) = BlockReference.GetParentCluster()->GetParentSegment()->GetRelativePosition(CodecState->GetElementPosition());
}
}
#endif // MATROSKA_VERSION
- if (BlockGroup != nullptr) {
+ if (BlockGroup) {
const auto CodecState = static_cast<const KaxCodecState *>(BlockGroup->FindFirstElt(EBML_INFO(KaxCodecState)));
- if (CodecState != nullptr) {
+ if (CodecState) {
auto &CueCodecState = AddNewChild<KaxCueCodecState>(NewPositions);
*static_cast<EbmlUInteger*>(&CueCodecState) = BlockGroup->GetParentCluster()->GetParentSegment()->GetRelativePosition(CodecState->GetElementPosition());
}
// compare timecode
auto TimeCodeA = static_cast<const KaxCueTime *>(FindElt(EBML_INFO(KaxCueTime)));
- if (TimeCodeA == nullptr)
+ if (!TimeCodeA)
return false;
auto TimeCodeB = static_cast<const KaxCueTime *>(theCmp->FindElt(EBML_INFO(KaxCueTime)));
- if (TimeCodeB == nullptr)
+ if (!TimeCodeB)
return false;
if (TimeCodeA->IsSmallerThan(TimeCodeB))
return false;
// compare tracks (timecodes are equal)
- auto TrackA = static_cast<const KaxCueTrack *>(FindElt(EBML_INFO(KaxCueTrack)));
- if (TrackA == nullptr)
+ const auto TrackA = static_cast<const KaxCueTrack *>(FindElt(EBML_INFO(KaxCueTrack)));
+ if (!TrackA)
return false;
- auto TrackB = static_cast<const KaxCueTrack *>(theCmp->FindElt(EBML_INFO(KaxCueTrack)));
- if (TrackB == nullptr)
+ const auto TrackB = static_cast<const KaxCueTrack *>(theCmp->FindElt(EBML_INFO(KaxCueTrack)));
+ if (!TrackB)
return false;
if (TrackA->IsSmallerThan(TrackB))
bool KaxCuePoint::Timecode(uint64 & aTimecode, uint64 GlobalTimecodeScale) const
{
- auto aTime = static_cast<const KaxCueTime *>(FindFirstElt(EBML_INFO(KaxCueTime)));
- if (aTime == nullptr)
+ const auto aTime = static_cast<const KaxCueTime *>(FindFirstElt(EBML_INFO(KaxCueTime)));
+ if (!aTime)
return false;
aTimecode = static_cast<uint64>(*aTime) * GlobalTimecodeScale;
return true;
uint64 aPosition = EBML_PRETTYLONGINT(0xFFFFFFFFFFFFFFF);
// find the position of the "earlier" Cluster
auto aPoss = static_cast<const KaxCueTrackPositions *>(FindFirstElt(EBML_INFO(KaxCueTrackPositions)));
- while (aPoss != nullptr) {
+ while (aPoss) {
auto aPos = static_cast<const KaxCueClusterPosition *>(aPoss->FindFirstElt(EBML_INFO(KaxCueClusterPosition)));
- if (aPos != nullptr && static_cast<uint64>(*aPos) < aPosition) {
+ if (aPos && static_cast<uint64>(*aPos) < aPosition) {
aPosition = static_cast<uint64>(*aPos);
result = aPoss;
}
uint64 KaxCueTrackPositions::ClusterPosition() const
{
- auto aPos = static_cast<const KaxCueClusterPosition *>(FindFirstElt(EBML_INFO(KaxCueClusterPosition)));
- if (aPos == nullptr)
+ const auto aPos = static_cast<const KaxCueClusterPosition *>(FindFirstElt(EBML_INFO(KaxCueClusterPosition)));
+ if (!aPos)
return 0;
return static_cast<uint64>(*aPos);
uint16 KaxCueTrackPositions::TrackNumber() const
{
- auto aTrack = static_cast<const KaxCueTrack *>(FindFirstElt(EBML_INFO(KaxCueTrack)));
- if (aTrack == nullptr)
+ const auto aTrack = static_cast<const KaxCueTrack *>(FindFirstElt(EBML_INFO(KaxCueTrack)));
+ if (!aTrack)
return 0;
return static_cast<uint16>(*aTrack);