From f39e8b4d8c6d405a7cb9966b59819165934012ec Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 8 Aug 2021 00:05:11 +0200 Subject: [PATCH] Avoid useless cases when assigning tag size (which is now std::uint64_t) --- matroska/matroskatag.cpp | 2 +- mp4/mp4tag.cpp | 2 +- vorbis/vorbiscomment.cpp | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/matroska/matroskatag.cpp b/matroska/matroskatag.cpp index f5d06bb..4af1532 100644 --- a/matroska/matroskatag.cpp +++ b/matroska/matroskatag.cpp @@ -110,13 +110,13 @@ KnownField MatroskaTag::internallyGetKnownField(const IdentifierType &id) const void MatroskaTag::parse(EbmlElement &tagElement, Diagnostics &diag) { static const string context("parsing Matroska tag"); + m_size = tagElement.totalSize(); tagElement.parse(diag); if (tagElement.totalSize() > numeric_limits::max()) { // FIXME: Support this? Likely not very useful in practise. diag.emplace_back(DiagLevel::Critical, "Matroska tag is too big.", context); throw NotImplementedException(); } - m_size = static_cast(tagElement.totalSize()); for (EbmlElement *child = tagElement.firstChild(); child; child = child->nextSibling()) { child->parse(diag); switch (child->id()) { diff --git a/mp4/mp4tag.cpp b/mp4/mp4tag.cpp index c554a3d..0eda6f5 100644 --- a/mp4/mp4tag.cpp +++ b/mp4/mp4tag.cpp @@ -328,13 +328,13 @@ bool Mp4Tag::hasField(KnownField field) const void Mp4Tag::parse(Mp4Atom &metaAtom, Diagnostics &diag) { static const string context("parsing MP4 tag"); + m_size = metaAtom.totalSize(); istream &stream = metaAtom.container().stream(); BinaryReader &reader = metaAtom.container().reader(); if (metaAtom.totalSize() > numeric_limits::max()) { diag.emplace_back(DiagLevel::Critical, "Can't handle such big \"meta\" atoms.", context); throw NotImplementedException(); } - m_size = static_cast(metaAtom.totalSize()); Mp4Atom *subAtom = nullptr; try { metaAtom.childById(Mp4AtomIds::HandlerReference, diag); diff --git a/vorbis/vorbiscomment.cpp b/vorbis/vorbiscomment.cpp index f6ee215..65c4ac8 100644 --- a/vorbis/vorbiscomment.cpp +++ b/vorbis/vorbiscomment.cpp @@ -134,7 +134,7 @@ template void VorbisComment::internalParse(StreamType &stream { // prepare parsing static const string context("parsing Vorbis comment"); - std::uint64_t startOffset = static_cast(stream.tellg()); + const auto startOffset = static_cast(stream.tellg()); try { // read signature: 0x3 + "vorbis" char sig[8]; @@ -180,7 +180,7 @@ template void VorbisComment::internalParse(StreamType &stream if (!(flags & VorbisCommentFlags::NoFramingByte)) { stream.ignore(); // skip framing byte } - m_size = static_cast(static_cast(stream.tellg()) - startOffset); + m_size = static_cast(stream.tellg()) - startOffset; // turn "YEAR" into "DATE" (unless "DATE" exists) // note: "DATE" is an official field and "YEAR" only an unofficial one but present in some files. In consistency with // MediaInfo and VLC player it is treated like "DATE" here. @@ -197,7 +197,7 @@ template void VorbisComment::internalParse(StreamType &stream throw InvalidDataException(); } } catch (const TruncatedDataException &) { - m_size = static_cast(static_cast(stream.tellg()) - startOffset); + m_size = static_cast(stream.tellg()) - startOffset; diag.emplace_back(DiagLevel::Critical, "Vorbis comment is truncated.", context); throw; }