From 5745632af7e8537c2f7a8ab17c52e86b03dd4588 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 16 May 2023 23:11:53 +0200 Subject: [PATCH] Move `maxFullParseSize()` to `MediaFileInfo` as non-static member --- matroska/matroskacontainer.cpp | 4 +--- matroska/matroskacontainer.h | 30 ------------------------------ mediafileinfo.cpp | 1 + mediafileinfo.h | 30 ++++++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/matroska/matroskacontainer.cpp b/matroska/matroskacontainer.cpp index d3ebd0e..266bf3c 100644 --- a/matroska/matroskacontainer.cpp +++ b/matroska/matroskacontainer.cpp @@ -35,8 +35,6 @@ namespace TagParser { * \brief Implementation of GenericContainer. */ -std::uint64_t MatroskaContainer::m_maxFullParseSize = 0x3200000; // FIXME v11: move to MediaFileInfo - /*! * \brief Constructs a new container for the specified \a fileInfo at the specified \a startOffset. */ @@ -564,7 +562,7 @@ void MatroskaContainer::internalParseHeader(Diagnostics &diag, AbortableProgress } } // -> stop if tracks and tags have been found or the file exceeds the max. size to fully process - if (((!m_tracksElements.empty() && !m_tagsElements.empty()) || fileInfo().size() > m_maxFullParseSize) + if (((!m_tracksElements.empty() && !m_tagsElements.empty()) || fileInfo().size() > fileInfo().maxFullParseSize()) && !m_segmentInfoElements.empty()) { goto finish; } diff --git a/matroska/matroskacontainer.h b/matroska/matroskacontainer.h index a1ccbe6..c1c0987 100644 --- a/matroska/matroskacontainer.h +++ b/matroska/matroskacontainer.h @@ -31,8 +31,6 @@ public: std::uint64_t maxSizeLength() const; const std::vector> &seekInfos() const; - static std::uint64_t maxFullParseSize(); - void setMaxFullParseSize(std::uint64_t maxFullParseSize); const std::vector> &editionEntires() const; MatroskaChapter *chapter(std::size_t index) override; std::size_t chapterCount() const override; @@ -72,7 +70,6 @@ private: std::vector> m_editionEntries; std::vector> m_attachments; std::size_t m_segmentCount; - static std::uint64_t m_maxFullParseSize; }; /*! @@ -99,33 +96,6 @@ inline const std::vector> &MatroskaContainer:: return m_seekInfos; } -/*! - * \brief Returns the maximal file size for a "full parse" in byte. - * - * The "Tags" element (which holds the tag information) is commonly at the end of a Matroska file. Hence the - * parser needs to walk through the entire file to find the tag information if no "SeekHead" element is present - * which might causes long loading times. To avoid this a maximal file size for a "full parse" can be specified. - * The disadvantage is that the parser relies on the presence of a SeekHead element on larger files to retrieve - * tag information. - * - * The default value is 50 MiB. - * - * \sa setMaxFullParseSize() - */ -inline std::uint64_t MatroskaContainer::maxFullParseSize() -{ - return m_maxFullParseSize; -} - -/*! - * \brief Sets the maximal file size for a "full parse" in byte. - * \sa maxFullParseSize() - */ -inline void MatroskaContainer::setMaxFullParseSize(std::uint64_t maxFullParseSize) -{ - m_maxFullParseSize = maxFullParseSize; -} - /*! * \brief Returns the edition entries. */ diff --git a/mediafileinfo.cpp b/mediafileinfo.cpp index 8ad6a9b..bae3c16 100644 --- a/mediafileinfo.cpp +++ b/mediafileinfo.cpp @@ -96,6 +96,7 @@ MediaFileInfo::MediaFileInfo(std::string &&path) , m_indexPosition(ElementPosition::BeforeData) , m_fileHandlingFlags(MediaFileHandlingFlags::ForceRewrite | MediaFileHandlingFlags::ForceTagPosition | MediaFileHandlingFlags::ForceIndexPosition | MediaFileHandlingFlags::NormalizeKnownTagFieldIds | MediaFileHandlingFlags::PreserveRawTimingValues) + , m_maxFullParseSize(0x3200000) { } diff --git a/mediafileinfo.h b/mediafileinfo.h index 4e90707..a25f1d5 100644 --- a/mediafileinfo.h +++ b/mediafileinfo.h @@ -187,6 +187,8 @@ public: void setIndexPosition(ElementPosition indexPosition); bool forceIndexPosition() const; void setForceIndexPosition(bool forceTagPosition); + std::uint64_t maxFullParseSize() const; + void setMaxFullParseSize(std::uint64_t maxFullParseSize); protected: void invalidated() override; @@ -230,6 +232,7 @@ private: ElementPosition m_tagPosition; ElementPosition m_indexPosition; MediaFileHandlingFlags m_fileHandlingFlags; + std::uint64_t m_maxFullParseSize; std::unique_ptr m_p; }; @@ -706,6 +709,33 @@ inline void MediaFileInfo::setForceIndexPosition(bool forceIndexPosition) CppUtilities::modFlagEnum(m_fileHandlingFlags, MediaFileHandlingFlags::ForceIndexPosition, forceIndexPosition); } +/*! + * \brief Returns the maximal file size for a "full parse" in byte. + * \remarks + * So far this is Matroska-specific: The "Tags" element (which holds the tag information) is commonly at the end + * of a Matroska file. Hence the parser needs to walk through the entire file to find the tag information if no + * "SeekHead" element is present which might causes long loading times. To avoid this a maximal file size for a + * "full parse" can be specified. The disadvantage is that the parser relies on the presence of a SeekHead element + * on larger files to retrieve tag information. + * + * The default value is 50 MiB. + * + * \sa setMaxFullParseSize() + */ +inline std::uint64_t MediaFileInfo::maxFullParseSize() const +{ + return m_maxFullParseSize; +} + +/*! + * \brief Sets the maximal file size for a "full parse" in byte. + * \sa maxFullParseSize() + */ +inline void MediaFileInfo::setMaxFullParseSize(std::uint64_t maxFullParseSize) +{ + m_maxFullParseSize = maxFullParseSize; +} + } // namespace TagParser #endif // TAG_PARSER_MEDIAINFO_H