From 3a0b6c24dd1a66858a3e9ac541093040cf80aa0e Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 1 Oct 2020 19:58:03 +0200 Subject: [PATCH] Include more details into track description * Usually the profile and level are interesting and don't take much space * Add also a short description if it is too long after all --- CMakeLists.txt | 4 +-- abstracttrack.cpp | 86 +++++++++++++++++++++++++++++++++-------------- abstracttrack.h | 4 +++ 3 files changed, 67 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4a7480..84f110b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,8 +9,8 @@ set(META_APP_AUTHOR "Martchus") set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") set(META_APP_DESCRIPTION "C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags") set(META_VERSION_MAJOR 9) -set(META_VERSION_MINOR 2) -set(META_VERSION_PATCH 1) +set(META_VERSION_MINOR 3) +set(META_VERSION_PATCH 0) set(META_REQUIRED_CPP_UNIT_VERSION 1.14.0) set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON) diff --git a/abstracttrack.cpp b/abstracttrack.cpp index 92c1fbc..10b0559 100644 --- a/abstracttrack.cpp +++ b/abstracttrack.cpp @@ -144,55 +144,91 @@ string AbstractTrack::label() const return ss.str(); } -/*! - * \brief Returns a short description about the track. - * - * The description contains the abbreviated format and further information depending on the media - * type (eg. display size in case of video, language in case of audio/text). It is intended to be joined - * with descriptions of other tracks to get a short technical description about the file. - * - * Examples (exact format might change in the future!): - * - H.264-720p - * - HE-AAC-6ch-eng - */ -string AbstractTrack::description() const +/// \cond +string AbstractTrack::makeDescription(bool verbose) const { // use abbreviated format - const char *format = m_format.shortAbbreviation(); - if (!format || !*format) { + const auto format = MediaFormat(m_format.general, verbose ? m_format.sub : 0, verbose ? m_format.extension : 0); + const char *formatName = format.shortAbbreviation(); + if (!formatName || !*formatName) { // fall back to media type name if no abbreviation available - format = mediaTypeName(); + formatName = mediaTypeName(); } - // find additional info - const char *additionalInfo = nullptr; + // find additional info and level + const char *additionalInfoRef = nullptr; + string level; switch (m_mediaType) { case MediaType::Video: if (!displaySize().isNull()) { - additionalInfo = displaySize().abbreviation(); + additionalInfoRef = displaySize().abbreviation(); } else if (!pixelSize().isNull()) { - additionalInfo = pixelSize().abbreviation(); + additionalInfoRef = pixelSize().abbreviation(); + } + if (verbose) { + switch (format.general) { + case GeneralMediaFormat::Mpeg4Video: + case GeneralMediaFormat::Avc: + case GeneralMediaFormat::Hevc: + if (version()) { + level = "@L" + numberToString(version()); + } + break; + default: + ; + } } break; case MediaType::Audio: case MediaType::Text: if (channelCount()) { if (!language().empty() && language() != "und") { - return argsToString(format, '-', channelCount(), "ch-", language()); + return argsToString(formatName, '-', channelCount(), "ch-", language()); } else { - return argsToString(format, '-', channelCount(), 'c', 'h'); + return argsToString(formatName, '-', channelCount(), 'c', 'h'); } } else if (!language().empty() && language() != "und") { - additionalInfo = language().data(); + additionalInfoRef = language().data(); } break; default:; } - if (additionalInfo) { - return argsToString(format, '-', additionalInfo); + if (additionalInfoRef) { + return argsToString(formatName, level, '-', additionalInfoRef); } - return format; + return argsToString(formatName, level); +} +/// \endcond + +/*! + * \brief Returns a description about the track. + * + * The description contains the abbreviated format and further information depending on the media + * type (eg. display size in case of video, language in case of audio/text). It is intended to be joined + * with descriptions of other tracks to get a short technical description about the file. + * + * Examples (exact format might change in the future!): + * - H.264-High-10@5.1-720p + * - HE-AAC-6ch-eng + */ +string AbstractTrack::description() const +{ + return makeDescription(true); +} + +/*! + * \brief Returns a short description about the track. + * + * See description() for details. + * + * Examples (exact format might change in the future!): + * - H.264-720p + * - HE-AAC-6ch-eng + */ +string AbstractTrack::shortDescription() const +{ + return makeDescription(false); } /*! diff --git a/abstracttrack.h b/abstracttrack.h index f943656..d1e1e6f 100644 --- a/abstracttrack.h +++ b/abstracttrack.h @@ -106,6 +106,7 @@ public: const Margin &cropping() const; std::string label() const; std::string description() const; + std::string shortDescription() const; void parseHeader(Diagnostics &diag); bool isHeaderValid() const; @@ -165,6 +166,9 @@ protected: bool m_usedWhenPreviewing; std::uint32_t m_colorSpace; Margin m_cropping; + +private: + std::string makeDescription(bool verbose) const; }; /*!