tagparser/signature.cpp

630 lines
18 KiB
C++
Raw Normal View History

2015-09-06 19:57:33 +02:00
#include "./signature.h"
2016-05-26 01:59:22 +02:00
#include "./matroska/matroskatagid.h"
2015-04-22 19:22:01 +02:00
#include <c++utilities/conversion/binaryconversion.h>
2019-03-13 19:06:42 +01:00
#include <cstdint>
2019-06-10 22:49:11 +02:00
using namespace CppUtilities;
2015-04-22 19:22:01 +02:00
namespace TagParser {
2015-04-22 19:22:01 +02:00
/*!
* \brief Holds 64-bit signatures.
*/
2019-03-13 19:06:42 +01:00
enum Sig64 : std::uint64_t {
ApeTag = 0x4150455441474558ul, // APETAGEX
Ar = 0x213C617263683E0A,
2015-04-22 19:22:01 +02:00
Asf1 = 0x3026B2758E66CF11ul,
Asf2 = 0xA6D900AA0062CE6Cul,
Png = 0x89504E470D0A1A0Aul,
RiffAvi = 0x415649204C495354ul,
2017-09-03 18:26:32 +02:00
YUV4Mpeg2 = 0x595556344D504547ul,
2015-04-22 19:22:01 +02:00
};
/*!
* \brief Holds 52-bit signatures.
*/
2019-03-13 19:06:42 +01:00
enum Sig56 : std::uint64_t {
2015-04-22 19:22:01 +02:00
Rar = 0x526172211A0700ul,
};
/*!
* \brief Holds 48-bit signatures.
*/
2019-03-13 19:06:42 +01:00
enum Sig48 : std::uint64_t {
2015-04-22 19:22:01 +02:00
Gif87a = 0x474946383761ul,
Gif89a = 0x474946383961ul,
2017-08-17 19:04:19 +02:00
SevenZ = 0x377ABCAF271Cul,
Xz = 0xFD377A585A00ul,
2015-04-22 19:22:01 +02:00
};
2022-08-17 23:06:09 +02:00
/*!
* \brief Holds 40-bit signatures.
*/
enum Sig40 : std::uint64_t {
Aiff = 0x464F524D00ul,
};
2015-04-22 19:22:01 +02:00
/*!
* \brief Holds 32-bit signatures.
*/
2019-03-13 19:06:42 +01:00
enum Sig32 : std::uint32_t {
2016-08-07 20:48:23 +02:00
Dirac = 0x42424344u,
2015-04-22 19:22:01 +02:00
Elf = 0x7F454C46u,
2016-05-16 20:56:53 +02:00
Flac = 0x664C6143u,
2018-07-28 14:56:00 +02:00
Ivf = 0x444B4946u,
2015-04-22 19:22:01 +02:00
JavaClassFile = 0xCAFEBABEu,
Ebml = 0x1A45DFA3u,
2018-08-29 22:32:11 +02:00
Midi = 0x4D546864u,
MonkeysAudio = 0x4D414320u,
2015-04-22 19:22:01 +02:00
Mp4 = 0x66747970u,
Ogg = 0x4F676753u,
PhotoshopDocument = 0x38425053u,
QuickTime = 0x6D6F6F76u,
2015-04-22 19:22:01 +02:00
Riff = 0x52494646u,
2018-03-07 01:17:50 +01:00
RiffWave = 0x57415645u,
2015-04-22 19:22:01 +02:00
TiffBigEndian = 0x4D4D002Au,
TiffLittleEndian = 0x49492A00u,
Utf32Text = 0xFFFE0000u,
2017-10-29 17:40:39 +01:00
WavPack = 0x7776706Bu,
2015-04-22 19:22:01 +02:00
WindowsIcon = 0x00000100u,
Lzip = 0x4C5A4950u,
Zip1 = 0x504B0304u,
Zip2 = 0x504B0506u,
Zip3 = 0x504B0708u,
2023-03-05 22:37:14 +01:00
Zstd = 0x28b52ffdu,
2015-04-22 19:22:01 +02:00
};
/*!
* \brief Holds 24-bit signatures.
*/
2019-03-13 19:06:42 +01:00
enum Sig24 : std::uint32_t {
2015-04-22 19:22:01 +02:00
Bzip2 = 0x425A68u,
2016-05-05 23:11:48 +02:00
Flv = 0x464C56u,
2015-04-22 19:22:01 +02:00
Gzip = 0x1F8B08u,
Id3v2 = 0x494433u,
2015-07-15 00:10:24 +02:00
Utf8Text = 0xEFBBBFu,
2015-04-22 19:22:01 +02:00
};
/*!
* \brief Holds 16-bit signatures.
*/
2019-03-13 19:06:42 +01:00
enum Sig16 : std::uint16_t {
2016-08-07 20:48:23 +02:00
Ac3 = 0x0B77u,
2015-07-15 00:10:24 +02:00
Adts = 0xFFF0u,
AdtsMask = 0xFFF6u,
2015-04-22 19:22:01 +02:00
Jpeg = 0xffd8u,
Lha = 0x1FA0u,
Lzw = 0x1F9Du,
MpegAudioFrames = 0x7FFu,
2015-04-22 19:22:01 +02:00
PortableExecutable = 0x4D5Au,
Utf16Text = 0xFFFEu,
WindowsBitmap = 0x424du,
};
/*!
* \brief Parses the signature read from the specified \a buffer.
* \param buffer Specifies the buffer to read the signature from.
* \param bufferSize Specifies the size of \a buffer.
* \return Returns the container format denoted by the signature. If the
* signature is unknown ContainerFormat::Unknown is returned.
*/
ContainerFormat parseSignature(std::string_view buffer)
2015-04-22 19:22:01 +02:00
{
// read signature
2019-03-13 19:06:42 +01:00
std::uint64_t sig = 0;
if (buffer.size() >= 8) {
sig = BE::toInt<std::uint64_t>(buffer.data());
} else if (buffer.size() >= 4) {
sig = BE::toInt<std::uint32_t>(buffer.data());
2015-04-22 19:22:01 +02:00
sig <<= 4;
} else if (buffer.size() >= 2) {
sig = BE::toInt<std::uint16_t>(buffer.data());
2015-04-22 19:22:01 +02:00
sig <<= 6;
} else {
return ContainerFormat::Unknown;
}
// return corresponding container format
2018-03-07 01:17:50 +01:00
switch (sig) { // check 64-bit signatures
case ApeTag:
return ContainerFormat::ApeTag;
case Ar:
return ContainerFormat::Ar;
2015-04-22 19:22:01 +02:00
case Asf1:
return ContainerFormat::Asf;
case Asf2:
return ContainerFormat::Asf;
case Png:
return ContainerFormat::Png;
2017-09-03 18:26:32 +02:00
case YUV4Mpeg2:
if (buffer.size() >= 10 && buffer[8] == 0x32 && buffer[9] == 0x20) {
2017-09-03 18:26:32 +02:00
return ContainerFormat::YUV4Mpeg2;
}
break;
2018-03-07 01:17:50 +01:00
default:;
2015-04-22 19:22:01 +02:00
}
2018-03-07 01:17:50 +01:00
switch (sig & 0x00000000FFFFFFFF) { // check 32-bit signatures @ bit 31
2015-04-22 19:22:01 +02:00
case Mp4:
return ContainerFormat::Mp4;
case QuickTime:
return ContainerFormat::QuickTime;
2018-03-07 01:17:50 +01:00
default:;
2015-04-22 19:22:01 +02:00
}
2018-03-07 01:17:50 +01:00
switch (sig >> 8) { // check 56-bit signatures
2015-04-22 19:22:01 +02:00
case Rar:
return ContainerFormat::Rar;
2018-03-07 01:17:50 +01:00
default:;
2015-04-22 19:22:01 +02:00
}
2018-03-07 01:17:50 +01:00
switch (sig >> 16) { // check 48-bit signatures
2015-04-22 19:22:01 +02:00
case Gif87a:
return ContainerFormat::Gif87a;
case Gif89a:
return ContainerFormat::Gif89a;
case SevenZ:
return ContainerFormat::SevenZ;
2017-08-17 19:04:19 +02:00
case Xz:
return ContainerFormat::Xz;
2018-03-07 01:17:50 +01:00
default:;
2015-04-22 19:22:01 +02:00
}
2022-08-17 23:06:09 +02:00
switch (sig >> 24) { // check 40-bit signatures
case Aiff:
return ContainerFormat::Aiff;
default:;
}
2018-03-07 01:17:50 +01:00
switch (sig >> 32) { // check 32-bit signatures
2016-08-07 20:48:23 +02:00
case Dirac:
return ContainerFormat::Dirac;
2015-04-22 19:22:01 +02:00
case Elf:
return ContainerFormat::Elf;
2016-05-16 20:56:53 +02:00
case Flac:
return ContainerFormat::Flac;
2018-07-28 14:56:00 +02:00
case Ivf:
return ContainerFormat::Ivf;
2015-04-22 19:22:01 +02:00
case JavaClassFile:
return ContainerFormat::JavaClassFile;
case Ebml:
return ContainerFormat::Ebml;
2018-08-29 22:32:11 +02:00
case Midi:
return ContainerFormat::Midi;
case MonkeysAudio:
return ContainerFormat::MonkeysAudio;
2015-04-22 19:22:01 +02:00
case Ogg:
return ContainerFormat::Ogg;
case PhotoshopDocument:
return ContainerFormat::PhotoshopDocument;
case Riff:
if (buffer.size() >= 16 && BE::toInt<std::uint64_t>(buffer.data() + 8) == Sig64::RiffAvi) {
2015-04-22 19:22:01 +02:00
return ContainerFormat::RiffAvi;
} else if (buffer.size() >= 12 && BE::toInt<std::uint32_t>(buffer.data() + 8) == RiffWave) {
2015-04-22 19:22:01 +02:00
return ContainerFormat::RiffWave;
} else {
return ContainerFormat::Riff;
}
case TiffBigEndian:
return ContainerFormat::TiffBigEndian;
case TiffLittleEndian:
return ContainerFormat::TiffLittleEndian;
case Utf32Text:
return ContainerFormat::Utf32Text;
2017-10-29 17:40:39 +01:00
case WavPack:
return ContainerFormat::WavPack;
2015-04-22 19:22:01 +02:00
case WindowsIcon:
return ContainerFormat::WindowsIcon;
case Lzip:
return ContainerFormat::Lzip;
case Zip1:
case Zip2:
case Zip3:
return ContainerFormat::Zip;
2023-03-05 22:37:14 +01:00
case Zstd:
return ContainerFormat::Zstd;
2018-03-07 01:17:50 +01:00
default:;
2015-04-22 19:22:01 +02:00
}
2018-03-07 01:17:50 +01:00
switch (sig >> 40) { // check 24-bit signatures
2015-04-22 19:22:01 +02:00
case Bzip2:
return ContainerFormat::Bzip2;
2016-05-05 23:11:48 +02:00
case Flv:
return ContainerFormat::FlashVideo;
2015-04-22 19:22:01 +02:00
case Gzip:
return ContainerFormat::Gzip;
case Id3v2:
2023-05-16 23:00:32 +02:00
return ContainerFormat::Id3v2Tag;
2015-04-22 19:22:01 +02:00
case Utf8Text:
return ContainerFormat::Utf8Text;
}
2018-03-07 01:17:50 +01:00
switch (sig >> 48) { // check 16-bit signatures
2016-08-07 20:48:23 +02:00
case Ac3:
return ContainerFormat::Ac3Frames;
2015-04-22 19:22:01 +02:00
case Jpeg:
return ContainerFormat::Jpeg;
case Lha:
return ContainerFormat::Lha;
case Lzw:
return ContainerFormat::Lzw;
case PortableExecutable:
return ContainerFormat::PortableExecutable;
case Utf16Text:
return ContainerFormat::Utf16Text;
case WindowsBitmap:
return ContainerFormat::WindowsBitmap;
2018-03-07 01:17:50 +01:00
default:;
2015-04-22 19:22:01 +02:00
}
// check other signatures
2018-03-07 01:17:50 +01:00
if (((sig >> 48) & AdtsMask) == Adts) {
2015-07-15 00:10:24 +02:00
return ContainerFormat::Adts;
}
2018-03-07 01:17:50 +01:00
if ((sig >> 53) == MpegAudioFrames) {
return ContainerFormat::MpegAudioFrames;
}
2015-04-22 19:22:01 +02:00
return ContainerFormat::Unknown;
}
/*!
* \brief Returns the abbreviation of the container format as C-style string considering
2016-08-07 20:48:23 +02:00
* the specified media type and version.
* \remarks The abbreviation might be used as file extension.
* \returns Returns an empty string if no abbreviation is available.
2015-04-22 19:22:01 +02:00
*/
std::string_view containerFormatAbbreviation(ContainerFormat containerFormat, MediaType mediaType, unsigned int version)
2015-04-22 19:22:01 +02:00
{
2018-03-07 01:17:50 +01:00
switch (containerFormat) {
case ContainerFormat::Ac3Frames:
return "ac3";
case ContainerFormat::Ar:
return "a";
case ContainerFormat::Asf:
return "asf";
case ContainerFormat::Dirac:
return "drc";
case ContainerFormat::Elf:
return "elf";
case ContainerFormat::Flac:
return "flac";
case ContainerFormat::FlashVideo:
return "flv";
2015-04-22 19:22:01 +02:00
case ContainerFormat::Gif87a:
2018-03-07 01:17:50 +01:00
case ContainerFormat::Gif89a:
return "gif";
2018-07-28 14:56:00 +02:00
case ContainerFormat::Ivf:
return "ivf";
2018-03-07 01:17:50 +01:00
case ContainerFormat::JavaClassFile:
return "class";
case ContainerFormat::Jpeg:
return "jpeg";
case ContainerFormat::Lha:
return "lzh";
case ContainerFormat::Lzw:
return "lzw";
2015-04-22 19:22:01 +02:00
case ContainerFormat::Mp4:
2018-03-07 01:17:50 +01:00
switch (mediaType) {
case MediaType::Audio:
2015-04-22 19:22:01 +02:00
return "m4a";
default:
return "mp4";
}
2016-01-17 19:34:36 +01:00
case ContainerFormat::Ogg:
2018-03-07 01:17:50 +01:00
switch (mediaType) {
case MediaType::Video:
2015-04-22 19:22:01 +02:00
return "ogv";
default:
2018-03-07 01:17:50 +01:00
switch (version) {
2016-01-17 19:34:36 +01:00
case static_cast<unsigned int>(GeneralMediaFormat::Opus):
return "opus";
2017-09-03 18:34:33 +02:00
case static_cast<unsigned int>(GeneralMediaFormat::Speex):
return "spx";
2016-01-17 19:34:36 +01:00
default:
return "ogg";
}
2015-04-22 19:22:01 +02:00
}
2018-03-07 01:17:50 +01:00
case ContainerFormat::PhotoshopDocument:
return "psd";
case ContainerFormat::Png:
return "png";
case ContainerFormat::PortableExecutable:
return "exe";
case ContainerFormat::Rar:
return "rar";
2015-04-22 19:22:01 +02:00
case ContainerFormat::Matroska:
2018-03-07 01:17:50 +01:00
switch (mediaType) {
case MediaType::Audio:
2015-04-22 19:22:01 +02:00
return "mka";
default:
return "mkv";
}
case ContainerFormat::MpegAudioFrames:
2018-03-07 01:17:50 +01:00
switch (version) {
2015-04-22 19:22:01 +02:00
case 1:
return "mp1";
case 2:
return "mp2";
default:
return "mp3";
}
2018-03-07 01:17:50 +01:00
case ContainerFormat::Riff:
return "riff";
case ContainerFormat::RiffWave:
return "wav";
case ContainerFormat::RiffAvi:
return "avi";
case ContainerFormat::Tar:
return "tar";
2015-04-22 19:22:01 +02:00
case ContainerFormat::TiffBigEndian:
2018-03-07 01:17:50 +01:00
case ContainerFormat::TiffLittleEndian:
return "tiff";
case ContainerFormat::WindowsBitmap:
return "bmp";
case ContainerFormat::WindowsIcon:
return "ico";
case ContainerFormat::Bzip2:
return "bz";
case ContainerFormat::Gzip:
return "gz";
case ContainerFormat::Lzip:
return "lz";
case ContainerFormat::QuickTime:
return "mov";
case ContainerFormat::Zip:
return "zip";
case ContainerFormat::SevenZ:
return "7z";
case ContainerFormat::Xz:
return "xz";
case ContainerFormat::YUV4Mpeg2:
return "y4m";
case ContainerFormat::WavPack:
return "wv";
case ContainerFormat::MonkeysAudio:
return "ape";
2018-08-29 22:32:11 +02:00
case ContainerFormat::Midi:
return "mid";
2022-08-17 23:06:09 +02:00
case ContainerFormat::Aiff:
return "aiff";
2023-03-05 22:37:14 +01:00
case ContainerFormat::Zstd:
return "zst";
2018-03-07 01:17:50 +01:00
default:
return "";
2015-04-22 19:22:01 +02:00
}
}
/*!
* \brief Returns the name of the specified container format as C-style string.
*
* Returns "unknown" if no name is available.
*/
std::string_view containerFormatName(ContainerFormat containerFormat)
2015-04-22 19:22:01 +02:00
{
2018-03-07 01:17:50 +01:00
switch (containerFormat) {
2016-08-07 20:48:23 +02:00
case ContainerFormat::Ac3Frames:
return "raw Dolby Digital";
2015-07-15 00:10:24 +02:00
case ContainerFormat::Adts:
return "Audio Data Transport Stream";
case ContainerFormat::Ar:
return "Archive (GNU ar)";
2015-04-22 19:22:01 +02:00
case ContainerFormat::Asf:
return "Advanced Systems Format";
2016-08-07 20:48:23 +02:00
case ContainerFormat::Dirac:
return "raw Dirac";
2015-04-22 19:22:01 +02:00
case ContainerFormat::Elf:
return "Executable and Linkable Format";
2016-05-16 20:56:53 +02:00
case ContainerFormat::Flac:
return "raw Free Lossless Audio Codec frames";
2016-05-05 23:11:48 +02:00
case ContainerFormat::FlashVideo:
return "Flash Video";
2015-04-22 19:22:01 +02:00
case ContainerFormat::Gif87a:
case ContainerFormat::Gif89a:
return "Graphics Interchange Format";
2018-07-28 14:56:00 +02:00
case ContainerFormat::Ivf:
return "IVF";
2015-04-22 19:22:01 +02:00
case ContainerFormat::JavaClassFile:
return "Java class file";
case ContainerFormat::Jpeg:
return "JPEG File Interchange Format";
case ContainerFormat::Lha:
return "LHA compressed file";
case ContainerFormat::Lzw:
return "LZW compressed file";
case ContainerFormat::Mp4:
return "MPEG-4 Part 14";
case ContainerFormat::Ogg:
return "Ogg transport bitstream";
case ContainerFormat::PhotoshopDocument:
return "Photoshop document";
case ContainerFormat::Png:
return "Portable Network Graphics";
case ContainerFormat::PortableExecutable:
return "Portable Executable";
case ContainerFormat::Rar:
return "RAR Archive";
case ContainerFormat::Ebml:
return "EBML";
case ContainerFormat::Matroska:
return "Matroska";
case ContainerFormat::Webm:
return "WebM";
case ContainerFormat::MpegAudioFrames:
return "MPEG-1 Layer 1/2/3 frames";
case ContainerFormat::Riff:
return "Resource Interchange File Format";
case ContainerFormat::RiffWave:
return "RIFF/WAVE";
case ContainerFormat::RiffAvi:
return "RIFF/Audio Video Interleave";
case ContainerFormat::Tar:
return "TAR archive";
2015-04-22 19:22:01 +02:00
case ContainerFormat::TiffBigEndian:
case ContainerFormat::TiffLittleEndian:
return "Tagged Image File Format";
case ContainerFormat::Utf16Text:
return "UTF-16 text";
case ContainerFormat::Utf32Text:
return "UTF-32 text";
case ContainerFormat::Utf8Text:
return "UTF-8 text";
2017-10-29 17:40:39 +01:00
case ContainerFormat::WavPack:
return "WavPack";
2015-04-22 19:22:01 +02:00
case ContainerFormat::WindowsBitmap:
return "Microsoft Windows Bitmap";
case ContainerFormat::WindowsIcon:
return "Microsoft Windows Icon";
case ContainerFormat::Bzip2:
return "bzip2 compressed file";
case ContainerFormat::Gzip:
return "gzip compressed file";
case ContainerFormat::Lzip:
return "lzip compressed file";
case ContainerFormat::SevenZ:
return "7z archive";
case ContainerFormat::QuickTime:
return "Quick Time";
2017-08-17 19:04:19 +02:00
case ContainerFormat::Xz:
return "xz compressed file";
2017-09-03 18:26:32 +02:00
case ContainerFormat::YUV4Mpeg2:
return "YUV4MPEG2";
case ContainerFormat::Zip:
return "ZIP archive";
case ContainerFormat::MonkeysAudio:
return "Monkey's Audio";
2018-08-29 22:32:11 +02:00
case ContainerFormat::Midi:
return "MIDI";
2022-08-17 23:06:09 +02:00
case ContainerFormat::Aiff:
return "Audio Interchange File Format";
2023-03-05 22:37:14 +01:00
case ContainerFormat::Zstd:
return "Zstandard compressed file";
2023-05-16 23:00:32 +02:00
case ContainerFormat::Id3v2Tag:
2023-05-06 11:12:08 +02:00
return "ID3v2 tag";
case ContainerFormat::ApeTag:
return "APE tag";
2015-04-22 19:22:01 +02:00
default:
return "unknown";
}
}
/*!
* \brief Returns the subversion of the container format as C-style string.
*
* Returns an empty string if there is no subversion available.
*/
std::string_view containerFormatSubversion(ContainerFormat containerFormat)
2015-04-22 19:22:01 +02:00
{
2018-03-07 01:17:50 +01:00
switch (containerFormat) {
2015-04-22 19:22:01 +02:00
case ContainerFormat::Gif87a:
return "87a";
case ContainerFormat::Gif89a:
return "89a";
case ContainerFormat::TiffBigEndian:
return "big endian";
case ContainerFormat::TiffLittleEndian:
return "little endian";
default:
return "";
}
}
/*!
* \brief Returns the MIME-type of the container format as C-style string.
*
* Returns an empty string if there is no MIME-type available.
*/
std::string_view containerMimeType(ContainerFormat containerFormat, MediaType mediaType)
2015-04-22 19:22:01 +02:00
{
2018-03-07 01:17:50 +01:00
switch (containerFormat) {
2016-08-07 20:48:23 +02:00
case ContainerFormat::Ac3Frames:
return "audio/ac3";
2015-04-22 19:22:01 +02:00
case ContainerFormat::Asf:
return "video/x-ms-asf";
2016-05-16 20:56:53 +02:00
case ContainerFormat::Flac:
return "audio/flac";
2016-05-05 23:11:48 +02:00
case ContainerFormat::FlashVideo:
return "video/x-flv";
2015-04-22 19:22:01 +02:00
case ContainerFormat::Gif87a:
case ContainerFormat::Gif89a:
return "image/gif";
case ContainerFormat::Jpeg:
return "image/jpeg";
case ContainerFormat::Png:
return "image/png";
case ContainerFormat::MpegAudioFrames:
return "audio/mpeg";
case ContainerFormat::Mp4:
2018-03-07 01:17:50 +01:00
switch (mediaType) {
case MediaType::Audio:
2015-04-22 19:22:01 +02:00
return "audio/mp4";
default:
return "video/mp4";
}
case ContainerFormat::Ogg:
2018-03-07 01:17:50 +01:00
switch (mediaType) {
case MediaType::Audio:
2015-04-22 19:22:01 +02:00
return "audio/ogg";
default:
return "video/ogg";
}
case ContainerFormat::Matroska:
2018-03-07 01:17:50 +01:00
switch (mediaType) {
case MediaType::Audio:
2015-04-22 19:22:01 +02:00
return "audio/x-matroska";
default:
return "video/x-matroska";
}
2018-08-29 22:32:11 +02:00
case ContainerFormat::Midi:
return "audio/midi";
2015-04-22 19:22:01 +02:00
case ContainerFormat::Bzip2:
return "application/x-bzip";
case ContainerFormat::Gzip:
return "application/gzip";
case ContainerFormat::Lha:
return "application/x-lzh-compressed";
case ContainerFormat::Rar:
return "application/x-rar-compressed";
case ContainerFormat::Lzip:
return "application/x-lzip";
case ContainerFormat::QuickTime:
return "video/quicktime";
2015-04-22 19:22:01 +02:00
case ContainerFormat::Zip:
return "application/zip";
case ContainerFormat::SevenZ:
return "application/x-7z-compressed";
2017-08-17 19:04:19 +02:00
case ContainerFormat::Xz:
return "application/x-xz";
2015-04-22 19:22:01 +02:00
case ContainerFormat::WindowsBitmap:
return "image/bmp";
case ContainerFormat::WindowsIcon:
return "image/vnd.microsoft.icon";
2023-03-05 22:37:14 +01:00
case ContainerFormat::Zstd:
return "application/zstd";
2015-04-22 19:22:01 +02:00
default:
return "";
}
}
2016-05-26 01:59:22 +02:00
/*!
* \brief Returns the general TagTargetLevel for the specified \a container format and raw \a targetLevelValue.
*/
2019-03-13 19:06:42 +01:00
TagTargetLevel containerTargetLevel(ContainerFormat containerFormat, std::uint64_t targetLevelValue)
2016-05-26 01:59:22 +02:00
{
2018-03-07 01:17:50 +01:00
switch (containerFormat) {
2016-05-26 01:59:22 +02:00
case ContainerFormat::Matroska:
case ContainerFormat::Webm:
return matroskaTagTargetLevel(targetLevelValue);
default:
return TagTargetLevel::Unspecified;
}
}
/*!
* \brief Returns the raw target level value for the specified \a containerFormat and general \a targetLevel.
*/
2019-03-13 19:06:42 +01:00
std::uint64_t containerTargetLevelValue(ContainerFormat containerFormat, TagTargetLevel targetLevel)
2016-05-26 01:59:22 +02:00
{
2018-03-07 01:17:50 +01:00
switch (containerFormat) {
2016-05-26 01:59:22 +02:00
case ContainerFormat::Matroska:
case ContainerFormat::Webm:
return matroskaTagTargetLevelValue(targetLevel);
default:
return 0;
}
}
2018-03-07 01:17:50 +01:00
} // namespace TagParser