diff options
Diffstat (limited to 'fed57c8cf746812bdc93704af7d0ebcfa69a5156.patch')
-rw-r--r-- | fed57c8cf746812bdc93704af7d0ebcfa69a5156.patch | 214 |
1 files changed, 214 insertions, 0 deletions
diff --git a/fed57c8cf746812bdc93704af7d0ebcfa69a5156.patch b/fed57c8cf746812bdc93704af7d0ebcfa69a5156.patch new file mode 100644 index 000000000000..0a7b0fafacc3 --- /dev/null +++ b/fed57c8cf746812bdc93704af7d0ebcfa69a5156.patch @@ -0,0 +1,214 @@ +From fed57c8cf746812bdc93704af7d0ebcfa69a5156 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= <mumei6102@gmail.com> +Date: Mon, 29 Jan 2024 20:00:41 +0100 +Subject: [PATCH] TagLib: Add support for 2.0, remove support for 1.9 and 1.10 + +Closes #680 +--- + README.md | 2 +- + src/gui/TagEditor.cpp | 78 ++++++++----------------------------------- + 2 files changed, 15 insertions(+), 65 deletions(-) + +diff --git a/README.md b/README.md +index 81b72f9e6..34025d084 100644 +--- a/README.md ++++ b/README.md +@@ -198,7 +198,7 @@ For CMake build be sure that you have CMake 3.9 or higher. + - libavdevice - for FFmpeg module only, optional (enabled on Linux as default), + + #### Important: +-- TagLib >= 1.9, ++- TagLib >= 1.11, + - libass - for OSD and non-graphical subtitles. + + #### For modules (some of them can be automatically disabled if not found): +diff --git a/src/gui/TagEditor.cpp b/src/gui/TagEditor.cpp +index d1f101b7d..55756cd60 100644 +--- a/src/gui/TagEditor.cpp ++++ b/src/gui/TagEditor.cpp +@@ -21,19 +21,12 @@ + #include <Functions.hpp> + #include <Main.hpp> + +-#define TAGLIB_VERSION ((TAGLIB_MAJOR_VERSION << 8) | TAGLIB_MINOR_VERSION) +-#define TAGLIB1B (TAGLIB_VERSION >= 0x10B) +- + #ifdef TAGLIB_FULL_INCLUDE_PATH + #include <taglib/taglib.h> + #else + #include <taglib.h> + #endif + +-#if TAGLIB_VERSION < 0x109 +- #error Taglib 1.9 or newer is needed! +-#endif +- + #ifdef TAGLIB_FULL_INCLUDE_PATH + #include <taglib/trueaudiofile.h> + #include <taglib/oggflacfile.h> +@@ -54,6 +47,7 @@ + #include <taglib/itfile.h> + #include <taglib/xmfile.h> + #include <taglib/opusfile.h> ++ #include <taglib/attachedpictureframe.h> + #else + #include <trueaudiofile.h> + #include <oggflacfile.h> +@@ -74,6 +68,7 @@ + #include <itfile.h> + #include <xmfile.h> + #include <opusfile.h> ++ #include <attachedpictureframe.h> + #endif + using namespace TagLib; + +@@ -136,17 +131,9 @@ static void removeXiphComment(Ogg::XiphComment *xiphComment) + { + if (xiphComment) + { +-#if TAGLIB1B + xiphComment->removeAllPictures(); + xiphComment->removeAllFields(); +-#else +- const Ogg::FieldListMap &fieldListMap = xiphComment->fieldListMap(); +- for (Ogg::FieldListMap::ConstIterator it = fieldListMap.begin(); it != fieldListMap.end(); ++it) +- { +- if (xiphComment->contains(it->first)) +- xiphComment->removeField(it->first); +- } +-#endif ++ + } + } + +@@ -312,10 +299,10 @@ bool TagEditor::open(const QString &fileName) + } + else if (instanceOf(file, MP4::File)) + { +- MP4::ItemListMap &itemListMap = ((MP4::File &)file).tag()->itemListMap(); +- MP4::ItemListMap::ConstIterator it = itemListMap.find("covr"); ++ auto &&itemMap = ((MP4::File &)file).tag()->itemMap(); ++ auto it = itemMap.find("covr"); + pictureB->setEnabled(true); +- if (it != itemListMap.end()) ++ if (it != itemMap.end()) + { + MP4::CoverArtList coverArtList = it->second.toCoverArtList(); + if (!coverArtList.isEmpty()) +@@ -355,25 +342,12 @@ bool TagEditor::open(const QString &fileName) + { + FLAC::Picture *flacPicture = nullptr; + pictureB->setEnabled(true); +-#if TAGLIB1B + const List<FLAC::Picture *> pictures = xiphComment->pictureList(); + if (!pictures.isEmpty()) + { + flacPicture = pictures[0]; + hasTags = true; + } +-#else +- const Ogg::FieldListMap &fieldListMap = xiphComment->fieldListMap(); +- Ogg::FieldListMap::ConstIterator it = fieldListMap.find("METADATA_BLOCK_PICTURE"); +- FLAC::Picture tmpFlacPicture; +- if (it != fieldListMap.end() && !it->second.isEmpty()) +- { +- /* OGG picture and FLAC picture are the same except OGG picture is encoded into Base64 */ +- const QByteArray pict_frame_decoded = QByteArray::fromBase64(it->second.front().toCString()); +- if (tmpFlacPicture.parse(ByteVector(pict_frame_decoded.data(), pict_frame_decoded.size()))) +- flacPicture = &tmpFlacPicture; +- } +-#endif + if (flacPicture) + { + pictureMimeType = flacPicture->mimeType().toCString(); +@@ -489,12 +463,12 @@ bool TagEditor::save() + } + else if (instanceOf(file, MP4::File)) + { +- MP4::ItemListMap &itemListMap = ((MP4::File &)file).tag()->itemListMap(); +- if (itemListMap.contains("covr")) +- itemListMap.erase("covr"); ++ auto &itemMap = const_cast<MP4::ItemMap &>(((MP4::File &)file).tag()->itemMap()); ++ if (itemMap.contains("covr")) ++ itemMap.erase("covr"); + if (hasPicture) + { +- MP4::CoverArt::Format format = (MP4::CoverArt::Format)0; ++ auto format = MP4::CoverArt::Format::Unknown; + if (pictureMimeType == "image/jpeg") + format = MP4::CoverArt::JPEG; + else if (pictureMimeType == "image/png") +@@ -503,11 +477,11 @@ bool TagEditor::save() + format = MP4::CoverArt::BMP; + else if (pictureMimeType == "image/gif") + format = MP4::CoverArt::GIF; +- if (format) ++ if (format != MP4::CoverArt::Format::Unknown) + { + MP4::CoverArtList coverArtList; + coverArtList.append(MP4::CoverArt(format, *picture)); +- itemListMap.insert("covr", coverArtList); ++ itemMap.insert("covr", coverArtList); + } + } + mustSave = true; +@@ -525,19 +499,9 @@ bool TagEditor::save() + flacPicture->setType(FLAC::Picture::FrontCover); + flacPicture->setData(*picture); + } +-#if TAGLIB1B + xiphComment->removeAllPictures(); + if (flacPicture) + xiphComment->addPicture(flacPicture); +-#else +- xiphComment->removeField("METADATA_BLOCK_PICTURE"); +- if (flacPicture) +- { +- const ByteVector pict_data = flacPicture->render(); +- xiphComment->addField("METADATA_BLOCK_PICTURE", QByteArray::fromRawData(pict_data.data(), pict_data.size()).toBase64().data()); +- delete flacPicture; +- } +-#endif + mustSave = true; + } + } +@@ -557,7 +521,7 @@ bool TagEditor::save() + else if (instanceOf(file, APE::File)) + ((APE::File &)file).strip(); + else if (instanceOf(file, MP4::File)) +- ((MP4::File &)file).tag()->itemListMap().clear(); ++ const_cast<MP4::ItemMap &>(((MP4::File &)file).tag()->itemMap()).clear(); + else if (instanceOf(file, ASF::File)) + ((ASF::File &)file).tag()->attributeListMap().clear(); + else if (isOgg(file)) +@@ -591,7 +555,7 @@ bool TagEditor::save() + else if (instanceOf(file, XM::File)) + modTag = ((XM::File &)file).tag(); + if (modTag) +- modTag->setTrackerName(String::null); ++ modTag->setTrackerName(String()); + } + } + +@@ -601,21 +565,7 @@ bool TagEditor::save() + FLAC::File &flacF = (FLAC::File &)file; + if (flacF.hasID3v1Tag() || flacF.hasID3v2Tag()) + { +-#if TAGLIB1B + flacF.strip(FLAC::File::ID3v1 | FLAC::File::ID3v2); +-#else +- #ifdef Q_OS_WIN +- const FileName fName = file.name(); //Class with "std::string" +- #else +- const QByteArray fName = file.name(); //Raw pointer, so copy it +- #endif +- result = fRef->save(); +- delete fRef; +- fRef = nullptr; +- if (result) +- result = MPEG::File(fName, false).save(MPEG::File::NoTags); +- mustSave = false; +-#endif + } + } + |