}
assert(ParentCluster != nullptr);
- int16 ActualTimecode = ParentCluster->GetBlockLocalTimecode(Timecode);
- big_int16 b16(ActualTimecode);
+ const int16 ActualTimecode = ParentCluster->GetBlockLocalTimecode(Timecode);
+ const auto b16 = big_int16(ActualTimecode);
b16.Fill(cursor);
cursor += 2;
}
assert(ParentCluster != nullptr);
- int16 ActualTimecode = ParentCluster->GetBlockLocalTimecode(Timecode);
- big_int16 b16(ActualTimecode);
+ const int16 ActualTimecode = ParentCluster->GetBlockLocalTimecode(Timecode);
+ const auto b16 = big_int16(ActualTimecode);
b16.Fill(cursor);
cursor += 2;
LocalTimecode = static_cast<int16>(Mem.GetUInt16BE());
bLocalTimecodeUsed = true;
- uint8 Flags = Mem.GetUInt8();
+ const uint8 Flags = Mem.GetUInt8();
if (EbmlId(*this) == EBML_ID(KaxSimpleBlock)) {
bIsKeyframe = (Flags & 0x80) != 0;
bIsDiscardable = (Flags & 0x01) != 0;
} else {
// read the number of frames in the lace
uint32 LastBufferSize = GetSize() - BlockHeadSize - 1; // 1 for number of frame
- uint8 FrameNum = Mem.GetUInt8(); // number of frames in the lace - 1
+ const uint8 FrameNum = Mem.GetUInt8(); // number of frames in the lace - 1
// read the list of frame sizes
uint8 Index;
int32 FrameSize;
}
binary *BufferEnd = BufferStart + GetSize();
- size_t NumFrames = myBuffers.size();
+ const size_t NumFrames = myBuffers.size();
// Sanity checks for frame pointers and boundaries.
for (size_t Index = 0; Index < NumFrames; ++Index) {
// read the number of frames in the lace
const uint32 TotalLacedSize = GetSize() - BlockHeadSize - 1; // 1 for number of frame
uint32 LastBufferSize = TotalLacedSize;
- uint8 FrameNum = _TempHead[0]; // number of frames in the lace - 1
+ const uint8 FrameNum = _TempHead[0]; // number of frames in the lace - 1
// read the list of frame sizes
uint8 Index;
uint32 FrameSize;
assert(ParentCluster != nullptr);
theBlock.SetParent(*ParentCluster);
ParentTrack = &track;
- bool bRes = theBlock.AddFrame(track, timecode, buffer, lacing);
+ const bool bRes = theBlock.AddFrame(track, timecode, buffer, lacing);
auto & thePastRef = GetChild<KaxReferenceBlock>(*this);
thePastRef.SetReferencedBlock(PastBlock);
assert(ParentCluster != nullptr);
theBlock.SetParent(*ParentCluster);
ParentTrack = &track;
- bool bRes = theBlock.AddFrame(track, timecode, buffer, lacing);
+ bool const bRes = theBlock.AddFrame(track, timecode, buffer, lacing);
auto & thePastRef = GetChild<KaxReferenceBlock>(*this);
thePastRef.SetReferencedBlock(PastBlock);
assert(ParentCluster != nullptr);
theBlock.SetParent(*ParentCluster);
ParentTrack = &track;
- bool bRes = theBlock.AddFrame(track, timecode, buffer, lacing);
+ const bool bRes = theBlock.AddFrame(track, timecode, buffer, lacing);
if (PastBlock != nullptr) {
auto & thePastRef = GetChild<KaxReferenceBlock>(*this);
uint64 KaxBlockGroup::GlobalTimecode() const
{
assert(ParentCluster != nullptr); // impossible otherwise
- KaxInternalBlock & MyBlock = *static_cast<KaxBlock *>(this->FindElt(EBML_INFO(KaxBlock)));
+ const auto& MyBlock = *static_cast<KaxBlock *>(this->FindElt(EBML_INFO(KaxBlock)));
return MyBlock.GlobalTimecode();
}
uint16 KaxBlockGroup::TrackNumber() const
{
- KaxInternalBlock & MyBlock = *static_cast<KaxBlock *>(this->FindElt(EBML_INFO(KaxBlock)));
+ const auto& MyBlock = *static_cast<KaxBlock *>(this->FindElt(EBML_INFO(KaxBlock)));
return MyBlock.TrackNum();
}
void KaxBlockGroup::ReleaseFrames()
{
- KaxInternalBlock & MyBlock = *static_cast<KaxBlock *>(this->FindElt(EBML_INFO(KaxBlock)));
+ auto& MyBlock = *static_cast<KaxBlock *>(this->FindElt(EBML_INFO(KaxBlock)));
MyBlock.ReleaseFrames();
}
void KaxBlockGroup::SetBlockDuration(uint64 TimeLength)
{
assert(ParentTrack != nullptr);
- int64 scale = ParentTrack->GlobalTimecodeScale();
- KaxBlockDuration & myDuration = *static_cast<KaxBlockDuration *>(FindFirstElt(EBML_INFO(KaxBlockDuration), true));
+ const int64 scale = ParentTrack->GlobalTimecodeScale();
+ auto& myDuration = *static_cast<KaxBlockDuration *>(FindFirstElt(EBML_INFO(KaxBlockDuration), true));
*(static_cast<EbmlUInteger *>(&myDuration)) = TimeLength / static_cast<uint64>(scale);
}
// 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(EBML_INFO(KaxTracks)));
+ const auto& MyTracks = *static_cast<KaxTracks *>(ParentSegment->FindElt(EBML_INFO(KaxTracks)));
for (auto&& Trk : MyTracks) {
if (EbmlId(*Trk) == EBML_ID(KaxTrackEntry)) {
- KaxTrackEntry & entry = *static_cast<KaxTrackEntry *>(Trk);
+ const auto& entry = *static_cast<KaxTrackEntry *>(Trk);
auto tracknum = static_cast<uint32>(entry.TrackNumber());
auto track = std::find_if(ElementList.begin(), ElementList.end(), [=](EbmlElement *element)
{ return EbmlId(*element) == EBML_ID(KaxBlockGroup) && static_cast<KaxBlockGroup *>(element)->TrackNumber() == tracknum; });
// 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(EBML_INFO(KaxTracks)));
+ const auto& MyTracks = *static_cast<KaxTracks *>(ParentSegment->FindElt(EBML_INFO(KaxTracks)));
for (auto&& Trk : MyTracks) {
if (EbmlId(*Trk) == EBML_ID(KaxTrackEntry)) {
- KaxTrackEntry & entry = *static_cast<KaxTrackEntry *>(Trk);
+ const auto& entry = *static_cast<KaxTrackEntry *>(Trk);
auto tracknum = static_cast<uint32>(entry.TrackNumber());
for (Index = 0; Index<Blobs.size(); Index++) {
if (static_cast<KaxInternalBlock&>(*Blobs[Index]).TrackNum() == tracknum)
*/
int16 KaxCluster::GetBlockLocalTimecode(uint64 aGlobalTimecode) const
{
- int64 TimecodeDelay = (static_cast<int64>(aGlobalTimecode) - static_cast<int64>(GlobalTimecode())) / static_cast<int64>(GlobalTimecodeScale());
+ const int64 TimecodeDelay = (static_cast<int64>(aGlobalTimecode) - static_cast<int64>(GlobalTimecode())) / static_cast<int64>(GlobalTimecodeScale());
assert(TimecodeDelay >= int16(0x8000) && TimecodeDelay <= int16(0x7FFF));
return static_cast<int16>(TimecodeDelay);
}
bool KaxCues::AddBlockBlob(const KaxBlockBlob & BlockReference)
{
// Do not add the element if it's already present.
- bool present = std::any_of(myTempReferences.begin(), myTempReferences.end(),
- [&](const KaxBlockBlob *myTempReference) { return myTempReference == &BlockReference; });
+ const auto& pr = myTempReferences;
+ const bool present = std::find(pr.begin(), pr.end(), &BlockReference) != pr.end();
if (present) {
return true;
}
void KaxCues::PositionSet(const KaxBlockBlob & BlockReference)
{
// look for the element in the temporary references
- auto it = std::find_if(myTempReferences.begin(), myTempReferences.end(),
- [&](const KaxBlockBlob *myTempReference){ return myTempReference == &BlockReference; });
+ const auto& pr = myTempReferences;
+ auto it = std::find(pr.begin(), pr.end(), &BlockReference);
- if (it != myTempReferences.end()) {
+ if (it != pr.end()) {
// found, now add the element to the entry list
auto & NewPoint = AddNewChild<KaxCuePoint>(*this);
NewPoint.PositionSet(BlockReference, GlobalTimecodeScale());
*/
const KaxCuePoint * KaxCues::GetTimecodePoint(uint64 aTimecode) const
{
- uint64 TimecodeToLocate = aTimecode / GlobalTimecodeScale();
+ const uint64 TimecodeToLocate = aTimecode / GlobalTimecodeScale();
const KaxCuePoint * aPointPrev = nullptr;
uint64 aPrevTime = 0;
uint64 aNextTime = EBML_PRETTYLONGINT(0xFFFFFFFFFFFF);
{ return (EbmlId(*Elt) == EBML_ID(KaxSeekID)); });
if (it != aElt->end()) {
aId = static_cast<KaxSeekID*>(*it);
- EbmlId aEbmlId(aId->GetBuffer(), aId->GetSize());
+ const auto aEbmlId = EbmlId(aId->GetBuffer(), aId->GetSize());
if (aEbmlId == EBML_INFO_ID(Callbacks)) {
return aElt;
}
auto _Id = static_cast<KaxSeekID*>(FindFirstElt(EBML_INFO(KaxSeekID)));
if (_Id == nullptr)
return false;
- EbmlId aEbmlId(_Id->GetBuffer(), _Id->GetSize());
+ const auto aEbmlId = EbmlId(_Id->GetBuffer(), _Id->GetSize());
return (aId == aEbmlId);
}
auto _IdB = static_cast<KaxSeekID*>(aPoint.FindFirstElt(EBML_INFO(KaxSeekID)));
if (_IdB == nullptr)
return false;
- EbmlId aEbmlIdA(_IdA->GetBuffer(), _IdA->GetSize());
- EbmlId aEbmlIdB(_IdB->GetBuffer(), _IdB->GetSize());
+ const auto aEbmlIdA = EbmlId(_IdA->GetBuffer(), _IdA->GetSize());
+ const auto aEbmlIdB = EbmlId(_IdB->GetBuffer(), _IdB->GetSize());
return (aEbmlIdA == aEbmlIdB);
}